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

package com.azure.resourcemanager.compute.generated;

import com.azure.resourcemanager.compute.fluent.models.GalleryImageVersionInner;
import com.azure.resourcemanager.compute.models.DataDiskImageEncryption;
import com.azure.resourcemanager.compute.models.EncryptionImages;
import com.azure.resourcemanager.compute.models.GalleryArtifactVersionFullSource;
import com.azure.resourcemanager.compute.models.GalleryDataDiskImage;
import com.azure.resourcemanager.compute.models.GalleryDiskImageSource;
import com.azure.resourcemanager.compute.models.GalleryImageVersionPublishingProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionSafetyProfile;
import com.azure.resourcemanager.compute.models.GalleryImageVersionStorageProfile;
import com.azure.resourcemanager.compute.models.GalleryOSDiskImage;
import com.azure.resourcemanager.compute.models.HostCaching;
import com.azure.resourcemanager.compute.models.OSDiskImageEncryption;
import com.azure.resourcemanager.compute.models.ReplicationMode;
import com.azure.resourcemanager.compute.models.StorageAccountType;
import com.azure.resourcemanager.compute.models.TargetRegion;
import java.util.Arrays;

/** Samples for GalleryImageVersions CreateOrUpdate. */
public final class GalleryImageVersionsCreateOrUpdateSamples {
    /*
     * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2022-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithShallowReplicationMode.json
     */
    /**
     * Sample code: Create or update a simple Gallery Image Version using shallow replication mode.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createOrUpdateASimpleGalleryImageVersionUsingShallowReplicationMode(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .virtualMachines()
            .manager()
            .serviceClient()
            .getGalleryImageVersions()
            .createOrUpdate(
                "myResourceGroup",
                "myGalleryName",
                "myGalleryImageName",
                "1.0.0",
                new GalleryImageVersionInner()
                    .withLocation("West US")
                    .withPublishingProfile(
                        new GalleryImageVersionPublishingProfile()
                            .withTargetRegions(
                                Arrays
                                    .asList(
                                        new TargetRegion()
                                            .withName("West US")
                                            .withRegionalReplicaCount(1)
                                            .withExcludeFromLatest(false)))
                            .withReplicationMode(ReplicationMode.SHALLOW))
                    .withStorageProfile(
                        new GalleryImageVersionStorageProfile()
                            .withSource(
                                new GalleryArtifactVersionFullSource()
                                    .withId(
                                        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}")))
                    .withSafetyProfile(
                        new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2022-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithVHD.json
     */
    /**
     * Sample code: Create or update a simple Gallery Image Version using vhd as a source.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createOrUpdateASimpleGalleryImageVersionUsingVhdAsASource(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .virtualMachines()
            .manager()
            .serviceClient()
            .getGalleryImageVersions()
            .createOrUpdate(
                "myResourceGroup",
                "myGalleryName",
                "myGalleryImageName",
                "1.0.0",
                new GalleryImageVersionInner()
                    .withLocation("West US")
                    .withPublishingProfile(
                        new GalleryImageVersionPublishingProfile()
                            .withTargetRegions(
                                Arrays
                                    .asList(
                                        new TargetRegion()
                                            .withName("West US")
                                            .withRegionalReplicaCount(1)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false),
                                        new TargetRegion()
                                            .withName("East US")
                                            .withRegionalReplicaCount(2)
                                            .withStorageAccountType(StorageAccountType.STANDARD_ZRS)
                                            .withExcludeFromLatest(false))))
                    .withStorageProfile(
                        new GalleryImageVersionStorageProfile()
                            .withOsDiskImage(
                                new GalleryOSDiskImage()
                                    .withHostCaching(HostCaching.READ_ONLY)
                                    .withSource(
                                        new GalleryDiskImageSource()
                                            .withId(
                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}")
                                            .withUri(
                                                "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd")))
                            .withDataDiskImages(
                                Arrays
                                    .asList(
                                        new GalleryDataDiskImage()
                                            .withHostCaching(HostCaching.NONE)
                                            .withSource(
                                                new GalleryDiskImageSource()
                                                    .withId(
                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}")
                                                    .withUri(
                                                        "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"))
                                            .withLun(1))))
                    .withSafetyProfile(
                        new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2022-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithVmAsSource.json
     */
    /**
     * Sample code: Create or update a simple Gallery Image Version using VM as source.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createOrUpdateASimpleGalleryImageVersionUsingVMAsSource(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .virtualMachines()
            .manager()
            .serviceClient()
            .getGalleryImageVersions()
            .createOrUpdate(
                "myResourceGroup",
                "myGalleryName",
                "myGalleryImageName",
                "1.0.0",
                new GalleryImageVersionInner()
                    .withLocation("West US")
                    .withPublishingProfile(
                        new GalleryImageVersionPublishingProfile()
                            .withTargetRegions(
                                Arrays
                                    .asList(
                                        new TargetRegion()
                                            .withName("West US")
                                            .withRegionalReplicaCount(2)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet")
                                                                    .withLun(0),
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false),
                                        new TargetRegion()
                                            .withName("East US")
                                            .withRegionalReplicaCount(2)
                                            .withStorageAccountType(StorageAccountType.STANDARD_ZRS)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet")
                                                                    .withLun(0),
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false))))
                    .withStorageProfile(
                        new GalleryImageVersionStorageProfile()
                            .withSource(
                                new GalleryArtifactVersionFullSource()
                                    .withId(
                                        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}")))
                    .withSafetyProfile(
                        new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2022-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithImageVersionAsSource.json
     */
    /**
     * Sample code: Create or update a simple Gallery Image Version using shared image as source.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createOrUpdateASimpleGalleryImageVersionUsingSharedImageAsSource(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .virtualMachines()
            .manager()
            .serviceClient()
            .getGalleryImageVersions()
            .createOrUpdate(
                "myResourceGroup",
                "myGalleryName",
                "myGalleryImageName",
                "1.0.0",
                new GalleryImageVersionInner()
                    .withLocation("West US")
                    .withPublishingProfile(
                        new GalleryImageVersionPublishingProfile()
                            .withTargetRegions(
                                Arrays
                                    .asList(
                                        new TargetRegion()
                                            .withName("West US")
                                            .withRegionalReplicaCount(1)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet")
                                                                    .withLun(0),
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false),
                                        new TargetRegion()
                                            .withName("East US")
                                            .withRegionalReplicaCount(2)
                                            .withStorageAccountType(StorageAccountType.STANDARD_ZRS)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet")
                                                                    .withLun(0),
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false))))
                    .withStorageProfile(
                        new GalleryImageVersionStorageProfile()
                            .withSource(
                                new GalleryArtifactVersionFullSource()
                                    .withId(
                                        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}")))
                    .withSafetyProfile(
                        new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2022-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithSnapshotsAsSource.json
     */
    /**
     * Sample code: Create or update a simple Gallery Image Version using mix of disks and snapshots as a source.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createOrUpdateASimpleGalleryImageVersionUsingMixOfDisksAndSnapshotsAsASource(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .virtualMachines()
            .manager()
            .serviceClient()
            .getGalleryImageVersions()
            .createOrUpdate(
                "myResourceGroup",
                "myGalleryName",
                "myGalleryImageName",
                "1.0.0",
                new GalleryImageVersionInner()
                    .withLocation("West US")
                    .withPublishingProfile(
                        new GalleryImageVersionPublishingProfile()
                            .withTargetRegions(
                                Arrays
                                    .asList(
                                        new TargetRegion()
                                            .withName("West US")
                                            .withRegionalReplicaCount(1)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false),
                                        new TargetRegion()
                                            .withName("East US")
                                            .withRegionalReplicaCount(2)
                                            .withStorageAccountType(StorageAccountType.STANDARD_ZRS)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false))))
                    .withStorageProfile(
                        new GalleryImageVersionStorageProfile()
                            .withOsDiskImage(
                                new GalleryOSDiskImage()
                                    .withHostCaching(HostCaching.READ_ONLY)
                                    .withSource(
                                        new GalleryDiskImageSource()
                                            .withId(
                                                "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}")))
                            .withDataDiskImages(
                                Arrays
                                    .asList(
                                        new GalleryDataDiskImage()
                                            .withHostCaching(HostCaching.NONE)
                                            .withSource(
                                                new GalleryDiskImageSource()
                                                    .withId(
                                                        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"))
                                            .withLun(1))))
                    .withSafetyProfile(
                        new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2022-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithSnapshotsAsSource.json
     */
    /**
     * Sample code: Create or update a simple Gallery Image Version using snapshots as a source.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createOrUpdateASimpleGalleryImageVersionUsingSnapshotsAsASource(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .virtualMachines()
            .manager()
            .serviceClient()
            .getGalleryImageVersions()
            .createOrUpdate(
                "myResourceGroup",
                "myGalleryName",
                "myGalleryImageName",
                "1.0.0",
                new GalleryImageVersionInner()
                    .withLocation("West US")
                    .withPublishingProfile(
                        new GalleryImageVersionPublishingProfile()
                            .withTargetRegions(
                                Arrays
                                    .asList(
                                        new TargetRegion()
                                            .withName("West US")
                                            .withRegionalReplicaCount(1)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false),
                                        new TargetRegion()
                                            .withName("East US")
                                            .withRegionalReplicaCount(2)
                                            .withStorageAccountType(StorageAccountType.STANDARD_ZRS)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false))))
                    .withStorageProfile(
                        new GalleryImageVersionStorageProfile()
                            .withOsDiskImage(
                                new GalleryOSDiskImage()
                                    .withHostCaching(HostCaching.READ_ONLY)
                                    .withSource(
                                        new GalleryDiskImageSource()
                                            .withId(
                                                "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}")))
                            .withDataDiskImages(
                                Arrays
                                    .asList(
                                        new GalleryDataDiskImage()
                                            .withHostCaching(HostCaching.NONE)
                                            .withSource(
                                                new GalleryDiskImageSource()
                                                    .withId(
                                                        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"))
                                            .withLun(1))))
                    .withSafetyProfile(
                        new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2022-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithTargetExtendedLocations.json
     */
    /**
     * Sample code: Create or update a simple gallery image version with target extended locations specified.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createOrUpdateASimpleGalleryImageVersionWithTargetExtendedLocationsSpecified(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .virtualMachines()
            .manager()
            .serviceClient()
            .getGalleryImageVersions()
            .createOrUpdate(
                "myResourceGroup",
                "myGalleryName",
                "myGalleryImageName",
                "1.0.0",
                new GalleryImageVersionInner()
                    .withLocation("West US")
                    .withPublishingProfile(
                        new GalleryImageVersionPublishingProfile()
                            .withTargetRegions(
                                Arrays
                                    .asList(
                                        new TargetRegion()
                                            .withName("West US")
                                            .withRegionalReplicaCount(1)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet")
                                                                    .withLun(0),
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false),
                                        new TargetRegion()
                                            .withName("East US")
                                            .withRegionalReplicaCount(2)
                                            .withStorageAccountType(StorageAccountType.STANDARD_ZRS)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet")
                                                                    .withLun(0),
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false))))
                    .withStorageProfile(
                        new GalleryImageVersionStorageProfile()
                            .withSource(
                                new GalleryArtifactVersionFullSource()
                                    .withId(
                                        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}")))
                    .withSafetyProfile(
                        new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2022-03-03/examples/galleryExamples/GalleryImageVersion_Create_WithCommunityImageVersionAsSource.json
     */
    /**
     * Sample code: Create or update a simple Gallery Image Version using community gallery image as source.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createOrUpdateASimpleGalleryImageVersionUsingCommunityGalleryImageAsSource(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .virtualMachines()
            .manager()
            .serviceClient()
            .getGalleryImageVersions()
            .createOrUpdate(
                "myResourceGroup",
                "myGalleryName",
                "myGalleryImageName",
                "1.0.0",
                new GalleryImageVersionInner()
                    .withLocation("West US")
                    .withPublishingProfile(
                        new GalleryImageVersionPublishingProfile()
                            .withTargetRegions(
                                Arrays
                                    .asList(
                                        new TargetRegion()
                                            .withName("West US")
                                            .withRegionalReplicaCount(1)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet")
                                                                    .withLun(0),
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false),
                                        new TargetRegion()
                                            .withName("East US")
                                            .withRegionalReplicaCount(2)
                                            .withStorageAccountType(StorageAccountType.STANDARD_ZRS)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet")
                                                                    .withLun(0),
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false))))
                    .withStorageProfile(
                        new GalleryImageVersionStorageProfile()
                            .withSource(
                                new GalleryArtifactVersionFullSource()
                                    .withCommunityGalleryImageId(
                                        "/communityGalleries/{communityGalleryName}/images/{communityGalleryImageName}")))
                    .withSafetyProfile(
                        new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)),
                com.azure.core.util.Context.NONE);
    }

    /*
     * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2022-03-03/examples/galleryExamples/GalleryImageVersion_Create.json
     */
    /**
     * Sample code: Create or update a simple Gallery Image Version using managed image as source.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createOrUpdateASimpleGalleryImageVersionUsingManagedImageAsSource(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .virtualMachines()
            .manager()
            .serviceClient()
            .getGalleryImageVersions()
            .createOrUpdate(
                "myResourceGroup",
                "myGalleryName",
                "myGalleryImageName",
                "1.0.0",
                new GalleryImageVersionInner()
                    .withLocation("West US")
                    .withPublishingProfile(
                        new GalleryImageVersionPublishingProfile()
                            .withTargetRegions(
                                Arrays
                                    .asList(
                                        new TargetRegion()
                                            .withName("West US")
                                            .withRegionalReplicaCount(1)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet")
                                                                    .withLun(0),
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false),
                                        new TargetRegion()
                                            .withName("East US")
                                            .withRegionalReplicaCount(2)
                                            .withStorageAccountType(StorageAccountType.STANDARD_ZRS)
                                            .withEncryption(
                                                new EncryptionImages()
                                                    .withOsDiskImage(
                                                        new OSDiskImageEncryption()
                                                            .withDiskEncryptionSetId(
                                                                "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"))
                                                    .withDataDiskImages(
                                                        Arrays
                                                            .asList(
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet")
                                                                    .withLun(0),
                                                                new DataDiskImageEncryption()
                                                                    .withDiskEncryptionSetId(
                                                                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet")
                                                                    .withLun(1))))
                                            .withExcludeFromLatest(false))))
                    .withStorageProfile(
                        new GalleryImageVersionStorageProfile()
                            .withSource(
                                new GalleryArtifactVersionFullSource()
                                    .withId(
                                        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}")))
                    .withSafetyProfile(
                        new GalleryImageVersionSafetyProfile().withAllowDeletionOfReplicatedLocations(false)),
                com.azure.core.util.Context.NONE);
    }
}
