Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon SNS #28

Open
electic opened this issue Mar 26, 2016 · 12 comments
Open

Amazon SNS #28

electic opened this issue Mar 26, 2016 · 12 comments

Comments

@electic
Copy link

electic commented Mar 26, 2016

Great library. Any plans to support SNS?

@jkakar
Copy link
Owner

jkakar commented Mar 26, 2016

Thanks @electic! Yes, it's on my todo list, I just haven't managed to find time to get there. SNS uses the query protocol which involves converting XML from the service to Erlang and Elixir maps, and vice versa, which is a bit tricky. I'll get there eventually, but can't promise when right now.

@electic
Copy link
Author

electic commented Mar 26, 2016

No problem. Thank you!

@brentonannan
Copy link

... I completely missed this issue before doing my PRs. Apologies if I've wasted time, @jkakar.

@jkakar
Copy link
Owner

jkakar commented Apr 12, 2016

@brentonannan Not a waste at all, please ask questions whenever they come up, I'm happy to try and help if I can! I'm not expecting to get to this issue anytime in the next few weeks, so if you have energy to put here, I'd welcome contributions. The same kind of issue that exists for SNS also exists for SQS and there's some discussion about that in jkakar/aws-elixir#27. Basically, we need to figure out how to convert from XML to map and back again. My current thinking is to implement that logic in aws-erlang and then re-use it in aws-elixir.

@electic
Copy link
Author

electic commented Apr 12, 2016

It would be great to have a solution. I ended up using erlcloud and doing something like this:

` token = token_arn |> String.to_char_list
msg = message |> String.to_char_list

    :erlcloud_sns.configure(access_key, secret, endpoint)
    :erlcloud_sns.publish_to_target(token, msg)`

But would love for this to be in Elixir. I would write it myself and PR it but I just started off in Elixir and frankly, I am really bad at it so far.

@slashmili
Copy link

Is the same reason that there is no S3 module?

@jkakar
Copy link
Owner

jkakar commented Aug 25, 2016

@slashmili Yes, exactly.

@dstendardi
Copy link
Contributor

@jkakar I might find some time to work on query protocol support. Do you mind if I open a dedicated issue about this and close this one ?

@ghost
Copy link

ghost commented Mar 7, 2017

@dstendardi and @jkakar I'd be interesting in working on this as well if I can be of any help.

@jkakar
Copy link
Owner

jkakar commented Mar 7, 2017

@dstendardi Closing this one and opening a dedicated issue sounds great, thanks!

@dstendardi
Copy link
Contributor

@kingoftheknoll I think there is enough work for both. I see mainly two parts (serializing the query, and deserialize the response). I'll open an issue and start working on it during this week.

@ghost
Copy link

ghost commented Mar 7, 2017

Agreed. I spent some time last night looking at the XML format and it looks like it should be possible to build up the full DOM tree described by the spec and then collapse it into xpath selectors and use sweetXML. About a month ago I started playing around with using SweetXML for use with ex_aws because it also doesn't deserialize the response.

Result looks like this:

  import SweetXml

  def xml_to_map(xml) do
    xml |> xpath(~x"//instancesSet"l,
      instance_id: ~x".//instanceId/text()"s,
      image_id: ~x".//imageId/text()"s,
      state: ~x".//instanceState/name/text()"s,
      private_dns_name: ~x"./item/privateDnsName/text()"s,
      dns_name: ~x".//dnsName/text()"s,
      key_name: ~x".//keyName/text()"s,
      instance_type: ~x".//instanceType/text()"s,
      launch_time: ~x".//launchTime/text()"s,
      availability_zone: ~x".//placement/availabilityZone/text()"s,
      subnet_id: ~x"./item/subnetId/text()"s,
      vpc_id: ~x"./item/vpcId/text()"s,
      private_ip_address: ~x"./item/privateIpAddress/text()"s,
      public_ip_address: ~x"./item/ipAddress/text()"s,
      access_lists: [
        ~x"./item/groupSet"l,
        access_list_id: ~x".//groupId/text()"s,
        access_list_name: ~x".//groupName/text()"s
      ]
    )
  end

Granted here I'm only doing the InstanceSet rather than the whole reservationSet but you get the idea. Because AWS doesn't use attributes in the xml elements this makes everything much easier. So it should be possible to have a very clear one-to-one bi-directional translation between a Map and the XML. I think I good first step would be a take the DescribeInstancesResponse schema and a test response and test that in isolation since I'm not too familiar with the code gen repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants