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 |
---|---|---|
|
| The unique identifier of the audit log entry to update. This ID is typically obtained when the synchronization process is first posted. |
|
| The current status of the synchronization process. Valid values are |
|
| A descriptive reason for the status update. This is particularly useful for explaining |
|
| The total number of objects involved in the synchronization operation. |
|
| The number of objects that failed to synchronize during the process. |
|
| The number of objects that were successfully synchronized. |
|
| The total size (in bytes) of the data synchronized. |
|
| The total duration (in milliseconds) the synchronization process took to complete. |
Returns#
Name | Type | Description |
---|---|---|
|
| The HTTP status code of the API response. |
|
| The HTTP status message corresponding to the |
|
| 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#
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.