Code Monkey home page Code Monkey logo

Comments (17)

Schwusch avatar Schwusch commented on September 13, 2024 1

I did some digging.
The JS SDK uses a QueryParamSerializer in the query protocol.
It in its turn uses metadata from the spec to serialize the data.
The spec gives that the locationName should be Value.
Maybe it gives some pointers.

from aws_client.

isoos avatar isoos commented on September 13, 2024 1

Looks like we are not alone in this issue: pplu/aws-sdk-perl#267

Btw. I've just noticed, that the expected format not only flattens the Map of Map, but also removes the plural from the attribute name. Which is a bit tricky, but I guess we should do it too...

from aws_client.

isoos avatar isoos commented on September 13, 2024 1

I think this issue cannot be solved with the current [ShapeClass].toJson() output and generic flatten method. We'll need to generate e.g. an inlined toFlatMap(String prefix) that will provide the map based on the shape's config, and "inlined" values will (should) know what to do.

from aws_client.

Schwusch avatar Schwusch commented on September 13, 2024 1

@Dvoikin I don't have time to work on it in the near future, but send us a pull request and we'll have a look at it!
It seems @isoos gave it a shot, that commit can perhaps give some pointers.

from aws_client.

lucasdina avatar lucasdina commented on September 13, 2024

I previously lied when I said I didn't have time. Working on a PR right now XD

from aws_client.

isoos avatar isoos commented on September 13, 2024

This is a difficult problem. The data type SQS is using is rich:
https://github.com/agilord/aws_client/blob/master/generated/aws_sqs_api/lib/sqs-2012-11-05.dart#L2470-L2522

However, we only have the basic algorithm for flattening the arguments:
https://github.com/agilord/aws_client/blob/master/shared_aws_api/lib/src/protocol/query.dart#L92-L142

@Schwusch: any idea how we should approach this?

@lucasdina: do you happen to know the wire format of your request? (e.g. what should be the body format if you specify the attributes?)

from aws_client.

lucasdina avatar lucasdina commented on September 13, 2024

@isoos
Here's what the body should look like:

Action=SendMessage&MessageAttribute.1.Name=testAttribute&MessageAttribute.1.Type=String&MessageAttribute.1.Value=ab0c6c4e50ce4bcd8709eefdbd533a35&MessageBody=%7B%22test%22%3A+%22cool%22%7D&MessageDeduplicationId=8c1056b07c8f11eaf1cde9f670f7ada1&MessageGroupId=testGroup1&QueueUrl={mySQSUrl}&Version=2012-11-05

^^ Ignore this body. That is an incorrect format
MessageAttribute and MessageSystemAttribute (now shown) are both maps and have the same format with the exception of the object name. In my PR I pretty much hard coded the MessageAttribute prefixes.

from aws_client.

isoos avatar isoos commented on September 13, 2024

@lucasdina: Thanks!

That's even more interesting: we'd need to map DataType to Type, and StringValue to Value. I don't see anything in the JSON API spec that would help us to do that automatically.

@Schwusch: what if we introduce an interface that the shared API can interpret, and make a special case in the codegen for this MessageAttribute? That seems to me the least bad resolution of this so far...

from aws_client.

Schwusch avatar Schwusch commented on September 13, 2024

Sorry, I don't have much time to dig in to this right now, but I would look at the Javascript implementation for reference. That would probably clarify things.

from aws_client.

lucasdina avatar lucasdina commented on September 13, 2024

@isoos I apologize, I accidently sent the wrong body. That was the one I had in my notes for some reason. This one is the one what SQS accepts:

Action=SendMessage&MessageAttribute.1.Name=testattrib&MessageAttribute.1.Value.DataType=String&MessageAttribute.1.Value.StringValue=test&MessageBody=%7B%22test%22%3A+%22cool%22%7D&MessageDeduplicationId=4a7f57c07cf611eaf1cde9f670f7ada1&MessageGroupId=AgriPayFarms&QueueUrl={sqsUrl}&Version=2012-11-05

It requires that extra '.Value' prefix.

from aws_client.

isoos avatar isoos commented on September 13, 2024

Ah, okay, the updated body seems to be better: we still need to generate a toJson() method for it, but it could be much more generic.

from aws_client.

Schwusch avatar Schwusch commented on September 13, 2024

@isoos The current flattening algorithm looks alright, the arguments just need to be json, as you said.
I guess the query protocol has to be added in Api.generateToJson and the arguments has to be serialized here and here. I think that's a good start atleast.

from aws_client.

Dvoikin avatar Dvoikin commented on September 13, 2024

@Schwusch this issue is still actual for our project. When it will be fixed?

from aws_client.

Schwusch avatar Schwusch commented on September 13, 2024

This should be fixed in version 0.1.1. @Dvoikin @lucasdina Can you verify?

from aws_client.

Schwusch avatar Schwusch commented on September 13, 2024

I'll close this for now, the activity indicates that this issue is either solved or not a problem anymore.

from aws_client.

Dvoikin avatar Dvoikin commented on September 13, 2024

@Schwusch sorry for the delay. We checked your updates and, unfortunately, they do not work for AWS SNS. We are trying to configure the service for sending SMS. Below is the code:

var credentials = AwsClientCredentials(
        accessKey: ***,
        secretKey: ***);
sns = SNS(region: 'eu-west-1', credentials: credentials); // Error occurred here

We see the next error message: Exception has occurred.
_CastError (type '_ImmutableMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast)

In case when we put shapes = null initialization instead of

shapes = shapesJson
            .map((key, value) => MapEntry(key, _s.Shape.fromJson(value)));

in SNS class, it works, but, of course, we face issues later bc shapes are null.

Hopefully, it will help you. But it still doesn't work for us.

from aws_client.

Schwusch avatar Schwusch commented on September 13, 2024

Thanks for replying!
I just tried and adding SNS 0.1.1 to another project I'm working on, just initializing it like so:

final sns = SNS(region: 'eu-west-1', credentials: AwsClientCredentials(accessKey: '', secretKey: ''));

It compiled and did not throw any runtime errors. I suspect it will work if you run pub upgrade in your project, getting the latest shared_aws_api. Tell me if that doesn't work.

from aws_client.

Related Issues (20)

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.