# 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
mysql_client = OCI::Mysql::DbSystemClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
create_db_system_response =
  mysql_client.create_db_system(
    OCI::Mysql::Models::CreateDbSystemDetails.new(
      compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
      shape_name: 'EXAMPLE-shapeName-Value',
      subnet_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value',
      display_name: 'EXAMPLE-displayName-Value',
      description: 'EXAMPLE-description-Value',
      rest:
        OCI::Mysql::Models::CreateRestDetails.new(
          configuration: 'DISABLED', port: 2176
        ),
      database_console:
        OCI::Mysql::Models::CreateDatabaseConsoleDetails.new(
          status: 'DISABLED', port: 8281
        ),
      is_highly_available: false,
      availability_domain: 'EXAMPLE-availabilityDomain-Value',
      fault_domain: 'EXAMPLE-faultDomain-Value',
      configuration_id:
        'ocid1.test.oc1..<unique_ID>EXAMPLE-configurationId-Value',
      mysql_version: 'EXAMPLE-mysqlVersion-Value',
      nsg_ids: %w[EXAMPLE--Value],
      security_attributes: {
        'EXAMPLE_KEY_mlvAk' => { 'EXAMPLE_KEY_62cOL' => 'EXAMPLE--Value' }
      },
      admin_username: 'EXAMPLE-adminUsername-Value',
      admin_password: 'EXAMPLE-adminPassword-Value',
      data_storage_size_in_gbs: 67_195,
      data_storage:
        OCI::Mysql::Models::DataStorageDetails.new(
          is_auto_expand_storage_enabled: false, max_storage_size_in_gbs: 49_013
        ),
      hostname_label: 'EXAMPLE-hostnameLabel-Value',
      ip_address: 'EXAMPLE-ipAddress-Value',
      is_ipv6_enabled: true,
      ipv6_address_ipv6_subnet_cidr_pair_details:
        OCI::Mysql::Models::Ipv6AddressIpv6SubnetCidrPairDetails.new(
          ipv6_subnet_cidr: 'EXAMPLE-ipv6SubnetCidr-Value',
          ipv6_address: 'EXAMPLE-ipv6Address-Value'
        ),
      port: 8408,
      port_x: 57_150,
      backup_policy:
        OCI::Mysql::Models::CreateBackupPolicyDetails.new(
          is_enabled: true,
          soft_delete: 'ENABLED',
          copy_policies: [
            OCI::Mysql::Models::CopyPolicy.new(
              copy_to_region: 'EXAMPLE-copyToRegion-Value',
              backup_copy_retention_in_days: 28
            )
          ],
          window_start_time: 'EXAMPLE-windowStartTime-Value',
          retention_in_days: 31,
          freeform_tags: {
            'EXAMPLE_KEY_uXH2T' => 'EXAMPLE_VALUE_BoVyIO4BfYu8yW44KZPh'
          },
          defined_tags: {
            'EXAMPLE_KEY_WSeFl' => { 'EXAMPLE_KEY_ktV45' => 'EXAMPLE--Value' }
          },
          pitr_policy: OCI::Mysql::Models::PitrPolicy.new(is_enabled: true)
        ),
      source:
        OCI::Mysql::Models::CreateDbSystemSourceImportFromUrlDetails.new(
          source_type: 'IMPORTURL', source_url: 'EXAMPLE-sourceUrl-Value'
        ),
      maintenance:
        OCI::Mysql::Models::CreateMaintenanceDetails.new(
          window_start_time: 'EXAMPLE-windowStartTime-Value',
          version_preference: 'NEWEST',
          version_track_preference: 'LONG_TERM_SUPPORT',
          maintenance_schedule_type: 'REGULAR',
          maintenance_disabled_windows: [
            OCI::Mysql::Models::MaintenanceDisabledWindow.new(
              time_start: DateTime.parse('2007-10-12T06:40:26.269Z'),
              time_end: DateTime.parse('2019-09-08T00:39:47.748Z')
            )
          ]
        ),
      freeform_tags: {
        'EXAMPLE_KEY_Mwt8H' => 'EXAMPLE_VALUE_bkidpJDbwMXBOhVOA8DP'
      },
      defined_tags: {
        'EXAMPLE_KEY_fCkWL' => { 'EXAMPLE_KEY_aTJaZ' => 'EXAMPLE--Value' }
      },
      deletion_policy:
        OCI::Mysql::Models::CreateDeletionPolicyDetails.new(
          automatic_backup_retention: 'RETAIN',
          final_backup: 'SKIP_FINAL_BACKUP',
          is_delete_protected: false
        ),
      crash_recovery: 'ENABLED',
      database_management: 'DISABLED',
      secure_connections:
        OCI::Mysql::Models::SecureConnectionDetails.new(
          certificate_generation_type: 'BYOC',
          certificate_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value'
        ),
      encrypt_data:
        OCI::Mysql::Models::EncryptDataDetails.new(
          key_generation_type: 'SYSTEM',
          key_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-keyId-Value'
        ),
      database_mode: 'READ_ONLY',
      access_mode: 'RESTRICTED',
      customer_contacts: [
        OCI::Mysql::Models::CustomerContact.new(email: 'EXAMPLE-email-Value')
      ],
      read_endpoint:
        OCI::Mysql::Models::CreateReadEndpointDetails.new(
          is_enabled: false,
          read_endpoint_ip_address: 'EXAMPLE-readEndpointIpAddress-Value',
          read_endpoint_ipv6_address_ipv6_subnet_cidr_pair_details:
            OCI::Mysql::Models::Ipv6AddressIpv6SubnetCidrPairDetails.new(
              ipv6_subnet_cidr: 'EXAMPLE-ipv6SubnetCidr-Value',
              ipv6_address: 'EXAMPLE-ipv6Address-Value'
            ),
          read_endpoint_hostname_label:
            'EXAMPLE-readEndpointHostnameLabel-Value',
          exclude_ips: %w[EXAMPLE--Value]
        ),
      telemetry_configuration:
        OCI::Mysql::Models::CreateTelemetryConfigurationDetails.new(
          logs: [
            OCI::Mysql::Models::LoggingDestinationConfiguration.new(
              destination: 'OPEN_TELEMETRY',
              destination_configurations: [
                OCI::Mysql::Models::DestinationConfiguration.new(
                  key: 'EXAMPLE-key-Value', value: 'EXAMPLE-value-Value'
                )
              ],
              log_types: %w[GENERAL_LOG]
            )
          ]
        )
    )
  )

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