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

com.azure.resourcemanager.storagepool.models.StoragePoolOperationDisplay Maven / Gradle / Ivy

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

package com.azure.resourcemanager.storagepool.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;

/**
 * Metadata about an operation.
 */
@Fluent
public final class StoragePoolOperationDisplay implements JsonSerializable {
    /*
     * Localized friendly form of the resource provider name.
     */
    private String provider;

    /*
     * Localized friendly form of the resource type related to this action/operation.
     */
    private String resource;

    /*
     * Localized friendly name for the operation, as it should be shown to the user.
     */
    private String operation;

    /*
     * Localized friendly description for the operation, as it should be shown to the user.
     */
    private String description;

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

    /**
     * Get the provider property: Localized friendly form of the resource provider name.
     * 
     * @return the provider value.
     */
    public String provider() {
        return this.provider;
    }

    /**
     * Set the provider property: Localized friendly form of the resource provider name.
     * 
     * @param provider the provider value to set.
     * @return the StoragePoolOperationDisplay object itself.
     */
    public StoragePoolOperationDisplay withProvider(String provider) {
        this.provider = provider;
        return this;
    }

    /**
     * Get the resource property: Localized friendly form of the resource type related to this action/operation.
     * 
     * @return the resource value.
     */
    public String resource() {
        return this.resource;
    }

    /**
     * Set the resource property: Localized friendly form of the resource type related to this action/operation.
     * 
     * @param resource the resource value to set.
     * @return the StoragePoolOperationDisplay object itself.
     */
    public StoragePoolOperationDisplay withResource(String resource) {
        this.resource = resource;
        return this;
    }

    /**
     * Get the operation property: Localized friendly name for the operation, as it should be shown to the user.
     * 
     * @return the operation value.
     */
    public String operation() {
        return this.operation;
    }

    /**
     * Set the operation property: Localized friendly name for the operation, as it should be shown to the user.
     * 
     * @param operation the operation value to set.
     * @return the StoragePoolOperationDisplay object itself.
     */
    public StoragePoolOperationDisplay withOperation(String operation) {
        this.operation = operation;
        return this;
    }

    /**
     * Get the description property: Localized friendly description for the operation, as it should be shown to the
     * user.
     * 
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: Localized friendly description for the operation, as it should be shown to the
     * user.
     * 
     * @param description the description value to set.
     * @return the StoragePoolOperationDisplay object itself.
     */
    public StoragePoolOperationDisplay withDescription(String description) {
        this.description = description;
        return this;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("provider", this.provider);
        jsonWriter.writeStringField("resource", this.resource);
        jsonWriter.writeStringField("operation", this.operation);
        jsonWriter.writeStringField("description", this.description);
        return jsonWriter.writeEndObject();
    }

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

                if ("provider".equals(fieldName)) {
                    deserializedStoragePoolOperationDisplay.provider = reader.getString();
                } else if ("resource".equals(fieldName)) {
                    deserializedStoragePoolOperationDisplay.resource = reader.getString();
                } else if ("operation".equals(fieldName)) {
                    deserializedStoragePoolOperationDisplay.operation = reader.getString();
                } else if ("description".equals(fieldName)) {
                    deserializedStoragePoolOperationDisplay.description = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedStoragePoolOperationDisplay;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy