Skip to content

Commit de8b593

Browse files
authored
Merge pull request #443 from ad-m/invitation
user: add invitation mgmt, organisation: add delete, generic.access.u…
2 parents 35e5dc6 + c49eb52 commit de8b593

8 files changed

Lines changed: 151 additions & 3 deletions

File tree

bin/generic/access/user/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = (parent) => {
2727
const resource = {
2828
title: `access rights for ${parent.title}`,
2929
description: `Manage your ${parent.title} access rights`,
30-
defaultQuery: '[].{id:id,role:role}',
30+
defaultQuery: '[].{id:id,role:role,state:state}',
3131
url: args => `${parent.url(args)}/${args[parent.name]}/accessrights`,
3232
options: options,
3333
plugins: defaults.plugins,

bin/organisation/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const resource = {
1212
require('bin/_plugins/api'),
1313
],
1414
title: 'Organisation',
15-
commands: ['show', 'history', 'access/user', 'list', 'rename', 'tag', 'payment'],
15+
commands: ['show', 'history', 'access/user', 'list', 'rename', 'tag', 'payment', 'delete'],
1616
};
1717

1818
const category = genericResource(resource);

bin/user/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ const category = Cli.createCategory(resource.name, {
2323
});
2424

2525
category.addChild(require('./create'));
26+
category.addChild(require('./invitation')(childDefaults));
2627

2728
category.addChild(require('bin/generic/credentials')(Object.assign(
2829
{},
29-
resource,
3030
childDefaults,
3131
{
3232
url: args => `${childDefaults.url(args)}/credential`,

bin/user/invitation/index.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
const genericDefaults = require('bin/generic/defaults');
3+
const genericResource = require('bin/generic');
4+
5+
module.exports = (parent) => {
6+
const schema = {
7+
project: {
8+
description: 'Project ID',
9+
type: 'string',
10+
required: true,
11+
},
12+
};
13+
14+
const resource = {
15+
name: 'invitation',
16+
defaultQuery: '[].{id:id,name:name,type:type}',
17+
url: () => 'user/me/invitation',
18+
options: Object.assign({}, parent.options),
19+
plugins: genericDefaults.plugins,
20+
commands: ['list'],
21+
extraCommands: [],
22+
schema: schema,
23+
title: `invitation of ${parent.title}`,
24+
};
25+
26+
const category = genericResource(resource);
27+
28+
['decline', 'accept'].forEach(action => {
29+
category.addChild(require('./update')(resource, action));
30+
});
31+
32+
return category;
33+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# {{actionTitle}} invitation
2+
3+
```bash
4+
{{command_name}} --invitation 5d88097cd6249ff5478540b2
5+
```
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
const text = require('lib/text');
3+
const Cli = require('lib/cli');
4+
5+
module.exports = (resource, action) => {
6+
const options = {
7+
[resource.name]: {
8+
description: 'Invitation ID',
9+
type: 'string',
10+
required: true,
11+
},
12+
};
13+
14+
return Cli.createCommand(action, {
15+
description: `${text.toTitleCase(action)} ${resource.title}`,
16+
options: Object.assign({}, resource.options, options),
17+
dirname: __dirname,
18+
resource: resource,
19+
context: {
20+
actionTitle: text.toTitleCase(action),
21+
},
22+
handler: async args => {
23+
await args.helpers.api.post(`${resource.url(args)}/${args[resource.name]}/${action}`);
24+
console.error(`Successfully ${action}ed invitation.`);
25+
},
26+
});
27+
};

docs/organisation.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* [h1 organisation payment](#h1-organisation-payment) - Manage your payment for Organisation
1212
* [h1 organisation payment show](#h1-organisation-payment-show) - Show payment
1313
* [h1 organisation payment list](#h1-organisation-payment-list) - List payment
14+
* [h1 organisation delete](#h1-organisation-delete) - Delete Organisation
1415
* [h1 organisation transfer](#h1-organisation-transfer) - Manage your transfer for Organisation
1516
* [h1 organisation transfer show](#h1-organisation-transfer-show) - Show transfer
1617
* [h1 organisation transfer list](#h1-organisation-transfer-list) - List transfer
@@ -216,6 +217,25 @@ h1 organisation payment list --Organisation my-Organisation
216217
| ---- | ------- | ----------- |
217218
| ```--organisation ORGANISATION``` | | Organisation ID or name |
218219

220+
## h1 organisation delete
221+
222+
Delete Organisation
223+
224+
### Syntax
225+
226+
```h1 organisation delete | --organisation ORGANISATION```
227+
### Example
228+
229+
```bash
230+
h1 organisation delete --organisation my-organisation
231+
```
232+
233+
### Required arguments
234+
235+
| Name | Default | Description |
236+
| ---- | ------- | ----------- |
237+
| ```--organisation ORGANISATION``` | | Organisation ID or name |
238+
219239
## h1 organisation transfer
220240

221241
Manage your transfer for Organisation

docs/user.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# TOC
22

33
* [h1 user create](#h1-user-create) - Create an account
4+
* [h1 user invitation](#h1-user-invitation) - Manage your invitation of User
5+
* [h1 user invitation list](#h1-user-invitation-list) - List invitation of User
6+
* [h1 user invitation decline](#h1-user-invitation-decline) - Decline invitation of User
7+
* [h1 user invitation accept](#h1-user-invitation-accept) - Accept invitation of User
48
* [h1 user credentials](#h1-user-credentials) - Manage your credentials
59
* [h1 user credentials show](#h1-user-credentials-show) - Show credentials
610
* [h1 user credentials list](#h1-user-credentials-list) - List credentials
@@ -32,6 +36,65 @@ Create an account
3236
h1 user create
3337
```
3438

39+
## h1 user invitation
40+
41+
Manage your invitation of User
42+
43+
## h1 user invitation list
44+
45+
List invitation of User
46+
47+
### Syntax
48+
49+
```h1 user invitation list | ```
50+
### Example
51+
52+
```bash
53+
h1 user invitation list
54+
```
55+
56+
## h1 user invitation decline
57+
58+
Decline invitation of User
59+
60+
### Syntax
61+
62+
```h1 user invitation decline | --invitation INVITATION```
63+
### Examples
64+
65+
#### Decline invitation
66+
67+
```bash
68+
h1 user invitation decline --invitation 5d88097cd6249ff5478540b2
69+
```
70+
71+
### Required arguments
72+
73+
| Name | Default | Description |
74+
| ---- | ------- | ----------- |
75+
| ```--invitation INVITATION``` | | Invitation ID |
76+
77+
## h1 user invitation accept
78+
79+
Accept invitation of User
80+
81+
### Syntax
82+
83+
```h1 user invitation accept | --invitation INVITATION```
84+
### Examples
85+
86+
#### Accept invitation
87+
88+
```bash
89+
h1 user invitation accept --invitation 5d88097cd6249ff5478540b2
90+
```
91+
92+
### Required arguments
93+
94+
| Name | Default | Description |
95+
| ---- | ------- | ----------- |
96+
| ```--invitation INVITATION``` | | Invitation ID |
97+
3598
## h1 user credentials
3699

37100
Manage your credentials

0 commit comments

Comments
 (0)