dsh 0.2.0-rc.2: in-container update (experimental channel), path-agnostic compose, upstream patches adapted to 0.1.x/0.2.x
This commit is contained in:
commit
e6dcef9bf5
302 files changed
+75178
No files matched your search
@@ -0,0 +1,29 @@
|
||||
export class SnapshotClient {
|
||||
constructor(api, scope) {
|
||||
if (!['dsh', 'user-plugin'].includes(scope)) throw new Error('snapshot scope is invalid')
|
||||
this.api = api
|
||||
this.scope = scope
|
||||
}
|
||||
|
||||
async call(operation, body, onProgress) {
|
||||
const response = await this.api.request('POST', `/v1/${this.scope}/${operation}`, body)
|
||||
if (response.progress !== null && onProgress !== undefined) await onProgress(response.progress)
|
||||
return response.result
|
||||
}
|
||||
|
||||
create(value = undefined) {
|
||||
if (this.scope === 'dsh') {
|
||||
const { onProgress, ...body } = value
|
||||
return this.call('create', body, onProgress)
|
||||
}
|
||||
return this.call('create', { id: value })
|
||||
}
|
||||
|
||||
inspect(id) { return this.call('inspect', { id }) }
|
||||
|
||||
restore(id, { onProgress } = {}) {
|
||||
return this.call('restore', { id }, onProgress)
|
||||
}
|
||||
|
||||
remove(id) { return this.call('remove', { id }) }
|
||||
}
|
||||
Reference in new issue
Block a user