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

namespace Oci.Sdk.DotNet.Example.Opsi
{
    public class CreateDatabaseInsightExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var createDatabaseInsightDetails = new Oci.OpsiService.Models.CreatePeComanagedDatabaseInsightDetails
			{
				DatabaseId = "ocid1.test.oc1..<unique_ID>EXAMPLE-databaseId-Value",
				DatabaseResourceType = "EXAMPLE-databaseResourceType-Value",
				OpsiPrivateEndpointId = "ocid1.test.oc1..<unique_ID>EXAMPLE-opsiPrivateEndpointId-Value",
				DbmPrivateEndpointId = "ocid1.test.oc1..<unique_ID>EXAMPLE-dbmPrivateEndpointId-Value",
				ServiceName = "EXAMPLE-serviceName-Value",
				CredentialDetails = new Oci.OpsiService.Models.CredentialByNamedCredentials
				{
					NamedCredentialId = "ocid1.test.oc1..<unique_ID>EXAMPLE-namedCredentialId-Value",
					CredentialSourceName = "EXAMPLE-credentialSourceName-Value"
				},
				ConnectionDetails = new Oci.OpsiService.Models.PeComanagedDatabaseConnectionDetails
				{
					Hosts = new List<Oci.OpsiService.Models.PeComanagedDatabaseHostDetails>
					{
						new Oci.OpsiService.Models.PeComanagedDatabaseHostDetails
						{
							HostIp = "EXAMPLE-hostIp-Value",
							Port = 63455
						}
					},
					Protocol = Oci.OpsiService.Models.PeComanagedDatabaseConnectionDetails.ProtocolEnum.Tcps,
					ServiceName = "EXAMPLE-serviceName-Value"
				},
				DeploymentType = Oci.OpsiService.Models.CreatePeComanagedDatabaseInsightDetails.DeploymentTypeEnum.BareMetal,
				SystemTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_olA14", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_ejxtL", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_39rrR", 
						"EXAMPLE_VALUE_u3mAahdmJ0M1KMbswyTb"
					}
				},
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_x1Aji", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_Sm5B1", 
								"EXAMPLE--Value"
							}
						}
					}
				}
			};
			var createDatabaseInsightRequest = new Oci.OpsiService.Requests.CreateDatabaseInsightRequest
			{
				CreateDatabaseInsightDetails = createDatabaseInsightDetails,
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
				OpcRequestId = "LI209EIXDIALWENRPTUA<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 OperationsInsightsClient(provider, new ClientConfiguration()))
				{
					var response = await client.CreateDatabaseInsight(createDatabaseInsightRequest);
					// Retrieve value from the response.
					var id = response.DatabaseInsight.Id;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"CreateDatabaseInsight Failed with {e.Message}");
                throw e;
            }
        }

    }
}

Was this article helpful?