# 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
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
update_monitored_resource_response =
  stack_monitoring_client.update_monitored_resource(
    'ocid1.test.oc1..<unique_ID>EXAMPLE-monitoredResourceId-Value',
    OCI::StackMonitoring::Models::UpdateMonitoredResourceDetails.new(
      display_name: 'EXAMPLE-displayName-Value',
      host_name: 'EXAMPLE-hostName-Value',
      resource_time_zone: 'EXAMPLE-resourceTimeZone-Value',
      properties: [
        OCI::StackMonitoring::Models::MonitoredResourceProperty.new(
          name: 'EXAMPLE-name-Value', value: 'EXAMPLE-value-Value'
        )
      ],
      database_connection_details:
        OCI::StackMonitoring::Models::ConnectionDetails.new(
          protocol: 'TCP',
          port: 17_002,
          service_name: 'EXAMPLE-serviceName-Value',
          connector_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-connectorId-Value',
          db_unique_name: 'EXAMPLE-dbUniqueName-Value',
          db_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-dbId-Value',
          ssl_secret_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-sslSecretId-Value'
        ),
      credentials:
        OCI::StackMonitoring::Models::PlainTextCredentials.new(
          credential_type: 'PLAINTEXT',
          properties: [
            OCI::StackMonitoring::Models::CredentialProperty.new(
              name: 'EXAMPLE-name-Value', value: 'EXAMPLE-value-Value'
            )
          ],
          source: 'EXAMPLE-source-Value',
          name: 'EXAMPLE-name-Value',
          type: 'EXAMPLE-type-Value',
          description: 'EXAMPLE-description-Value'
        ),
      aliases:
        OCI::StackMonitoring::Models::MonitoredResourceAliasCredential.new(
          source: 'EXAMPLE-source-Value',
          name: 'EXAMPLE-name-Value',
          credential:
            OCI::StackMonitoring::Models::MonitoredResourceAliasSourceCredential
              .new(
              source: 'EXAMPLE-source-Value',
              name: 'EXAMPLE-name-Value',
              service: 'EXAMPLE-service-Value'
            )
        ),
      additional_credentials: [
        OCI::StackMonitoring::Models::EncryptedCredentials.new(
          credential_type: 'ENCRYPTED',
          key_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-keyId-Value',
          properties: [
            OCI::StackMonitoring::Models::CredentialProperty.new(
              name: 'EXAMPLE-name-Value', value: 'EXAMPLE-value-Value'
            )
          ],
          source: 'EXAMPLE-source-Value',
          name: 'EXAMPLE-name-Value',
          type: 'EXAMPLE-type-Value',
          description: 'EXAMPLE-description-Value'
        )
      ],
      additional_aliases: [
        OCI::StackMonitoring::Models::MonitoredResourceAliasCredential.new(
          source: 'EXAMPLE-source-Value',
          name: 'EXAMPLE-name-Value',
          credential:
            OCI::StackMonitoring::Models::MonitoredResourceAliasSourceCredential
              .new(
              source: 'EXAMPLE-source-Value',
              name: 'EXAMPLE-name-Value',
              service: 'EXAMPLE-service-Value'
            )
        )
      ],
      freeform_tags: {
        'EXAMPLE_KEY_gHM3V' => 'EXAMPLE_VALUE_H376Q5XhJNn30kR5hfzY'
      },
      defined_tags: {
        'EXAMPLE_KEY_8F0j3' => { 'EXAMPLE_KEY_TRKLi' => 'EXAMPLE--Value' }
      }
    )
  )

# Get the data from response
puts "#{update_monitored_resource_response.headers}"

Was this article helpful?