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

com.azure.resourcemanager.mediaservices.models.JobOutputAsset 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.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.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;

/**
 * Represents an Asset used as a JobOutput.
 */
@Fluent
public final class JobOutputAsset extends JobOutput {
    /*
     * The discriminator for derived types.
     */
    private String odataType = "#Microsoft.Media.JobOutputAsset";

    /*
     * The name of the output Asset.
     */
    private String assetName;

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

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

    /*
     * If the JobOutput is in a Processing state, this contains the Job completion percentage. The value is an estimate
     * and not intended to be used to predict Job completion times. To determine if the JobOutput is complete, use the
     * State property.
     */
    private Integer progress;

    /*
     * Describes the state of the JobOutput.
     */
    private JobState state;

    /*
     * If the JobOutput is in the Error state, it contains the details of the error.
     */
    private JobError error;

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

    /**
     * Get the odataType property: The discriminator for derived types.
     * 
     * @return the odataType value.
     */
    @Override
    public String odataType() {
        return this.odataType;
    }

    /**
     * Get the assetName property: The name of the output Asset.
     * 
     * @return the assetName value.
     */
    public String assetName() {
        return this.assetName;
    }

    /**
     * Set the assetName property: The name of the output Asset.
     * 
     * @param assetName the assetName value to set.
     * @return the JobOutputAsset object itself.
     */
    public JobOutputAsset withAssetName(String assetName) {
        this.assetName = assetName;
        return this;
    }

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

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

    /**
     * Get the progress property: If the JobOutput is in a Processing state, this contains the Job completion
     * percentage. The value is an estimate and not intended to be used to predict Job completion times. To determine if
     * the JobOutput is complete, use the State property.
     * 
     * @return the progress value.
     */
    @Override
    public Integer progress() {
        return this.progress;
    }

    /**
     * Get the state property: Describes the state of the JobOutput.
     * 
     * @return the state value.
     */
    @Override
    public JobState state() {
        return this.state;
    }

    /**
     * Get the error property: If the JobOutput is in the Error state, it contains the details of the error.
     * 
     * @return the error value.
     */
    @Override
    public JobError error() {
        return this.error;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JobOutputAsset withPresetOverride(Preset presetOverride) {
        super.withPresetOverride(presetOverride);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JobOutputAsset withLabel(String label) {
        super.withLabel(label);
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        if (assetName() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property assetName in model JobOutputAsset"));
        }
        if (error() != null) {
            error().validate();
        }
        if (presetOverride() != null) {
            presetOverride().validate();
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("presetOverride", presetOverride());
        jsonWriter.writeStringField("label", label());
        jsonWriter.writeStringField("assetName", this.assetName);
        jsonWriter.writeStringField("@odata.type", this.odataType);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of JobOutputAsset from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of JobOutputAsset 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 JobOutputAsset.
     */
    public static JobOutputAsset fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            JobOutputAsset deserializedJobOutputAsset = new JobOutputAsset();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("error".equals(fieldName)) {
                    deserializedJobOutputAsset.error = JobError.fromJson(reader);
                } else if ("presetOverride".equals(fieldName)) {
                    deserializedJobOutputAsset.withPresetOverride(Preset.fromJson(reader));
                } else if ("state".equals(fieldName)) {
                    deserializedJobOutputAsset.state = JobState.fromString(reader.getString());
                } else if ("progress".equals(fieldName)) {
                    deserializedJobOutputAsset.progress = reader.getNullable(JsonReader::getInt);
                } else if ("label".equals(fieldName)) {
                    deserializedJobOutputAsset.withLabel(reader.getString());
                } else if ("startTime".equals(fieldName)) {
                    deserializedJobOutputAsset.startTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("endTime".equals(fieldName)) {
                    deserializedJobOutputAsset.endTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("assetName".equals(fieldName)) {
                    deserializedJobOutputAsset.assetName = reader.getString();
                } else if ("@odata.type".equals(fieldName)) {
                    deserializedJobOutputAsset.odataType = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedJobOutputAsset;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy