Search in sources :

Example 1 with CDPStructuredNotificationEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent in project cloudbreak by hortonworks.

the class CDPStructuredEventV1Controller method getAuditEventsZipResponse.

private Response getAuditEventsZipResponse(Collection<CDPStructuredNotificationEvent> events, String resourceCrn) {
    StreamingOutput streamingOutput = output -> {
        try (ZipOutputStream zipOutputStream = new ZipOutputStream(output)) {
            zipOutputStream.putNextEntry(new ZipEntry("struct-events.json"));
            zipOutputStream.write(JsonUtil.writeValueAsString(events).getBytes());
            zipOutputStream.closeEntry();
        }
    };
    String resourceType = Crn.safeFromString(resourceCrn).getResourceType().getName();
    String fileName = String.format("audit-%s.zip", resourceType);
    return Response.ok(streamingOutput).header("content-disposition", String.format("attachment; filename = %s", fileName)).build();
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) ResourceCrn(com.sequenceiq.authorization.annotation.ResourceCrn) Collection(java.util.Collection) PageRequest(org.springframework.data.domain.PageRequest) CDPStructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent) StreamingOutput(javax.ws.rs.core.StreamingOutput) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) Controller(org.springframework.stereotype.Controller) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) CDPStructuredEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredEvent) CDPStructuredEventV1Endpoint(com.sequenceiq.cloudbreak.structuredevent.rest.endpoint.CDPStructuredEventV1Endpoint) Inject(javax.inject.Inject) StructuredEventType(com.sequenceiq.cloudbreak.structuredevent.event.StructuredEventType) List(java.util.List) CustomPermissionCheck(com.sequenceiq.authorization.annotation.CustomPermissionCheck) Response(javax.ws.rs.core.Response) Sort(org.springframework.data.domain.Sort) ZipEntry(java.util.zip.ZipEntry) CDPStructuredEventDBService(com.sequenceiq.cloudbreak.structuredevent.service.db.CDPStructuredEventDBService) ZipOutputStream(java.util.zip.ZipOutputStream) ZipEntry(java.util.zip.ZipEntry) StreamingOutput(javax.ws.rs.core.StreamingOutput)

Example 2 with CDPStructuredNotificationEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent in project cloudbreak by hortonworks.

the class CDPStructuredEventV1ControllerTest method createCDPStructuredNotificationEvent.

private CDPStructuredNotificationEvent createCDPStructuredNotificationEvent() {
    CDPStructuredNotificationEvent event = new CDPStructuredNotificationEvent();
    event.setOperation(createTestCDPStructuredEvent().getOperation());
    return event;
}
Also used : CDPStructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)

Example 3 with CDPStructuredNotificationEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent in project cloudbreak by hortonworks.

the class EventSenderService method sendEventAndNotificationForMissingEnv.

public void sendEventAndNotificationForMissingEnv(BaseNamedFlowEvent payload, ResourceEvent resourceEvent, String userCrn) {
    CDPStructuredNotificationEvent cdpStructuredEvent = createStructureEventForMissingEnvironment(payload, resourceEvent, userCrn);
    cdpDefaultStructuredEventClient.sendStructuredEvent(cdpStructuredEvent);
    notificationService.send(resourceEvent, payload, userCrn);
}
Also used : CDPStructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)

Example 4 with CDPStructuredNotificationEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent in project cloudbreak by hortonworks.

the class SdxEventsServiceTests method createCDPStructuredNotificationEvent.

private CDPStructuredEvent createCDPStructuredNotificationEvent(Long timestamp) {
    CDPOperationDetails operationDetails = new CDPOperationDetails();
    operationDetails.setResourceCrn("someCrn");
    operationDetails.setResourceType("datalake");
    operationDetails.setTimestamp(timestamp);
    operationDetails.setEventType(StructuredEventType.NOTIFICATION);
    CDPStructuredNotificationEvent cdpStructuredEvent = new CDPStructuredNotificationEvent() {

        @Override
        public String getStatus() {
            return SENT;
        }

        @Override
        public Long getDuration() {
            return 1L;
        }
    };
    cdpStructuredEvent.setOperation(operationDetails);
    return cdpStructuredEvent;
}
Also used : CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) CDPStructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)

Example 5 with CDPStructuredNotificationEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent in project cloudbreak by hortonworks.

the class EventSenderService method sendEventAndNotificationWithPayload.

public void sendEventAndNotificationWithPayload(AccountAwareResource resource, String userCrn, ResourceEvent resourceEvent, Object payload, Collection<?> messageArgs) {
    CDPStructuredNotificationEvent cdpStructuredEvent = getStructuredEvent(resource, resourceEvent, payload, messageArgs);
    cdpDefaultStructuredEventClient.sendStructuredEvent(cdpStructuredEvent);
}
Also used : CDPStructuredNotificationEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)

Aggregations

CDPStructuredNotificationEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationEvent)11 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)6 CDPStructuredNotificationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredNotificationDetails)3 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)1 ResourceCrn (com.sequenceiq.authorization.annotation.ResourceCrn)1 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 JsonUtil (com.sequenceiq.cloudbreak.common.json.JsonUtil)1 StructuredEventType (com.sequenceiq.cloudbreak.structuredevent.event.StructuredEventType)1 CDPStructuredEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredEvent)1 CDPStructuredEventV1Endpoint (com.sequenceiq.cloudbreak.structuredevent.rest.endpoint.CDPStructuredEventV1Endpoint)1 CDPStructuredEventDBService (com.sequenceiq.cloudbreak.structuredevent.service.db.CDPStructuredEventDBService)1 Collection (java.util.Collection)1 List (java.util.List)1 ZipEntry (java.util.zip.ZipEntry)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 Inject (javax.inject.Inject)1 Response (javax.ws.rs.core.Response)1 StreamingOutput (javax.ws.rs.core.StreamingOutput)1 PageRequest (org.springframework.data.domain.PageRequest)1 Sort (org.springframework.data.domain.Sort)1