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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.healthcareapis.models.IotDestinationProperties;
import com.azure.resourcemanager.healthcareapis.models.IotIdentityResolutionType;
import com.azure.resourcemanager.healthcareapis.models.IotMappingProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/** IoT Connector destination properties for an Azure FHIR service. */
@Fluent
public final class IotFhirDestinationProperties extends IotDestinationProperties {
    /*
     * Determines how resource identity is resolved on the destination.
     */
    @JsonProperty(value = "resourceIdentityResolutionType", required = true)
    private IotIdentityResolutionType resourceIdentityResolutionType;

    /*
     * Fully qualified resource id of the FHIR service to connect to.
     */
    @JsonProperty(value = "fhirServiceResourceId", required = true)
    private String fhirServiceResourceId;

    /*
     * FHIR Mappings
     */
    @JsonProperty(value = "fhirMapping", required = true)
    private IotMappingProperties fhirMapping;

    /**
     * Get the resourceIdentityResolutionType property: Determines how resource identity is resolved on the destination.
     *
     * @return the resourceIdentityResolutionType value.
     */
    public IotIdentityResolutionType resourceIdentityResolutionType() {
        return this.resourceIdentityResolutionType;
    }

    /**
     * Set the resourceIdentityResolutionType property: Determines how resource identity is resolved on the destination.
     *
     * @param resourceIdentityResolutionType the resourceIdentityResolutionType value to set.
     * @return the IotFhirDestinationProperties object itself.
     */
    public IotFhirDestinationProperties withResourceIdentityResolutionType(
        IotIdentityResolutionType resourceIdentityResolutionType) {
        this.resourceIdentityResolutionType = resourceIdentityResolutionType;
        return this;
    }

    /**
     * Get the fhirServiceResourceId property: Fully qualified resource id of the FHIR service to connect to.
     *
     * @return the fhirServiceResourceId value.
     */
    public String fhirServiceResourceId() {
        return this.fhirServiceResourceId;
    }

    /**
     * Set the fhirServiceResourceId property: Fully qualified resource id of the FHIR service to connect to.
     *
     * @param fhirServiceResourceId the fhirServiceResourceId value to set.
     * @return the IotFhirDestinationProperties object itself.
     */
    public IotFhirDestinationProperties withFhirServiceResourceId(String fhirServiceResourceId) {
        this.fhirServiceResourceId = fhirServiceResourceId;
        return this;
    }

    /**
     * Get the fhirMapping property: FHIR Mappings.
     *
     * @return the fhirMapping value.
     */
    public IotMappingProperties fhirMapping() {
        return this.fhirMapping;
    }

    /**
     * Set the fhirMapping property: FHIR Mappings.
     *
     * @param fhirMapping the fhirMapping value to set.
     * @return the IotFhirDestinationProperties object itself.
     */
    public IotFhirDestinationProperties withFhirMapping(IotMappingProperties fhirMapping) {
        this.fhirMapping = fhirMapping;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (resourceIdentityResolutionType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property resourceIdentityResolutionType in model"
                            + " IotFhirDestinationProperties"));
        }
        if (fhirServiceResourceId() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property fhirServiceResourceId in model IotFhirDestinationProperties"));
        }
        if (fhirMapping() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property fhirMapping in model IotFhirDestinationProperties"));
        } else {
            fhirMapping().validate();
        }
    }

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