// 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.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;

/** Key properties for JWT token validation. */
@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "@type",
    defaultImpl = TokenKey.class)
@JsonTypeName("TokenKey")
@JsonSubTypes({
    @JsonSubTypes.Type(name = "#Microsoft.VideoAnalyzer.RsaTokenKey", value = RsaTokenKey.class),
    @JsonSubTypes.Type(name = "#Microsoft.VideoAnalyzer.EccTokenKey", value = EccTokenKey.class)
})
@Fluent
public class TokenKey {
    /*
     * JWT token key id. Validation keys are looked up based on the key id
     * present on the JWT token header.
     */
    @JsonProperty(value = "kid", required = true)
    private String kid;

    /**
     * Get the kid property: JWT token key id. Validation keys are looked up based on the key id present on the JWT
     * token header.
     *
     * @return the kid value.
     */
    public String kid() {
        return this.kid;
    }

    /**
     * Set the kid property: JWT token key id. Validation keys are looked up based on the key id present on the JWT
     * token header.
     *
     * @param kid the kid value to set.
     * @return the TokenKey object itself.
     */
    public TokenKey withKid(String kid) {
        this.kid = kid;
        return this;
    }

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

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