// 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 a managed image in customer subscription. This image must reside in the same
 * subscription and region as the Image Builder template.
 */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonTypeName("ManagedImage")
@Fluent
public final class ImageTemplateManagedImageSource extends ImageTemplateSource {
    /*
     * ARM resource id of the managed image in customer subscription
     */
    @JsonProperty(value = "imageId", required = true)
    private String imageId;

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

    /**
     * Get the imageId property: ARM resource id of the managed image in customer subscription.
     *
     * @return the imageId value.
     */
    public String imageId() {
        return this.imageId;
    }

    /**
     * Set the imageId property: ARM resource id of the managed image in customer subscription.
     *
     * @param imageId the imageId value to set.
     * @return the ImageTemplateManagedImageSource object itself.
     */
    public ImageTemplateManagedImageSource withImageId(String imageId) {
        this.imageId = imageId;
        return this;
    }

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

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