pip_clients_roles 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • new50

Pip.Services Logo
Roles Microservice Client SDK for Dart #

This is a Dart client SDK for pip-services-roles microservice.

Download #

Right now the only way to get the microservice is to check it out directly from github repository

git clone git@github.com:pip-services-users/pip-clients-roles-dart.git

Pip.Service team is working to implement packaging and make stable releases available for your as zip downloadable archieves.

Contract #

Logical contract of the microservice is presented below. For physical implementation (HTTP/REST), please, refer to documentation of the specific protocol.

class UserRolesV1 implements IStringIdentifiable {
  String id;
  List<String> roles;
  DateTime update_time;
}

abstract class IRolesV1 {
  Future<DataPage<UserRolesV1>> getRolesByFilter(
      String correlationId, FilterParams filter, PagingParams paging);

  Future<List<String>> getRolesById(String correlationId, String userId);

  Future<List<String>> setRoles(String correlationId, String userId, List<String> roles);

  Future<List<String>> grantRoles(String correlationId, String userId, List<String> roles);

  Future<List<String>> revokeRoles(String correlationId, String userId, List<String> roles);

  Future<bool> authorize(String correlationId, String userId, List<String> roles);
}

Use #

The easiest way to work with the microservice is to use client SDK.

Define client configuration parameters that match the configuration of the microservice's external API

// Client configuration
var httpConfig = ConfigParams.fromTuples(
	"connection.protocol", "http",
	"connection.host", "localhost",
	"connection.port", 8080
);

Instantiate the client and open connection to the microservice

// Create the client instance
var client = RolesHttpClientV1(config);

// Configure the client
client.configure(httpConfig);

// Connect to the microservice
try{
  await client.open(null)
}catch() {
  // Error handling...
}       
// Work with the microservice
// ...

Now the client is ready to perform operations

final ROLES = ['Role 1', 'Role 2', 'Role 3'];

    // Set the roles
    try {
      var role = await client.setRoles('123', '1', ROLES);
      // Do something with the returned roles...
    } catch(err) {
      // Error handling...     
    }
// Get the roles by id
try {
var role = await client.getRolesById(
    null,
    '1');
    // Do something with roles...

    } catch(err) { // Error handling}
// Grant user a role
try {
var role = await client.grantRoles(
    null,
    '1',
    ['admin']);
    // Do something with roles...

    } catch(err) { // Error handling}

// Authorize user
try {
var role = await client.authorize(
    null,
    '1',
    ['admin']);
    // Do something with bool value(authorized or not authorized) ...

    } catch(err) { // Error handling}    

Acknowledgements #

This microservice was created and currently maintained by

  • Sergey Seroukhov
  • Nuzhnykh Egor.

1.0.0 #

  • Initial version

1.0.1 #

  • Added direct client test

example/README.md

Examples for Roles Microservice #

This is a user roles microservice from Pip.Services library. It provides basic role-based authorization mechanism for users.

Define configuration parameters that match the configuration of the microservice's external API

// Service/Client configuration
var httpConfig = ConfigParams.fromTuples(
	"connection.protocol", "http",
	"connection.host", "localhost",
	"connection.port", 8080
);

Instantiate the client and open connection to the microservice

// Create the client instance
var client = RolesHttpClientV1(config);

// Configure the client
client.configure(httpConfig);

// Connect to the microservice
try{
  await client.open(null)
}catch() {
  // Error handling...
}       
// Work with the microservice
// ...

Now the client is ready to perform operations

final ROLES = ['Role 1', 'Role 2', 'Role 3'];

    // Set the roles
    try {
      var role = await client.setRoles('123', '1', ROLES);
      // Do something with the returned roles...
    } catch(err) {
      // Error handling...     
    }
// Get the roles by id
try {
var role = await client.getRolesById(
    null,
    '1');
    // Do something with roles...

    } catch(err) { // Error handling}
// Grant user a role
try {
var role = await client.grantRoles(
    null,
    '1',
    ['admin']);
    // Do something with roles...

    } catch(err) { // Error handling}

// Authorize user
try {
var role = await client.authorize(
    null,
    '1',
    ['admin']);
    // Do something with bool value(authorized or not authorized) ...

    } catch(err) { // Error handling}    

In the help for each class there is a general example of its use. Also one of the quality sources are the source code for the tests.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pip_clients_roles: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pip_clients_roles/pip_clients_roles.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on May 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
angel_framework ^2.1.1 2.1.1
http ^0.12.0 0.12.1
pip_services3_commons >=1.0.5 <2.0.0 1.0.9
pip_services3_components >=1.0.2 <2.0.0 1.0.6
pip_services3_container >=1.0.0 <2.0.0 1.0.2
pip_services3_data >=1.0.0 <2.0.0 1.0.4
pip_services3_grpc >=1.0.0 <2.0.0 1.0.0
pip_services3_mongodb >=1.0.2 <2.0.0 1.0.3
pip_services3_rpc >=1.0.2 <2.0.0 1.0.3
pip_services_roles >=1.0.0 <2.0.0 1.0.0
Transitive dependencies
angel_container 1.1.0
angel_http_exception 1.1.0
angel_model 1.0.3
angel_route 3.1.0+1
async 2.4.1
bson 0.3.2
charcode 1.1.3
code_buffer 1.0.1
collection 1.14.12
combinator 1.1.0
convert 2.1.1
crypto 2.1.5
dart2_constant 1.0.2+dart2
file 5.1.0
fixnum 0.10.11
googleapis_auth 0.2.11+1
grpc 2.1.3
http2 1.0.0
http_parser 3.1.4
http_server 0.9.8+3
intl 0.16.1
logging 0.11.4
matcher 0.12.6
merge_map 1.0.2
meta 1.1.8
mime 0.9.6+3
mock_request 1.0.7
mongo_dart 0.4.0
mongo_dart_query 0.4.1
more 1.18.2 2.3.1
mustache4dart2 0.1.0
path 1.7.0
pedantic 1.9.0
pool 1.4.0
protobuf 1.0.1
quiver 2.1.3
quiver_hashcode 2.0.0
recase 2.0.1 3.0.0
source_span 1.7.0
sprintf 4.0.2
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
tuple 1.0.3
typed_data 1.1.6
uuid 2.0.4
yaml 2.2.1
Dev dependencies
test >=1.14.2 <2.0.0