MeltwaterArchive / datasift-ruby

Ruby client for DataSift
http://datasift.com
MIT License
24 stars 22 forks source link

Cannot create push subscription with DynamoDB destination #71

Closed JadedEvan closed 9 years ago

JadedEvan commented 9 years ago

I am having issues somewhere between v3.0.0 and v3.1.3 of this gem. I am attempting to create a new push subscription with a data destination of DynamoDB. v3.1.3 of the gem is throwing an exception saying Bad request,An empty table name was supplied for URL https://api.datasift.com/v1/push/create.

I am able to confirm that I can create a push subscription using the exact same parameters with v3.0.0 of the gem.

Example payload:

{
  :initial_status=>"active",
  :name=>"my-destination",
  "output_type"=>"dynamodb",
  "output_params.region"=>"dynamodb.us-east-1.amazonaws.com",
  "output_params.table"=>"my-dynamodb-table",
  "output_params.auth.access_key"=>"my-access-id",
  "output_params.auth.secret_key"=>"my-secret-key",
  :hash=>"9bbf13593b87c1279120ee93267751a1",
  "output_params.chirpify.hashtag_md5"=>"5428ea2b07c1a9bcb12eda9f19238f5c"
}
dugjason commented 9 years ago

Passing a Ruby object like the following should work for you:

{
  :initial_status => "active",
  :name => "my-destination",
  :output_type => "dynamodb",
  :output_params => {
    :region => "dynamodb.us-east-1.amazonaws.com",
    :table => "my-dynamodb-table",
    :auth => {
      :access_key => "my-access-id",
      :secret_key => "my-secret-key"
    }
    :hash => "9bbf13593b87c1279120ee93267751a1",
    :chirpify => {
      :hashtag_md5"=>"5428ea2b07c1a9bcb12eda9f19238f5c"
    }
  }
}

I'll take a look to see if we can support this method of passing params too.

JadedEvan commented 9 years ago

Thanks @dugjason that looks like it corrected the issue I was experiencing. The hash/formatting you indicated above is not abundantly clear in the documentation (both here http://dev.datasift.com/docs/api/1/pushcreate and here - http://dev.datasift.com/docs/push/connectors/dynamodb). The source code doesn't have much documentation either (see DataSift::Push). It'd be helpful in the future if the web docs maybe had an example.

I'd be happy to write up some YARD documentation (in the form of an @example block) for the ruby source code if you'd find that useful. Might help other folks in the future?

dugjason commented 9 years ago

@JadedEvan if you would like to write any YARD docs for the library, that would certainly be appreciated; we are always keen to accept any contributions to our client libraries