All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.huawei.openstack4j.model.image.v2.Task Maven / Gradle / Ivy

/*******************************************************************************
 * 	Copyright 2016 ContainX and OpenStack4j                                          
 * 	                                                                                 
 * 	Licensed under the Apache License, Version 2.0 (the "License"); you may not      
 * 	use this file except in compliance with the License. You may obtain a copy of    
 * 	the License at                                                                   
 * 	                                                                                 
 * 	    http://www.apache.org/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 com.huawei.openstack4j.model.image.v2;

import java.util.Date;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.huawei.openstack4j.common.Buildable;
import com.huawei.openstack4j.model.ModelEntity;
import com.huawei.openstack4j.model.image.v2.builder.TaskBuilder;

/**
 * An object representing a Glance V2 task.
 * Tasks offer end users a front end to long
 * running asynchronous operations.
 * @author emjburns
 */
public interface Task extends ModelEntity, Buildable {

    public enum TaskStatus {
        /**
         *The task identifier has been reserved for a task in the Glance.
         * No processing has begun on it yet.
         */
        PENDING,
        /**
         * The task has been picked up by the underlying executor and is
         * being run using the backend Glance execution logic for that task type.
         */
        PROCESSING,
        /**
         * Denotes that the task has had a successful run within Glance.
         * The result field of the task shows more details about the outcome.
         */
        SUCCESS,
        /**
         * Denotes that an error occurred during the execution of the task and it cannot continue processing.
         * The message field of the task shows what the error was.
         */
        FAILURE,
        /**
         * Task status is not a known value.
         */
        UNKNOWN;

        @JsonCreator
        public static TaskStatus value(String v)
        {
            if (v == null) return UNKNOWN;
            try {
                return valueOf(v.toUpperCase());
            } catch (IllegalArgumentException e) {
                return UNKNOWN;
            }
        }

        @JsonValue
        public String value() {
            return name().toLowerCase();
        }
    }

    /**
     * Date and time task was created.
     * @return
     */
    Date getCreatedAt();

    /**
     * The date and time the task is subject to removal.
     * The result of the task will still exist.
     * @return
     */
    Date getExpiresAt();

    /**
     * The date and time the task was updated.
     * @return
     */
    Date getUpdatedAt();

    /**
     * Identifier for the task, a UUID.
     * @return
     */
    String getId();

    /**
     * A JSON object specifying the input parameters of the task.
     * @return
     */
    Map getInput();

    /**
     * Human readable text, possibly and empty string, usually
     * displayed in an error situation to provide more information
     * about what has occurred.
     * @return
     */
    String getMessage();

    /**
     * Identifier for owner of the task, usually tenant ID.
     * @return
     */
    String getOwner();

    /**
     * A JSON object specifying information about the ultimate
     * outcome of the task.
     * @return
     */
    Map getResult();

    /**
     * The URI for the schema describing an image task.
     * @return
     */
    String getSchema();

    /**
     * The status of the task.
     * @return taskStatus
     */
    TaskStatus getStatus();

    /**
     * The type of task represented by this content.
     * @return
     */
    String getType();

    /**
     * A URI for this task.
     * @return
     */
    String getSelf();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy