// 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.AssociatedLocalTaskDetails
{
ExecutionDetails = new Oci.FleetappsmanagementService.Models.ApiBasedExecutionDetails
{
Endpoint = "EXAMPLE-endpoint-Value",
SystemVariables = new List<string>
{
"EXAMPLE--Value"
}
},
Description = "EXAMPLE-description-Value",
Platform = "EXAMPLE-platform-Value",
IsCopyToLibraryEnabled = false,
OsType = Oci.FleetappsmanagementService.Models.OsType.Windows,
Properties = new Oci.FleetappsmanagementService.Models.Properties
{
NumRetries = 237,
TimeoutInSeconds = 360
},
IsDiscoveryOutputTask = true,
IsApplySubjectTask = true,
Name = "EXAMPLE-name-Value"
},
StepProperties = new Oci.FleetappsmanagementService.Models.ComponentProperties
{
RunOn = new Oci.FleetappsmanagementService.Models.PreviousTaskInstanceRunOnDetails
{
PreviousTaskInstanceDetails = new List<Oci.FleetappsmanagementService.Models.PreviousTaskInstanceDetails>
{
new Oci.FleetappsmanagementService.Models.PreviousTaskInstanceDetails
{
OutputVariableDetails = new Oci.FleetappsmanagementService.Models.OutputVariableDetails
{
StepName = "EXAMPLE-stepName-Value",
OutputVariableName = "EXAMPLE-outputVariableName-Value"
},
ResourceId = "ocid1.test.oc1..<unique_ID>EXAMPLE-resourceId-Value",
ResourceType = "EXAMPLE-resourceType-Value"
}
}
},
PreCondition = "EXAMPLE-preCondition-Value",
ActionOnFailure = Oci.FleetappsmanagementService.Models.ComponentProperties.ActionOnFailureEnum.Continue,
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.ParallelTaskGroup,
Name = "EXAMPLE-name-Value",
Properties = new Oci.FleetappsmanagementService.Models.ComponentProperties
{
RunOn = new Oci.FleetappsmanagementService.Models.PreviousTaskInstanceRunOnDetails
{
PreviousTaskInstanceDetails = new List<Oci.FleetappsmanagementService.Models.PreviousTaskInstanceDetails>
{
new Oci.FleetappsmanagementService.Models.PreviousTaskInstanceDetails
{
OutputVariableDetails = new Oci.FleetappsmanagementService.Models.OutputVariableDetails
{
StepName = "EXAMPLE-stepName-Value",
OutputVariableName = "EXAMPLE-outputVariableName-Value"
},
ResourceId = "ocid1.test.oc1..<unique_ID>EXAMPLE-resourceId-Value",
ResourceType = "EXAMPLE-resourceType-Value"
}
}
},
PreCondition = "EXAMPLE-preCondition-Value",
ActionOnFailure = Oci.FleetappsmanagementService.Models.ComponentProperties.ActionOnFailureEnum.Rollback,
PauseDetails = new Oci.FleetappsmanagementService.Models.TimeBasedPauseDetails
{
DurationInMinutes = 515
},
NotificationPreferences = new Oci.FleetappsmanagementService.Models.TaskNotificationPreferences
{
ShouldNotifyOnPause = true,
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.ParallelResourceGroup,
Steps = new List<Oci.FleetappsmanagementService.Models.WorkflowComponent>
{
new Oci.FleetappsmanagementService.Models.WorkflowGroupComponent
{
GroupName = "EXAMPLE-groupName-Value",
Steps = new List<string>
{
"EXAMPLE--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"
}
}
}
}
}
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_SiIWt",
"EXAMPLE_VALUE_Vc2FfloEQjr8H5jOpsU1"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_vdo1w",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_GZ94t",
"EXAMPLE--Value"
}
}
}
}
};
var createRunbookVersionRequest = new Oci.FleetappsmanagementService.Requests.CreateRunbookVersionRequest
{
CreateRunbookVersionDetails = createRunbookVersionDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "IVVNSADH6XL7UVTMSSY0<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;
}
}
}
}