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

namespace Oci.Sdk.DotNet.Example.Adm
{
    public class CreateRemediationRecipeExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var createRemediationRecipeDetails = new Oci.AdmService.Models.CreateRemediationRecipeDetails
			{
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				DisplayName = "EXAMPLE-displayName-Value",
				ScmConfiguration = new Oci.AdmService.Models.OciCodeRepositoryConfiguration
				{
					OciCodeRepositoryId = "ocid1.test.oc1..<unique_ID>EXAMPLE-ociCodeRepositoryId-Value",
					Branch = "EXAMPLE-branch-Value",
					BuildFileLocation = "EXAMPLE-buildFileLocation-Value",
					IsAutomergeEnabled = false
				},
				VerifyConfiguration = new Oci.AdmService.Models.GitLabPipelineConfiguration
				{
					RepositoryUrl = "EXAMPLE-repositoryUrl-Value",
					Username = "EXAMPLE-username-Value",
					PatSecretId = "ocid1.test.oc1..<unique_ID>EXAMPLE-patSecretId-Value",
					TriggerSecretId = "ocid1.test.oc1..<unique_ID>EXAMPLE-triggerSecretId-Value",
					AdditionalParameters = new Dictionary<string, string>()
					{
						{
							"EXAMPLE_KEY_BWbs0", 
							"EXAMPLE_VALUE_wy5gyUFw6BJnNrMAmxpH"
						}
					}
				},
				DetectConfiguration = new Oci.AdmService.Models.DetectConfiguration
				{
					Exclusions = new List<string>
					{
						"EXAMPLE--Value"
					},
					UpgradePolicy = Oci.AdmService.Models.DetectConfiguration.UpgradePolicyEnum.Nearest,
					MaxPermissibleCvssV2Score = (float)9.321152,
					MaxPermissibleCvssV3Score = (float)8.4324255,
					MaxPermissibleSeverity = Oci.AdmService.Models.ConfigSeverity.None
				},
				NetworkConfiguration = new Oci.AdmService.Models.NetworkConfiguration
				{
					SubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
					NsgIds = new List<string>
					{
						"EXAMPLE--Value"
					}
				},
				KnowledgeBaseId = "ocid1.test.oc1..<unique_ID>EXAMPLE-knowledgeBaseId-Value",
				IsRunTriggeredOnKbChange = true,
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_bQpWh", 
						"EXAMPLE_VALUE_o5R369pwjiU1kh0akICf"
					}
				},
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_6B9Gx", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_qyt45", 
								"EXAMPLE--Value"
							}
						}
					}
				}
			};
			var createRemediationRecipeRequest = new Oci.AdmService.Requests.CreateRemediationRecipeRequest
			{
				CreateRemediationRecipeDetails = createRemediationRecipeDetails,
				OpcRequestId = "DI2MWSKROPUCS8M0JETO<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 ApplicationDependencyManagementClient(provider, new ClientConfiguration()))
				{
					var response = await client.CreateRemediationRecipe(createRemediationRecipeRequest);
					// Retrieve value from the response.
					var versionValue = response.httpResponseMessage.Version;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"CreateRemediationRecipe Failed with {e.Message}");
                throw e;
            }
        }

    }
}

Was this article helpful?