# PowerIAM.RoleApi

All URIs are relative to *http://localhost:9000*

Method | HTTP request | Description
------------- | ------------- | -------------
[**addPermissionToRole**](RoleApi.md#addPermissionToRole) | **PUT** /v2/add-permission-to-role | 
[**createRole**](RoleApi.md#createRole) | **POST** /v2/create-role | 
[**deleteRole**](RoleApi.md#deleteRole) | **DELETE** /v2/delete-role | 
[**editRole**](RoleApi.md#editRole) | **PUT** /v2/edit-role | 
[**getRole**](RoleApi.md#getRole) | **GET** /v2/get-role | 
[**getRolePermissions**](RoleApi.md#getRolePermissions) | **GET** /v2/get-role-permissions | 
[**getRoles**](RoleApi.md#getRoles) | **GET** /v2/get-roles | 
[**removePermissionFromRole**](RoleApi.md#removePermissionFromRole) | **DELETE** /v2/remove-permission-from-role | 
[**setRolePermissions**](RoleApi.md#setRolePermissions) | **PUT** /v2/set-role-permissions | 

<a name="addPermissionToRole"></a>
# **addPermissionToRole**
> &#x27;String&#x27; addPermissionToRole(opts)



Add a permission to a role.

### Example
```javascript
import {PowerIAM} from '@poweriam/sdk';
let defaultClient = PowerIAM.ApiClient.instance;

// Configure API key authorization: JWT Token
let JWT Token = defaultClient.authentications['JWT Token'];
JWT Token.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//JWT Token.apiKeyPrefix = 'Token';

let apiInstance = new PowerIAM.RoleApi();
let opts = { 
  'roleId': "roleId_example", // String | 
  'permissionId': "permissionId_example" // String | 
};
apiInstance.addPermissionToRole(opts, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **roleId** | **String**|  | [optional] 
 **permissionId** | **String**|  | [optional] 

### Return type

**&#x27;String&#x27;**

### Authorization

[JWT Token](../README.md#JWT Token)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="createRole"></a>
# **createRole**
> RoleV2 createRole(body)



Create a role in the world, or in a realm.

### Example
```javascript
import {PowerIAM} from '@poweriam/sdk';
let defaultClient = PowerIAM.ApiClient.instance;

// Configure API key authorization: JWT Token
let JWT Token = defaultClient.authentications['JWT Token'];
JWT Token.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//JWT Token.apiKeyPrefix = 'Token';

let apiInstance = new PowerIAM.RoleApi();
let body = new PowerIAM.CreateRoleCommandV2(); // CreateRoleCommandV2 | 

apiInstance.createRole(body, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **body** | [**CreateRoleCommandV2**](CreateRoleCommandV2.md)|  | 

### Return type

[**RoleV2**](RoleV2.md)

### Authorization

[JWT Token](../README.md#JWT Token)

### HTTP request headers

 - **Content-Type**: application/json
 - **Accept**: application/json

<a name="deleteRole"></a>
# **deleteRole**
> &#x27;String&#x27; deleteRole(opts)



Delete a role.

### Example
```javascript
import {PowerIAM} from '@poweriam/sdk';
let defaultClient = PowerIAM.ApiClient.instance;

// Configure API key authorization: JWT Token
let JWT Token = defaultClient.authentications['JWT Token'];
JWT Token.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//JWT Token.apiKeyPrefix = 'Token';

let apiInstance = new PowerIAM.RoleApi();
let opts = { 
  'roleId': "roleId_example" // String | 
};
apiInstance.deleteRole(opts, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **roleId** | **String**|  | [optional] 

### Return type

**&#x27;String&#x27;**

### Authorization

[JWT Token](../README.md#JWT Token)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="editRole"></a>
# **editRole**
> RoleV2 editRole(opts)



Edit a role.

### Example
```javascript
import {PowerIAM} from '@poweriam/sdk';
let defaultClient = PowerIAM.ApiClient.instance;

// Configure API key authorization: JWT Token
let JWT Token = defaultClient.authentications['JWT Token'];
JWT Token.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//JWT Token.apiKeyPrefix = 'Token';

let apiInstance = new PowerIAM.RoleApi();
let opts = { 
  'roleId': "roleId_example", // String | 
  'name': "name_example", // String | 
  'description': "description_example", // String | 
  'externalId': "externalId_example" // String | 
};
apiInstance.editRole(opts, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **roleId** | **String**|  | [optional] 
 **name** | **String**|  | [optional] 
 **description** | **String**|  | [optional] 
 **externalId** | **String**|  | [optional] 

### Return type

[**RoleV2**](RoleV2.md)

### Authorization

[JWT Token](../README.md#JWT Token)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="getRole"></a>
# **getRole**
> RoleV2 getRole(opts)



Get a role.

### Example
```javascript
import {PowerIAM} from '@poweriam/sdk';
let defaultClient = PowerIAM.ApiClient.instance;

// Configure API key authorization: JWT Token
let JWT Token = defaultClient.authentications['JWT Token'];
JWT Token.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//JWT Token.apiKeyPrefix = 'Token';

let apiInstance = new PowerIAM.RoleApi();
let opts = { 
  'roleId': "roleId_example" // String | 
};
apiInstance.getRole(opts, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **roleId** | **String**|  | [optional] 

### Return type

[**RoleV2**](RoleV2.md)

### Authorization

[JWT Token](../README.md#JWT Token)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="getRolePermissions"></a>
# **getRolePermissions**
> [PermissionV2] getRolePermissions(opts)



Get all permissions of a role.

### Example
```javascript
import {PowerIAM} from '@poweriam/sdk';
let defaultClient = PowerIAM.ApiClient.instance;

// Configure API key authorization: JWT Token
let JWT Token = defaultClient.authentications['JWT Token'];
JWT Token.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//JWT Token.apiKeyPrefix = 'Token';

let apiInstance = new PowerIAM.RoleApi();
let opts = { 
  'roleId': "roleId_example" // String | 
};
apiInstance.getRolePermissions(opts, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **roleId** | **String**|  | [optional] 

### Return type

[**[PermissionV2]**](PermissionV2.md)

### Authorization

[JWT Token](../README.md#JWT Token)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="getRoles"></a>
# **getRoles**
> [RoleV2] getRoles(opts)



Get all roles in the world, or in a realm.

### Example
```javascript
import {PowerIAM} from '@poweriam/sdk';
let defaultClient = PowerIAM.ApiClient.instance;

// Configure API key authorization: JWT Token
let JWT Token = defaultClient.authentications['JWT Token'];
JWT Token.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//JWT Token.apiKeyPrefix = 'Token';

let apiInstance = new PowerIAM.RoleApi();
let opts = { 
  'inRealmId': "inRealmId_example" // String | 
};
apiInstance.getRoles(opts, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **inRealmId** | **String**|  | [optional] 

### Return type

[**[RoleV2]**](RoleV2.md)

### Authorization

[JWT Token](../README.md#JWT Token)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="removePermissionFromRole"></a>
# **removePermissionFromRole**
> &#x27;String&#x27; removePermissionFromRole(opts)



Remove a permission from a role.

### Example
```javascript
import {PowerIAM} from '@poweriam/sdk';
let defaultClient = PowerIAM.ApiClient.instance;

// Configure API key authorization: JWT Token
let JWT Token = defaultClient.authentications['JWT Token'];
JWT Token.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//JWT Token.apiKeyPrefix = 'Token';

let apiInstance = new PowerIAM.RoleApi();
let opts = { 
  'permissionId': "permissionId_example", // String | 
  'roleId': "roleId_example" // String | 
};
apiInstance.removePermissionFromRole(opts, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **permissionId** | **String**|  | [optional] 
 **roleId** | **String**|  | [optional] 

### Return type

**&#x27;String&#x27;**

### Authorization

[JWT Token](../README.md#JWT Token)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="setRolePermissions"></a>
# **setRolePermissions**
> &#x27;String&#x27; setRolePermissions(opts)



Set the permissions of a role.

### Example
```javascript
import {PowerIAM} from '@poweriam/sdk';
let defaultClient = PowerIAM.ApiClient.instance;

// Configure API key authorization: JWT Token
let JWT Token = defaultClient.authentications['JWT Token'];
JWT Token.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//JWT Token.apiKeyPrefix = 'Token';

let apiInstance = new PowerIAM.RoleApi();
let opts = { 
  'roleId': "roleId_example", // String | 
  'permissionIds': ["permissionIds_example"] // [String] | 
};
apiInstance.setRolePermissions(opts, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **roleId** | **String**|  | [optional] 
 **permissionIds** | [**[String]**](String.md)|  | [optional] 

### Return type

**&#x27;String&#x27;**

### Authorization

[JWT Token](../README.md#JWT Token)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

