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

SimpleDB functionality doesn't work #60

Closed
Josh-Tilles opened this issue Aug 6, 2014 · 3 comments
Closed

SimpleDB functionality doesn't work #60

Josh-Tilles opened this issue Aug 6, 2014 · 3 comments

Comments

@Josh-Tilles
Copy link

I know it's probably not a surprise that SimpleDB doesn't work —given that you don't include a MVS in the readme— but I figured it might be useful for you to track the task in an issue anyway.

(require '[amazonica.core :refer [defcredentials])
(defcredentials "AccessKeyID" "SecretKey")
(require '[amazonica.aws.simpledb :as sdb])
(sdb/put-attributes "domain"
                    "devapiTue Aug 05 23:24:36 UTC 2014"
                    [{:name "args", :value ["Test message"]}
                     {:name "instant", :value #inst "2014-08-05T23:24:36.701-00:00"}
                     {:name "ns", :value "some-api.main"}
                     {:name "file", :value "/tmp/form-init6934682238825582339.clj"}
                     {:name "hostname", :value "devapi"}
                     {:name "output", :value "2014-Aug-05 23:24:36 +0000 devapi WARN [some-api.main] - Test message"}
                     {:name "prefix", :value "2014-Aug-05 23:24:36 +0000 devapi WARN [some-api.main]"}
                     {:name "level", :value :warn}
                     {:name "line", :value nil}
                     {:name "ap-config", :value {}}
                     {:name "error?", :value false}
                     {:name "throwable", :value nil}
                     {:name "timestamp", :value "2014-Aug-05 23:24:36 +0000"}
                     {:name "message", :value "Test message"}])

And the error is:

IllegalArgumentException Could not determine best method to invoke for put-attributes using arguments ("spike_for_logging" "devapiTue Aug 05 23:25:28 UTC 2014" ({:name "args", :value "[\"Test message\"]"} {:name "instant", :value "Tue Aug 05 23:25:28 UTC 2014"} {:name "ns", :value "some-api.main"} {:name "file", :value "/tmp/form-init6934682238825582339.clj"} {:name "hostname", :value "devapi"} {:name "output", :value "2014-Aug-05 23:25:28 +0000 devapi WARN [some-api.main] - Test message"} {:name "prefix", :value "2014-Aug-05 23:25:28 +0000 devapi WARN [some-api.main]"} {:name "level", :value ":warn"} {:name "line", :value ""} {:name "ap-config", :value "{}"} {:name "error?", :value "false"} {:name "throwable", :value ""} {:name "timestamp", :value "2014-Aug-05 23:25:28 +0000"} {:name "message", :value "Test message"}))  amazonica.core/intern-function/fn--11248 (core.clj:780)
@Josh-Tilles
Copy link
Author

In case you fix this before I get around to submitting a pull request, you might find this snippet of code useful:

(defn verbosify-map-for-simpledb [m]
  (for [[k v] m]
    (hash-map :name (name k), :value v)))

Feel free to come up with a better name though 😜

@mcohen01
Copy link
Owner

mcohen01 commented Aug 6, 2014

You sort of have to have the javadocs open when you use amazonica.

http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/index.html

Basically, any Java methods that take j.u.Collections as args take the corresponding Clojure data structure. So a List or Collection will take a Clojure list, seq, or vector. Maps take Clojure maps.

If the Java method takes some kind of aws-sdk Javabean as an argument, then you pass a Clojure map with keys named according to the method names. See the README.md for more details.

(sdb/put-attributes :domain-name "domain"
                    :item-name "my-item"
                    :attributes [{:name "foo"
                                     :value "bar"}
                                     {:name "baz"
                                       :value 42}])

@mcohen01 mcohen01 closed this as completed Aug 6, 2014
@Josh-Tilles
Copy link
Author

My mistake—thank you for explaining.

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

2 participants