Skip to content

Commit 940422d

Browse files
Kitty JoseKitty Jose
authored andcommitted
2 parents faffc59 + d3eb2e1 commit 940422d

File tree

10 files changed

+6445
-5932
lines changed

10 files changed

+6445
-5932
lines changed

docs/api/accesscontrol.md

Lines changed: 179 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ Sets the API token for the object, to request a token create an account in http
6363
| atokenpi | <code>string</code> | The API token to use to connect with TerminusX |
6464

6565

66+
## setApiKey
67+
##### accessControl.setApiKey(atokenpi)
68+
Sets the API token for the object, to request a token create an account in https://terminusdb.com/
69+
70+
71+
| Param | Type | Description |
72+
| --- | --- | --- |
73+
| atokenpi | <code>string</code> | The API token to use to connect with TerminusX |
74+
75+
6676
## getAPIUrl
6777
##### accessControl.getAPIUrl(cloudAPIUrl) ⇒ <code>string</code>
6878
Get a API url from cloudAPIUrl
@@ -80,10 +90,35 @@ Get all the system database roles types.
8090

8191
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
8292

93+
## getAllOrganizations
94+
##### accessControl.getAllOrganizations() ⇒ <code>Promise</code>
95+
This end point works only in basic authentication admin user
96+
Get all the system organizations list
97+
98+
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
99+
83100
## createOrganization
84101
##### accessControl.createOrganization(orgName) ⇒ <code>Promise</code>
85-
Any user can create their own organization.
86-
IMPORTANT This does not work with the API-TOKEN.
102+
This works only in the local database
103+
TerminusX - Any user can create their own organization. -
104+
TerminusX - IMPORTANT This does not work with the API-TOKEN.
105+
106+
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
107+
108+
| Param | Type | Description |
109+
| --- | --- | --- |
110+
| orgName | <code>string</code> | The organization name to create |
111+
112+
**Example**
113+
```javascript
114+
accessControl.createOrganization("my_org_name").then(result=>{
115+
console.log(result)
116+
})
117+
```
118+
119+
## deleteOrganization
120+
##### accessControl.deleteOrganization(orgName) ⇒ <code>Promise</code>
121+
This api works only in the local installation
87122

88123
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
89124

@@ -271,6 +306,45 @@ accessControl.getTeamUserRole().then(result=>{
271306
{"userRole":"Role/admin"}
272307
```
273308
309+
## getTeamUserRoles
310+
##### accessControl.getTeamUserRoles([userName], [orgName]) ⇒ <code>Promise</code>
311+
Get the user role for a given organization or the default organization,
312+
313+
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
314+
315+
| Param | Type | Description |
316+
| --- | --- | --- |
317+
| [userName] | <code>string</code> | The organization name. |
318+
| [orgName] | <code>string</code> | The organization name. |
319+
320+
**Example**
321+
```javascript
322+
accessControl.getTeamUserRole("myUser").then(result=>{
323+
console.log(result)
324+
})
325+
326+
//response object example
327+
{
328+
"@id": "User/myUser",
329+
"capability": [
330+
{
331+
"@id":"Capability/server_access",
332+
"@type":"Capability",
333+
"role": [{
334+
"@id":"Role/reader",
335+
"@type":"Role",
336+
"action": [
337+
"instance_read_access",
338+
],
339+
"name":"reader"
340+
}],
341+
"scope":"Organization/myteam"
342+
}
343+
],
344+
"name": "myUser"
345+
}
346+
```
347+
274348
## removeUserFromOrg
275349
##### accessControl.removeUserFromOrg(userId, [orgName]) ⇒ <code>Promise</code>
276350
Remove an user from an organization, only an admin user can remove an user from an organization
@@ -427,3 +501,106 @@ accessControl.deleteAccessRequest("djjdshhsuuwewueueuiHYHYYW.......").then(resul
427501
console.log(result)
428502
})
429503
```
504+
505+
## createRole
506+
##### accessControl.createRole([name], [actions]) ⇒ <code>Promise</code>
507+
Create a new role in the system database, (this api is enabled only in the local installation)
508+
509+
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
510+
511+
| Param | Type | Description |
512+
| --- | --- | --- |
513+
| [name] | <code>string</code> | The role name. |
514+
| [actions] | <code>array</code> | A list of actions |
515+
516+
**Example**
517+
```javascript
518+
accessControl.createRole("Reader",[ACTIONS.INSTANCE_READ_ACCESS]).then(result=>{
519+
console.log(result)
520+
})
521+
```
522+
523+
## deleteRole
524+
##### accessControl.deleteRole([name]) ⇒ <code>Promise</code>
525+
Delete role in the system database, (this api is enabled only in the local installation)
526+
527+
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
528+
529+
| Param | Type | Description |
530+
| --- | --- | --- |
531+
| [name] | <code>string</code> | The role name. |
532+
533+
**Example**
534+
```javascript
535+
accessControl.deleteRole("Reader").then(result=>{
536+
console.log(result)
537+
})
538+
```
539+
540+
## getAllUsers
541+
##### accessControl.getAllUsers() ⇒ <code>Promise</code>
542+
Return the list of all the users (this api is enabled only in the local installation)
543+
544+
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
545+
**Example**
546+
```javascript
547+
accessControl.getAllUsers().then(result=>{
548+
console.log(result)
549+
})
550+
```
551+
552+
## deleteUser
553+
##### accessControl.deleteUser(userId) ⇒ <code>Promise</code>
554+
Remove the user from the system database (this api is enabled only in the local installation)
555+
556+
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
557+
558+
| Param | Type | Description |
559+
| --- | --- | --- |
560+
| userId | <code>string</code> | the document user id |
561+
562+
**Example**
563+
```javascript
564+
accessControl.deleteUser(userId).then(result=>{
565+
console.log(result)
566+
})
567+
```
568+
569+
## createUser
570+
##### accessControl.createUser(name, [password]) ⇒ <code>Promise</code>
571+
Add the user into the system database (this api is enabled only in the local installation)
572+
573+
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
574+
575+
| Param | Type | Description |
576+
| --- | --- | --- |
577+
| name | <code>string</code> | the user name |
578+
| [password] | <code>string</code> | you need the password for basic authentication |
579+
580+
**Example**
581+
```javascript
582+
accessControl.deleteUser(userId).then(result=>{
583+
console.log(result)
584+
})
585+
```
586+
587+
## manageCapability
588+
##### accessControl.manageCapability(userId, resourceId, rolesArr, operation) ⇒ <code>Promise</code>
589+
Grant/Revoke Capability (this api is enabled only in the local installation)
590+
591+
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
592+
593+
| Param | Type | Description |
594+
| --- | --- | --- |
595+
| userId | <code>string</code> | the document user id |
596+
| resourceId | <code>string</code> | the resource id (database or team) |
597+
| rolesArr | <code>array</code> | the roles list |
598+
| operation | <code>string</code> | grant/revoke operation |
599+
600+
**Example**
601+
```javascript
602+
{ "operation" : "grant",
603+
"scope" : "Organization/myteam",
604+
"user" : "User/myUser",
605+
"roles" : ["Role/reader"] }
606+
```

0 commit comments

Comments
 (0)