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

import 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.config.from_file()


# Initialize service client with default config file
fleet_apps_management_client = oci.fleet_apps_management.FleetAppsManagementRunbooksClient(
    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(
    create_runbook_details=oci.fleet_apps_management.models.CreateRunbookDetails(
        display_name="EXAMPLE-displayName-Value",
        operation="EXAMPLE-operation-Value",
        runbook_version=oci.fleet_apps_management.models.Version(
            tasks=[
                oci.fleet_apps_management.models.Task(
                    step_name="EXAMPLE-stepName-Value",
                    task_record_details=oci.fleet_apps_management.models.AssociatedLocalTaskDetails(
                        scope="LOCAL",
                        execution_details=oci.fleet_apps_management.models.ScriptBasedExecutionDetails(
                            execution_type="SCRIPT",
                            variables=oci.fleet_apps_management.models.TaskVariable(
                                input_variables=[
                                    oci.fleet_apps_management.models.OutputVariableInputArgument(
                                        type="OUTPUT_VARIABLE",
                                        name="EXAMPLE-name-Value",
                                        description="EXAMPLE-description-Value")],
                                output_variables=["EXAMPLE--Value"]),
                            content=oci.fleet_apps_management.models.CatalogContentDetails(
                                source_type="CATALOG",
                                catalog_id="ocid1.test.oc1..<unique_ID>EXAMPLE-catalogId-Value"),
                            command="EXAMPLE-command-Value",
                            credentials=[
                                oci.fleet_apps_management.models.ConfigAssociationDetails(
                                    id="ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
                                    display_name="EXAMPLE-displayName-Value")],
                            is_locked=True,
                            is_executable_content=False,
                            system_variables=["EXAMPLE--Value"]),
                        description="EXAMPLE-description-Value",
                        platform="EXAMPLE-platform-Value",
                        is_copy_to_library_enabled=True,
                        os_type="GENERIC",
                        properties=oci.fleet_apps_management.models.Properties(
                            num_retries=541,
                            timeout_in_seconds=271),
                        is_discovery_output_task=True,
                        is_apply_subject_task=True,
                        name="EXAMPLE-name-Value"),
                    step_properties=oci.fleet_apps_management.models.ComponentProperties(
                        action_on_failure="CONTINUE",
                        run_on=oci.fleet_apps_management.models.ScheduleInstanceTargetRunOnDetails(
                            kind="SCHEDULE_INSTANCE_TARGETS",
                            condition="EXAMPLE-condition-Value"),
                        pre_condition="EXAMPLE-preCondition-Value",
                        pause_details=oci.fleet_apps_management.models.TimeBasedPauseDetails(
                            kind="TIME_BASED",
                            duration_in_minutes=25),
                        notification_preferences=oci.fleet_apps_management.models.TaskNotificationPreferences(
                            should_notify_on_pause=True,
                            should_notify_on_task_failure=False,
                            should_notify_on_task_success=False)),
                    output_variable_mappings=[
                        oci.fleet_apps_management.models.OutputVariableMapping(
                            name="EXAMPLE-name-Value",
                            output_variable_details=oci.fleet_apps_management.models.OutputVariableDetails(
                                step_name="EXAMPLE-stepName-Value",
                                output_variable_name="EXAMPLE-outputVariableName-Value"))])],
            groups=[
                oci.fleet_apps_management.models.Group(
                    type="PARALLEL_RESOURCE_GROUP",
                    name="EXAMPLE-name-Value",
                    properties=oci.fleet_apps_management.models.ComponentProperties(
                        action_on_failure="ABORT",
                        run_on=oci.fleet_apps_management.models.SelfHostedInstanceRunOnDetails(
                            kind="SELF_HOSTED_INSTANCES",
                            host="EXAMPLE-host-Value"),
                        pre_condition="EXAMPLE-preCondition-Value",
                        pause_details=oci.fleet_apps_management.models.UserActionBasedPauseDetails(
                            kind="USER_ACTION"),
                        notification_preferences=oci.fleet_apps_management.models.TaskNotificationPreferences(
                            should_notify_on_pause=True,
                            should_notify_on_task_failure=True,
                            should_notify_on_task_success=False)))],
            execution_workflow_details=oci.fleet_apps_management.models.ExecutionWorkflowDetails(
                workflow=[
                    oci.fleet_apps_management.models.WorkflowGroup(
                        group_name="EXAMPLE-groupName-Value",
                        type="ROLLING_RESOURCE_GROUP",
                        steps=[
                            oci.fleet_apps_management.models.WorkflowGroupComponent(
                                type="PARALLEL_TASK_GROUP",
                                group_name="EXAMPLE-groupName-Value",
                                steps=["EXAMPLE--Value"])])]),
            rollback_workflow_details=oci.fleet_apps_management.models.RollbackWorkflowDetails(
                scope="ACTION_GROUP",
                workflow=[
                    oci.fleet_apps_management.models.WorkflowGroup(
                        group_name="EXAMPLE-groupName-Value",
                        type="ROLLING_RESOURCE_GROUP",
                        steps=[
                            oci.fleet_apps_management.models.WorkflowTaskComponent(
                                type="TASK",
                                step_name="EXAMPLE-stepName-Value")])]),
            version="EXAMPLE-version-Value",
            is_latest=True),
        compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
        description="EXAMPLE-description-Value",
        os_type="GENERIC",
        platform="EXAMPLE-platform-Value",
        is_default=True,
        is_sudo_access_needed=False,
        estimated_time="EXAMPLE-estimatedTime-Value",
        freeform_tags={
            'EXAMPLE_KEY_5iIKK': 'EXAMPLE_VALUE_76LuNANTEO2fGrEenHps'},
        defined_tags={
            'EXAMPLE_KEY_K03iH': {
                'EXAMPLE_KEY_jiQxF': 'EXAMPLE--Value'}}),
    opc_retry_token="EXAMPLE-opcRetryToken-Value",
    opc_request_id="BKUSQP5TMBHPZIGJKWHE<unique_ID>")

# Get the data from response
print(create_runbook_response.data)