pip_services4_aws 0.0.4 copy "pip_services4_aws: ^0.0.4" to clipboard
pip_services4_aws: ^0.0.4 copied to clipboard

This framework is part of the [Pip.Services](https://github.com/pip-services/pip-services) project. It contains components for AWS cloud platform.

example/main.dart

import 'dart:io';

import 'package:pip_services4_components/pip_services4_components.dart';
import 'package:pip_services4_data/pip_services4_data.dart';

import './Dummy.dart';
import 'DummyCommandableLambdaClient.dart';
import 'DummyCommandableLambdaFunction.dart';

void main() async {
  var awsAccessId = Platform.environment['AWS_ACCESS_ID'];
  var awsAccessKey = Platform.environment['AWS_ACCESS_KEY'];
  var lambdaArn = Platform.environment['LAMBDA_ARN'];
  var config = ConfigParams.fromTuples([
    'logger.descriptor',
    'pip-services:logger:console:default:1.0',
    'service.descriptor',
    'pip-services-dummies:service:default:default:1.0'
  ]);
  var lambdaConfig = ConfigParams.fromTuples([
    'connection.protocol',
    'aws',
    'connection.arn',
    lambdaArn,
    'credential.access_id',
    awsAccessId,
    'credential.access_key',
    awsAccessKey,
    'options.connection_timeout',
    30000
  ]);

  DummyCommandableLambdaFunction lambda;
  DummyCommandableLambdaClient client;

  lambda = DummyCommandableLambdaFunction();
  lambda.configure(config);

  await lambda.open(null);

  client = DummyCommandableLambdaClient();

  client.configure(lambdaConfig);
  await client.open(null);

  var dummy1 = Dummy(id: null, key: 'Key 1', content: 'Content 1');
  var dummy2 = Dummy(id: null, key: 'Key 2', content: 'Content 2');

  // Create one dummy
  try {
    var dummy = await client.createDummy(null, dummy1);
    // work with created item

    dummy1 = dummy!;
  } catch (err) {
    // error processing
  }

  // Create another dummy
  try {
    var dummy = await client.createDummy(null, dummy2);
    // work with second created item
    dummy2 = dummy!;
  } catch (err) {
    // error processing
  }

  // Get all dummies
  try {
    var dummies = await client.getDummies(
        null, FilterParams(), PagingParams(0, 5, false));
    print(dummies);
    // processing recived items
  } catch (err) {
    // error processing
  }

  // Update the dummy
  try {
    dummy1.content = 'Updated Content 1';
    var dummy = await client.updateDummy(null, dummy1);
    // processing with updated item
    dummy1 = dummy!;
  } catch (err) {
    // error processing
  }

  // Delete dummy
  try {
    await client.deleteDummy(null, dummy1.id!);
  } catch (err) {
    // error processing
  }

  // Try to get delete dummy
  try {
    var dummy = await client.getDummyById(null, dummy1.id!);
    print(dummy);
    // work with deleted item
  } catch (err) {
    // error processing
  }
  // close service and client
  await client.close(null);
}
0
likes
130
points
54
downloads

Publisher

verified publisherentinco.com

Weekly Downloads

This framework is part of the [Pip.Services](https://github.com/pip-services/pip-services) project. It contains components for AWS cloud platform.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

aws_client, aws_cloudwatch_api, aws_lambda_dart_runtime, aws_logs_api, collection, http, pip_services4_commons, pip_services4_components, pip_services4_config, pip_services4_container, pip_services4_data, pip_services4_observability, pip_services4_rpc

More

Packages that depend on pip_services4_aws