// 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.
 */
@Fluent
public final class SubscriptionResourceProperties implements JsonSerializable<SubscriptionResourceProperties> {
    /*
     * The status of the last operation.
     */
    private ResourceProvisioningState provisioningState;

    /*
     * The subscription-scoped setting.
     */
    private String subscriptionSetting;

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

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

    /**
     * Get the subscriptionSetting property: The subscription-scoped setting.
     * 
     * @return the subscriptionSetting value.
     */
    public String subscriptionSetting() {
        return this.subscriptionSetting;
    }

    /**
     * Set the subscriptionSetting property: The subscription-scoped setting.
     * 
     * @param subscriptionSetting the subscriptionSetting value to set.
     * @return the SubscriptionResourceProperties object itself.
     */
    public SubscriptionResourceProperties withSubscriptionSetting(String subscriptionSetting) {
        this.subscriptionSetting = subscriptionSetting;
        return this;
    }

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

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

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

            return deserializedSubscriptionResourceProperties;
        });
    }
}
