Search in sources :

Example 6 with MetadataEntity

use of io.cdap.cdap.api.metadata.MetadataEntity in project cdap by caskdata.

the class MetadataHttpHandler method removeProperties.

@DELETE
@Path("/**/metadata/properties")
public void removeProperties(HttpRequest request, HttpResponder responder, @QueryParam("type") String type, @QueryParam("async") @DefaultValue("false") Boolean async) throws Exception {
    MetadataEntity metadataEntity = getMetadataEntityFromPath(request.uri(), type, "/metadata/properties");
    enforce(metadataEntity, StandardPermission.UPDATE);
    metadataAdmin.removeProperties(metadataEntity, async ? ASYNC : SYNC);
    responder.sendString(HttpResponseStatus.OK, String.format("Metadata properties for %s deleted successfully.", metadataEntity));
}
Also used : MetadataEntity(io.cdap.cdap.api.metadata.MetadataEntity) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 7 with MetadataEntity

use of io.cdap.cdap.api.metadata.MetadataEntity in project cdap by caskdata.

the class MetadataHttpHandler method removeTags.

@DELETE
@Path("/**/metadata/tags")
public void removeTags(HttpRequest request, HttpResponder responder, @QueryParam("type") String type, @QueryParam("async") @DefaultValue("false") Boolean async) throws Exception {
    MetadataEntity metadataEntity = getMetadataEntityFromPath(request.uri(), type, "/metadata/tags");
    enforce(metadataEntity, StandardPermission.UPDATE);
    metadataAdmin.removeTags(metadataEntity, async ? ASYNC : SYNC);
    responder.sendString(HttpResponseStatus.OK, String.format("Metadata tags for %s deleted successfully.", metadataEntity));
}
Also used : MetadataEntity(io.cdap.cdap.api.metadata.MetadataEntity) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 8 with MetadataEntity

use of io.cdap.cdap.api.metadata.MetadataEntity in project cdap by caskdata.

the class MetadataHttpHandler method getTags.

@GET
@Path("/**/metadata/tags")
public void getTags(HttpRequest request, HttpResponder responder, @QueryParam("scope") String scope, @QueryParam("type") String type, @Nullable @QueryParam("responseFormat") @DefaultValue("v5") String responseFormat) throws Exception {
    MetadataEntity entity = getMetadataEntityFromPath(request.uri(), type, "/metadata/tags");
    if (isEntityType(entity)) {
        accessEnforcer.enforce(EntityId.<EntityId>fromMetadataEntity(entity), authenticationContext.getPrincipal(), StandardPermission.GET);
    }
    MetadataScope theScope = validateScope(scope);
    responder.sendJson(HttpResponseStatus.OK, GSON.toJson("v5".equals(responseFormat) ? (scope == null ? metadataAdmin.getTags(entity) : metadataAdmin.getTags(theScope, entity)) : metadataAdmin.getMetadata(entity, theScope, MetadataKind.TAG)));
}
Also used : MetadataEntity(io.cdap.cdap.api.metadata.MetadataEntity) MetadataScope(io.cdap.cdap.api.metadata.MetadataScope) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 9 with MetadataEntity

use of io.cdap.cdap.api.metadata.MetadataEntity in project cdap by caskdata.

the class MetadataHttpHandler method addProperties.

@POST
@Path("/**/metadata/properties")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void addProperties(FullHttpRequest request, HttpResponder responder, @QueryParam("type") String type, @QueryParam("async") @DefaultValue("false") Boolean async) throws Exception {
    MetadataEntity metadataEntity = getMetadataEntityFromPath(request.uri(), type, "/metadata/properties");
    enforce(metadataEntity, StandardPermission.UPDATE);
    metadataAdmin.addProperties(metadataEntity, readProperties(request), async ? ASYNC : SYNC);
    responder.sendString(HttpResponseStatus.OK, String.format("Metadata properties for %s added successfully.", metadataEntity));
}
Also used : MetadataEntity(io.cdap.cdap.api.metadata.MetadataEntity) Path(javax.ws.rs.Path) AuditPolicy(io.cdap.cdap.common.security.AuditPolicy) POST(javax.ws.rs.POST)

Example 10 with MetadataEntity

use of io.cdap.cdap.api.metadata.MetadataEntity in project cdap by caskdata.

the class MetadataHttpHandler method removeMetadata.

@DELETE
@Path("/**/metadata")
public void removeMetadata(HttpRequest request, HttpResponder responder, @QueryParam("type") String type, @QueryParam("async") @DefaultValue("false") Boolean async) throws Exception {
    MetadataEntity metadataEntity = getMetadataEntityFromPath(request.uri(), type, "/metadata");
    enforce(metadataEntity, StandardPermission.DELETE);
    metadataAdmin.removeMetadata(metadataEntity, async ? ASYNC : SYNC);
    responder.sendString(HttpResponseStatus.OK, String.format("Metadata for %s deleted successfully.", metadataEntity));
}
Also used : MetadataEntity(io.cdap.cdap.api.metadata.MetadataEntity) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Aggregations

MetadataEntity (io.cdap.cdap.api.metadata.MetadataEntity)192 Test (org.junit.Test)114 Drop (io.cdap.cdap.spi.metadata.MetadataMutation.Drop)58 Update (io.cdap.cdap.spi.metadata.MetadataMutation.Update)56 MetadataScope (io.cdap.cdap.api.metadata.MetadataScope)34 HashMap (java.util.HashMap)30 HashSet (java.util.HashSet)30 Map (java.util.Map)28 ImmutableMap (com.google.common.collect.ImmutableMap)26 IOException (java.io.IOException)26 ArrayList (java.util.ArrayList)26 Remove (io.cdap.cdap.spi.metadata.MetadataMutation.Remove)24 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)22 List (java.util.List)22 Metadata (io.cdap.cdap.spi.metadata.Metadata)20 Create (io.cdap.cdap.spi.metadata.MetadataMutation.Create)20 Set (java.util.Set)20 Collectors (java.util.stream.Collectors)20 Nullable (javax.annotation.Nullable)20 Path (javax.ws.rs.Path)20