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

com.azure.resourcemanager.mediaservices.fluent.models.MediaServiceOperationStatusInner 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 media service operation.
 */
@Fluent
public final class MediaServiceOperationStatusInner 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 MediaServiceOperationStatusInner class.
     */
    public MediaServiceOperationStatusInner() {
    }

    /**
     * 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 MediaServiceOperationStatusInner object itself.
     */
    public MediaServiceOperationStatusInner 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 MediaServiceOperationStatusInner object itself.
     */
    public MediaServiceOperationStatusInner 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 MediaServiceOperationStatusInner object itself.
     */
    public MediaServiceOperationStatusInner 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 MediaServiceOperationStatusInner object itself.
     */
    public MediaServiceOperationStatusInner 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 MediaServiceOperationStatusInner object itself.
     */
    public MediaServiceOperationStatusInner 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 MediaServiceOperationStatusInner object itself.
     */
    public MediaServiceOperationStatusInner 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 MediaServiceOperationStatusInner"));
        }
        if (status() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property status in model MediaServiceOperationStatusInner"));
        }
    }

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

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

            return deserializedMediaServiceOperationStatusInner;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy