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

package azure.resourcemanager.resources.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
 * Nested Proxy Resource Properties.
 */
@Fluent
public final class NestedProxyResourceProperties implements JsonSerializable<NestedProxyResourceProperties> {
    /*
     * Provisioning State of the nested child Resource
     */
    private ProvisioningState provisioningState;

    /*
     * Nested resource description.
     */
    private String description;

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

    /**
     * Get the provisioningState property: Provisioning State of the nested child Resource.
     * 
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the description property: Nested resource description.
     * 
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: Nested resource description.
     * 
     * @param description the description value to set.
     * @return the NestedProxyResourceProperties object itself.
     */
    public NestedProxyResourceProperties withDescription(String description) {
        this.description = description;
        return this;
    }

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

    /**
     * Reads an instance of NestedProxyResourceProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of NestedProxyResourceProperties if the JsonReader was pointing to an instance of it, or null
     * if it was pointing to JSON null.
     * @throws IOException If an error occurs while reading the NestedProxyResourceProperties.
     */
    public static NestedProxyResourceProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            NestedProxyResourceProperties deserializedNestedProxyResourceProperties
                = new NestedProxyResourceProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

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

            return deserializedNestedProxyResourceProperties;
        });
    }
}
