ripe-atlas 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7ec79693b345913501dcd77b03ff69da9540b9c
4
- data.tar.gz: dba08726fee18dd90f87fd1ce6481ddc7012ed91
3
+ metadata.gz: 788cc5c16c6cf59e8a5ce2e018ec1aaef2e4494c
4
+ data.tar.gz: d0141984d5421a5eca3f96f85e65f9c7a84c0afd
5
5
  SHA512:
6
- metadata.gz: c4fda0924cb4eb266b09e5698561b9e56e3534270aa2b17d6957f2669712e2001ef83e4c65ec83c1f35d055eab86470bde347bb4caf3edc9014278984d248c4f
7
- data.tar.gz: 9935f040db8ba55d8e05b68c0b4e639a7f32f97842c07e63f71668cb1d8d383dd4eb583782f03058c1480b552c8594824f7b97f5f801abeb663172fe12ff02ab
6
+ metadata.gz: 7e7f685d25bdc72bdab72dd9c29ae3f133527514bac93f6cc1541d9339fdf05d7d5757883ef8aff047779ae86d92d1c279f3f594cec86aa280e2407257bed482
7
+ data.tar.gz: 03d00156fad9a3726b62fa74320cd8bed422208d9aaa53f119161cd0c870dd4abe2258e1de0e37c4d89074003b7b9980680e93c776b8e75c05c2002279beeedb
@@ -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
- ## Installation
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
- Navigate into the created directory and build the gem.
19
- ```bash
20
- cd ripe-atlas/
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
- Congrats, now you can use the ripe-atlas gem!
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 'Atlas.get_probes'.
35
+ To get RIPE Atlas probes, you can use #get_probes.
41
36
 
42
37
  ```ruby
43
- Atlas.get_probes({:id => 333})
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 'Atlas.get_measurements'.
44
+ To get measurement objects, you can use #get_measurements.
50
45
  ```ruby
51
- Atlas.get_measurements({:status => 3})
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
- Atlas.stop_measurement(id, "api-key")
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:
@@ -1,8 +1,12 @@
1
+ require 'json'
2
+ require 'rest_client'
3
+ #require 'time'
4
+
1
5
  module Atlas
2
6
  end
3
7
 
4
8
  require 'ripe-atlas/version'
5
- require 'ripe-atlas/api'
9
+ require 'ripe-atlas/client'
6
10
  require 'ripe-atlas/probe'
7
11
  require 'ripe-atlas/measurement'
8
12
 
@@ -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
@@ -0,0 +1,9 @@
1
+ module Atlas
2
+ module MeasurementCreation
3
+ class Definition
4
+ af = [4, 6]
5
+ type = [:ping, :traceroute, :dns, :sslcert]
6
+
7
+ end
8
+ end
9
+ end
@@ -3,6 +3,6 @@ require 'json'
3
3
 
4
4
  module Atlas
5
5
  class MeasurementRequest
6
-
6
+
7
7
  end
8
8
  end
@@ -0,0 +1,9 @@
1
+ module Atlas
2
+ module MeasurementCreation
3
+ class Probes
4
+
5
+ def initialize(p)
6
+ end
7
+ end
8
+ end
9
+ 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)
@@ -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)
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'ripe-atlas'
4
- s.version = '0.1.1'
5
- s.date = '2014-08-27'
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.1.1
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-08-27 00:00:00.000000000 Z
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/api.rb
52
- - lib/ripe-atlas/measurement-request.rb
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
@@ -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