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

com.azure.resourcemanager.newrelicobservability.fluent.models.MonitoredSubscriptionInner 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.newrelicobservability.fluent.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 com.azure.resourcemanager.newrelicobservability.models.Status;
import java.io.IOException;

/**
 * The list of subscriptions and it's monitoring status by current NewRelic monitor.
 */
@Fluent
public final class MonitoredSubscriptionInner implements JsonSerializable {
    /*
     * The subscriptionId to be monitored.
     */
    private String subscriptionId;

    /*
     * The state of monitoring.
     */
    private Status status;

    /*
     * The reason of not monitoring the subscription.
     */
    private String error;

    /*
     * The resource-specific properties for this resource.
     */
    private MonitoringTagRulesPropertiesInner tagRules;

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

    /**
     * Get the subscriptionId property: The subscriptionId to be monitored.
     * 
     * @return the subscriptionId value.
     */
    public String subscriptionId() {
        return this.subscriptionId;
    }

    /**
     * Set the subscriptionId property: The subscriptionId to be monitored.
     * 
     * @param subscriptionId the subscriptionId value to set.
     * @return the MonitoredSubscriptionInner object itself.
     */
    public MonitoredSubscriptionInner withSubscriptionId(String subscriptionId) {
        this.subscriptionId = subscriptionId;
        return this;
    }

    /**
     * Get the status property: The state of monitoring.
     * 
     * @return the status value.
     */
    public Status status() {
        return this.status;
    }

    /**
     * Set the status property: The state of monitoring.
     * 
     * @param status the status value to set.
     * @return the MonitoredSubscriptionInner object itself.
     */
    public MonitoredSubscriptionInner withStatus(Status status) {
        this.status = status;
        return this;
    }

    /**
     * Get the error property: The reason of not monitoring the subscription.
     * 
     * @return the error value.
     */
    public String error() {
        return this.error;
    }

    /**
     * Set the error property: The reason of not monitoring the subscription.
     * 
     * @param error the error value to set.
     * @return the MonitoredSubscriptionInner object itself.
     */
    public MonitoredSubscriptionInner withError(String error) {
        this.error = error;
        return this;
    }

    /**
     * Get the tagRules property: The resource-specific properties for this resource.
     * 
     * @return the tagRules value.
     */
    public MonitoringTagRulesPropertiesInner tagRules() {
        return this.tagRules;
    }

    /**
     * Set the tagRules property: The resource-specific properties for this resource.
     * 
     * @param tagRules the tagRules value to set.
     * @return the MonitoredSubscriptionInner object itself.
     */
    public MonitoredSubscriptionInner withTagRules(MonitoringTagRulesPropertiesInner tagRules) {
        this.tagRules = tagRules;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (tagRules() != null) {
            tagRules().validate();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("subscriptionId", this.subscriptionId);
        jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString());
        jsonWriter.writeStringField("error", this.error);
        jsonWriter.writeJsonField("tagRules", this.tagRules);
        return jsonWriter.writeEndObject();
    }

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

                if ("subscriptionId".equals(fieldName)) {
                    deserializedMonitoredSubscriptionInner.subscriptionId = reader.getString();
                } else if ("status".equals(fieldName)) {
                    deserializedMonitoredSubscriptionInner.status = Status.fromString(reader.getString());
                } else if ("error".equals(fieldName)) {
                    deserializedMonitoredSubscriptionInner.error = reader.getString();
                } else if ("tagRules".equals(fieldName)) {
                    deserializedMonitoredSubscriptionInner.tagRules
                        = MonitoringTagRulesPropertiesInner.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedMonitoredSubscriptionInner;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy