Fork me on GitHub
#aws
<
2022-03-11
>
rmxm23:03:56

hey, i was wondering if I could do a list of operations on api. (aws/doc s3-client) without providing :op name, like (aws/doc s3-client :ListBuckets)

ghadi23:03:16

(aws/ops s3-client)

rmxm23:03:31

hmmm cool, thanks, but I would still consider adding arity for (aws/doc s3-client) It seems intuitive. If you see it somewhere in git repo, you try and reach for it -at least I did -> probably doc is supported generically, so I might be dreaming 🙂

rmxm23:03:48

One last thing, is there some easy path to "paged" results? or do I have to come up with mine?

kenny00:03:58

Nothing built in.

rmxm01:03:31

if anybody needs, tested with s3

(defn paged-invoke
  ([client
    {:keys [op results is-truncated marker next-marker request]
     :or {results :Contents is-truncated :IsTruncated marker :Marker next-marker :Marker}
     :as options}]
   (let [response (aws/invoke client {:op op :request request})]
    (when (contains? response :cognitect.anomalies/category)
      (throw (ex-info "aws/invoke error" {:op op :request request :response response})))
    (if (is-truncated response)
       (lazy-cat (results response)
                 (paged-invoke client (assoc options marker (next-marker response))))
       (results response)))))

kenny01:03:45

How each api paginates still must be manually written. There are some libs that try to specify where the req/resp pagination tokens are stored. It's not included in the all smithy files.

steveb8n11:03:32

I agree. I think a bunch of new libs will address similar problems using Iteration https://www.juxt.pro/blog/new-clojure-iteration