# 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 'date'
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
stack_monitoring_client =
  OCI::StackMonitoring::StackMonitoringClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
search_monitored_resources_response =
  stack_monitoring_client.search_monitored_resources(
    OCI::StackMonitoring::Models::SearchMonitoredResourcesDetails.new(
      compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
      compartment_ids: %w[EXAMPLE--Value],
      lifecycle_states: %w[
        CREATING
        UPDATING
        ACTIVE
        INACTIVE
        DELETING
        DELETED
        FAILED
      ],
      source_type: 'COLLECTD',
      resource_category: 'MIDDLEWARE',
      name: 'EXAMPLE-name-Value',
      name_contains: 'EXAMPLE-nameContains-Value',
      type: 'EXAMPLE-type-Value',
      host_name: 'EXAMPLE-hostName-Value',
      external_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-externalId-Value',
      host_name_contains: 'EXAMPLE-hostNameContains-Value',
      management_agent_id:
        'ocid1.test.oc1..<unique_ID>EXAMPLE-managementAgentId-Value',
      lifecycle_state: 'CREATING',
      license: 'ENTERPRISE_EDITION',
      time_created_greater_than_or_equal_to:
        DateTime.parse('2039-08-02T17:51:22.977Z'),
      time_created_less_than: DateTime.parse('2007-03-20T13:59:24.611Z'),
      time_updated_greater_than_or_equal_to:
        DateTime.parse('2003-11-30T06:34:04.415Z'),
      time_updated_less_than: DateTime.parse('2023-03-27T09:42:41.915Z'),
      resource_time_zone: 'EXAMPLE-resourceTimeZone-Value',
      sort_order: 'ASC',
      sort_by: 'TIME_CREATED',
      property_equals: {
        'EXAMPLE_KEY_joxdQ' => 'EXAMPLE_VALUE_3Hfmz2xLnFrQk8hwDSk4'
      }
    )
  )

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