Skip to content

Commit

Permalink
add search endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Yingjian Wu committed Jun 10, 2024
1 parent fcaa0c0 commit 7096045
Show file tree
Hide file tree
Showing 13 changed files with 278 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
import com.fasterxml.jackson.datatype.guava.GuavaModule;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
import com.google.common.base.Preconditions;
import com.netflix.metacat.client.api.MetacatV1;
import com.netflix.metacat.client.api.MetadataV1;
import com.netflix.metacat.client.api.ParentChildRelV1;
import com.netflix.metacat.client.api.PartitionV1;
import com.netflix.metacat.client.api.ResolverV1;
import com.netflix.metacat.client.api.TagV1;
import com.netflix.metacat.client.module.JacksonDecoder;
import com.netflix.metacat.client.module.JacksonEncoder;
import com.netflix.metacat.client.module.MetacatErrorDecoder;
import com.netflix.metacat.common.MetacatRequestContext;
import com.netflix.metacat.client.api.MetacatV1;
import com.netflix.metacat.client.api.MetadataV1;
import com.netflix.metacat.client.api.PartitionV1;
import com.netflix.metacat.client.api.ResolverV1;
import com.netflix.metacat.common.json.MetacatJsonLocator;
import feign.Feign;
import feign.Request;
Expand Down Expand Up @@ -58,6 +59,8 @@ public final class Client {
private final ResolverV1 resolverApi;
private final TagV1 tagApi;

private final ParentChildRelV1 parentChildRelApi;

private Client(
final String host,
final feign.Client client,
Expand Down Expand Up @@ -93,6 +96,7 @@ private Client(
metadataApi = getApiClient(MetadataV1.class);
resolverApi = getApiClient(ResolverV1.class);
tagApi = getApiClient(TagV1.class);
parentChildRelApi = getApiClient(ParentChildRelV1.class);
}

/**
Expand Down Expand Up @@ -163,6 +167,15 @@ public TagV1 getTagApi() {
return tagApi;
}

/**
* Return an API instance that can be used to interact with
* the metacat server for parent child relationship metadata.
* @return An instance api conforming to ParentChildRelV1 interface
*/
public ParentChildRelV1 getParentChildRelApi() {
return parentChildRelApi;
}

/**
* Builder class to build the metacat client.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.netflix.metacat.client.api;

import javax.ws.rs.Path;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.GET;
import javax.ws.rs.PathParam;

import javax.ws.rs.core.MediaType;
import com.netflix.metacat.common.dto.notifications.ChildInfoDto;

import java.util.Set;

/**
* Metacat API for managing parent child relation.
*
* @author Yingjianw
*/

@Path("/mds/v1/parentChildRel")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface ParentChildRelV1 {
/**
* Return the list of children.
* @param catalogName catalogName
* @param databaseName databaseName
* @param tableName tableName
* @return list of childInfos
*/
@GET
@Path("children/catalog/{catalog-name}/database/{database-name}/table/{table-name}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
Set<ChildInfoDto> getChildren(
@PathParam("catalog-name")
String catalogName,
@PathParam("database-name")
String databaseName,
@PathParam("table-name")
String tableName
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.netflix.metacat.common.dto.Sort;
import com.netflix.metacat.common.dto.StorageDto;
import com.netflix.metacat.common.dto.TableDto;
import com.netflix.metacat.common.dto.notifications.ChildInfoDto;
import com.netflix.metacat.common.server.connectors.ConnectorRequestContext;
import com.netflix.metacat.common.server.connectors.model.AuditInfo;
import com.netflix.metacat.common.server.connectors.model.CatalogInfo;
Expand All @@ -46,6 +47,7 @@
import com.netflix.metacat.common.server.connectors.model.PartitionsSaveResponse;
import com.netflix.metacat.common.server.connectors.model.StorageInfo;
import com.netflix.metacat.common.server.connectors.model.TableInfo;
import com.netflix.metacat.common.server.model.ChildInfo;
import lombok.NonNull;
import org.dozer.CustomConverter;
import org.dozer.DozerBeanMapper;
Expand Down Expand Up @@ -276,5 +278,13 @@ public PartitionsSaveResponseDto toPartitionsSaveResponseDto(final PartitionsSav
return mapper.map(partitionsSaveResponse, PartitionsSaveResponseDto.class);
}


/**
* Convert ChildInfo to ChildInfoDto.
*
* @param childInfo childInfo
* @return childInfo dto
*/
public ChildInfoDto toChildInfoDto(final ChildInfo childInfo) {
return mapper.map(childInfo, ChildInfoDto.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import lombok.Data;

import java.io.Serializable;

/**
* Base class to represent relation entity.
*/
@Data
public abstract class BaseRelEntityInfo {
public abstract class BaseRelEntityInfo implements Serializable {
private static final long serialVersionUID = 9121109874202888889L;
private String name;
private String relationType;
private String uuid;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.netflix.metacat.common.server.usermetadata;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.dto.notifications.ChildInfoDto;
import com.netflix.metacat.common.server.model.ChildInfo;
import com.netflix.metacat.common.server.model.ParentInfo;

Expand Down Expand Up @@ -93,4 +94,13 @@ Set<ParentInfo> getParents(
Set<ChildInfo> getChildren(
QualifiedName name
);

/**
* get the set of children dto for the input name.
* @param name name
* @return a set of ChildInfo
*/
Set<ChildInfoDto> getChildrenDto(
QualifiedName name
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.netflix.metacat.common.dto.notifications;

import com.netflix.metacat.common.dto.BaseDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
* ChildInfo information.
*/
@SuppressWarnings("unused")
@Data
@EqualsAndHashCode(callSuper = false)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ChildInfoDto extends BaseDto {
private static final long serialVersionUID = 9121109874202088789L;
/* Name of the child */
@ApiModelProperty(value = "name of the child")
private String name;
/* Type of the relation */
@ApiModelProperty(value = "type of the relation")
private String relationType;
/* uuid of the table */
@ApiModelProperty(value = "uuid of the table")
private String uuid;
}
Loading

0 comments on commit 7096045

Please sign in to comment.