// 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 UpdateRunbookVersionExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var updateRunbookVersionDetails = new Oci.FleetappsmanagementService.Models.UpdateRunbookVersionDetails
			{
				Tasks = new List<Oci.FleetappsmanagementService.Models.Task>
				{
					new Oci.FleetappsmanagementService.Models.Task
					{
						StepName = "EXAMPLE-stepName-Value",
						TaskRecordDetails = new Oci.FleetappsmanagementService.Models.AssociatedLocalTaskDetails
						{
							ExecutionDetails = new Oci.FleetappsmanagementService.Models.ScriptBasedExecutionDetails
							{
								Variables = new Oci.FleetappsmanagementService.Models.TaskVariable
								{
									InputVariables = new List<Oci.FleetappsmanagementService.Models.InputArgument>
									{
										new Oci.FleetappsmanagementService.Models.StringInputArgument
										{
											Name = "EXAMPLE-name-Value",
											Description = "EXAMPLE-description-Value"
										}
									},
									OutputVariables = new List<string>
									{
										"EXAMPLE--Value"
									}
								},
								Content = new Oci.FleetappsmanagementService.Models.ObjectStorageBucketContentDetails
								{
									NamespaceName = "EXAMPLE-namespaceName-Value",
									BucketName = "EXAMPLE-bucketName-Value",
									ObjectName = "EXAMPLE-objectName-Value",
									Checksum = "EXAMPLE-checksum-Value"
								},
								Command = "EXAMPLE-command-Value",
								Credentials = new List<Oci.FleetappsmanagementService.Models.ConfigAssociationDetails>
								{
									new Oci.FleetappsmanagementService.Models.ConfigAssociationDetails
									{
										Id = "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
										DisplayName = "EXAMPLE-displayName-Value"
									}
								},
								IsLocked = true,
								IsExecutableContent = false,
								SystemVariables = new List<string>
								{
									"EXAMPLE--Value"
								}
							},
							Description = "EXAMPLE-description-Value",
							Platform = "EXAMPLE-platform-Value",
							IsCopyToLibraryEnabled = false,
							OsType = Oci.FleetappsmanagementService.Models.OsType.Generic,
							Properties = new Oci.FleetappsmanagementService.Models.Properties
							{
								NumRetries = 257,
								TimeoutInSeconds = 146
							},
							IsDiscoveryOutputTask = false,
							IsApplySubjectTask = true,
							Name = "EXAMPLE-name-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.UserActionBasedPauseDetails
							{
							},
							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.ParallelResourceGroup,
						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.Abort,
							PauseDetails = new Oci.FleetappsmanagementService.Models.TimeBasedPauseDetails
							{
								DurationInMinutes = 427
							},
							NotificationPreferences = new Oci.FleetappsmanagementService.Models.TaskNotificationPreferences
							{
								ShouldNotifyOnPause = false,
								ShouldNotifyOnTaskFailure = true,
								ShouldNotifyOnTaskSuccess = true
							}
						}
					}
				},
				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.ParallelResourceGroup,
							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.RollingResourceGroup,
							Steps = new List<Oci.FleetappsmanagementService.Models.WorkflowComponent>
							{
								new Oci.FleetappsmanagementService.Models.WorkflowGroupComponent
								{
									GroupName = "EXAMPLE-groupName-Value",
									Steps = new List<string>
									{
										"EXAMPLE--Value"
									}
								}
							}
						}
					}
				}
			};
			var updateRunbookVersionRequest = new Oci.FleetappsmanagementService.Requests.UpdateRunbookVersionRequest
			{
				RunbookVersionId = "ocid1.test.oc1..<unique_ID>EXAMPLE-runbookVersionId-Value",
				UpdateRunbookVersionDetails = updateRunbookVersionDetails,
				IfMatch = "EXAMPLE-ifMatch-Value",
				OpcRequestId = "6XNRYPHQCGWG1T7CG4BT<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.UpdateRunbookVersion(updateRunbookVersionRequest);
					// Retrieve value from the response.
					var versionValue = response.httpResponseMessage.Version;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"UpdateRunbookVersion Failed with {e.Message}");
                throw e;
            }
        }

    }
}