Search in sources :

Example 46 with AuditPolicy

use of co.cask.cdap.common.security.AuditPolicy in project cdap by caskdata.

the class MetadataHttpHandler method addAppTags.

@POST
@Path("/namespaces/{namespace-id}/apps/{app-id}/metadata/tags")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void addAppTags(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId) throws BadRequestException, NotFoundException {
    ApplicationId app = new ApplicationId(namespaceId, appId);
    metadataAdmin.addTags(app, readArray(request));
    responder.sendString(HttpResponseStatus.OK, String.format("Added tags to application %s successfully.", app));
}
Also used : ApplicationId(co.cask.cdap.proto.id.ApplicationId) Path(javax.ws.rs.Path) AuditPolicy(co.cask.cdap.common.security.AuditPolicy) POST(javax.ws.rs.POST)

Example 47 with AuditPolicy

use of co.cask.cdap.common.security.AuditPolicy in project cdap by caskdata.

the class MetadataHttpHandler method addAppProperties.

@POST
@Path("/namespaces/{namespace-id}/apps/{app-id}/metadata/properties")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void addAppProperties(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId) throws BadRequestException, NotFoundException {
    ApplicationId app = new ApplicationId(namespaceId, appId);
    metadataAdmin.addProperties(app, readMetadata(request));
    responder.sendString(HttpResponseStatus.OK, "Metadata added successfully to " + app);
}
Also used : ApplicationId(co.cask.cdap.proto.id.ApplicationId) Path(javax.ws.rs.Path) AuditPolicy(co.cask.cdap.common.security.AuditPolicy) POST(javax.ws.rs.POST)

Example 48 with AuditPolicy

use of co.cask.cdap.common.security.AuditPolicy in project cdap by caskdata.

the class MetadataHttpHandler method addStreamProperties.

@POST
@Path("/namespaces/{namespace-id}/streams/{stream-id}/metadata/properties")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void addStreamProperties(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("stream-id") String streamId) throws BadRequestException, NotFoundException {
    StreamId stream = new StreamId(namespaceId, streamId);
    metadataAdmin.addProperties(stream, readMetadata(request));
    responder.sendString(HttpResponseStatus.OK, "Metadata added successfully to " + stream);
}
Also used : StreamId(co.cask.cdap.proto.id.StreamId) Path(javax.ws.rs.Path) AuditPolicy(co.cask.cdap.common.security.AuditPolicy) POST(javax.ws.rs.POST)

Example 49 with AuditPolicy

use of co.cask.cdap.common.security.AuditPolicy in project cdap by caskdata.

the class MetadataHttpHandler method addViewProperties.

@POST
@Path("/namespaces/{namespace-id}/streams/{stream-id}/views/{view-id}/metadata/properties")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void addViewProperties(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("stream-id") String streamId, @PathParam("view-id") String viewId) throws NotFoundException, BadRequestException {
    StreamViewId view = new StreamViewId(namespaceId, streamId, viewId);
    metadataAdmin.addProperties(view, readMetadata(request));
    responder.sendString(HttpResponseStatus.OK, "Metadata added successfully to " + view);
}
Also used : StreamViewId(co.cask.cdap.proto.id.StreamViewId) Path(javax.ws.rs.Path) AuditPolicy(co.cask.cdap.common.security.AuditPolicy) POST(javax.ws.rs.POST)

Example 50 with AuditPolicy

use of co.cask.cdap.common.security.AuditPolicy in project cdap by caskdata.

the class DatasetInstanceHandler method update.

/**
   * Updates an existing dataset specification properties.
   *
   * @param namespaceId namespace of the dataset instance
   * @param name name of the dataset instance
   * @throws Exception
   */
@PUT
@Path("/data/datasets/{name}/properties")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void update(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("name") String name) throws Exception {
    DatasetId instance = ConversionHelpers.toDatasetInstanceId(namespaceId, name);
    Map<String, String> properties = ConversionHelpers.getProperties(request);
    instanceService.update(instance, properties);
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : DatasetId(co.cask.cdap.proto.id.DatasetId) Path(javax.ws.rs.Path) AuditPolicy(co.cask.cdap.common.security.AuditPolicy) PUT(javax.ws.rs.PUT)

Aggregations

AuditPolicy (co.cask.cdap.common.security.AuditPolicy)86 Path (javax.ws.rs.Path)86 POST (javax.ws.rs.POST)47 PUT (javax.ws.rs.PUT)38 BadRequestException (co.cask.cdap.common.BadRequestException)25 ProgramId (co.cask.cdap.proto.id.ProgramId)22 NamespaceId (co.cask.cdap.proto.id.NamespaceId)17 IOException (java.io.IOException)14 NotFoundException (co.cask.cdap.common.NotFoundException)13 JsonSyntaxException (com.google.gson.JsonSyntaxException)13 NamespaceNotFoundException (co.cask.cdap.common.NamespaceNotFoundException)11 ArtifactId (co.cask.cdap.proto.id.ArtifactId)11 ArrayList (java.util.ArrayList)11 StreamId (co.cask.cdap.proto.id.StreamId)10 ApplicationId (co.cask.cdap.proto.id.ApplicationId)9 Constraint (co.cask.cdap.internal.schedule.constraint.Constraint)8 DatasetId (co.cask.cdap.proto.id.DatasetId)8 InputStreamReader (java.io.InputStreamReader)8 Reader (java.io.Reader)8 ArtifactNotFoundException (co.cask.cdap.common.ArtifactNotFoundException)5