-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new api call for BranchPermission #51
Conversation
package com.cdancy.bitbucket.rest.domain.branch; | ||
|
||
public enum BranchPermissionEnumType { | ||
fast_forward_only("Rewriting history", "fast-forward-only", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do all CAPS for enum types (e.g. fast_forward_only to FAST_FORWARD_ONLY)?
@Override | ||
public String toString() { | ||
return this.getApiName(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary and/or being used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's need for update or create BranchPermission because Gson use toString() for conversion value before send to bitbucket
develop("development", "Development", "MODEL_BRANCH", "Branching model branch"), | ||
master("production", "Production", "MODEL_BRANCH", "Branching model branch"); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove extra line break
public enum MatcherId { | ||
release("RELEASE", "Release", "MODEL_CATEGORY", "Branching model category"), | ||
develop("development", "Development", "MODEL_BRANCH", "Branching model branch"), | ||
master("production", "Production", "MODEL_BRANCH", "Branching model branch"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caps for enum names. Was it intentional to put RELEASE
in call caps and then development
not in all caps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not error. In Bitbucket, the brancing model for release is uppercase and for develop/master is lowercase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. Can we also change the enum name to match the release name (e.g. RELEASE, DEVELOPMENT, MASTER)?
@Path("/branch-permissions/2.0/projects/{project}/repos/{repo}/restrictions") | ||
@Fallback(BitbucketFallbacks.BranchPermissionPageOnError.class) | ||
@GET | ||
BranchPermissionPage getBranchPermission(@PathParam("project") String project, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets change to listBranchPermission
to keep in line with naming standards already set.
@@ -114,4 +119,35 @@ Branch getDefault(@PathParam("project") String project, | |||
@GET | |||
BranchModel model(@PathParam("project") String project, | |||
@PathParam("repo") String repo); | |||
|
|||
@Named("branch:get-BranchPermission") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to branch:list-branch-permission
@Nullable @QueryParam("start") Integer start, | ||
@Nullable @QueryParam("limit") Integer limit); | ||
|
||
@Named("branch:update-BranchPermission") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to branch:update-branch-permission
@PathParam("repo") String repo, | ||
@BinderParam(BindToJsonPayload.class) List<BranchPermission> listBranchPermission); | ||
|
||
@Named("branch:get-BranchPermission") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to branch:delete-branch-permission
@Named("branch:update-BranchPermission") | ||
@Documentation({"https://developer.atlassian.com/static/rest/bitbucket-server/4.14.1/bitbucket-ref-restriction-rest.html#idm45354011023456"}) | ||
@Path("/branch-permissions/2.0/projects/{project}/repos/{repo}/restrictions") | ||
@Produces("application/vnd.atl.bitbucket.bulk+json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason to need to override the default json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes because Bitbucket need for update. If, I don't put it, bitbucket return this error : "Can not deserialize instance of com.atlassian.stash.internal.repository.ref.restriction.rest.RestRestrictionRequest out of START_ARRAY token\n at [Source: com.atlassian.stash.internal.web.util.web.CountingServletInputStream@68f4c6d2; line: 1, column: 1]""
@DELETE | ||
boolean deleteBranchPermission(@PathParam("project") String project, | ||
@PathParam("repo") String repo, | ||
@PathParam("id") Long id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since id
is not optional lets use long
instead of boxed version.
@j0nathan33 thanks for PR! Added some intial comments to address. Looks Ok so far. FYI: I would need mock and integration tests prior to merging. If you need help writing these feel free to scream my way ;) |
Ok, I will try to add some mock and integration tests :). |
return enumType; | ||
} | ||
} | ||
throw new IllegalArgumentException("Value not Found"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do something more descriptive? Maybe "Value " + apiName + " is not a legal BranchPermission"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I change it
@Named("branch:update-branch-permission") | ||
@Documentation({"https://developer.atlassian.com/static/rest/bitbucket-server/4.14.1/bitbucket-ref-restriction-rest.html#idm45354011023456"}) | ||
@Path("/branch-permissions/2.0/projects/{project}/repos/{repo}/restrictions") | ||
@Produces("application/vnd.atl.bitbucket.bulk+json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this content-type required? Will the already defined @Produces(MediaType.APPLICATION_JSON)
not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the documentation appears so. Ok lets keep it.
@j0nathan33 looks like you left out |
Right now, it's not possible to add new attribute "accessKeys", because my bitbucket server have old version but I will try to add It |
@j0nathan33 what version of bitbucket are you on? |
Response looks like this:
|
While request looks like this:
|
They look optional in both cases so to speak. |
@j0nathan33 integration tests pass as expected. Pulling this in as I'd like to get a release out today. As the endpoints don't require Thanks for the PR @j0nathan33! |
No description provided.