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

com.azure.resourcemanager.devcenter.fluent.models.GalleryProperties 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.devcenter.fluent.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 com.azure.resourcemanager.devcenter.models.ProvisioningState;
import java.io.IOException;

/**
 * Properties of a gallery.
 */
@Fluent
public final class GalleryProperties implements JsonSerializable {
    /*
     * The provisioning state of the resource.
     */
    private ProvisioningState provisioningState;

    /*
     * The resource ID of the backing Azure Compute Gallery.
     */
    private String galleryResourceId;

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

    /**
     * Get the provisioningState property: The provisioning state of the resource.
     * 
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the galleryResourceId property: The resource ID of the backing Azure Compute Gallery.
     * 
     * @return the galleryResourceId value.
     */
    public String galleryResourceId() {
        return this.galleryResourceId;
    }

    /**
     * Set the galleryResourceId property: The resource ID of the backing Azure Compute Gallery.
     * 
     * @param galleryResourceId the galleryResourceId value to set.
     * @return the GalleryProperties object itself.
     */
    public GalleryProperties withGalleryResourceId(String galleryResourceId) {
        this.galleryResourceId = galleryResourceId;
        return this;
    }

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

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

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

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

                if ("galleryResourceId".equals(fieldName)) {
                    deserializedGalleryProperties.galleryResourceId = reader.getString();
                } else if ("provisioningState".equals(fieldName)) {
                    deserializedGalleryProperties.provisioningState = ProvisioningState.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedGalleryProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy