// 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.DatabasemigrationService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Databasemigration
{
public class CreateMigrationExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createMigrationDetails = new Oci.DatabasemigrationService.Models.CreateMySqlMigrationDetails
{
DataTransferMediumDetails = new Oci.DatabasemigrationService.Models.CreateMySqlObjectStorageDataTransferMediumDetails
{
ObjectStorageBucket = new Oci.DatabasemigrationService.Models.CreateObjectStoreBucket
{
NamespaceName = "EXAMPLE-namespaceName-Value",
BucketName = "EXAMPLE-bucketName-Value"
}
},
InitialLoadSettings = new Oci.DatabasemigrationService.Models.CreateMySqlInitialLoadSettings
{
IsConsistent = true,
IsTzUtc = false,
Compatibility = new List<Oci.DatabasemigrationService.Models.CompatibilityOption>
{
Oci.DatabasemigrationService.Models.CompatibilityOption.ForceInnodb,
Oci.DatabasemigrationService.Models.CompatibilityOption.SkipInvalidAccounts,
Oci.DatabasemigrationService.Models.CompatibilityOption.StripDefiners,
Oci.DatabasemigrationService.Models.CompatibilityOption.StripRestrictedGrants,
Oci.DatabasemigrationService.Models.CompatibilityOption.StripTablespaces,
Oci.DatabasemigrationService.Models.CompatibilityOption.IgnoreWildcardGrants,
Oci.DatabasemigrationService.Models.CompatibilityOption.StripInvalidGrants
},
PrimaryKeyCompatibility = Oci.DatabasemigrationService.Models.PrimaryKeyCompatibility.None,
IsIgnoreExistingObjects = true,
HandleGrantErrors = Oci.DatabasemigrationService.Models.HandleGrantErrors.Ignore,
JobMode = Oci.DatabasemigrationService.Models.JobModeMySql.Full
},
AdvisorSettings = new Oci.DatabasemigrationService.Models.CreateMySqlAdvisorSettings
{
IsSkipAdvisor = true,
IsIgnoreErrors = false
},
ExcludeObjects = new List<Oci.DatabasemigrationService.Models.MySqlDatabaseObject>
{
new Oci.DatabasemigrationService.Models.MySqlDatabaseObject
{
Schema = "EXAMPLE-schema-Value",
ObjectName = "EXAMPLE-objectName-Value",
Type = "EXAMPLE-type-Value"
}
},
IncludeObjects = new List<Oci.DatabasemigrationService.Models.MySqlDatabaseObject>
{
new Oci.DatabasemigrationService.Models.MySqlDatabaseObject
{
Schema = "EXAMPLE-schema-Value",
ObjectName = "EXAMPLE-objectName-Value",
Type = "EXAMPLE-type-Value"
}
},
BulkIncludeExcludeData = "EXAMPLE-bulkIncludeExcludeData-Value",
HubDetails = new Oci.DatabasemigrationService.Models.CreateGoldenGateHubDetails
{
RestAdminCredentials = new Oci.DatabasemigrationService.Models.CreateAdminCredentials
{
Username = "EXAMPLE-username-Value",
Password = "EXAMPLE-password-Value"
},
Url = "EXAMPLE-url-Value",
ComputeId = "ocid1.test.oc1..<unique_ID>EXAMPLE-computeId-Value",
VaultId = "ocid1.test.oc1..<unique_ID>EXAMPLE-vaultId-Value",
KeyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-keyId-Value",
Extract = new Oci.DatabasemigrationService.Models.CreateExtract
{
PerformanceProfile = Oci.DatabasemigrationService.Models.ExtractPerformanceProfile.Medium,
LongTransDuration = 135
},
Replicat = new Oci.DatabasemigrationService.Models.CreateReplicat
{
PerformanceProfile = Oci.DatabasemigrationService.Models.ReplicatPerformanceProfile.High
},
AcceptableLag = 28
},
GgsDetails = new Oci.DatabasemigrationService.Models.CreateMySqlGgsDeploymentDetails
{
Replicat = new Oci.DatabasemigrationService.Models.CreateReplicat
{
PerformanceProfile = Oci.DatabasemigrationService.Models.ReplicatPerformanceProfile.Low
},
AcceptableLag = 28
},
Description = "EXAMPLE-description-Value",
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
Type = Oci.DatabasemigrationService.Models.MigrationTypes.Online,
DisplayName = "EXAMPLE-displayName-Value",
SourceDatabaseConnectionId = "ocid1.test.oc1..<unique_ID>EXAMPLE-sourceDatabaseConnectionId-Value",
TargetDatabaseConnectionId = "ocid1.test.oc1..<unique_ID>EXAMPLE-targetDatabaseConnectionId-Value",
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_x1SWo",
"EXAMPLE_VALUE_NHOm4twUXwe4npKRN3qr"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_KacvL",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_lu4Ll",
"EXAMPLE--Value"
}
}
}
},
AssessmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-assessmentId-Value"
};
var createMigrationRequest = new Oci.DatabasemigrationService.Requests.CreateMigrationRequest
{
CreateMigrationDetails = createMigrationDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "YXZXOXEYJW02EI5IHAMH<unique_ID>"
};
// 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 DatabaseMigrationClient(provider, new ClientConfiguration()))
{
var response = await client.CreateMigration(createMigrationRequest);
// Retrieve value from the response.
var id = response.Migration.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateMigration Failed with {e.Message}");
throw e;
}
}
}
}