package be.iminds.ilabt.jfed.experimenter_gui.events;

import be.iminds.ilabt.jfed.rspec.rspec_source.RequestRspecSource;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.time.Instant;

/**
 * User: twalcari
 * Date: 8/9/2016
 * Time: 16:54
 */
public class StartExperimentEvent {

    @Nonnull
    private final String sliceName;
    @Nullable
    private final String subAuthName;

    @Nullable
    private final Instant startTime;
    @Nonnull
    private final Instant expirationTime;

    private final RequestRspecSource requestRspecSource;

    private final boolean includeSshKeys;
    private final boolean requestSla;

    public StartExperimentEvent(String sliceName, String subAuthName, Instant expirationTime, RequestRspecSource requestRspecSource, boolean includeSshKeys, boolean requestSla) {
        this(sliceName, subAuthName, null, expirationTime, requestRspecSource, includeSshKeys, requestSla);
    }

    public StartExperimentEvent(@Nonnull String sliceName, @Nullable String subAuthName,
                                @Nullable Instant startTime, @Nonnull Instant expirationTime, RequestRspecSource requestRspecSource, boolean includeSshKeys, boolean requestSla) {
        this.sliceName = sliceName;
        this.subAuthName = subAuthName;
        this.startTime = startTime;
        this.expirationTime = expirationTime;
        this.requestRspecSource = requestRspecSource;
        this.includeSshKeys = includeSshKeys;
        this.requestSla = requestSla;
    }

    @Nonnull
    public String getSliceName() {
        return sliceName;
    }

    @Nullable
    public String getSubAuthName() {
        return subAuthName;
    }

    @Nonnull
    public Instant getExpirationTime() {
        return expirationTime;
    }

    public RequestRspecSource getRequestRspecSource() {
        return requestRspecSource;
    }

    @Nullable
    public Instant getStartTime() {
        return startTime;
    }

    public boolean isIncludeSshKeys() {
        return includeSshKeys;
    }

    public boolean isRequestSla() {
        return requestSla;
    }

    @Override
    public String toString() {
        return "StartExperimentEvent{" +
                "sliceName='" + sliceName + '\'' +
                ", subAuthName='" + subAuthName + '\'' +
                ", startTime=" + startTime +
                ", expirationTime=" + expirationTime +
                ", requestRspec=" + (requestRspecSource==null?null:requestRspecSource.getRspecXmlString()) +
                ", includeSshKeys=" + includeSshKeys +
                ", requestSla=" + requestSla +
                '}';
    }
}
