forked from kuzzleio/kourou
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.ts
38 lines (29 loc) · 976 Bytes
/
create.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { flags } from '@oclif/command'
import { Client } from '@elastic/elasticsearch'
import { Kommand } from '../../../common'
export default class EsSnapshotsCreate extends Kommand {
static initSdk = false
static description = 'Create a snapshot repository inside an ES instance'
static flags = {
node: flags.string({
char: 'n',
description: 'Elasticsearch server URL',
default: 'http://localhost:9200',
}),
help: flags.help(),
}
static args = [
{ name: 'repository', description: 'ES repository name', required: true },
{ name: 'name', description: 'ES snapshot name', required: true },
]
async runSafe() {
const esClient = new Client({ node: this.flags.node })
const esRequest = {
repository: this.args.repository,
snapshot: this.args.name,
body: {}
}
const response = await esClient.snapshot.create(esRequest)
this.logOk(`Success ${JSON.stringify(response.body)}`)
}
}