# 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'
require 'date'

# 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
log_analytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
update_ingest_time_rule_response =
  log_analytics_client.update_ingest_time_rule(
    'EXAMPLE-namespaceName-Value',
    'ocid1.test.oc1..<unique_ID>EXAMPLE-ingestTimeRuleId-Value',
    OCI::LogAnalytics::Models::IngestTimeRule.new(
      id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value',
      compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
      display_name: 'EXAMPLE-displayName-Value',
      description: 'EXAMPLE-description-Value',
      freeform_tags: {
        'EXAMPLE_KEY_NcGjK' => 'EXAMPLE_VALUE_bPKoaFnX7yEEL6nmVATL'
      },
      defined_tags: {
        'EXAMPLE_KEY_vkqB9' => { 'EXAMPLE_KEY_1BVL5' => 'EXAMPLE--Value' }
      },
      time_created: DateTime.parse('2017-04-04T03:13:05.574Z'),
      time_updated: DateTime.parse('2019-09-03T15:09:03.545Z'),
      lifecycle_state: 'ACTIVE',
      is_enabled: true,
      conditions:
        OCI::LogAnalytics::Models::IngestTimeRuleFieldCondition.new(
          kind: 'FIELD',
          field_name: 'EXAMPLE-fieldName-Value',
          field_operator: 'EQUAL',
          field_value: 'EXAMPLE-fieldValue-Value',
          additional_conditions: [
            OCI::LogAnalytics::Models::IngestTimeRuleAdditionalFieldCondition
              .new(
              condition_field: 'EXAMPLE-conditionField-Value',
              condition_operator: 'ENDS_WITH',
              condition_value: 'EXAMPLE-conditionValue-Value'
            )
          ]
        ),
      actions: [
        OCI::LogAnalytics::Models::IngestTimeRuleMetricExtractionAction.new(
          type: 'METRIC_EXTRACTION',
          compartment_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
          namespace: 'EXAMPLE-namespace-Value',
          metric_name: 'EXAMPLE-metricName-Value',
          resource_group: 'EXAMPLE-resourceGroup-Value',
          dimensions: %w[EXAMPLE--Value]
        )
      ]
    )
  )

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

Was this article helpful?