├── settings.gradle ├── gradle ├── dependencies.gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── additional-artifacts.gradle └── release.gradle ├── src ├── test │ ├── resources │ │ ├── labels-get-byname.json │ │ ├── build-summary.json │ │ ├── pull-request-can-merge-succeed.json │ │ ├── accesskeys-list-empty.json │ │ ├── repository-page-empty.json │ │ ├── synchronize.json │ │ ├── version.json │ │ ├── accesskeys-get-wrong-id.json │ │ ├── files-page.json │ │ ├── labels-list.json │ │ ├── accesskeys-create-wrong-key.json │ │ ├── hook-settings.json │ │ ├── insight-report-error.json │ │ ├── postwebhook-errors.json │ │ ├── build-status-error.json │ │ ├── line-page.json │ │ ├── repository-webhook-errors.json │ │ ├── admin-list-user-by-group-error.json │ │ ├── build-status-post.json │ │ ├── project-not-exist.json │ │ ├── repository-labels.json │ │ ├── repository-hook-error.json │ │ ├── project-permission-group-error.json │ │ ├── project-permission-users-error.json │ │ ├── repository-permission-group-error.json │ │ ├── repository-permission-users-error.json │ │ ├── repository-not-exist.json │ │ ├── project.json │ │ ├── pull-request-settings-error.json │ │ ├── branch-default.json │ │ ├── branch.json │ │ ├── participants-error.json │ │ ├── project-create-fail.json │ │ ├── pull-request-not-exist.json │ │ ├── pull-request-participants-error.json │ │ ├── repository-permission-group.json │ │ ├── branch-permission-list-error.json │ │ ├── post-comment.json │ │ ├── project-permission-group.json │ │ ├── commit-error.json │ │ ├── pull-request-create-error.json │ │ ├── pull-request-page-error.json │ │ ├── tag.json │ │ ├── pull-request-activities-error.json │ │ ├── pull-request-delete-non-existent.json │ │ ├── branch-model-configuration-error.json │ │ ├── merge-failed-retry.json │ │ ├── pull-request-delete-merged.json │ │ ├── admin-delete-user-error.json │ │ ├── repository-webhook.json │ │ ├── sync-enabled.json │ │ ├── pull-request-comment-likes.json │ │ ├── admin-delete-user.json │ │ ├── pull-request-can-merge-fail.json │ │ ├── errors.json │ │ ├── repository-hook.json │ │ ├── repository-illegal-name.json │ │ ├── insight-report.json │ │ ├── participants.json │ │ ├── tag-page.json │ │ ├── branch-list-error.json │ │ ├── accesskeys-get-for-project.json │ │ ├── repository-webhook-page.json │ │ ├── postwebhook-create.json │ │ ├── postwebhook-update.json │ │ ├── project-permission-users.json │ │ ├── repository-permission-users.json │ │ ├── insight-report-page.json │ │ ├── pull-request-commits.json │ │ ├── admin-list-users.json │ │ ├── annotations.json │ │ ├── build-status.json │ │ ├── pull-request-participants.json │ │ ├── pull-request-create.json │ │ ├── branch-model-configuration.json │ │ ├── accesskeys-list-by-project.json │ │ ├── branch-model.json │ │ ├── commit.json │ │ ├── line-page-with-blame.json │ │ ├── project-page-truncated.json │ │ ├── repository.json │ │ ├── branch-permission-list.json │ │ ├── default-reviwers-create.json │ │ ├── task-open.json │ │ ├── task-resolved.json │ │ ├── project-page-full.json │ │ ├── repository-page-single.json │ │ ├── comments.json │ │ ├── postwebhooks-list.json │ │ ├── accesskeys-get-for-repository.json │ │ ├── pull-request-changes.json │ │ ├── admin-list-user-by-group.json │ │ ├── task.json │ │ ├── repository-hooks.json │ │ ├── accesskeys-list-by-repository.json │ │ ├── branch-list.json │ │ ├── repository-fork.json │ │ └── last-modified.json │ └── java │ │ └── com │ │ └── cdancy │ │ └── bitbucket │ │ └── rest │ │ ├── features │ │ ├── BitbucketClientMockTest.java │ │ ├── LabelsApiLiveTest.java │ │ └── SystemApiLiveTest.java │ │ └── BitbucketApiMetadataTest.java └── main │ └── java │ └── com │ └── cdancy │ └── bitbucket │ └── rest │ ├── domain │ ├── common │ │ ├── Value.java │ │ ├── Page.java │ │ ├── ErrorsHolder.java │ │ ├── LinksHolder.java │ │ ├── Veto.java │ │ ├── Links.java │ │ ├── RequestStatus.java │ │ └── Error.java │ ├── repository │ │ ├── Group.java │ │ ├── WebHookConfiguration.java │ │ ├── Permissions.java │ │ ├── MergeConfig.java │ │ ├── Hook.java │ │ └── HookDetails.java │ ├── comment │ │ ├── Parent.java │ │ ├── MinimalAnchor.java │ │ ├── Link.java │ │ └── PermittedOperations.java │ ├── pullrequest │ │ ├── ProjectKey.java │ │ ├── Properties.java │ │ ├── Parents.java │ │ ├── MinimalRepository.java │ │ ├── Person.java │ │ ├── Path.java │ │ └── MergeStatus.java │ ├── search │ │ ├── SearchQuery.java │ │ ├── SearchPathMatch.java │ │ ├── SearchHitContext.java │ │ └── SearchScope.java │ ├── insights │ │ ├── InsightReportDataLink.java │ │ └── AnnotationsResponse.java │ ├── file │ │ ├── Line.java │ │ ├── RawContent.java │ │ ├── FilesPage.java │ │ └── LastModified.java │ ├── defaultreviewers │ │ └── Scope.java │ ├── build │ │ ├── Summary.java │ │ └── Status.java │ ├── sshkey │ │ └── Key.java │ ├── branch │ │ ├── BranchConfiguration.java │ │ ├── BranchRestrictionType.java │ │ └── BranchModel.java │ ├── labels │ │ └── Label.java │ ├── activities │ │ ├── ActivitiesCommit.java │ │ └── ActivitiesPage.java │ ├── system │ │ └── Version.java │ ├── project │ │ └── ProjectPermissions.java │ └── admin │ │ └── UserPage.java │ ├── options │ ├── EditPullRequest.java │ ├── CreateKey.java │ ├── Context.java │ ├── CreateAnnotations.java │ ├── CreateAccessKey.java │ ├── CreateTask.java │ ├── CreateTag.java │ ├── CreateRepository.java │ ├── CreateBranch.java │ ├── CreateComment.java │ ├── CreateProject.java │ ├── CreateParticipants.java │ └── CreateBuildStatus.java │ ├── auth │ └── AuthenticationType.java │ ├── annotations │ └── Documentation.java │ ├── exception │ ├── MethodNotAllowedException.java │ ├── ForbiddenException.java │ └── UnsupportedMediaTypeException.java │ ├── config │ ├── BitbucketAuthenticationModule.java │ ├── BitbucketAuthenticationProvider.java │ └── BitbucketHttpApiModule.java │ ├── parsers │ ├── RequestStatusParser.java │ ├── RawContentParser.java │ └── DeleteRepositoryParser.java │ ├── binders │ ├── BindHookSettingsToPayload.java │ └── BindSearchRequestToPayload.java │ ├── features │ └── SystemApi.java │ └── filters │ └── BitbucketAuthenticationFilter.java ├── .editorconfig ├── config ├── pmd │ └── pmd.xml └── header │ └── java.header ├── .gitignore ├── .github ├── dependabot.yml ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── CONTRIBUTING.md ├── .travis.yml ├── gradle.properties └── .gitattributes /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "bitbucket-rest" 2 | -------------------------------------------------------------------------------- /gradle/dependencies.gradle: -------------------------------------------------------------------------------- 1 | ext.depVersions = ['gradleGit': '1.6.0'] 2 | 3 | -------------------------------------------------------------------------------- /src/test/resources/labels-get-byname.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "labelName" 3 | } 4 | 5 | -------------------------------------------------------------------------------- /src/test/resources/build-summary.json: -------------------------------------------------------------------------------- 1 | { 2 | "failed": 1, 3 | "inProgress": 2, 4 | "successful": 3 5 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdancy/bitbucket-rest/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/test/resources/pull-request-can-merge-succeed.json: -------------------------------------------------------------------------------- 1 | { 2 | "canMerge": true, 3 | "conflicted": false, 4 | "vetoes": [ 5 | 6 | ] 7 | } -------------------------------------------------------------------------------- /src/test/resources/accesskeys-list-empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 0, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "values": [], 6 | "start": 0 7 | } -------------------------------------------------------------------------------- /src/test/resources/repository-page-empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 0, 3 | "limit": 25, 4 | "start": 0, 5 | "isLastPage": true, 6 | "values": [] 7 | } -------------------------------------------------------------------------------- /src/test/resources/synchronize.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "refs/heads/master", 3 | "displayId": "master", 4 | "state": "AHEAD", 5 | "tag": false 6 | } -------------------------------------------------------------------------------- /src/test/resources/version.json: -------------------------------------------------------------------------------- 1 | { 2 | "version":"4.6.0", 3 | "buildNumber":"4006000", 4 | "buildDate":"1462767710190", 5 | "displayName":"Bitbucket" 6 | } -------------------------------------------------------------------------------- /src/test/resources/accesskeys-get-wrong-id.json: -------------------------------------------------------------------------------- 1 | { 2 | "context": null, 3 | "message": "SSH key with ID 2 cannot access ...", 4 | "exceptionName": null 5 | } -------------------------------------------------------------------------------- /src/test/resources/files-page.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "values": [ 6 | "path/to/file.txt" 7 | ], 8 | "start": 0 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/labels-list.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "values": [ 6 | { 7 | "name": "labelName" 8 | } 9 | ], 10 | "start": 0 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/accesskeys-create-wrong-key.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": "text", 5 | "message": "You must enter a valid public key", 6 | "exceptionName": null 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/hook-settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "string-value": "this is an arbitrary string", 3 | "integer-value": 1, 4 | "long-value": 2147483648, 5 | "boolean-value": true, 6 | "double-value": 1.1 7 | } -------------------------------------------------------------------------------- /src/test/resources/insight-report-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": "reportKey", 5 | "message": "No report found with key: qwerty", 6 | "exceptionName": null 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/postwebhook-errors.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "message": "A detailed error message.", 6 | "exceptionName": null 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/build-status-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "message": "You are not permitted to access this resource", 6 | "exceptionName": null 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/line-page.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "start": 0, 6 | "lines": [ 7 | { 8 | "text": "BEARS" 9 | } 10 | ] 11 | } -------------------------------------------------------------------------------- /src/test/resources/repository-webhook-errors.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "message": "A detailed error message.", 6 | "exceptionName": null 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/admin-list-user-by-group-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "context":null, 3 | "message":"You are not permitted to access this resource", 4 | "exceptionName":"com.atlassian.bitbucket.AuthorisationException" 5 | } 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | charset = utf-8 6 | 7 | [*.{java,groovy,gradle}] 8 | indent_style = space 9 | indent_size = 4 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/test/resources/build-status-post.json: -------------------------------------------------------------------------------- 1 | { 2 | "state": "SUCCESSFUL", 3 | "key": "REPO-MASTER", 4 | "name": "REPO-MASTER-42", 5 | "url": "https://bamboo.example.com/browse/REPO-MASTER-42", 6 | "description": "Changes by John Doe" 7 | } -------------------------------------------------------------------------------- /src/test/resources/project-not-exist.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors":[ 3 | { 4 | "context":null, 5 | "message":"Project HelloWorld does not exist.", 6 | "exceptionName":"com.atlassian.bitbucket.project.NoSuchProjectException" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/repository-labels.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 2, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "values": [ 6 | { 7 | "name": "label1" 8 | }, 9 | { 10 | "name": "label2" 11 | } 12 | ], 13 | "start": 0 14 | } -------------------------------------------------------------------------------- /src/test/resources/repository-hook-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "message": "No such hook com.atlassian.bitbucket.server.bitbucket-bundled-hooks:force-push-hook2", 6 | "exceptionName": null 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/project-permission-group-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "exceptionName": "com.atlassian.bitbucket.project.NoSuchProjectException", 6 | "message": "Project test123 does not exist." 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/project-permission-users-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "exceptionName": "com.atlassian.bitbucket.project.NoSuchProjectException", 6 | "message": "Project test123 does not exist." 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/repository-permission-group-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "exceptionName": "com.atlassian.bitbucket.project.NoSuchProjectException", 6 | "message": "Project test123 does not exist." 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/repository-permission-users-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "exceptionName": "com.atlassian.bitbucket.project.NoSuchProjectException", 6 | "message": "Project test123 does not exist." 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/repository-not-exist.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors":[ 3 | { 4 | "context":null, 5 | "message":"Repository CFSTLRYHBN/JKXATTQLOT does not exist.", 6 | "exceptionName":"com.atlassian.bitbucket.repository.NoSuchRepositoryException" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /src/test/resources/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "key":"HELLO", 3 | "id":42, 4 | "name":"HELLO", 5 | "public":false, 6 | "type":"NORMAL", 7 | "links":{ 8 | "self":[ 9 | { 10 | "href":"http://127.0.0.1:7990/projects/HELLO" 11 | } 12 | ] 13 | } 14 | } -------------------------------------------------------------------------------- /src/test/resources/pull-request-settings-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "exceptionName": "com.atlassian.bitbucket.repository.NoSuchRepositoryException", 6 | "message": "Repository test/test-test does not exist." 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/branch-default.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "refs/heads/master", 3 | "displayId": "master", 4 | "type": "BRANCH", 5 | "latestCommit": "8d51122def5632836d1cb1026e879069e10a1e13", 6 | "latestChangeset": "8d51122def5632836d1cb1026e879069e10a1e13", 7 | "isDefault": true 8 | } -------------------------------------------------------------------------------- /src/test/resources/branch.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "refs/heads/dev-branch", 3 | "displayId": "dev-branch", 4 | "type": "BRANCH", 5 | "latestCommit": "8d351a10fb428c0c1239530256e21cf24f136e73", 6 | "latestChangeset": "8d351a10fb428c0c1239530256e21cf24f136e73", 7 | "isDefault": false 8 | } -------------------------------------------------------------------------------- /src/test/resources/participants-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors":[ 3 | { 4 | "context":null, 5 | "message":"Repository HelloWorld/something does not exist.", 6 | "exceptionName":"com.atlassian.stash.exception.NoSuchRepositoryException" 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/project-create-fail.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors":[ 3 | { 4 | "context":"key", 5 | "message":"Project keys must start with a letter and may only consist of ASCII letters, numbers and underscores (A-Z, a-z, 0-9, _)", 6 | "exceptionName":null 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/pull-request-not-exist.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors":[ 3 | { 4 | "context":null, 5 | "message":"Pull request 101 does not exist in TES/dev.", 6 | "exceptionName":"com.atlassian.bitbucket.pull.NoSuchPullRequestException" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/pull-request-participants-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "exceptionName": "com.atlassian.bitbucket.pull.NoSuchPullRequestException", 6 | "message": "No pull request exists with ID 999 for this repository 136" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/repository-permission-group.json: -------------------------------------------------------------------------------- 1 | { 2 | "isLastPage": true, 3 | "limit": 25, 4 | "size": 1, 5 | "start": 0, 6 | "values": [ 7 | { 8 | "group": { 9 | "name": "test12345" 10 | }, 11 | "permission": "REPO_WRITE" 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /src/test/resources/branch-permission-list-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors":[ 3 | { 4 | "context":null, 5 | "message":"The repository 'hello' does not exist in project 'world'", 6 | "exceptionName":"com.atlassian.stash.exception.NoSuchChangesetException" 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/post-comment.json: -------------------------------------------------------------------------------- 1 | { 2 | "text": "A measured reply.", 3 | "parent": { 4 | "id": 1 5 | }, 6 | "anchor": { 7 | "line": 1, 8 | "lineType": "CONTEXT", 9 | "fileType": "FROM", 10 | "path": "path/to/file", 11 | "srcPath": "path/to/file" 12 | } 13 | } -------------------------------------------------------------------------------- /src/test/resources/project-permission-group.json: -------------------------------------------------------------------------------- 1 | { 2 | "isLastPage": true, 3 | "limit": 25, 4 | "size": 1, 5 | "start": 0, 6 | "values": [ 7 | { 8 | "group": { 9 | "name": "test12345" 10 | }, 11 | "permission": "PROJECT_WRITE" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/commit-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors":[ 3 | { 4 | "context":null, 5 | "message":"The changeset '1234567890' does not exist in repository 'prpc-platform'", 6 | "exceptionName":"com.atlassian.stash.exception.NoSuchChangesetException" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/pull-request-create-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "message": "Branch \"master\" is already up-to-date with branch \"feature-ABC-123\" in repository \"my-repo\".", 5 | "exceptionName": "com.atlassian.bitbucket.pull.EmptyPullRequestException" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/pull-request-page-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors":[ 3 | { 4 | "context":null, 5 | "message":"Repository HelloWorld/something does not exist.", 6 | "exceptionName":"com.atlassian.stash.exception.NoSuchRepositoryException" 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/tag.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "refs/tags/release-2.0.0", 3 | "displayId": "release-2.0.0", 4 | "type": "TAG", 5 | "latestCommit": "8d351a10fb428c0c1239530256e21cf24f136e73", 6 | "latestChangeset": "8d351a10fb428c0c1239530256e21cf24f136e73", 7 | "hash": "8d51122def5632836d1cb1026e879069e10a1e13" 8 | } -------------------------------------------------------------------------------- /src/test/resources/pull-request-activities-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "exceptionName": "com.atlassian.bitbucket.pull.NoSuchPullRequestException", 6 | "message": "No pull request exists with ID 999 for this repository 136" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/pull-request-delete-non-existent.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors" : [ 3 | { 4 | "exceptionName" : "com.atlassian.bitbucket.pull.NoSuchPullRequestException", 5 | "context" : null, 6 | "message" : "No pull request exists with ID 999 for this repository 1" 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/branch-model-configuration-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "message": "There is no branch model configuration defined for repository ~JDOIRE/testmessage[228]. You must enable the branch model first", 6 | "exceptionName": "com.atlassian.bitbucket.NoSuchEntityException" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/test/resources/merge-failed-retry.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors":[ 3 | { 4 | "context" : null, 5 | "message" : "New changes were pushed to master in PROJECT/repo while the merge was being performed. Please retry the merge.", 6 | "exceptionName" : "com.atlassian.stash.scm.MergeException" 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/pull-request-delete-merged.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": null, 5 | "message": "This pull request has already been merged and cannot be deleted.", 6 | "exceptionName": 7 | "com.atlassian.bitbucket.pull.IllegalPullRequestStateException" 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/test/resources/admin-delete-user-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": "field_a", 5 | "message": "A detailed validation error message for field_a.", 6 | "exceptionName": null 7 | }, 8 | { 9 | "context": null, 10 | "message": "A detailed error message.", 11 | "exceptionName": null 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/repository-webhook.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 10, 3 | "name": "Webhook Name", 4 | "createdDate": 1513106011000, 5 | "updatedDate": 1513106011000, 6 | "events": [ 7 | "repo:refs_changed", 8 | "repo:modified" 9 | ], 10 | "configuration": { 11 | "secret": "password" 12 | }, 13 | "url": "http://example.com", 14 | "active": true 15 | } 16 | -------------------------------------------------------------------------------- /src/test/resources/sync-enabled.json: -------------------------------------------------------------------------------- 1 | { 2 | "available": true, 3 | "enabled": true, 4 | "lastSync": 1331038800000, 5 | "aheadRefs": [], 6 | "divergedRefs": [ 7 | { 8 | "id": "refs/heads/master", 9 | "displayId": "master", 10 | "state": "DIVERGED", 11 | "tag": false 12 | } 13 | ], 14 | "orphanedRefs": [] 15 | } -------------------------------------------------------------------------------- /src/test/resources/pull-request-comment-likes.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "values": [ 6 | { 7 | "name": "jcitizen", 8 | "emailAddress": "jane@example.com", 9 | "id": 103, 10 | "displayName": "Jane Citizen", 11 | "active": true, 12 | "slug": "jcitizen", 13 | "type": "NORMAL" 14 | } 15 | ], 16 | "start": 0 17 | } -------------------------------------------------------------------------------- /src/test/resources/admin-delete-user.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "user", 3 | "emailAddress": "email", 4 | "id": 101, 5 | "displayName": "display", 6 | "active": true, 7 | "slug": "user", 8 | "type": "NORMAL", 9 | "directoryName": "Bitbucket Internal Directory", 10 | "deletable": true, 11 | "lastAuthenticationTimestamp": 1368145580548, 12 | "mutableDetails": true, 13 | "mutableGroups": true 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/pull-request-can-merge-fail.json: -------------------------------------------------------------------------------- 1 | { 2 | "canMerge": false, 3 | "conflicted": false, 4 | "vetoes": [ 5 | { 6 | "summaryMessage": "You may not merge after 6pm on a Friday.", 7 | "detailedMessage": "It is likely that your Blood Alcohol Content (BAC) exceeds the threshold for making sensible decisions regarding pull requests. Please try again on Monday." 8 | } 9 | ] 10 | } -------------------------------------------------------------------------------- /src/test/resources/errors.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "context": "name", 5 | "message": "The name should be between 1 and 255 characters.", 6 | "exceptionName": null 7 | }, 8 | { 9 | "context": "email", 10 | "message": "The email should be a valid email address.", 11 | "exceptionName": null 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /src/test/resources/repository-hook.json: -------------------------------------------------------------------------------- 1 | { 2 | "details": { 3 | "key": "com.atlassian.bitbucket.server.bitbucket-bundled-hooks:force-push-hook", 4 | "name": "Reject Force Push", 5 | "type": "PRE_RECEIVE", 6 | "description": "Reject all force pushes (git push --force) to this repository", 7 | "version": "5.0.0", 8 | "configFormKey": null 9 | }, 10 | "enabled": false, 11 | "configured": false 12 | } -------------------------------------------------------------------------------- /config/pmd/pmd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | .*/build/.* 9 | 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Directories # 2 | ###################### 3 | build 4 | bin 5 | out 6 | src/generated 7 | .gradle 8 | test-output 9 | 10 | # OS generated files # 11 | ###################### 12 | .DS_Store 13 | 14 | # IDE generated files # 15 | ###################### 16 | .settings/ 17 | .classpath 18 | .project 19 | .README* 20 | .idea 21 | *.iml 22 | *.ipr 23 | *.iws 24 | /.nb-gradle/ 25 | 26 | # vim generated files # 27 | ####################### 28 | Session.vim 29 | *.swp 30 | -------------------------------------------------------------------------------- /src/test/resources/repository-illegal-name.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors":[ 3 | { 4 | "context":"name", 5 | "message":"Repository names are limited to 128 characters. They must start with a letter or number and may contain spaces, hyphens, underscores and periods", 6 | "exceptionName":null 7 | }, 8 | { 9 | "context":"slug", 10 | "message":"Please enter a non-empty value less than 128 characters", 11 | "exceptionName":null 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: gradle 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "10:00" 8 | open-pull-requests-limit: 10 9 | ignore: 10 | - dependency-name: com.jfrog.artifactory 11 | versions: 12 | - 4.21.0 13 | - dependency-name: com.google.inject.extensions:guice-assistedinject 14 | versions: 15 | - 5.0.0 16 | - dependency-name: com.google.inject:guice 17 | versions: 18 | - 5.0.0 19 | -------------------------------------------------------------------------------- /src/test/resources/insight-report.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "title": "THIS_IS_A_TITLE", 5 | "value": "THIS_IS_A_VALUE", 6 | "type": "TEXT" 7 | }, 8 | { 9 | "title": "Code Coverage", 10 | "value": 3, 11 | "type": "PERCENTAGE" 12 | } 13 | ], 14 | "createdDate": 1562578136068, 15 | "details": "details", 16 | "key": "qwerty", 17 | "result": "FAIL", 18 | "title": "THIS_IS_THE_REPORT_TITLE", 19 | "reporter": "TEST_REPORTER" 20 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: openjdk11 3 | 4 | before_cache: 5 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 6 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 7 | 8 | cache: 9 | directories: 10 | - $HOME/.gradle/caches/ 11 | - $HOME/.gradle/wrapper/ 12 | 13 | install: true 14 | 15 | script: 16 | - ./gradlew -s -Dorg.gradle.daemon=false clean build mockTest publishToMavenLocal 17 | 18 | after_script: 19 | - bash <(curl -s https://codecov.io/bash) 20 | 21 | -------------------------------------------------------------------------------- /src/test/resources/participants.json: -------------------------------------------------------------------------------- 1 | { 2 | "approved": false, 3 | "role": "PARTICIPANT", 4 | "status": "UNAPPROVED", 5 | "user": { 6 | "active": true, 7 | "displayName": "test123", 8 | "emailAddress": "test123@asdf.com", 9 | "id": 339, 10 | "links": { 11 | "self": [ 12 | { 13 | "href": "https://test.test.com/users/test123" 14 | } 15 | ] 16 | }, 17 | "name": "test123", 18 | "slug": "test123", 19 | "type": "NORMAL" 20 | } 21 | } -------------------------------------------------------------------------------- /src/test/resources/tag-page.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 10, 4 | "isLastPage": true, 5 | "values": [ 6 | { 7 | "id": "release-2.0.0", 8 | "displayId": "refs/tags/release-2.0.0", 9 | "type": "TAG", 10 | "latestCommit": "8d351a10fb428c0c1239530256e21cf24f136e73", 11 | "latestChangeset": "8d351a10fb428c0c1239530256e21cf24f136e73", 12 | "hash": "8d51122def5632836d1cb1026e879069e10a1e13" 13 | } 14 | ], 15 | "start": 0 16 | } -------------------------------------------------------------------------------- /src/test/resources/branch-list-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors":[ 3 | { 4 | "context":null, 5 | "message":"The repository 'hello' does not exist in project 'world'", 6 | "exceptionName":"com.atlassian.stash.exception.NoSuchChangesetException", 7 | "conflicted":false, 8 | "vetoes":[ 9 | { 10 | "summaryMessage":"some short message", 11 | "detailedMessage":"some detailed message" 12 | } 13 | ] 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /src/test/resources/accesskeys-get-for-project.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "id": 1, 4 | "text": "ssh-rsa abc", 5 | "label": "abc" 6 | }, 7 | "project": { 8 | "key": "MY-PROJECT", 9 | "id": 1, 10 | "name": "MY-PROJECT", 11 | "description": "Example", 12 | "public": false, 13 | "type": "NORMAL", 14 | "links": { 15 | "self": [ 16 | { 17 | "href": "https://my-bitbucket.com/bitbucket/projects/PLAY" 18 | } 19 | ] 20 | } 21 | }, 22 | "permission": "PROJECT_READ" 23 | } -------------------------------------------------------------------------------- /src/test/resources/repository-webhook-page.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "values": [ 6 | { 7 | "id": 10, 8 | "name": "Webhook Name", 9 | "createdDate": 1513106011000, 10 | "updatedDate": 1513106011000, 11 | "events": [ 12 | "repo:refs_changed", 13 | "repo:modified" 14 | ], 15 | "configuration": { 16 | "secret": "password" 17 | }, 18 | "url": "http://example.com", 19 | "active": true 20 | } 21 | ], 22 | "start": 0 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/postwebhook-create.json: -------------------------------------------------------------------------------- 1 | { 2 | "branchCreated": true, 3 | "branchDeleted": true, 4 | "branchesToIgnore": "release/1.0", 5 | "buildStatus": true, 6 | "committersToIgnore": "userid", 7 | "enabled": true, 8 | "id": 1107, 9 | "prCommented": true, 10 | "prCreated": true, 11 | "prDeclined": true, 12 | "prMerged": true, 13 | "prReopened": true, 14 | "prRescoped": true, 15 | "prUpdated": true, 16 | "repoMirrorSynced": true, 17 | "repoPush": true, 18 | "tagCreated": true, 19 | "title": "new updated title", 20 | "url": "new url" 21 | } 22 | -------------------------------------------------------------------------------- /src/test/resources/postwebhook-update.json: -------------------------------------------------------------------------------- 1 | { 2 | "branchCreated": true, 3 | "branchDeleted": true, 4 | "branchesToIgnore": "release/1.0", 5 | "buildStatus": true, 6 | "committersToIgnore": "userid", 7 | "enabled": true, 8 | "id": 1107, 9 | "prCommented": true, 10 | "prCreated": true, 11 | "prDeclined": true, 12 | "prMerged": true, 13 | "prReopened": true, 14 | "prRescoped": true, 15 | "prUpdated": true, 16 | "repoMirrorSynced": true, 17 | "repoPush": true, 18 | "tagCreated": true, 19 | "title": "new updated title", 20 | "url": "new url" 21 | } 22 | -------------------------------------------------------------------------------- /src/test/resources/project-permission-users.json: -------------------------------------------------------------------------------- 1 | { 2 | "isLastPage": true, 3 | "limit": 25, 4 | "size": 1, 5 | "start": 0, 6 | "values": [ 7 | { 8 | "permission": "PROJECT_READ", 9 | "user": { 10 | "active": true, 11 | "displayName": "test123 123", 12 | "emailAddress": "test@amce.com", 13 | "id": 339, 14 | "links": { 15 | "self": [ 16 | { 17 | "href": "https://bitbucket.amce.com/users/test" 18 | } 19 | ] 20 | }, 21 | "name": "test", 22 | "type": "NORMAL" 23 | } 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /src/test/resources/repository-permission-users.json: -------------------------------------------------------------------------------- 1 | { 2 | "isLastPage": true, 3 | "limit": 25, 4 | "size": 1, 5 | "start": 0, 6 | "values": [ 7 | { 8 | "permission": "REPO_READ", 9 | "user": { 10 | "active": true, 11 | "displayName": "test123 123", 12 | "emailAddress": "test@amce.com", 13 | "id": 339, 14 | "links": { 15 | "self": [ 16 | { 17 | "href": "https://bitbucket.amce.com/users/test" 18 | } 19 | ] 20 | }, 21 | "name": "test", 22 | "slug": "test", 23 | "type": "NORMAL" 24 | } 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /src/test/resources/insight-report-page.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 25, 4 | "start": 0, 5 | "isLastPage": true, 6 | "values": [ 7 | { 8 | "data": [ 9 | { 10 | "title": "THIS_IS_A_TITLE", 11 | "value": "THIS_IS_A_VALUE", 12 | "type": "TEXT" 13 | }, 14 | { 15 | "title": "Code Coverage", 16 | "value": 3, 17 | "type": "PERCENTAGE" 18 | } 19 | ], 20 | "createdDate": 1562578136068, 21 | "details": "details", 22 | "key": "qwerty", 23 | "result": "FAIL", 24 | "title": "THIS_IS_THE_REPORT_TITLE", 25 | "reporter": "TEST_REPORTER" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /src/test/resources/pull-request-commits.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "values": [ 6 | { 7 | "id": "def0123abcdef4567abcdef8987abcdef6543abc", 8 | "displayId": "def0123abcd", 9 | "author": { 10 | "name": "charlie", 11 | "emailAddress": "charlie@example.com" 12 | }, 13 | "authorTimestamp": 1469663809545, 14 | "message": "More work on feature 1", 15 | "parents": [ 16 | { 17 | "id": "abcdef0123abcdef4567abcdef8987abcdef6543", 18 | "displayId": "abcdef0" 19 | } 20 | ] 21 | } 22 | ], 23 | "start": 0, 24 | "authorCount": 1, 25 | "totalCount": 1 26 | } -------------------------------------------------------------------------------- /src/test/resources/admin-list-users.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "size": 1, 4 | "limit": 25, 5 | "isLastPage": true, 6 | "values": [ 7 | { 8 | "name": "jcitizen", 9 | "emailAddress": "jane@example.com", 10 | "id": 101, 11 | "displayName": "Jane Citizen", 12 | "active": true, 13 | "slug": "jcitizen", 14 | "type": "NORMAL", 15 | "directoryName": "Bitbucket Internal Directory", 16 | "deletable": true, 17 | "lastAuthenticationTimestamp": 1368145580548, 18 | "mutableDetails": true, 19 | "mutableGroups": true 20 | } 21 | ], 22 | "start": 0 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/annotations.json: -------------------------------------------------------------------------------- 1 | { 2 | "totalCount": 3, 3 | "annotations": [ 4 | { 5 | "reportKey": "qwerty", 6 | "line": 0, 7 | "message": "test", 8 | "path": ".gitignore", 9 | "severity": "HIGH" 10 | }, 11 | { 12 | "reportKey": "qwerty", 13 | "externalId": "ext-id", 14 | "line": 1, 15 | "message": "something wrong", 16 | "path": ".gitignore", 17 | "severity": "MEDIUM", 18 | "type": "BUG" 19 | }, 20 | { 21 | "reportKey": "qwerty", 22 | "line": 2, 23 | "message": "is this a whitespace", 24 | "path": ".gitignore", 25 | "severity": "LOW", 26 | "type": "CODE_SMELL" 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /src/test/resources/build-status.json: -------------------------------------------------------------------------------- 1 | { 2 | "isLastPage": true, 3 | "limit": 100, 4 | "size": 2, 5 | "start": 0, 6 | "values": [ 7 | { 8 | "dateAdded": 1492526977926, 9 | "description": "#120 failed\n(1 test failed)\nin 45 minutes", 10 | "key": "AC-TEST", 11 | "name": "develop", 12 | "state": "FAILED", 13 | "url": "https://bamboo.acme.com/browse/AC-TEST-120" 14 | }, 15 | { 16 | "dateAdded": 1492525545176, 17 | "description": "#110 successful\n(with 1288 tests)\nin 6 minutes", 18 | "key": "AC-TEST2", 19 | "name": "develop", 20 | "state": "SUCCESSFUL", 21 | "url": "https://bamboo.acme.com/browse/AC-TEST2-110" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /src/test/resources/pull-request-participants.json: -------------------------------------------------------------------------------- 1 | { 2 | "isLastPage": true, 3 | "limit": 25, 4 | "size": 1, 5 | "start": 0, 6 | "values": [ 7 | { 8 | "approved": false, 9 | "role": "PARTICIPANT", 10 | "status": "UNAPPROVED", 11 | "user": { 12 | "active": true, 13 | "displayName": "test123", 14 | "emailAddress": "test123@asdf.com", 15 | "id": 339, 16 | "links": { 17 | "self": [ 18 | { 19 | "href": "https://test.test.com/users/test123" 20 | } 21 | ] 22 | }, 23 | "name": "test123", 24 | "slug": "test123", 25 | "type": "NORMAL" 26 | } 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /src/test/resources/pull-request-create.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "ISSUE-123", 3 | "description": "Fix for issue 123", 4 | "state": "OPEN", 5 | "open": true, 6 | "closed": false, 7 | "fromRef": { 8 | "id": "refs/heads/feature-ABC-123", 9 | "repository": { 10 | "slug": "my-pesonal-repo", 11 | "name": null, 12 | "project": { 13 | "key": "PRJ1" 14 | } 15 | } 16 | }, 17 | "toRef": { 18 | "id": "refs/heads/master", 19 | "repository": { 20 | "slug": "my-target-repo", 21 | "name": null, 22 | "project": { 23 | "key": "PRJ2" 24 | } 25 | } 26 | }, 27 | "locked": false, 28 | "reviewers": [], 29 | "links": { 30 | "self": [] 31 | } 32 | } -------------------------------------------------------------------------------- /src/test/resources/branch-model-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "development": { 3 | "refId": "refs/heads/master", 4 | "useDefault": false 5 | }, 6 | "types": [ 7 | { 8 | "id": "BUGFIX", 9 | "displayName": "Bugfix", 10 | "enabled": true, 11 | "prefix": "bugfix/" 12 | }, 13 | { 14 | "id": "FEATURE", 15 | "displayName": "Feature", 16 | "enabled": true, 17 | "prefix": "feature/" 18 | }, 19 | { 20 | "id": "HOTFIX", 21 | "displayName": "Hotfix", 22 | "enabled": true, 23 | "prefix": "hotfix/" 24 | }, 25 | { 26 | "id": "RELEASE", 27 | "displayName": "Release", 28 | "enabled": true, 29 | "prefix": "release2/" 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /src/test/resources/accesskeys-list-by-project.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "values": [ 6 | { 7 | "key": { 8 | "id": 1, 9 | "text": "ssh-rsa abc", 10 | "label": "abc" 11 | }, 12 | "project": { 13 | "key": "MY-PROJECT", 14 | "id": 1, 15 | "name": "MY-PROJECT", 16 | "description": "Example", 17 | "public": false, 18 | "type": "NORMAL", 19 | "links": { 20 | "self": [ 21 | { 22 | "href": "https://my-bitbucket.com/bitbucket/projects/PLAY" 23 | } 24 | ] 25 | } 26 | }, 27 | "permission": "PROJECT_READ" 28 | } 29 | ], 30 | "start": 0 31 | } -------------------------------------------------------------------------------- /src/test/resources/branch-model.json: -------------------------------------------------------------------------------- 1 | { 2 | "development":{ 3 | "id":"refs/heads/master", 4 | "displayId":"master", 5 | "type":"BRANCH", 6 | "latestCommit":"d90ca08fa076e2e4c076592fce3832aba80a494f", 7 | "latestChangeset":"d90ca08fa076e2e4c076592fce3832aba80a494f", 8 | "isDefault":true 9 | }, 10 | "types":[ 11 | { 12 | "id":"BUGFIX", 13 | "displayName":"Bugfix", 14 | "prefix":"bugfix/" 15 | }, 16 | { 17 | "id":"FEATURE", 18 | "displayName":"Feature", 19 | "prefix":"feature/" 20 | }, 21 | { 22 | "id":"HOTFIX", 23 | "displayName":"Hotfix", 24 | "prefix":"hotfix/" 25 | }, 26 | { 27 | "id":"RELEASE", 28 | "displayName":"Release", 29 | "prefix":"release/" 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /src/test/resources/commit.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "abcdef0123abcdef4567abcdef8987abcdef6543", 3 | "displayId": "abcdef0123a", 4 | "author": { 5 | "name": "charlie", 6 | "emailAddress": "charlie@example.com", 7 | "displayName": "Charlie Brown" 8 | }, 9 | "authorTimestamp": 1484800877151, 10 | "message": "WIP on feature 1", 11 | "committer": { 12 | "name": "john", 13 | "emailAddress": "john@example.com", 14 | "displayName": "John Smith" 15 | }, 16 | "committerTimestamp": 1594900977151, 17 | "parents": [ 18 | { 19 | "id": "abcdef0123abcdef4567abcdef8987abcdef6543", 20 | "displayId": "abcdef0" 21 | } 22 | ], 23 | "properties": { 24 | "jira-key": [ 25 | "IEA-2170" 26 | ] 27 | } 28 | } -------------------------------------------------------------------------------- /config/header/java.header: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ -------------------------------------------------------------------------------- /src/test/resources/line-page-with-blame.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "start": 0, 6 | "lines":[ 7 | { 8 | "text":"BEARS" 9 | } 10 | ], 11 | "blame":[ 12 | { 13 | "author":{ 14 | "name":"JordanPeterson", 15 | "emailAddress":"jordan.peterson@whatever.com" 16 | }, 17 | "authorTimestamp":1497013186000, 18 | "commitHash":"cba97d2b0c71e56850f50f0d5882a4bf3d92c65b", 19 | "displayCommitHash":"cba97d2b0c7", 20 | "commitId":"cba97d2b0c71e56850f50f0d5882a4bf3d92c65b", 21 | "commitDisplayId":"cba97d2b0c7", 22 | "fileName":"faf4b2275e434c4aae775ea043d0e3cc.txt", 23 | "lineNumber":1, 24 | "spannedLines":1 25 | } 26 | ], 27 | "start":0, 28 | "size":1, 29 | "isLastPage":true 30 | } -------------------------------------------------------------------------------- /src/test/resources/project-page-truncated.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 2, 3 | "limit": 2, 4 | "start": 0, 5 | "isLastPage": false, 6 | "nextPageStart": 2, 7 | "values": [ 8 | { 9 | "key": "PRJ1", 10 | "id": 1, 11 | "name": "Project 1", 12 | "description": "Mock project #1", 13 | "public": false, 14 | "type": "NORMAL", 15 | "links": { 16 | "self": [ 17 | { 18 | "href": "http://127.0.0.1:7990/projects/PRJ1" 19 | } 20 | ] 21 | } 22 | }, 23 | { 24 | "key": "PRJ2", 25 | "id": 2, 26 | "name": "Project 2", 27 | "description": "Mock project #2", 28 | "public": false, 29 | "type": "NORMAL", 30 | "links": { 31 | "self": [ 32 | { 33 | "href": "http://127.0.0.1:7990/projects/PRJ2" 34 | } 35 | ] 36 | } 37 | } 38 | ] 39 | } -------------------------------------------------------------------------------- /src/test/resources/repository.json: -------------------------------------------------------------------------------- 1 | { 2 | "slug": "my-repo", 3 | "id": 1, 4 | "name": "my-repo", 5 | "scmId": "git", 6 | "state": "AVAILABLE", 7 | "statusMessage": "Available", 8 | "forkable": true, 9 | "project": { 10 | "key": "PRJ", 11 | "id": 1, 12 | "name": "My Cool Project", 13 | "description": "The description for my cool project.", 14 | "public": true, 15 | "type": "NORMAL", 16 | "links": { 17 | "self": [ 18 | { 19 | "href": "http://link/to/project" 20 | } 21 | ] 22 | } 23 | }, 24 | "public": true, 25 | "links": { 26 | "clone": [ 27 | { 28 | "href": "ssh://git@/PRJ/my-repo.git", 29 | "name": "ssh" 30 | }, 31 | { 32 | "href": "https:///scm/PRJ/my-repo.git", 33 | "name": "http" 34 | } 35 | ], 36 | "self": [ 37 | { 38 | "href": "http://link/to/repository" 39 | } 40 | ] 41 | } 42 | } -------------------------------------------------------------------------------- /src/test/resources/branch-permission-list.json: -------------------------------------------------------------------------------- 1 | { 2 | "isLastPage": true, 3 | "limit": 25, 4 | "size": 1, 5 | "start": 0, 6 | "values": [ 7 | { 8 | "groups": [ 9 | "GROUPS1" 10 | ], 11 | "id": 839, 12 | "matcher": { 13 | "active": true, 14 | "displayId": "Development", 15 | "id": "development", 16 | "type": { 17 | "id": "MODEL_BRANCH", 18 | "name": "Branching model branch" 19 | } 20 | }, 21 | "type": "fast-forward-only", 22 | "users": [], 23 | "accessKeys": [ 24 | { 25 | "key": { 26 | "id": 158, 27 | "label": "test213", 28 | "text": "ssh-rsa fasdfadsfdsf test213" 29 | } 30 | }, 31 | { 32 | "key": { 33 | "id": 126, 34 | "label": "test123", 35 | "text": "ssh-rsa gagjfdsggfds23434 test123" 36 | } 37 | } 38 | ] 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | group = io.github.cdancy 2 | version = 3.1.2-SNAPSHOT 3 | 4 | artifactoryURL = http://127.0.0.1:8080/artifactory 5 | artifactoryUser = admin 6 | artifactoryPassword = password 7 | 8 | snapshotRepository = libs-snapshot-local 9 | releaseRepository = libs-release-local 10 | 11 | testBitbucketRestEndpoint = http://127.0.0.1:7990 12 | 13 | # can be base64 encoded 14 | testBitbucketRestCredentials = root:root 15 | 16 | # Uncomment out below, and comment out above, if you 17 | # want to use token/bearer auth for running integ tests. 18 | #testBitbucketRestToken = root:root 19 | 20 | # the optional Bitbucket project to use should 21 | # the passed along authentication not have privileges 22 | # to create Projects. 23 | testBitbucketRestProject=DEV 24 | 25 | githubUsername=fixme 26 | githubPassword=fixme 27 | 28 | signing.keyId=fixme 29 | signing.password=fixme 30 | signing.secretKeyRingFile=fixme 31 | 32 | sonatypeUsername=fixme 33 | sonatypePassword=fixme 34 | sonatypeURL=https://s01.oss.sonatype.org 35 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Handle line endings automatically for files detected as text 2 | # and leave all files detected as binary untouched. 3 | * text=auto 4 | 5 | # 6 | # The above will handle all files NOT found below 7 | # 8 | # These files are text and should be normalized (Convert crlf => lf) 9 | *.css text 10 | *.df text 11 | *.htm text 12 | *.html text 13 | *.java text 14 | *.js text 15 | *.json text 16 | *.jsp text 17 | *.jspf text 18 | *.properties text 19 | *.sh text 20 | *.bat text 21 | *.tld text 22 | *.txt text 23 | *.xml text 24 | *.bat text 25 | 26 | # These files are binary and should be left untouched 27 | # (binary is a macro for -text -diff) 28 | *.class binary 29 | *.dll binary 30 | *.ear binary 31 | *.gif binary 32 | *.ico binary 33 | *.jar binary 34 | *.jpg binary 35 | *.jpeg binary 36 | *.png binary 37 | *.so binary 38 | *.war binary 39 | 40 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/common/Value.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.common; 19 | 20 | import org.jclouds.javax.annotation.Nullable; 21 | 22 | public interface Value { 23 | 24 | @Nullable 25 | public abstract T value(); 26 | } 27 | -------------------------------------------------------------------------------- /src/test/resources/default-reviwers-create.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 3, 3 | "requiredApprovals": 1, 4 | "reviewers": [ 5 | { 6 | "active": true, 7 | "avatarUrl": "http://www.gravatar.com/avatar/7f08d8c2a996003767fbe0cb09d89589.jpg?s=32&d=mm", 8 | "displayName": "root", 9 | "emailAddress": "root@root.com", 10 | "id": 1, 11 | "links": { 12 | "self": [ 13 | { 14 | "href": "http://192.168.99.100:32770/users/root" 15 | } 16 | ] 17 | }, 18 | "name": "root", 19 | "slug": "root", 20 | "type": "NORMAL" 21 | } 22 | ], 23 | "scope": { 24 | "resourceId": 10, 25 | "type": "REPOSITORY" 26 | }, 27 | "sourceRefMatcher": { 28 | "active": true, 29 | "displayId": "ANY_REF_MATCHER_ID", 30 | "id": "ANY_REF_MATCHER_ID", 31 | "type": { 32 | "id": "ANY_REF", 33 | "name": "Any branch" 34 | } 35 | }, 36 | "targetRefMatcher": { 37 | "active": true, 38 | "displayId": "ANY_REF_MATCHER_ID", 39 | "id": "ANY_REF_MATCHER_ID", 40 | "type": { 41 | "id": "ANY_REF", 42 | "name": "Any branch" 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/test/resources/task-open.json: -------------------------------------------------------------------------------- 1 | { 2 | "anchor": { 3 | "properties": { 4 | "key": "value" 5 | }, 6 | "id": 1, 7 | "version": 1, 8 | "text": "An insightful comment.", 9 | "author": { 10 | "name": "jcitizen", 11 | "emailAddress": "jane@example.com", 12 | "id": 101, 13 | "displayName": "Jane Citizen", 14 | "active": true, 15 | "slug": "jcitizen", 16 | "type": "NORMAL" 17 | }, 18 | "createdDate": 1499057503993, 19 | "updatedDate": 1499057503993, 20 | "comments": [], 21 | "tasks": [], 22 | "permittedOperations": { 23 | "editable": true, 24 | "deletable": true 25 | } 26 | }, 27 | "author": { 28 | "name": "jcitizen", 29 | "emailAddress": "jane@example.com", 30 | "id": 101, 31 | "displayName": "Jane Citizen", 32 | "active": true, 33 | "slug": "jcitizen", 34 | "type": "NORMAL" 35 | }, 36 | "createdDate": 1499057504642, 37 | "id": 99, 38 | "permittedOperations": { 39 | "deletable": false, 40 | "editable": false, 41 | "transitionable": true 42 | }, 43 | "text": "Resolve the merge conflicts", 44 | "state": "OPEN" 45 | } -------------------------------------------------------------------------------- /src/test/resources/task-resolved.json: -------------------------------------------------------------------------------- 1 | { 2 | "anchor": { 3 | "properties": { 4 | "key": "value" 5 | }, 6 | "id": 1, 7 | "version": 1, 8 | "text": "An insightful comment.", 9 | "author": { 10 | "name": "jcitizen", 11 | "emailAddress": "jane@example.com", 12 | "id": 101, 13 | "displayName": "Jane Citizen", 14 | "active": true, 15 | "slug": "jcitizen", 16 | "type": "NORMAL" 17 | }, 18 | "createdDate": 1499057503993, 19 | "updatedDate": 1499057503993, 20 | "comments": [], 21 | "tasks": [], 22 | "permittedOperations": { 23 | "editable": true, 24 | "deletable": true 25 | } 26 | }, 27 | "author": { 28 | "name": "jcitizen", 29 | "emailAddress": "jane@example.com", 30 | "id": 101, 31 | "displayName": "Jane Citizen", 32 | "active": true, 33 | "slug": "jcitizen", 34 | "type": "NORMAL" 35 | }, 36 | "createdDate": 1499057504642, 37 | "id": 99, 38 | "permittedOperations": { 39 | "deletable": false, 40 | "editable": false, 41 | "transitionable": true 42 | }, 43 | "text": "Resolve the merge conflicts", 44 | "state": "RESOLVED" 45 | } -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/common/Page.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.common; 19 | 20 | import java.util.List; 21 | 22 | public interface Page { 23 | 24 | int start(); 25 | 26 | int limit(); 27 | 28 | int size(); 29 | 30 | int nextPageStart(); 31 | 32 | boolean isLastPage(); 33 | 34 | List values(); 35 | } 36 | -------------------------------------------------------------------------------- /src/test/resources/project-page-full.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 3, 3 | "limit": 25, 4 | "start": 0, 5 | "isLastPage": true, 6 | "values": [ 7 | { 8 | "key": "PRJ1", 9 | "id": 1, 10 | "name": "Project 1", 11 | "description": "Mock project #1", 12 | "public": false, 13 | "type": "NORMAL", 14 | "links": { 15 | "self": [ 16 | { 17 | "href": "http://127.0.0.1:7990/projects/PRJ1" 18 | } 19 | ] 20 | } 21 | }, 22 | { 23 | "key": "PRJ2", 24 | "id": 2, 25 | "name": "Project 2", 26 | "description": "Mock project #2", 27 | "public": false, 28 | "type": "NORMAL", 29 | "links": { 30 | "self": [ 31 | { 32 | "href": "http://127.0.0.1:7990/projects/PRJ2" 33 | } 34 | ] 35 | } 36 | }, 37 | { 38 | "key": "PRJ3", 39 | "id": 3, 40 | "name": "Project 3", 41 | "description": "Mock project #3", 42 | "public": false, 43 | "type": "NORMAL", 44 | "links": { 45 | "self": [ 46 | { 47 | "href": "http://127.0.0.1:7990/projects/PRJ3" 48 | } 49 | ] 50 | } 51 | } 52 | ] 53 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ### Expected Behavior 7 | 8 | 9 | 10 | ### Current Behavior 11 | 12 | 13 | 14 | ### Context 15 | 16 | 17 | 18 | ### Steps to Reproduce (for bugs) 19 | 20 | 21 | 22 | ### Your Environment 23 | 24 | -------------------------------------------------------------------------------- /src/test/resources/repository-page-single.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 25, 4 | "start": 0, 5 | "isLastPage": true, 6 | "values": [ 7 | { 8 | "slug": "my-repo", 9 | "id": 1, 10 | "name": "my-repo", 11 | "scmId": "git", 12 | "state": "AVAILABLE", 13 | "statusMessage": "Available", 14 | "forkable": true, 15 | "project": { 16 | "key": "PRJ", 17 | "id": 1, 18 | "name": "My Cool Project", 19 | "description": "The description for my cool project.", 20 | "public": true, 21 | "type": "NORMAL", 22 | "links": { 23 | "self": [ 24 | { 25 | "href": "http://link/to/project" 26 | } 27 | ] 28 | } 29 | }, 30 | "public": true, 31 | "links": { 32 | "clone": [ 33 | { 34 | "href": "ssh://git@/PRJ/my-repo.git", 35 | "name": "ssh" 36 | }, 37 | { 38 | "href": "https:///scm/PRJ/my-repo.git", 39 | "name": "http" 40 | } 41 | ], 42 | "self": [ 43 | { 44 | "href": "http://link/to/repository" 45 | } 46 | ] 47 | } 48 | } 49 | ] 50 | } -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/EditPullRequest.java: -------------------------------------------------------------------------------- 1 | package com.cdancy.bitbucket.rest.options; 2 | 3 | import com.cdancy.bitbucket.rest.domain.pullrequest.Person; 4 | import com.google.auto.value.AutoValue; 5 | import org.jclouds.javax.annotation.Nullable; 6 | import org.jclouds.json.SerializedNames; 7 | 8 | import java.util.List; 9 | 10 | @AutoValue 11 | public abstract class EditPullRequest { 12 | 13 | public abstract int id(); 14 | 15 | public abstract int version(); 16 | 17 | public abstract String title(); 18 | 19 | @Nullable 20 | public abstract String description(); 21 | 22 | // default to empty List if null 23 | @Nullable 24 | public abstract List reviewers(); 25 | 26 | EditPullRequest() { 27 | } 28 | 29 | @SerializedNames({"id", "version", "title", "description", "reviewers"}) 30 | public static EditPullRequest create(final int id, 31 | final int version, 32 | final String title, 33 | final String description, 34 | final List reviewers) { 35 | return new AutoValue_EditPullRequest(id, version, title, description, reviewers); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/resources/comments.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "key": "value" 4 | }, 5 | "id": 1, 6 | "version": 1, 7 | "text": "A measured reply.", 8 | "author": { 9 | "name": "jcitizen", 10 | "emailAddress": "jane@example.com", 11 | "id": 101, 12 | "displayName": "Jane Citizen", 13 | "active": true, 14 | "slug": "jcitizen", 15 | "type": "NORMAL" 16 | }, 17 | "createdDate": 1471844240957, 18 | "updatedDate": 1471844240957, 19 | "comments": [ 20 | { 21 | "properties": { 22 | "key": "value" 23 | }, 24 | "id": 1, 25 | "version": 1, 26 | "text": "An insightful comment.", 27 | "author": { 28 | "name": "jcitizen", 29 | "emailAddress": "jane@example.com", 30 | "id": 101, 31 | "displayName": "Jane Citizen", 32 | "active": true, 33 | "slug": "jcitizen", 34 | "type": "NORMAL" 35 | }, 36 | "createdDate": 1471844240950, 37 | "updatedDate": 1471844240950, 38 | "comments": [], 39 | "tasks": [], 40 | "permittedOperations": { 41 | "editable": true, 42 | "deletable": true 43 | } 44 | } 45 | ], 46 | "tasks": [], 47 | "permittedOperations": { 48 | "editable": true, 49 | "deletable": true 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/resources/postwebhooks-list.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "branchCreated": false, 4 | "branchDeleted": false, 5 | "branchesToIgnore": "", 6 | "buildStatus": false, 7 | "committersToIgnore": "", 8 | "enabled": true, 9 | "id": 1115, 10 | "prCommented": false, 11 | "prCreated": false, 12 | "prDeclined": false, 13 | "prMerged": false, 14 | "prReopened": false, 15 | "prRescoped": false, 16 | "prUpdated": false, 17 | "repoMirrorSynced": false, 18 | "repoPush": false, 19 | "tagCreated": true, 20 | "title": "test", 21 | "url": "test" 22 | }, 23 | { 24 | "branchCreated": true, 25 | "branchDeleted": true, 26 | "branchesToIgnore": "", 27 | "buildStatus": false, 28 | "committersToIgnore": "", 29 | "enabled": false, 30 | "id": 1107, 31 | "prCommented": false, 32 | "prCreated": true, 33 | "prDeclined": true, 34 | "prMerged": true, 35 | "prReopened": true, 36 | "prRescoped": true, 37 | "prUpdated": true, 38 | "repoMirrorSynced": false, 39 | "repoPush": true, 40 | "tagCreated": true, 41 | "title": "http://jenkins.example.com", 42 | "url": "http://jenkins.example.com/bitbucket-scmsource-hook/notify" 43 | } 44 | ] -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Please do not create a Pull Request without first creating an ISSUE. 2 | Any change needs to be discussed before proceeding. 3 | Failure to do so may result in the rejection of the Pull Request. 4 | 5 | Explain the **details** for making this change: What existing problem does the Pull Request solve? Why is this feature beneficial? 6 | 7 | **On adding new feautes/endpoints** 8 | 9 | No more than 1 endpoint should be coded within a Pull Request. 10 | This alone requires enough code to review and adding more than 1 WILL result in your Pull Request either being ignored or rejected outright. 11 | 12 | **On adding Mock and Integ Tests** 13 | 14 | At _least_ 2 mock tests and 2 integ tests are required prior to merging. 15 | Each pair should should test what the success and failure of added change looks like. 16 | More complicated additions will of course require more tests. 17 | 18 | **On CI testing (currently using travis)** 19 | 20 | Code will not be reviewed until CI passes. 21 | Current CI does NOT exercise `integ` tests and so each Pull Request will have to be run manually by one of the maintainers to confirm it works as expected: please be patient. 22 | 23 | **On automtatic closing of ISSUES** 24 | 25 | Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such). 26 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/repository/Group.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.repository; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | @AutoValue 24 | public abstract class Group { 25 | 26 | public abstract String name(); 27 | 28 | @SerializedNames({"name"}) 29 | public static Group create(final String name) { 30 | return new AutoValue_Group(name); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/resources/accesskeys-get-for-repository.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "id": 1, 4 | "text": "ssh-rsa abc", 5 | "label": "abc" 6 | }, 7 | "repository": { 8 | "slug": "my-repo", 9 | "id": 1, 10 | "name": "my-repo", 11 | "scmId": "git", 12 | "state": "AVAILABLE", 13 | "statusMessage": "Available", 14 | "forkable": true, 15 | "project": { 16 | "key": "MY-PROJECT", 17 | "id": 626, 18 | "name": "MY-PROJECT", 19 | "description": "Example.", 20 | "public": false, 21 | "type": "NORMAL", 22 | "links": { 23 | "self": [ 24 | { 25 | "href": "https://my-bitbucket.com/bitbucket/projects/MY-PROJECT" 26 | } 27 | ] 28 | } 29 | }, 30 | "public": false, 31 | "links": { 32 | "clone": [ 33 | { 34 | "href": "ssh://git@my-bitbucket.com:7999/MY-PROJECT/my-repo.git", 35 | "name": "ssh" 36 | }, 37 | { 38 | "href": "https://my-bitbucket.com/bitbucket/scm/MY-PROJECT/my-repo.git", 39 | "name": "http" 40 | } 41 | ], 42 | "self": [ 43 | { 44 | "href": "https://my-bitbucket.com/bitbucket/projects/MY-PROJECT/repos/my-repo/browse" 45 | } 46 | ] 47 | } 48 | }, 49 | "permission": "REPO_READ" 50 | } 51 | -------------------------------------------------------------------------------- /src/test/resources/pull-request-changes.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "values": [ 6 | { 7 | "contentId": "abcdef0123abcdef4567abcdef8987abcdef6543", 8 | "fromContentId": "bcdef0123abcdef4567abcdef8987abcdef6543a", 9 | "path": { 10 | "components": [ 11 | "new", 12 | "path", 13 | "to", 14 | "file" 15 | ], 16 | "parent": "new/path/to", 17 | "name": "file", 18 | "toString": "new/path/to/file" 19 | }, 20 | "executable": false, 21 | "percentUnchanged": 98, 22 | "type": "MOVE", 23 | "nodeType": "FILE", 24 | "srcPath": { 25 | "components": [ 26 | "path", 27 | "to", 28 | "file.txt" 29 | ], 30 | "parent": "path/to", 31 | "name": "file.txt", 32 | "extension": "txt", 33 | "toString": "path/to/file.txt" 34 | }, 35 | "srcExecutable": false, 36 | "links": { 37 | "self": [ 38 | { 39 | "href": "http://link/to/restchange" 40 | } 41 | ] 42 | } 43 | } 44 | ], 45 | "start": 0 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/common/ErrorsHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.common; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * This interface should NOT be applied to "option" like classes and/or used 24 | * in instances where this is applied to outgoing http traffic. This interface 25 | * should ONLY be used for classes modeled after incoming http traffic. 26 | */ 27 | public interface ErrorsHolder { 28 | 29 | List errors(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/comment/Parent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.comment; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | @AutoValue 24 | public abstract class Parent { 25 | 26 | public abstract int id(); 27 | 28 | Parent() { 29 | } 30 | 31 | @SerializedNames({ "id" }) 32 | public static Parent create(final int id) { 33 | return new AutoValue_Parent(id); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/CreateKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.options; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | @AutoValue 24 | public abstract class CreateKey { 25 | 26 | public abstract String text(); 27 | 28 | CreateKey() { 29 | } 30 | 31 | @SerializedNames({ "text" }) 32 | public static CreateKey create(final String text) { 33 | return new AutoValue_CreateKey(text); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /gradle/additional-artifacts.gradle: -------------------------------------------------------------------------------- 1 | shadowJar { 2 | classifier = 'all' 3 | mergeServiceFiles() 4 | 5 | def foundGroup = rootProject.findProperty('group') 6 | def foundName = rootProject.name.replaceAll('-', '.') 7 | def newBasePackage = "${foundGroup}.${foundName}" 8 | 9 | relocate 'com.google', "${newBasePackage}.shaded.com.google" 10 | relocate 'com.sun', "${newBasePackage}.shaded.com.sun" 11 | relocate 'org.aopalliance', "${newBasePackage}.shaded.org.aopalliance" 12 | relocate 'org.checkerframework', "${newBasePackage}.shaded.org.checkerframework" 13 | relocate 'org.eclipse', "${newBasePackage}.shaded.org.eclipse" 14 | relocate 'org.glassfish', "${newBasePackage}.shaded.org.glassfish" 15 | relocate 'org.jclouds', "${newBasePackage}.shaded.org.jclouds" 16 | relocate 'jakarta', "${newBasePackage}.shaded.jakarta" 17 | relocate 'javax.activation', "${newBasePackage}.shaded.javax.activation" 18 | relocate 'javax.annotation', "${newBasePackage}.shaded.javax.annotation" 19 | } 20 | 21 | task sourcesJar(type: Jar) { 22 | classifier 'sources' 23 | from sourceSets.main.allSource 24 | } 25 | 26 | task docsJar(type: Jar, dependsOn: javadoc) { 27 | classifier 'javadoc' 28 | from javadoc.destinationDir 29 | } 30 | 31 | task testsJar(type: Jar) { 32 | classifier 'tests' 33 | from sourceSets.test.output 34 | } 35 | -------------------------------------------------------------------------------- /src/test/resources/admin-list-user-by-group.json: -------------------------------------------------------------------------------- 1 | { 2 | "isLastPage": false, 3 | "limit": 2, 4 | "nextPageStart": 2, 5 | "size": 2, 6 | "start": 0, 7 | "values": [ 8 | { 9 | "active": true, 10 | "deletable": false, 11 | "directoryName": "bob Crowd", 12 | "displayName": "bob 123", 13 | "emailAddress": "bob123@acme.com", 14 | "id": 216, 15 | "lastAuthenticationTimestamp": 1491592057692, 16 | "links": { 17 | "self": [ 18 | { 19 | "href": "https://bitbucket.acme.com/users/bob123" 20 | } 21 | ] 22 | }, 23 | "mutableDetails": false, 24 | "mutableGroups": false, 25 | "name": "bob123", 26 | "slug": "bob123", 27 | "type": "NORMAL" 28 | }, 29 | { 30 | "active": true, 31 | "deletable": false, 32 | "directoryName": "bob Crowd", 33 | "displayName": "bob 126", 34 | "emailAddress": "bob126@acme.com", 35 | "id": 319, 36 | "lastAuthenticationTimestamp": 1491844251886, 37 | "links": { 38 | "self": [ 39 | { 40 | "href": "https://bitbucket.acme.com/users/bob126" 41 | } 42 | ] 43 | }, 44 | "mutableDetails": false, 45 | "mutableGroups": false, 46 | "name": "bob126", 47 | "slug": "bob126", 48 | "type": "NORMAL" 49 | } 50 | ] 51 | } -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/common/LinksHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.common; 19 | 20 | import org.jclouds.javax.annotation.Nullable; 21 | 22 | /** 23 | * This interface should NOT be applied to "option" like classes and/or used 24 | * in instances where this is applied to outgoing http traffic. This interface 25 | * should ONLY be used for classes modeled after incoming http traffic. 26 | */ 27 | public interface LinksHolder { 28 | 29 | @Nullable 30 | Links links(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/pullrequest/ProjectKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.pullrequest; 19 | 20 | import org.jclouds.json.SerializedNames; 21 | 22 | import com.google.auto.value.AutoValue; 23 | 24 | @AutoValue 25 | public abstract class ProjectKey { 26 | 27 | public abstract String key(); 28 | 29 | ProjectKey() { 30 | } 31 | 32 | @SerializedNames({ "key" }) 33 | public static ProjectKey create(final String key) { 34 | return new AutoValue_ProjectKey(key); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/auth/AuthenticationType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.auth; 19 | 20 | /** 21 | * Supported Authentication Types for Bitbucket. 22 | */ 23 | public enum AuthenticationType { 24 | 25 | Basic("Basic"), 26 | Bearer("Bearer"), 27 | Anonymous(""); 28 | 29 | private final String type; 30 | 31 | private AuthenticationType(final String type) { 32 | this.type = type; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return type; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/resources/task.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "diffAnchorPath": "path/to/file.txt" 4 | }, 5 | "anchor": { 6 | "properties": { 7 | "key": "value" 8 | }, 9 | "id": 1, 10 | "version": 1, 11 | "text": "An insightful comment.", 12 | "author": { 13 | "name": "jcitizen", 14 | "emailAddress": "jane@example.com", 15 | "id": 101, 16 | "displayName": "Jane Citizen", 17 | "active": true, 18 | "slug": "jcitizen", 19 | "type": "NORMAL" 20 | }, 21 | "createdDate": 1499057503993, 22 | "updatedDate": 1499057503993, 23 | "comments": [], 24 | "tasks": [], 25 | "permittedOperations": { 26 | "editable": true, 27 | "deletable": true 28 | } 29 | }, 30 | "author": { 31 | "name": "jcitizen", 32 | "emailAddress": "jane@example.com", 33 | "id": 101, 34 | "displayName": "Jane Citizen", 35 | "active": true, 36 | "slug": "jcitizen", 37 | "type": "NORMAL" 38 | }, 39 | "createdDate": 1499057504642, 40 | "id": 99, 41 | "permittedOperations": { 42 | "deletable": false, 43 | "editable": false, 44 | "transitionable": true 45 | }, 46 | "text": "Resolve the merge conflicts", 47 | "state": "OPEN" 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/comment/MinimalAnchor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.comment; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | @AutoValue 24 | public abstract class MinimalAnchor { 25 | 26 | public abstract int id(); 27 | 28 | public abstract String type(); 29 | 30 | @SerializedNames({ "id", "type" }) 31 | public static MinimalAnchor create(final int id, final String type) { 32 | return new AutoValue_MinimalAnchor(id, type); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/comment/Link.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.comment; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | @AutoValue 24 | public abstract class Link { 25 | 26 | public abstract String url(); 27 | 28 | public abstract String rel(); 29 | 30 | Link() { 31 | } 32 | 33 | @SerializedNames({ "url", "rel" }) 34 | public static Link create(final String url, final String rel) { 35 | return new AutoValue_Link(url, rel); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/search/SearchQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.search; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | @AutoValue 24 | public abstract class SearchQuery { 25 | 26 | public abstract boolean substituted(); 27 | 28 | SearchQuery() { 29 | } 30 | 31 | @SerializedNames({ "substituted" }) 32 | public static SearchQuery create(final boolean substituted) { 33 | 34 | return new AutoValue_SearchQuery(substituted); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/Context.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.options; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class Context { 26 | 27 | @Nullable 28 | public abstract String commitMessage(); 29 | 30 | Context() { 31 | } 32 | 33 | @SerializedNames({ "commitMessage" }) 34 | public static Context create(final String commitMessage) { 35 | return new AutoValue_Context(commitMessage); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/insights/InsightReportDataLink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.insights; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | @AutoValue 24 | public abstract class InsightReportDataLink { 25 | public abstract String linkText(); 26 | 27 | public abstract String href(); 28 | 29 | @SerializedNames({ "linktext", "href" }) 30 | public static InsightReportDataLink create(final String linkText, final String href) { 31 | return new AutoValue_InsightReportDataLink(linkText, href); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/CreateAnnotations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.options; 19 | 20 | import com.cdancy.bitbucket.rest.domain.insights.Annotation; 21 | import com.google.auto.value.AutoValue; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | import java.util.List; 25 | 26 | @AutoValue 27 | public abstract class CreateAnnotations { 28 | 29 | public abstract List annotations(); 30 | 31 | @SerializedNames({"annotations"}) 32 | public static CreateAnnotations create(final List annotations) { 33 | return new AutoValue_CreateAnnotations(annotations); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/pullrequest/Properties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.pullrequest; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | @AutoValue 24 | public abstract class Properties { 25 | 26 | public abstract long openTaskCount(); 27 | 28 | public abstract long resolvedTaskCount(); 29 | 30 | @SerializedNames({"openTaskCount", "resolvedTaskCount"}) 31 | public static Properties create(final long openTaskCount, final long resolvedTaskCount) { 32 | return new AutoValue_Properties(openTaskCount, resolvedTaskCount); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/file/Line.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.file; 19 | 20 | import org.jclouds.json.SerializedNames; 21 | 22 | import com.google.auto.value.AutoValue; 23 | import org.jclouds.javax.annotation.Nullable; 24 | 25 | @AutoValue 26 | public abstract class Line { 27 | 28 | @Nullable 29 | public abstract String text(); 30 | 31 | @Nullable 32 | public abstract String type(); 33 | 34 | Line() { 35 | } 36 | 37 | @SerializedNames({ "text", "type" }) 38 | public static Line create(final String text, final String type) { 39 | return new AutoValue_Line(text, type); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/repository/WebHookConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.repository; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class WebHookConfiguration { 26 | 27 | @Nullable 28 | public abstract String secret(); 29 | 30 | WebHookConfiguration() { 31 | } 32 | 33 | @SerializedNames({ "secret" }) 34 | public static WebHookConfiguration create(@Nullable final String secret) { 35 | return new AutoValue_WebHookConfiguration(secret); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/defaultreviewers/Scope.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.defaultreviewers; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | @AutoValue 24 | public abstract class Scope { 25 | 26 | public enum ScopeType { 27 | REPOSITORY, 28 | PROJECT 29 | } 30 | 31 | public abstract ScopeType type(); 32 | 33 | public abstract Long resourceId(); 34 | 35 | @SerializedNames({ "type", "resourceId"}) 36 | public static Scope create(final ScopeType type, final Long resourceId) { 37 | return new AutoValue_Scope(type, resourceId); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/pullrequest/Parents.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.pullrequest; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class Parents { 26 | 27 | public abstract String id(); 28 | 29 | @Nullable 30 | public abstract String displayId(); 31 | 32 | Parents() { 33 | } 34 | 35 | @SerializedNames({ "id", "displayId" }) 36 | public static Parents create(final String id, final String displayId) { 37 | return new AutoValue_Parents(id, displayId); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/annotations/Documentation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.annotations; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Provides a potential list of URI's for further documentation. 27 | */ 28 | @Target(value = {ElementType.TYPE, ElementType.METHOD}) 29 | @Retention(value = RetentionPolicy.RUNTIME) 30 | public @interface Documentation { 31 | 32 | /** 33 | * List of documentation URI's. 34 | * 35 | * @return list of URI's. 36 | */ 37 | public String[] value(); 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/com/cdancy/bitbucket/rest/features/BitbucketClientMockTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.features; 19 | 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.testng.annotations.Test; 23 | 24 | import com.cdancy.bitbucket.rest.BitbucketClient; 25 | import com.cdancy.bitbucket.rest.BaseBitbucketMockTest; 26 | 27 | @Test(groups = "unit", testName = "BitbucketClientMockTest") 28 | public class BitbucketClientMockTest extends BaseBitbucketMockTest { 29 | 30 | @Test 31 | public void testCreateClient() { 32 | final BitbucketClient client = BitbucketClient.builder().build(); 33 | assertThat(client).isNotNull(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/build/Summary.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.build; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | @AutoValue 24 | public abstract class Summary { 25 | 26 | public abstract long failed(); 27 | 28 | public abstract long inProgress(); 29 | 30 | public abstract long successful(); 31 | 32 | @SerializedNames({"failed", "inProgress", "successful"}) 33 | public static Summary create(final long failed, 34 | final long inProgress, 35 | final long successful) { 36 | return new AutoValue_Summary(failed, inProgress, successful); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/sshkey/Key.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.sshkey; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class Key { 26 | 27 | @Nullable 28 | public abstract Long id(); 29 | 30 | public abstract String text(); 31 | 32 | public abstract String label(); 33 | 34 | @SerializedNames({"id", "text", "label"}) 35 | public static Key create(@Nullable final Long id, 36 | final String text, 37 | final String label) { 38 | return new AutoValue_Key(id, text, label); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/CreateAccessKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.options; 19 | 20 | import com.cdancy.bitbucket.rest.domain.sshkey.AccessKey.PermissionType; 21 | 22 | import com.google.auto.value.AutoValue; 23 | import org.jclouds.json.SerializedNames; 24 | 25 | @AutoValue 26 | public abstract class CreateAccessKey { 27 | 28 | public abstract CreateKey key(); 29 | 30 | public abstract PermissionType permission(); 31 | 32 | CreateAccessKey() { 33 | } 34 | 35 | @SerializedNames({ "key", "permission" }) 36 | public static CreateAccessKey create(final CreateKey key, final PermissionType permission) { 37 | return new AutoValue_CreateAccessKey(key, permission); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/branch/BranchConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.branch; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class BranchConfiguration { 26 | 27 | @Nullable 28 | public abstract String refId(); 29 | 30 | public abstract boolean useDefault(); 31 | 32 | BranchConfiguration() { 33 | } 34 | 35 | @SerializedNames({ "refId", "useDefault" }) 36 | public static BranchConfiguration create(final String refId, final boolean useDefault) { 37 | return new AutoValue_BranchConfiguration(refId, useDefault); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/common/Veto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.common; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class Veto { 26 | 27 | @Nullable 28 | public abstract String summaryMessage(); 29 | 30 | @Nullable 31 | public abstract String detailedMessage(); 32 | 33 | Veto() { 34 | } 35 | 36 | @SerializedNames({ "summaryMessage", "detailedMessage" }) 37 | public static Veto create(final String summaryMessage, final String detailedMessage) { 38 | return new AutoValue_Veto(summaryMessage, detailedMessage); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/resources/repository-hooks.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 3, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "values": [ 6 | { 7 | "details": { 8 | "key": "de.aeffle.stash.plugin.stash-http-get-post-receive-hook:http-get-post-receive-hook", 9 | "name": "Http Request Post Receive Hook", 10 | "type": "POST_RECEIVE", 11 | "description": "Does a HTTP request of an URL after a git push has been received.", 12 | "version": "4.2.1", 13 | "configFormKey": "de.aeffle.stash.plugin.stash-http-get-post-receive-hook:http-get-post-receive-hook-config-form" 14 | }, 15 | "enabled": false, 16 | "configured": false 17 | }, 18 | { 19 | "details": { 20 | "key": "com.atlassian.bitbucket.server.bitbucket-bundled-hooks:force-push-hook", 21 | "name": "Reject Force Push", 22 | "type": "PRE_RECEIVE", 23 | "description": "Reject all force pushes (git push --force) to this repository", 24 | "version": "5.0.0", 25 | "configFormKey": null 26 | }, 27 | "enabled": false, 28 | "configured": false 29 | }, 30 | { 31 | "details": { 32 | "key": "com.atlassian.bitbucket.server.bitbucket-bundled-hooks:verify-committer-hook", 33 | "name": "Verify Committer", 34 | "type": "PRE_RECEIVE", 35 | "description": "Reject commits not committed by the user pushing to this repository", 36 | "version": "5.0.0", 37 | "configFormKey": null 38 | }, 39 | "enabled": false, 40 | "configured": false 41 | } 42 | ], 43 | "start": 0 44 | } -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/search/SearchPathMatch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.search; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class SearchPathMatch { 26 | 27 | public abstract boolean match(); 28 | 29 | @Nullable 30 | public abstract String text(); 31 | 32 | SearchPathMatch() { 33 | } 34 | 35 | @SerializedNames({ "match", "text" }) 36 | public static SearchPathMatch create(final boolean match, 37 | final String text) { 38 | 39 | return new AutoValue_SearchPathMatch(match, 40 | text); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/exception/MethodNotAllowedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.exception; 19 | 20 | /** 21 | * Thrown when a method was used that is not supported by this endpoint. 22 | */ 23 | public class MethodNotAllowedException extends RuntimeException { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | public MethodNotAllowedException() { 28 | super(); 29 | } 30 | 31 | public MethodNotAllowedException(final String arg0, final Throwable arg1) { 32 | super(arg0, arg1); 33 | } 34 | 35 | public MethodNotAllowedException(final String arg0) { 36 | super(arg0); 37 | } 38 | 39 | public MethodNotAllowedException(final Throwable arg0) { 40 | super(arg0); 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/search/SearchHitContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.search; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class SearchHitContext { 26 | 27 | @Nullable 28 | public abstract String line(); 29 | 30 | @Nullable 31 | public abstract String text(); 32 | 33 | SearchHitContext() { 34 | } 35 | 36 | @SerializedNames({ "line", "text" }) 37 | public static SearchHitContext create(final String line, 38 | final String text) { 39 | 40 | return new AutoValue_SearchHitContext(line, 41 | text); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/resources/accesskeys-list-by-repository.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 25, 4 | "isLastPage": true, 5 | "values": [ 6 | { 7 | "key": { 8 | "id": 1, 9 | "text": "ssh-rsa abc", 10 | "label": "abc" 11 | }, 12 | "repository": { 13 | "slug": "my-repo", 14 | "id": 1, 15 | "name": "my-repo", 16 | "scmId": "git", 17 | "state": "AVAILABLE", 18 | "statusMessage": "Available", 19 | "forkable": true, 20 | "project": { 21 | "key": "MY-PROJECT", 22 | "id": 626, 23 | "name": "MY-PROJECT", 24 | "description": "Example.", 25 | "public": false, 26 | "type": "NORMAL", 27 | "links": { 28 | "self": [ 29 | { 30 | "href": "https://my-bitbucket.com/bitbucket/projects/MY-PROJECT" 31 | } 32 | ] 33 | } 34 | }, 35 | "public": false, 36 | "links": { 37 | "clone": [ 38 | { 39 | "href": "ssh://git@my-bitbucket.com:7999/MY-PROJECT/my-repo.git", 40 | "name": "ssh" 41 | }, 42 | { 43 | "href": "https://my-bitbucket.com/bitbucket/scm/MY-PROJECT/my-repo.git", 44 | "name": "http" 45 | } 46 | ], 47 | "self": [ 48 | { 49 | "href": "https://my-bitbucket.com/bitbucket/projects/MY-PROJECT/repos/my-repo/browse" 50 | } 51 | ] 52 | } 53 | }, 54 | "permission": "REPO_READ" 55 | } 56 | ], 57 | "start": 0 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/exception/ForbiddenException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.exception; 19 | 20 | /** 21 | * Thrown when an action has breached the licensed user limit of the server, or 22 | * degrading the authenticated user's permission level. 23 | */ 24 | public class ForbiddenException extends RuntimeException { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public ForbiddenException() { 29 | super(); 30 | } 31 | 32 | public ForbiddenException(final String arg0, final Throwable arg1) { 33 | super(arg0, arg1); 34 | } 35 | 36 | public ForbiddenException(final String arg0) { 37 | super(arg0); 38 | } 39 | 40 | public ForbiddenException(final Throwable arg0) { 41 | super(arg0); 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/branch/BranchRestrictionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.branch; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | @AutoValue 24 | public abstract class BranchRestrictionType { 25 | 26 | public abstract String id(); 27 | 28 | public abstract String name(); 29 | 30 | @SerializedNames({"id", "name"}) 31 | public static BranchRestrictionType create(final String id, final String name) { 32 | return new AutoValue_BranchRestrictionType(id, name); 33 | } 34 | 35 | public static BranchRestrictionType create(final Matcher.MatcherId matcherId) { 36 | return new AutoValue_BranchRestrictionType(matcherId.getTypeId(), matcherId.getTypeName()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/labels/Label.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.labels; 19 | 20 | import com.cdancy.bitbucket.rest.BitbucketUtils; 21 | import com.cdancy.bitbucket.rest.domain.common.Error; 22 | import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder; 23 | import com.google.auto.value.AutoValue; 24 | import org.jclouds.json.SerializedNames; 25 | 26 | import java.util.List; 27 | 28 | @AutoValue 29 | public abstract class Label implements ErrorsHolder { 30 | 31 | public abstract String name(); 32 | 33 | Label() { 34 | } 35 | 36 | @SerializedNames({"name", "errors"}) 37 | public static Label create(final String name, final List errors) { 38 | return new AutoValue_Label(BitbucketUtils.nullToEmpty(errors), name); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/com/cdancy/bitbucket/rest/features/LabelsApiLiveTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.features; 19 | 20 | import com.cdancy.bitbucket.rest.BaseBitbucketApiLiveTest; 21 | import org.testng.annotations.Test; 22 | 23 | import static org.assertj.core.api.Assertions.assertThat; 24 | 25 | @Test(groups = "live", testName = "LabelsApiLiveTest", singleThreaded = true) 26 | public class LabelsApiLiveTest extends BaseBitbucketApiLiveTest { 27 | 28 | @Test 29 | public void testLabel() { 30 | assertThat(api().list(null).values()).isEmpty(); 31 | } 32 | 33 | @Test 34 | public void testLabelByName() { 35 | assertThat(api().getLabelByName("labelName").name()).isEmpty(); 36 | } 37 | 38 | private LabelsApi api() { 39 | return api.labelsApi(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/common/Links.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.common; 19 | 20 | import java.util.List; 21 | import java.util.Map; 22 | 23 | import org.jclouds.json.SerializedNames; 24 | 25 | import com.cdancy.bitbucket.rest.BitbucketUtils; 26 | import com.google.auto.value.AutoValue; 27 | 28 | @AutoValue 29 | public abstract class Links { 30 | 31 | public abstract List> clone(); 32 | 33 | public abstract List> self(); 34 | 35 | Links() { 36 | } 37 | 38 | @SerializedNames({ "clone", "self" }) 39 | public static Links create(final List> clone, final List> self) { 40 | return new AutoValue_Links(BitbucketUtils.nullToEmpty(clone), BitbucketUtils.nullToEmpty(self)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/comment/PermittedOperations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.comment; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | @AutoValue 24 | public abstract class PermittedOperations { 25 | 26 | public abstract boolean editable(); 27 | 28 | public abstract boolean deletable(); 29 | 30 | public abstract boolean transitionable(); 31 | 32 | PermittedOperations() { 33 | } 34 | 35 | @SerializedNames({ "editable", "deletable", "transitionable" }) 36 | public static PermittedOperations create(final boolean editable, 37 | final boolean deletable, 38 | final boolean transitionable) { 39 | return new AutoValue_PermittedOperations(editable, deletable, transitionable); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/config/BitbucketAuthenticationModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.config; 19 | 20 | import com.cdancy.bitbucket.rest.BitbucketAuthentication; 21 | import com.google.inject.AbstractModule; 22 | import java.util.Objects; 23 | 24 | /** 25 | * Configure the provider for BitbucketAuthentication. 26 | */ 27 | public class BitbucketAuthenticationModule extends AbstractModule { 28 | 29 | private final BitbucketAuthentication authentication; 30 | 31 | public BitbucketAuthenticationModule(final BitbucketAuthentication authentication) { 32 | this.authentication = Objects.requireNonNull(authentication); 33 | } 34 | 35 | @Override 36 | protected void configure() { 37 | bind(BitbucketAuthentication.class).toProvider(new BitbucketAuthenticationProvider(authentication)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/CreateTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.options; 19 | 20 | import com.cdancy.bitbucket.rest.domain.comment.MinimalAnchor; 21 | import com.google.auto.value.AutoValue; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class CreateTask { 26 | 27 | public abstract MinimalAnchor anchor(); 28 | 29 | public abstract String text(); 30 | 31 | CreateTask() { 32 | } 33 | 34 | @SerializedNames({"anchor", "text" }) 35 | public static CreateTask create(final MinimalAnchor anchor, final String text) { 36 | return new AutoValue_CreateTask(anchor, text); 37 | } 38 | 39 | public static CreateTask create(final int id, final String text) { 40 | return CreateTask.create(MinimalAnchor.create(id, "COMMENT"), text); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/activities/ActivitiesCommit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.activities; 19 | 20 | import com.cdancy.bitbucket.rest.domain.commit.Commit; 21 | import com.cdancy.bitbucket.rest.BitbucketUtils; 22 | import com.google.auto.value.AutoValue; 23 | import org.jclouds.javax.annotation.Nullable; 24 | import org.jclouds.json.SerializedNames; 25 | 26 | import java.util.List; 27 | 28 | @AutoValue 29 | public abstract class ActivitiesCommit { 30 | 31 | @Nullable 32 | public abstract List commits(); 33 | 34 | public abstract long total(); 35 | 36 | @SerializedNames({"commits", "total"}) 37 | public static ActivitiesCommit create(@Nullable final List commits, final long total) { 38 | return new AutoValue_ActivitiesCommit(BitbucketUtils.nullToEmpty(commits), total); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/pullrequest/MinimalRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.pullrequest; 19 | 20 | import org.jclouds.javax.annotation.Nullable; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | import com.google.auto.value.AutoValue; 24 | 25 | @AutoValue 26 | public abstract class MinimalRepository { 27 | 28 | public abstract String slug(); 29 | 30 | @Nullable 31 | public abstract String name(); 32 | 33 | public abstract ProjectKey project(); 34 | 35 | MinimalRepository() { 36 | } 37 | 38 | @SerializedNames({ "slug", "name", "project" }) 39 | public static MinimalRepository create(final String slug, 40 | final String name, 41 | final ProjectKey project) { 42 | 43 | return new AutoValue_MinimalRepository(slug, name, project); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/CreateTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.options; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class CreateTag { 26 | 27 | public abstract String name(); 28 | 29 | public abstract String startPoint(); 30 | 31 | // defaults to value of name if null 32 | @Nullable 33 | public abstract String message(); 34 | 35 | CreateTag() { 36 | } 37 | 38 | @SerializedNames({ "name", "startPoint", "message" }) 39 | public static CreateTag create(final String name, 40 | final String startPoint, 41 | final String message) { 42 | return new AutoValue_CreateTag(name, startPoint, message != null ? message : name); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/CreateRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.options; 19 | 20 | import org.jclouds.javax.annotation.Nullable; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | import com.google.auto.value.AutoValue; 24 | 25 | @AutoValue 26 | public abstract class CreateRepository { 27 | 28 | public abstract String name(); 29 | 30 | @Nullable 31 | public abstract String description(); 32 | 33 | public abstract String scmId(); 34 | 35 | public abstract boolean forkable(); 36 | 37 | CreateRepository() { 38 | } 39 | 40 | @SerializedNames({ "name", "description", "scmId", "forkable" }) 41 | public static CreateRepository create(final String name, final String description, final boolean forkable) { 42 | return new AutoValue_CreateRepository(name, description,"git", forkable); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/CreateBranch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.options; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class CreateBranch { 26 | 27 | public abstract String name(); 28 | 29 | public abstract String startPoint(); 30 | 31 | // defaults to value of name if null 32 | @Nullable 33 | public abstract String message(); 34 | 35 | CreateBranch() { 36 | } 37 | 38 | @SerializedNames({ "name", "startPoint", "message" }) 39 | public static CreateBranch create(final String name, 40 | final String startPoint, 41 | final String message) { 42 | return new AutoValue_CreateBranch(name, startPoint, message != null ? message : name); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/parsers/RequestStatusParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.parsers; 19 | 20 | import com.cdancy.bitbucket.rest.domain.common.RequestStatus; 21 | import com.google.common.base.Function; 22 | import jakarta.inject.Singleton; 23 | import org.jclouds.http.HttpResponse; 24 | 25 | /** 26 | * Turn a valid response, but one that has no body, into a RequestStatus. 27 | */ 28 | @Singleton 29 | public class RequestStatusParser implements Function { 30 | 31 | @Override 32 | public RequestStatus apply(final HttpResponse input) { 33 | final int statusCode = input.getStatusCode(); 34 | if (statusCode >= 200 && statusCode < 400) { 35 | return RequestStatus.create(true, null); 36 | } else { 37 | throw new RuntimeException(input.getStatusLine()); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/resources/branch-list.json: -------------------------------------------------------------------------------- 1 | { 2 | "size": 1, 3 | "limit": 1, 4 | "isLastPage": false, 5 | "values": [ 6 | { 7 | "id": "refs/heads/hello-world", 8 | "displayId": "hello-world", 9 | "latestChangeset": "e73efd28360ed2ec94804d582c591d2d3ba6bcc4", 10 | "isDefault": false, 11 | "metadata": { 12 | "com.atlassian.bitbucket.server.bitbucket-jira:branch-list-jira-issues": [ 13 | { 14 | "key": "CICD-4590", 15 | "url": "https://acme.com/plugins/servlet/jira-integration/issues/CICD-4590" 16 | } 17 | ], 18 | "com.atlassian.bitbucket.server.bitbucket-branch:ahead-behind-metadata-provider": { 19 | "ahead": 1, 20 | "behind": 0 21 | }, 22 | "com.atlassian.bitbucket.server.bitbucket-branch:latest-commit-metadata": { 23 | "id": "026e014dc71376bafc601c155fca75bd5dab8205", 24 | "displayId": "026e014dc71", 25 | "author": { 26 | "name": "Sergey", 27 | "emailAddress": "slysyuk@acme.com", 28 | "avatarUrl": "https://secure.gravatar.com/avatar/724799292f3a225600f4d4644468171c.jpg?s=64&d=mm" 29 | }, 30 | "authorTimestamp": 1495834461000, 31 | "message": "sticky fix", 32 | "parents": [ 33 | { 34 | "id": "5114f8c7dcc51f9c85a223429938a0b5598d238d", 35 | "displayId": "5114f8c7dcc" 36 | } 37 | ] 38 | }, 39 | "com.atlassian.bitbucket.server.bitbucket-build:build-status-metadata": { 40 | "successful": 1, 41 | "inProgress": 0, 42 | "failed": 0 43 | } 44 | } 45 | } 46 | ], 47 | "start": 0, 48 | "nextPageStart": 1 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/config/BitbucketAuthenticationProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.config; 19 | 20 | import com.cdancy.bitbucket.rest.BitbucketAuthentication; 21 | import com.google.inject.Inject; 22 | import com.google.inject.Provider; 23 | 24 | /** 25 | * Provider for BitbucketAuthentication objects. The BitbucketAuthentication 26 | * should be created ahead of time with this module simply handing it out 27 | * to downstream objects for injection. 28 | */ 29 | public class BitbucketAuthenticationProvider implements Provider { 30 | 31 | private final BitbucketAuthentication creds; 32 | 33 | @Inject 34 | public BitbucketAuthenticationProvider(final BitbucketAuthentication creds) { 35 | this.creds = creds; 36 | } 37 | 38 | @Override 39 | public BitbucketAuthentication get() { 40 | return creds; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/com/cdancy/bitbucket/rest/features/SystemApiLiveTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.features; 19 | 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.testng.annotations.Test; 23 | 24 | import com.cdancy.bitbucket.rest.BaseBitbucketApiLiveTest; 25 | import com.cdancy.bitbucket.rest.domain.system.Version; 26 | 27 | @Test(groups = "live", testName = "SystemApiLiveTest", singleThreaded = true) 28 | public class SystemApiLiveTest extends BaseBitbucketApiLiveTest { 29 | 30 | private final String versionRegex = "^\\d+\\.\\d+\\.\\d+$"; 31 | 32 | @Test 33 | public void testGetVersion() { 34 | final Version version = api().version(); 35 | assertThat(version).isNotNull(); 36 | assertThat(version.version().matches(versionRegex)).isTrue(); 37 | } 38 | 39 | private SystemApi api() { 40 | return api.systemApi(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/file/RawContent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.file; 19 | 20 | import java.util.List; 21 | 22 | import org.jclouds.javax.annotation.Nullable; 23 | import org.jclouds.json.SerializedNames; 24 | 25 | import com.cdancy.bitbucket.rest.domain.common.Error; 26 | import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder; 27 | import com.cdancy.bitbucket.rest.domain.common.Value; 28 | import com.cdancy.bitbucket.rest.BitbucketUtils; 29 | import com.google.auto.value.AutoValue; 30 | 31 | @AutoValue 32 | public abstract class RawContent implements Value, ErrorsHolder { 33 | 34 | @SerializedNames({ "value", "errors" }) 35 | public static RawContent create(@Nullable final String value, 36 | final List errors) { 37 | 38 | return new AutoValue_RawContent(value, 39 | BitbucketUtils.nullToEmpty(errors)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/CreateComment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.options; 19 | 20 | import com.cdancy.bitbucket.rest.domain.comment.Anchor; 21 | import com.cdancy.bitbucket.rest.domain.comment.Parent; 22 | import com.google.auto.value.AutoValue; 23 | import org.jclouds.javax.annotation.Nullable; 24 | import org.jclouds.json.SerializedNames; 25 | 26 | @AutoValue 27 | public abstract class CreateComment { 28 | 29 | public abstract String text(); 30 | 31 | @Nullable 32 | public abstract Parent parent(); 33 | 34 | @Nullable 35 | public abstract Anchor anchor(); 36 | 37 | CreateComment() { 38 | } 39 | 40 | @SerializedNames({ "text", "parent", "anchor" }) 41 | public static CreateComment create(final String text, 42 | final Parent parent, 43 | final Anchor anchor) { 44 | return new AutoValue_CreateComment(text, parent, anchor); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/system/Version.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.system; 19 | 20 | import org.jclouds.json.SerializedNames; 21 | 22 | import com.google.auto.value.AutoValue; 23 | 24 | @AutoValue 25 | public abstract class Version { 26 | 27 | public abstract String version(); 28 | 29 | public abstract String buildNumber(); 30 | 31 | public abstract String buildDate(); 32 | 33 | public abstract String displayName(); 34 | 35 | Version() { 36 | } 37 | 38 | @SerializedNames({ "version", "buildNumber", "buildDate", "displayName" }) 39 | public static Version create(final String version, 40 | final String buildNumber, 41 | final String buildDate, 42 | final String displayName) { 43 | return new AutoValue_Version(version, 44 | buildNumber, 45 | buildDate, 46 | displayName); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/repository/Permissions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.repository; 19 | 20 | import com.cdancy.bitbucket.rest.domain.pullrequest.User; 21 | import com.google.auto.value.AutoValue; 22 | import org.jclouds.javax.annotation.Nullable; 23 | import org.jclouds.json.SerializedNames; 24 | 25 | @AutoValue 26 | public abstract class Permissions { 27 | 28 | public enum PermissionsType { 29 | REPO_ADMIN, 30 | REPO_WRITE, 31 | REPO_READ 32 | } 33 | 34 | @Nullable 35 | public abstract User user(); 36 | 37 | @Nullable 38 | public abstract Group group(); 39 | 40 | public abstract PermissionsType permission(); 41 | 42 | @SerializedNames({"user", "group", "permission"}) 43 | public static Permissions create(final User user, 44 | final Group group, 45 | final PermissionsType type) { 46 | return new AutoValue_Permissions(user, group, type); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/pullrequest/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.pullrequest; 19 | 20 | import org.jclouds.javax.annotation.Nullable; 21 | import org.jclouds.json.SerializedNames; 22 | 23 | import com.google.auto.value.AutoValue; 24 | 25 | @AutoValue 26 | public abstract class Person { 27 | 28 | public abstract User user(); 29 | 30 | @Nullable 31 | public abstract String role(); 32 | 33 | public abstract boolean approved(); 34 | 35 | @Nullable 36 | public abstract String status(); 37 | 38 | Person() { 39 | } 40 | 41 | @SerializedNames({ "user", "role", "approved", "status" }) 42 | public static Person create(final User user, 43 | final String role, 44 | final boolean approved, 45 | final String status) { 46 | 47 | return new AutoValue_Person(user, 48 | role, 49 | approved, 50 | status); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/binders/BindHookSettingsToPayload.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.binders; 19 | 20 | import static com.google.common.base.Preconditions.checkArgument; 21 | 22 | import com.cdancy.bitbucket.rest.domain.repository.HookSettings; 23 | 24 | import jakarta.inject.Singleton; 25 | 26 | import org.jclouds.http.HttpRequest; 27 | import org.jclouds.rest.Binder; 28 | 29 | @Singleton 30 | public class BindHookSettingsToPayload implements Binder { 31 | 32 | @SuppressWarnings("unchecked") 33 | @Override 34 | public R bindToRequest(final R request, final Object hookSettings) { 35 | checkArgument(hookSettings instanceof HookSettings, "binder is only valid for HookSettings"); 36 | final HookSettings passedHookSettings = HookSettings.class.cast(hookSettings); 37 | final String payload = passedHookSettings.settings().toString(); 38 | return (R) request.toBuilder().payload(payload).build(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/binders/BindSearchRequestToPayload.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.binders; 19 | 20 | import static com.google.common.base.Preconditions.checkArgument; 21 | 22 | import com.cdancy.bitbucket.rest.domain.search.SearchRequest; 23 | 24 | import jakarta.inject.Singleton; 25 | 26 | import org.jclouds.http.HttpRequest; 27 | import org.jclouds.rest.Binder; 28 | 29 | @Singleton 30 | public class BindSearchRequestToPayload implements Binder { 31 | 32 | @SuppressWarnings("unchecked") 33 | @Override 34 | public R bindToRequest(final R request, final Object searchRequest) { 35 | checkArgument(searchRequest instanceof SearchRequest, "binder is only valid for SearchRequest"); 36 | final SearchRequest passedSearchRequest = SearchRequest.class.cast(searchRequest); 37 | final String payload = passedSearchRequest.request().toString(); 38 | return (R) request.toBuilder().payload(payload).build(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/search/SearchScope.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.search; 19 | 20 | import com.cdancy.bitbucket.rest.domain.project.Project; 21 | import com.google.auto.value.AutoValue; 22 | import org.jclouds.javax.annotation.Nullable; 23 | import org.jclouds.json.SerializedNames; 24 | 25 | @AutoValue 26 | public abstract class SearchScope { 27 | 28 | @Nullable 29 | public abstract Project project(); 30 | 31 | @Nullable 32 | public abstract String type(); 33 | 34 | @Nullable 35 | public abstract SearchQuery query(); 36 | 37 | SearchScope() { 38 | } 39 | 40 | @SerializedNames({ "project", "type", "query" }) 41 | public static SearchScope create(final Project project, 42 | final String type, 43 | final SearchQuery query) { 44 | 45 | return new AutoValue_SearchScope(project, 46 | type, 47 | query); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/parsers/RawContentParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.parsers; 19 | 20 | import com.cdancy.bitbucket.rest.domain.file.RawContent; 21 | import com.google.common.base.Function; 22 | import com.google.common.base.Throwables; 23 | import java.io.InputStream; 24 | import jakarta.inject.Singleton; 25 | import org.jclouds.http.HttpResponse; 26 | import org.jclouds.util.Strings2; 27 | 28 | /** 29 | * Parse body of response into RawContent. 30 | */ 31 | @Singleton 32 | public class RawContentParser implements Function { 33 | 34 | @Override 35 | public RawContent apply(final HttpResponse input) { 36 | try (final InputStream inputStream = input.getPayload().openStream()) { 37 | final String value = Strings2.toStringAndClose(inputStream); 38 | return RawContent.create(value, null); 39 | } catch (final Exception e) { 40 | throw Throwables.propagate(e); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/CreateProject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.options; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class CreateProject { 26 | 27 | public abstract String key(); 28 | 29 | // defaults to value of key if null 30 | @Nullable 31 | public abstract String name(); 32 | 33 | @Nullable 34 | public abstract String description(); 35 | 36 | @Nullable 37 | public abstract String avatar(); 38 | 39 | CreateProject() { 40 | } 41 | 42 | @SerializedNames({ "key", "name", "description", "avatar" }) 43 | public static CreateProject create(final String key, 44 | final String name, 45 | final String description, 46 | final String avatar) { 47 | return new AutoValue_CreateProject(key, name != null ? name : key, description, avatar); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/config/BitbucketHttpApiModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.config; 19 | 20 | import org.jclouds.http.HttpErrorHandler; 21 | import org.jclouds.http.annotation.ClientError; 22 | import org.jclouds.http.annotation.Redirection; 23 | import org.jclouds.http.annotation.ServerError; 24 | import org.jclouds.rest.ConfiguresHttpApi; 25 | import org.jclouds.rest.config.HttpApiModule; 26 | 27 | import com.cdancy.bitbucket.rest.BitbucketApi; 28 | import com.cdancy.bitbucket.rest.handlers.BitbucketErrorHandler; 29 | 30 | @ConfiguresHttpApi 31 | public class BitbucketHttpApiModule extends HttpApiModule { 32 | 33 | @Override 34 | protected void bindErrorHandlers() { 35 | bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(BitbucketErrorHandler.class); 36 | bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(BitbucketErrorHandler.class); 37 | bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(BitbucketErrorHandler.class); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/resources/repository-fork.json: -------------------------------------------------------------------------------- 1 | { 2 | "slug": "hello-world", 3 | "id": 2, 4 | "name": "hello world", 5 | "scmId": "git", 6 | "state": "AVAILABLE", 7 | "statusMessage": "Available", 8 | "forkable": true, 9 | "origin": { 10 | "slug": "my-repo", 11 | "id": 1, 12 | "name": "My repo", 13 | "scmId": "git", 14 | "state": "AVAILABLE", 15 | "statusMessage": "Available", 16 | "forkable": true, 17 | "project": { 18 | "key": "PRJ", 19 | "id": 1, 20 | "name": "My Cool Project", 21 | "description": "The description for my cool project.", 22 | "public": true, 23 | "type": "NORMAL", 24 | "links": { 25 | "self": [ 26 | { 27 | "href": "http://link/to/project" 28 | } 29 | ] 30 | } 31 | }, 32 | "public": true, 33 | "links": { 34 | "clone": [ 35 | { 36 | "href": "ssh://git@/PRJ/my-repo.git", 37 | "name": "ssh" 38 | }, 39 | { 40 | "href": "https:///scm/PRJ/my-repo.git", 41 | "name": "http" 42 | } 43 | ], 44 | "self": [ 45 | { 46 | "href": "http://link/to/repository" 47 | } 48 | ] 49 | } 50 | }, 51 | "project": { 52 | "key": "~JDOE", 53 | "id": 2, 54 | "name": "John Doe", 55 | "type": "PERSONAL", 56 | "links": { 57 | "self": [ 58 | { 59 | "href": "http://link/to/project" 60 | } 61 | ] 62 | } 63 | }, 64 | "links": { 65 | "clone": [ 66 | { 67 | "href": "https:///scm/JDOE/my-repo.git", 68 | "name": "http" 69 | }, 70 | { 71 | "href": "ssh://git@/JDOE/my-repo.git", 72 | "name": "ssh" 73 | } 74 | ], 75 | "self": [ 76 | { 77 | "href": "http://link/to/repository" 78 | } 79 | ] 80 | } 81 | } -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # How to contribute 3 | 4 | ## Getting Started 5 | 6 | * Make sure you have a [GitHub account](https://github.com/signup/free) 7 | * Submit a ticket for your issue, assuming one does not already exist. 8 | * Clearly describe the issue including steps to reproduce when it is a bug. 9 | * Make sure you fill in the earliest version that you know has the issue. 10 | * Fork the repository on GitHub 11 | 12 | ## Making Changes 13 | 14 | * Create a topic branch from where you want to base your work. 15 | * This is usually the master branch. 16 | * Only target release branches if you are certain your fix must be on that 17 | branch. 18 | * To quickly create a topic branch based on master; `git checkout -b 19 | fix/master/my_contribution master`. Please avoid working directly on the 20 | `master` branch. 21 | * Make commits of logical units. 22 | * Check for unnecessary whitespace with `git diff --check` before committing. 23 | * Make sure your commit messages are in the proper format: 24 | 25 | `ISSUE-1234: terse and to the point message describing change` 26 | 27 | * Make sure you have added the necessary tests for your changes. 28 | * Run _all_ the tests to assure nothing else was accidentally broken. 29 | * Make sure you've done a squash and rebase before submitting 30 | 31 | ## Submitting Changes 32 | 33 | * Push your changes to a topic branch in your fork of the repository. 34 | * Submit a pull request. 35 | * After feedback has been given we expect responses within two weeks. After two 36 | weeks we may close the pull request if it isn't showing any activity. 37 | 38 | # Additional Resources 39 | 40 | * [General GitHub documentation](https://help.github.com/) 41 | * [GitHub pull request documentation](https://help.github.com/send-pull-requests/) 42 | * [Squash and Rebase](https://github.com/ginatrapani/todo.txt-android/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit) 43 | 44 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/features/SystemApi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.features; 19 | 20 | import com.cdancy.bitbucket.rest.annotations.Documentation; 21 | import jakarta.inject.Named; 22 | import jakarta.ws.rs.Consumes; 23 | import jakarta.ws.rs.GET; 24 | import jakarta.ws.rs.Path; 25 | import jakarta.ws.rs.Produces; 26 | import jakarta.ws.rs.core.MediaType; 27 | 28 | import org.jclouds.rest.annotations.RequestFilters; 29 | 30 | import com.cdancy.bitbucket.rest.domain.system.Version; 31 | import com.cdancy.bitbucket.rest.filters.BitbucketAuthenticationFilter; 32 | 33 | @Produces(MediaType.APPLICATION_JSON) 34 | @RequestFilters(BitbucketAuthenticationFilter.class) 35 | @Path("/rest/api/{jclouds.api-version}") 36 | @SuppressWarnings("PMD.AvoidDuplicateLiterals") 37 | public interface SystemApi { 38 | 39 | @Named("system:version") 40 | @Documentation({"https://developer.atlassian.com/static/rest/bitbucket-server/latest/bitbucket-rest.html"}) 41 | @Consumes(MediaType.APPLICATION_JSON) 42 | @Path("/application-properties") 43 | @GET 44 | Version version(); 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/exception/UnsupportedMediaTypeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.exception; 19 | 20 | /** 21 | * The request entity has a Content-Type that the server does not support. 22 | * Almost all of the Bitbucket REST API accepts application/json format, but 23 | * check the individual resource documentation for more details. Additionally, 24 | * double-check that you are setting the Content-Type header correctly on your 25 | * request (e.g. using -H "Content-Type: application/json" in cURL). 26 | */ 27 | public class UnsupportedMediaTypeException extends RuntimeException { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | public UnsupportedMediaTypeException() { 32 | super(); 33 | } 34 | 35 | public UnsupportedMediaTypeException(final String arg0, final Throwable arg1) { 36 | super(arg0, arg1); 37 | } 38 | 39 | public UnsupportedMediaTypeException(final String arg0) { 40 | super(arg0); 41 | } 42 | 43 | public UnsupportedMediaTypeException(final Throwable arg0) { 44 | super(arg0); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/common/RequestStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.common; 19 | 20 | import java.util.List; 21 | 22 | import org.jclouds.javax.annotation.Nullable; 23 | import org.jclouds.json.SerializedNames; 24 | 25 | import com.cdancy.bitbucket.rest.BitbucketUtils; 26 | import com.google.auto.value.AutoValue; 27 | 28 | /** 29 | * Generic response to be returned when an endpoint returns 30 | * no content (i.e. 204 response code). 31 | * 32 | *

When the response code is valid the `value` parameter will 33 | * be set to true while a non-valid response has the `value` set to 34 | * false along with any potential `error` objects returned from Bitbucket. 35 | */ 36 | @AutoValue 37 | public abstract class RequestStatus implements Value, ErrorsHolder { 38 | 39 | @SerializedNames({ "value", "errors" }) 40 | public static RequestStatus create(@Nullable final Boolean value, 41 | final List errors) { 42 | 43 | return new AutoValue_RequestStatus(value, 44 | BitbucketUtils.nullToEmpty(errors)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/insights/AnnotationsResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.insights; 19 | 20 | import com.cdancy.bitbucket.rest.BitbucketUtils; 21 | import com.cdancy.bitbucket.rest.domain.common.Error; 22 | import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder; 23 | import com.google.auto.value.AutoValue; 24 | import org.jclouds.javax.annotation.Nullable; 25 | import org.jclouds.json.SerializedNames; 26 | 27 | import java.util.List; 28 | 29 | @AutoValue 30 | public abstract class AnnotationsResponse implements ErrorsHolder { 31 | public abstract int totalCount(); 32 | 33 | @Nullable 34 | public abstract List annotations(); 35 | 36 | @SerializedNames({"totalCount", "annotations", "errors"}) 37 | public static AnnotationsResponse create(final int totalCount, 38 | final List annotations, 39 | final List errors) { 40 | return new AutoValue_AnnotationsResponse(BitbucketUtils.nullToEmpty(errors), totalCount, annotations); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/project/ProjectPermissions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.project; 19 | 20 | import com.cdancy.bitbucket.rest.domain.pullrequest.User; 21 | import com.cdancy.bitbucket.rest.domain.repository.Group; 22 | import com.google.auto.value.AutoValue; 23 | import org.jclouds.javax.annotation.Nullable; 24 | import org.jclouds.json.SerializedNames; 25 | 26 | @AutoValue 27 | public abstract class ProjectPermissions { 28 | 29 | public enum PermissionsType { 30 | PROJECT_ADMIN, 31 | PROJECT_WRITE, 32 | PROJECT_READ 33 | } 34 | 35 | @Nullable 36 | public abstract User user(); 37 | 38 | @Nullable 39 | public abstract Group group(); 40 | 41 | public abstract PermissionsType permission(); 42 | 43 | @SerializedNames({"user", "group", "permission"}) 44 | public static ProjectPermissions create(final User user, 45 | final Group group, 46 | final PermissionsType type) { 47 | return new AutoValue_ProjectPermissions(user, group, type); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/com/cdancy/bitbucket/rest/BitbucketApiMetadataTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest; 19 | 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import java.util.HashSet; 23 | 24 | import org.jclouds.View; 25 | import org.jclouds.apis.ApiMetadata; 26 | import org.jclouds.apis.Apis; 27 | import org.jclouds.apis.internal.BaseApiMetadataTest; 28 | import org.testng.annotations.Test; 29 | 30 | import com.google.common.reflect.TypeToken; 31 | 32 | /** 33 | * Unit tests for the {@link BitbucketApiMetadata} class. 34 | */ 35 | @Test(groups = "unit", testName = "BitbucketApiMetadataTest") 36 | public class BitbucketApiMetadataTest extends BaseApiMetadataTest { 37 | 38 | public BitbucketApiMetadataTest() { 39 | super(new BitbucketApiMetadata(), new HashSet>()); 40 | } 41 | 42 | public void testBitbucketApiRegistered() { 43 | final ApiMetadata api = Apis.withId("bitbucket"); 44 | 45 | assertThat(api).isNotNull(); 46 | assertThat(api instanceof BitbucketApiMetadata).isTrue(); 47 | assertThat("bitbucket").isEqualTo(api.getId()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/file/FilesPage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.file; 19 | 20 | import java.util.List; 21 | 22 | import org.jclouds.javax.annotation.Nullable; 23 | import org.jclouds.json.SerializedNames; 24 | 25 | import com.cdancy.bitbucket.rest.domain.common.Error; 26 | import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder; 27 | import com.cdancy.bitbucket.rest.domain.common.Page; 28 | import com.cdancy.bitbucket.rest.BitbucketUtils; 29 | import com.google.auto.value.AutoValue; 30 | 31 | @AutoValue 32 | public abstract class FilesPage implements Page, ErrorsHolder { 33 | 34 | @SerializedNames({ "start", "limit", "size", "nextPageStart", "isLastPage", "values", "errors" }) 35 | public static FilesPage create(final int start, final int limit, final int size, final int nextPageStart, 36 | final boolean isLastPage, @Nullable final List lines, @Nullable final List errors) { 37 | return new AutoValue_FilesPage(start, limit, size, nextPageStart, isLastPage, 38 | BitbucketUtils.nullToEmpty(lines), BitbucketUtils.nullToEmpty(errors)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/repository/MergeConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.repository; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | import java.util.List; 25 | 26 | @AutoValue 27 | public abstract class MergeConfig { 28 | 29 | public enum MergeConfigType { 30 | REPOSITORY, 31 | DEFAULT, 32 | PROJECT 33 | } 34 | 35 | public abstract MergeStrategy defaultStrategy(); 36 | 37 | public abstract List strategies(); 38 | 39 | public abstract MergeConfigType type(); 40 | 41 | @Nullable 42 | public abstract Integer commitSummaries(); 43 | 44 | @SerializedNames({ "defaultStrategy", "strategies", "type", "commitSummaries"}) 45 | public static MergeConfig create(final MergeStrategy defaultStrategy, 46 | final List strategies, 47 | final MergeConfigType type, 48 | final Integer commitSummaries) { 49 | 50 | return new AutoValue_MergeConfig(defaultStrategy, strategies, type, commitSummaries); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/resources/last-modified.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": { 3 | "pom.xml": { 4 | "id": "def0123abcdef4567abcdef8987abcdef6543abc", 5 | "displayId": "def0123abcd", 6 | "author": { 7 | "name": "charlie", 8 | "emailAddress": "charlie@example.com" 9 | }, 10 | "authorTimestamp": 1549862602763, 11 | "committer": { 12 | "name": "charlie", 13 | "emailAddress": "charlie@example.com" 14 | }, 15 | "committerTimestamp": 1549862602763, 16 | "message": "More work on feature 1", 17 | "parents": [ 18 | { 19 | "id": "abcdef0123abcdef4567abcdef8987abcdef6543", 20 | "displayId": "abcdef0" 21 | } 22 | ] 23 | }, 24 | "README.md": { 25 | "id": "abcdef0123abcdef4567abcdef8987abcdef6543", 26 | "displayId": "abcdef0123a", 27 | "author": { 28 | "name": "charlie", 29 | "emailAddress": "charlie@example.com" 30 | }, 31 | "authorTimestamp": 1549862602763, 32 | "committer": { 33 | "name": "charlie", 34 | "emailAddress": "charlie@example.com" 35 | }, 36 | "committerTimestamp": 1549862602763, 37 | "message": "WIP on feature 1", 38 | "parents": [ 39 | { 40 | "id": "abcdef0123abcdef4567abcdef8987abcdef6543", 41 | "displayId": "abcdef0" 42 | } 43 | ] 44 | } 45 | }, 46 | "latestCommit": { 47 | "id": "def0123abcdef4567abcdef8987abcdef6543abc", 48 | "displayId": "def0123abcd", 49 | "author": { 50 | "name": "charlie", 51 | "emailAddress": "charlie@example.com" 52 | }, 53 | "authorTimestamp": 1549862602763, 54 | "committer": { 55 | "name": "charlie", 56 | "emailAddress": "charlie@example.com" 57 | }, 58 | "committerTimestamp": 1549862602763, 59 | "message": "More work on feature 1", 60 | "parents": [ 61 | { 62 | "id": "abcdef0123abcdef4567abcdef8987abcdef6543", 63 | "displayId": "abcdef0" 64 | } 65 | ] 66 | } 67 | } -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/build/Status.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.build; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.json.SerializedNames; 22 | import org.jclouds.javax.annotation.Nullable; 23 | 24 | @AutoValue 25 | public abstract class Status { 26 | 27 | public enum StatusState { 28 | SUCCESSFUL, 29 | FAILED, 30 | INPROGRESS 31 | } 32 | 33 | public abstract long dateAdded(); 34 | 35 | @Nullable 36 | public abstract String description(); 37 | 38 | public abstract String key(); 39 | 40 | @Nullable 41 | public abstract String name(); 42 | 43 | public abstract StatusState state(); 44 | 45 | public abstract String url(); 46 | 47 | @SerializedNames({"dateAdded", "description", "key", "name", "state", "url"}) 48 | public static Status create(final long dateAdded, 49 | final String description, 50 | final String key, 51 | final String name, 52 | final StatusState state, 53 | final String url) { 54 | return new AutoValue_Status(dateAdded, description, key, name, state, url); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/repository/Hook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.repository; 19 | 20 | import com.cdancy.bitbucket.rest.domain.common.Error; 21 | import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder; 22 | import com.cdancy.bitbucket.rest.BitbucketUtils; 23 | import com.google.auto.value.AutoValue; 24 | import org.jclouds.javax.annotation.Nullable; 25 | import org.jclouds.json.SerializedNames; 26 | 27 | import java.util.List; 28 | 29 | @AutoValue 30 | public abstract class Hook implements ErrorsHolder { 31 | 32 | @Nullable 33 | public abstract HookDetails details(); 34 | 35 | public abstract boolean enabled(); 36 | 37 | public abstract boolean configured(); 38 | 39 | @SerializedNames({ "details", "enabled", "configured", "errors" }) 40 | public static Hook create(final HookDetails details, 41 | final boolean enabled, 42 | final boolean configured, 43 | @Nullable final List errors) { 44 | 45 | return new AutoValue_Hook(BitbucketUtils.nullToEmpty(errors), 46 | details, 47 | enabled, 48 | configured); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/activities/ActivitiesPage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.activities; 19 | 20 | import com.cdancy.bitbucket.rest.domain.common.Error; 21 | import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder; 22 | import com.cdancy.bitbucket.rest.domain.common.Page; 23 | import com.cdancy.bitbucket.rest.BitbucketUtils; 24 | import com.google.auto.value.AutoValue; 25 | import org.jclouds.javax.annotation.Nullable; 26 | import org.jclouds.json.SerializedNames; 27 | 28 | import java.util.List; 29 | 30 | @AutoValue 31 | public abstract class ActivitiesPage implements Page, ErrorsHolder { 32 | 33 | @SerializedNames({ "start", "limit", "size", "nextPageStart", "isLastPage", "values", "errors" }) 34 | public static ActivitiesPage create(final int start, final int limit, 35 | final int size, final int nextPageStart, final boolean isLastPage, 36 | @Nullable final List values, @Nullable final List errors) { 37 | return new AutoValue_ActivitiesPage(start, limit, size, nextPageStart, isLastPage, 38 | BitbucketUtils.nullToEmpty(values), BitbucketUtils.nullToEmpty(errors)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/CreateParticipants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.options; 19 | 20 | import com.cdancy.bitbucket.rest.domain.participants.Participants; 21 | import com.cdancy.bitbucket.rest.domain.pullrequest.User; 22 | import com.google.auto.value.AutoValue; 23 | import org.jclouds.javax.annotation.Nullable; 24 | import org.jclouds.json.SerializedNames; 25 | 26 | 27 | @AutoValue 28 | public abstract class CreateParticipants { 29 | 30 | public abstract User user(); 31 | 32 | @Nullable 33 | public abstract String lastReviewedCommit(); 34 | 35 | public abstract Participants.Role role(); 36 | 37 | public abstract boolean approved(); 38 | 39 | public abstract Participants.Status status(); 40 | 41 | @SerializedNames({"user", "lastReviewedCommit", "role", "approved", "status"}) 42 | public static CreateParticipants create(final User user, 43 | final String lastReviewedCommit, 44 | final Participants.Role role, 45 | final boolean approved, 46 | final Participants.Status status) { 47 | return new AutoValue_CreateParticipants(user, lastReviewedCommit, role, approved, status); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/file/LastModified.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.file; 19 | 20 | import com.cdancy.bitbucket.rest.BitbucketUtils; 21 | import com.cdancy.bitbucket.rest.domain.commit.Commit; 22 | import com.cdancy.bitbucket.rest.domain.common.Error; 23 | import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder; 24 | import com.google.auto.value.AutoValue; 25 | import org.jclouds.javax.annotation.Nullable; 26 | import org.jclouds.json.SerializedNames; 27 | 28 | import java.util.List; 29 | import java.util.Map; 30 | 31 | @AutoValue 32 | public abstract class LastModified implements ErrorsHolder { 33 | 34 | @Nullable 35 | public abstract Map files(); 36 | 37 | @Nullable 38 | public abstract Commit latestCommit(); 39 | 40 | LastModified() { 41 | } 42 | 43 | @SerializedNames({ "files", "latestCommit", "errors" }) 44 | public static LastModified create(final Map files, 45 | final Commit latestCommit, 46 | final List errors) { 47 | return new AutoValue_LastModified(BitbucketUtils.nullToEmpty(errors), 48 | BitbucketUtils.nullToEmpty(files), 49 | latestCommit); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/repository/HookDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.repository; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class HookDetails { 26 | 27 | public abstract String key(); 28 | 29 | public abstract String name(); 30 | 31 | public abstract String type(); 32 | 33 | public abstract String description(); 34 | 35 | public abstract String version(); 36 | 37 | @Nullable 38 | public abstract String configFormKey(); 39 | 40 | @SerializedNames({ "key", "name", "type", 41 | "description", "version", "configFormKey" }) 42 | public static HookDetails create(final String key, 43 | final String name, 44 | final String type, 45 | final String description, 46 | final String version, 47 | final String configFormKey) { 48 | 49 | return new AutoValue_HookDetails(key, 50 | name, 51 | type, 52 | description, 53 | version, 54 | configFormKey); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/filters/BitbucketAuthenticationFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.filters; 19 | 20 | import jakarta.inject.Inject; 21 | import jakarta.inject.Singleton; 22 | 23 | import com.cdancy.bitbucket.rest.BitbucketAuthentication; 24 | import com.cdancy.bitbucket.rest.auth.AuthenticationType; 25 | 26 | import org.jclouds.http.HttpException; 27 | import org.jclouds.http.HttpRequest; 28 | import org.jclouds.http.HttpRequestFilter; 29 | import com.google.common.net.HttpHeaders; 30 | 31 | @Singleton 32 | public class BitbucketAuthenticationFilter implements HttpRequestFilter { 33 | private final BitbucketAuthentication creds; 34 | 35 | @Inject 36 | BitbucketAuthenticationFilter(final BitbucketAuthentication creds) { 37 | this.creds = creds; 38 | } 39 | 40 | @Override 41 | public HttpRequest filter(final HttpRequest request) throws HttpException { 42 | if (creds.authType() == AuthenticationType.Anonymous) { 43 | return request; 44 | } else { 45 | final String authHeader = creds.authType() + " " + creds.authValue(); 46 | return request.toBuilder().addHeader(HttpHeaders.AUTHORIZATION, authHeader).build(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /gradle/release.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath 'org.eclipse.jgit:org.eclipse.jgit:6.0.0.202111291000-r' 7 | } 8 | } 9 | 10 | import org.eclipse.jgit.api.Git 11 | import org.eclipse.jgit.api.DeleteTagCommand 12 | import org.eclipse.jgit.api.TagCommand 13 | import org.eclipse.jgit.api.PushCommand 14 | import org.eclipse.jgit.lib.Repository 15 | import org.eclipse.jgit.storage.file.FileRepositoryBuilder 16 | import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider 17 | 18 | File repoDir = new File("${projectDir}") 19 | FileRepositoryBuilder builder = new FileRepositoryBuilder() 20 | Repository repo = builder.findGitDir(repoDir).build() 21 | Git git = new Git(repo) 22 | 23 | task createTag { 24 | description = 'Creates repository tag with current project version.' 25 | ext.tagName = "v${project.version}" 26 | 27 | doLast { 28 | logger.quiet "Creating tag '$tagName'." 29 | 30 | // Remove potentially existing tag 31 | DeleteTagCommand delTag = git.tagDelete() 32 | delTag.setTags(tagName).call() 33 | 34 | // Create tag 35 | TagCommand tag = git.tag() 36 | tag.setName(tagName).setMessage("Version ${project.version}").call() 37 | } 38 | } 39 | 40 | task pushTag { 41 | description = 'Pushes tag to remote repository.' 42 | dependsOn createTag 43 | 44 | doLast { 45 | logger.quiet "Pushing tag '$createTag.tagName' to remote." 46 | PushCommand push = git.push() 47 | push.add(createTag.tagName) 48 | push.setCredentialsProvider(new UsernamePasswordCredentialsProvider(project.githubUsername, project.githubPassword)) 49 | push.call() 50 | } 51 | } 52 | 53 | task tag { 54 | dependsOn pushTag 55 | mustRunAfter "publishToSonatype", "closeAndReleaseSonatypeStagingRepository" 56 | } 57 | 58 | task release { 59 | description = 'Publishes artifacts to Bintray and tags repository with current project version.' 60 | dependsOn assemble, "publishToSonatype", "closeAndReleaseSonatypeStagingRepository", tag 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/pullrequest/Path.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.pullrequest; 19 | 20 | import java.util.List; 21 | 22 | import org.jclouds.javax.annotation.Nullable; 23 | import org.jclouds.json.SerializedNames; 24 | 25 | import com.cdancy.bitbucket.rest.BitbucketUtils; 26 | import com.google.auto.value.AutoValue; 27 | 28 | @AutoValue 29 | public abstract class Path { 30 | 31 | public abstract List components(); 32 | 33 | public abstract String parent(); 34 | 35 | public abstract String name(); 36 | 37 | @Nullable 38 | public abstract String extension(); 39 | 40 | public abstract String _toString(); 41 | 42 | Path() { 43 | } 44 | 45 | @SerializedNames({ "components", "parent", "name", 46 | "extension", "toString" }) 47 | public static Path create(final List components, 48 | final String parent, 49 | final String name, 50 | final String extension, 51 | final String _toString) { 52 | 53 | return new AutoValue_Path(BitbucketUtils.nullToEmpty(components), 54 | parent, 55 | name, 56 | extension, 57 | _toString); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/pullrequest/MergeStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.pullrequest; 19 | 20 | import com.cdancy.bitbucket.rest.domain.common.Veto; 21 | import java.util.List; 22 | 23 | import org.jclouds.json.SerializedNames; 24 | 25 | import com.cdancy.bitbucket.rest.domain.common.Error; 26 | import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder; 27 | import com.cdancy.bitbucket.rest.BitbucketUtils; 28 | import com.google.auto.value.AutoValue; 29 | 30 | @AutoValue 31 | public abstract class MergeStatus implements ErrorsHolder { 32 | 33 | public abstract boolean canMerge(); 34 | 35 | public abstract boolean conflicted(); 36 | 37 | public abstract List vetoes(); 38 | 39 | MergeStatus() { 40 | } 41 | 42 | @SerializedNames({ "canMerge", "conflicted", "vetoes", "errors" }) 43 | public static MergeStatus create(final boolean canMerge, 44 | final boolean conflicted, 45 | final List vetoes, 46 | final List errors) { 47 | 48 | return new AutoValue_MergeStatus(BitbucketUtils.nullToEmpty(errors), 49 | canMerge, 50 | conflicted, 51 | BitbucketUtils.nullToEmpty(vetoes)); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/admin/UserPage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.admin; 19 | 20 | import com.cdancy.bitbucket.rest.domain.common.Error; 21 | import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder; 22 | import com.cdancy.bitbucket.rest.domain.common.Page; 23 | import com.cdancy.bitbucket.rest.domain.pullrequest.User; 24 | import com.cdancy.bitbucket.rest.BitbucketUtils; 25 | import com.google.auto.value.AutoValue; 26 | import org.jclouds.javax.annotation.Nullable; 27 | import org.jclouds.json.SerializedNames; 28 | 29 | import java.util.List; 30 | 31 | @AutoValue 32 | public abstract class UserPage implements Page, ErrorsHolder { 33 | 34 | @SerializedNames({ "start", "limit", "size", "nextPageStart", "isLastPage", "values", "errors" }) 35 | public static UserPage create(final int start, final int limit, 36 | final int size, final int nextPageStart, 37 | final boolean isLastPage, @Nullable final List values, 38 | @Nullable final List errors) { 39 | return new AutoValue_UserPage(start, limit, 40 | size, nextPageStart, 41 | isLastPage, BitbucketUtils.nullToEmpty(values), 42 | BitbucketUtils.nullToEmpty(errors)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/options/CreateBuildStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.options; 19 | 20 | import com.google.auto.value.AutoValue; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | @AutoValue 25 | public abstract class CreateBuildStatus { 26 | 27 | public enum STATE { 28 | SUCCESSFUL, 29 | FAILED, 30 | INPROGRESS 31 | } 32 | 33 | public abstract String state(); 34 | 35 | public abstract String key(); 36 | 37 | @Nullable 38 | public abstract String name(); 39 | 40 | public abstract String url(); 41 | 42 | @Nullable 43 | public abstract String description(); 44 | 45 | CreateBuildStatus() { 46 | } 47 | 48 | @SerializedNames({ "state", "key", "name", "url", "description" }) 49 | public static CreateBuildStatus create(final STATE state, 50 | final String key, 51 | final String name, 52 | final String url, 53 | final String description) { 54 | 55 | return new AutoValue_CreateBuildStatus(state != null ? state.toString() : null, 56 | key, 57 | name, 58 | url, 59 | description); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/branch/BranchModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.branch; 19 | 20 | import java.util.List; 21 | 22 | import org.jclouds.javax.annotation.Nullable; 23 | import org.jclouds.json.SerializedNames; 24 | 25 | import com.cdancy.bitbucket.rest.domain.common.Error; 26 | import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder; 27 | import com.cdancy.bitbucket.rest.BitbucketUtils; 28 | import com.google.auto.value.AutoValue; 29 | 30 | @AutoValue 31 | public abstract class BranchModel implements ErrorsHolder { 32 | 33 | @Nullable 34 | public abstract Branch development(); 35 | 36 | @Nullable 37 | public abstract Branch production(); 38 | 39 | public abstract List types(); 40 | 41 | BranchModel() { 42 | } 43 | 44 | @SerializedNames({ "development", "production", "types", "errors" }) 45 | public static BranchModel create(final Branch development, 46 | final Branch production, 47 | final List types, 48 | final List errors) { 49 | 50 | return new AutoValue_BranchModel(BitbucketUtils.nullToEmpty(errors), 51 | development, 52 | production, 53 | BitbucketUtils.nullToEmpty(types)); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/parsers/DeleteRepositoryParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.parsers; 19 | 20 | import com.cdancy.bitbucket.rest.domain.common.RequestStatus; 21 | import com.google.common.base.Function; 22 | import jakarta.inject.Singleton; 23 | import org.jclouds.http.HttpResponse; 24 | import org.jclouds.rest.ResourceNotFoundException; 25 | 26 | /** 27 | * When deleting a repository, and it doesn't exist, Bitbucket will return a 204. To account 28 | * for this we need to implement a custom parser that handles success, not found (204), 29 | * and all other failures appropriately. 30 | */ 31 | @Singleton 32 | public class DeleteRepositoryParser implements Function { 33 | 34 | @Override 35 | public RequestStatus apply(final HttpResponse input) { 36 | final int statusCode = input.getStatusCode(); 37 | if (statusCode >= 200 && statusCode < 400) { 38 | if (statusCode == 204) { 39 | throw new ResourceNotFoundException("The repository does not exist in this project."); 40 | } else { 41 | return RequestStatus.create(true, null); 42 | } 43 | } else { 44 | throw new RuntimeException(input.getStatusLine()); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/cdancy/bitbucket/rest/domain/common/Error.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cdancy.bitbucket.rest.domain.common; 19 | 20 | import com.cdancy.bitbucket.rest.BitbucketUtils; 21 | import org.jclouds.javax.annotation.Nullable; 22 | import org.jclouds.json.SerializedNames; 23 | 24 | import com.google.auto.value.AutoValue; 25 | import java.util.List; 26 | 27 | @AutoValue 28 | public abstract class Error { 29 | 30 | @Nullable 31 | public abstract String context(); 32 | 33 | @Nullable 34 | public abstract String message(); 35 | 36 | @Nullable 37 | public abstract String exceptionName(); 38 | 39 | public abstract boolean conflicted(); 40 | 41 | public abstract List vetoes(); 42 | 43 | Error() { 44 | } 45 | 46 | @SerializedNames({ "context", "message", "exceptionName", "conflicted", "vetoes" }) 47 | public static Error create(final String context, 48 | final String message, 49 | final String exceptionName, 50 | final boolean conflicted, 51 | final List vetoes) { 52 | 53 | return new AutoValue_Error(context, 54 | message, 55 | exceptionName, 56 | conflicted, 57 | BitbucketUtils.nullToEmpty(vetoes)); 58 | } 59 | } 60 | --------------------------------------------------------------------------------