// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.mysqlflexibleserver.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.Resource;
import com.azure.core.management.SystemData;
import com.azure.resourcemanager.mysqlflexibleserver.models.Backup;
import com.azure.resourcemanager.mysqlflexibleserver.models.CreateMode;
import com.azure.resourcemanager.mysqlflexibleserver.models.DataEncryption;
import com.azure.resourcemanager.mysqlflexibleserver.models.HighAvailability;
import com.azure.resourcemanager.mysqlflexibleserver.models.Identity;
import com.azure.resourcemanager.mysqlflexibleserver.models.MaintenanceWindow;
import com.azure.resourcemanager.mysqlflexibleserver.models.Network;
import com.azure.resourcemanager.mysqlflexibleserver.models.ReplicationRole;
import com.azure.resourcemanager.mysqlflexibleserver.models.ServerState;
import com.azure.resourcemanager.mysqlflexibleserver.models.ServerVersion;
import com.azure.resourcemanager.mysqlflexibleserver.models.Sku;
import com.azure.resourcemanager.mysqlflexibleserver.models.Storage;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;
import java.util.Map;

/** Represents a server. */
@Fluent
public final class ServerInner extends Resource {
    /*
     * The cmk identity for the server.
     */
    @JsonProperty(value = "identity")
    private Identity identity;

    /*
     * The SKU (pricing tier) of the server.
     */
    @JsonProperty(value = "sku")
    private Sku sku;

    /*
     * Properties of the server.
     */
    @JsonProperty(value = "properties")
    private ServerProperties innerProperties;

