// *** 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.azure.core;

import com.pulumi.azure.Utilities;
import com.pulumi.azure.core.SubscriptionArgs;
import com.pulumi.azure.core.inputs.SubscriptionState;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.String;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * Manages an Alias for a Subscription - which adds an Alias to an existing Subscription, allowing it to be managed in the provider - or create a new Subscription with a new Alias.
 * 
 * &gt; **NOTE:** Destroying a Subscription controlled by this resource will place the Subscription into a cancelled state. It is possible to re-activate a subscription within 90-days of cancellation, after which time the Subscription is irrevocably deleted, and the Subscription ID cannot be re-used. For further information see [here](https://docs.microsoft.com/azure/cost-management-billing/manage/cancel-azure-subscription#what-happens-after-subscription-cancellation). Users can optionally delete a Subscription once 72 hours have passed, however, this functionality is not suitable for this provider. A `Deleted` subscription cannot be reactivated.
 * 
 * &gt; **NOTE:** It is not possible to destroy (cancel) a subscription if it contains resources. If resources are present that are not managed by the provider then these will need to be removed before the Subscription can be destroyed.
 * 
 * &gt; **NOTE:** Azure supports Multiple Aliases per Subscription, however, to reliably manage this resource in this provider only a single Alias is supported.
 * 
 * &gt; **NOTE:** When using this resource across tenants the `client_id` and `tenant_id` of the `provider` config block should be for the home tenant details for the SPN / User or a permissions error will likely be encountered. See [the official documentation](https://learn.microsoft.com/en-us/azure/cost-management-billing/manage/programmatically-create-subscription) for more details.
 * 
 * ## Example Usage
 * ### Creating A New Alias And Subscription For An Enrollment Account
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azure.billing.BillingFunctions;
 * import com.pulumi.azure.billing.inputs.GetEnrollmentAccountScopeArgs;
 * import com.pulumi.azure.core.Subscription;
 * import com.pulumi.azure.core.SubscriptionArgs;
 * 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) {
 *         final var exampleEnrollmentAccountScope = BillingFunctions.getEnrollmentAccountScope(GetEnrollmentAccountScopeArgs.builder()
 *             .billingAccountName(&#34;1234567890&#34;)
 *             .enrollmentAccountName(&#34;0123456&#34;)
 *             .build());
 * 
 *         var exampleSubscription = new Subscription(&#34;exampleSubscription&#34;, SubscriptionArgs.builder()        
 *             .subscriptionName(&#34;My Example EA Subscription&#34;)
 *             .billingScopeId(exampleEnrollmentAccountScope.applyValue(getEnrollmentAccountScopeResult -&gt; getEnrollmentAccountScopeResult.id()))
 *             .build());
 * 
 *     }
 * }
 * ```
 * ### Creating A New Alias And Subscription For A Microsoft Customer Account
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azure.billing.BillingFunctions;
 * import com.pulumi.azure.billing.inputs.GetMcaAccountScopeArgs;
 * import com.pulumi.azure.core.Subscription;
 * import com.pulumi.azure.core.SubscriptionArgs;
 * 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) {
 *         final var exampleMcaAccountScope = BillingFunctions.getMcaAccountScope(GetMcaAccountScopeArgs.builder()
 *             .billingAccountName(&#34;e879cf0f-2b4d-5431-109a-f72fc9868693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31&#34;)
 *             .billingProfileName(&#34;PE2Q-NOIT-BG7-TGB&#34;)
 *             .invoiceSectionName(&#34;MTT4-OBS7-PJA-TGB&#34;)
 *             .build());
 * 
 *         var exampleSubscription = new Subscription(&#34;exampleSubscription&#34;, SubscriptionArgs.builder()        
 *             .subscriptionName(&#34;My Example MCA Subscription&#34;)
 *             .billingScopeId(exampleMcaAccountScope.applyValue(getMcaAccountScopeResult -&gt; getMcaAccountScopeResult.id()))
 *             .build());
 * 
 *     }
 * }
 * ```
 * ### Creating A New Alias And Subscription For A Microsoft Partner Account
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azure.billing.BillingFunctions;
 * import com.pulumi.azure.billing.inputs.GetMpaAccountScopeArgs;
 * import com.pulumi.azure.core.Subscription;
 * import com.pulumi.azure.core.SubscriptionArgs;
 * 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) {
 *         final var exampleMpaAccountScope = BillingFunctions.getMpaAccountScope(GetMpaAccountScopeArgs.builder()
 *             .billingAccountName(&#34;e879cf0f-2b4d-5431-109a-f72fc9868693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31&#34;)
 *             .customerName(&#34;2281f543-7321-4cf9-1e23-edb4Oc31a31c&#34;)
 *             .build());
 * 
 *         var exampleSubscription = new Subscription(&#34;exampleSubscription&#34;, SubscriptionArgs.builder()        
 *             .subscriptionName(&#34;My Example MPA Subscription&#34;)
 *             .billingScopeId(exampleMpaAccountScope.applyValue(getMpaAccountScopeResult -&gt; getMpaAccountScopeResult.id()))
 *             .build());
 * 
 *     }
 * }
 * ```
 * ### Adding An Alias To An Existing Subscription
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azure.core.Subscription;
 * import com.pulumi.azure.core.SubscriptionArgs;
 * 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 example = new Subscription(&#34;example&#34;, SubscriptionArgs.builder()        
 *             .alias(&#34;examplesub&#34;)
 *             .subscriptionId(&#34;12345678-12234-5678-9012-123456789012&#34;)
 *             .subscriptionName(&#34;My Example Subscription&#34;)
 *             .build());
 * 
 *     }
 * }
 * ```
 * 
 * ## Import
 * 
 * Subscriptions can be imported using the `resource id`, e.g.
 * 
 * ```sh
 *  $ pulumi import azure:core/subscription:Subscription example &#34;/providers/Microsoft.Subscription/aliases/subscription1&#34;
 * ```
 * 
 *  In this scenario, the `subscription_id` property can be completed and the provider will assume control of the existing subscription by creating an Alias. See the `adding an Alias to an existing Subscription` above. This provider requires an alias to correctly manage Subscription resources due to Azure Subscription API design.
 * 
 */
@ResourceType(type="azure:core/subscription:Subscription")
public class Subscription extends com.pulumi.resources.CustomResource {
    /**
     * The Alias name for the subscription. This provider will generate a new GUID if this is not supplied. Changing this forces a new Subscription to be created.
     * 
     */
    @Export(name="alias", refs={String.class}, tree="[0]")
    private Output<String> alias;

    /**
     * @return The Alias name for the subscription. This provider will generate a new GUID if this is not supplied. Changing this forces a new Subscription to be created.
     * 
     */
    public Output<String> alias() {
        return this.alias;
    }
    /**
     * The Azure Billing Scope ID. Can be a Microsoft Customer Account Billing Scope ID, a Microsoft Partner Account Billing Scope ID or an Enrollment Billing Scope ID.
     * 
     */
    @Export(name="billingScopeId", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> billingScopeId;

    /**
     * @return The Azure Billing Scope ID. Can be a Microsoft Customer Account Billing Scope ID, a Microsoft Partner Account Billing Scope ID or an Enrollment Billing Scope ID.
     * 
     */
    public Output<Optional<String>> billingScopeId() {
        return Codegen.optional(this.billingScopeId);
    }
    /**
     * The ID of the Subscription. Changing this forces a new Subscription to be created.
     * 
     * &gt; **NOTE:** This value can be specified only for adopting control of an existing Subscription, it cannot be used to provide a custom Subscription ID.
     * 
     * &gt; **NOTE:** Either `billing_scope_id` or `subscription_id` has to be specified.
     * 
     */
    @Export(name="subscriptionId", refs={String.class}, tree="[0]")
    private Output<String> subscriptionId;

    /**
     * @return The ID of the Subscription. Changing this forces a new Subscription to be created.
     * 
     * &gt; **NOTE:** This value can be specified only for adopting control of an existing Subscription, it cannot be used to provide a custom Subscription ID.
     * 
     * &gt; **NOTE:** Either `billing_scope_id` or `subscription_id` has to be specified.
     * 
     */
    public Output<String> subscriptionId() {
        return this.subscriptionId;
    }
    /**
     * The Name of the Subscription. This is the Display Name in the portal.
     * 
     */
    @Export(name="subscriptionName", refs={String.class}, tree="[0]")
    private Output<String> subscriptionName;

    /**
     * @return The Name of the Subscription. This is the Display Name in the portal.
     * 
     */
    public Output<String> subscriptionName() {
        return this.subscriptionName;
    }
    /**
     * A mapping of tags to assign to the Subscription.
     * 
     */
    @Export(name="tags", refs={Map.class,String.class}, tree="[0,1,1]")
    private Output</* @Nullable */ Map<String,String>> tags;

    /**
     * @return A mapping of tags to assign to the Subscription.
     * 
     */
    public Output<Optional<Map<String,String>>> tags() {
        return Codegen.optional(this.tags);
    }
    /**
     * The ID of the Tenant to which the subscription belongs.
     * 
     */
    @Export(name="tenantId", refs={String.class}, tree="[0]")
    private Output<String> tenantId;

    /**
     * @return The ID of the Tenant to which the subscription belongs.
     * 
     */
    public Output<String> tenantId() {
        return this.tenantId;
    }
    /**
     * The workload type of the Subscription. Possible values are `Production` (default) and `DevTest`. Changing this forces a new Subscription to be created.
     * 
     */
    @Export(name="workload", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> workload;

    /**
     * @return The workload type of the Subscription. Possible values are `Production` (default) and `DevTest`. Changing this forces a new Subscription to be created.
     * 
     */
    public Output<Optional<String>> workload() {
        return Codegen.optional(this.workload);
    }

    /**
     *
     * @param name The _unique_ name of the resulting resource.
     */
    public Subscription(String name) {
        this(name, SubscriptionArgs.Empty);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     */
    public Subscription(String name, SubscriptionArgs 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 Subscription(String name, SubscriptionArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("azure:core/subscription:Subscription", name, args == null ? SubscriptionArgs.Empty : args, makeResourceOptions(options, Codegen.empty()));
    }

    private Subscription(String name, Output<String> id, @Nullable SubscriptionState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("azure:core/subscription:Subscription", 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 Subscription get(String name, Output<String> id, @Nullable SubscriptionState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        return new Subscription(name, id, state, options);
    }
}
