Skip to content
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

Support filter capability for Tenant Management API #723

Merged
merged 8 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ public Response isDomainExist(@ApiParam(value = "tenant domain",required=true) @
}, tags={ "Tenants", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK", response = TenantsListResponse.class),
@ApiResponse(code = 400, message = "Invalid Input Request", response = Error.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@ApiResponse(code = 403, message = "Resource Forbidden", response = Void.class),
@ApiResponse(code = 404, message = "The specified resource is not found", response = Error.class),
@ApiResponse(code = 500, message = "Internal Server Error", response = Error.class),
@ApiResponse(code = 501, message = "Not Implemented", response = Error.class)
@ApiResponse(code = 500, message = "Internal Server Error", response = Error.class)
})
public Response retrieveTenants( @Valid @Min(0)@ApiParam(value = "Maximum number of records to return.") @QueryParam("limit") Integer limit, @Valid @Min(0)@ApiParam(value = "Number of records to skip for pagination.") @QueryParam("offset") Integer offset, @Valid@ApiParam(value = "Define the order in which the retrieved tenants should be sorted.", allowableValues="asc, desc") @QueryParam("sortOrder") String sortOrder, @Valid@ApiParam(value = "Attribute by which the retrieved records should be sorted. Currently sorting through _<b>domainName<b>_ only supported.") @QueryParam("sortBy") String sortBy, @Valid@ApiParam(value = "Condition to filter the retrival of records. Supports 'sw', 'co', 'ew' and 'eq' operations and also complex queries with 'and' operations. E.g. /tenants?filter=domain+sw+\"wso2\". _<b>This option is not yet supported.<b>_ ") @QueryParam("filter") String filter) {
public Response retrieveTenants( @Valid @Min(0)@ApiParam(value = "Maximum number of records to return.") @QueryParam("limit") Integer limit, @Valid @Min(0)@ApiParam(value = "Number of records to skip for pagination.") @QueryParam("offset") Integer offset, @Valid@ApiParam(value = "Define the order in which the retrieved tenants should be sorted.", allowableValues="asc, desc") @QueryParam("sortOrder") String sortOrder, @Valid@ApiParam(value = "Attribute by which the retrieved records should be sorted. Currently sorting through <b>domainName</b> only supported.") @QueryParam("sortBy") String sortBy, @Valid@ApiParam(value = "Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations. Currently, filtering is supported only by the <b>domainName</b>. E.g. /tenants?filter=domainName+sw+wso2. ") @QueryParam("filter") String filter) {

return delegate.retrieveTenants(limit, offset, sortOrder, sortBy, filter );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public String addTenant(TenantModel tenantModel) {
public TenantsListResponse listTenants(Integer limit, Integer offset, String sortOrder, String sortBy,
String filter) {

handleNotImplementedCapabilities(filter);
TenantMgtService tenantMgtService = TenantManagementServiceHolder.getTenantMgtService();

try {
Expand Down Expand Up @@ -605,26 +604,6 @@ private static String includeData(TenantManagementConstants.ErrorMessage error,
return message;
}

/**
* Return Not Implemented error response for tenant List filtering which are not yet supported by the server.
*
* @param filter Filter string.
*/
private void handleNotImplementedCapabilities(String filter) {

TenantManagementConstants.ErrorMessage errorEnum = null;

if (filter != null) {
errorEnum = TenantManagementConstants.ErrorMessage.ERROR_CODE_FILTER_NOT_IMPLEMENTED;
}

if (errorEnum != null) {
ErrorResponse errorResponse = getErrorBuilder(errorEnum, null).build(log, errorEnum.getDescription());
Response.Status status = Response.Status.NOT_IMPLEMENTED;
throw new APIError(status, errorResponse);
}
}

public String addTenant(ChannelVerifiedTenantModel channelVerifiedTenantModel) {
String resourceId;
TenantMgtService tenantMgtService = TenantManagementServiceHolder.getTenantMgtService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ paths:
'application/json':
schema:
$ref: '#/components/schemas/TenantsListResponse'
'400':
$ref: '#/components/responses/InvalidInput'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
Expand All @@ -51,12 +53,6 @@ paths:
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/ServerError'
'501':
description: Not Implemented
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
tags:
- Tenants
Expand Down Expand Up @@ -488,7 +484,7 @@ components:
name: sortBy
required: false
description: >-
Attribute by which the retrieved records should be sorted. Currently sorting through _<b>domainName<b>_ only
Attribute by which the retrieved records should be sorted. Currently sorting through <b>domainName</b> only
supported.
schema:
type: string
Expand All @@ -497,10 +493,9 @@ components:
name: filter
required: false
description: >
Condition to filter the retrival of records. Supports 'sw', 'co', 'ew'
and 'eq' operations and also complex queries with 'and' operations. E.g.
/tenants?filter=domain+sw+"wso2". _<b>This
option is not yet supported.<b>_
Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations.
Currently, filtering is supported only by the <b>domainName</b>.
E.g. /tenants?filter=domainName+sw+wso2.
schema:
type: string
additionalClaimsQueryParam:
Expand Down
Loading