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

com.azure.resourcemanager.mediaservices.fluent.models.JobProperties Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for MediaServices Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. This Swagger was generated by the API Framework. Package tag package-account-2023-01.

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

package com.azure.resourcemanager.mediaservices.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.mediaservices.models.JobInput;
import com.azure.resourcemanager.mediaservices.models.JobOutput;
import com.azure.resourcemanager.mediaservices.models.JobState;
import com.azure.resourcemanager.mediaservices.models.Priority;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;

/**
 * Properties of the Job.
 */
@Fluent
public final class JobProperties implements JsonSerializable {
    /*
     * The UTC date and time when the customer has created the Job, in 'YYYY-MM-DDThh:mm:ssZ' format.
     */
    private OffsetDateTime created;

    /*
     * The current state of the job.
     */
    private JobState state;

    /*
     * Optional customer supplied description of the Job.
     */
    private String description;

    /*
     * The inputs for the Job.
     */
    private JobInput input;

    /*
     * The UTC date and time when the customer has last updated the Job, in 'YYYY-MM-DDThh:mm:ssZ' format.
     */
    private OffsetDateTime lastModified;

    /*
     * The outputs for the Job.
     */
    private List outputs;

    /*
     * Priority with which the job should be processed. Higher priority jobs are processed before lower priority jobs.
     * If not set, the default is normal.
     */
    private Priority priority;

    /*
     * Customer provided key, value pairs that will be returned in Job and JobOutput state events.
     */
    private Map correlationData;

    /*
     * The UTC date and time at which this Job began processing.
     */
    private OffsetDateTime startTime;

    /*
     * The UTC date and time at which this Job finished processing.
     */
    private OffsetDateTime endTime;

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

    /**
     * Get the created property: The UTC date and time when the customer has created the Job, in 'YYYY-MM-DDThh:mm:ssZ'
     * format.
     * 
     * @return the created value.
     */
    public OffsetDateTime created() {
        return this.created;
    }

    /**
     * Get the state property: The current state of the job.
     * 
     * @return the state value.
     */
    public JobState state() {
        return this.state;
    }

    /**
     * Get the description property: Optional customer supplied description of the Job.
     * 
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: Optional customer supplied description of the Job.
     * 
     * @param description the description value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the input property: The inputs for the Job.
     * 
     * @return the input value.
     */
    public JobInput input() {
        return this.input;
    }

    /**
     * Set the input property: The inputs for the Job.
     * 
     * @param input the input value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withInput(JobInput input) {
        this.input = input;
        return this;
    }

    /**
     * Get the lastModified property: The UTC date and time when the customer has last updated the Job, in
     * 'YYYY-MM-DDThh:mm:ssZ' format.
     * 
     * @return the lastModified value.
     */
    public OffsetDateTime lastModified() {
        return this.lastModified;
    }

    /**
     * Get the outputs property: The outputs for the Job.
     * 
     * @return the outputs value.
     */
    public List outputs() {
        return this.outputs;
    }

    /**
     * Set the outputs property: The outputs for the Job.
     * 
     * @param outputs the outputs value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withOutputs(List outputs) {
        this.outputs = outputs;
        return this;
    }

    /**
     * Get the priority property: Priority with which the job should be processed. Higher priority jobs are processed
     * before lower priority jobs. If not set, the default is normal.
     * 
     * @return the priority value.
     */
    public Priority priority() {
        return this.priority;
    }

    /**
     * Set the priority property: Priority with which the job should be processed. Higher priority jobs are processed
     * before lower priority jobs. If not set, the default is normal.
     * 
     * @param priority the priority value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withPriority(Priority priority) {
        this.priority = priority;
        return this;
    }

    /**
     * Get the correlationData property: Customer provided key, value pairs that will be returned in Job and JobOutput
     * state events.
     * 
     * @return the correlationData value.
     */
    public Map correlationData() {
        return this.correlationData;
    }

    /**
     * Set the correlationData property: Customer provided key, value pairs that will be returned in Job and JobOutput
     * state events.
     * 
     * @param correlationData the correlationData value to set.
     * @return the JobProperties object itself.
     */
    public JobProperties withCorrelationData(Map correlationData) {
        this.correlationData = correlationData;
        return this;
    }

    /**
     * Get the startTime property: The UTC date and time at which this Job began processing.
     * 
     * @return the startTime value.
     */
    public OffsetDateTime startTime() {
        return this.startTime;
    }

    /**
     * Get the endTime property: The UTC date and time at which this Job finished processing.
     * 
     * @return the endTime value.
     */
    public OffsetDateTime endTime() {
        return this.endTime;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (input() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property input in model JobProperties"));
        } else {
            input().validate();
        }
        if (outputs() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property outputs in model JobProperties"));
        } else {
            outputs().forEach(e -> e.validate());
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("input", this.input);
        jsonWriter.writeArrayField("outputs", this.outputs, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeStringField("description", this.description);
        jsonWriter.writeStringField("priority", this.priority == null ? null : this.priority.toString());
        jsonWriter.writeMapField("correlationData", this.correlationData,
            (writer, element) -> writer.writeString(element));
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of JobProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of JobProperties if the JsonReader was pointing to an instance of it, or null if it was
     * pointing to JSON null.
     * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
     * @throws IOException If an error occurs while reading the JobProperties.
     */
    public static JobProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            JobProperties deserializedJobProperties = new JobProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("input".equals(fieldName)) {
                    deserializedJobProperties.input = JobInput.fromJson(reader);
                } else if ("outputs".equals(fieldName)) {
                    List outputs = reader.readArray(reader1 -> JobOutput.fromJson(reader1));
                    deserializedJobProperties.outputs = outputs;
                } else if ("created".equals(fieldName)) {
                    deserializedJobProperties.created = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("state".equals(fieldName)) {
                    deserializedJobProperties.state = JobState.fromString(reader.getString());
                } else if ("description".equals(fieldName)) {
                    deserializedJobProperties.description = reader.getString();
                } else if ("lastModified".equals(fieldName)) {
                    deserializedJobProperties.lastModified = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("priority".equals(fieldName)) {
                    deserializedJobProperties.priority = Priority.fromString(reader.getString());
                } else if ("correlationData".equals(fieldName)) {
                    Map correlationData = reader.readMap(reader1 -> reader1.getString());
                    deserializedJobProperties.correlationData = correlationData;
                } else if ("startTime".equals(fieldName)) {
                    deserializedJobProperties.startTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("endTime".equals(fieldName)) {
                    deserializedJobProperties.endTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedJobProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy