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

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

/**
 * Properties of subscription resource 1.
 */
@Fluent
public final class SubscriptionResource1Properties implements JsonSerializable<SubscriptionResource1Properties> {
    /*
     * The status of the last operation.
     */
    private ResourceProvisioningState provisioningState;

    /*
     * The description of the resource.
     */
    private String description;

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

    /**
     * Get the provisioningState property: The status of the last operation.
     * 
     * @return the provisioningState value.
     */
    public ResourceProvisioningState provisioningState() {
        return this.provisioningState;
    }

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

    /**
     * Set the description property: The description of the resource.
     * 
     * @param description the description value to set.
     * @return the SubscriptionResource1Properties object itself.
     */
    public SubscriptionResource1Properties 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 SubscriptionResource1Properties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of SubscriptionResource1Properties 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 SubscriptionResource1Properties.
     */
    public static SubscriptionResource1Properties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            SubscriptionResource1Properties deserializedSubscriptionResource1Properties
                = new SubscriptionResource1Properties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

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

            return deserializedSubscriptionResource1Properties;
        });
    }
}
