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

package com.azure.resourcemanager.videoanalyzer.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.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;

/** Required validation properties for tokens generated with RSA algorithm. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type")
@JsonTypeName("#Microsoft.VideoAnalyzer.RsaTokenKey")
@Fluent
public final class RsaTokenKey extends TokenKey {
    /*
     * RSA algorithm to be used: RS256, RS384 or RS512.
     */
    @JsonProperty(value = "alg", required = true)
    private AccessPolicyRsaAlgo alg;

    /*
     * RSA public key modulus.
     */
    @JsonProperty(value = "n", required = true)
    private String n;

    /*
     * RSA public key exponent.
     */
    @JsonProperty(value = "e", required = true)
    private String e;

    /**
     * Get the alg property: RSA algorithm to be used: RS256, RS384 or RS512.
     *
     * @return the alg value.
     */
    public AccessPolicyRsaAlgo alg() {
        return this.alg;
    }

    /**
     * Set the alg property: RSA algorithm to be used: RS256, RS384 or RS512.
     *
     * @param alg the alg value to set.
     * @return the RsaTokenKey object itself.
     */
    public RsaTokenKey withAlg(AccessPolicyRsaAlgo alg) {
        this.alg = alg;
        return this;
    }

    /**
     * Get the n property: RSA public key modulus.
     *
     * @return the n value.
     */
    public String n() {
        return this.n;
    }

    /**
     * Set the n property: RSA public key modulus.
     *
     * @param n the n value to set.
     * @return the RsaTokenKey object itself.
     */
    public RsaTokenKey withN(String n) {
        this.n = n;
        return this;
    }

    /**
     * Get the e property: RSA public key exponent.
     *
     * @return the e value.
     */
    public String e() {
        return this.e;
    }

    /**
     * Set the e property: RSA public key exponent.
     *
     * @param e the e value to set.
     * @return the RsaTokenKey object itself.
     */
    public RsaTokenKey withE(String e) {
        this.e = e;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public RsaTokenKey withKid(String kid) {
        super.withKid(kid);
        return this;
    }

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

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