giraffi 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.document +5 -0
  2. data/.yardopts +7 -0
  3. data/Gemfile +10 -0
  4. data/HISTORY.md +6 -0
  5. data/LICENSE.md +20 -0
  6. data/README.md +114 -0
  7. data/Rakefile +53 -0
  8. data/VERSION +1 -0
  9. data/examples/setup_http_monitoring.rb +88 -0
  10. data/giraffi.gemspec +155 -0
  11. data/lib/giraffi/client/applogs.rb +25 -0
  12. data/lib/giraffi/client/axions.rb +96 -0
  13. data/lib/giraffi/client/items.rb +102 -0
  14. data/lib/giraffi/client/logs.rb +23 -0
  15. data/lib/giraffi/client/media.rb +67 -0
  16. data/lib/giraffi/client/monitoringdata.rb +25 -0
  17. data/lib/giraffi/client/my_current_status.rb +19 -0
  18. data/lib/giraffi/client/regions.rb +15 -0
  19. data/lib/giraffi/client/services.rb +97 -0
  20. data/lib/giraffi/client/trends.rb +25 -0
  21. data/lib/giraffi/client/triggers.rb +94 -0
  22. data/lib/giraffi/client.rb +73 -0
  23. data/lib/giraffi/config.rb +60 -0
  24. data/lib/giraffi/version.rb +3 -0
  25. data/lib/giraffi.rb +26 -0
  26. data/test/applogs_test.rb +55 -0
  27. data/test/axions_test.rb +149 -0
  28. data/test/client_test.rb +52 -0
  29. data/test/fixtures/add_applogs_success_response.json +3 -0
  30. data/test/fixtures/add_monitroingdata.json +1 -0
  31. data/test/fixtures/add_service_to_item.json +12 -0
  32. data/test/fixtures/add_trigger_to_service.json +1 -0
  33. data/test/fixtures/create_axion.json +1 -0
  34. data/test/fixtures/create_item.json +15 -0
  35. data/test/fixtures/create_medium.json +1 -0
  36. data/test/fixtures/find_applogs_with_no_param.json +11 -0
  37. data/test/fixtures/find_applogs_with_params.json +2 -0
  38. data/test/fixtures/find_average_trends.json +6 -0
  39. data/test/fixtures/find_axion_by_id.json +9 -0
  40. data/test/fixtures/find_axion_by_trigger.json +11 -0
  41. data/test/fixtures/find_axion_logs_with_no_param.json +6 -0
  42. data/test/fixtures/find_axion_logs_with_params.json +5 -0
  43. data/test/fixtures/find_axions_by_trigger_with_axionkind.json +1 -0
  44. data/test/fixtures/find_axions_by_trigger_without_axionkind.json +1 -0
  45. data/test/fixtures/find_axions_with_no_param.json +1 -0
  46. data/test/fixtures/find_axions_with_params.json +11 -0
  47. data/test/fixtures/find_failure_trends.json +1 -0
  48. data/test/fixtures/find_item_by_id.json +15 -0
  49. data/test/fixtures/find_items_with_no_param.json +77 -0
  50. data/test/fixtures/find_items_with_params.json +17 -0
  51. data/test/fixtures/find_media_by_axion.json +13 -0
  52. data/test/fixtures/find_media_with_no_param.json +22 -0
  53. data/test/fixtures/find_media_with_params.json +1 -0
  54. data/test/fixtures/find_medium_by_id.json +1 -0
  55. data/test/fixtures/find_monitoringdata_with_no_param.json +4 -0
  56. data/test/fixtures/find_monitoringdata_with_params.json +3 -0
  57. data/test/fixtures/find_region_by_service.json +1 -0
  58. data/test/fixtures/find_regions.json +1 -0
  59. data/test/fixtures/find_service_by_id.json +12 -0
  60. data/test/fixtures/find_service_by_item_with_params.json +14 -0
  61. data/test/fixtures/find_services_by_item_with_no_param.json +14 -0
  62. data/test/fixtures/find_services_with_no_param.json +38 -0
  63. data/test/fixtures/find_services_with_params.json +14 -0
  64. data/test/fixtures/find_trigger_by_id.json +12 -0
  65. data/test/fixtures/find_triggers_by_service.json +1 -0
  66. data/test/fixtures/find_triggers_with_no_param.json +34 -0
  67. data/test/fixtures/find_triggers_with_params.json +14 -0
  68. data/test/fixtures/my_current_status_about_fake_uri.json +6 -0
  69. data/test/fixtures/my_current_status_about_real_uri.json +6 -0
  70. data/test/giraffi_test.rb +14 -0
  71. data/test/items_test.rb +170 -0
  72. data/test/logs_test.rb +60 -0
  73. data/test/media_test.rb +104 -0
  74. data/test/monitoringdata_test.rb +53 -0
  75. data/test/my_current_status_test.rb +29 -0
  76. data/test/regions_test.rb +20 -0
  77. data/test/services_test.rb +166 -0
  78. data/test/test_helper.rb +40 -0
  79. data/test/trends_test.rb +35 -0
  80. data/test/triggers_test.rb +151 -0
  81. metadata +271 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ -
