Skip to content

Commit

Permalink
Fix return type for generic ingest API (#387)
Browse files Browse the repository at this point in the history
* Fix return type for generic ingest API

* fix

* fix

* fix

---------

Co-authored-by: Jesse Jia <jejia@jejia-mn2.linkedin.biz>
  • Loading branch information
zhixuanjia and Jesse Jia committed Jun 21, 2024
1 parent 793bd8c commit 21b2285
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.linkedin.metadata.internal.IngestionParams;
import com.linkedin.parseq.Task;
import com.linkedin.restli.common.HttpStatus;
import com.linkedin.restli.server.CreateResponse;
import com.linkedin.restli.server.RestLiServiceException;
import com.linkedin.restli.server.annotations.Action;
import com.linkedin.restli.server.annotations.ActionParam;
Expand Down Expand Up @@ -88,11 +87,10 @@ public Task<String> queryLatest(
* @param aspectClass The canonical class name of the aspect.
* @param trackingContext Nullable tracking context contains information passed from metadata events.
* @param ingestionParams Different options for ingestion.
* @return CreateResponse if metadata is ingested successfully.
*/
@Action(name = ACTION_INGEST)
@Nonnull
public Task<CreateResponse> ingest(
public Task<Void> ingest(
@ActionParam(PARAM_URN) @Nonnull String urn,
@ActionParam(PARAM_ASPECT) @Nonnull String aspect,
@ActionParam(PARAM_ASPECT_CLASS) @Nonnull String aspectClass,
Expand All @@ -104,7 +102,7 @@ public Task<CreateResponse> ingest(
Class clazz = this.getClass().getClassLoader().loadClass(aspectClass);
IngestionMode ingestionMode = ingestionParams == null ? null : ingestionParams.getIngestionMode();
genericLocalDAO().save(Urn.createFromCharSequence(urn), clazz, aspect, auditStamp, trackingContext, ingestionMode);
return RestliUtils.toTask(() -> new CreateResponse(HttpStatus.S_201_CREATED));
return Task.value(null);
} catch (ClassNotFoundException e) {
throw new RestLiServiceException(HttpStatus.S_400_BAD_REQUEST, String.format("No such class %s.", aspectClass));
} catch (URISyntaxException e) {
Expand All @@ -115,12 +113,12 @@ public Task<CreateResponse> ingest(
/**
* Backfill secondary storage by triggering MAEs.
* @param urn The urn identified the entity for which the metadata is associated with.
* @param aspectNames The metadata aspect serialized as string in JSON format.
* @param aspectNames A list of aspect's canonical names.
*/
@Action(name = ACTION_BACKFILL_WITH_URNS)
@Action(name = ACTION_BACKFILL_WITH_URN)
@Nonnull
public Task<BackfillResult> backfill(
@ActionParam(PARAM_URNS) @Nonnull String urn,
@ActionParam(PARAM_URN) @Nonnull String urn,
@ActionParam(PARAM_ASPECTS) @Nonnull String[] aspectNames) {
Set<Class<? extends RecordTemplate>> aspects = Arrays.stream(aspectNames).map(ModelUtils::getAspectClass).collect(Collectors.toSet());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ private RestliConstants() { }
public static final String ACTION_BACKFILL_ENTITY_TABLES = "backfillEntityTables";
public static final String ACTION_BACKFILL_RELATIONSHIP_TABLES = "backfillRelationshipTables";
public static final String ACTION_BACKFILL_WITH_URNS = "backfillWithUrns";
public static final String ACTION_BACKFILL_WITH_URN = "backfillWithUrn";
public static final String ACTION_BACKFILL_WITH_NEW_VALUE = "backfillWithNewValue";
public static final String ACTION_BACKFILL_LEGACY = "backfillLegacy";
public static final String ACTION_BROWSE = "browse";
Expand Down

0 comments on commit 21b2285

Please sign in to comment.