Skip to content

Commit

Permalink
Merge pull request #723 from hwupathum/tenant-filter
Browse files Browse the repository at this point in the history
Support filter capability for Tenant Management API
  • Loading branch information
hwupathum authored Oct 25, 2024
2 parents 49ba34d + 54d60e5 commit 7db0673
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 35 deletions.
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

0 comments on commit 7db0673

Please sign in to comment.