mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-20 22:43:14 +00:00
This commit is contained in:
parent
8621ee3fa0
commit
31353afc24
@ -109,7 +109,7 @@ public class LocationResource {
|
||||
|
||||
@GET
|
||||
@Operation(summary = "List locations", tags = "locations",
|
||||
description = "Get a list of locations, optionally filtered by `fqnPrefix`. Use `fields` " +
|
||||
description = "Get a list of locations, optionally filtered by `service` it belongs to. Use `fields` " +
|
||||
"parameter to get only necessary fields. Use cursor-based pagination to limit the number " +
|
||||
"entries in the list using `limit` and `before` or `after` query params.",
|
||||
responses = {@ApiResponse(responseCode = "200", description = "List of locations",
|
||||
@ -122,7 +122,7 @@ public class LocationResource {
|
||||
@QueryParam("fields") String fieldsParam,
|
||||
@Parameter(description = "Filter locations by prefix of the FQN",
|
||||
schema = @Schema(type = "string", example = "s3://bucket/folder1"))
|
||||
@QueryParam("fqnPrefix") String fqnPrefixParam,
|
||||
@QueryParam("service") String serviceParam,
|
||||
@Parameter(description = "Limit the number locations returned. " +
|
||||
"(1 to 1000000, default = 10)")
|
||||
@DefaultValue("10")
|
||||
@ -141,9 +141,9 @@ public class LocationResource {
|
||||
|
||||
ResultList<Location> locations;
|
||||
if (before != null) { // Reverse paging
|
||||
locations = dao.listBefore(uriInfo, fields, fqnPrefixParam, limitParam, before); // Ask for one extra entry
|
||||
locations = dao.listBefore(uriInfo, fields, serviceParam, limitParam, before); // Ask for one extra entry
|
||||
} else { // Forward paging or first page
|
||||
locations = dao.listAfter(uriInfo, fields, fqnPrefixParam, limitParam, after);
|
||||
locations = dao.listAfter(uriInfo, fields, serviceParam, limitParam, after);
|
||||
}
|
||||
locations.getData().forEach(l -> addHref(uriInfo, l));
|
||||
return locations;
|
||||
|
@ -30,6 +30,7 @@ import org.openmetadata.catalog.resources.services.StorageServiceResourceTest;
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.StorageServiceType;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
import org.openmetadata.catalog.util.ResultList;
|
||||
import org.openmetadata.catalog.util.TestUtils;
|
||||
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
@ -39,6 +40,7 @@ import java.net.URISyntaxException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -82,12 +84,14 @@ public class LocationResourceTest extends EntityResourceTest<Location> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createRequest(String name, String description, String displayName, EntityReference owner) throws URISyntaxException {
|
||||
public Object createRequest(String name, String description, String displayName, EntityReference owner)
|
||||
throws URISyntaxException {
|
||||
return create(name).withDescription(description).withOwner(owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCreatedEntity(Location location, Object request, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
public void validateCreatedEntity(Location location, Object request, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
CreateLocation createRequest = (CreateLocation) request;
|
||||
validateCommonEntityFields(getEntityInterface(location), createRequest.getDescription(),
|
||||
TestUtils.getPrincipal(authHeaders), createRequest.getOwner());
|
||||
@ -103,12 +107,14 @@ public class LocationResourceTest extends EntityResourceTest<Location> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateUpdatedEntity(Location location, Object request, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
public void validateUpdatedEntity(Location location, Object request, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
validateCreatedEntity(location, request, authHeaders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compareEntities(Location expected, Location patched, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
public void compareEntities(Location expected, Location patched, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
validateCommonEntityFields(getEntityInterface(patched), expected.getDescription(),
|
||||
TestUtils.getPrincipal(authHeaders), expected.getOwner());
|
||||
// Entity specific validation
|
||||
@ -242,11 +248,12 @@ public class LocationResourceTest extends EntityResourceTest<Location> {
|
||||
for (EntityReference service : differentServices) {
|
||||
createAndCheckEntity(create(test).withService(service), adminAuthHeaders());
|
||||
|
||||
// List locations by filtering on service name and ensure right locations are returned in the response
|
||||
// LocationList list = listLocations("service", service.getName(), adminAuthHeaders());
|
||||
// for (Location location : list.getData()) {
|
||||
// assertEquals(service.getName(), location.getService().getName());
|
||||
// }
|
||||
// List locations by filtering on service name and ensure right locations are returned
|
||||
Map<String, String> queryParams = new HashMap<>(){{put("service", service.getName());}};
|
||||
ResultList<Location> list = listEntities(queryParams, adminAuthHeaders());
|
||||
for (Location location : list.getData()) {
|
||||
assertEquals(service.getName(), location.getService().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user