# 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
os_management_hub_client =
  OCI::OsManagementHub::DynamicSetClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
preview_managed_instances_response =
  os_management_hub_client.preview_managed_instances(
    OCI::OsManagementHub::Models::PreviewManagedInstancesDetails.new(
      target_compartments: [
        OCI::OsManagementHub::Models::TargetCompartmentDetails.new(
          compartment_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
          does_include_children: false
        )
      ],
      match_type: 'ANY',
      matching_rule:
        OCI::OsManagementHub::Models::MatchingRule.new(
          tags: [
            OCI::OsManagementHub::Models::DefinedTag.new(
              type: 'DEFINED',
              key: 'EXAMPLE-key-Value',
              value: 'EXAMPLE-value-Value',
              namespace: 'EXAMPLE-namespace-Value'
            )
          ],
          managed_instance_ids: %w[EXAMPLE--Value],
          managed_instance_group_ids: %w[EXAMPLE--Value],
          display_names: %w[EXAMPLE--Value],
          os_names: %w[ORACLE_LINUX],
          architectures: %w[AARCH64],
          os_families: %w[UBUNTU_20_04],
          statuses: %w[UNREACHABLE],
          locations: %w[EC2],
          is_reboot_required: false
        ),
      freeform_tags: {
        'EXAMPLE_KEY_CnT7h' => 'EXAMPLE_VALUE_Eyg3RSTiFhUg8k1hA392'
      },
      defined_tags: {
        'EXAMPLE_KEY_Hx80O' => { 'EXAMPLE_KEY_cXvTL' => 'EXAMPLE--Value' }
      }
    )
  )

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