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

com.azure.resourcemanager.monitor.fluent.models.DiagnosticSettings 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.monitor.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.monitor.models.LogSettings;
import com.azure.resourcemanager.monitor.models.MetricSettings;
import java.io.IOException;
import java.util.List;

/**
 * The diagnostic settings.
 */
@Fluent
public final class DiagnosticSettings implements JsonSerializable {
    /*
     * The resource ID of the storage account to which you would like to send Diagnostic Logs.
     */
    private String storageAccountId;

    /*
     * The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility.
     */
    private String serviceBusRuleId;

    /*
     * The resource Id for the event hub authorization rule.
     */
    private String eventHubAuthorizationRuleId;

    /*
     * The name of the event hub. If none is specified, the default event hub will be selected.
     */
    private String eventHubName;

    /*
     * The list of metric settings.
     */
    private List metrics;

    /*
     * The list of logs settings.
     */
    private List logs;

    /*
     * The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example:
     * /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.
     * OperationalInsights/workspaces/viruela2
     */
    private String workspaceId;

    /*
     * The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs.
     */
    private String marketplacePartnerId;

    /*
     * A string indicating whether the export to Log Analytics should use the default destination type, i.e.
     * AzureDiagnostics, or use a destination type constructed as follows: _. Possible values are: Dedicated and null (null is default.)
     */
    private String logAnalyticsDestinationType;

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

    /**
     * Get the storageAccountId property: The resource ID of the storage account to which you would like to send
     * Diagnostic Logs.
     * 
     * @return the storageAccountId value.
     */
    public String storageAccountId() {
        return this.storageAccountId;
    }

    /**
     * Set the storageAccountId property: The resource ID of the storage account to which you would like to send
     * Diagnostic Logs.
     * 
     * @param storageAccountId the storageAccountId value to set.
     * @return the DiagnosticSettings object itself.
     */
    public DiagnosticSettings withStorageAccountId(String storageAccountId) {
        this.storageAccountId = storageAccountId;
        return this;
    }

    /**
     * Get the serviceBusRuleId property: The service bus rule Id of the diagnostic setting. This is here to maintain
     * backwards compatibility.
     * 
     * @return the serviceBusRuleId value.
     */
    public String serviceBusRuleId() {
        return this.serviceBusRuleId;
    }

    /**
     * Set the serviceBusRuleId property: The service bus rule Id of the diagnostic setting. This is here to maintain
     * backwards compatibility.
     * 
     * @param serviceBusRuleId the serviceBusRuleId value to set.
     * @return the DiagnosticSettings object itself.
     */
    public DiagnosticSettings withServiceBusRuleId(String serviceBusRuleId) {
        this.serviceBusRuleId = serviceBusRuleId;
        return this;
    }

    /**
     * Get the eventHubAuthorizationRuleId property: The resource Id for the event hub authorization rule.
     * 
     * @return the eventHubAuthorizationRuleId value.
     */
    public String eventHubAuthorizationRuleId() {
        return this.eventHubAuthorizationRuleId;
    }

    /**
     * Set the eventHubAuthorizationRuleId property: The resource Id for the event hub authorization rule.
     * 
     * @param eventHubAuthorizationRuleId the eventHubAuthorizationRuleId value to set.
     * @return the DiagnosticSettings object itself.
     */
    public DiagnosticSettings withEventHubAuthorizationRuleId(String eventHubAuthorizationRuleId) {
        this.eventHubAuthorizationRuleId = eventHubAuthorizationRuleId;
        return this;
    }

    /**
     * Get the eventHubName property: The name of the event hub. If none is specified, the default event hub will be
     * selected.
     * 
     * @return the eventHubName value.
     */
    public String eventHubName() {
        return this.eventHubName;
    }

    /**
     * Set the eventHubName property: The name of the event hub. If none is specified, the default event hub will be
     * selected.
     * 
     * @param eventHubName the eventHubName value to set.
     * @return the DiagnosticSettings object itself.
     */
    public DiagnosticSettings withEventHubName(String eventHubName) {
        this.eventHubName = eventHubName;
        return this;
    }

    /**
     * Get the metrics property: The list of metric settings.
     * 
     * @return the metrics value.
     */
    public List metrics() {
        return this.metrics;
    }

    /**
     * Set the metrics property: The list of metric settings.
     * 
     * @param metrics the metrics value to set.
     * @return the DiagnosticSettings object itself.
     */
    public DiagnosticSettings withMetrics(List metrics) {
        this.metrics = metrics;
        return this;
    }

    /**
     * Get the logs property: The list of logs settings.
     * 
     * @return the logs value.
     */
    public List logs() {
        return this.logs;
    }

    /**
     * Set the logs property: The list of logs settings.
     * 
     * @param logs the logs value to set.
     * @return the DiagnosticSettings object itself.
     */
    public DiagnosticSettings withLogs(List logs) {
        this.logs = logs;
        return this;
    }

