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

namespace Oci.Sdk.DotNet.Example.Fleetappsmanagement
{
    public class CreateRunbookVersionExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var createRunbookVersionDetails = new Oci.FleetappsmanagementService.Models.CreateRunbookVersionDetails
			{
				RunbookId = "ocid1.test.oc1..<unique_ID>EXAMPLE-runbookId-Value",
				Tasks = new List<Oci.FleetappsmanagementService.Models.Task>
				{
					new Oci.FleetappsmanagementService.Models.Task
					{
						StepName = "EXAMPLE-stepName-Value",
						TaskRecordDetails = new Oci.FleetappsmanagementService.Models.AssociatedSharedTaskDetails
						{
							TaskRecordId = "ocid1.test.oc1..<unique_ID>EXAMPLE-taskRecordId-Value"
						},
						StepProperties = new Oci.FleetappsmanagementService.Models.ComponentProperties
						{
							RunOn = new Oci.FleetappsmanagementService.Models.ScheduleInstanceRunOnDetails
							{
								Condition = "EXAMPLE-condition-Value"
							},
							PreCondition = "EXAMPLE-preCondition-Value",
							ActionOnFailure = Oci.FleetappsmanagementService.Models.ComponentProperties.ActionOnFailureEnum.Rollback,
							PauseDetails = new Oci.FleetappsmanagementService.Models.TimeBasedPauseDetails
							{
								DurationInMinutes = 355
							},
							NotificationPreferences = new Oci.FleetappsmanagementService.Models.TaskNotificationPreferences
							{
								ShouldNotifyOnPause = false,
								ShouldNotifyOnTaskFailure = false,
								ShouldNotifyOnTaskSuccess = true
							}
						},
						OutputVariableMappings = new List<Oci.FleetappsmanagementService.Models.OutputVariableMapping>
						{
							new Oci.FleetappsmanagementService.Models.OutputVariableMapping
							{
								Name = "EXAMPLE-name-Value",
								OutputVariableDetails = new Oci.FleetappsmanagementService.Models.OutputVariableDetails
								{
									StepName = "EXAMPLE-stepName-Value",
									OutputVariableName = "EXAMPLE-outputVariableName-Value"
								}
							}
						}
					}
				},
				Groups = new List<Oci.FleetappsmanagementService.Models.Group>
				{
					new Oci.FleetappsmanagementService.Models.Group
					{
						Type = Oci.FleetappsmanagementService.Models.Group.TypeEnum.ParallelTaskGroup,
						Name = "EXAMPLE-name-Value",
						Properties = new Oci.FleetappsmanagementService.Models.ComponentProperties
						{
							RunOn = new Oci.FleetappsmanagementService.Models.ScheduleInstanceTargetRunOnDetails
							{
								Condition = "EXAMPLE-condition-Value"
							},
							PreCondition = "EXAMPLE-preCondition-Value",
							ActionOnFailure = Oci.FleetappsmanagementService.Models.ComponentProperties.ActionOnFailureEnum.Rollback,
							PauseDetails = new Oci.FleetappsmanagementService.Models.TimeBasedPauseDetails
							{
								DurationInMinutes = 927
							},
							NotificationPreferences = new Oci.FleetappsmanagementService.Models.TaskNotificationPreferences
							{
								ShouldNotifyOnPause = false,
								ShouldNotifyOnTaskFailure = true,
								ShouldNotifyOnTaskSuccess = false
							}
						}
					}
				},
				ExecutionWorkflowDetails = new Oci.FleetappsmanagementService.Models.ExecutionWorkflowDetails
				{
					Workflow = new List<Oci.FleetappsmanagementService.Models.WorkflowGroup>
					{
						new Oci.FleetappsmanagementService.Models.WorkflowGroup
						{
							GroupName = "EXAMPLE-groupName-Value",
							Type = Oci.FleetappsmanagementService.Models.WorkflowGroup.TypeEnum.RollingResourceGroup,
							Steps = new List<Oci.FleetappsmanagementService.Models.WorkflowComponent>
							{
								new Oci.FleetappsmanagementService.Models.WorkflowTaskComponent
								{
									StepName = "EXAMPLE-stepName-Value"
								}
							}
						}
					}
				},
				RollbackWorkflowDetails = new Oci.FleetappsmanagementService.Models.RollbackWorkflowDetails
				{
					Scope = Oci.FleetappsmanagementService.Models.RollbackWorkflowDetails.ScopeEnum.ActionGroup,
					Workflow = new List<Oci.FleetappsmanagementService.Models.WorkflowGroup>
					{
						new Oci.FleetappsmanagementService.Models.WorkflowGroup
						{
							GroupName = "EXAMPLE-groupName-Value",
							Type = Oci.FleetappsmanagementService.Models.WorkflowGroup.TypeEnum.ParallelResourceGroup,
							Steps = new List<Oci.FleetappsmanagementService.Models.WorkflowComponent>
							{
								new Oci.FleetappsmanagementService.Models.WorkflowGroupComponent
								{
									GroupName = "EXAMPLE-groupName-Value",
									Steps = new List<string>
									{
										"EXAMPLE--Value"
									}
								}
							}
						}
					}
				},
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_AgCzi", 
						"EXAMPLE_VALUE_d8etSVo9H4I1CXCccTdQ"
					}
				},
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_L0l14", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_M4TDZ", 
								"EXAMPLE--Value"
							}
						}
					}
				}
			};
			var createRunbookVersionRequest = new Oci.FleetappsmanagementService.Requests.CreateRunbookVersionRequest
			{
				CreateRunbookVersionDetails = createRunbookVersionDetails,
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
				OpcRequestId = "WC3RB1PSM86H2MS1DSF0<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 FleetAppsManagementRunbooksClient(provider, new ClientConfiguration()))
				{
					var response = await client.CreateRunbookVersion(createRunbookVersionRequest);
					// Retrieve value from the response.
					var id = response.RunbookVersion.Id;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"CreateRunbookVersion Failed with {e.Message}");
                throw e;
            }
        }

    }
}