Giter Club home page Giter Club logo

aws_client's Introduction

High-level APIs for Amazon Web Services (AWS) in Dart

Development

Generate Dart APIs

Generated sources are checked into the repository. To generate the sources, run the following command at the root of the generator folder:

dart bin/generate.dart generate

All commands in generate.dart has the --help command available for more information on usage.

Published generated packages

TODO

  • Implement EC2 protocol

aws_client's People

Contributors

bschulz87 avatar cbatson avatar dmosdallas avatar dreznichuk avatar ipconfiger avatar isoos avatar kmcgill88 avatar lucasdina avatar mohsinhijazee avatar paca94 avatar paulreimer avatar py4x3g avatar schwusch avatar simonbuchan avatar thomas94100 avatar tyrchen avatar xvrh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws_client's Issues

build_runner on +200 packages is very slow

Running pub get and pub run build_runner build on the +200 packages takes a lot of time (>30 minutes on my mac?).

Raw idea:

  • Generate all the API's in a single development package where each API has its own folder.
all_apis
  lib
    aws_accessanalyzer_api
      accessanalyzer-2019-11-01.dart
  • Run build_runner on this all_apis package where it will generate the .g.dart files.
  • Have an other command that copy the content of each folder and generate the corresponding package.

The all_apis package is not necessary versioned.

WDYT?

AWS Cognito implementation

Hi,
I want to implement JS SDK of AWS Cognito in Dart.
I have just started to learn Dart after getting started with Flutter.
So if you please help me to start then I think I can handle the rest.
Best.

SES NoSuchMethodError: Class 'Destination' has no instance method 'toJson'.

Whilst trying out your SES support, I encountered the following exception.

NoSuchMethodError: Class 'Destination' has no instance method 'toJson'.
Receiver: Instance of 'Destination'
Tried calling: toJson()
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1      _flatten (package:shared_aws_api/src/protocol/query.dart:124:17)
#2      _SyncIterator.moveNext (dart:core-patch/core_patch.dart:146:12)
#3      _SyncIterator.moveNext (dart:core-patch/core_patch.dart:139:32)
#4      MapMixin.addEntries (dart:collection/maps.dart:172:23)
#5      new Map.fromEntries (dart:core/map.dart:187:17)
#6      flatQueryParams (package:shared_aws_api/src/protocol/query.dart:89:14)
#7      QueryProtocol._buildRequest (package:shared_aws_api/src/protocol/query.dart:74:26)
#8      QueryProtocol.send (package:shared_aws_api/src/protocol/query.dart:49:16)
#9      SES.sendEmail (package:aws_ses_api/email-2010-12-01.dart:2208:37)

The following code demonstrates this minimally:

import 'package:aws_ses_api/email-2010-12-01.dart';

void main(List<String> arguments) async {
  final cred = AwsClientCredentials(
      accessKey: '',
      secretKey: '');
  final ses = SES(region: 'eu-west-1', credentials: cred);
  await ses.sendEmail(
      destination: Destination(toAddresses: ['[email protected]']),
      message: Message(
        body: Body(
          text: Content(data: 'My test text'),
        ),
        subject: Content(data: 'Test subject'),
      ),
      source: '[email protected]');
}

xml dependency needs to be upgraded because it is conflicting with other aws related packages

The xml package dependency version needs to be bumped because it is conflicting with other aws related packages to be upgraded:

Because aws_dynamodb_api >=0.1.1 depends on shared_aws_api ^0.2.1 which depends on xml ^4.2.0, aws_dynamodb_api >=0.1.1 requires xml ^4.2.0.
And because aws_client 0.2.0 depends on xml ^3.0.0 and no versions of aws_client match >0.2.0 <0.3.0, aws_dynamodb_api >=0.1.1 is incompatible with aws_client ^0.2.0.
So, because oysterpack depends on both aws_client ^0.2.0 and aws_dynamodb_api ^0.1.1, version solving failed.

My work around is to override the xml dependency:

dependency_overrides:
  xml: 4.3.0

version issue

Because every version of flutter_test from sdk depends on xml 3.6.1 and shared_aws_api >=0.2.0 depends on xml ^4.2.0, flutter_test from sdk is incompatible with shared_aws_api >=0.2.0.

And because aws_sns_api >=0.1.0 <0.1.1 depends on shared_aws_api ^0.2.0, flutter_test from sdk is incompatible with aws_sns_api >=0.1.0 <0.1.1.

So, because fitchoo depends on both aws_sns_api 0.1.0 and flutter_test any from sdk, version solving failed.
pub get failed (1; So, because fitchoo depends on both aws_sns_api 0.1.0 and flutter_test any from sdk, version solving failed.)

every flutter_test depends on [xml 3.6.1], but this library depends on [xml 4.2.0].
So you can downgrade xml version on 3.6.1 or even less?

