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

com.azure.resourcemanager.mediaservices.fluent.models.AssetTrackOperationStatusInner 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.management.exception.ManagementError;
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 java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;

/**
 * Status of asset track operation.
 */
@Fluent
public final class AssetTrackOperationStatusInner implements JsonSerializable {
    /*
     * Operation identifier.
     */
    private String name;

    /*
     * Operation resource ID.
     */
    private String id;

    /*
     * Operation start time.
     */
    private OffsetDateTime startTime;

    /*
     * Operation end time.
     */
    private OffsetDateTime endTime;

    /*
     * Operation status.
     */
    private String status;

    /*
     * The error detail.
     */
    private ManagementError error;

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

    /**
     * Get the name property: Operation identifier.
     * 
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: Operation identifier.
     * 
     * @param name the name value to set.
     * @return the AssetTrackOperationStatusInner object itself.
     */
    public AssetTrackOperationStatusInner withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the id property: Operation resource ID.
     * 
     * @return the id value.
     */
    public String id() {
        return this.id;
    }

    /**
     * Set the id property: Operation resource ID.
     * 
     * @param id the id value to set.
     * @return the AssetTrackOperationStatusInner object itself.
     */
    public AssetTrackOperationStatusInner withId(String id) {
        this.id = id;
        return this;
    }

    /**
     * Get the startTime property: Operation start time.
     * 
     * @return the startTime value.
     */
    public OffsetDateTime startTime() {
        return this.startTime;
    }

    /**
     * Set the startTime property: Operation start time.
     * 
     * @param startTime the startTime value to set.
     * @return the AssetTrackOperationStatusInner object itself.
     */
    public AssetTrackOperationStatusInner withStartTime(OffsetDateTime startTime) {
        this.startTime = startTime;
        return this;
    }

    /**
     * Get the endTime property: Operation end time.
     * 
     * @return the endTime value.
     */
    public OffsetDateTime endTime() {
        return this.endTime;
    }

    /**
     * Set the endTime property: Operation end time.
     * 
     * @param endTime the endTime value to set.
     * @return the AssetTrackOperationStatusInner object itself.
     */
    public AssetTrackOperationStatusInner withEndTime(OffsetDateTime endTime) {
        this.endTime = endTime;
        return this;
    }

    /**
     * Get the status property: Operation status.
     * 
     * @return the status value.
     */
    public String status() {
        return this.status;
    }

    /**
     * Set the status property: Operation status.
     * 
     * @param status the status value to set.
     * @return the AssetTrackOperationStatusInner object itself.
     */
    public AssetTrackOperationStatusInner withStatus(String status) {
        this.status = status;
        return this;
    }

    /**
     * Get the error property: The error detail.
     * 
     * @return the error value.
     */
    public ManagementError error() {
        return this.error;
    }

    /**
     * Set the error property: The error detail.
     * 
     * @param error the error value to set.
     * @return the AssetTrackOperationStatusInner object itself.
     */
    public AssetTrackOperationStatusInner withError(ManagementError error) {
        this.error = error;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (name() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property name in model AssetTrackOperationStatusInner"));
        }
        if (status() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property status in model AssetTrackOperationStatusInner"));
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("name", this.name);
        jsonWriter.writeStringField("status", this.status);
        jsonWriter.writeStringField("id", this.id);
        jsonWriter.writeStringField("startTime",
            this.startTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.startTime));
        jsonWriter.writeStringField("endTime",
            this.endTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.endTime));
        jsonWriter.writeJsonField("error", this.error);
        return jsonWriter.writeEndObject();
    }

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

                if ("name".equals(fieldName)) {
                    deserializedAssetTrackOperationStatusInner.name = reader.getString();
                } else if ("status".equals(fieldName)) {
                    deserializedAssetTrackOperationStatusInner.status = reader.getString();
                } else if ("id".equals(fieldName)) {
                    deserializedAssetTrackOperationStatusInner.id = reader.getString();
                } else if ("startTime".equals(fieldName)) {
                    deserializedAssetTrackOperationStatusInner.startTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("endTime".equals(fieldName)) {
                    deserializedAssetTrackOperationStatusInner.endTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("error".equals(fieldName)) {
                    deserializedAssetTrackOperationStatusInner.error = ManagementError.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedAssetTrackOperationStatusInner;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy