Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する
Commands Reference

Put Sync


The Put Sync command allows you to update the status and details of an ongoing or completed object synchronization process within your DID Space's audit logs. This is crucial for maintaining accurate records of your data synchronization activities, providing insights into their success or failure, and tracking performance metrics.

This command complements the Post Sync command, which is used to initiate and record new synchronization events. You can also List Logs to retrieve existing audit log entries.

Update Sync Log#

Use the PutObjectsSyncCommand to update an existing audit log entry for an object synchronization. This is typically used to mark a synchronization as complete (success or failure) and provide detailed statistics.

Parameters#

Name

Type

Description

id

string

The unique identifier of the audit log entry to update. This ID is typically obtained when the synchronization process is first posted.

status

AuditLogStatus

The current status of the synchronization process. Valid values are SUCCESS, FAILURE, or PENDING.

reason

string (optional)

A descriptive reason for the status update. This is particularly useful for explaining FAILURE statuses.

totalCount

number

The total number of objects involved in the synchronization operation.

errorCount

number

The number of objects that failed to synchronize during the process.

successCount

number (optional)

The number of objects that were successfully synchronized.

size

number

The total size (in bytes) of the data synchronized.

duration

number

The total duration (in milliseconds) the synchronization process took to complete.

Returns#

Name

Type

Description

statusCode

number

The HTTP status code of the API response.

statusMessage

string

The HTTP status message corresponding to the statusCode.

data

AuditLogModel<AuditLogAction.APP_OBJECTS_SYNC>

The updated audit log entry object, including its ID, status, reason, action type, and detailed data (totalCount, errorCount, successCount, size, duration).

Example#

import { SpaceClient } from '@did-space/client';
import { PutObjectsSyncCommand } from '@did-space/client/lib/commands/audit-log/put-objects-sync-command';
import { AuditLogStatus } from '@did-space/constants';

// Assume client setup with endpoint and wallet
const client = new SpaceClient({
endpoint: 'https://your-did-space-endpoint.com/api',
wallet: YOUR_DID_WALLET_INSTANCE, // Replace with your actual DID Wallet instance
});

async function updateObjectsSyncAuditLog(logId: string) {
try {
const result = await client.send(new PutObjectsSyncCommand({
id: logId,
status: AuditLogStatus.SUCCESS, // Mark as successful
reason: 'All files synchronized successfully.',
totalCount: 150,
errorCount: 0,
successCount: 150,
size: 78912345, // Approximately 75 MB
duration: 180000, // 3 minutes
}));

console.log('Audit log updated:');
console.log(`Status Code: ${result.statusCode}`);
console.log(`Log ID: ${result.data.id}`);
console.log(`New Status: ${result.data.status}`);
console.log(`Total Objects: ${result.data.data.totalCount}`);
console.log(`Errors: ${result.data.data.errorCount}`);
} catch (error) {
console.error('Failed to update audit log:', error);
}
}

// To use, replace 'your-sync-log-id' with an actual audit log ID from a previously posted sync operation.
// updateObjectsSyncAuditLog('your-sync-log-id');

This example demonstrates how to update an existing audit log entry for an object synchronization. It sets the status to SUCCESS, provides a reason, and updates the counts, size, and duration of the synchronized data. This allows for comprehensive tracking of synchronization job outcomes.

Synchronization Audit Log Flow#

Upon Completion/Failure

Success

Failure

Query Logs

Start: Initiated Sync (Post Sync)

Sync Process Running

Update Sync Log (Put Sync)

Audit Log Entry: SUCCESS

Audit Log Entry: FAILURE

End: Sync Recorded

List Logs


Conclusion#

The Put Sync command is essential for providing detailed status updates and metrics for your object synchronization tasks. By using this command, you ensure that your DID Space's audit logs accurately reflect the state and outcome of all synchronization operations.

To view the updated log entries, refer to the List Logs command. For a broader understanding of all audit log operations, visit the main Audit Log section.