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

package com.azure.resourcemanager.dataprotection.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Backup Instance. */
@Fluent
public class BackupInstance {
    /*
     * Gets or sets the Backup Instance friendly name.
     */
    @JsonProperty(value = "friendlyName")
    private String friendlyName;

    /*
     * Datasource
     *
     * Gets or sets the data source information.
     */
    @JsonProperty(value = "dataSourceInfo", required = true)
    private Datasource dataSourceInfo;

    /*
     * DatasourceSet
     *
     * Gets or sets the data source set information.
     */
    @JsonProperty(value = "dataSourceSetInfo")
    private DatasourceSet dataSourceSetInfo;

    /*
     * PolicyInfo
     *
     * Gets or sets the policy information.
     */
    @JsonProperty(value = "policyInfo", required = true)
    private PolicyInfo policyInfo;

    /*
     * ProtectionStatusDetails
     *
     * Specifies the protection status of the resource
     */
    @JsonProperty(value = "protectionStatus", access = JsonProperty.Access.WRITE_ONLY)
    private ProtectionStatusDetails protectionStatus;

    /*
     * Specifies the current protection state of the resource
     */
    @JsonProperty(value = "currentProtectionState", access = JsonProperty.Access.WRITE_ONLY)
    private CurrentProtectionState currentProtectionState;

    /*
     * Specifies the protection error of the resource
     */
    @JsonProperty(value = "protectionErrorDetails", access = JsonProperty.Access.WRITE_ONLY)
    private UserFacingError protectionErrorDetails;

    /*
     * Specifies the provisioning state of the resource i.e. provisioning/updating/Succeeded/Failed
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private String provisioningState;

    /*
     * Credentials to use to authenticate with data source provider.
     */
    @JsonProperty(value = "datasourceAuthCredentials")
    private AuthCredentials datasourceAuthCredentials;

    /*
     * Specifies the type of validation. In case of DeepValidation, all validations from /validateForBackup API will
     * run again.
     */
    @JsonProperty(value = "validationType")
    private ValidationType validationType;

    /*
     * The objectType property.
     */
    @JsonProperty(value = "objectType", required = true)
    private String objectType;

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

    /**
     * Get the friendlyName property: Gets or sets the Backup Instance friendly name.
     *
     * @return the friendlyName value.
     */
    public String friendlyName() {
        return this.friendlyName;
    }

    /**
     * Set the friendlyName property: Gets or sets the Backup Instance friendly name.
     *
     * @param friendlyName the friendlyName value to set.
     * @return the BackupInstance object itself.
     */
    public BackupInstance withFriendlyName(String friendlyName) {
        this.friendlyName = friendlyName;
        return this;
    }

    /**
     * Get the dataSourceInfo property: Datasource
     *
     * <p>Gets or sets the data source information.
     *
     * @return the dataSourceInfo value.
     */
    public Datasource dataSourceInfo() {
        return this.dataSourceInfo;
    }

    /**
     * Set the dataSourceInfo property: Datasource
     *
     * <p>Gets or sets the data source information.
     *
     * @param dataSourceInfo the dataSourceInfo value to set.
     * @return the BackupInstance object itself.
     */
    public BackupInstance withDataSourceInfo(Datasource dataSourceInfo) {
        this.dataSourceInfo = dataSourceInfo;
        return this;
    }

    /**
     * Get the dataSourceSetInfo property: DatasourceSet
     *
     * <p>Gets or sets the data source set information.
     *
     * @return the dataSourceSetInfo value.
     */
    public DatasourceSet dataSourceSetInfo() {
        return this.dataSourceSetInfo;
    }

    /**
     * Set the dataSourceSetInfo property: DatasourceSet
     *
     * <p>Gets or sets the data source set information.
     *
     * @param dataSourceSetInfo the dataSourceSetInfo value to set.
     * @return the BackupInstance object itself.
     */
    public BackupInstance withDataSourceSetInfo(DatasourceSet dataSourceSetInfo) {
        this.dataSourceSetInfo = dataSourceSetInfo;
        return this;
    }

    /**
     * Get the policyInfo property: PolicyInfo
     *
     * <p>Gets or sets the policy information.
     *
     * @return the policyInfo value.
     */
    public PolicyInfo policyInfo() {
        return this.policyInfo;
    }

    /**
     * Set the policyInfo property: PolicyInfo
     *
     * <p>Gets or sets the policy information.
     *
     * @param policyInfo the policyInfo value to set.
     * @return the BackupInstance object itself.
     */
    public BackupInstance withPolicyInfo(PolicyInfo policyInfo) {
        this.policyInfo = policyInfo;
        return this;
    }

    /**
     * Get the protectionStatus property: ProtectionStatusDetails
     *
     * <p>Specifies the protection status of the resource.
     *
     * @return the protectionStatus value.
     */
    public ProtectionStatusDetails protectionStatus() {
        return this.protectionStatus;
    }

    /**
     * Get the currentProtectionState property: Specifies the current protection state of the resource.
     *
     * @return the currentProtectionState value.
     */
    public CurrentProtectionState currentProtectionState() {
        return this.currentProtectionState;
    }

    /**
     * Get the protectionErrorDetails property: Specifies the protection error of the resource.
     *
     * @return the protectionErrorDetails value.
     */
    public UserFacingError protectionErrorDetails() {
        return this.protectionErrorDetails;
    }

    /**
     * Get the provisioningState property: Specifies the provisioning state of the resource i.e.
     * provisioning/updating/Succeeded/Failed.
     *
     * @return the provisioningState value.
     */
    public String provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the datasourceAuthCredentials property: Credentials to use to authenticate with data source provider.
     *
     * @return the datasourceAuthCredentials value.
     */
    public AuthCredentials datasourceAuthCredentials() {
        return this.datasourceAuthCredentials;
    }

    /**
     * Set the datasourceAuthCredentials property: Credentials to use to authenticate with data source provider.
     *
     * @param datasourceAuthCredentials the datasourceAuthCredentials value to set.
     * @return the BackupInstance object itself.
     */
    public BackupInstance withDatasourceAuthCredentials(AuthCredentials datasourceAuthCredentials) {
        this.datasourceAuthCredentials = datasourceAuthCredentials;
        return this;
    }

    /**
     * Get the validationType property: Specifies the type of validation. In case of DeepValidation, all validations
     * from /validateForBackup API will run again.
     *
     * @return the validationType value.
     */
    public ValidationType validationType() {
        return this.validationType;
    }

    /**
     * Set the validationType property: Specifies the type of validation. In case of DeepValidation, all validations
     * from /validateForBackup API will run again.
     *
     * @param validationType the validationType value to set.
     * @return the BackupInstance object itself.
     */
    public BackupInstance withValidationType(ValidationType validationType) {
        this.validationType = validationType;
        return this;
    }

    /**
     * Get the objectType property: The objectType property.
     *
     * @return the objectType value.
     */
    public String objectType() {
        return this.objectType;
    }

    /**
     * Set the objectType property: The objectType property.
     *
     * @param objectType the objectType value to set.
     * @return the BackupInstance object itself.
     */
    public BackupInstance withObjectType(String objectType) {
        this.objectType = objectType;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (dataSourceInfo() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property dataSourceInfo in model BackupInstance"));
        } else {
            dataSourceInfo().validate();
        }
        if (dataSourceSetInfo() != null) {
            dataSourceSetInfo().validate();
        }
        if (policyInfo() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property policyInfo in model BackupInstance"));
        } else {
            policyInfo().validate();
        }
        if (protectionStatus() != null) {
            protectionStatus().validate();
        }
        if (protectionErrorDetails() != null) {
            protectionErrorDetails().validate();
        }
        if (datasourceAuthCredentials() != null) {
            datasourceAuthCredentials().validate();
        }
        if (objectType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property objectType in model BackupInstance"));
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(BackupInstance.class);
}
