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

com.azure.resourcemanager.mediaservices.models.Operation 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.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;

/**
 * An operation.
 */
@Fluent
public final class Operation implements JsonSerializable {
    /*
     * The operation name.
     */
    private String name;

    /*
     * The operation display name.
     */
    private OperationDisplay display;

    /*
     * Origin of the operation.
     */
    private String origin;

    /*
     * Operation properties format.
     */
    private Properties properties;

    /*
     * Whether the operation applies to data-plane.
     */
    private Boolean isDataAction;

    /*
     * Indicates the action type.
     */
    private ActionType actionType;

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

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

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

    /**
     * Get the display property: The operation display name.
     * 
     * @return the display value.
     */
    public OperationDisplay display() {
        return this.display;
    }

    /**
     * Set the display property: The operation display name.
     * 
     * @param display the display value to set.
     * @return the Operation object itself.
     */
    public Operation withDisplay(OperationDisplay display) {
        this.display = display;
        return this;
    }

    /**
     * Get the origin property: Origin of the operation.
     * 
     * @return the origin value.
     */
    public String origin() {
        return this.origin;
    }

    /**
     * Set the origin property: Origin of the operation.
     * 
     * @param origin the origin value to set.
     * @return the Operation object itself.
     */
    public Operation withOrigin(String origin) {
        this.origin = origin;
        return this;
    }

    /**
     * Get the properties property: Operation properties format.
     * 
     * @return the properties value.
     */
    public Properties properties() {
        return this.properties;
    }

    /**
     * Set the properties property: Operation properties format.
     * 
     * @param properties the properties value to set.
     * @return the Operation object itself.
     */
    public Operation withProperties(Properties properties) {
        this.properties = properties;
        return this;
    }

    /**
     * Get the isDataAction property: Whether the operation applies to data-plane.
     * 
     * @return the isDataAction value.
     */
    public Boolean isDataAction() {
        return this.isDataAction;
    }

    /**
     * Set the isDataAction property: Whether the operation applies to data-plane.
     * 
     * @param isDataAction the isDataAction value to set.
     * @return the Operation object itself.
     */
    public Operation withIsDataAction(Boolean isDataAction) {
        this.isDataAction = isDataAction;
        return this;
    }

    /**
     * Get the actionType property: Indicates the action type.
     * 
     * @return the actionType value.
     */
    public ActionType actionType() {
        return this.actionType;
    }

    /**
     * Set the actionType property: Indicates the action type.
     * 
     * @param actionType the actionType value to set.
     * @return the Operation object itself.
     */
    public Operation withActionType(ActionType actionType) {
        this.actionType = actionType;
        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 Operation"));
        }
        if (display() != null) {
            display().validate();
        }
        if (properties() != null) {
            properties().validate();
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("name", this.name);
        jsonWriter.writeJsonField("display", this.display);
        jsonWriter.writeStringField("origin", this.origin);
        jsonWriter.writeJsonField("properties", this.properties);
        jsonWriter.writeBooleanField("isDataAction", this.isDataAction);
        jsonWriter.writeStringField("actionType", this.actionType == null ? null : this.actionType.toString());
        return jsonWriter.writeEndObject();
    }

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

                if ("name".equals(fieldName)) {
                    deserializedOperation.name = reader.getString();
                } else if ("display".equals(fieldName)) {
                    deserializedOperation.display = OperationDisplay.fromJson(reader);
                } else if ("origin".equals(fieldName)) {
                    deserializedOperation.origin = reader.getString();
                } else if ("properties".equals(fieldName)) {
                    deserializedOperation.properties = Properties.fromJson(reader);
                } else if ("isDataAction".equals(fieldName)) {
                    deserializedOperation.isDataAction = reader.getNullable(JsonReader::getBoolean);
                } else if ("actionType".equals(fieldName)) {
                    deserializedOperation.actionType = ActionType.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedOperation;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy