createRoleSet method

Future<RoleSet?> createRoleSet(
  1. CreateRoleSetRequest createRoleSetRequest
)

Create a role set

Creates a new role set with the given name and roles. The key must be unique for the instance and start with the 'role_set:' prefix, followed by lowercase alphanumeric characters and underscores only. You must provide at least one role and specify a default role key and creator role key.

Parameters:

Implementation

Future<RoleSet?> createRoleSet(
  CreateRoleSetRequest createRoleSetRequest,
) async {
  final response = await createRoleSetWithHttpInfo(
    createRoleSetRequest,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty &&
      response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(
      await _decodeBodyBytes(response),
      'RoleSet',
    ) as RoleSet;
  }
  return null;
}