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

package com.azure.resourcemanager.batchai.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

/** The OS image reference. */
@Fluent
public final class ImageReference {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(ImageReference.class);

    /*
     * Publisher of the image.
     */
    @JsonProperty(value = "publisher", required = true)
    private String publisher;

    /*
     * Offer of the image.
     */
    @JsonProperty(value = "offer", required = true)
    private String offer;

    /*
     * SKU of the image.
     */
    @JsonProperty(value = "sku", required = true)
    private String sku;

    /*
     * Version of the image.
     */
    @JsonProperty(value = "version")
    private String version;

    /*
     * The ARM resource identifier of the virtual machine image for the compute
     * nodes. This is of the form
     * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}.
     * The virtual machine image must be in the same region and subscription as
     * the cluster. For information about the firewall settings for the Batch
     * node agent to communicate with the Batch service see
     * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
     * Note, you need to provide publisher, offer and sku of the base OS image
     * of which the custom image has been derived from.
     */
    @JsonProperty(value = "virtualMachineImageId")
    private String virtualMachineImageId;

    /**
     * Get the publisher property: Publisher of the image.
     *
     * @return the publisher value.
     */
    public String publisher() {
        return this.publisher;
    }

    /**
     * Set the publisher property: Publisher of the image.
     *
     * @param publisher the publisher value to set.
     * @return the ImageReference object itself.
     */
    public ImageReference withPublisher(String publisher) {
        this.publisher = publisher;
        return this;
    }

    /**
     * Get the offer property: Offer of the image.
     *
     * @return the offer value.
     */
    public String offer() {
        return this.offer;
    }

    /**
     * Set the offer property: Offer of the image.
     *
     * @param offer the offer value to set.
     * @return the ImageReference object itself.
     */
    public ImageReference withOffer(String offer) {
        this.offer = offer;
        return this;
    }

    /**
     * Get the sku property: SKU of the image.
     *
     * @return the sku value.
     */
    public String sku() {
        return this.sku;
    }

    /**
     * Set the sku property: SKU of the image.
     *
     * @param sku the sku value to set.
     * @return the ImageReference object itself.
     */
    public ImageReference withSku(String sku) {
        this.sku = sku;
        return this;
    }

    /**
     * Get the version property: Version of the image.
     *
     * @return the version value.
     */
    public String version() {
        return this.version;
    }

    /**
     * Set the version property: Version of the image.
     *
     * @param version the version value to set.
     * @return the ImageReference object itself.
     */
    public ImageReference withVersion(String version) {
        this.version = version;
        return this;
    }

    /**
     * Get the virtualMachineImageId property: The ARM resource identifier of the virtual machine image for the compute
     * nodes. This is of the form
     * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}.
     * The virtual machine image must be in the same region and subscription as the cluster. For information about the
     * firewall settings for the Batch node agent to communicate with the Batch service see
     * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
     * Note, you need to provide publisher, offer and sku of the base OS image of which the custom image has been
     * derived from.
     *
     * @return the virtualMachineImageId value.
     */
    public String virtualMachineImageId() {
        return this.virtualMachineImageId;
    }

    /**
     * Set the virtualMachineImageId property: The ARM resource identifier of the virtual machine image for the compute
     * nodes. This is of the form
     * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}.
     * The virtual machine image must be in the same region and subscription as the cluster. For information about the
     * firewall settings for the Batch node agent to communicate with the Batch service see
     * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
     * Note, you need to provide publisher, offer and sku of the base OS image of which the custom image has been
     * derived from.
     *
     * @param virtualMachineImageId the virtualMachineImageId value to set.
     * @return the ImageReference object itself.
     */
    public ImageReference withVirtualMachineImageId(String virtualMachineImageId) {
        this.virtualMachineImageId = virtualMachineImageId;
        return this;
    }

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