// 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.OceService;
using Oci.Common;
using Oci.Common.Auth;

namespace Oci.Sdk.DotNet.Example.Oce
{
    public class CreateOceInstanceExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var createOceInstanceDetails = new Oci.OceService.Models.CreateOceInstanceDetails
			{
				Description = "EXAMPLE-description-Value",
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				Name = "EXAMPLE-name-Value",
				TenancyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-tenancyId-Value",
				IdcsAccessToken = "EXAMPLE-idcsAccessToken-Value",
				IdentityStripe = new Oci.OceService.Models.IdentityStripeDetails
				{
					ServiceName = "EXAMPLE-serviceName-Value",
					Tenancy = "EXAMPLE-tenancy-Value"
				},
				TenancyName = "EXAMPLE-tenancyName-Value",
				InstanceUsageType = Oci.OceService.Models.CreateOceInstanceDetails.InstanceUsageTypeEnum.Primary,
				AddOnFeatures = new List<string>
				{
					"EXAMPLE--Value"
				},
				ObjectStorageNamespace = "EXAMPLE-objectStorageNamespace-Value",
				AdminEmail = "EXAMPLE-adminEmail-Value",
				UpgradeSchedule = Oci.OceService.Models.OceInstance.UpgradeScheduleEnum.UpgradeImmediately,
				WafPrimaryDomain = "EXAMPLE-wafPrimaryDomain-Value",
				InstanceAccessType = Oci.OceService.Models.CreateOceInstanceDetails.InstanceAccessTypeEnum.Private,
				InstanceLicenseType = Oci.OceService.Models.LicenseType.Byol,
				DrRegion = "EXAMPLE-drRegion-Value",
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_5fu2W", 
						"EXAMPLE_VALUE_AfdYciza6wSb6NmkhSzk"
					}
				},
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_6K4zo", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_K3ykz", 
								"EXAMPLE--Value"
							}
						}
					}
				}
			};
			var createOceInstanceRequest = new Oci.OceService.Requests.CreateOceInstanceRequest
			{
				CreateOceInstanceDetails = createOceInstanceDetails,
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
				OpcRequestId = "EQTDOZSNSGDLH9SJPANN<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 OceInstanceClient(provider, new ClientConfiguration()))
				{
					var response = await client.CreateOceInstance(createOceInstanceRequest);
					// Retrieve value from the response.
					var versionValue = response.httpResponseMessage.Version;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"CreateOceInstance Failed with {e.Message}");
                throw e;
            }
        }

    }
}

Was this article helpful?