Zum Hauptinhalt springen

IBotServicesClient

Namespace: Meshmakers.Octo.Sdk.ServiceClient.BotServices

Implementation of the client proxy for bot services.

public interface IBotServicesClient : IServiceClient

Implements IServiceClient

Methods​

GetImportJobStatus(String)​

Gets the status of an import job

Task<JobDto> GetImportJobStatus(string id)

Parameters​

id String
ID of the job

Returns​

Task<JobDto>

DownloadExportRtResultAsync(String, String)​

Caution​

Use DownloadDumpToFileAsync for streaming downloads instead.


Downloads the job result as a binary file.

Task<Byte[]> DownloadExportRtResultAsync(string tenantId, string id)

Parameters​

tenantId String
Tenant ID of the job

id String
ID of the job

Returns​

Task<Byte[]>

DownloadDumpToFileAsync(String, String, String, Action<Int64>, CancellationToken)​

Downloads the dump result directly to a file using streaming (no full byte[] in RAM).

Task DownloadDumpToFileAsync(string tenantId, string jobId, string outputFilePath, Action<long> progressCallback, CancellationToken cancellationToken)

Parameters​

tenantId String
Tenant ID of the job.

jobId String
ID of the completed dump job.

outputFilePath String
The local file path to write the dump to.

progressCallback Action<Int64>
Optional callback for download progress (bytes downloaded).

cancellationToken CancellationToken
A cancellation token.

Returns​

Task

StartRunFixupScriptAsync(String)​

Start a job to run a fixup script for the given tenant.

Task<JobResponseDto> StartRunFixupScriptAsync(string tenantId)

Parameters​

tenantId String
Tenant ID of the job

Returns​

Task<JobResponseDto>
The job response containing the job ID.

RestoreRepositoryWithTusAsync(String, String, String, String, Boolean, Action<Double>, CancellationToken, Boolean)​

Restores the repository using tus resumable upload protocol. The file is uploaded in chunks with resume support, then a restore job is started.

Task<JobResponseDto> RestoreRepositoryWithTusAsync(string tenantId, string databaseName, string filePath, string oldDatabaseName, bool restoreArchiveData, Action<double> progressCallback, CancellationToken cancellationToken, bool overrideForeignOwnership)

Parameters​

tenantId String
The tenant ID for which the repository should be restored.

databaseName String
The name of the database to restore.

filePath String
The backup artifact: a mongodump .tar.gz, or an .octobak.zip container produced by a dump with archive data.

oldDatabaseName String
The (optional) name of the old db. This is required when restoring under a different name.