XML List are not extracted correctly

For instance, the generated code for ListRolePoliciesResponse in the IAM API looks like:

  factory ListRolePoliciesResponse.fromXml(_s.XmlElement elem) {
    return ListRolePoliciesResponse(
      policyNames: _s
          .extractXmlChild(elem, 'PolicyNames')
          ?.let((elem) => _s.extractXmlStringListValues(elem, 'PolicyNames')),
    );
  }

return ListRolePoliciesResponse(

However the returned response of AWS is:

<ListRolePoliciesResult>
  <PolicyNames>
    <member>CloudWatchPolicy</member>
    <member>DynamoDBPolicy</member>
  </PolicyNames>
</ListRolePoliciesResult>

So it should use member instead of PolicyNames in the extractXmlStringListValues call.
Or extractXmlStringListValues should not take the tag name and return the content of every children...

Generate example projects

Looking at pub.dev, it seems like the packages get minus points if no example project is present. That should be somewhat easy to do for a minimal example, just instantiating the main service class:

import 'package:aws_sns_api/sns-2010-03-31.dart';

void main() {
  final credentials = AwsClientCredentials(accessKey: '', secretKey: '');
  SNS(region: 'eu-west-1', credentials: credentials);
}

Lock api definitions version in config

We should lock the definitions downloaded from aws-sdk-js in the download command with a config entry, pointing to some adequate reference. That would probably make generation more predictable, and wouldn't require @isoos to carefully save the api definitions between versions.

type error in underlying sigv4 client

Hi again!

I'm trying to generate the AWS logs api for Cloudwatch and I'm getting the following error. I think it's due to the version of sigv4 being used.

// Line client.dart:117-118
headers[_x_amz_decoded_content_length] = utf8.encode(body).length;
headers['Content-Length'] = utf8.encode(body).length;
#0      _LinkedHashMapMixin.[]= (dart:collection-patch/compact_hash.dart)
#1      Sigv4Client.signedHeaders (package:sigv4/src/client.dart:117:14)
#2      Sigv4Client.request (package:sigv4/src/client.dart:187:5)
#3      JsonProtocol.sendRequest (package:shared_aws_api/src/protocol/json.dart:85:33)
#4      JsonProtocol.send (package:shared_aws_api/src/protocol/json.dart:55:22)
#5      CloudWatchLogs.putLogEvents (package:aws_logs_api/logs-2014-03-28.dart:2224:42)

The problem seems to be fixed in sigv4: 4.0.0. I used a dependency override to verify. Although the interface to the client changed and it expects a body of type string, not Map:

[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: type '_InternalLinkedHashMap<String, Object>' is not a subtype of type 'String'
#0      JsonProtocol.sendRequest (package:shared_aws_api/src/protocol/json.dart:90:17)
#1      JsonProtocol.send (package:shared_aws_api/src/protocol/json.dart:55:22)
#2      CloudWatchLogs.putLogEvents (package:aws_logs_api/logs-2014-03-28.dart:2224:42)

I updated json.dart:84-94 to the following and it seemed to fix the problem:

      case 'POST':
        final jsonBody = json.encode(body);
        final rq = _sigv4client.request(
          url,
          method: method.toUpperCase(),
          query: queryParams,
          headers: headers,
          body: jsonBody,
        );
        rs = await _client.post(rq.url, headers: rq.headers, body: rq.body);
        break;

Kinesis video stream, Video not showing in Kinesis console

I'm using the below code to create a video stream. However, the video is not getting streamed at the Kinesis console

class CameraPage extends StatefulWidget {
  @override
  _CameraPageState createState() => _CameraPageState();
}

class _CameraPageState extends State<CameraPage> {

  CameraController controller;
  var index=0;
  final service = KinesisVideo(region: 'ap-south-1',credentials: AwsClientCredentials
    (accessKey: "XXXXXXXXXXXXXXXXXX",
    secretKey: "XXXXXXXXXXXXXXXX",),);

  @override
  void initState() {
    controller = CameraController(cameras[index], ResolutionPreset.medium);
    controller.initialize().then((_) {
      if (!mounted) {
        return;
      }
      setState(() {});
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    final mediaQuery=MediaQuery.of(context).size;
    if (!controller.value.isInitialized) {
      return Container();
    }
    return Scaffold(
      body: Container(
        width: mediaQuery.width,
        height: mediaQuery.height*0.9,
        child: Stack(
          children: [
            CameraPreview(controller),
            Positioned(bottom: 20,
            child: Container(
              width: mediaQuery.width,
              child: Row(
                children: [
                  Spacer(),
                  Container(width: 40.0,),
                  Spacer(),
                  InkWell(
                    onTap: (){
                      service.createStream(streamName: "demo7_stream",dataRetentionInHours: 24,
                          mediaType: "video/h264",kmsKeyId: "b2e58180-ed42-471a-a1e3-02a4527c5919",
                        deviceName: "Redmi"
                          );
                    },
                    child: Container(
                      width: 100.0,
                      height: 100.0,
                      decoration: BoxDecoration(
                        color: Colors.red,
                        shape: BoxShape.circle,
                      ),
                      child: Center(
                        child: Text('Emergency',style: TextStyle(color: Colors.white),),
                      ),
                    ),
                  ),
                  Spacer(),
                  IconButton(icon: Icon(Icons.switch_camera,size: 40.0,color: Colors.white,),onPressed: (){
                    setState(() {
                      if(index==0){
                        index=1;
                      }else{
                        index=0;
                      }
                      controller = CameraController(cameras[index], ResolutionPreset.high);
                      controller.initialize().then((_) {
                        if (!mounted) {
                          return;
                        }
                        setState(() {});
                      });
                    });
                  },),
                  Spacer(),
                ],
              ),
            ),),


          ],
        ),
      ),
    );
  }
}

The Logcat for this application

2020-09-14 23:29:44.512 19450-19450/com.bjofficial.testing_kinesis W/testing_kinesis: type=1400 audit(0.0:529442): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=12941 scontext=u:r:untrusted_app:s0:c60,c259,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-09-14 23:29:44.527 19450-19450/com.bjofficial.testing_kinesis E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 23:29:52.292 19450-19450/com.bjofficial.testing_kinesis W/Binder:19450_5: type=1400 audit(0.0:529446): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=12941 scontext=u:r:untrusted_app:s0:c60,c259,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-09-14 23:29:52.310 19450-19903/com.bjofficial.testing_kinesis E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 23:29:52.391 19450-19903/com.bjofficial.testing_kinesis E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 23:29:52.372 19450-19450/com.bjofficial.testing_kinesis W/Binder:19450_5: type=1400 audit(0.0:529448): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=12941 scontext=u:r:untrusted_app:s0:c60,c259,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-09-14 23:29:52.422 19450-19482/com.bjofficial.testing_kinesis W/testing_kinesi: Long monitor contention with owner main (19450) at void android.hardware.camera2.impl.CameraDeviceImpl.close()(CameraDeviceImpl.java:1174) waiters=0 in void android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.onResultReceived(android.hardware.camera2.impl.CameraMetadataNative, android.hardware.camera2.impl.CaptureResultExtras, android.hardware.camera2.impl.PhysicalCaptureResultInfo[]) for 569ms
2020-09-14 23:29:52.472 19450-19450/com.bjofficial.testing_kinesis W/testing_kinesis: type=1400 audit(0.0:529449): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=12941 scontext=u:r:untrusted_app:s0:c60,c259,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-09-14 23:29:52.489 19450-19450/com.bjofficial.testing_kinesis E/libc: Access denied finding property "persist.vendor.camera.privapp.list"
2020-09-14 23:29:52.552 19450-19450/com.bjofficial.testing_kinesis W/Binder:19450_5: type=1400 audit(0.0:529451): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=12941 scontext=u:r:untrusted_app:s0:c60,c259,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-09-14 23:29:52.570 19450-19903/com.bjofficial.testing_kinesis E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 23:29:52.592 19450-19903/com.bjofficial.testing_kinesis E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 23:30:52.839 19450-19450/com.bjofficial.testing_kinesis W/Looper: Slow Looper main: doFrame is 336ms late because of 2 msg, msg 1 took 217ms (h=android.app.ActivityThread$H w=159), msg 2 took 108ms (late=230ms h=android.app.ActivityThread$H w=137)
2020-09-14 23:30:53.755 19450-19450/com.bjofficial.testing_kinesis W/Looper: Slow Looper main: Activity com.bjofficial.testing_kinesis/.MainActivity is 388ms late (wall=50ms running=0ms ClientTransaction{ lifecycleRequest=android.app.servertransaction.PauseActivityItem }) because of 7 msg, msg 1 took 110ms (late=55ms h=android.app.ActivityThread$H w=159), msg 2 took 275ms (late=42ms h=android.view.Choreographer$FrameHandler w=0)
2020-09-14 23:30:54.166 19450-19450/com.bjofficial.testing_kinesis W/Looper: Slow Looper main: Activity com.bjofficial.testing_kinesis/.MainActivity is 381ms late (wall=9ms running=0ms ClientTransaction{ lifecycleRequest=android.app.servertransaction.StopActivityItem }) because of 23 msg, msg 20 took 269ms (late=127ms h=android.view.Choreographer$FrameHandler c=android.view.Choreographer$FrameDisplayEventReceiver)
2020-09-14 23:30:58.938 19450-19700/com.bjofficial.testing_kinesis E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 23:30:58.922 19450-19450/com.bjofficial.testing_kinesis W/Binder:19450_4: type=1400 audit(0.0:529520): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=12941 scontext=u:r:untrusted_app:s0:c60,c259,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-09-14 23:30:58.988 19450-19700/com.bjofficial.testing_kinesis E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 23:30:58.999 19450-19506/com.bjofficial.testing_kinesis W/testing_kinesi: Long monitor contention with owner main (19450) at boolean android.os.BinderProxy.transactNative(int, android.os.Parcel, android.os.Parcel, int)(Binder.java:-2) waiters=0 in void android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.onCaptureStarted(android.hardware.camera2.impl.CaptureResultExtras, long) for 523ms
2020-09-14 23:30:59.113 19450-19506/com.bjofficial.testing_kinesis E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-09-14 23:31:05.375 19450-19506/com.bjofficial.testing_kinesis E/libc: Access denied finding property "vendor.camera.aux.packagelist"

The terminal output when trying to create the stream

Performing hot restart...
Syncing files to device Redmi Note 7S...
Restarted application in 21,878ms.
W/testing_kinesis(19450): type=1400 audit(0.0:529442): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=12941 scontext=u:r:untrusted_app:s0:c60,c259,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
E/libc    (19450): Access denied finding property "vendor.camera.aux.packagelist"
W/Binder:19450_5(19450): type=1400 audit(0.0:529446): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=12941 scontext=u:r:untrusted_app:s0:c60,c259,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
E/libc    (19450): Access denied finding property "vendor.camera.aux.packagelist"
E/libc    (19450): Access denied finding property "vendor.camera.aux.packagelist"
W/Binder:19450_5(19450): type=1400 audit(0.0:529448): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=12941 scontext=u:r:untrusted_app:s0:c60,c259,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
W/testing_kinesi(19450): Long monitor contention with owner main (19450) at void android.hardware.camera2.impl.CameraDeviceImpl.close()(CameraDeviceImpl.java:1174) waiters=0 in void android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.onResultReceived(android.hardware.camera2.impl.CameraMetadataNative, android.hardware.camera2.impl.CaptureResultExtras, android.hardware.camera2.impl.PhysicalCaptureResultInfo[]) for 569ms
W/testing_kinesis(19450): type=1400 audit(0.0:529449): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=12941 scontext=u:r:untrusted_app:s0:c60,c259,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
E/libc    (19450): Access denied finding property "persist.vendor.camera.privapp.list"
W/Binder:19450_5(19450): type=1400 audit(0.0:529451): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=12941 scontext=u:r:untrusted_app:s0:c60,c259,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
E/libc    (19450): Access denied finding property "vendor.camera.aux.packagelist"
E/libc    (19450): Access denied finding property "vendor.camera.aux.packagelist"
W/Looper  (19450): Slow Looper main: doFrame is 336ms late because of 2 msg, msg 1 took 217ms (h=android.app.ActivityThread$H w=159), msg 2 took 108ms (late=230ms h=android.app.ActivityThread$H w=137)
W/Looper  (19450): Slow Looper main: Activity com.bjofficial.testing_kinesis/.MainActivity is 388ms late (wall=50ms running=0ms ClientTransaction{ lifecycleRequest=android.app.servertransaction.PauseActivityItem }) because of 7 msg, msg 1 took 110ms (late=55ms h=android.app.ActivityThread$H w=159), msg 2 took 275ms (late=42ms h=android.view.Choreographer$FrameHandler w=0)
W/Looper  (19450): Slow Looper main: Activity com.bjofficial.testing_kinesis/.MainActivity is 381ms late (wall=9ms running=0ms ClientTransaction{ lifecycleRequest=android.app.servertransaction.StopActivityItem }) because of 23 msg, msg 20 took 269ms (late=127ms h=android.view.Choreographer$FrameHandler c=android.view.Choreographer$FrameDisplayEventReceiver)
E/libc    (19450): Access denied finding property "vendor.camera.aux.packagelist"
W/Binder:19450_4(19450): type=1400 audit(0.0:529520): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=12941 scontext=u:r:untrusted_app:s0:c60,c259,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
E/libc    (19450): Access denied finding property "vendor.camera.aux.packagelist"
W/testing_kinesi(19450): Long monitor contention with owner main (19450) at boolean android.os.BinderProxy.transactNative(int, android.os.Parcel, android.os.Parcel, int)(Binder.java:-2) waiters=0 in void android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.onCaptureStarted(android.hardware.camera2.impl.CaptureResultExtras, long) for 523ms
E/libc    (19450): Access denied finding property "vendor.camera.aux.packagelist"
E/libc    (19450): Access denied finding property "vendor.camera.aux.packagelist"

Here is the image file from the kinesis console

Screen Shot 2020-09-14 at 11 34 35 PM

Make a new package named 'core' for shared code

I think it is time to break with the old aws_client package, and put shared code for generated packages in a new package named core. It is a bit messy, and does not make semantic sense to use the old package.

It will probably make users confused as well, to "reuse" the aws_client package in this way. Versioning would probably also be easier since we're starting at zero with a new package.

Improve enum parameters

I would like better type safety and user ergonomics for enumerated parameters.

A suggestion would be enums with extensions:

enum AttributeAction {
  ADD,
  PUT,
  DELETE
}

extension on AttributeAction {
  String get name {
    switch (this) {
      case AttributeAction.ADD:
        return 'ADD';
      case AttributeAction.PUT:
        return 'PUT';
      case AttributeAction.DELETE:
        return 'DELETE';
    }
    throw Exception('This will never throw');
  }
}

This would be received as such:

foo(AttributeAction action) {
  bar(action.name)
}

And the call foo() would be:

foo(AttributeAction.ADD) ;

@isoos, what do you think?

Unhandled Exception: NoSuchMethodError: The getter 'keys' was called on null.

Key was called on NULL

I created the new project and I used this aws_kinesisvideo_api package to send the live video broadcast to AWS but I'm getting this error while using this package. I couldn't find any clear documents about how to parse the parameters for KinesisVideo() constructor and even if I pass all the parameters I'm still getting this error. can anyone please help me to find the solution on this

pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  aws_kinesisvideo_api: ^0.0.2
  camera: ^0.5.8+5

CameraPage.dart

class CameraPage extends StatefulWidget {
  @override
  _CameraPageState createState() => _CameraPageState();
}

class _CameraPageState extends State<CameraPage> {

  CameraController controller;
  var index=0;
  final service = KinesisVideo(region: 'ap-south-1',credentials: AwsClientCredentials
    (accessKey: "XXXXXXXXXXXXXXXXXXXXXX",
    secretKey: "XXXXXXXXXXXXXXXXXXXXXX",),);

  @override
  void initState() {
    controller = CameraController(cameras[index], ResolutionPreset.medium);
    controller.initialize().then((_) {
      if (!mounted) {
        return;
      }
      setState(() {});
    });
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    final mediaQuery=MediaQuery.of(context).size;
    if (!controller.value.isInitialized) {
      return Container();
    }
    return Scaffold(
      body: Container(
        width: mediaQuery.width,
        height: mediaQuery.height*0.9,
        child: Stack(
          children: [
            CameraPreview(controller),
            Positioned(bottom: 20,
            child: Container(
              width: mediaQuery.width,
              child: Row(
                children: [
                  Spacer(),
                  Container(width: 40.0,),
                  Spacer(),
                  InkWell(
                    onTap: (){
                      service.createStream(streamName: "demo_stream",
                          );
                    },
                    child: Container(
                      width: 100.0,
                      height: 100.0,
                      decoration: BoxDecoration(
                        color: Colors.red,
                        shape: BoxShape.circle,
                      ),
                      child: Center(
                        child: Text('Emergency',style: TextStyle(color: Colors.white),),
                      ),
                    ),
                  ),
                  Spacer(),
                  IconButton(icon: Icon(Icons.switch_camera,size: 40.0,color: Colors.white,),onPressed: (){
                    setState(() {
                      if(index==0){
                        index=1;
                      }else{
                        index=0;
                      }
                      controller = CameraController(cameras[index], ResolutionPreset.high);
                      controller.initialize().then((_) {
                        if (!mounted) {
                          return;
                        }
                        setState(() {});
                      });
                    });
                  },),
                  Spacer(),
                ],
              ),
            ),),
          ],
        ),
      ),
    );
  }
}

The error message

[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: NoSuchMethodError: The getter 'keys' was called on null.
E/flutter ( 7820): Receiver: null
E/flutter ( 7820): Tried calling: keys
E/flutter ( 7820): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter ( 7820): #1      MapMixin.addAll (dart:collection/maps.dart:128:25)
E/flutter ( 7820): #2      RestJsonProtocol.send (package:shared_aws_api/src/protocol/rest-json.dart:55:16)
E/flutter ( 7820): #3      KinesisVideo.createStream (package:aws_kinesisvideo_api/kinesisvideo-2017-09-30.dart:242:38)
E/flutter ( 7820): #4      _CameraPageState.build.<anonymous closure> (package:testing_kinesis/main.dart:130:38)
E/flutter ( 7820): #5      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:953:19)
E/flutter ( 7820): #6      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1059:38)
E/flutter ( 7820): #7      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 7820): #8      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:522:11)
E/flutter ( 7820): #9      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
E/flutter ( 7820): #10     BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7)
E/flutter ( 7820): #11     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9)
E/flutter ( 7820): #12     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter ( 7820): #13     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter ( 7820): #14     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter ( 7820): #15     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter ( 7820): #16     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter ( 7820): #17     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter ( 7820): #18     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter ( 7820): #19     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter ( 7820): #20     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter ( 7820): #21     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter ( 7820): #22     _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter ( 7820): #23     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 7820): #24     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter ( 7820): #25     _invoke1 (dart:ui/hooks.dart:281:10)
E/flutter ( 7820): #26     _dispatchPointerDataPacket (dart:ui/hooks.dart:190:5)

I'm not sure what is right and wrong here so can anyone provides the clear documents for this aws_kinesisvideo_api and the demo code snippet for making this app send the video stream data to AWS

Make AwsClientCredentials constructor argument optional

In the JS SDK the usage is more ergonomic:

const secretsManager = new AWS.SecretsManager({ 'region':  'eu-west-1' });
...

This step:

final environment = Platform.environment;
final credentials = AwsClientCredentials(
  accessKey: environment['AWS_ACCESS_KEY_ID'],
  secretKey: environment['AWS_SECRET_ACCESS_KEY'],
  sessionToken: environment['AWS_SESSION_TOKEN'],
);
// final secretsManager = SecretsManager(region: region, credentials: credentials);

We should be able to do that step in the protocol factory constructor if credentials are null.
That change would make onboarding new users smoother.

AWS Image Upload

Is there any means now to use the library now for uploading AWS photos to an S3 storage bucket ?

DocumentClient scan not working?

Hi, I tried a simple scan with the new DocumentClient library and I get the following error:

Unhandled exception:
NoSuchMethodError: The method 'map' was called on null.
Receiver: null
Tried calling: map<String, AttributeValue>(Closure: (String, dynamic) => MapEntry<String, AttributeValue>)
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1      DynamicTranslator.fromJsonToAttributeValue (package:document_client/src/translator.dart:61:7)
#2      DocumentClient.scan (package:document_client/document_client.dart:353:44)

command I issued

  final dynamodb = DocumentClient(region: region);
  var scan = await dynamodb.scan(
      tableName: "tableName");

[BUG] Error When Flattening MessageAttributeValue and MessageSystemAttributeValue

When sending an SQS message, the library attempts to flatten the extra parameters from sendMessage() at sqs-2012-11-15.dart:1681 in the auto generated package. The optional parameters are for the messageAttributes (Map<String, MessageAttribute>) and messageSystemAttributes (Map<String, MessageSystemAttribute>). Somewhere down the line, send() gets called at query.dart:42 in the shared auto generated package which calls _buildRequest() > flatQueryParams() > _flatten() all in the same file. _flatten checks for the type to flatten it for the request but fails because there is no case to handle MessageAttribute or MessageSystemAttribute. I would fix and submit another PR but I don't really have the time. Here is the error:

[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: Invalid argument(s): Unknown type at "MessageAttributes.entry.1.value": MessageAttributeValue (Instance of 'MessageAttributeValue')
#0      _flatten (package:shared_aws_api/src/protocol/query.dart:140:3)
#1      _SyncIterator.moveNext (dart:core-patch/core_patch.dart:146:12)
#2      _SyncIterator.moveNext (dart:core-patch/core_patch.dart:139:32)
#3      _SyncIterator.moveNext (dart:core-patch/core_patch.dart:139:32)
#4      MapMixin.addEntries (dart:collection/maps.dart:172:23)
#5      new Map.fromEntries (dart:core/map.dart:187:17)
#6      flatQueryParams (package:shared_aws_api/src/protocol/query.dart:89:14)
#7      QueryProtocol._buildRequest (package:shared_aws_api/src/protocol/query.dart:74:26)
#8      QueryProtocol.send (package:shared_aws_api/src/protocol/query.dart:49:16)
#9      SQS.sendMessage (package:aws_sqs_api/sqs-2012-11-05.dart:1705:37)

EDIT: Here is my code causing the error:

    sqs.sendMessage(
        messageBody: unsentEntries[i].toJson().toString(),
        queueUrl: sqsUrl,
        messageGroupId: unsentEntries[i].company.shortName.replaceAll(' ', ''),
        messageDeduplicationId: utils.getUuid(),
        messageAttributes: <String, MessageAttributeValue>{
          'companyId': new MessageAttributeValue(dataType:'string', stringValue: unsentEntries[i].company.id)
        });

putObject working but throws error

Hello, s3 upload successful but throws error
return error message = ""<" expected"

My code:

try {
  await service.putObject(
    bucket: bucketName,
    key: fileName,
    body: imageFile.readAsBytesSync(),
    acl: ObjectCannedACL.publicRead,
  );
} catch (ex) {
  var error= ex;
}

Rename LICENSE.txt -> LICENSE

When publishing the generated packages, we get the following warning:

Package validation found the following potential issue:
* Please consider renaming LICENSE.txt to `LICENSE`.
  See https://dart.dev/tools/pub/publishing#important-files.

" method, newHttpClient() is not found" ERROR !!!

I tried to build a sample example as main.dart after referring below link on andoirdstudio.
https://pub.dev/packages/aws_client, https://pub.dev/packages/aws_client

`
import 'package:aws_client/aws_client.dart';
import 'package:http_client/console.dart';

main() async {
var httpClient = newHttpClient();
var credentials = new Credentials(accessKey: 'MY_ACCESS_KEY', secretKey: 'MY_SECRET_KEY');
var aws = new Aws(credentials: credentials, httpClient: httpClient);
var queue = aws.sqs.queue('https://my-queue-url/number/queue-name');
await queue.sendMessage('Hello from Dart client!');
httpClient.close();
}

`

But I git the following error at logs:

"method, newHttpClient() is not found"

Please, let me know how to solve this error.
Thanks in advance.

main library for each generated package

Right now we get a warning when publishing to pub:

* The name of "lib/route53-2013-04-01.dart", "route53-2013-04-01", should match the name of the package, "aws_route53_api".
This helps users know what library to import.

Lambda.createFunction doesn't work if "publish" is not specified

The publish argument is optional. But if it is not provided, the library puts a null value in the request payload which results in a 500 InternalFailure error.

I guess the generated code should build a map only with the arguments that are not null:

final $payload = <String, dynamic>{
      'Code': code,
      //...
      if (publish != null)
        'Publish': publish,
    };

Or filter it before the jsonEncode.

snake_case conversions

I've noticed that a lot of the enum values have snake_case format, which we may transform to lowerCamelCase (or whatever the name for it is). For some it works fine, but for e.g. usEast1 it is debatable if it is better than us_east_1). @Schwusch wdyt?

[DocumentClient] put method does not handle null for 'expected' parameter

Hi,

I tried to use the put method with only tableName and item parameter and I get the following error:

NoSuchMethodError: The method 'map' was called on null.
Receiver: null
Tried calling: map<String, ExpectedAttributeValue>(Closure: (String, ExpectedAttributeValueDC) => MapEntry<String, ExpectedAttributeValue>)
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1      DocumentClient.put (package:document_client/document_client.dart:239:26)
#2      main (package:dart_lambdas/apigateway2.dart:33:12)
#3      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

Seems that the value null is not handled for the expected value. Maybe there is only an ? missing in document_client.dart:239 ?

Edit: yes an ? solves the problem. Line 239 should be

expected: expected?.map((key, value) => MapEntry(

AWS dynamodb Bug for ReturnConsumedCapacity

Hi,

thank you for your library. The aws_dynamodb_api is already working really fine.

I think I found a small bug, the ReturnConsumedCapacity is not working. When I use the option returnConsumedCapacity: ReturnConsumedCapacity.total for a query or an update operation (DynamoDB.updateItem/DynamoDB.query) I get the following errors.

for a query:

Unhandled exception:
Converting object to an encodable object failed: Instance of 'ReturnConsumedCapacity'
#0      _JsonStringifier.writeObject (dart:convert/json.dart:659:7)
#1      _JsonStringifier.writeMap (dart:convert/json.dart:740:7)
#2      _JsonStringifier.writeJsonValue (dart:convert/json.dart:695:21)
#3      _JsonStringifier.writeObject (dart:convert/json.dart:650:9)
#4      _JsonStringStringifier.printOn (dart:convert/json.dart:846:17)
#5      _JsonStringStringifier.stringify (dart:convert/json.dart:831:5)
#6      JsonEncoder.convert (dart:convert/json.dart:260:30)
#7      JsonCodec.encode (dart:convert/json.dart:168:45)
#8      JsonProtocol.send (package:shared_aws_api/src/protocol/json.dart:53:45)
#9      DynamoDB.query (package:aws_dynamodb_api/dynamodb-2012-08-10.dart:3006:42)

for an update:

Unhandled exception:
Converting object to an encodable object failed: Instance of 'ReturnConsumedCapacity'
#0      _JsonStringifier.writeObject (dart:convert/json.dart:659:7)
#1      _JsonStringifier.writeMap (dart:convert/json.dart:740:7)
#2      _JsonStringifier.writeJsonValue (dart:convert/json.dart:695:21)
#3      _JsonStringifier.writeObject (dart:convert/json.dart:650:9)
#4      _JsonStringStringifier.printOn (dart:convert/json.dart:846:17)
#5      _JsonStringStringifier.stringify (dart:convert/json.dart:831:5)
#6      JsonEncoder.convert (dart:convert/json.dart:260:30)
#7      JsonCodec.encode (dart:convert/json.dart:168:45)
#8      JsonProtocol.send (package:shared_aws_api/src/protocol/json.dart:53:45)
#9      DynamoDB.updateItem (package:aws_dynamodb_api/dynamodb-2012-08-10.dart:4679:42)

Latest versions on pub

Hi!

Thanks for the great work! I'm looking to use the generated APIs here and I was wondering if it would be possible to publish the latest library version on pub. I generated the API for the aws_logs_api and it requires the latest version of the aws_shared_api to be published with the JSON protocol's send function available.

Thanks

S3 requests is not correctly signed

My request are failing with the following

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>There were headers present in the request which were not signed</Message><HeadersNotSigned>x-amz-security-token</HeadersNotSigned><RequestId>redacted</RequestId><HostId>redacted</HostId></Error>

Lambda

Great work on this package!

My itch is invoking Lambda's from Dart. If I implement that are you open to PR's?

http library version upgrade

Hi!

Thanks for the great work! I'm looking to use the generated APIs here and I was wondering if it would be possible to upgrade the version of http. I'm getting a version incompatibility error when running pub upgrade.

Thanks

One package vs. multiple packages for generated code.

/cc @Schwusch

The current aws_client/lib/generated directory is 28MB. package:googleapis is a similar package, it is generated from service definitions, and it already had issues on pub.dev with dartdoc-generation or analysis timing out.

Should we aim for N smaller packages instead of one big "everything-in-it" package?

Write a DocumentClient for DynamoDB

As good as the DynamoDB api works now, it's not very ergonomic. The JS SDK has what is called a DocumentClient that eases use of DynamoDB.

It should be possible to write a similar package for Dart. Question is if it should be a separate package or incorporated in the generated package.

@isoos WDYT?

Tackle signing protocols

It seems we have overlooked signing protocols a bit, as showed in #238, and I think it's time to get an overview of what we need to support.

This issue is for tracking the work towards supporting the missing signing protocols.

Support hostPrefix option in operation model

It seems the operations can customise the endPoint to use by adding a prefix

  "operations": {
    "AssociateAssets": {
      "name": "AssociateAssets",
      "http": {
        "method": "POST",
        "requestUri": "/assets/{assetId}/associate"
      },
      "endpoint": {
        "hostPrefix": "model."
      }
    }

We should probably add that option to the send methods of the protocol and adapt the internal _endpoint.url.

Some tests in the generated suite cover this behaviour.

[DocumentClient] How to add a List of Numbers (not a NumberSet)?

Hi,
how do I add a List of Numbers to the database? The translator is translating any number list to a NumberSet which is not ordered and completely random in the dynamodb (translator.dart:19). Maybe we should check if the value is already an AttributeValue and return it in this case in the toAttributeValue method? With this I could just create the AttributeValue with a value l of a list of AttributeValues with type number like

  List<AttributeValue> dataListToAdd = [];

  for (var myNumber in [1,2,3]) {
    dataListToAdd.add(AttributeValue(n: myNumber.toString()));
  }
  var myValue = AttributeValue(l: dataListToAdd);

This was how it works with the DynamoDB class before. But currently this will create a json object and this will store it as a Map.
But that's only my first idea, maybe there is something better. Because it seems a bit random if the library uses a list or a set but this makes a huge difference for the user of the library.

Edit: I tried the simple fix by adding

  } else if (value is AttributeValue) {
    return value;
  }

to the toAttributeValue method and it is working for me.

DocumentClient update bug?

Now I get an error if I try to run the DocumentClient.update method.
Although I specified the keys I get the following error:

Unhandled exception:
Invalid argument(s) (key): Must not be null
#0      ArgumentError.checkNotNull (dart:core/errors.dart:196:27)
#1      DynamoDB.updateItem (package:aws_dynamodb_api/dynamodb-2012-08-10.dart:4660:19)
#2      DocumentClient.update (package:document_client/document_client.dart:398:31)

I guess something is wrong in line 399 of document_client.dart, since the transformation (key: key.fromJsonToAttributeValue()) is returning null...

Generate tests

We should be able to generate protocol test cases, much like aws-sdk-go.
It would help development a lot to know if the implementations are correct.

Write a full-featured SDK based on code generation and predefined API definitions

Suggestion

I suggest a discussion about a general solution in order to make a feature complete Dart AWS SDK.

What has been done

I made an attempt to generate all AWS services, statically typed, by building a general source code generator. This seemed promising until I realised all nuances and the complexity of AWS services in aggregate.

Idea

Why not copy the JS SDK architecture, and just type it statically at the bounds of the API.

TypedClassInputArgument -> serviceFunction() -> TypedClassInputArgument.toJson() -> JS SDK implemented in Dart -> JSON -> TypedClassOutput.fromJson()

By this design, the architecture and reference implementation would be given. Most of the specifics of Dart, such as signing requests, etc, is already solved. The underlying architecture would need to be implemented, such as the core and protocols.

It would then be as easy as to prepend a JSON defined API with final Map<String, dynamic> definition = and rename the file to .dart in order to have a statically compilable Dart Map to load in runtime.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.