    /**
     * Get the workspaceId property: The full ARM resource ID of the Log Analytics workspace to which you would like to
     * send Diagnostic Logs. Example:
     * /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2.
     * 
     * @return the workspaceId value.
     */
    public String workspaceId() {
        return this.workspaceId;
    }

    /**
     * Set the workspaceId property: The full ARM resource ID of the Log Analytics workspace to which you would like to
     * send Diagnostic Logs. Example:
     * /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2.
     * 
     * @param workspaceId the workspaceId value to set.
     * @return the DiagnosticSettings object itself.
     */
    public DiagnosticSettings withWorkspaceId(String workspaceId) {
        this.workspaceId = workspaceId;
        return this;
    }

    /**
     * Get the marketplacePartnerId property: The full ARM resource ID of the Marketplace resource to which you would
     * like to send Diagnostic Logs.
     * 
     * @return the marketplacePartnerId value.
     */
    public String marketplacePartnerId() {
        return this.marketplacePartnerId;
    }

    /**
     * Set the marketplacePartnerId property: The full ARM resource ID of the Marketplace resource to which you would
     * like to send Diagnostic Logs.
     * 
     * @param marketplacePartnerId the marketplacePartnerId value to set.
     * @return the DiagnosticSettings object itself.
     */
    public DiagnosticSettings withMarketplacePartnerId(String marketplacePartnerId) {
        this.marketplacePartnerId = marketplacePartnerId;
        return this;
    }

    /**
     * Get the logAnalyticsDestinationType property: A string indicating whether the export to Log Analytics should use
     * the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows:
     * <normalized service identity>_<normalized category name>. Possible values are: Dedicated and null
     * (null is default.).
     * 
     * @return the logAnalyticsDestinationType value.
     */
    public String logAnalyticsDestinationType() {
        return this.logAnalyticsDestinationType;
    }

    /**
     * Set the logAnalyticsDestinationType property: A string indicating whether the export to Log Analytics should use
     * the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows:
     * <normalized service identity>_<normalized category name>. Possible values are: Dedicated and null
     * (null is default.).
     * 
     * @param logAnalyticsDestinationType the logAnalyticsDestinationType value to set.
     * @return the DiagnosticSettings object itself.
     */
    public DiagnosticSettings withLogAnalyticsDestinationType(String logAnalyticsDestinationType) {
        this.logAnalyticsDestinationType = logAnalyticsDestinationType;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (metrics() != null) {
            metrics().forEach(e -> e.validate());
        }
        if (logs() != null) {
            logs().forEach(e -> e.validate());
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("storageAccountId", this.storageAccountId);
        jsonWriter.writeStringField("serviceBusRuleId", this.serviceBusRuleId);
        jsonWriter.writeStringField("eventHubAuthorizationRuleId", this.eventHubAuthorizationRuleId);
        jsonWriter.writeStringField("eventHubName", this.eventHubName);
        jsonWriter.writeArrayField("metrics", this.metrics, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("logs", this.logs, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeStringField("workspaceId", this.workspaceId);
        jsonWriter.writeStringField("marketplacePartnerId", this.marketplacePartnerId);
        jsonWriter.writeStringField("logAnalyticsDestinationType", this.logAnalyticsDestinationType);
        return jsonWriter.writeEndObject();
    }

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

                if ("storageAccountId".equals(fieldName)) {
                    deserializedDiagnosticSettings.storageAccountId = reader.getString();
                } else if ("serviceBusRuleId".equals(fieldName)) {
                    deserializedDiagnosticSettings.serviceBusRuleId = reader.getString();
                } else if ("eventHubAuthorizationRuleId".equals(fieldName)) {
                    deserializedDiagnosticSettings.eventHubAuthorizationRuleId = reader.getString();
                } else if ("eventHubName".equals(fieldName)) {
                    deserializedDiagnosticSettings.eventHubName = reader.getString();
                } else if ("metrics".equals(fieldName)) {
                    List metrics = reader.readArray(reader1 -> MetricSettings.fromJson(reader1));
                    deserializedDiagnosticSettings.metrics = metrics;
                } else if ("logs".equals(fieldName)) {
                    List logs = reader.readArray(reader1 -> LogSettings.fromJson(reader1));
                    deserializedDiagnosticSettings.logs = logs;
                } else if ("workspaceId".equals(fieldName)) {
                    deserializedDiagnosticSettings.workspaceId = reader.getString();
                } else if ("marketplacePartnerId".equals(fieldName)) {
                    deserializedDiagnosticSettings.marketplacePartnerId = reader.getString();
                } else if ("logAnalyticsDestinationType".equals(fieldName)) {
                    deserializedDiagnosticSettings.logAnalyticsDestinationType = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedDiagnosticSettings;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy