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

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

/** Details of the On Premise resource that was assessed. */
@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "source",
    defaultImpl = OnPremiseResourceDetails.class)
@JsonTypeName("OnPremise")
@JsonSubTypes({@JsonSubTypes.Type(name = "OnPremiseSql", value = OnPremiseSqlResourceDetails.class)})
@Fluent
public class OnPremiseResourceDetails extends ResourceDetails {
    /*
     * Azure resource Id of the workspace the machine is attached to
     */
    @JsonProperty(value = "workspaceId", required = true)
    private String workspaceId;

    /*
     * The unique Id of the machine
     */
    @JsonProperty(value = "vmuuid", required = true)
    private String vmuuid;

    /*
     * The oms agent Id installed on the machine
     */
    @JsonProperty(value = "sourceComputerId", required = true)
    private String sourceComputerId;

    /*
     * The name of the machine
     */
    @JsonProperty(value = "machineName", required = true)
    private String machineName;

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

    /**
     * Get the workspaceId property: Azure resource Id of the workspace the machine is attached to.
     *
     * @return the workspaceId value.
     */
    public String workspaceId() {
        return this.workspaceId;
    }

    /**
     * Set the workspaceId property: Azure resource Id of the workspace the machine is attached to.
     *
     * @param workspaceId the workspaceId value to set.
     * @return the OnPremiseResourceDetails object itself.
     */
    public OnPremiseResourceDetails withWorkspaceId(String workspaceId) {
        this.workspaceId = workspaceId;
        return this;
    }

    /**
     * Get the vmuuid property: The unique Id of the machine.
     *
     * @return the vmuuid value.
     */
    public String vmuuid() {
        return this.vmuuid;
    }

    /**
     * Set the vmuuid property: The unique Id of the machine.
     *
     * @param vmuuid the vmuuid value to set.
     * @return the OnPremiseResourceDetails object itself.
     */
    public OnPremiseResourceDetails withVmuuid(String vmuuid) {
        this.vmuuid = vmuuid;
        return this;
    }

    /**
     * Get the sourceComputerId property: The oms agent Id installed on the machine.
     *
     * @return the sourceComputerId value.
     */
    public String sourceComputerId() {
        return this.sourceComputerId;
    }

    /**
     * Set the sourceComputerId property: The oms agent Id installed on the machine.
     *
     * @param sourceComputerId the sourceComputerId value to set.
     * @return the OnPremiseResourceDetails object itself.
     */
    public OnPremiseResourceDetails withSourceComputerId(String sourceComputerId) {
        this.sourceComputerId = sourceComputerId;
        return this;
    }

    /**
     * Get the machineName property: The name of the machine.
     *
     * @return the machineName value.
     */
    public String machineName() {
        return this.machineName;
    }

    /**
     * Set the machineName property: The name of the machine.
     *
     * @param machineName the machineName value to set.
     * @return the OnPremiseResourceDetails object itself.
     */
    public OnPremiseResourceDetails withMachineName(String machineName) {
        this.machineName = machineName;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (workspaceId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property workspaceId in model OnPremiseResourceDetails"));
        }
        if (vmuuid() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property vmuuid in model OnPremiseResourceDetails"));
        }
        if (sourceComputerId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property sourceComputerId in model OnPremiseResourceDetails"));
        }
        if (machineName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property machineName in model OnPremiseResourceDetails"));
        }
    }

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