// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.gcp.compute;

import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import com.pulumi.gcp.Utilities;
import com.pulumi.gcp.compute.MachineImageArgs;
import com.pulumi.gcp.compute.inputs.MachineImageState;
import com.pulumi.gcp.compute.outputs.MachineImageMachineImageEncryptionKey;
import java.lang.Boolean;
import java.lang.String;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * Represents a Machine Image resource. Machine images store all the configuration,
 * metadata, permissions, and data from one or more disks required to create a
 * Virtual machine (VM) instance.
 * 
 * To get more information about MachineImage, see:
 * 
 * * [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/machineImages)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/compute/docs/machine-images)
 * 
 * ## Example Usage
 * ### Machine Image Basic
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.compute.Instance;
 * import com.pulumi.gcp.compute.InstanceArgs;
 * import com.pulumi.gcp.compute.inputs.InstanceBootDiskArgs;
 * import com.pulumi.gcp.compute.inputs.InstanceBootDiskInitializeParamsArgs;
 * import com.pulumi.gcp.compute.inputs.InstanceNetworkInterfaceArgs;
 * import com.pulumi.gcp.compute.MachineImage;
 * import com.pulumi.gcp.compute.MachineImageArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * 
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 * 
 *     public static void stack(Context ctx) {
 *         var vm = new Instance(&#34;vm&#34;, InstanceArgs.builder()        
 *             .machineType(&#34;e2-medium&#34;)
 *             .bootDisk(InstanceBootDiskArgs.builder()
 *                 .initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
 *                     .image(&#34;debian-cloud/debian-11&#34;)
 *                     .build())
 *                 .build())
 *             .networkInterfaces(InstanceNetworkInterfaceArgs.builder()
 *                 .network(&#34;default&#34;)
 *                 .build())
 *             .build(), CustomResourceOptions.builder()
 *                 .provider(google_beta)
 *                 .build());
 * 
 *         var image = new MachineImage(&#34;image&#34;, MachineImageArgs.builder()        
 *             .sourceInstance(vm.selfLink())
 *             .build(), CustomResourceOptions.builder()
 *                 .provider(google_beta)
 *                 .build());
 * 
 *     }
 * }
 * ```
 * ### Compute Machine Image Kms
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.compute.Instance;
 * import com.pulumi.gcp.compute.InstanceArgs;
 * import com.pulumi.gcp.compute.inputs.InstanceBootDiskArgs;
 * import com.pulumi.gcp.compute.inputs.InstanceBootDiskInitializeParamsArgs;
 * import com.pulumi.gcp.compute.inputs.InstanceNetworkInterfaceArgs;
 * import com.pulumi.gcp.kms.KeyRing;
 * import com.pulumi.gcp.kms.KeyRingArgs;
 * import com.pulumi.gcp.kms.CryptoKey;
 * import com.pulumi.gcp.kms.CryptoKeyArgs;
 * import com.pulumi.gcp.compute.MachineImage;
 * import com.pulumi.gcp.compute.MachineImageArgs;
 * import com.pulumi.gcp.compute.inputs.MachineImageMachineImageEncryptionKeyArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * 
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 * 
 *     public static void stack(Context ctx) {
 *         var vm = new Instance(&#34;vm&#34;, InstanceArgs.builder()        
 *             .machineType(&#34;e2-medium&#34;)
 *             .bootDisk(InstanceBootDiskArgs.builder()
 *                 .initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
 *                     .image(&#34;debian-cloud/debian-11&#34;)
 *                     .build())
 *                 .build())
 *             .networkInterfaces(InstanceNetworkInterfaceArgs.builder()
 *                 .network(&#34;default&#34;)
 *                 .build())
 *             .build(), CustomResourceOptions.builder()
 *                 .provider(google_beta)
 *                 .build());
 * 
 *         var keyRing = new KeyRing(&#34;keyRing&#34;, KeyRingArgs.builder()        
 *             .location(&#34;us&#34;)
 *             .build(), CustomResourceOptions.builder()
 *                 .provider(google_beta)
 *                 .build());
 * 
 *         var cryptoKey = new CryptoKey(&#34;cryptoKey&#34;, CryptoKeyArgs.builder()        
 *             .keyRing(keyRing.id())
 *             .build(), CustomResourceOptions.builder()
 *                 .provider(google_beta)
 *                 .build());
 * 
 *         var image = new MachineImage(&#34;image&#34;, MachineImageArgs.builder()        
 *             .sourceInstance(vm.selfLink())
 *             .machineImageEncryptionKey(MachineImageMachineImageEncryptionKeyArgs.builder()
 *                 .kmsKeyName(cryptoKey.id())
 *                 .build())
 *             .build(), CustomResourceOptions.builder()
 *                 .provider(google_beta)
 *                 .build());
 * 
 *     }
 * }
 * ```
 * 
 * ## Import
 * 
 * MachineImage can be imported using any of these accepted formats
 * 
 * ```sh
 *  $ pulumi import gcp:compute/machineImage:MachineImage default projects/{{project}}/global/machineImages/{{name}}
 * ```
 * 
 * ```sh
 *  $ pulumi import gcp:compute/machineImage:MachineImage default {{project}}/{{name}}
 * ```
 * 
 * ```sh
 *  $ pulumi import gcp:compute/machineImage:MachineImage default {{name}}
 * ```
 * 
 */
@ResourceType(type="gcp:compute/machineImage:MachineImage")
public class MachineImage extends com.pulumi.resources.CustomResource {
    /**
     * A text description of the resource.
     * 
     */
    @Export(name="description", type=String.class, parameters={})
    private Output</* @Nullable */ String> description;

    /**
     * @return A text description of the resource.
     * 
     */
    public Output<Optional<String>> description() {
        return Codegen.optional(this.description);
    }
    /**
     * Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process.
     * Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
     * 
     */
    @Export(name="guestFlush", type=Boolean.class, parameters={})
    private Output</* @Nullable */ Boolean> guestFlush;

    /**
     * @return Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process.
     * Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
     * 
     */
    public Output<Optional<Boolean>> guestFlush() {
        return Codegen.optional(this.guestFlush);
    }
    /**
     * Encrypts the machine image using a customer-supplied encryption key.
     * After you encrypt a machine image with a customer-supplied key, you must
     * provide the same key if you use the machine image later (e.g. to create a
     * instance from the image)
     * Structure is documented below.
     * 
     */
    @Export(name="machineImageEncryptionKey", type=MachineImageMachineImageEncryptionKey.class, parameters={})
    private Output</* @Nullable */ MachineImageMachineImageEncryptionKey> machineImageEncryptionKey;

    /**
     * @return Encrypts the machine image using a customer-supplied encryption key.
     * After you encrypt a machine image with a customer-supplied key, you must
     * provide the same key if you use the machine image later (e.g. to create a
     * instance from the image)
     * Structure is documented below.
     * 
     */
    public Output<Optional<MachineImageMachineImageEncryptionKey>> machineImageEncryptionKey() {
        return Codegen.optional(this.machineImageEncryptionKey);
    }
    /**
     * Name of the resource.
     * 
     */
    @Export(name="name", type=String.class, parameters={})
    private Output<String> name;

    /**
     * @return Name of the resource.
     * 
     */
    public Output<String> name() {
        return this.name;
    }
    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     * 
     */
    @Export(name="project", type=String.class, parameters={})
    private Output<String> project;

    /**
     * @return The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     * 
     */
    public Output<String> project() {
        return this.project;
    }
    /**
     * The URI of the created resource.
     * 
     */
    @Export(name="selfLink", type=String.class, parameters={})
    private Output<String> selfLink;

    /**
     * @return The URI of the created resource.
     * 
     */
    public Output<String> selfLink() {
        return this.selfLink;
    }
    /**
     * The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.
     * 
     * ***
     * 
     */
    @Export(name="sourceInstance", type=String.class, parameters={})
    private Output<String> sourceInstance;

    /**
     * @return The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.
     * 
     * ***
     * 
     */
    public Output<String> sourceInstance() {
        return this.sourceInstance;
    }
    /**
     * The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
     * 
     */
    @Export(name="storageLocations", type=List.class, parameters={String.class})
    private Output<List<String>> storageLocations;

    /**
     * @return The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
     * 
     */
    public Output<List<String>> storageLocations() {
        return this.storageLocations;
    }

    /**
     *
     * @param name The _unique_ name of the resulting resource.
     */
    public MachineImage(String name) {
        this(name, MachineImageArgs.Empty);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     */
    public MachineImage(String name, MachineImageArgs args) {
        this(name, args, null);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     * @param options A bag of options that control this resource's behavior.
     */
    public MachineImage(String name, MachineImageArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("gcp:compute/machineImage:MachineImage", name, args == null ? MachineImageArgs.Empty : args, makeResourceOptions(options, Codegen.empty()));
    }

    private MachineImage(String name, Output<String> id, @Nullable MachineImageState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("gcp:compute/machineImage:MachineImage", name, state, makeResourceOptions(options, id));
    }

    private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output<String> id) {
        var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
            .version(Utilities.getVersion())
            .build();
        return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
    }

    /**
     * Get an existing Host resource's state with the given name, ID, and optional extra
     * properties used to qualify the lookup.
     *
     * @param name The _unique_ name of the resulting resource.
     * @param id The _unique_ provider ID of the resource to lookup.
     * @param state
     * @param options Optional settings to control the behavior of the CustomResource.
     */
    public static MachineImage get(String name, Output<String> id, @Nullable MachineImageState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        return new MachineImage(name, id, state, options);
    }
}
