// 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.CcdoffersService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Ccdoffers
{
public class CreateCcdCommitmentExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createCcdCommitmentDetails = new Oci.CcdoffersService.Models.CreateCcdCommitmentDetails
{
Quantity = 507,
DisplayName = "EXAMPLE-displayName-Value",
SubscriptionId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subscriptionId-Value",
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
FillerTenancyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-fillerTenancyId-Value",
UsageEligibility = new Oci.CcdoffersService.Models.UsageEligibility
{
CompartmentIds = new List<string>
{
"EXAMPLE--Value"
},
Region = "EXAMPLE-region-Value",
AvailabilityDomain = "EXAMPLE-availabilityDomain-Value",
TenancyIds = new List<string>
{
"EXAMPLE--Value"
}
},
SecondarySkus = new List<Oci.CcdoffersService.Models.SecondarySkus>
{
new Oci.CcdoffersService.Models.SecondarySkus
{
Sku = "EXAMPLE-sku-Value",
SkuDisplayName = "EXAMPLE-skuDisplayName-Value",
SkuMetric = "EXAMPLE-skuMetric-Value",
Quantity = 707
}
},
TimeCcdCommitmentStarts = DateTime.Parse("07/11/2004 17:45:43"),
TimeCcdCommitmentEnds = DateTime.Parse("08/19/2000 03:48:37"),
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_SHmZj",
"EXAMPLE_VALUE_ApTPCe6qiJWZfJtUVz3i"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_qelBb",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_pj9ug",
"EXAMPLE--Value"
}
}
}
}
};
var createCcdCommitmentRequest = new Oci.CcdoffersService.Requests.CreateCcdCommitmentRequest
{
CcdOfferId = "ocid1.test.oc1..<unique_ID>EXAMPLE-ccdOfferId-Value",
CreateCcdCommitmentDetails = createCcdCommitmentDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "A8FGZ5VSAA8UE0A1LM6T<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 CcdCommitmentsClient(provider, new ClientConfiguration()))
{
var response = await client.CreateCcdCommitment(createCcdCommitmentRequest);
// Retrieve value from the response.
var id = response.CcdCommitment.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateCcdCommitment Failed with {e.Message}");
throw e;
}
}
}
}