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

package com.azure.resourcemanager.webpubsub.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Upstream auth settings. If not set, no auth is used for upstream messages. */
@Fluent
public final class UpstreamAuthSettings {
    /*
     * Upstream auth type enum.
     */
    @JsonProperty(value = "type")
    private UpstreamAuthType type;

    /*
     * Managed identity settings for upstream.
     */
    @JsonProperty(value = "managedIdentity")
    private ManagedIdentitySettings managedIdentity;

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

    /**
     * Get the type property: Upstream auth type enum.
     *
     * @return the type value.
     */
    public UpstreamAuthType type() {
        return this.type;
    }

    /**
     * Set the type property: Upstream auth type enum.
     *
     * @param type the type value to set.
     * @return the UpstreamAuthSettings object itself.
     */
    public UpstreamAuthSettings withType(UpstreamAuthType type) {
        this.type = type;
        return this;
    }

    /**
     * Get the managedIdentity property: Managed identity settings for upstream.
     *
     * @return the managedIdentity value.
     */
    public ManagedIdentitySettings managedIdentity() {
        return this.managedIdentity;
    }

    /**
     * Set the managedIdentity property: Managed identity settings for upstream.
     *
     * @param managedIdentity the managedIdentity value to set.
     * @return the UpstreamAuthSettings object itself.
     */
    public UpstreamAuthSettings withManagedIdentity(ManagedIdentitySettings managedIdentity) {
        this.managedIdentity = managedIdentity;
        return this;
    }

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