Giter VIP home page Giter VIP logo

ruby-maxcdn's People

Contributors

atmos avatar dlitvakb avatar eamonnscu avatar ewoodh2o avatar hiroshi avatar jdorfman avatar jmervine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ruby-maxcdn's Issues

request to change http client used

Can we switch to using HTTParty instead of Curb for the actual http requests to the api?
The problem with Curb is that it uses C extensions which don't work easily with JRuby.

Thanks,

-Tony

Cache-status from Raw-Logs-Api is empty-string

I am seeing these results:

start_date = '2014-10-16'
end_date   = '2014-10-17'
api = MaxCDN::Client.new("", "", "")
base_path = "/v3/reporting/logs.json?start=#{start_date}&end=#{end_date}&limit=1000"
requests  = api.get(path)

   {"bytes"=>84,
    "client_asn"=>"AS15830 TELECITYGROUP INTERNATIONAL LIMITED",
    "client_city"=>"-",
    "client_continent"=>"EU",
    "client_country"=>"GB",
    "client_dma"=>"0",
    "client_ip"=>"88.255.255.255",
    "client_latitude"=>51.5,
    "client_longitude"=>-0.12999999523162842,
    "client_state"=>"-",
    "company_id"=>35293,
    "cache_status"=>"",
    "hostname"=>"cdn.website.com",
    "method"=>"POST",
    "origin_time"=>0.496,
    "pop"=>"lhr",
    "protocol"=>"HTTP/1.1",
    "query_string"=>"",
    "referer"=>"-",
    "request_time"=>0.533,
    "scheme"=>"https",
    "status"=>200,
    "time"=>"2014-10-16T20:43:54.202Z",
    "uri"=>"/traffictest",
    "user_agent"=>"api.rb 0.0.1; 2.1.2",
    "zone_id"=>192491},
    {"bytes"=>81,
    "client_asn"=>"AS15830 TELECITYGROUP INTERNATIONAL LIMITED",
    "client_city"=>"-",
    "client_continent"=>"EU",
    "client_country"=>"GB",
    "client_dma"=>"0",
    "client_ip"=>"88.255.255.255",
    "client_latitude"=>51.5,
    "client_longitude"=>-0.12999999523162842,
    "client_state"=>"-",
    "company_id"=>35293,
    "cache_status"=>"",
    "hostname"=>"cdn.website.com",
    "method"=>"POST",
    "origin_time"=>0.804,
    "pop"=>"lhr",
    "protocol"=>"HTTP/1.1",
    "query_string"=>"",
    "referer"=>"-",
    "request_time"=>0.834,
    "scheme"=>"https",
    "status"=>200,
    "time"=>"2014-10-16T20:43:43.643Z",
    "uri"=>"/traffictest",
    "user_agent"=>"api.rb 0.0.1; 2.1.2",
    "zone_id"=>192491}

uninitialized constant Hash::URI

While we were testing one of the features via API we've found that ruby SDK is acting up in a way that it errors out for Hash::URI not being initialized when called under _escape but, not sure I can back trace properly:

call:

require 'maxcdn' 
api = MaxCDN::Client.new("ALIAS", "SECRET", "KEY")
params = {'canonical_link_headers' => '1'} 
api.put('/zones/pull.json/ZONE', params)

exception:

$ ruby maxcdn.rb       
/home/user/.gem/ruby/gems/maxcdn-0.3.0/lib/ext/hash.rb:5:in `_escape': uninitialized constant
Hash::URI (NameError) 
       from /home/user/.gem/ruby/gems/maxcdn-0.3.0/lib/ext/hash.rb:20:in `block in to_params
' 
       from /home/user/.gem/ruby/gems/maxcdn-0.3.0/lib/ext/hash.rb:14:in `each' 
       from /home/user/.gem/ruby/gems/maxcdn-0.3.0/lib/ext/hash.rb:14:in `to_params' 
       from /home/user/.gem/ruby/gems/maxcdn-0.3.0/lib/maxcdn.rb:46:in `_response_as_json' 
       from /home/user/.gem/ruby/gems/maxcdn-0.3.0/lib/maxcdn.rb:90:in `block (2 levels) in 
<class:Client>' 
       from maxcdn.rb:11:in `<main>'

Addressable::URI::InvalidURIError (Invalid scheme format: {"email")

Hi,
I got the Invalid scheme format. When try to add a client.

response = @client.post("/clients.json", { 'package_id' => APP_CONFIG[:netdna_package_id], 'name' => "viswaraj", 'alias' => "thg", 'status' => 2, 'account_owner' => {"email"=>"[email protected]", "password"=>"test1234", "firstname"=>"viswaraj", "lastname"=>"Somarajan", "phone"=>"9633555797", "active"=>1}.to_json, 'address' => {"street1"=>"kaloor", "street2"=>"kaloor", "city"=>"Cochin", "state"=>"Kerala", "zip"=>"564666", "country"=>"IN"}.to_json })
Traceback (most recent call last):
1: from (irb):16
Addressable::URI::InvalidURIError (Invalid scheme format: {"email")

Can you help me to fix the issue?

Regards,
Viswaraj

Updates and tweaks for debugging.

Requests from @dlitvakb

  • Add back @secure_connection for dev support and rws testing.
  • Add back :debug_json and :debug_request for dev support and rws testing.
  • Add custom header support and set default Content-Type header to application/x-www-form-urlencoded. Note on this; custom content-type didn't work before my changes, it could be passed to the MaxCDN (was NetDNARWS) module, but didn't actually get passed down to the underlying OAuth agent. The primary functional change I made was to make custom content-type support work, and then set it to application/json, which seems to be required for POST and PUT requests with body messages.

return per file status when Array is passed to purge

Similar to netdnarws version 0.3.4 (see netdnarws issue #12), purge API call MaxCDN::Client.purge() breaks existing infrastructure, when migrating from netdnarws gem to maxcdn

Here is my usage example:

files_flushed = []
files_failed = []
$api = MaxCDN::Client.new(account, key, secret)
zone_flush = $api.purge($options.zone_id, files_changed)
zone_flush.each { |k,v| if v["code"] == 200
    files_flushed.push k
  else
    files_failed.push k
  end
}

It appears, in versions <= 0.3.3 of netdnarws gem purge(zone_id,files) upon success, returns

  • {"code"=>200}, when files is String
  • {"/path/to/file"=>{"code"=>200}}, when files is an Array

In version 0.3.4 of netdnarws as well as in maxcdn, however, purge(zone_id,files), upon success, returns

  • {"code"=>200}, when files is String or an Array

Getting a Hash with individual file status like so, is very helpful, when tracking successes and failures on per file basis.

{
  "/path/to/file1" => {"code"=>200}
  "/path/to/file2" => {"code"=>200}
  "/path/to/file3" => {"code"=>200}
}

Please consider replicating functionality of netdnarws gems version <= 0.3.3 ..

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.