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

namespace Oci.Sdk.DotNet.Example.Stackmonitoring
{
    public class CreateMonitoredResourceExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var createMonitoredResourceDetails = new Oci.StackmonitoringService.Models.CreateMonitoredResourceDetails
			{
				Name = "EXAMPLE-name-Value",
				DisplayName = "EXAMPLE-displayName-Value",
				Type = "EXAMPLE-type-Value",
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				HostName = "EXAMPLE-hostName-Value",
				ExternalId = "ocid1.test.oc1..<unique_ID>EXAMPLE-externalId-Value",
				ManagementAgentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-managementAgentId-Value",
				ResourceTimeZone = "EXAMPLE-resourceTimeZone-Value",
				License = Oci.StackmonitoringService.Models.LicenseType.EnterpriseEditionForGpuInfrastructure,
				Properties = new List<Oci.StackmonitoringService.Models.MonitoredResourceProperty>
				{
					new Oci.StackmonitoringService.Models.MonitoredResourceProperty
					{
						Name = "EXAMPLE-name-Value",
						Value = "EXAMPLE-value-Value"
					}
				},
				DatabaseConnectionDetails = new Oci.StackmonitoringService.Models.ConnectionDetails
				{
					Protocol = Oci.StackmonitoringService.Models.ConnectionDetails.ProtocolEnum.Tcp,
					Port = 51325,
					ConnectorId = "ocid1.test.oc1..<unique_ID>EXAMPLE-connectorId-Value",
					ServiceName = "EXAMPLE-serviceName-Value",
					DbUniqueName = "EXAMPLE-dbUniqueName-Value",
					DbId = "ocid1.test.oc1..<unique_ID>EXAMPLE-dbId-Value",
					SslSecretId = "ocid1.test.oc1..<unique_ID>EXAMPLE-sslSecretId-Value"
				},
				Credentials = new Oci.StackmonitoringService.Models.PreExistingCredentials
				{
					Source = "EXAMPLE-source-Value",
					Name = "EXAMPLE-name-Value",
					Type = "EXAMPLE-type-Value",
					Description = "EXAMPLE-description-Value"
				},
				Aliases = new Oci.StackmonitoringService.Models.MonitoredResourceAliasCredential
				{
					Source = "EXAMPLE-source-Value",
					Name = "EXAMPLE-name-Value",
					Credential = new Oci.StackmonitoringService.Models.MonitoredResourceAliasSourceCredential
					{
						Source = "EXAMPLE-source-Value",
						Name = "EXAMPLE-name-Value",
						Service = "EXAMPLE-service-Value"
					}
				},
				AdditionalCredentials = new List<Oci.StackmonitoringService.Models.MonitoredResourceCredential>
				{
					new Oci.StackmonitoringService.Models.EncryptedCredentials
					{
						KeyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-keyId-Value",
						Properties = new List<Oci.StackmonitoringService.Models.CredentialProperty>
						{
							new Oci.StackmonitoringService.Models.CredentialProperty
							{
								Name = "EXAMPLE-name-Value",
								Value = "EXAMPLE-value-Value"
							}
						},
						Source = "EXAMPLE-source-Value",
						Name = "EXAMPLE-name-Value",
						Type = "EXAMPLE-type-Value",
						Description = "EXAMPLE-description-Value"
					}
				},
				AdditionalAliases = new List<Oci.StackmonitoringService.Models.MonitoredResourceAliasCredential>
				{
					new Oci.StackmonitoringService.Models.MonitoredResourceAliasCredential
					{
						Source = "EXAMPLE-source-Value",
						Name = "EXAMPLE-name-Value",
						Credential = new Oci.StackmonitoringService.Models.MonitoredResourceAliasSourceCredential
						{
							Source = "EXAMPLE-source-Value",
							Name = "EXAMPLE-name-Value",
							Service = "EXAMPLE-service-Value"
						}
					}
				},
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_FzrBB", 
						"EXAMPLE_VALUE_EDGnfzflV5dYBQg9eCjy"
					}
				},
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_sBjjY", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_qZIWV", 
								"EXAMPLE--Value"
							}
						}
					}
				}
			};
			var createMonitoredResourceRequest = new Oci.StackmonitoringService.Requests.CreateMonitoredResourceRequest
			{
				CreateMonitoredResourceDetails = createMonitoredResourceDetails,
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
				OpcRequestId = "CJVN9MUVTYJAZ31YKDSI<unique_ID>",
				ExternalResourceId = "ocid1.test.oc1..<unique_ID>EXAMPLE-externalResourceId-Value"
			};

            // 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 StackMonitoringClient(provider, new ClientConfiguration()))
				{
					var response = await client.CreateMonitoredResource(createMonitoredResourceRequest);
					// Retrieve value from the response.
					var id = response.MonitoredResource.Id;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"CreateMonitoredResource Failed with {e.Message}");
                throw e;
            }
        }

    }
}