Skip to content

Commit

Permalink
Setting up retrieving of role and permission
Browse files Browse the repository at this point in the history
  • Loading branch information
cpluta committed Nov 3, 2019
1 parent d931fe6 commit 87de1d1
Show file tree
Hide file tree
Showing 2 changed files with 200 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/roles/creating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Creating a role allows it to be assignable to a user.
var meshyConnection = await client.loginAnonymously(username);
meshyConnection.rolesService.create(role);
await meshyConnection.rolesService.create(role);
|parameters|

Expand Down Expand Up @@ -213,8 +213,8 @@ When creating a permission it is assigned to a role. When a user has the role th

accountName : :type:`string`, :required:`required`
Indicates which account you are connecting to.
username : :type:`string`, :required:`required`
Unique identifier for user or device.
access_token : :type:`string`, :required:`required`
Token identifying authorization with MeshyDB requested during `Generating Token <../authorization/generating_token.html#generating-token>`_.
roleId : :type:`string`, :required:`required`
Identifies id of role.
permissibleName : :type:`string`, :required:`required`
Expand Down
197 changes: 197 additions & 0 deletions docs/roles/retrieving.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
.. role:: required

.. role:: type

.. |parameters| raw:: html

<h4>Parameters</h4>

----------
Retrieving
----------


Retrieve information for specific specific role.

''''
Role
''''

Retrieve details about role by id.

.. tabs::

.. group-tab:: C#

.. code-block:: c#
var client = MeshyClient.Initialize(accountName, publicKey);
var connection = await client.LoginAnonymouslyAsync(username);
await connection.Roles.GetAsync(roleId);
|parameters|

accountName : :type:`string`, :required:`required`
Indicates which account you are connecting to.
publicKey : :type:`string`, :required:`required`
Public identifier of connecting service.
username : :type:`string`, :required:`required`
Unique identifier for user or device.
roleId : :type:`string`, :required:`required`
Identifies id of role.

.. group-tab:: NodeJS

.. code-block:: javascript
var client = MeshyClient.initialize(accountName, publicKey);
var meshyConnection = await client.loginAnonymously(username);
await meshyConnection.rolesService.get(roleId);
|parameters|

accountName : :type:`string`, :required:`required`
Indicates which account you are connecting to.
publicKey : :type:`string`, :required:`required`
Public identifier of connecting service.
username : :type:`string`, :required:`required`
Unique identifier for user or device.
roleId : :type:`string`, :required:`required`
Identifies id of role.

.. group-tab:: REST

.. code-block:: http
GET https://api.meshydb.com/{accountName}/roles/{roleId} HTTP/1.1
Authentication: Bearer {access_token}
|parameters|

accountName : :type:`string`, :required:`required`
Indicates which account you are connecting to.
access_token : :type:`string`, :required:`required`
Token identifying authorization with MeshyDB requested during `Generating Token <../authorization/generating_token.html#generating-token>`_.

.. rubric:: Responses

200 : OK
* Identifies if role was found.

Example Result

.. code-block:: json
{
"name":"test",
"description":"...",
"id":"5db..."
}
403 : Forbidden
* User has insufficent permission to read roles.

404 : Not Found
* Role was not found.

429 : Too many request
* You have either hit your API or Database limit. Please review your account.

''''''''''
Permission
''''''''''

Get specific permission from role by id.

.. tabs::

.. group-tab:: C#

.. code-block:: c#
var client = MeshyClient.Initialize(accountName, publicKey);
var connection = await client.LoginAnonymouslyAsync(username);
var permission = await connection.Roles.GetPermissionAsync(roleId, permissionId);
|parameters|

accountName : :type:`string`, :required:`required`
Indicates which account you are connecting to.
publicKey : :type:`string`, :required:`required`
Public identifier of connecting service.
roleId : :type:`string`, :required:`required`
Identifies id of role.
permissionId : :type:`string`, :required:`required`
Identifies id of permission.

.. group-tab:: NodeJS

.. code-block:: javascript
var client = MeshyClient.initialize(accountName, publicKey);
var meshyConnection = await client.loginAnonymously(username);
var permission = await meshyConnection.rolesService.getPermission(roleId, permissionId);
|parameters|

accountName : :type:`string`, :required:`required`
Indicates which account you are connecting to.
publicKey : :type:`string`, :required:`required`
Public identifier of connecting service.
username : :type:`string`, :required:`required`
Unique identifier for user or device.
roleId : :type:`string`, :required:`required`
Identifies id of role.
permissionId : :type:`string`, :required:`required`
Identifies id of permission.

.. group-tab:: REST

.. code-block:: http
GET https://api.meshydb.com/{accountName}/roles/{roleId}/permissions/{permissionId} HTTP/1.1
Authentication: Bearer {access_token}
|parameters|

accountName : :type:`string`, :required:`required`
Indicates which account you are connecting to.
access_token : :type:`string`, :required:`required`
Token identifying authorization with MeshyDB requested during `Generating Token <../authorization/generating_token.html#generating-token>`_.
roleId : :type:`string`, :required:`required`
Identifies id of role.
permissionId : :type:`string`, :required:`required`
Identifies id of permission.

.. rubric:: Responses

200 : OK
* Identifies if permission was found.

Example Result

.. code-block:: json
{
"id":"5db...",
"permissibleName":"meshes",
"create":"true",
"update":"true",
"read":"true",
"delete":"true"
}
403 : Forbidden
* User has insufficent permission to read roles.

404 : Not Found
* Permission was not found.

429 : Too many request
* You have either hit your API or Database limit. Please review your account.

0 comments on commit 87de1d1

Please sign in to comment.