Skip to content

Commit

Permalink
Better path parameter names for organization and member APIs
Browse files Browse the repository at this point in the history
Closes keycloak#35745

Signed-off-by: Pedro Igor <[email protected]>
  • Loading branch information
pedroigor committed Dec 10, 2024
1 parent 93afd4d commit a6643c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,29 +154,29 @@ public Stream<MemberRepresentation> search(
return provider.getMembersStream(organization, filters, exact, first, max).map(this::toRepresentation);
}

@Path("{id}")
@Path("{memberId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@NoCache
@Tag(name = KeycloakOpenAPI.Admin.Tags.ORGANIZATIONS)
@Operation( summary = "Returns the member of the organization with the specified id", description = "Searches for a" +
"user with the given id. If one is found, and is currently a member of the organization, returns it. Otherwise," +
"an error response with status NOT_FOUND is returned")
public MemberRepresentation get(@PathParam("id") String id) {
public MemberRepresentation get(@PathParam("memberId") String id) {
if (StringUtil.isBlank(id)) {
throw ErrorResponse.error("id cannot be null", Status.BAD_REQUEST);
}

return toRepresentation(getMember(id));
}

@Path("{id}")
@Path("{memberId}")
@DELETE
@Tag(name = KeycloakOpenAPI.Admin.Tags.ORGANIZATIONS)
@Operation(summary = "Removes the user with the specified id from the organization", description = "Breaks the association " +
"between the user and organization. The user itself is deleted in case the membership is managed, otherwise the user is not deleted. " +
"If no user is found, or if they are not a member of the organization, an error response is returned")
public Response delete(@PathParam("id") String id) {
public Response delete(@PathParam("memberId") String id) {
if (StringUtil.isBlank(id)) {
throw ErrorResponse.error("id cannot be null", Status.BAD_REQUEST);
}
Expand All @@ -196,13 +196,13 @@ public Response delete(@PathParam("id") String id) {
throw ErrorResponse.error("Not a member of the organization", Status.BAD_REQUEST);
}

@Path("{id}/organizations")
@Path("{memberId}/organizations")
@GET
@Produces(MediaType.APPLICATION_JSON)
@NoCache
@Tag(name = KeycloakOpenAPI.Admin.Tags.ORGANIZATIONS)
@Operation(summary = "Returns the organizations associated with the user that has the specified id")
public Stream<OrganizationRepresentation> getOrganizations(@PathParam("id") String id) {
public Stream<OrganizationRepresentation> getOrganizations(@PathParam("memberId") String id) {
if (StringUtil.isBlank(id)) {
throw ErrorResponse.error("id cannot be null", Status.BAD_REQUEST);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ public Stream<OrganizationRepresentation> search(
/**
* Base path for the admin REST API for one particular organization.
*/
@Path("{id}")
public OrganizationResource get(@PathParam("id") String id) {
@Path("{orgId}")
public OrganizationResource get(@PathParam("orgId") String id) {
auth.realm().requireManageRealm();
Organizations.checkEnabled(provider);

Expand All @@ -171,13 +171,13 @@ public OrganizationResource get(@PathParam("id") String id) {
return new OrganizationResource(session, organizationModel, adminEvent);
}

@Path("members/{id}/organizations")
@Path("members/{memberId}/organizations")
@GET
@Produces(MediaType.APPLICATION_JSON)
@NoCache
@Tag(name = KeycloakOpenAPI.Admin.Tags.ORGANIZATIONS)
@Operation(summary = "Returns the organizations associated with the user that has the specified id")
public Stream<OrganizationRepresentation> getOrganizations(@PathParam("id") String id) {
public Stream<OrganizationRepresentation> getOrganizations(@PathParam("memberId") String id) {
return new OrganizationMemberResource(session, null, adminEvent).getOrganizations(id);
}
}

0 comments on commit a6643c6

Please sign in to comment.