ripe-atlas 0.1.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +17 -27
- data/lib/ripe-atlas.rb +5 -1
- data/lib/ripe-atlas/client.rb +73 -0
- data/lib/ripe-atlas/measurement-creation/definitions.rb +9 -0
- data/lib/ripe-atlas/{measurement-request.rb → measurement-creation/measurement-request.rb} +1 -1
- data/lib/ripe-atlas/measurement-creation/probes.rb +9 -0
- data/lib/ripe-atlas/measurement.rb +0 -1
- data/lib/ripe-atlas/probe.rb +3 -2
- data/ripe-atlas.gemspec +2 -2
- metadata +7 -4
- data/lib/ripe-atlas/api.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 788cc5c16c6cf59e8a5ce2e018ec1aaef2e4494c
|
4
|
+
data.tar.gz: d0141984d5421a5eca3f96f85e65f9c7a84c0afd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e7f685d25bdc72bdab72dd9c29ae3f133527514bac93f6cc1541d9339fdf05d7d5757883ef8aff047779ae86d92d1c279f3f594cec86aa280e2407257bed482
|
7
|
+
data.tar.gz: 03d00156fad9a3726b62fa74320cd8bed422208d9aaa53f119161cd0c870dd4abe2258e1de0e37c4d89074003b7b9980680e93c776b8e75c05c2002279beeedb
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/README.md
CHANGED
@@ -7,26 +7,15 @@ At the current state of development, you can:
|
|
7
7
|
- Get measurements
|
8
8
|
- Stop measurements
|
9
9
|
|
10
|
-
|
11
|
-
Since ripe-atlas is currently not hosted on RubyGems.org, you have to install it manually.
|
12
|
-
|
13
|
-
Clone the GitHub repository.
|
14
|
-
```bash
|
15
|
-
git clone https://github.com/EddyShure/ripe-atlas.git
|
16
|
-
```
|
10
|
+
---
|
17
11
|
|
18
|
-
|
19
|
-
```
|
20
|
-
|
21
|
-
gem build ripe-atlas.gemspec
|
22
|
-
```
|
23
|
-
|
24
|
-
Install the gem.
|
25
|
-
```bash
|
26
|
-
gem install ripe-atlas-*.gem
|
12
|
+
## Installation
|
13
|
+
```ruby
|
14
|
+
gem install ripe-atlas
|
27
15
|
```
|
16
|
+
Congratulations, now you can use the ripe-atlas gem!
|
28
17
|
|
29
|
-
|
18
|
+
---
|
30
19
|
|
31
20
|
## Usage
|
32
21
|
|
@@ -35,33 +24,34 @@ To use the gem, you should require it first:
|
|
35
24
|
require 'ripe-atlas'
|
36
25
|
```
|
37
26
|
|
27
|
+
Then you should create a client. You can pass an API key:
|
28
|
+
```ruby
|
29
|
+
client = Atlas::Client.new "1234-1234-1234-1234"
|
30
|
+
```
|
31
|
+
Now, you should be able to do some magic with your freshly initialized client:
|
32
|
+
|
38
33
|
### Getting Atlas probes
|
39
34
|
|
40
|
-
To get RIPE Atlas probes, you can use
|
35
|
+
To get RIPE Atlas probes, you can use #get_probes.
|
41
36
|
|
42
37
|
```ruby
|
43
|
-
|
38
|
+
client.get_probes({:id => 333})
|
44
39
|
```
|
45
40
|
To get a list of all parameters, visit this site: https://atlas.ripe.net/docs/rest/#probe
|
46
41
|
|
47
42
|
### Getting measurements
|
48
43
|
|
49
|
-
To get measurement objects, you can use
|
44
|
+
To get measurement objects, you can use #get_measurements.
|
50
45
|
```ruby
|
51
|
-
|
46
|
+
client.get_measurements({:status => 3})
|
52
47
|
```
|
53
48
|
List of all parameters: https://atlas.ripe.net/docs/rest/#measurement
|
54
49
|
|
55
50
|
### Stopping measurements
|
56
51
|
```ruby
|
57
|
-
|
52
|
+
client.stop_measurement(id)
|
58
53
|
```
|
59
54
|
|
60
|
-
##TODO
|
61
|
-
* Add probe-participation-request
|
62
|
-
* Clean up code
|
63
|
-
* Add MeasurementRequest
|
64
|
-
|
65
55
|
## Donate
|
66
56
|
|
67
57
|
If you would like to support me, you can buy me a bottle of Club Mate via GitTip:
|
data/lib/ripe-atlas.rb
CHANGED
@@ -0,0 +1,73 @@
|
|
1
|
+
module Atlas
|
2
|
+
class Client
|
3
|
+
attr_accessor :key
|
4
|
+
|
5
|
+
API = "https://atlas.ripe.net/api/v1/"
|
6
|
+
|
7
|
+
def initialize(key = nil)
|
8
|
+
if key.is_a? String and key != nil
|
9
|
+
send("key=", key)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_object(type, p)
|
14
|
+
@url = API + "#{type}/"
|
15
|
+
@res = RestClient.get(@url, {:accept => :json, :params => p})
|
16
|
+
|
17
|
+
if @res.code == 200
|
18
|
+
@json = JSON.parse @res.body
|
19
|
+
end
|
20
|
+
|
21
|
+
@objects = Array.new
|
22
|
+
@json["objects"].each do |n|
|
23
|
+
case type
|
24
|
+
when "probe"
|
25
|
+
@objects << Atlas::Probe.new(n)
|
26
|
+
when "measurement"
|
27
|
+
@objects << Atlas::Measurement.new(n)
|
28
|
+
else
|
29
|
+
raise "F*** you all!"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
return @objects
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_probes(p)
|
37
|
+
@probes = get_object("probe", p)
|
38
|
+
return @probes
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_measurements(p)
|
42
|
+
@measurements = get_object("measurement", p)
|
43
|
+
return @measurements
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_measurement(id)
|
47
|
+
@url = API + "measurement/#{id}/"
|
48
|
+
@res = RestClient.get(@url, {:accept => :json})
|
49
|
+
|
50
|
+
if @res.code == 200
|
51
|
+
@json = JSON.parse @res.body
|
52
|
+
end
|
53
|
+
|
54
|
+
@measurement = Atlas::Measurement.new(@json["object"])
|
55
|
+
return @measurement
|
56
|
+
end
|
57
|
+
|
58
|
+
def stop_measurement(id)
|
59
|
+
if self.key == nil
|
60
|
+
raise "Specify an API key!"
|
61
|
+
end
|
62
|
+
@url = API + "measurement/" + "#{id}/" + "?key=" + self.key
|
63
|
+
@res = RestClient.delete(@url)
|
64
|
+
p @res
|
65
|
+
puts @res.code
|
66
|
+
if @res.code == 204
|
67
|
+
return true
|
68
|
+
else
|
69
|
+
return false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -4,7 +4,6 @@ module Atlas
|
|
4
4
|
:description, :dst_addr, :dst_asn, :dst_name, :interval, :is_oneoff, :is_public, :msm_id,
|
5
5
|
:participant_count, :resolve_on_probe, :resolved_ips, :result, :start_time, :status, :stop_time, :type
|
6
6
|
|
7
|
-
# Just for Eliah Shure: (.)(.)
|
8
7
|
def initialize(p)
|
9
8
|
p.each do |k,v|
|
10
9
|
send("#{k}=",v)
|
data/lib/ripe-atlas/probe.rb
CHANGED
@@ -2,8 +2,9 @@ module Atlas
|
|
2
2
|
class Probe
|
3
3
|
|
4
4
|
attr_accessor :address_v4, :address_v6, :asn_v4, :asn_v6, :country_code, :id, :is_anchor,
|
5
|
-
:is_public, :latitude, :longitude, :prefix_v4, :prefix_v6, :status, :status_name, :status_since
|
6
|
-
|
5
|
+
:is_public, :latitude, :longitude, :prefix_v4, :prefix_v6, :status, :status_name, :status_since,
|
6
|
+
:tags
|
7
|
+
|
7
8
|
def initialize(p)
|
8
9
|
p.each do |k,v|
|
9
10
|
send("#{k}=",v)
|
data/ripe-atlas.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'ripe-atlas'
|
4
|
-
s.version = '0.
|
5
|
-
s.date = '2014-
|
4
|
+
s.version = '0.3.0'
|
5
|
+
s.date = '2014-09-05'
|
6
6
|
s.summary = "A Ruby gem for the RIPE Atlas API."
|
7
7
|
s.description = "ripe-atlas is an API wrapper for the RIPE Atlas API. You can get probes and measurements and even stop measurements."
|
8
8
|
s.authors = ["Eddy Shure"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ripe-atlas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eddy Shure
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -45,11 +45,14 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- .gitignore
|
48
49
|
- LICENSE
|
49
50
|
- README.md
|
50
51
|
- lib/ripe-atlas.rb
|
51
|
-
- lib/ripe-atlas/
|
52
|
-
- lib/ripe-atlas/measurement-
|
52
|
+
- lib/ripe-atlas/client.rb
|
53
|
+
- lib/ripe-atlas/measurement-creation/definitions.rb
|
54
|
+
- lib/ripe-atlas/measurement-creation/measurement-request.rb
|
55
|
+
- lib/ripe-atlas/measurement-creation/probes.rb
|
53
56
|
- lib/ripe-atlas/measurement.rb
|
54
57
|
- lib/ripe-atlas/probe.rb
|
55
58
|
- lib/ripe-atlas/version.rb
|
data/lib/ripe-atlas/api.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'rest_client'
|
3
|
-
|
4
|
-
module Atlas
|
5
|
-
API = "https://atlas.ripe.net/api/v1/"
|
6
|
-
|
7
|
-
def self.get_object(type, p)
|
8
|
-
@url = API + "#{type}/"
|
9
|
-
@res = RestClient.get(@url, {:accept => :json, :params => p})
|
10
|
-
|
11
|
-
if @res.code == 200
|
12
|
-
@json = JSON.parse @res.body
|
13
|
-
end
|
14
|
-
|
15
|
-
@objects = Array.new
|
16
|
-
@json["objects"].each do |n|
|
17
|
-
case type
|
18
|
-
when "probe"
|
19
|
-
@objects << Atlas::Probe.new(n)
|
20
|
-
when "measurement"
|
21
|
-
@objects << Atlas::Measurement.new(n)
|
22
|
-
else
|
23
|
-
raise "F*** you all!"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
return @objects
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.get_probes(p)
|
31
|
-
@probes = get_object("probe", p)
|
32
|
-
return @probes
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.get_measurements(p)
|
36
|
-
@measurements = get_object("measurement", p)
|
37
|
-
return @measurements
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.get_measurement(id)
|
41
|
-
@url = API + "measurement/#{id}/"
|
42
|
-
@res = RestClient.get(@url, {:accept => :json})
|
43
|
-
|
44
|
-
if @res.code == 200
|
45
|
-
@json = JSON.parse @res.body
|
46
|
-
end
|
47
|
-
|
48
|
-
@measurement = Atlas::Measurement.new(@json["object"])
|
49
|
-
return @measurement
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.stop_measurement(id, key)
|
53
|
-
@url = API + "measurement/" + "#{id}/" + "?key=" + key
|
54
|
-
@res = RestClient.delete(@url)
|
55
|
-
p @res
|
56
|
-
puts @res.code
|
57
|
-
if @res.code == 204
|
58
|
-
return true
|
59
|
-
else
|
60
|
-
return false
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|