@@ -0,0 +1,1930 @@
+package io.digdag.standards.command.kubernetes;%0A%0Aimport io.fabric8.kubernetes.api.model.ContainerStateTerminated;%0Aimport io.fabric8.kubernetes.api.model.ContainerStatus;%0Aimport io.fabric8.kubernetes.api.model.ObjectMeta;%0Aimport io.fabric8.kubernetes.api.model.PodStatus;%0A%0Aimport java.time.Instant;%0Aimport java.time.ZoneId;%0Aimport java.time.format.DateTimeFormatter;%0Aimport java.util.List;%0Aimport java.util.Locale;%0A%0Apublic class Pod%0A%7B%0A    public static Pod of(final io.fabric8.kubernetes.api.model.Pod pod)%0A    %7B%0A        return new Pod(pod);%0A    %7D%0A%0A    private final io.fabric8.kubernetes.api.model.Pod pod;%0A    private final DateTimeFormatter formatter;%0A%0A    private Pod(final io.fabric8.kubernetes.api.model.Pod pod)%0A    %7B%0A        this.pod = pod;%0A        this.formatter = DateTimeFormatter.ofPattern(%22yyyy-MM-dd'T'HH:mm:ss'Z'%22, Locale.ENGLISH)%0A                .withZone(ZoneId.of(%22UTC%22));%0A    %7D%0A%0A    public String getName()%0A    %7B%0A        return getMetadata().getName();%0A    %7D%0A%0A    public long getCreationTimestamp()%0A    %7B%0A        String creationTimestamp = getMetadata().getCreationTimestamp();%0A        Instant instant = Instant.from(formatter.parse(creationTimestamp));%0A        return instant.getEpochSecond();%0A    %7D%0A%0A    public String getPhase()%0A    %7B%0A        return getStatus().getPhase();%0A    %7D%0A%0A    public int getStatusCode()%0A    %7B%0A        // if the pod completed, we can use this method.%0A        final PodStatus podStatus = pod.getStatus();%0A        final List%3CContainerStatus%3E containerStatusList = podStatus.getContainerStatuses();%0A        final ContainerStateTerminated terminated = containerStatusList.get(0).getState().getTerminated();%0A        return terminated.getExitCode();%0A    %7D%0A%0A    @Override%0A    public String toString()%0A    %7B%0A        return pod.toString();%0A    %7D%0A%0A    PodStatus getStatus()%0A    %7B%0A        return pod.getStatus();%0A    %7D%0A%0A    ObjectMeta getMetadata()%0A    %7B%0A        return pod.getMetadata();%0A    %7D%0A%7D%0A

Create Pod model