org.testifyproject.spotify.docker.client.messages.Event Maven / Gradle / Ivy
The newest version!
/*-
* -\-\-
* docker-client
* --
* Copyright (C) 2016 Spotify AB
* --
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in org.testifyproject.testifyprojectpliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org.testifyproject/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* -/-/-
*/
package org.testifyproject.testifyproject.spotify.docker.client.messages;
import static org.testifyproject.testifyproject.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY;
import static org.testifyproject.testifyproject.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import org.testifyproject.testifyproject.fasterxml.jackson.annotation.JsonAutoDetect;
import org.testifyproject.testifyproject.fasterxml.jackson.annotation.JsonCreator;
import org.testifyproject.testifyproject.fasterxml.jackson.annotation.JsonProperty;
import org.testifyproject.testifyproject.fasterxml.jackson.annotation.JsonValue;
import org.testifyproject.testifyproject.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.testifyproject.testifyproject.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.testifyproject.testifyproject.google.auto.value.AutoValue;
import org.testifyproject.testifyproject.google.org.testifyproject.testifyprojectmon.collect.ImmutableMap;
import org.testifyproject.testifyproject.spotify.docker.client.jackson.UnixTimestampDeserializer;
import org.testifyproject.testifyproject.spotify.docker.client.jackson.UnixTimestampSerializer;
import java.util.Date;
import java.util.Map;
import javax.annotation.Nullable;
@AutoValue
@JsonAutoDetect(fieldVisibility = ANY, setterVisibility = NONE, getterVisibility = NONE)
public abstract class Event {
/**
* Event status.
* @return status
* @deprecated Use {@link #action()} instead
*/
@Deprecated
@Nullable
@JsonProperty("status")
public abstract String status();
/**
* Event actor id. When the event type is "container" this is the container id.
* @return id
* @deprecated Use the {@link org.testifyproject.testifyproject.spotify.docker.client.messages.Event.Actor#id()}
* field from {@link #actor()}
*/
@Deprecated
@Nullable
@JsonProperty("id")
public abstract String id();
/**
* When the event type is "container" this is the image id.
* @return from
* @deprecated Use the "image" attribute in the
* {@link org.testifyproject.testifyproject.spotify.docker.client.messages.Event.Actor#attributes()}
* map from {@link #actor()}
*/
@Deprecated
@Nullable
@JsonProperty("from")
public abstract String from();
@Nullable
@JsonProperty("Type")
public abstract Type type();
/**
* Event action.
* @return action
* @since API 1.22
*/
@Nullable
@JsonProperty("Action")
public abstract String action();
/**
* Event actor.
* @return {@link Actor}
* @since API 1.22
*/
@Nullable
@JsonProperty("Actor")
public abstract Actor actor();
@JsonProperty("time")
@JsonDeserialize(using = UnixTimestampDeserializer.class)
@JsonSerialize(using = UnixTimestampSerializer.class)
public abstract Date time();
@Nullable
@JsonProperty("timeNano")
public abstract Long timeNano();
@JsonCreator
static Event create(
@JsonProperty("status") final String status,
@JsonProperty("id") final String id,
@JsonProperty("from") final String from,
@JsonProperty("Type") final Type type,
@JsonProperty("Action") final String action,
@JsonProperty("Actor") final Actor actor,
@JsonProperty("time") final Date time,
@JsonProperty("timeNano") final Long timeNano) {
return new AutoValue_Event(status, id, from, type, action, actor, time, timeNano);
}
@AutoValue
public abstract static class Actor {
@JsonProperty("ID")
public abstract String id();
@Nullable
@JsonProperty("Attributes")
public abstract ImmutableMap attributes();
@JsonCreator
static Actor create(
@JsonProperty("ID") final String id,
@JsonProperty("Attributes") final Map attributes) {
final ImmutableMap attributesT = attributes == null
? null : ImmutableMap.copyOf(attributes);
return new AutoValue_Event_Actor(id, attributesT);
}
}
public enum Type {
CONTAINER("container"),
IMAGE("image"),
VOLUME("volume"),
NETWORK("network"),
DAEMON("daemon"),
PLUGIN("plugin"),
NODE("node"),
SERVICE("service"),
SECRET("secret");
private final String name;
@JsonCreator
Type(final String name) {
this.name = name;
}
@JsonValue
public String getName() {
return name;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy