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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.apimanagement.models.KeyType;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

/** Parameters supplied to the Get User Token operation. */
@Fluent
public final class UserTokenParameterProperties {
    /*
     * The Key to be used to generate token for user.
     */
    @JsonProperty(value = "keyType", required = true)
    private KeyType keyType;

    /*
     * The Expiry time of the Token. Maximum token expiry time is set to 30
     * days. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ`
     * as specified by the ISO 8601 standard.
     *
     */
    @JsonProperty(value = "expiry", required = true)
    private OffsetDateTime expiry;

    /**
     * Get the keyType property: The Key to be used to generate token for user.
     *
     * @return the keyType value.
     */
    public KeyType keyType() {
        return this.keyType;
    }

    /**
     * Set the keyType property: The Key to be used to generate token for user.
     *
     * @param keyType the keyType value to set.
     * @return the UserTokenParameterProperties object itself.
     */
    public UserTokenParameterProperties withKeyType(KeyType keyType) {
        this.keyType = keyType;
        return this;
    }

    /**
     * Get the expiry property: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The date
     * conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard.
     *
     * @return the expiry value.
     */
    public OffsetDateTime expiry() {
        return this.expiry;
    }

    /**
     * Set the expiry property: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The date
     * conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard.
     *
     * @param expiry the expiry value to set.
     * @return the UserTokenParameterProperties object itself.
     */
    public UserTokenParameterProperties withExpiry(OffsetDateTime expiry) {
        this.expiry = expiry;
        return this;
    }

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

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