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

package com.azure.resourcemanager.imagebuilder.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;

/** Describes an image source that is an image version in an Azure Compute Gallery or a Direct Shared Gallery. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonTypeName("SharedImageVersion")
@Fluent
public final class ImageTemplateSharedImageVersionSource extends ImageTemplateSource {
    /*
     * ARM resource id of the image version. When image version name is 'latest', the version is evaluated when the
     * image build takes place.
     */
    @JsonProperty(value = "imageVersionId", required = true)
    private String imageVersionId;

    /*
     * Exact ARM resource id of the image version. This readonly field differs from the image version Id in
     * 'imageVersionId' only if the version name specified in 'imageVersionId' field is 'latest'.
     */
    @JsonProperty(value = "exactVersion", access = JsonProperty.Access.WRITE_ONLY)
    private String exactVersion;

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

    /**
     * Get the imageVersionId property: ARM resource id of the image version. When image version name is 'latest', the
     * version is evaluated when the image build takes place.
     *
     * @return the imageVersionId value.
     */
    public String imageVersionId() {
        return this.imageVersionId;
    }

    /**
     * Set the imageVersionId property: ARM resource id of the image version. When image version name is 'latest', the
     * version is evaluated when the image build takes place.
     *
     * @param imageVersionId the imageVersionId value to set.
     * @return the ImageTemplateSharedImageVersionSource object itself.
     */
    public ImageTemplateSharedImageVersionSource withImageVersionId(String imageVersionId) {
        this.imageVersionId = imageVersionId;
        return this;
    }

    /**
     * Get the exactVersion property: Exact ARM resource id of the image version. This readonly field differs from the
     * image version Id in 'imageVersionId' only if the version name specified in 'imageVersionId' field is 'latest'.
     *
     * @return the exactVersion value.
     */
    public String exactVersion() {
        return this.exactVersion;
    }

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

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