# 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
create_monitored_resource_response =
stack_monitoring_client.create_monitored_resource(
OCI::StackMonitoring::Models::CreateMonitoredResourceDetails.new(
name: 'EXAMPLE-name-Value',
type: 'EXAMPLE-type-Value',
compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
display_name: 'EXAMPLE-displayName-Value',
host_name: 'EXAMPLE-hostName-Value',
external_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-externalId-Value',
management_agent_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-managementAgentId-Value',
resource_time_zone: 'EXAMPLE-resourceTimeZone-Value',
license: 'ENTERPRISE_EDITION',
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: 25_057,
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::PreExistingCredentials.new(
credential_type: 'EXISTING',
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_HjWWG' => 'EXAMPLE_VALUE_BF9F8yFuqBuhLncJXn9m'
},
defined_tags: {
'EXAMPLE_KEY_LYI8d' => { 'EXAMPLE_KEY_9LIXN' => 'EXAMPLE--Value' }
}
)
)
# Get the data from response
puts "#{create_monitored_resource_response.data}"