3
+ LICENSE.md
4
+ HISTORY.md
5
+ README.md
data/.yardopts ADDED
@@ -0,0 +1,7 @@
1
+ --no-private
2
+ --protected
3
+ --tag requires_apikey:"Requires APIKEY?"
4
+ --markup markdown
5
+ -
6
+ HISTORY.md
7
+ LICENSE.md
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ #
9
+
10
+ gemspec
data/HISTORY.md ADDED
@@ -0,0 +1,6 @@
1
+ HISTORY
2
+ =======
3
+
4
+ 0.1.0 - December 9, 2011
5
+ -------------------------
6
+ * [Initial release](http://github.com/giraffi/giraffi/commit/)
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 azukiwasher
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # The Giraffi Ruby Gem
2
+
3
+ A Ruby wrapper for the Giraffi API
4
+
5
+ ## Installation
6
+
7
+ gem install giraffi
8
+
9
+ ## Requirements
10
+ * Ruby 1.9.2 or later
11
+ * An apikey for the Giraffi API
12
+
13
+ ## Usage
14
+
15
+ ### How to start monitoring your web site status via HTTP
16
+
17
+ 1. Create a new Giraffi::Client object
18
+ 2. Create a medium
19
+ 3. Create an axion
20
+ 4. Add the medium you created to the axion
21
+ 5. Create an item
22
+ 6. Add a service to the item
23
+ 7. Add a trigger to the service
24
+ 8. Update the axion of the trigger
25
+ 9. Update the region of the service
26
+ 10. Reload the settings
27
+
28
+ ``` ruby
29
+ require 'json'
30
+ require 'pp'
31
+
32
+ # An `APIKEY` that allows you to access the Giraffi API
33
+ APIKEY = 'hanamoguella'
34
+
35
+ # Sample attributes to create a `medium`
36
+ medium_attrs = {
37
+ name: "Alert Email",
38
+ mediumtype: "email",
39
+ options: { address: "user@example.com" }
40
+ }
41
+
42
+ # Sample attributes to create an `axion`
43
+ axion_attrs = {
44
+ name: "aborted alert",
45
+ axiontype: "messaging",
46
+ options: {}
47
+ }
48
+
49
+ # Sample attributes to create an `item`
50
+ item_attrs = {
51
+ name: "web01",
52
+ host: "localhost",
53
+ ip: "127.0.0.1",
54
+ normalinterval: 120,
55
+ warninginterval: 60,
56
+ warningretry: 2,
57
+ status: 1
58
+ }
59
+
60
+ # Sample attributes to create a `service`
61
+ service_attrs = {
62
+ servicetype: "web_response_time",
63
+ normalinterval: 120,
64
+ warninginterval: 60,
65
+ warningretry: 2,
66
+ status: 1,
67
+ options: {}
68
+ }
69
+
70
+ # Sample attributes to create a `trigger`
71
+ trigger_attrs = {
72
+ triggertype: "timeout",
73
+ axioninterval: 180,
74
+ options:{
75
+ time: "3"
76
+ }
77
+ }
78
+
79
+ # Create a Giraffi client object
80
+ g = Giraffi.new({apikey: APIKEY})
81
+
82
+ # Create a medium
83
+ response = g.create_medium(medium_attrs)
84
+ medium_id = JSON.parse(response.body)['medium']['id']
85
+
86
+ # Create an axion
87
+ response = g.create_axion(axion_attrs)
88
+ axion_id = JSON.parse(response.body)['axion']['id']
89
+
90
+ # Add the medium you created to the axion
91
+ pp g.add_medium_to_axion(axion_id, medium_id)
92
+
93
+ # Create an item
94
+ response = g.create_item(item_attrs)
95
+ item_id = JSON.parse(response.body)['item']['id']
96
+
97
+ # Add a service to the item
98
+ response = g.add_service_to_item(item_id, service_attrs)
99
+ service_id = JSON.parse(response.body)['service']['id']
100
+
101
+ # Add a trigger to the service
102
+ response = g.add_trigger_to_service(service_id, trigger_attrs)
103
+ trigger_id = JSON.parse(response.body)['trigger']['id']
104
+
105
+ # Update the axion of the trigger
106
+ pp g.update_axion_of_trigger(trigger_id, axion_id, "problem")
107
+
108
+ # Update the region of the service
109
+ pp g.update_region_of_service(service_id, "JP")
110
+
111
+ # Reload the settings
112
+ pp g.reload_items
113
+
114
+ ```
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "giraffi"
18
+ gem.homepage = "http://github.com/giraffi/giraffi"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A Ruby wrapper for the Giraffi API}
21
+ gem.description = %Q{A Ruby wrapper for the Giraffi API}
22
+ gem.email = "azukiwasher@higanworks.com"
23
+ gem.authors = ["azukiwasher"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rdoc/task'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "giraffi #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.3
@@ -0,0 +1,88 @@
1
+ dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require File.join(dir, 'giraffi')
4
+ require 'json'
5
+ require 'pp'
6
+
7
+ # An `APIKEY` that allows you to access the Giraffi API
8
+ APIKEY = 'wtLTFEqCTX55Lvhtzlqw6doj5xuphemxJa707QXtDPc'
9
+
10
+ # Sample attributes to create a `medium`
11
+ medium_attrs = {
12
+ name: "Alert Email",
13
+ mediumtype: "email",
14
+ options: { address: "user@example.com" }
15
+ }
16
+
17
+ # Sample attributes to create an `axion`
18
+ axion_attrs = {
19
+ name: "aborted alert",
20
+ axiontype: "messaging",
21
+ options: {}
22
+ }
23
+
24
+ # Sample attributes to create an `item`
25
+ item_attrs = {
26
+ name: "web01",
27
+ host: "localhost",
28
+ ip: "210.152.132.21",
29
+ normalinterval: 120,
30
+ warninginterval: 60,
31
+ warningretry: 2,
32
+ status: 1
33
+ }
34
+
35
+ # Sample attributes to create a `service`
36
+ service_attrs = {
37
+ servicetype: "web_response_time",
38
+ normalinterval: 120,
39
+ warninginterval: 60,
40
+ warningretry: 2,
41
+ status: 1,
42
+ options: {}
43
+ }
44
+
45
+ # Sample attributes to create a `trigger`
46
+ trigger_attrs = {
47
+ triggertype: "timeout",
48
+ axioninterval: 180,
49
+ options:{
50
+ time: "3"
51
+ }
52
+ }
53
+
54
+ # Create a Giraffi client object
55
+ g = Giraffi.new({apikey: APIKEY})
56
+
57
+ # Create a medium
58
+ response = g.create_medium(medium_attrs)
59
+ medium_id = JSON.parse(response.body)['medium']['id']
60
+
61
+ # Create an axion
62
+ response = g.create_axion(axion_attrs)
63
+ axion_id = JSON.parse(response.body)['axion']['id']
64
+
65
+ # Add the medium you created to the axion
66
+ pp g.add_medium_to_axion(axion_id, medium_id)
67
+
68
+ # Create an item
69
+ response = g.create_item(item_attrs)
70
+ item_id = JSON.parse(response.body)['item']['id']
71
+
72
+ # Add a service to the item
73
+ response = g.add_service_to_item(item_id, service_attrs)
74
+ service_id = JSON.parse(response.body)['service']['id']
75
+
76
+ # Add a trigger to the service
77
+ response = g.add_trigger_to_service(service_id, trigger_attrs)
78
+ trigger_id = JSON.parse(response.body)['trigger']['id']
79
+
80
+ # Update the axion of the trigger
81
+ pp g.update_axion_of_trigger(trigger_id, axion_id, "problem")
82
+
83
+ # Update the region of the service
84
+ pp g.update_region_of_service(service_id, "JP")
85
+
86
+ # Reload the settings
87
+ pp g.reload_items
88
+
data/giraffi.gemspec ADDED
@@ -0,0 +1,155 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "giraffi"
8
+ s.version = "0.1.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["azukiwasher"]
12
+ s.date = "2011-12-09"
13
+ s.description = "A Ruby wrapper for the Giraffi API"
14
+ s.email = "azukiwasher@yahoo.co.jp"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.md",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".yardopts",
22
+ "Gemfile",
23
+ "HISTORY.md",
24
+ "LICENSE.md",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "examples/setup_http_monitoring.rb",
29
+ "giraffi.gemspec",
30
+ "lib/giraffi.rb",
31
+ "lib/giraffi/client.rb",
32
+ "lib/giraffi/client/applogs.rb",
33
+ "lib/giraffi/client/axions.rb",
34
+ "lib/giraffi/client/items.rb",
35
+ "lib/giraffi/client/logs.rb",
36
+ "lib/giraffi/client/media.rb",
37
+ "lib/giraffi/client/monitoringdata.rb",
38
+ "lib/giraffi/client/my_current_status.rb",
39
+ "lib/giraffi/client/regions.rb",
40
+ "lib/giraffi/client/services.rb",
41
+ "lib/giraffi/client/trends.rb",
42
+ "lib/giraffi/client/triggers.rb",
43
+ "lib/giraffi/config.rb",
44
+ "lib/giraffi/version.rb",
45
+ "test/applogs_test.rb",
46
+ "test/axions_test.rb",
47
+ "test/client_test.rb",
48
+ "test/fixtures/add_applogs_success_response.json",
49
+ "test/fixtures/add_monitroingdata.json",
50
+ "test/fixtures/add_service_to_item.json",
51
+ "test/fixtures/add_trigger_to_service.json",
52
+ "test/fixtures/create_axion.json",
53
+ "test/fixtures/create_item.json",
54
+ "test/fixtures/create_medium.json",
55
+ "test/fixtures/find_applogs_with_no_param.json",
56
+ "test/fixtures/find_applogs_with_params.json",
57
+ "test/fixtures/find_average_trends.json",
58
+ "test/fixtures/find_axion_by_id.json",
59
+ "test/fixtures/find_axion_by_trigger.json",
60
+ "test/fixtures/find_axion_logs_with_no_param.json",
61
+ "test/fixtures/find_axion_logs_with_params.json",
62
+ "test/fixtures/find_axions_by_trigger_with_axionkind.json",
63
+ "test/fixtures/find_axions_by_trigger_without_axionkind.json",
64
+ "test/fixtures/find_axions_with_no_param.json",
65
+ "test/fixtures/find_axions_with_params.json",
66
+ "test/fixtures/find_failure_trends.json",
67
+ "test/fixtures/find_item_by_id.json",
68
+ "test/fixtures/find_items_with_no_param.json",
69
+ "test/fixtures/find_items_with_params.json",
70
+ "test/fixtures/find_media_by_axion.json",
71
+ "test/fixtures/find_media_with_no_param.json",
72
+ "test/fixtures/find_media_with_params.json",
73
+ "test/fixtures/find_medium_by_id.json",
74
+ "test/fixtures/find_monitoringdata_with_no_param.json",
75
+ "test/fixtures/find_monitoringdata_with_params.json",
76
+ "test/fixtures/find_region_by_service.json",
77
+ "test/fixtures/find_regions.json",
78
+ "test/fixtures/find_service_by_id.json",
79
+ "test/fixtures/find_service_by_item_with_params.json",
80
+ "test/fixtures/find_services_by_item_with_no_param.json",
81
+ "test/fixtures/find_services_with_no_param.json",
82
+ "test/fixtures/find_services_with_params.json",
83
+ "test/fixtures/find_trigger_by_id.json",
84
+ "test/fixtures/find_triggers_by_service.json",
85
+ "test/fixtures/find_triggers_with_no_param.json",
86
+ "test/fixtures/find_triggers_with_params.json",
87
+ "test/fixtures/my_current_status_about_fake_uri.json",
88
+ "test/fixtures/my_current_status_about_real_uri.json",
89
+ "test/giraffi_test.rb",
90
+ "test/items_test.rb",
91
+ "test/logs_test.rb",
92
+ "test/media_test.rb",
93
+ "test/monitoringdata_test.rb",
94
+ "test/my_current_status_test.rb",
95
+ "test/regions_test.rb",
96
+ "test/services_test.rb",
97
+ "test/test_helper.rb",
98
+ "test/trends_test.rb",
99
+ "test/triggers_test.rb"
100
+ ]
101
+ s.homepage = "http://github.com/giraffi/giraffi"
102
+ s.licenses = ["MIT"]
103
+ s.require_paths = ["lib"]
104
+ s.rubygems_version = "1.8.10"
105
+ s.summary = "A Ruby wrapper for the Giraffi API"
106
+
107
+ if s.respond_to? :specification_version then
108
+ s.specification_version = 3
109
+
110
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
111
+ s.add_runtime_dependency(%q<multi_json>, [">= 1.0"])
112
+ s.add_runtime_dependency(%q<httparty>, [">= 0.8"])
113
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
114
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
115
+ s.add_development_dependency(%q<bundler>, [">= 0"])
116
+ s.add_development_dependency(%q<rcov>, [">= 0"])
117
+ s.add_development_dependency(%q<webmock>, [">= 0"])
118
+ s.add_development_dependency(%q<vcr>, [">= 0"])
119
+ s.add_development_dependency(%q<turn>, [">= 0"])
120
+ s.add_development_dependency(%q<watchr>, [">= 0"])
121
+ s.add_development_dependency(%q<rb-fsevent>, [">= 0"])
122
+ s.add_development_dependency(%q<redcarpet>, [">= 0"])
123
+ s.add_development_dependency(%q<yard>, [">= 0"])
124
+ else
125
+ s.add_dependency(%q<multi_json>, [">= 1.0"])
126
+ s.add_dependency(%q<httparty>, [">= 0.8"])
127
+ s.add_dependency(%q<shoulda>, [">= 0"])
128
+ s.add_dependency(%q<jeweler>, [">= 0"])
129
+ s.add_dependency(%q<bundler>, [">= 0"])
130
+ s.add_dependency(%q<rcov>, [">= 0"])
131
+ s.add_dependency(%q<webmock>, [">= 0"])
132
+ s.add_dependency(%q<vcr>, [">= 0"])
133
+ s.add_dependency(%q<turn>, [">= 0"])
134
+ s.add_dependency(%q<watchr>, [">= 0"])
135
+ s.add_dependency(%q<rb-fsevent>, [">= 0"])
136
+ s.add_dependency(%q<redcarpet>, [">= 0"])
137
+ s.add_dependency(%q<yard>, [">= 0"])
138
+ end
139
+ else
140
+ s.add_dependency(%q<multi_json>, [">= 1.0"])
141
+ s.add_dependency(%q<httparty>, [">= 0.8"])
142
+ s.add_dependency(%q<shoulda>, [">= 0"])
143
+ s.add_dependency(%q<jeweler>, [">= 0"])
144
+ s.add_dependency(%q<bundler>, [">= 0"])
145
+ s.add_dependency(%q<rcov>, [">= 0"])
146
+ s.add_dependency(%q<webmock>, [">= 0"])
147
+ s.add_dependency(%q<vcr>, [">= 0"])
148
+ s.add_dependency(%q<turn>, [">= 0"])
149
+ s.add_dependency(%q<watchr>, [">= 0"])
150
+ s.add_dependency(%q<rb-fsevent>, [">= 0"])
151
+ s.add_dependency(%q<redcarpet>, [">= 0"])
152
+ s.add_dependency(%q<yard>, [">= 0"])
153
+ end
154
+ end
155
+
@@ -0,0 +1,25 @@
1
+ module Giraffi
2
+ class Client
3
+ # Defines methods related to the applogs
4
+
5
+ module Applogs
6
+ # Returns the desired applogs related
7
+ #
8
+ # @requires_apikey Yes
9
+ # @param options [Hash] The request params to retrieve the desired applogs
10
+ # @return [HTTParty::Response]
11
+ def find_applogs(options={})
12
+ self.class.get("/applogs.json?apikey=#{apikey}", :query => options)
13
+ end
14
+
15
+ # Posts the applogs to the Giraffi
16
+ #
17
+ # @requires_apikey Yes
18
+ # @param options [Hash] The applogs to post to the Giraffi
19
+ # @return [HTTParty::Response]
20
+ def add_applogs(options={})
21
+ self.class.post("#{applogs_endpoint}/applogs.json?apikey=#{apikey}", :body => MultiJson.encode({applog: options}))
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,96 @@
1
+ module Giraffi
2
+ class Client
3
+ # Defines methods related to the axions
4
+
5
+ module Axions
6
+ # Returns the desired axions
7
+ #
8
+ # @requires_apikey Yes
9
+ # @param options [Hash] The request params to retrieve the desired axions
10
+ # @return [HTTParty::Response]
11
+ def find_axions(options={})
12
+ self.class.get("/axions.json?apikey=#{apikey}", :query => options)
13
+ end
14
+
15
+ # Returns the desired axion
16
+ #
17
+ # @requires_apikey Yes
18
+ # @param id [String] The numerical ID of the desired axion
19
+ # @return [HTTParty::Response]
20
+ def find_axion(id)
21
+ self.class.get("/axions/#{id}.json?apikey=#{apikey}")
22
+ end
23
+
24
+ # Returns all media related to the desired axion
25
+ #
26
+ # @requires_apikey Yes
27
+ # @param id [String] The numerical ID of the desired axion
28
+ # @param options [Hash] A set of params to retrieve media related the axion
29
+ # @return [HTTParty::Response]
30
+ def find_media_by_axion(id, options={})
31
+ self.class.get("/axions/#{id}/media.json?apikey=#{apikey}", :query => options)
32
+ end
33
+
34
+ # Creates a new axion
35
+ #
36
+ # @requires_apikey Yes
37
+ # @param options [Hash] A set of attributes to create a new axion
38
+ # @return [HTTParty::Response]
39
+ def create_axion(options={})
40
+ self.class.post("/axions.json?apikey=#{apikey}", :query => { :axion => options })
41
+ end
42
+
43
+ # Executes the desired axion
44
+ #
45
+ # @requires_apikey Yes
46
+ # @param id [String] The numerical ID of the desired axion
47
+ # @return [HTTParty::Response]
48
+ def execute_axion(id)
49
+ self.class.post("/axions/#{id}/execute.json?apikey=#{apikey}")
50
+ end
51
+
52
+ # Updates the desired axion
53
+ #
54
+ # @requires_apikey Yes
55
+ # @param id [String] The numerical ID of the desired axion
56
+ # @param options [Hash] A set of attributes to update the axion
57
+ # @return [HTTParty::Response]
58
+ def update_axion(id, options={})
59
+ self.class.put("/axions/#{id}.json?apikey=#{apikey}", :query => { :axion => options }, :body => {})
60
+ end
61
+
62
+ # Adds a medium to the axion
63
+ #
64
+ # @requires_apikey Yes
65
+ # @param args [Array] A set of params to add a medium to the axion
66
+ # @option args [String] The numerical ID of the related axion
67
+ # @option args [String] The numerical ID of the medium to add
68
+ # @return [HTTParty::Response]
69
+ def add_medium_to_axion(*args)
70
+ raise ArgumentError.new('The method `add_medium_to_axion` requires 2 argments (axion-id and medium-id)') if args.size != 2
71
+ self.class.put("/axions/#{args[0]}/media/#{args[-1]}.json?apikey=#{apikey}", :body => {})
72
+ end
73
+
74
+ # Deletes the axion
75
+ #
76
+ # @requires_apikey Yes
77
+ # @param id [String] The numerical ID of the desired axion
78
+ # @return [HTTParty::Response]
79
+ def destroy_axion(id)
80
+ self.class.delete("/axions/#{id}?apikey=#{apikey}")
81
+ end
82
+
83
+ # Removes a medium from the axion
84
+ #
85
+ # @requires_apikey Yes
86
+ # @param args [Array] A set of params to remove a medium from the axion
87
+ # @option args [String] The numerical ID of the related axion
88
+ # @option args [String] The numerical ID of the axion to remove
89
+ # @return [HTTParty::Response]
90
+ def remove_medium_from_axion(*args)
91
+ raise ArgumentError.new('The method `remove_medium_from_axion` requires 2 argments (axion-id and medium-id)') if args.size != 2
92
+ self.class.delete("/axions/#{args[0]}/media/#{args[-1]}.json?apikey=#{apikey}")
93
+ end
94
+ end
95
+ end
96
+ end