// 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 CreateMonitoredResourceTaskExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var createMonitoredResourceTaskDetails = new Oci.StackmonitoringService.Models.CreateMonitoredResourceTaskDetails
			{
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				Name = "EXAMPLE-name-Value",
				TaskDetails = new Oci.StackmonitoringService.Models.UpdateResourceTypeConfigTaskDetails
				{
					HandlerType = Oci.StackmonitoringService.Models.HandlerType.Telegraf,
					ResourceTypesConfiguration = new List<Oci.StackmonitoringService.Models.ResourceTypeConfigDetails>
					{
						new Oci.StackmonitoringService.Models.ResourceTypeConfigDetails
						{
							ResourceType = "EXAMPLE-resourceType-Value",
							AvailabilityMetricsConfig = new Oci.StackmonitoringService.Models.AvailabilityMetricsDetails
							{
								Metrics = new List<string>
								{
									"EXAMPLE--Value"
								},
								CollectionIntervalInSeconds = 285
							},
							HandlerConfig = new Oci.StackmonitoringService.Models.AgentExtensionHandlerConfiguration
							{
								CollectorTypes = new List<string>
								{
									"EXAMPLE--Value"
								},
								MetricUploadIntervalInSeconds = 786,
								TelemetryResourceGroup = "EXAMPLE-telemetryResourceGroup-Value",
								TelegrafResourceNameConfig = new Oci.StackmonitoringService.Models.TelegrafResourceNameConfigurationDetails
								{
									IsUseTagsOnly = true,
									IncludeTags = new List<string>
									{
										"EXAMPLE--Value"
									},
									ExcludeTags = new List<string>
									{
										"EXAMPLE--Value"
									}
								},
								CollectdResourceNameConfig = new Oci.StackmonitoringService.Models.CollectdResourceNameConfigurationDetails
								{
									Suffix = "EXAMPLE-suffix-Value",
									IncludeProperties = new List<string>
									{
										"EXAMPLE--Value"
									},
									ExcludeProperties = new List<string>
									{
										"EXAMPLE--Value"
									}
								},
								MetricNameConfig = new Oci.StackmonitoringService.Models.MetricNameConfigurationDetails
								{
									IsPrefixWithCollectorType = true,
									ExcludePatternOnPrefix = "EXAMPLE-excludePatternOnPrefix-Value"
								},
								MetricMappings = new List<Oci.StackmonitoringService.Models.AgentExtensionHandlerMetricMappingDetails>
								{
									new Oci.StackmonitoringService.Models.AgentExtensionHandlerMetricMappingDetails
									{
										CollectorMetricName = "EXAMPLE-collectorMetricName-Value",
										TelemetryMetricName = "EXAMPLE-telemetryMetricName-Value",
										IsSkipUpload = true,
										MetricUploadIntervalInSeconds = 60
									}
								},
								HandlerProperties = new List<Oci.StackmonitoringService.Models.AgentExtensionHandlerConfigurationProperty>
								{
									new Oci.StackmonitoringService.Models.AgentExtensionHandlerConfigurationProperty
									{
										Name = "EXAMPLE-name-Value",
										Value = "EXAMPLE-value-Value"
									}
								}
							}
						}
					}
				},
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_H27ig", 
						"EXAMPLE_VALUE_CNKqx0LdvRcdNpnLFY5F"
					}
				},
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_E9WJg", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_ZQjTt", 
								"EXAMPLE--Value"
							}
						}
					}
				}
			};
			var createMonitoredResourceTaskRequest = new Oci.StackmonitoringService.Requests.CreateMonitoredResourceTaskRequest
			{
				CreateMonitoredResourceTaskDetails = createMonitoredResourceTaskDetails,
				OpcRequestId = "J2X64OWUY8ZJRVARLZDI<unique_ID>",
				OpcRetryToken = "EXAMPLE-opcRetryToken-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.CreateMonitoredResourceTask(createMonitoredResourceTaskRequest);
					// Retrieve value from the response.
					var id = response.MonitoredResourceTask.Id;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"CreateMonitoredResourceTask Failed with {e.Message}");
                throw e;
            }
        }

    }
}