forked from kuzzleio/kourou
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-repository.ts
48 lines (39 loc) · 1.23 KB
/
create-repository.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
39
40
41
42
43
44
45
46
47
48
import { flags } from '@oclif/command'
import { Client } from '@elastic/elasticsearch'
import { Kommand } from '../../../common'
export default class EsSnapshotsCreateRepository extends Kommand {
static initSdk = false
static description = 'Create a FS snapshot repository inside an ES instance'
static flags = {
compress: flags.boolean({
description: 'Compress data when storing them',
default: false
}),
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: 'location', description: 'ES snapshot repository location', required: true },
]
async runSafe() {
const esClient = new Client({ node: this.flags.node })
const esRequest = {
repository: this.args.repository,
verify: true,
body: {
type: 'fs',
settings: {
location: this.args.location,
compress: this.flags.compress
}
}
}
const response = await esClient.snapshot.createRepository(esRequest)
this.logOk(`Success ${JSON.stringify(response.body)}`)
}
}