// 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.DatabaseService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Database
{
public class CreateDataGuardAssociationExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createDataGuardAssociationDetails = new Oci.DatabaseService.Models.CreateDataGuardAssociationWithNewDbSystemDetails
{
DisplayName = "EXAMPLE-displayName-Value",
AvailabilityDomain = "EXAMPLE-availabilityDomain-Value",
Shape = "EXAMPLE-shape-Value",
CpuCoreCount = 35,
StorageVolumePerformanceMode = Oci.DatabaseService.Models.CreateDataGuardAssociationWithNewDbSystemDetails.StorageVolumePerformanceModeEnum.Balanced,
ComputeModel = Oci.DatabaseService.Models.CreateDataGuardAssociationWithNewDbSystemDetails.ComputeModelEnum.Ecpu,
ComputeCount = 377,
NodeCount = 1,
SubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
NsgIds = new List<string>
{
"EXAMPLE--Value"
},
BackupNetworkNsgIds = new List<string>
{
"EXAMPLE--Value"
},
Hostname = "EXAMPLE-hostname-Value",
Domain = "EXAMPLE-domain-Value",
TimeZone = "EXAMPLE-timeZone-Value",
FaultDomains = new List<string>
{
"EXAMPLE--Value"
},
PrivateIp = "EXAMPLE-privateIp-Value",
PrivateIpV6 = "EXAMPLE-privateIpV6-Value",
LicenseModel = Oci.DatabaseService.Models.CreateDataGuardAssociationWithNewDbSystemDetails.LicenseModelEnum.LicenseIncluded,
DbSystemFreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_g3OaQ",
"EXAMPLE_VALUE_p1yUA1ZZtmmwJUGWOvb2"
}
},
DbSystemDefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_4MCnf",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_yvrnb",
"EXAMPLE--Value"
}
}
}
},
DbSystemSecurityAttributes = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_K9OMt",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_3FBVX",
"EXAMPLE--Value"
}
}
}
},
DatabaseFreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_AIJSE",
"EXAMPLE_VALUE_vBCMzpMbDmcc5WoMCrOV"
}
},
DatabaseDefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_X52fj",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_M1rqA",
"EXAMPLE--Value"
}
}
}
},
DataCollectionOptions = new Oci.DatabaseService.Models.DataCollectionOptions
{
IsDiagnosticsEventsEnabled = false,
IsHealthMonitoringEnabled = false,
IsIncidentLogsEnabled = false
},
ClusterPlacementGroupId = "ocid1.test.oc1..<unique_ID>EXAMPLE-clusterPlacementGroupId-Value",
SubscriptionId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subscriptionId-Value",
DatabaseSoftwareImageId = "ocid1.test.oc1..<unique_ID>EXAMPLE-databaseSoftwareImageId-Value",
DatabaseAdminPassword = "EXAMPLE-databaseAdminPassword-Value",
SourceEncryptionKeyLocationDetails = new Oci.DatabaseService.Models.ExternalHsmEncryptionDetails
{
HsmPassword = "EXAMPLE-hsmPassword-Value"
},
ProtectionMode = Oci.DatabaseService.Models.CreateDataGuardAssociationDetails.ProtectionModeEnum.MaximumProtection,
TransportType = Oci.DatabaseService.Models.CreateDataGuardAssociationDetails.TransportTypeEnum.Sync,
IsActiveDataGuardEnabled = false,
PeerDbUniqueName = "EXAMPLE-peerDbUniqueName-Value",
PeerSidPrefix = "EXAMPLE-peerSidPrefix-Value"
};
var createDataGuardAssociationRequest = new Oci.DatabaseService.Requests.CreateDataGuardAssociationRequest
{
DatabaseId = "ocid1.test.oc1..<unique_ID>EXAMPLE-databaseId-Value",
CreateDataGuardAssociationDetails = createDataGuardAssociationDetails,
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 DatabaseClient(provider, new ClientConfiguration()))
{
var response = await client.CreateDataGuardAssociation(createDataGuardAssociationRequest);
// Retrieve value from the response.
var id = response.DataGuardAssociation.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateDataGuardAssociation Failed with {e.Message}");
throw e;
}
}
}
}