// 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.implementation;

import com.azure.core.util.Context;
import com.azure.resourcemanager.security.fluent.models.SecurityContactInner;
import com.azure.resourcemanager.security.models.SecurityContact;
import com.azure.resourcemanager.security.models.SecurityContactPropertiesAlertNotifications;
import com.azure.resourcemanager.security.models.SecurityContactPropertiesNotificationsByRole;

public final class SecurityContactImpl implements SecurityContact, SecurityContact.Definition {
    private SecurityContactInner innerObject;

    private final com.azure.resourcemanager.security.SecurityManager serviceManager;

    SecurityContactImpl(
        SecurityContactInner innerObject, com.azure.resourcemanager.security.SecurityManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
    }

    public String id() {
        return this.innerModel().id();
    }

    public String name() {
        return this.innerModel().name();
    }

    public String type() {
        return this.innerModel().type();
    }

    public String emails() {
        return this.innerModel().emails();
    }

    public String phone() {
        return this.innerModel().phone();
    }

    public SecurityContactPropertiesAlertNotifications alertNotifications() {
        return this.innerModel().alertNotifications();
    }

    public SecurityContactPropertiesNotificationsByRole notificationsByRole() {
        return this.innerModel().notificationsByRole();
    }

    public SecurityContactInner innerModel() {
        return this.innerObject;
    }

    private com.azure.resourcemanager.security.SecurityManager manager() {
        return this.serviceManager;
    }

    private String securityContactName;

    public SecurityContact create() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSecurityContacts()
                .createWithResponse(securityContactName, this.innerModel(), Context.NONE)
                .getValue();
        return this;
    }

    public SecurityContact create(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSecurityContacts()
                .createWithResponse(securityContactName, this.innerModel(), context)
                .getValue();
        return this;
    }

    SecurityContactImpl(String name, com.azure.resourcemanager.security.SecurityManager serviceManager) {
        this.innerObject = new SecurityContactInner();
        this.serviceManager = serviceManager;
        this.securityContactName = name;
    }

    public SecurityContact refresh() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSecurityContacts()
                .getWithResponse(securityContactName, Context.NONE)
                .getValue();
        return this;
    }

    public SecurityContact refresh(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getSecurityContacts()
                .getWithResponse(securityContactName, context)
                .getValue();
        return this;
    }

    public SecurityContactImpl withEmails(String emails) {
        this.innerModel().withEmails(emails);
        return this;
    }

    public SecurityContactImpl withPhone(String phone) {
        this.innerModel().withPhone(phone);
        return this;
    }

    public SecurityContactImpl withAlertNotifications(SecurityContactPropertiesAlertNotifications alertNotifications) {
        this.innerModel().withAlertNotifications(alertNotifications);
        return this;
    }

    public SecurityContactImpl withNotificationsByRole(
        SecurityContactPropertiesNotificationsByRole notificationsByRole) {
        this.innerModel().withNotificationsByRole(notificationsByRole);
        return this;
    }
}
