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

com.azure.resourcemanager.security.fluent.models.SecurityContactProperties 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.security.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.security.models.NotificationsSource;
import com.azure.resourcemanager.security.models.SecurityContactPropertiesNotificationsByRole;
import java.io.IOException;
import java.util.List;

/**
 * Describes security contact properties.
 */
@Fluent
public final class SecurityContactProperties implements JsonSerializable {
    /*
     * List of email addresses which will get notifications from Microsoft Defender for Cloud by the configurations
     * defined in this security contact.
     */
    private String emails;

    /*
     * The security contact's phone number
     */
    private String phone;

    /*
     * Indicates whether the security contact is enabled.
     */
    private Boolean isEnabled;

    /*
     * A collection of sources types which evaluate the email notification.
     */
    private List notificationsSources;

    /*
     * Defines whether to send email notifications from Microsoft Defender for Cloud to persons with specific RBAC roles
     * on the subscription.
     */
    private SecurityContactPropertiesNotificationsByRole notificationsByRole;

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

    /**
     * Get the emails property: List of email addresses which will get notifications from Microsoft Defender for Cloud
     * by the configurations defined in this security contact.
     * 
     * @return the emails value.
     */
    public String emails() {
        return this.emails;
    }

    /**
     * Set the emails property: List of email addresses which will get notifications from Microsoft Defender for Cloud
     * by the configurations defined in this security contact.
     * 
     * @param emails the emails value to set.
     * @return the SecurityContactProperties object itself.
     */
    public SecurityContactProperties withEmails(String emails) {
        this.emails = emails;
        return this;
    }

    /**
     * Get the phone property: The security contact's phone number.
     * 
     * @return the phone value.
     */
    public String phone() {
        return this.phone;
    }

    /**
     * Set the phone property: The security contact's phone number.
     * 
     * @param phone the phone value to set.
     * @return the SecurityContactProperties object itself.
     */
    public SecurityContactProperties withPhone(String phone) {
        this.phone = phone;
        return this;
    }

    /**
     * Get the isEnabled property: Indicates whether the security contact is enabled.
     * 
     * @return the isEnabled value.
     */
    public Boolean isEnabled() {
        return this.isEnabled;
    }

    /**
     * Set the isEnabled property: Indicates whether the security contact is enabled.
     * 
     * @param isEnabled the isEnabled value to set.
     * @return the SecurityContactProperties object itself.
     */
    public SecurityContactProperties withIsEnabled(Boolean isEnabled) {
        this.isEnabled = isEnabled;
        return this;
    }

    /**
     * Get the notificationsSources property: A collection of sources types which evaluate the email notification.
     * 
     * @return the notificationsSources value.
     */
    public List notificationsSources() {
        return this.notificationsSources;
    }

    /**
     * Set the notificationsSources property: A collection of sources types which evaluate the email notification.
     * 
     * @param notificationsSources the notificationsSources value to set.
     * @return the SecurityContactProperties object itself.
     */
    public SecurityContactProperties withNotificationsSources(List notificationsSources) {
        this.notificationsSources = notificationsSources;
        return this;
    }

    /**
     * Get the notificationsByRole property: Defines whether to send email notifications from Microsoft Defender for
     * Cloud to persons with specific RBAC roles on the subscription.
     * 
     * @return the notificationsByRole value.
     */
    public SecurityContactPropertiesNotificationsByRole notificationsByRole() {
        return this.notificationsByRole;
    }

    /**
     * Set the notificationsByRole property: Defines whether to send email notifications from Microsoft Defender for
     * Cloud to persons with specific RBAC roles on the subscription.
     * 
     * @param notificationsByRole the notificationsByRole value to set.
     * @return the SecurityContactProperties object itself.
     */
    public SecurityContactProperties
        withNotificationsByRole(SecurityContactPropertiesNotificationsByRole notificationsByRole) {
        this.notificationsByRole = notificationsByRole;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("emails", this.emails);
        jsonWriter.writeStringField("phone", this.phone);
        jsonWriter.writeBooleanField("isEnabled", this.isEnabled);
        jsonWriter.writeArrayField("notificationsSources", this.notificationsSources,
            (writer, element) -> writer.writeJson(element));
        jsonWriter.writeJsonField("notificationsByRole", this.notificationsByRole);
        return jsonWriter.writeEndObject();
    }

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

                if ("emails".equals(fieldName)) {
                    deserializedSecurityContactProperties.emails = reader.getString();
                } else if ("phone".equals(fieldName)) {
                    deserializedSecurityContactProperties.phone = reader.getString();
                } else if ("isEnabled".equals(fieldName)) {
                    deserializedSecurityContactProperties.isEnabled = reader.getNullable(JsonReader::getBoolean);
                } else if ("notificationsSources".equals(fieldName)) {
                    List notificationsSources
                        = reader.readArray(reader1 -> NotificationsSource.fromJson(reader1));
                    deserializedSecurityContactProperties.notificationsSources = notificationsSources;
                } else if ("notificationsByRole".equals(fieldName)) {
                    deserializedSecurityContactProperties.notificationsByRole
                        = SecurityContactPropertiesNotificationsByRole.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedSecurityContactProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy