Chilkat Online Tools

DeleteReplicationTask C# Example

AWS Database Migration Service

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

Chilkat.Rest rest = new Chilkat.Rest();
bool success;

Chilkat.AuthAws authAws = new Chilkat.AuthAws();
authAws.AccessKey = "AWS_ACCESS_KEY";
authAws.SecretKey = "AWS_SECRET_KEY";

// Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
authAws.Region = "us-west-2";
authAws.ServiceName = "dms";
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws);

// URL: https://dms.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.Connect("dms.us-west-2.amazonaws.com",443,true,true);
if (success != true) {
    Debug.WriteLine("ConnectFailReason: " + Convert.ToString(rest.ConnectFailReason));
    Debug.WriteLine(rest.LastErrorText);
    return;
}

// The following code creates the JSON request body.
// The JSON created by this code is shown below.

// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON

Chilkat.JsonObject json = new Chilkat.JsonObject();
json.UpdateString("ReplicationTaskArn","string");

// The JSON request body created by the above code:

// {
//   "ReplicationTaskArn": "string"
// }

rest.AddHeader("Content-Type","application/x-amz-json-1.1");
rest.AddHeader("X-Amz-Target","AmazonDMSv20160101.DeleteReplicationTask");

Chilkat.StringBuilder sbRequestBody = new Chilkat.StringBuilder();
json.EmitSb(sbRequestBody);
Chilkat.StringBuilder sbResponseBody = new Chilkat.StringBuilder();
success = rest.FullRequestSb("POST","/",sbRequestBody,sbResponseBody);
if (success != true) {
    Debug.WriteLine(rest.LastErrorText);
    return;
}

int respStatusCode = rest.ResponseStatusCode;
Debug.WriteLine("response status code = " + Convert.ToString(respStatusCode));
if (respStatusCode != 200) {
    Debug.WriteLine("Response Header:");
    Debug.WriteLine(rest.ResponseHeader);
    Debug.WriteLine("Response Body:");
    Debug.WriteLine(sbResponseBody.GetAsString());
    return;
}

Chilkat.JsonObject jResp = new Chilkat.JsonObject();
jResp.LoadSb(sbResponseBody);

// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.

// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON

string CdcStartPosition = jResp.StringOf("ReplicationTask.CdcStartPosition");
string CdcStopPosition = jResp.StringOf("ReplicationTask.CdcStopPosition");
string LastFailureMessage = jResp.StringOf("ReplicationTask.LastFailureMessage");
string MigrationType = jResp.StringOf("ReplicationTask.MigrationType");
string RecoveryCheckpoint = jResp.StringOf("ReplicationTask.RecoveryCheckpoint");
string ReplicationInstanceArn = jResp.StringOf("ReplicationTask.ReplicationInstanceArn");
string ReplicationTaskArn = jResp.StringOf("ReplicationTask.ReplicationTaskArn");
int ReplicationTaskCreationDate = jResp.IntOf("ReplicationTask.ReplicationTaskCreationDate");
string ReplicationTaskIdentifier = jResp.StringOf("ReplicationTask.ReplicationTaskIdentifier");
string ReplicationTaskSettings = jResp.StringOf("ReplicationTask.ReplicationTaskSettings");
int ReplicationTaskStartDate = jResp.IntOf("ReplicationTask.ReplicationTaskStartDate");
int ElapsedTimeMillis = jResp.IntOf("ReplicationTask.ReplicationTaskStats.ElapsedTimeMillis");
int FreshStartDate = jResp.IntOf("ReplicationTask.ReplicationTaskStats.FreshStartDate");
int FullLoadFinishDate = jResp.IntOf("ReplicationTask.ReplicationTaskStats.FullLoadFinishDate");
int FullLoadProgressPercent = jResp.IntOf("ReplicationTask.ReplicationTaskStats.FullLoadProgressPercent");
int FullLoadStartDate = jResp.IntOf("ReplicationTask.ReplicationTaskStats.FullLoadStartDate");
int StartDate = jResp.IntOf("ReplicationTask.ReplicationTaskStats.StartDate");
int StopDate = jResp.IntOf("ReplicationTask.ReplicationTaskStats.StopDate");
int TablesErrored = jResp.IntOf("ReplicationTask.ReplicationTaskStats.TablesErrored");
int TablesLoaded = jResp.IntOf("ReplicationTask.ReplicationTaskStats.TablesLoaded");
int TablesLoading = jResp.IntOf("ReplicationTask.ReplicationTaskStats.TablesLoading");
int TablesQueued = jResp.IntOf("ReplicationTask.ReplicationTaskStats.TablesQueued");
string SourceEndpointArn = jResp.StringOf("ReplicationTask.SourceEndpointArn");
string Status = jResp.StringOf("ReplicationTask.Status");
string StopReason = jResp.StringOf("ReplicationTask.StopReason");
string TableMappings = jResp.StringOf("ReplicationTask.TableMappings");
string TargetEndpointArn = jResp.StringOf("ReplicationTask.TargetEndpointArn");
string TargetReplicationInstanceArn = jResp.StringOf("ReplicationTask.TargetReplicationInstanceArn");
string TaskData = jResp.StringOf("ReplicationTask.TaskData");

// A sample JSON response body parsed by the above code:

// {
//   "ReplicationTask": {
//     "CdcStartPosition": "string",
//     "CdcStopPosition": "string",
//     "LastFailureMessage": "string",
//     "MigrationType": "string",
//     "RecoveryCheckpoint": "string",
//     "ReplicationInstanceArn": "string",
//     "ReplicationTaskArn": "string",
//     "ReplicationTaskCreationDate": number,
//     "ReplicationTaskIdentifier": "string",
//     "ReplicationTaskSettings": "string",
//     "ReplicationTaskStartDate": number,
//     "ReplicationTaskStats": {
//       "ElapsedTimeMillis": number,
//       "FreshStartDate": number,
//       "FullLoadFinishDate": number,
//       "FullLoadProgressPercent": number,
//       "FullLoadStartDate": number,
//       "StartDate": number,
//       "StopDate": number,
//       "TablesErrored": number,
//       "TablesLoaded": number,
//       "TablesLoading": number,
//       "TablesQueued": number
//     },
//     "SourceEndpointArn": "string",
//     "Status": "string",
//     "StopReason": "string",
//     "TableMappings": "string",
//     "TargetEndpointArn": "string",
//     "TargetReplicationInstanceArn": "string",
//     "TaskData": "string"
//   }
// }