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

namespace Oci.Sdk.DotNet.Example.Cloudguard
{
    public class CreateDetectorRecipeExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var createDetectorRecipeDetails = new Oci.CloudguardService.Models.CreateDetectorRecipeDetails
			{
				DisplayName = "EXAMPLE-displayName-Value",
				Description = "EXAMPLE-description-Value",
				Detector = Oci.CloudguardService.Models.DetectorEnum.IaasThreatDetector,
				SourceDetectorRecipeId = "ocid1.test.oc1..<unique_ID>EXAMPLE-sourceDetectorRecipeId-Value",
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				DetectorRules = new List<Oci.CloudguardService.Models.UpdateDetectorRecipeDetectorRule>
				{
					new Oci.CloudguardService.Models.UpdateDetectorRecipeDetectorRule
					{
						DetectorRuleId = "ocid1.test.oc1..<unique_ID>EXAMPLE-detectorRuleId-Value",
						Details = new Oci.CloudguardService.Models.UpdateDetectorRuleDetails
						{
							IsEnabled = true,
							RiskLevel = Oci.CloudguardService.Models.RiskLevel.High,
							Configurations = new List<Oci.CloudguardService.Models.DetectorConfiguration>
							{
								new Oci.CloudguardService.Models.DetectorConfiguration
								{
									ConfigKey = "EXAMPLE-configKey-Value",
									Name = "EXAMPLE-name-Value",
									Value = "EXAMPLE-value-Value",
									DataType = "EXAMPLE-dataType-Value",
									Values = new List<Oci.CloudguardService.Models.ConfigValue>
									{
										new Oci.CloudguardService.Models.ConfigValue
										{
											ListType = Oci.CloudguardService.Models.ConfigurationListItemType.Custom,
											ManagedListType = "EXAMPLE-managedListType-Value",
											Value = "EXAMPLE-value-Value"
										}
									},
									AllowedValuesDataType = "EXAMPLE-allowedValuesDataType-Value",
									AllowedValues = new List<Oci.CloudguardService.Models.PropertyTuple>
									{
										new Oci.CloudguardService.Models.PropertyTuple
										{
											Key = "EXAMPLE-key-Value",
											Value = "EXAMPLE-value-Value"
										}
									},
									AdditionalProperties = new List<Oci.CloudguardService.Models.AdditionalConfigPropertyDefinition>
									{
										new Oci.CloudguardService.Models.AdditionalConfigPropertyDefinition
										{
											PropertyType = Oci.CloudguardService.Models.AdditionalConfigPropertyDefinition.PropertyTypeEnum.Hint,
											Key = "EXAMPLE-key-Value",
											Value = "EXAMPLE-value-Value"
										}
									}
								}
							},
							Condition = new Oci.CloudguardService.Models.CompositeCondition
							{
								CompositeOperator = Oci.CloudguardService.Models.CompositeCondition.CompositeOperatorEnum.Or,
							},
							Labels = new List<string>
							{
								"EXAMPLE--Value"
							},
							Description = "EXAMPLE-description-Value",
							Recommendation = "EXAMPLE-recommendation-Value",
							DataSourceId = "ocid1.test.oc1..<unique_ID>EXAMPLE-dataSourceId-Value",
							EntitiesMappings = new List<Oci.CloudguardService.Models.EntitiesMapping>
							{
								new Oci.CloudguardService.Models.EntitiesMapping
								{
									DisplayName = "EXAMPLE-displayName-Value",
									QueryField = "EXAMPLE-queryField-Value",
									EntityType = Oci.CloudguardService.Models.EntityType.InternalIp
								}
							}
						}
					}
				},
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_v94bH", 
						"EXAMPLE_VALUE_Qcaq2hTKIcrnkgwlPnJQ"
					}
				},
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_dUhPH", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_shV7P", 
								"EXAMPLE--Value"
							}
						}
					}
				}
			};
			var createDetectorRecipeRequest = new Oci.CloudguardService.Requests.CreateDetectorRecipeRequest
			{
				CreateDetectorRecipeDetails = createDetectorRecipeDetails,
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
				OpcRequestId = "3T2HNXB9KFN9OASI9HV3<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 CloudGuardClient(provider, new ClientConfiguration()))
				{
					var response = await client.CreateDetectorRecipe(createDetectorRecipeRequest);
					// Retrieve value from the response.
					var id = response.DetectorRecipe.Id;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"CreateDetectorRecipe Failed with {e.Message}");
                throw e;
            }
        }

    }
}