Skip to content

Commit

Permalink
Add job tagging to API (#2774)
Browse files Browse the repository at this point in the history
* add job tagging to API

Signed-off-by: sharpd <davidsharp7@gmail.com>

* fix various tests that were failing

Signed-off-by: sharpd <davidsharp7@gmail.com>

* fix merge commit

Signed-off-by: sharpd <davidsharp7@gmail.com>

* fix liniting

Signed-off-by: sharpd <davidsharp7@gmail.com>

* update based on pr feedback

Signed-off-by: sharpd <davidsharp7@gmail.com>

* lint tag test code

Signed-off-by: sharpd <davidsharp7@gmail.com>

* lint tag  code

Signed-off-by: sharpd <davidsharp7@gmail.com>

* fix log typo

Signed-off-by: sharpd <davidsharp7@gmail.com>

* fix logging

Signed-off-by: sharpd <davidsharp7@gmail.com>

* update based on PR feedback.

Signed-off-by: sharpd <davidsharp7@gmail.com>

* correct db field error

Signed-off-by: sharpd <davidsharp7@gmail.com>

---------

Signed-off-by: sharpd <davidsharp7@gmail.com>
Co-authored-by: Willy Lulciuc <willy@datakin.com>
  • Loading branch information
davidsharp7 and wslulciuc authored May 7, 2024
1 parent ae794a9 commit 00b6d35
Show file tree
Hide file tree
Showing 21 changed files with 510 additions and 169 deletions.
4 changes: 2 additions & 2 deletions api/src/main/java/marquez/api/DatasetResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public Response tagField(
throwIfNotExists(namespaceName, datasetName);
throwIfNotExists(namespaceName, datasetName, fieldName);
log.info(
"Tagging field '{}' for dataset '{}' with '{}'.",
"Tagging field '{}' on dataset '{}' with '{}'.",
fieldName.getValue(),
datasetName.getValue(),
tagName.getValue());
Expand Down Expand Up @@ -270,7 +270,7 @@ public Response deleteTagField(
throwIfNotExists(namespaceName, datasetName);
throwIfNotExists(namespaceName, datasetName, fieldName);
log.info(
"Deleting Tag '{}' from field '{}' on dataset '{}' in namepspace '{}'.",
"Deleting Tag '{}' from field '{}' on dataset '{}' in namespace '{}'.",
tagName.getValue(),
fieldName.getValue(),
datasetName.getValue(),
Expand Down
42 changes: 42 additions & 0 deletions api/src/main/java/marquez/api/JobResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import marquez.common.models.JobName;
import marquez.common.models.NamespaceName;
import marquez.common.models.RunId;
import marquez.common.models.TagName;
import marquez.common.models.Version;
import marquez.db.JobFacetsDao;
import marquez.db.JobVersionDao;
Expand Down Expand Up @@ -273,6 +274,47 @@ public Response getRunFacets(
return Response.ok(facets).build();
}

@Timed
@ResponseMetered
@ExceptionMetered
@POST
@Path("/namespaces/{namespace}/jobs/{job}/tags/{tag}")
@Produces(APPLICATION_JSON)
public Response updatetag(
@PathParam("namespace") NamespaceName namespaceName,
@PathParam("job") JobName jobName,
@PathParam("tag") TagName tagName) {
throwIfNotExists(namespaceName);
throwIfNotExists(namespaceName, jobName);

jobService.updateJobTags(namespaceName.getValue(), jobName.getValue(), tagName.getValue());
Job job =
jobService
.findJobByName(namespaceName.getValue(), jobName.getValue())
.orElseThrow(() -> new JobNotFoundException(jobName));
return Response.ok(job).build();
}

@ResponseMetered
@ExceptionMetered
@DELETE
@Path("/namespaces/{namespace}/jobs/{job}/tags/{tag}")
@Produces(APPLICATION_JSON)
public Response deletetag(
@PathParam("namespace") NamespaceName namespaceName,
@PathParam("job") JobName jobName,
@PathParam("tag") TagName tagName) {
throwIfNotExists(namespaceName);
throwIfNotExists(namespaceName, jobName);

jobService.deleteJobTags(namespaceName.getValue(), jobName.getValue(), tagName.getValue());
Job job =
jobService
.findJobByName(namespaceName.getValue(), jobName.getValue())
.orElseThrow(() -> new JobNotFoundException(jobName));
return Response.ok(job).build();
}

@Value
static class JobVersions {
@NonNull
Expand Down
Loading

0 comments on commit 00b6d35

Please sign in to comment.