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

import com.pulumi.azure.Utilities;
import com.pulumi.azure.apimanagement.SubscriptionArgs;
import com.pulumi.azure.apimanagement.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.Boolean;
import java.lang.String;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * Manages a Subscription within a API Management Service.
 * 
 * ## Example Usage
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azure.apimanagement.ApimanagementFunctions;
 * import com.pulumi.azure.apimanagement.inputs.GetServiceArgs;
 * import com.pulumi.azure.apimanagement.inputs.GetProductArgs;
 * import com.pulumi.azure.apimanagement.inputs.GetUserArgs;
 * import com.pulumi.azure.apimanagement.Subscription;
 * import com.pulumi.azure.apimanagement.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 exampleService = ApimanagementFunctions.getService(GetServiceArgs.builder()
 *             .name(&#34;example-apim&#34;)
 *             .resourceGroupName(&#34;example-resources&#34;)
 *             .build());
 * 
 *         final var exampleProduct = ApimanagementFunctions.getProduct(GetProductArgs.builder()
 *             .productId(&#34;00000000-0000-0000-0000-000000000000&#34;)
 *             .apiManagementName(exampleService.applyValue(getServiceResult -&gt; getServiceResult.name()))
 *             .resourceGroupName(exampleService.applyValue(getServiceResult -&gt; getServiceResult.resourceGroupName()))
 *             .build());
 * 
 *         final var exampleUser = ApimanagementFunctions.getUser(GetUserArgs.builder()
 *             .userId(&#34;11111111-1111-1111-1111-111111111111&#34;)
 *             .apiManagementName(exampleService.applyValue(getServiceResult -&gt; getServiceResult.name()))
 *             .resourceGroupName(exampleService.applyValue(getServiceResult -&gt; getServiceResult.resourceGroupName()))
 *             .build());
 * 
 *         var exampleSubscription = new Subscription(&#34;exampleSubscription&#34;, SubscriptionArgs.builder()        
 *             .apiManagementName(exampleService.applyValue(getServiceResult -&gt; getServiceResult.name()))
 *             .resourceGroupName(exampleService.applyValue(getServiceResult -&gt; getServiceResult.resourceGroupName()))
 *             .userId(exampleUser.applyValue(getUserResult -&gt; getUserResult.id()))
 *             .productId(exampleProduct.applyValue(getProductResult -&gt; getProductResult.id()))
 *             .displayName(&#34;Parser API&#34;)
 *             .build());
 * 
 *     }
 * }
 * ```
 * 
 * ## Import
 * 
 * API Management Subscriptions can be imported using the `resource id`, e.g.
 * 
 * ```sh
 *  $ pulumi import azure:apimanagement/subscription:Subscription example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-resources/providers/Microsoft.ApiManagement/service/example-apim/subscriptions/subscription-name
 * ```
 * 
 */
@ResourceType(type="azure:apimanagement/subscription:Subscription")
public class Subscription extends com.pulumi.resources.CustomResource {
    /**
     * Determines whether tracing can be enabled. Defaults to `true`.
     * 
     */
    @Export(name="allowTracing", refs={Boolean.class}, tree="[0]")
    private Output</* @Nullable */ Boolean> allowTracing;

    /**
     * @return Determines whether tracing can be enabled. Defaults to `true`.
     * 
     */
    public Output<Optional<Boolean>> allowTracing() {
        return Codegen.optional(this.allowTracing);
    }
    /**
     * The ID of the API which should be assigned to this Subscription. Changing this forces a new resource to be created.
     * 
     * &gt; **Info:** Only one of `product_id` and `api_id` can be set. If both are missing `/apis` scope is used for the subscription and all apis are accessible.
     * 
     */
    @Export(name="apiId", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> apiId;

    /**
     * @return The ID of the API which should be assigned to this Subscription. Changing this forces a new resource to be created.
     * 
     * &gt; **Info:** Only one of `product_id` and `api_id` can be set. If both are missing `/apis` scope is used for the subscription and all apis are accessible.
     * 
     */
    public Output<Optional<String>> apiId() {
        return Codegen.optional(this.apiId);
    }
    /**
     * The name of the API Management Service where this Subscription should be created. Changing this forces a new resource to be created.
     * 
     */
    @Export(name="apiManagementName", refs={String.class}, tree="[0]")
    private Output<String> apiManagementName;

    /**
     * @return The name of the API Management Service where this Subscription should be created. Changing this forces a new resource to be created.
     * 
     */
    public Output<String> apiManagementName() {
        return this.apiManagementName;
    }
    /**
     * The display name of this Subscription.
     * 
     */
    @Export(name="displayName", refs={String.class}, tree="[0]")
    private Output<String> displayName;

    /**
     * @return The display name of this Subscription.
     * 
     */
    public Output<String> displayName() {
        return this.displayName;
    }
    /**
     * The primary subscription key to use for the subscription.
     * 
     */
    @Export(name="primaryKey", refs={String.class}, tree="[0]")
    private Output<String> primaryKey;

    /**
     * @return The primary subscription key to use for the subscription.
     * 
     */
    public Output<String> primaryKey() {
        return this.primaryKey;
    }
    /**
     * The ID of the Product which should be assigned to this Subscription. Changing this forces a new resource to be created.
     * 
     * &gt; **Info:** Only one of `product_id` and `api_id` can be set. If both are missing `all_apis` scope is used for the subscription.
     * 
     */
    @Export(name="productId", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> productId;

    /**
     * @return The ID of the Product which should be assigned to this Subscription. Changing this forces a new resource to be created.
     * 
     * &gt; **Info:** Only one of `product_id` and `api_id` can be set. If both are missing `all_apis` scope is used for the subscription.
     * 
     */
    public Output<Optional<String>> productId() {
        return Codegen.optional(this.productId);
    }
    /**
     * The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
     * 
     */
    @Export(name="resourceGroupName", refs={String.class}, tree="[0]")
    private Output<String> resourceGroupName;

    /**
     * @return The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
     * 
     */
    public Output<String> resourceGroupName() {
        return this.resourceGroupName;
    }
    /**
     * The secondary subscription key to use for the subscription.
     * 
     */
    @Export(name="secondaryKey", refs={String.class}, tree="[0]")
    private Output<String> secondaryKey;

    /**
     * @return The secondary subscription key to use for the subscription.
     * 
     */
    public Output<String> secondaryKey() {
        return this.secondaryKey;
    }
    /**
     * The state of this Subscription. Possible values are `active`, `cancelled`, `expired`, `rejected`, `submitted` and `suspended`. Defaults to `submitted`.
     * 
     */
    @Export(name="state", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> state;

    /**
     * @return The state of this Subscription. Possible values are `active`, `cancelled`, `expired`, `rejected`, `submitted` and `suspended`. Defaults to `submitted`.
     * 
     */
    public Output<Optional<String>> state() {
        return Codegen.optional(this.state);
    }
    /**
     * An Identifier which should used as the ID of this Subscription. If not specified a new Subscription ID will be generated. Changing this forces a new resource to be created.
     * 
     */
    @Export(name="subscriptionId", refs={String.class}, tree="[0]")
    private Output<String> subscriptionId;

    /**
     * @return An Identifier which should used as the ID of this Subscription. If not specified a new Subscription ID will be generated. Changing this forces a new resource to be created.
     * 
     */
    public Output<String> subscriptionId() {
        return this.subscriptionId;
    }
    /**
     * The ID of the User which should be assigned to this Subscription. Changing this forces a new resource to be created.
     * 
     */
    @Export(name="userId", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> userId;

    /**
     * @return The ID of the User which should be assigned to this Subscription. Changing this forces a new resource to be created.
     * 
     */
    public Output<Optional<String>> userId() {
        return Codegen.optional(this.userId);
    }

    /**
     *
     * @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:apimanagement/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:apimanagement/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())
            .additionalSecretOutputs(List.of(
                "primaryKey",
                "secondaryKey"
            ))
            .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);
    }
}
