maxcdn / ruby-maxcdn Goto Github PK
View Code? Open in Web Editor NEWThis project forked from netdna/netdnarws-ruby
Ruby Gem for MaxCDN's REST API
License: MIT License
This project forked from netdna/netdnarws-ruby
Ruby Gem for MaxCDN's REST API
License: MIT License
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
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}
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:
require 'maxcdn'
api = MaxCDN::Client.new("ALIAS", "SECRET", "KEY")
params = {'canonical_link_headers' => '1'}
api.put('/zones/pull.json/ZONE', params)
$ 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>'
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
Requests from @dlitvakb
@secure_connection
for dev support and rws testing.:debug_json
and :debug_request
for dev support and rws testing.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.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 ArrayIn 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 ArrayGetting 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 ..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.