Search in sources :

Example 1 with Json

use of com.sequenceiq.periscope.model.json.Json in project cloudbreak by hortonworks.

the class AuditService method auditAutoscaleServiceEvent.

@Async
public void auditAutoscaleServiceEvent(ScalingStatus scalingStatus, String auditMessage, String clusterCrn, String accountId, Long timestamp) {
    AuditEvent event = null;
    try {
        Map<String, Object> eventDetails = new HashMap<>();
        eventDetails.put(CLUSTER_CRN, clusterCrn);
        eventDetails.put(TIMESTAMP, timestamp);
        eventDetails.put(AUTOSCALE_ACTION, auditMessage);
        eventDetails.put(AUTOSCALE_TRIGGER_STATUS, scalingStatus);
        ServiceEventData serviceEventData = ServiceEventData.builder().withEventDetails(new Json(eventDetails).getValue()).withVersion(periscopeVersion).build();
        event = AuditEvent.builder().withAccountId(accountId).withEventData(serviceEventData).withEventName(AuditEventName.AUTOSCALE_DATAHUB_CLUSTER).withEventSource(Crn.Service.DATAHUB).withActor(ActorService.builder().withActorServiceName(Crn.Service.DATAHUB.getName()).build()).build();
        auditClient.createAuditEvent(event);
    } catch (Exception ex) {
        LOGGER.warn("Service Audit event creation failed, error : '{}', event : '{}'", ex.getMessage(), event, ex);
    }
}
Also used : HashMap(java.util.HashMap) ServiceEventData(com.sequenceiq.cloudbreak.audit.model.ServiceEventData) AuditEvent(com.sequenceiq.cloudbreak.audit.model.AuditEvent) Json(com.sequenceiq.periscope.model.json.Json) Async(org.springframework.scheduling.annotation.Async)

Example 2 with Json

use of com.sequenceiq.periscope.model.json.Json in project cloudbreak by hortonworks.

the class AuditService method auditRestApi.

@Async
public void auditRestApi(Map<String, Object> requestParameters, boolean mutating, String userAgent, String userCrn, String accountId, String sourceIp) {
    AuditEvent event = null;
    try {
        ApiRequestData apiRequestData = ApiRequestData.builder().withApiVersion(periscopeVersion).withMutating(mutating).withRequestParameters(new Json(requestParameters).getValue()).withUserAgent(userAgent).build();
        event = AuditEvent.builder().withAccountId(accountId).withActor(ActorCrn.builder().withActorCrn(userCrn).build()).withEventData(apiRequestData).withEventName(AuditEventName.MANAGE_AUTOSCALE_DATAHUB_CLUSTER).withEventSource(Crn.Service.DATAHUB).withSourceIp(sourceIp).build();
        auditClient.createAuditEvent(event);
    } catch (Exception ex) {
        LOGGER.warn("API Audit event creation failed, error : '{}', event : '{}'", ex.getMessage(), event, ex);
    }
}
Also used : ApiRequestData(com.sequenceiq.cloudbreak.audit.model.ApiRequestData) AuditEvent(com.sequenceiq.cloudbreak.audit.model.AuditEvent) Json(com.sequenceiq.periscope.model.json.Json) Async(org.springframework.scheduling.annotation.Async)

Aggregations

AuditEvent (com.sequenceiq.cloudbreak.audit.model.AuditEvent)2 Json (com.sequenceiq.periscope.model.json.Json)2 Async (org.springframework.scheduling.annotation.Async)2 ApiRequestData (com.sequenceiq.cloudbreak.audit.model.ApiRequestData)1 ServiceEventData (com.sequenceiq.cloudbreak.audit.model.ServiceEventData)1 HashMap (java.util.HashMap)1