// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.logic.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

/** The tracking event. */
@Fluent
public final class TrackingEvent {
    /*
     * The event level.
     */
    @JsonProperty(value = "eventLevel", required = true)
    private EventLevel eventLevel;

    /*
     * The event time.
     */
    @JsonProperty(value = "eventTime", required = true)
    private OffsetDateTime eventTime;

    /*
     * The record type.
     */
    @JsonProperty(value = "recordType", required = true)
    private TrackingRecordType recordType;

    /*
     * The record.
     */
    @JsonProperty(value = "record")
    private Object record;

    /*
     * The error.
     */
    @JsonProperty(value = "error")
    private TrackingEventErrorInfo error;

    /** Creates an instance of TrackingEvent class. */
    public TrackingEvent() {
    }

    /**
     * Get the eventLevel property: The event level.
     *
     * @return the eventLevel value.
     */
    public EventLevel eventLevel() {
        return this.eventLevel;
    }

    /**
     * Set the eventLevel property: The event level.
     *
     * @param eventLevel the eventLevel value to set.
     * @return the TrackingEvent object itself.
     */
    public TrackingEvent withEventLevel(EventLevel eventLevel) {
        this.eventLevel = eventLevel;
        return this;
    }

    /**
     * Get the eventTime property: The event time.
     *
     * @return the eventTime value.
     */
    public OffsetDateTime eventTime() {
        return this.eventTime;
    }

    /**
     * Set the eventTime property: The event time.
     *
     * @param eventTime the eventTime value to set.
     * @return the TrackingEvent object itself.
     */
    public TrackingEvent withEventTime(OffsetDateTime eventTime) {
        this.eventTime = eventTime;
        return this;
    }

    /**
     * Get the recordType property: The record type.
     *
     * @return the recordType value.
     */
    public TrackingRecordType recordType() {
        return this.recordType;
    }

    /**
     * Set the recordType property: The record type.
     *
     * @param recordType the recordType value to set.
     * @return the TrackingEvent object itself.
     */
    public TrackingEvent withRecordType(TrackingRecordType recordType) {
        this.recordType = recordType;
        return this;
    }

    /**
     * Get the record property: The record.
     *
     * @return the record value.
     */
    public Object record() {
        return this.record;
    }

    /**
     * Set the record property: The record.
     *
     * @param record the record value to set.
     * @return the TrackingEvent object itself.
     */
    public TrackingEvent withRecord(Object record) {
        this.record = record;
        return this;
    }

    /**
     * Get the error property: The error.
     *
     * @return the error value.
     */
    public TrackingEventErrorInfo error() {
        return this.error;
    }

    /**
     * Set the error property: The error.
     *
     * @param error the error value to set.
     * @return the TrackingEvent object itself.
     */
    public TrackingEvent withError(TrackingEventErrorInfo error) {
        this.error = error;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (eventLevel() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property eventLevel in model TrackingEvent"));
        }
        if (eventTime() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property eventTime in model TrackingEvent"));
        }
        if (recordType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property recordType in model TrackingEvent"));
        }
        if (error() != null) {
            error().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(TrackingEvent.class);
}