    /*
     * The system metadata relating to this resource.
     */
    @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY)
    private SystemData systemData;

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

    /**
     * Get the identity property: The cmk identity for the server.
     *
     * @return the identity value.
     */
    public Identity identity() {
        return this.identity;
    }

    /**
     * Set the identity property: The cmk identity for the server.
     *
     * @param identity the identity value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withIdentity(Identity identity) {
        this.identity = identity;
        return this;
    }

    /**
     * Get the sku property: The SKU (pricing tier) of the server.
     *
     * @return the sku value.
     */
    public Sku sku() {
        return this.sku;
    }

    /**
     * Set the sku property: The SKU (pricing tier) of the server.
     *
     * @param sku the sku value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withSku(Sku sku) {
        this.sku = sku;
        return this;
    }

    /**
     * Get the innerProperties property: Properties of the server.
     *
     * @return the innerProperties value.
     */
    private ServerProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the systemData property: The system metadata relating to this resource.
     *
     * @return the systemData value.
     */
    public SystemData systemData() {
        return this.systemData;
    }

    /** {@inheritDoc} */
    @Override
    public ServerInner withLocation(String location) {
        super.withLocation(location);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public ServerInner withTags(Map<String, String> tags) {
        super.withTags(tags);
        return this;
    }

    /**
     * Get the administratorLogin property: The administrator's login name of a server. Can only be specified when the
     * server is being created (and is required for creation).
     *
     * @return the administratorLogin value.
     */
    public String administratorLogin() {
        return this.innerProperties() == null ? null : this.innerProperties().administratorLogin();
    }

    /**
     * Set the administratorLogin property: The administrator's login name of a server. Can only be specified when the
     * server is being created (and is required for creation).
     *
     * @param administratorLogin the administratorLogin value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withAdministratorLogin(String administratorLogin) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withAdministratorLogin(administratorLogin);
        return this;
    }

    /**
     * Get the administratorLoginPassword property: The password of the administrator login (required for server
     * creation).
     *
     * @return the administratorLoginPassword value.
     */
    public String administratorLoginPassword() {
        return this.innerProperties() == null ? null : this.innerProperties().administratorLoginPassword();
    }

    /**
     * Set the administratorLoginPassword property: The password of the administrator login (required for server
     * creation).
     *
     * @param administratorLoginPassword the administratorLoginPassword value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withAdministratorLoginPassword(String administratorLoginPassword) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withAdministratorLoginPassword(administratorLoginPassword);
        return this;
    }

    /**
     * Get the version property: Server version.
     *
     * @return the version value.
     */
    public ServerVersion version() {
        return this.innerProperties() == null ? null : this.innerProperties().version();
    }

    /**
     * Set the version property: Server version.
     *
     * @param version the version value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withVersion(ServerVersion version) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withVersion(version);
        return this;
    }

    /**
     * Get the availabilityZone property: availability Zone information of the server.
     *
     * @return the availabilityZone value.
     */
    public String availabilityZone() {
        return this.innerProperties() == null ? null : this.innerProperties().availabilityZone();
    }

    /**
     * Set the availabilityZone property: availability Zone information of the server.
     *
     * @param availabilityZone the availabilityZone value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withAvailabilityZone(String availabilityZone) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withAvailabilityZone(availabilityZone);
        return this;
    }

    /**
     * Get the createMode property: The mode to create a new MySQL server.
     *
     * @return the createMode value.
     */
    public CreateMode createMode() {
        return this.innerProperties() == null ? null : this.innerProperties().createMode();
    }

    /**
     * Set the createMode property: The mode to create a new MySQL server.
     *
     * @param createMode the createMode value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withCreateMode(CreateMode createMode) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withCreateMode(createMode);
        return this;
    }

    /**
     * Get the sourceServerResourceId property: The source MySQL server id.
     *
     * @return the sourceServerResourceId value.
     */
    public String sourceServerResourceId() {
        return this.innerProperties() == null ? null : this.innerProperties().sourceServerResourceId();
    }

    /**
     * Set the sourceServerResourceId property: The source MySQL server id.
     *
     * @param sourceServerResourceId the sourceServerResourceId value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withSourceServerResourceId(String sourceServerResourceId) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withSourceServerResourceId(sourceServerResourceId);
        return this;
    }

    /**
     * Get the restorePointInTime property: Restore point creation time (ISO8601 format), specifying the time to restore
     * from.
     *
     * @return the restorePointInTime value.
     */
    public OffsetDateTime restorePointInTime() {
        return this.innerProperties() == null ? null : this.innerProperties().restorePointInTime();
    }

    /**
     * Set the restorePointInTime property: Restore point creation time (ISO8601 format), specifying the time to restore
     * from.
     *
     * @param restorePointInTime the restorePointInTime value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withRestorePointInTime(OffsetDateTime restorePointInTime) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withRestorePointInTime(restorePointInTime);
        return this;
    }

    /**
     * Get the replicationRole property: The replication role.
     *
     * @return the replicationRole value.
     */
    public ReplicationRole replicationRole() {
        return this.innerProperties() == null ? null : this.innerProperties().replicationRole();
    }

    /**
     * Set the replicationRole property: The replication role.
     *
     * @param replicationRole the replicationRole value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withReplicationRole(ReplicationRole replicationRole) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withReplicationRole(replicationRole);
        return this;
    }

    /**
     * Get the replicaCapacity property: The maximum number of replicas that a primary server can have.
     *
     * @return the replicaCapacity value.
     */
    public Integer replicaCapacity() {
        return this.innerProperties() == null ? null : this.innerProperties().replicaCapacity();
    }

    /**
     * Get the dataEncryption property: The Data Encryption for CMK.
     *
     * @return the dataEncryption value.
     */
    public DataEncryption dataEncryption() {
        return this.innerProperties() == null ? null : this.innerProperties().dataEncryption();
    }

    /**
     * Set the dataEncryption property: The Data Encryption for CMK.
     *
     * @param dataEncryption the dataEncryption value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withDataEncryption(DataEncryption dataEncryption) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withDataEncryption(dataEncryption);
        return this;
    }

    /**
     * Get the state property: The state of a server.
     *
     * @return the state value.
     */
    public ServerState state() {
        return this.innerProperties() == null ? null : this.innerProperties().state();
    }

    /**
     * Get the fullyQualifiedDomainName property: The fully qualified domain name of a server.
     *
     * @return the fullyQualifiedDomainName value.
     */
    public String fullyQualifiedDomainName() {
        return this.innerProperties() == null ? null : this.innerProperties().fullyQualifiedDomainName();
    }

    /**
     * Get the storage property: Storage related properties of a server.
     *
     * @return the storage value.
     */
    public Storage storage() {
        return this.innerProperties() == null ? null : this.innerProperties().storage();
    }

    /**
     * Set the storage property: Storage related properties of a server.
     *
     * @param storage the storage value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withStorage(Storage storage) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withStorage(storage);
        return this;
    }

    /**
     * Get the backup property: Backup related properties of a server.
     *
     * @return the backup value.
     */
    public Backup backup() {
        return this.innerProperties() == null ? null : this.innerProperties().backup();
    }

    /**
     * Set the backup property: Backup related properties of a server.
     *
     * @param backup the backup value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withBackup(Backup backup) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withBackup(backup);
        return this;
    }

    /**
     * Get the highAvailability property: High availability related properties of a server.
     *
     * @return the highAvailability value.
     */
    public HighAvailability highAvailability() {
        return this.innerProperties() == null ? null : this.innerProperties().highAvailability();
    }

    /**
     * Set the highAvailability property: High availability related properties of a server.
     *
     * @param highAvailability the highAvailability value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withHighAvailability(HighAvailability highAvailability) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withHighAvailability(highAvailability);
        return this;
    }

    /**
     * Get the network property: Network related properties of a server.
     *
     * @return the network value.
     */
    public Network network() {
        return this.innerProperties() == null ? null : this.innerProperties().network();
    }

    /**
     * Set the network property: Network related properties of a server.
     *
     * @param network the network value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withNetwork(Network network) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withNetwork(network);
        return this;
    }

    /**
     * Get the maintenanceWindow property: Maintenance window of a server.
     *
     * @return the maintenanceWindow value.
     */
    public MaintenanceWindow maintenanceWindow() {
        return this.innerProperties() == null ? null : this.innerProperties().maintenanceWindow();
    }

    /**
     * Set the maintenanceWindow property: Maintenance window of a server.
     *
     * @param maintenanceWindow the maintenanceWindow value to set.
     * @return the ServerInner object itself.
     */
    public ServerInner withMaintenanceWindow(MaintenanceWindow maintenanceWindow) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ServerProperties();
        }
        this.innerProperties().withMaintenanceWindow(maintenanceWindow);
        return this;
    }

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