// This is an automatically generated code sample. 
// To make this code sample work in your Oracle Cloud tenancy, 
// please replace the values for any parameters whose current values do not fit
// your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and 
// boolean, number, and enum parameters with values not fitting your use case).

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oci.SelfService;
using Oci.Common;
using Oci.Common.Auth;

namespace Oci.Sdk.DotNet.Example.Self
{
    public class CreateSubscriptionExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var createSubscriptionDetails = new Oci.SelfService.Models.CreateSubscriptionDetails
			{
				DisplayName = "EXAMPLE-displayName-Value",
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				TenantId = "ocid1.test.oc1..<unique_ID>EXAMPLE-tenantId-Value",
				SubscriptionDetails = new Oci.SelfService.Models.SubscriptionDetails
				{
					PricingPlan = new Oci.SelfService.Models.PricingPlan
					{
						PlanType = Oci.SelfService.Models.PricingPlan.PlanTypeEnum.UsageBased,
						PlanName = "EXAMPLE-planName-Value",
						PlanDescription = "EXAMPLE-planDescription-Value",
						BillingFrequency = Oci.SelfService.Models.BillingFrequency.SemiAnnual,
						PlanDuration = Oci.SelfService.Models.PricingPlan.PlanDurationEnum.Monthly,
						Rates = new List<Oci.SelfService.Models.PricingRate>
						{
							new Oci.SelfService.Models.PricingRate
							{
								Currency = "6mk",
								Rate = (float)4687.3604
							}
						},
						Dimensions = new List<Oci.SelfService.Models.UsageDimension>
						{
							new Oci.SelfService.Models.UsageDimension
							{
								DimensionName = "EXAMPLE-dimensionName-Value",
								DimensionKey = "EXAMPLE-dimensionKey-Value",
								DimensionDescription = "EXAMPLE-dimensionDescription-Value",
								MetricType = Oci.SelfService.Models.MetricType.Each,
								DimensionBillingFrequency = Oci.SelfService.Models.BillingFrequency.Annual,
								IncludedQuantity = (float)6641.628,
							}
						}
					},
					PartnerRegistrationUrl = "EXAMPLE-partnerRegistrationUrl-Value",
					Currency = "3w7",
					Amount = (float)9508.698,
					BillingDetails = new List<Oci.SelfService.Models.BillingDetails>
					{
						new Oci.SelfService.Models.BillingDetails
						{
							PricingPlanKey = "EXAMPLE-pricingPlanKey-Value",
							BillingModel = Oci.SelfService.Models.BillingDetails.BillingModelEnum.FlatRate,
							Sku = "EXAMPLE-sku-Value",
							MetricType = Oci.SelfService.Models.MetricType.OcpuHours,
							RateAllocation = (float)0.89022064,
							HasGovSku = true,
							Meters = new List<Oci.SelfService.Models.Meter>
							{
								new Oci.SelfService.Models.Meter
								{
									Name = "EXAMPLE-name-Value",
									RateAllocation = (float)0.44062293,
									ExtendedMetadata = new List<Oci.SelfService.Models.ExtendedMetadata>
									{
										new Oci.SelfService.Models.ExtendedMetadata
										{
											Key = "EXAMPLE-key-Value",
											Value = "EXAMPLE-value-Value"
										}
									}
								}
							}
						}
					},
					IsAutoRenew = false
				},
				SellerId = "ocid1.test.oc1..<unique_ID>EXAMPLE-sellerId-Value",
				SourceType = Oci.SelfService.Models.SourceType.ThirdParty,
				ProductId = "ocid1.test.oc1..<unique_ID>EXAMPLE-productId-Value",
				AdditionalDetails = new List<Oci.SelfService.Models.ExtendedMetadata>
				{
					new Oci.SelfService.Models.ExtendedMetadata
					{
						Key = "EXAMPLE-key-Value",
						Value = "EXAMPLE-value-Value"
					}
				},
				Realm = "EXAMPLE-realm-Value",
				Region = "EXAMPLE-region-Value",
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_hhdmg", 
						"EXAMPLE_VALUE_y7eYoOqFgmO1Sw10JXio"
					}
				},
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_RwhTM", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_fjztj", 
								"EXAMPLE--Value"
							}
						}
					}
				}
			};
			var createSubscriptionRequest = new Oci.SelfService.Requests.CreateSubscriptionRequest
			{
				CreateSubscriptionDetails = createSubscriptionDetails,
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
				OpcRequestId = "UKGROSJOOUW3GDTXLOHY<unique_ID>"
			};

            // Create a default authentication provider that uses the DEFAULT
            // profile in the configuration file.
            // Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file. 
            var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
            try
            {
                // Create a service client and send the request.
				using (var client = new SubscriptionClient(provider, new ClientConfiguration()))
				{
					var response = await client.CreateSubscription(createSubscriptionRequest);
					// Retrieve value from the response.
					var id = response.Subscription.Id;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"CreateSubscription Failed with {e.Message}");
                throw e;
            }
        }

    }
}