restoreArchiveData Boolean
When true, CrateDB archive data contained in the backup artifact is restored alongside the Mongo data. Default false restores Mongo only (today's behaviour).

progressCallback Action<Double>
Optional callback reporting upload progress (0.0 to 1.0).

cancellationToken CancellationToken
A cancellation token.

overrideForeignOwnership Boolean
Deliberate administrator override: when true, the restore overwrites a tenant database that records another OctoMesh instance on the same MongoDB server as its owner while no instance registers it any more, instead of refusing it; the service logs the override as a warning naming the owner. A database another instance still registers, and another instance's system database, are refused even with the override.

Returns​

Task<JobResponseDto>
The job response containing the job ID.

Remarks:

Every parameter is required on purpose: a call that leaves any of them out binds to the overload without the override (the signature from in older versions, with its defaults), so existing callers and their mock setups keep binding to the method they bound to before.

RestoreRepositoryWithTusAsync(String, String, String, String, Boolean, Action<Double>, CancellationToken)​

Restores the repository using tus resumable upload protocol, without the ownership override. The signature of the SDK in older versions, unchanged with its defaults, so assemblies compiled against it still bind and source calls with fewer arguments still land here; only a call with every argument and overrideForeignOwnership binds to the overload with the override.

Task<JobResponseDto> RestoreRepositoryWithTusAsync(string tenantId, string databaseName, string filePath, string oldDatabaseName, bool restoreArchiveData, Action<double> progressCallback, CancellationToken cancellationToken)

Parameters​

tenantId String
The tenant ID for which the repository should be restored.

databaseName String
The name of the database to restore.

filePath String
The backup artifact: a mongodump .tar.gz, or an .octobak.zip container produced by a dump with archive data.

oldDatabaseName String
The (optional) name of the old db. This is required when restoring under a different name.

restoreArchiveData Boolean
When true, CrateDB archive data contained in the backup artifact is restored alongside the Mongo data.

progressCallback Action<Double>
Optional callback reporting upload progress (0.0 to 1.0).

cancellationToken CancellationToken
A cancellation token.

Returns​

Task<JobResponseDto>
The job response containing the job ID.

UploadRestoreFileWithTusAsync(String, String, String, String, Action<Double>, CancellationToken)​

Uploads a backup artifact for a later restore with the tus resumable upload protocol (in parts, with resume) and returns the tus file id, without starting anything. Start the restore with IBotServicesClient.StartRestoreFromUploadAsync(String, String, String, String, Boolean) or with the asynchronous CK method System.Bot/TenantRepository.Restore-1.

Task<string> UploadRestoreFileWithTusAsync(string tenantId, string databaseName, string filePath, string oldDatabaseName, Action<double> progressCallback, CancellationToken cancellationToken)

Parameters​

tenantId String
The tenant the upload is staged for (and that will be restored).

databaseName String
The name of the database to restore (upload metadata).

filePath String
The backup artifact: a mongodump .tar.gz or an .octobak.zip.

oldDatabaseName String
The (optional) name of the database in the backup (upload metadata).

progressCallback Action<Double>
Optional callback reporting upload progress (0.0 to 1.0).

cancellationToken CancellationToken
A cancellation token.

Returns​

Task<String>
The tus file id of the completed upload.

StartRestoreFromUploadAsync(String, String, String, String, Boolean)​

Starts the restore job ({tenantId}/v1/jobs/restore-from-upload) from an upload made with IBotServicesClient.UploadRestoreFileWithTusAsync(String, String, String, String, Action<Double>, CancellationToken).

Task<JobResponseDto> StartRestoreFromUploadAsync(string tenantId, string tusFileId, string databaseName, string oldDatabaseName, bool restoreArchiveData)

Parameters​

tenantId String
The tenant to restore.

tusFileId String
The tus file id of the completed upload.

databaseName String
The name of the database to restore.

oldDatabaseName String
The (optional) name of the database in the backup.

restoreArchiveData Boolean
Also restore the archive data of an .octobak.zip.

Returns​

Task<JobResponseDto>
The job response containing the job ID.

Remarks:

Restores without the ownership override. To restore with the override, call the overload that takes every argument and overrideForeignOwnership.

StartRestoreFromUploadAsync(String, String, String, String, Boolean, Boolean)​

Starts the restore job ({tenantId}/v1/jobs/restore-from-upload) from an upload made with IBotServicesClient.UploadRestoreFileWithTusAsync(String, String, String, String, Action<Double>, CancellationToken), optionally with the ownership override.

Task<JobResponseDto> StartRestoreFromUploadAsync(string tenantId, string tusFileId, string databaseName, string oldDatabaseName, bool restoreArchiveData, bool overrideForeignOwnership)

Parameters​

tenantId String
The tenant to restore.

tusFileId String
The tus file id of the completed upload.

databaseName String
The name of the database to restore.

oldDatabaseName String
The (optional) name of the database in the backup.

restoreArchiveData Boolean
Also restore the archive data of an .octobak.zip.

overrideForeignOwnership Boolean
Deliberate administrator override: when true, the restore overwrites a tenant database that records another OctoMesh instance on the same MongoDB server as its owner while no instance registers it any more, instead of refusing it; the service logs the override as a warning naming the owner. A database another instance still registers, and another instance's system database, are refused even with the override. Sent as the query parameter overrideForeignOwnership=True only when set.

Returns​

Task<JobResponseDto>
The job response containing the job ID.

Remarks:

Every parameter is required on purpose, as with IBotServicesClient.RestoreRepositoryWithTusAsync(String, String, String, String, Boolean, Action<Double>, CancellationToken, Boolean): a call that leaves any of them out binds to the overload without the override.

StartDumpRepositoryAsync(String, Boolean)​

Dumps the repository for the given tenant.

Task<JobResponseDto> StartDumpRepositoryAsync(string tenantId, bool includeArchiveData)

Parameters​

tenantId String
The tenant ID for which the repository should be restored.

includeArchiveData Boolean
When true, CrateDB archive data is included in the dump artifact. Default false dumps Mongo only (today's behaviour).

Returns​

Task<JobResponseDto>
The job response containing the job ID.

ReconfigureLogLevelAsync(String, LogLevelDto, LogLevelDto)​

Reconfigure the log level of the service.

Task ReconfigureLogLevelAsync(string loggerName, LogLevelDto minLogLevel, LogLevelDto maxLogLevel)

Parameters​

loggerName String
Logger pattern name, e. g. Microsoft.*

minLogLevel LogLevelDto
Minimal log level to be logged.

maxLogLevel LogLevelDto
Maximum log level to be logged.

Returns​

Task

StartExportArchiveDataAsync(String, String, Nullable<DateTime>, Nullable<DateTime>)​

Starts an async Hangfire job in bot-services that exports the row data of an archive to a downloadable ZIP (delegating the CrateDB read to asset-repo over the SDK). When both fromUtc and toUtc are null the whole archive is exported; when supplied, the slice [fromUtc, toUtc) is exported. Poll the job and download the result via the existing job plumbing. Archive data export/import concept §5.

Task<JobResponseDto> StartExportArchiveDataAsync(string tenantId, string archiveRtId, Nullable<DateTime> fromUtc, Nullable<DateTime> toUtc)

Parameters​

tenantId String
The tenant that owns the archive.

archiveRtId String
Runtime id of the CkArchive entity.

fromUtc Nullable<DateTime>
Inclusive lower bound of the exported window (UTC); null for whole archive.

toUtc Nullable<DateTime>
Exclusive upper bound of the exported window (UTC); null for whole archive.

Returns​

Task<JobResponseDto>
The job response containing the job id.

StartImportArchiveDataWithTusAsync(String, String, String, ArchiveImportMode, Action<Double>, CancellationToken)​

Uploads an export ZIP via the tus resumable-upload protocol (same as repository restore) and then starts an async import job in bot-services that validates the schema match and streams the rows into the target archive. Archive data export/import concept §5.

Task<JobResponseDto> StartImportArchiveDataWithTusAsync(string tenantId, string archiveRtId, string filePath, ArchiveImportMode mode, Action<double> progressCallback, CancellationToken cancellationToken)

Parameters​

tenantId String
The tenant that owns the archive.

archiveRtId String
Runtime id of the target CkArchive entity.

filePath String
Local path to the export ZIP to import.

mode ArchiveImportMode
Insert-only or upsert; serialized as a string query parameter.

progressCallback Action<Double>
Optional callback reporting upload progress (0.0 to 1.0).

cancellationToken CancellationToken
A cancellation token.

Returns​

Task<JobResponseDto>
The job response containing the job id.

UploadArchiveDataWithTusAsync(String, String, String, Action<Double>, CancellationToken)​

Uploads an archive data export ZIP with the tus resumable upload protocol and returns the tus file id, without starting the import. Start it with IBotServicesClient.StartImportArchiveDataFromUploadAsync(String, String, String, ArchiveImportMode) or with the asynchronous CK method System.Bot/TenantRepository.ImportArchiveData-1.

Task<string> UploadArchiveDataWithTusAsync(string tenantId, string archiveRtId, string filePath, Action<double> progressCallback, CancellationToken cancellationToken)

Parameters​

tenantId String
The tenant that owns the archive.

archiveRtId String
Runtime id of the target CkArchive entity (upload metadata).

filePath String
Local path to the export ZIP.

progressCallback Action<Double>
Optional callback reporting upload progress (0.0 to 1.0).

cancellationToken CancellationToken
A cancellation token.

Returns​

Task<String>
The tus file id of the completed upload.

StartImportArchiveDataFromUploadAsync(String, String, String, ArchiveImportMode)​

Starts the archive data import job ({tenantId}/v1/jobs/import-archive-data-from-upload) from an upload made with IBotServicesClient.UploadArchiveDataWithTusAsync(String, String, String, Action<Double>, CancellationToken).

Task<JobResponseDto> StartImportArchiveDataFromUploadAsync(string tenantId, string tusFileId, string archiveRtId, ArchiveImportMode mode)

Parameters​

tenantId String
The tenant that owns the archive.

tusFileId String
The tus file id of the completed upload.

archiveRtId String
Runtime id of the target CkArchive entity.

mode ArchiveImportMode
Insert-only or upsert.

Returns​

Task<JobResponseDto>
The job response containing the job id.

StartSecretSweepAsync(String, SecretSweepModeDto, Boolean)​

Starts a secret sweep job for tenantId (POST {tenantId}/v1/jobs/secret-sweep?mode=[&confirm=true], role SecretManagement). Writing modes take a pre-sweep dump first and are followed by a verify step. Poll the job via the existing job plumbing and read the result with IBotServicesClient.GetSecretSweepReportAsync(String).

Task<JobResponseDto> StartSecretSweepAsync(string tenantId, SecretSweepModeDto mode, bool confirm)

Parameters​

tenantId String
The tenant to sweep.

mode SecretSweepModeDto
(default), , or . is not offered and throws ArgumentOutOfRangeException.

confirm Boolean
Sends confirm=true. The service answers 400 ConfirmationRequired for and without it.

Returns​

Task<JobResponseDto>
The job response containing the job id.

GetSecretEnvironmentStatusAsync(String)​

Returns the encryption status of the environment as seen from tenantId (GET {tenantId}/v1/secrets/status; any user with tenant access).

Task<SecretEnvironmentStatusDto> GetSecretEnvironmentStatusAsync(string tenantId)

Parameters​

tenantId String
The tenant.

Returns​

Task<SecretEnvironmentStatusDto>

GetSecretSweepRunsAsync(String, Int32)​

Returns the secret sweep runs of tenantId, newest first (GET {tenantId}/v1/secrets/sweep-runs?limit=, role AdminPanelManagement).

Task<IReadOnlyList<SecretSweepRunDto>> GetSecretSweepRunsAsync(string tenantId, int limit)

Parameters​

tenantId String
The tenant.

limit Int32
Maximum number of runs (at least 1; the service keeps the last 50).

Returns​

Task<IReadOnlyList<SecretSweepRunDto>>

DeleteSecretSweepDumpAsync(String, String)​

Deletes the pre-sweep dump of a run early (DELETE {tenantId}/v1/secrets/sweep-runs/{runId}/dump, role SecretManagement).

Task<SecretSweepDumpDeleteResultDto> DeleteSecretSweepDumpAsync(string tenantId, string runId)

Parameters​

tenantId String
The tenant.

runId String
The run id ().

Returns​

Task<SecretSweepDumpDeleteResultDto>
(204), (404: unknown run or no dump) or (409). Other errors (e.g. 403) throw ServiceClientResultException.

RestoreSecretSweepDumpAsync(String, String, Boolean)​

Restores the pre-sweep dump of a run into the same tenant and runs a Verify afterwards (POST {tenantId}/v1/secrets/sweep-runs/{runId}/restore-dump?confirm=true, role SecretManagement). The tenant's database is dropped and replaced by the dump. 🔴 A dump taken before the first Encrypt holds plaintext secrets: restoring it brings the plaintext back - run an Encrypt sweep afterwards.

Task<JobResponseDto> RestoreSecretSweepDumpAsync(string tenantId, string runId, bool confirm)

Parameters​

tenantId String
The tenant the dump was taken from (a dump can only be restored into it).

runId String
The run id ().

confirm Boolean
Sends confirm=true; without it the service answers 400 ConfirmationRequired.

Returns​

Task<JobResponseDto>
The job response containing the id of the restore job; follow it with IBotServicesClient.GetImportJobStatus(String).

Exceptions​

SecretSweepDumpRestoreException
400 ConfirmationRequired, 404 (unknown run / no dump / dump no longer stored), 409 DumpDeleted or 409 DumpKeyMissing; see SecretSweepDumpRestoreException.Reason. Other errors (e.g. 403) throw ServiceClientResultException.

GetSecretSweepReportAsync(String)​

Returns the last secret sweep report of tenantId (GET {tenantId}/v1/jobs/secret-sweep/report), or null when the service answers 404 (no sweep has run for the tenant yet). Never contains a value.

Task<SecretSweepReportDto> GetSecretSweepReportAsync(string tenantId)

Parameters​

tenantId String
The tenant.

Returns​

Task<SecretSweepReportDto>

StartSecretSweepAllTenantsAsync(SecretSweepModeDto, Boolean)​

Starts a secret sweep over all tenants of the instance (POST system/v1/secrets/sweep?mode=). Requires access to the system tenant. Per-tenant results: IBotServicesClient.GetSecretSweepReportsAsync().

Task<JobResponseDto> StartSecretSweepAllTenantsAsync(SecretSweepModeDto mode, bool confirm)

Parameters​

mode SecretSweepModeDto
Same modes as IBotServicesClient.StartSecretSweepAsync(String, SecretSweepModeDto, Boolean); Decrypt throws.

confirm Boolean
Sends confirm=true. The service answers 400 ConfirmationRequired for without it.

Returns​

Task<JobResponseDto>
The job response containing the job id.

GetSecretSweepReportsAsync()​

Returns the last secret sweep report of every tenant that has one, ordered by tenant id (GET system/v1/secrets/reports). Requires access to the system tenant.

Task<IReadOnlyList<SecretSweepReportDto>> GetSecretSweepReportsAsync()

Returns​

Task<IReadOnlyList<SecretSweepReportDto>>