# 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).

require 'oci'

# Create a default config using DEFAULT profile in default location
# Refer to https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File for more info
config = OCI::ConfigFileLoader.load_config

# Initialize service client with default config file
fleet_apps_management_client =
  OCI::FleetAppsManagement::FleetAppsManagementRunbooksClient.new(
    config: config
  )

# Send the request to service, some parameters are not required, see API doc for more info
create_runbook_response =
  fleet_apps_management_client.create_runbook(
    OCI::FleetAppsManagement::Models::CreateRunbookDetails.new(
      display_name: 'EXAMPLE-displayName-Value',
      operation: 'EXAMPLE-operation-Value',
      runbook_version:
        OCI::FleetAppsManagement::Models::Version.new(
          tasks: [
            OCI::FleetAppsManagement::Models::Task.new(
              step_name: 'EXAMPLE-stepName-Value',
              task_record_details:
                OCI::FleetAppsManagement::Models::AssociatedLocalTaskDetails
                  .new(
                  scope: 'LOCAL',
                  execution_details:
                    OCI::FleetAppsManagement::Models::ApiBasedExecutionDetails
                      .new(
                      execution_type: 'API',
                      endpoint: 'EXAMPLE-endpoint-Value',
                      system_variables: %w[EXAMPLE--Value]
                    ),
                  description: 'EXAMPLE-description-Value',
                  platform: 'EXAMPLE-platform-Value',
                  is_copy_to_library_enabled: false,
                  os_type: 'WINDOWS',
                  properties:
                    OCI::FleetAppsManagement::Models::Properties.new(
                      num_retries: 855, timeout_in_seconds: 736
                    ),
                  is_discovery_output_task: false,
                  is_apply_subject_task: false,
                  name: 'EXAMPLE-name-Value'
                ),
              step_properties:
                OCI::FleetAppsManagement::Models::ComponentProperties.new(
                  action_on_failure: 'ABORT',
                  run_on:
                    OCI::FleetAppsManagement::Models::PreviousTaskInstanceRunOnDetails
                      .new(
                      kind: 'PREVIOUS_TASK_INSTANCES',
                      previous_task_instance_details: [
                        OCI::FleetAppsManagement::Models::PreviousTaskInstanceDetails
                          .new(
                          output_variable_details:
                            OCI::FleetAppsManagement::Models::OutputVariableDetails
                              .new(
                              step_name: 'EXAMPLE-stepName-Value',
                              output_variable_name:
                                'EXAMPLE-outputVariableName-Value'
                            ),
                          resource_id:
                            'ocid1.test.oc1..<unique_ID>EXAMPLE-resourceId-Value',
                          resource_type: 'EXAMPLE-resourceType-Value'
                        )
                      ]
                    ),
                  pre_condition: 'EXAMPLE-preCondition-Value',
                  pause_details:
                    OCI::FleetAppsManagement::Models::UserActionBasedPauseDetails
                      .new(kind: 'USER_ACTION'),
                  notification_preferences:
                    OCI::FleetAppsManagement::Models::TaskNotificationPreferences
                      .new(
                      should_notify_on_pause: true,
                      should_notify_on_task_failure: false,
                      should_notify_on_task_success: true
                    )
                ),
              output_variable_mappings: [
                OCI::FleetAppsManagement::Models::OutputVariableMapping.new(
                  name: 'EXAMPLE-name-Value',
                  output_variable_details:
                    OCI::FleetAppsManagement::Models::OutputVariableDetails.new(
                      step_name: 'EXAMPLE-stepName-Value',
                      output_variable_name: 'EXAMPLE-outputVariableName-Value'
                    )
                )
              ]
            )
          ],
          groups: [
            OCI::FleetAppsManagement::Models::Group.new(
              type: 'PARALLEL_TASK_GROUP',
              name: 'EXAMPLE-name-Value',
              properties:
                OCI::FleetAppsManagement::Models::ComponentProperties.new(
                  action_on_failure: 'ROLLBACK',
                  run_on:
                    OCI::FleetAppsManagement::Models::SelfHostedInstanceRunOnDetails
                      .new(
                      kind: 'SELF_HOSTED_INSTANCES', host: 'EXAMPLE-host-Value'
                    ),
                  pre_condition: 'EXAMPLE-preCondition-Value',
                  pause_details:
                    OCI::FleetAppsManagement::Models::UserActionBasedPauseDetails
                      .new(kind: 'USER_ACTION'),
                  notification_preferences:
                    OCI::FleetAppsManagement::Models::TaskNotificationPreferences
                      .new(
                      should_notify_on_pause: true,
                      should_notify_on_task_failure: false,
                      should_notify_on_task_success: true
                    )
                )
            )
          ],
          execution_workflow_details:
            OCI::FleetAppsManagement::Models::ExecutionWorkflowDetails.new(
              workflow: [
                OCI::FleetAppsManagement::Models::WorkflowGroup.new(
                  group_name: 'EXAMPLE-groupName-Value',
                  type: 'PARALLEL_RESOURCE_GROUP',
                  steps: [
                    OCI::FleetAppsManagement::Models::WorkflowTaskComponent.new(
                      type: 'TASK', step_name: 'EXAMPLE-stepName-Value'
                    )
                  ]
                )
              ]
            ),
          rollback_workflow_details:
            OCI::FleetAppsManagement::Models::RollbackWorkflowDetails.new(
              scope: 'TARGET',
              workflow: [
                OCI::FleetAppsManagement::Models::WorkflowGroup.new(
                  group_name: 'EXAMPLE-groupName-Value',
                  type: 'ROLLING_RESOURCE_GROUP',
                  steps: [
                    OCI::FleetAppsManagement::Models::WorkflowGroupComponent
                      .new(
                      type: 'PARALLEL_TASK_GROUP',
                      group_name: 'EXAMPLE-groupName-Value',
                      steps: %w[EXAMPLE--Value]
                    )
                  ]
                )
              ]
            ),
          version: 'EXAMPLE-version-Value',
          is_latest: true
        ),
      compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
      description: 'EXAMPLE-description-Value',
      os_type: 'LINUX',
      platform: 'EXAMPLE-platform-Value',
      is_default: true,
      is_sudo_access_needed: false,
      estimated_time: 'EXAMPLE-estimatedTime-Value',
      freeform_tags: {
        'EXAMPLE_KEY_S3vto' => 'EXAMPLE_VALUE_XHKJ7OmZwBxnDCYWjFL9'
      },
      defined_tags: {
        'EXAMPLE_KEY_za8EP' => { 'EXAMPLE_KEY_Cf5Fn' => 'EXAMPLE--Value' }
      }
    )
  )

# Get the data from response
puts "#{create_runbook_response.data}"