# 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
psql_client = OCI::Psql::PostgresqlClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
create_db_system_response =
  psql_client.create_db_system(
    OCI::Psql::Models::CreateDbSystemDetails.new(
      display_name: 'EXAMPLE-displayName-Value',
      compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
      db_version: 'EXAMPLE-dbVersion-Value',
      storage_details:
        OCI::Psql::Models::OciOptimizedStorageDetails.new(
          system_type: 'OCI_OPTIMIZED_STORAGE',
          is_regionally_durable: true,
          availability_domain: 'EXAMPLE-availabilityDomain-Value',
          iops: 74
        ),
      shape: 'EXAMPLE-shape-Value',
      network_details:
        OCI::Psql::Models::NetworkDetails.new(
          subnet_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value',
          primary_db_endpoint_private_ip:
            'EXAMPLE-primaryDbEndpointPrivateIp-Value',
          nsg_ids: %w[EXAMPLE--Value]
        ),
      description: 'EXAMPLE-description-Value',
      system_type: 'OCI_OPTIMIZED_STORAGE',
      config_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-configId-Value',
      instance_ocpu_count: 397,
      instance_memory_size_in_gbs: 956,
      instance_count: 398,
      instances_details: [
        OCI::Psql::Models::CreateDbInstanceDetails.new(
          display_name: 'EXAMPLE-displayName-Value',
          description: 'EXAMPLE-description-Value',
          private_ip: 'EXAMPLE-privateIp-Value'
        )
      ],
      credentials:
        OCI::Psql::Models::Credentials.new(
          username: 'EXAMPLE-username-Value',
          password_details:
            OCI::Psql::Models::PlainTextPasswordDetails.new(
              password_type: 'PLAIN_TEXT', password: 'EXAMPLE-password-Value'
            )
        ),
      management_policy:
        OCI::Psql::Models::ManagementPolicyDetails.new(
          maintenance_window_start: 'EXAMPLE-maintenanceWindowStart-Value',
          backup_policy:
            OCI::Psql::Models::NoneBackupPolicy.new(
              kind: 'NONE', retention_days: 31
            )
        ),
      source: OCI::Psql::Models::NoneSourceDetails.new(source_type: 'NONE'),
      freeform_tags: {
        'EXAMPLE_KEY_oByJ6' => 'EXAMPLE_VALUE_FtnZQuWcjOXTZ4NXzTYB'
      },
      defined_tags: {
        'EXAMPLE_KEY_cLX6b' => { 'EXAMPLE_KEY_ExIDg' => 'EXAMPLE--Value' }
      }
    )
  )

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

Was this article helpful?