From 21b228524ff2b0fd7db3574328dd203c5cecc8dc Mon Sep 17 00:00:00 2001 From: Jesse Jia Date: Fri, 21 Jun 2024 08:24:38 -0700 Subject: [PATCH] Fix return type for generic ingest API (#387) * Fix return type for generic ingest API * fix * fix * fix --------- Co-authored-by: Jesse Jia --- .../restli/BaseEntityAgnosticAspectResource.java | 12 +++++------- .../linkedin/metadata/restli/RestliConstants.java | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/restli-resources/src/main/java/com/linkedin/metadata/restli/BaseEntityAgnosticAspectResource.java b/restli-resources/src/main/java/com/linkedin/metadata/restli/BaseEntityAgnosticAspectResource.java index 21611dfa8..8ddc2164a 100644 --- a/restli-resources/src/main/java/com/linkedin/metadata/restli/BaseEntityAgnosticAspectResource.java +++ b/restli-resources/src/main/java/com/linkedin/metadata/restli/BaseEntityAgnosticAspectResource.java @@ -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; @@ -88,11 +87,10 @@ public Task 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 ingest( + public Task ingest( @ActionParam(PARAM_URN) @Nonnull String urn, @ActionParam(PARAM_ASPECT) @Nonnull String aspect, @ActionParam(PARAM_ASPECT_CLASS) @Nonnull String aspectClass, @@ -104,7 +102,7 @@ public Task 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) { @@ -115,12 +113,12 @@ public Task 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 backfill( - @ActionParam(PARAM_URNS) @Nonnull String urn, + @ActionParam(PARAM_URN) @Nonnull String urn, @ActionParam(PARAM_ASPECTS) @Nonnull String[] aspectNames) { Set> aspects = Arrays.stream(aspectNames).map(ModelUtils::getAspectClass).collect(Collectors.toSet()); diff --git a/restli-resources/src/main/java/com/linkedin/metadata/restli/RestliConstants.java b/restli-resources/src/main/java/com/linkedin/metadata/restli/RestliConstants.java index 20d2f193f..39541b3dd 100644 --- a/restli-resources/src/main/java/com/linkedin/metadata/restli/RestliConstants.java +++ b/restli-resources/src/main/java/com/linkedin/metadata/restli/RestliConstants.java @@ -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";