Skip to content

Commit c5291ad

Browse files
ad-mfredericosilva
authored andcommitted
Add journal retention period mgmt (#442)
* Add journal retention period mgmt * Drop spread operator syntax
1 parent 4f814f3 commit c5291ad

5 files changed

Lines changed: 36 additions & 6 deletions

File tree

bin/generic/update/replace/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
const Cli = require('lib/cli');
33

44
module.exports = (resource, field_name) => {
5-
const parameter = resource.schema[field_name];
5+
const parameter = Object.assign({},
6+
resource.schema[field_name],
7+
{ required: true }
8+
);
69

710
const name = parameter.name || field_name;
811

bin/journal/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const schema = {
2323
required: false,
2424
defaultValue: 90,
2525
onCreate: true,
26+
onUpdate: true,
2627
},
2728
credentials: {
2829
virtual: true,
@@ -31,15 +32,14 @@ const schema = {
3132
tags: {
3233
virtual: true,
3334
onCreate: true,
34-
onUpdate: true,
3535
},
3636
};
3737

3838
const resource = {
3939
name: 'journal',
4040
apiName: 'journal',
4141
defaultQuery: '[].{id:id,name:name,retention:retention,sizeUsed:sizeUsed,state:state,processing:processing}',
42-
commands: ['show', 'delete', 'rename', 'create', 'list', 'history', 'tag', 'service', 'transfer', 'credential'],
42+
commands: ['show', 'delete', 'rename', 'create', 'list', 'history', 'tag', 'service', 'transfer', 'update', 'credential'],
4343
plugins: genericDefaults.plugins,
4444
url: () => 'journal',
4545
dirname: __dirname,

bin/journal/tests.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ava.serial('journal logger & stream', async t => {
2323
const content = await tests.getToken();
2424
const log_file = tests.getRandomFile(content);
2525
const output_file = tests.randomFileName();
26-
const journal = await tests.run(`journal create --name log-logger-${now}`);
26+
const journal = await tests.run(`journal create --name ${tests.getName(t.title)}`);
2727
try {
2828
await tests.run(`journal credential password add --journal ${journal.id} --name my-token --password ${token}`);
2929
await tests.run(`journal logger --journal ${journal.id} --token ${token} --log-file ${log_file}`);
@@ -45,7 +45,7 @@ ava.serial('journal logger & stream with tags', async t => {
4545
const content_without_tag = await tests.getToken();
4646
const log_file_without_tag = tests.getRandomFile(content_without_tag);
4747
const output_file = tests.randomFileName();
48-
const journal = await tests.run(`journal create --name log-logger-${now} --password ${token}`);
48+
const journal = await tests.run(`journal create --name ${tests.getName(t.title)} --password ${token}`);
4949
try {
5050
await tests.run(`journal logger --journal ${journal.id} --token ${token} --log-file ${log_file_with_tag} --tag host=123`);
5151
await tests.run(`journal logger --journal ${journal.id} --token ${token} --log-file ${log_file_without_tag}`);
@@ -60,3 +60,15 @@ ava.serial('journal logger & stream with tags', async t => {
6060
await tests.remove('journal', journal);
6161
}
6262
});
63+
64+
ava.serial('journal retention update', async t => {
65+
const journal = await tests.run(`journal create --name ${now} --retention 25`);
66+
try {
67+
t.true(journal.retention === 25);
68+
await tests.run(`journal retention --journal ${journal.id} --retention 25`);
69+
const journal_updated = await tests.run(`journal show --journal ${journal.id}`);
70+
t.true(journal_updated.retention === 25);
71+
} finally {
72+
await tests.remove('journal', journal);
73+
}
74+
});

docs/journal.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [h1 journal service list](#h1-journal-service-list) - List Service for Journal
1111
* [h1 journal service show](#h1-journal-service-show) - Show Service for Journal
1212
* [h1 journal transfer](#h1-journal-transfer) - Transfer Journal to other project
13+
* [h1 journal retention](#h1-journal-retention) - Update Data retention period (in days) of Journal
1314
* [h1 journal stream](#h1-journal-stream) - Stream or read messages of Journal
1415
* [h1 journal logger](#h1-journal-logger) - Log messages to Journal
1516
* [h1 journal credential](#h1-journal-credential) - Manage your credentials of Journal
@@ -248,6 +249,20 @@ h1 journal transfer --journal test-journal --new-project OtherProject
248249
| ```--journal JOURNAL``` | | Journal ID or name |
249250
| ```--new-project NEW-PROJECT``` | | New name |
250251

252+
## h1 journal retention
253+
254+
Update Data retention period (in days) of Journal
255+
256+
### Syntax
257+
258+
```h1 journal retention | --retention RETENTION --journal JOURNAL```
259+
### Required arguments
260+
261+
| Name | Default | Description |
262+
| ---- | ------- | ----------- |
263+
| ```--retention RETENTION``` | | Data retention period (in days) |
264+
| ```--journal JOURNAL``` | | Journal ID or name |
265+
251266
## h1 journal stream
252267

253268
Stream or read messages of Journal

lib/tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ const get = (url) => {
494494

495495
const runProcess = (cmd, opts = {}) => new Promise((resolve, reject) => {
496496
const argv = shell_quote.parse(cmd);
497-
497+
console.log(new Date(), 'local:', cmd);
498498
const proc = spawn(argv[0], argv.slice(1), {
499499
env: Object.assign({}, process.env, opts.env),
500500
stdio: [null, 'pipe', 'pipe'],

0 commit comments

Comments
 (0)