# 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::FleetAppsManagementClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
create_fleet_response =
  fleet_apps_management_client.create_fleet(
    OCI::FleetAppsManagement::Models::CreateFleetDetails.new(
      display_name: 'EXAMPLE-displayName-Value',
      compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
      resource_selection:
        OCI::FleetAppsManagement::Models::DynamicResourceSelection.new(
          resource_selection_type: 'DYNAMIC',
          rule_selection_criteria:
            OCI::FleetAppsManagement::Models::SelectionCriteria.new(
              match_condition: 'ANY',
              rules: [
                OCI::FleetAppsManagement::Models::Rule.new(
                  compartment_id:
                    'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
                  resource_compartment_id:
                    'ocid1.test.oc1..<unique_ID>EXAMPLE-resourceCompartmentId-Value',
                  conditions: [
                    OCI::FleetAppsManagement::Models::Condition.new(
                      attr_group: 'EXAMPLE-attrGroup-Value',
                      attr_key: 'EXAMPLE-attrKey-Value',
                      attr_value: 'EXAMPLE-attrValue-Value'
                    )
                  ],
                  basis: 'EXAMPLE-basis-Value',
                  match_condition: 'MATCH_ALL',
                  compartment_id_in_subtree: true
                )
              ]
            )
        ),
      description: 'EXAMPLE-description-Value',
      details:
        OCI::FleetAppsManagement::Models::GroupFleetDetails.new(
          fleet_type: 'GROUP'
        ),
      products: %w[EXAMPLE--Value],
      environment_type: 'EXAMPLE-environmentType-Value',
      notification_preferences: [
        OCI::FleetAppsManagement::Models::NotificationPreference.new(
          topic_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-topicId-Value',
          compartment_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
          preferences:
            OCI::FleetAppsManagement::Models::Preferences.new(
              upcoming_schedule:
                OCI::FleetAppsManagement::Models::UpcomingSchedule.new(
                  on_upcoming_schedule: false,
                  notify_before: 'EXAMPLE-notifyBefore-Value'
                ),
              on_job_failure: true,
              on_topology_modification: false,
              on_task_pause: false,
              on_task_failure: true,
              on_task_success: false,
              on_resource_non_compliance: false,
              on_runbook_newer_version: false,
              on_job_success: true,
              on_job_start: true,
              on_job_canceled: false,
              on_job_schedule_change: true
            )
        )
      ],
      resources: [
        OCI::FleetAppsManagement::Models::AssociatedFleetResourceDetails.new(
          resource_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-resourceId-Value',
          compartment_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
          tenancy_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-tenancyId-Value',
          fleet_resource_type: 'EXAMPLE-fleetResourceType-Value'
        )
      ],
      credentials: [
        OCI::FleetAppsManagement::Models::AssociatedFleetCredentialDetails.new(
          display_name: 'EXAMPLE-displayName-Value',
          compartment_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
          entity_specifics:
            OCI::FleetAppsManagement::Models::FleetCredentialEntitySpecificDetails
              .new(
              credential_level: 'FLEET',
              variables: [
                OCI::FleetAppsManagement::Models::Variable.new(
                  name: 'EXAMPLE-name-Value', value: 'EXAMPLE-value-Value'
                )
              ]
            ),
          user:
            OCI::FleetAppsManagement::Models::PlainTextCredentialDetails.new(
              credential_type: 'PLAIN_TEXT', value: 'EXAMPLE-value-Value'
            )
        )
      ],
      properties: [
        OCI::FleetAppsManagement::Models::AssociatedFleetPropertyDetails.new(
          compartment_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
          fleet_property_type: 'STRING',
          display_name: 'EXAMPLE-displayName-Value',
          value: 'EXAMPLE-value-Value',
          is_required: false
        )
      ],
      parent_fleet_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-parentFleetId-Value',
      is_target_auto_confirm: false,
      freeform_tags: {
        'EXAMPLE_KEY_ekdrq' => 'EXAMPLE_VALUE_lvzRLAHb8OthAnOzlsDy'
      },
      defined_tags: {
        'EXAMPLE_KEY_MgOsm' => { 'EXAMPLE_KEY_6iSOh' => 'EXAMPLE--Value' }
      }
    )
  )

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