Skip to content

Commit 00b6d35

Browse files
Add job tagging to API (#2774)
* add job tagging to API Signed-off-by: sharpd <[email protected]> * fix various tests that were failing Signed-off-by: sharpd <[email protected]> * fix merge commit Signed-off-by: sharpd <[email protected]> * fix liniting Signed-off-by: sharpd <[email protected]> * update based on pr feedback Signed-off-by: sharpd <[email protected]> * lint tag test code Signed-off-by: sharpd <[email protected]> * lint tag code Signed-off-by: sharpd <[email protected]> * fix log typo Signed-off-by: sharpd <[email protected]> * fix logging Signed-off-by: sharpd <[email protected]> * update based on PR feedback. Signed-off-by: sharpd <[email protected]> * correct db field error Signed-off-by: sharpd <[email protected]> --------- Signed-off-by: sharpd <[email protected]> Co-authored-by: Willy Lulciuc <[email protected]>
1 parent ae794a9 commit 00b6d35

File tree

21 files changed

+510
-169
lines changed

21 files changed

+510
-169
lines changed

api/src/main/java/marquez/api/DatasetResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public Response tagField(
242242
throwIfNotExists(namespaceName, datasetName);
243243
throwIfNotExists(namespaceName, datasetName, fieldName);
244244
log.info(
245-
"Tagging field '{}' for dataset '{}' with '{}'.",
245+
"Tagging field '{}' on dataset '{}' with '{}'.",
246246
fieldName.getValue(),
247247
datasetName.getValue(),
248248
tagName.getValue());
@@ -270,7 +270,7 @@ public Response deleteTagField(
270270
throwIfNotExists(namespaceName, datasetName);
271271
throwIfNotExists(namespaceName, datasetName, fieldName);
272272
log.info(
273-
"Deleting Tag '{}' from field '{}' on dataset '{}' in namepspace '{}'.",
273+
"Deleting Tag '{}' from field '{}' on dataset '{}' in namespace '{}'.",
274274
tagName.getValue(),
275275
fieldName.getValue(),
276276
datasetName.getValue(),

api/src/main/java/marquez/api/JobResource.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import marquez.common.models.JobName;
4343
import marquez.common.models.NamespaceName;
4444
import marquez.common.models.RunId;
45+
import marquez.common.models.TagName;
4546
import marquez.common.models.Version;
4647
import marquez.db.JobFacetsDao;
4748
import marquez.db.JobVersionDao;
@@ -273,6 +274,47 @@ public Response getRunFacets(
273274
return Response.ok(facets).build();
274275
}
275276

277+
@Timed
278+
@ResponseMetered
279+
@ExceptionMetered
280+
@POST
281+
@Path("/namespaces/{namespace}/jobs/{job}/tags/{tag}")
282+
@Produces(APPLICATION_JSON)
283+
public Response updatetag(
284+
@PathParam("namespace") NamespaceName namespaceName,
285+
@PathParam("job") JobName jobName,
286+
@PathParam("tag") TagName tagName) {
287+
throwIfNotExists(namespaceName);
288+
throwIfNotExists(namespaceName, jobName);
289+
290+
jobService.updateJobTags(namespaceName.getValue(), jobName.getValue(), tagName.getValue());
291+
Job job =
292+
jobService
293+
.findJobByName(namespaceName.getValue(), jobName.getValue())
294+
.orElseThrow(() -> new JobNotFoundException(jobName));
295+
return Response.ok(job).build();
296+
}
297+
298+
@ResponseMetered
299+
@ExceptionMetered
300+
@DELETE
301+
@Path("/namespaces/{namespace}/jobs/{job}/tags/{tag}")
302+
@Produces(APPLICATION_JSON)
303+
public Response deletetag(
304+
@PathParam("namespace") NamespaceName namespaceName,
305+
@PathParam("job") JobName jobName,
306+
@PathParam("tag") TagName tagName) {
307+
throwIfNotExists(namespaceName);
308+
throwIfNotExists(namespaceName, jobName);
309+
310+
jobService.deleteJobTags(namespaceName.getValue(), jobName.getValue(), tagName.getValue());
311+
Job job =
312+
jobService
313+
.findJobByName(namespaceName.getValue(), jobName.getValue())
314+
.orElseThrow(() -> new JobNotFoundException(jobName));
315+
return Response.ok(job).build();
316+
}
317+
276318
@Value
277319
static class JobVersions {
278320
@NonNull

0 commit comments

Comments
 (0)