// 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).
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oci.MysqlService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Mysql
{
public class CreateDbSystemExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createDbSystemDetails = new Oci.MysqlService.Models.CreateDbSystemDetails
{
DisplayName = "EXAMPLE-displayName-Value",
Description = "EXAMPLE-description-Value",
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
Rest = new Oci.MysqlService.Models.CreateRestDetails
{
Configuration = Oci.MysqlService.Models.RestConfigurationType.DbsystemOnly,
Port = 29681
},
DatabaseConsole = new Oci.MysqlService.Models.CreateDatabaseConsoleDetails
{
Status = Oci.MysqlService.Models.DatabaseConsoleStatus.Disabled,
Port = 50564
},
IsHighlyAvailable = true,
AvailabilityDomain = "EXAMPLE-availabilityDomain-Value",
FaultDomain = "EXAMPLE-faultDomain-Value",
ConfigurationId = "ocid1.test.oc1..<unique_ID>EXAMPLE-configurationId-Value",
ShapeName = "EXAMPLE-shapeName-Value",
MysqlVersion = "EXAMPLE-mysqlVersion-Value",
SubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
NsgIds = new List<string>
{
"EXAMPLE--Value"
},
SecurityAttributes = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_ADnvV",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_ac3kU",
"EXAMPLE--Value"
}
}
}
},
AdminUsername = "EXAMPLE-adminUsername-Value",
AdminPassword = "EXAMPLE-adminPassword-Value",
DataStorageSizeInGBs = 102800,
DataStorage = new Oci.MysqlService.Models.DataStorageDetails
{
IsAutoExpandStorageEnabled = true,
MaxStorageSizeInGBs = 93804
},
HostnameLabel = "EXAMPLE-hostnameLabel-Value",
IpAddress = "EXAMPLE-ipAddress-Value",
IsIpv6Enabled = false,
Ipv6AddressIpv6SubnetCidrPairDetails = new Oci.MysqlService.Models.Ipv6AddressIpv6SubnetCidrPairDetails
{
Ipv6SubnetCidr = "EXAMPLE-ipv6SubnetCidr-Value",
Ipv6Address = "EXAMPLE-ipv6Address-Value"
},
Port = 63781,
PortX = 26320,
BackupPolicy = new Oci.MysqlService.Models.CreateBackupPolicyDetails
{
IsEnabled = false,
SoftDelete = Oci.MysqlService.Models.SoftDelete.Enabled,
CopyPolicies = new List<Oci.MysqlService.Models.CopyPolicy>
{
new Oci.MysqlService.Models.CopyPolicy
{
CopyToRegion = "EXAMPLE-copyToRegion-Value",
BackupCopyRetentionInDays = 7
}
},
WindowStartTime = "EXAMPLE-windowStartTime-Value",
RetentionInDays = 8,
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_u1v5y",
"EXAMPLE_VALUE_48M7m1oqSPkJqXx0U5NB"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_ilWuZ",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_SfREa",
"EXAMPLE--Value"
}
}
}
},
PitrPolicy = new Oci.MysqlService.Models.PitrPolicy
{
IsEnabled = false
}
},
Source = new Oci.MysqlService.Models.CreateDbSystemSourceImportFromUrlDetails
{
SourceUrl = "EXAMPLE-sourceUrl-Value"
},
Maintenance = new Oci.MysqlService.Models.CreateMaintenanceDetails
{
WindowStartTime = "EXAMPLE-windowStartTime-Value",
VersionPreference = Oci.MysqlService.Models.VersionPreference.Newest,
VersionTrackPreference = Oci.MysqlService.Models.VersionTrackPreference.Innovation,
MaintenanceScheduleType = Oci.MysqlService.Models.MaintenanceScheduleType.Early,
MaintenanceDisabledWindows = new List<Oci.MysqlService.Models.MaintenanceDisabledWindow>
{
new Oci.MysqlService.Models.MaintenanceDisabledWindow
{
TimeStart = DateTime.Parse("04/23/2033 21:50:42"),
TimeEnd = DateTime.Parse("09/04/2013 10:52:12")
}
}
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_fg8qr",
"EXAMPLE_VALUE_s26xJrxFSeRkhuztcyMB"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_2sEoH",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_RyGxM",
"EXAMPLE--Value"
}
}
}
},
DeletionPolicy = new Oci.MysqlService.Models.CreateDeletionPolicyDetails
{
AutomaticBackupRetention = Oci.MysqlService.Models.CreateDeletionPolicyDetails.AutomaticBackupRetentionEnum.Delete,
FinalBackup = Oci.MysqlService.Models.CreateDeletionPolicyDetails.FinalBackupEnum.RequireFinalBackup,
IsDeleteProtected = false
},
CrashRecovery = Oci.MysqlService.Models.CrashRecoveryStatus.Disabled,
DatabaseManagement = Oci.MysqlService.Models.DatabaseManagementStatus.Enabled,
SecureConnections = new Oci.MysqlService.Models.SecureConnectionDetails
{
CertificateId = "ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value",
CertificateGenerationType = Oci.MysqlService.Models.CertificateGenerationType.System
},
EncryptData = new Oci.MysqlService.Models.EncryptDataDetails
{
KeyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-keyId-Value",
KeyGenerationType = Oci.MysqlService.Models.KeyGenerationType.System
},
DatabaseMode = Oci.MysqlService.Models.DbSystem.DatabaseModeEnum.ReadOnly,
AccessMode = Oci.MysqlService.Models.DbSystem.AccessModeEnum.Restricted,
CustomerContacts = new List<Oci.MysqlService.Models.CustomerContact>
{
new Oci.MysqlService.Models.CustomerContact
{
Email = "EXAMPLE-email-Value"
}
},
ReadEndpoint = new Oci.MysqlService.Models.CreateReadEndpointDetails
{
IsEnabled = true,
ReadEndpointIpAddress = "EXAMPLE-readEndpointIpAddress-Value",
ReadEndpointIpv6AddressIpv6SubnetCidrPairDetails = new Oci.MysqlService.Models.Ipv6AddressIpv6SubnetCidrPairDetails
{
Ipv6SubnetCidr = "EXAMPLE-ipv6SubnetCidr-Value",
Ipv6Address = "EXAMPLE-ipv6Address-Value"
},
ReadEndpointHostnameLabel = "EXAMPLE-readEndpointHostnameLabel-Value",
ExcludeIps = new List<string>
{
"EXAMPLE--Value"
}
},
TelemetryConfiguration = new Oci.MysqlService.Models.CreateTelemetryConfigurationDetails
{
Logs = new List<Oci.MysqlService.Models.LoggingDestinationConfiguration>
{
new Oci.MysqlService.Models.LoggingDestinationConfiguration
{
Destination = Oci.MysqlService.Models.LoggingDestinationConfiguration.DestinationEnum.LogAnalytics,
DestinationConfigurations = new List<Oci.MysqlService.Models.DestinationConfiguration>
{
new Oci.MysqlService.Models.DestinationConfiguration
{
Key = "EXAMPLE-key-Value",
Value = "EXAMPLE-value-Value"
}
},
LogTypes = new List<Oci.MysqlService.Models.LoggingDestinationConfiguration.LogTypesEnum>
{
Oci.MysqlService.Models.LoggingDestinationConfiguration.LogTypesEnum.GeneralLog
}
}
}
}
};
var createDbSystemRequest = new Oci.MysqlService.Requests.CreateDbSystemRequest
{
CreateDbSystemDetails = createDbSystemDetails,
OpcRequestId = "E6QAUOGGDHFSFEMXJTTG<unique_ID>",
OpcRetryToken = "EXAMPLE-opcRetryToken-Value"
};
// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
try
{
// Create a service client and send the request.
using (var client = new DbSystemClient(provider, new ClientConfiguration()))
{
var response = await client.CreateDbSystem(createDbSystemRequest);
// Retrieve value from the response.
var id = response.DbSystem.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateDbSystem Failed with {e.Message}");
throw e;
}
}
}
}