xcal-parktronic 0.0.1

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTRjMTNmYzgwYWZmNTYzZDQ4NmJkZTBjOTE3OTg1ZTE0ZjA2ZDJhOA==
5
+ data.tar.gz: !binary |-
6
+ OTllOTViZWE1ODMyZTRmMGQ2YTRjYjBiZWE4NDNiY2JmYWYwNDc2Zg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OTg4NGU4YWU2OTZhZDVjOWUyOWY0ZGQyNzE1NmJlZDg2ZWU4MWI0MWQ0NGFi
10
+ Mjc2OTZjMDg0NWY1NTkzOGE5ZDhiNDlhMjcxYWU2MmU4ZjFmNTI3ZTJmZGE1
11
+ Njg3NmI5YjhjNTAyMmU1YmNmYTFlOTVhYWI5NTFjNjVlZDA5OWU=
12
+ data.tar.gz: !binary |-
13
+ NTNjM2QwOGNmZDg4MTM5YTU5Yjk5NTQ4MzlkZjkzNzY0YTM4Yzk4MjBiZGFk
14
+ NzQ5ZmZlYmNmZWE0NWUwNzZkODBkZDQzYTYzNDE5ZjVmYmExN2VkZTU1OTdl
15
+ NzY3MTU5ZmVjMzk3NzcxM2NmYWRmNGI3OGUyNTg0MWJkOGJmYzY=
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ /.idea/*
20
+ /*.sublime-*
21
+ .ruby-version
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in xcal-parktronic.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Max Reznichenko
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Xcal::Parktronic
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'xcal-parktronic'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install xcal-parktronic
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -0,0 +1,21 @@
1
+ require 'json'
2
+ require 'net/http'
3
+
4
+ module Xcal; module Parktronic; class ApiClient; end end end
5
+
6
+ # version
7
+ require 'xcal/parktronic/version'
8
+
9
+ # extensions
10
+ require 'hashie'
11
+
12
+ # each route then common Routes module
13
+ require 'xcal/parktronic/routes/alarms'
14
+ require 'xcal/parktronic/routes'
15
+
16
+ # exceptions
17
+ require 'xcal/parktronic/exceptions'
18
+
19
+ # response and client
20
+ require 'xcal/parktronic/generic_response'
21
+ require 'xcal/parktronic/api_client'
@@ -0,0 +1,60 @@
1
+ module Xcal
2
+ module Parktronic
3
+
4
+ class ApiClient
5
+
6
+ include Xcal::Parktronic::Routes
7
+
8
+ # API Client initialization.
9
+ #
10
+ # Acceptable attributes:
11
+ # +endpoint+ - OIV endpoint
12
+ # +proxy+ - enables proxy if proxy url is passed
13
+ # +access_token+ - access key to application
14
+ # +version+ - api version. defaults to v1
15
+ def initialize(args)
16
+ @args = args
17
+ end
18
+
19
+ def host
20
+ uri.host
21
+ end
22
+
23
+ def uri
24
+ @uri ||= URI(@args[:endpoint])
25
+ end
26
+
27
+ def access_token
28
+ @args[:access_token]
29
+ end
30
+
31
+ def api_version
32
+ @args[:version] || 'v1'
33
+ end
34
+
35
+ def port
36
+ uri.port
37
+ end
38
+
39
+ def http
40
+ return @http if @http
41
+
42
+ proxy_http = @args[:proxy]
43
+ if proxy_http.nil? || proxy_http.empty?
44
+ @http = Net::HTTP.new(uri.host, uri.port)
45
+ else
46
+ proxy_uri = URI.parse(proxy_http)
47
+ @http = Net::HTTP.new(uri.host, uri.port, proxy_uri.host, proxy_uri.port)
48
+ end
49
+
50
+ if uri.scheme == 'https'
51
+ @http.use_ssl = true
52
+ @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
53
+ end
54
+
55
+ @http
56
+ end
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,9 @@
1
+ module Xcal
2
+ module Parktronic
3
+
4
+ module Exceptions
5
+ # include all name-sorted exceptions here
6
+ class InvalidResponseArgument < Exception; end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,45 @@
1
+ module Xcal
2
+ module Parktronic
3
+
4
+ class GenericResponse
5
+ include Exceptions
6
+
7
+ # Generic Response initializations
8
+ #
9
+ # Accepted attributes are:
10
+ # +raw_response+ should be a hash or a valid raw JSON string
11
+ def initialize(raw_response = nil)
12
+ # nil input
13
+ raise InvalidResponseArgument.new('Cannot create response object without raw response') if raw_response.nil?
14
+
15
+ if raw_response.is_a?(Hash)
16
+ # hash input
17
+ @source = raw_response
18
+ elsif raw_response.is_a?(String)
19
+ # json input
20
+ parsed_json = JSON.parse(raw_response) rescue nil
21
+ raise InvalidResponseArgument.new("Argument `#{raw_response}' should be a Hash or raw json String") unless parsed_json
22
+
23
+ # for list routes render first Array object, for single item routes render object as is
24
+ @source = parsed_json.is_a?(Array) ? parsed_json.first : parsed_json
25
+ else
26
+ # invalid input
27
+ raise InvalidResponseArgument.new("Argument `#{raw_response}' should be a Hash or raw json String")
28
+ end
29
+
30
+ @source = Hashie::Mash.new(@source)
31
+ end
32
+
33
+ def method_missing(*args)
34
+ # deep inject itself into the each object of the hash
35
+ if @source.has_key?(args.first)
36
+ @source[args.first]
37
+ else
38
+ raise NoMethodError, "undefined method `#{args.first}' for #{self.class}"
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,9 @@
1
+ module Xcal
2
+ module Parktronic
3
+
4
+ module Routes
5
+ # include all available routes here
6
+ include Alarms
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,77 @@
1
+ module Xcal
2
+ module Parktronic
3
+ module Routes
4
+
5
+ module Alarms
6
+
7
+ # Fetches latest alarms
8
+ #
9
+ # Accepted attributes:
10
+ # +page+ set page, defaults to 1
11
+ # +per_page+ set per page value, defaults to 10
12
+ def get_paged_alarms(args = {})
13
+ args.merge!(:access_token => access_token)
14
+ response = http.get("/#{api_version}/alarms?#{URI.encode_www_form(args)}")
15
+
16
+ generic_response = Xcal::Parktronic::GenericResponse.new(response.body)
17
+ response.code == '200' ? generic_response.alarms.map(&:alarm) : generic_response
18
+
19
+ # TODO Add caching
20
+ end
21
+ alias :alarms :get_paged_alarms
22
+
23
+
24
+ # Fetches alarm with specific ID
25
+ #
26
+ # Accepted attributes:
27
+ # +id+ alarm ID
28
+ def get_alarm(id)
29
+ response = http.get("/#{api_version}/alarms/#{id}?access_token=#{access_token}")
30
+
31
+ generic_response = Xcal::Parktronic::GenericResponse.new(response.body)
32
+ response.code == '200' ? generic_response.alarm : generic_response
33
+
34
+ # TODO Add caching
35
+ end
36
+ alias :alarm :get_alarm
37
+
38
+ # Posts new alarm
39
+ #
40
+ # Alarm argument should be a hash of Alarm + Events data.
41
+ #
42
+ # Example of alarm data:
43
+ #
44
+ # +alarm+ :
45
+ # {
46
+ # :name => 'alarm name',
47
+ # :originating_system => 'Source System',
48
+ # :impact_level => 'low',
49
+ # :tag_list => %w(taga tagb)
50
+ # }
51
+ #
52
+ # Example of events array:
53
+ # +events+ :
54
+ # [
55
+ # {
56
+ # :subject => 'EventSubj',
57
+ # :description => 'EventDesc',
58
+ # :host_impacted => 'host',
59
+ # :initiated_at => '2013-11-22T01:00:24Z',
60
+ # :service_impacted => 'EventSvc',
61
+ # :incident_status => 'CRITICAL'
62
+ # }
63
+ # ]
64
+ #
65
+ def post_alarm(alarm = {}, events = [])
66
+ request = Net::HTTP::Post.new("/#{api_version}/alarms", 'Content-Type' => 'application/json')
67
+ request.body = { access_token: access_token, alarm: alarm, events: events }.to_json
68
+ response = http.start { |net| net.request(request) }
69
+
70
+ Xcal::Parktronic::GenericResponse.new(response.body)
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,5 @@
1
+ module Xcal
2
+ module Parktronic
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Xcal::Parktronic::ApiClient do
4
+
5
+ context 'initialization' do
6
+
7
+ let(:api_http_client){ Xcal::Parktronic::ApiClient.new(endpoint: 'http://localhost:3000/v1', access_token: 'fake_access_token') }
8
+ let(:api_http_proxy_client){ Xcal::Parktronic::ApiClient.new(endpoint: 'http://localhost:3000/v1', access_token: 'fake_access_token', proxy: 'http://localhost:3333') }
9
+ let(:api_https_client){ Xcal::Parktronic::ApiClient.new(endpoint: 'https://localhost:3000/v1', access_token: 'fake_access_token') }
10
+ let(:api_invalid_client){ Xcal::Parktronic::ApiClient.new(endpoint: 'http://', access_token: 'fake_access_token') }
11
+
12
+ it 'should initialize correctly and provide access to arguments' do
13
+ expect(api_http_client.host).to eql('localhost')
14
+ expect(api_http_client.port).to eql(3000)
15
+ expect(api_http_client.uri).to be_a_kind_of(URI)
16
+
17
+ expect { api_invalid_client.http.get('/') } .to raise_error(URI::InvalidURIError, /bad URI/)
18
+ end
19
+
20
+ it 'should have a valid set of http arguments' do
21
+ expect(api_http_client.http).to be_a_kind_of(Net::HTTP)
22
+
23
+ # ssl
24
+ expect(api_http_client.http.use_ssl?).to eql(false)
25
+ expect(api_https_client.http.use_ssl?).to eql(true)
26
+
27
+ # proxy
28
+ expect(api_http_client.http.proxy?).to eql(nil)
29
+ expect(api_http_proxy_client.http.proxy?).to eql(true)
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe Xcal::Parktronic::GenericResponse do
4
+
5
+ context 'initialization' do
6
+
7
+ let(:valid_generic_response) do
8
+ Xcal::Parktronic::GenericResponse.new(
9
+ {
10
+ :first_argument => 'first',
11
+ :second_argument => 'second',
12
+ :nil_argument => nil,
13
+ :boolean_argument => false
14
+ }
15
+ )
16
+ end
17
+
18
+ it 'should initialize correctly and raise appropriate errors' do
19
+ expect do
20
+ Xcal::Parktronic::GenericResponse.new
21
+ end.to raise_error(Xcal::Parktronic::Exceptions::InvalidResponseArgument, /without raw response/)
22
+
23
+ expect do
24
+ Xcal::Parktronic::GenericResponse.new('d')
25
+ end.to raise_error(Xcal::Parktronic::Exceptions::InvalidResponseArgument, /should be a Hash/)
26
+
27
+ expect do
28
+ Xcal::Parktronic::GenericResponse.new('{"key":"value"}')
29
+ end.not_to raise_error
30
+
31
+ expect(Xcal::Parktronic::GenericResponse.new('{"key":"value"}').key).to eql('value')
32
+
33
+ expect{ Xcal::Parktronic::GenericResponse.new({}) }.not_to raise_error
34
+ end
35
+
36
+ it 'should have a valid set of http arguments' do
37
+ expect(valid_generic_response.first_argument).to eql('first')
38
+ expect(valid_generic_response.second_argument).to eql('second')
39
+ expect(valid_generic_response.nil_argument).to eql(nil)
40
+ expect(valid_generic_response.boolean_argument).to eql(false)
41
+
42
+ expect{ valid_generic_response.missing_argument }.to raise_error(NoMethodError, /undefined method/)
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe Xcal::Parktronic::ApiClient do
4
+
5
+ let(:api_http_client){ Xcal::Parktronic::ApiClient.new(endpoint: 'http://api.mock', access_token: 'access_token') }
6
+ let(:api_invalid_client){ Xcal::Parktronic::ApiClient.new(endpoint: 'http://api.mock') }
7
+
8
+ context 'alarms route' do
9
+
10
+ it 'should not be allowed without access_token' do
11
+ expect{ api_invalid_client.get_paged_alarms(page: 1, per_page: 10) }.not_to raise_error
12
+ expect{ api_invalid_client.get_alarm(1) }.not_to raise_error
13
+ expect{ api_invalid_client.post_alarm({}, {}) }.not_to raise_error
14
+ end
15
+
16
+ context 'getting' do
17
+ it 'should respond with the correct set of alarms' do
18
+ alarms = nil
19
+ expect{ alarms = api_http_client.get_paged_alarms(page: 1, per_page: 10) }.not_to raise_error
20
+ expect(alarms.first.id.to_s).to eql('1')
21
+ expect(alarms.first.name).to eql('ALARM NAME 1')
22
+
23
+ expect(alarms.last.id.to_s).to eql('10')
24
+ expect(alarms.last.name).to eql('ALARM NAME 10')
25
+ end
26
+
27
+ it 'should respond with single alarm' do
28
+ alarm = nil
29
+ expect{ alarm = api_http_client.get_alarm(2) }.not_to raise_error
30
+
31
+ expect(alarm.id.to_s).to eql('2')
32
+ end
33
+ end
34
+
35
+ context 'posting' do
36
+ let(:alarm) do
37
+ { :name => 'alarm name', :originating_system => 'Source System', :impact_level => 'low', :tag_list => %w(taga tagb) }
38
+ end
39
+ let(:event) do
40
+ {
41
+ :subject => 'EventSubj',
42
+ :description => 'EventDesc',
43
+ :host_impacted => 'host',
44
+ :initiated_at => '2013-11-22T01:00:24Z',
45
+ :service_impacted => 'EventSvc',
46
+ :incident_status => 'CRITICAL'
47
+ }
48
+ end
49
+
50
+ it 'should post alarms successfully' do
51
+ expect{ api_http_client.post_alarm({ :alarm => alarm, :events => [event] }) }.not_to raise_error
52
+ expect{ api_invalid_client.post_alarm({ :alarm => alarm, :events => [event] }) }.not_to raise_error
53
+ end
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,49 @@
1
+ #require 'spec_helper'
2
+ #
3
+ #describe Xcal::Parktronic::ApiClient do
4
+ #
5
+ # let(:api_http_client){ Xcal::Parktronic::ApiClient.new(endpoint: 'http://api.mock', access_token: 'fake_access_token') }
6
+ # let(:api_invalid_client){ Xcal::Parktronic::ApiClient.new(endpoint: 'http://api.mock') }
7
+ #
8
+ # context 'alarms route' do
9
+ #
10
+ # it 'should not be allowed without access_token' do
11
+ # response = api_invalid_client.get_paged_alarms(page: 1, per_page: 10)
12
+ #
13
+ # expect(response.code).to eql('403')
14
+ # expect{ JSON.load(response.body) }.not_to raise_error
15
+ # end
16
+ #
17
+ # it 'should respond with the correct set of alarms' do
18
+ # response = api_http_client.get_paged_alarms(page: 1, per_page: 10)
19
+ #
20
+ # expect(response.code).to eql('200')
21
+ # expect{ JSON.load(response.body) }.not_to raise_error
22
+ # end
23
+ #
24
+ # context 'posting' do
25
+ # let(:alarm) do
26
+ # { :name => 'alarm name', :originating_system => 'Source System', :impact_level => 'low', :tag_list => %w(taga tagb) }
27
+ # end
28
+ # let(:event) do
29
+ # {
30
+ # :subject => 'EventSubj',
31
+ # :description => 'EventDesc',
32
+ # :host_impacted => 'host',
33
+ # :initiated_at => '2013-11-22T01:00:24Z',
34
+ # :service_impacted => 'EventSvc',
35
+ # :incident_status => 'CRITICAL'
36
+ # }
37
+ # end
38
+ #
39
+ # it 'should post alarms successfully' do
40
+ # response = api_http_client.post_alarm({ :alarm => alarm, :events => [event] })
41
+ #
42
+ # expect(response.code).to eql('201')
43
+ # expect{ JSON.load(response.body) }.not_to raise_error
44
+ # end
45
+ # end
46
+ #
47
+ #
48
+ # end
49
+ #end
@@ -0,0 +1,14 @@
1
+ require 'xcal/parktronic'
2
+ require 'webmock/rspec'
3
+
4
+ Dir['spec/support/**/*.rb'].each do |support_file|
5
+ require File.expand_path('.', support_file)
6
+ end
7
+
8
+ WebMock.disable_net_connect!(allow_localhost: false)
9
+
10
+ RSpec.configure do |config|
11
+ config.before(:each) do
12
+ stub_request(:any, /api.mock/).to_rack(ApiMock)
13
+ end
14
+ end
@@ -0,0 +1,37 @@
1
+ require 'sinatra/base'
2
+
3
+ class ApiMock < Sinatra::Base
4
+
5
+ before /.*/ do
6
+ request_body = JSON.parse(request.body.read) rescue {}
7
+
8
+ if params[:access_token].nil? || params[:access_token].empty?
9
+ if request_body['access_token'].nil? || request_body['access_token'].empty?
10
+ json_response(403, 'forbidden.json')
11
+ end
12
+ end
13
+ end
14
+
15
+ get '/:version/alarms' do
16
+ if params[:page].nil? || params[:page].empty?
17
+ json_response 200, 'alarms_page_1.json'
18
+ else
19
+ json_response 200, "alarms_page_#{params[:page]}.json"
20
+ end
21
+ end
22
+
23
+ get '/:version/alarms/:id' do
24
+ json_response 200, 'alarm.json'
25
+ end
26
+
27
+ post '/:version/alarms' do
28
+ json_response 201, 'alarms_post.json'
29
+ end
30
+
31
+ private
32
+
33
+ def json_response(response_code, file_name)
34
+ content_type :json
35
+ halt response_code, File.open(File.dirname(__FILE__) + '/fixtures/responses/' + file_name, 'rb').read
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ {
2
+ "alarm":{
3
+ "id":2,
4
+ "name":"Alarm Name",
5
+ "alarm_type":null,
6
+ "originating_system":"Source System",
7
+ "component":null,
8
+ "primary_owner":null,
9
+ "secondary_owner":null,
10
+ "impact_level":"CRITICAL",
11
+ "impacted_business_process":null,
12
+ "confidence_factor":null,
13
+ "description":"HARD",
14
+ "sop":null,
15
+ "is_active":true,
16
+ "upper_threshold":null,
17
+ "lower_threshold":null,
18
+ "added_at":"2013-07-05T13:56:42.000Z",
19
+ "last_reviewed_at":null
20
+ }
21
+ }
@@ -0,0 +1,220 @@
1
+ [
2
+ {
3
+ "alarms":[
4
+ {
5
+ "alarm":{
6
+ "added_at":"2013-05-21T16:03:39.000Z",
7
+ "alarm_type":null,
8
+ "component":null,
9
+ "confidence_factor":null,
10
+ "description":null,
11
+ "id":1,
12
+ "impact_level":"Unknown",
13
+ "impacted_business_process":null,
14
+ "is_active":true,
15
+ "last_reviewed_at":null,
16
+ "lower_threshold":null,
17
+ "name":"ALARM NAME 1",
18
+ "originating_system":"Source System",
19
+ "primary_owner":null,
20
+ "secondary_owner":null,
21
+ "sop":null,
22
+ "upper_threshold":null
23
+ }
24
+ },
25
+ {
26
+ "alarm":{
27
+ "added_at":"2013-05-21T16:08:24.000Z",
28
+ "alarm_type":null,
29
+ "component":null,
30
+ "confidence_factor":null,
31
+ "description":null,
32
+ "id":2,
33
+ "impact_level":"Unknown",
34
+ "impacted_business_process":null,
35
+ "is_active":true,
36
+ "last_reviewed_at":null,
37
+ "lower_threshold":null,
38
+ "name":"ALARM NAME 2",
39
+ "originating_system":"Source System",
40
+ "primary_owner":null,
41
+ "secondary_owner":null,
42
+ "sop":null,
43
+ "upper_threshold":null
44
+ }
45
+ },
46
+ {
47
+ "alarm":{
48
+ "added_at":"2013-05-21T16:08:25.000Z",
49
+ "alarm_type":null,
50
+ "component":null,
51
+ "confidence_factor":null,
52
+ "description":null,
53
+ "id":3,
54
+ "impact_level":"Unknown",
55
+ "impacted_business_process":null,
56
+ "is_active":true,
57
+ "last_reviewed_at":null,
58
+ "lower_threshold":null,
59
+ "name":"ALARM NAME 3",
60
+ "originating_system":"Source System",
61
+ "primary_owner":null,
62
+ "secondary_owner":null,
63
+ "sop":null,
64
+ "upper_threshold":null
65
+ }
66
+ },
67
+ {
68
+ "alarm":{
69
+ "added_at":"2013-05-21T16:10:09.000Z",
70
+ "alarm_type":null,
71
+ "component":null,
72
+ "confidence_factor":null,
73
+ "description":null,
74
+ "id":4,
75
+ "impact_level":"Unknown",
76
+ "impacted_business_process":null,
77
+ "is_active":true,
78
+ "last_reviewed_at":null,
79
+ "lower_threshold":null,
80
+ "name":"ALARM NAME 4",
81
+ "originating_system":"Source System",
82
+ "primary_owner":null,
83
+ "secondary_owner":null,
84
+ "sop":null,
85
+ "upper_threshold":null
86
+ }
87
+ },
88
+ {
89
+ "alarm":{
90
+ "added_at":"2013-05-21T16:24:09.000Z",
91
+ "alarm_type":null,
92
+ "component":null,
93
+ "confidence_factor":null,
94
+ "description":null,
95
+ "id":5,
96
+ "impact_level":"Unknown",
97
+ "impacted_business_process":null,
98
+ "is_active":true,
99
+ "last_reviewed_at":null,
100
+ "lower_threshold":null,
101
+ "name":"ALARM NAME 5",
102
+ "originating_system":"Source System",
103
+ "primary_owner":null,
104
+ "secondary_owner":null,
105
+ "sop":null,
106
+ "upper_threshold":null
107
+ }
108
+ },
109
+ {
110
+ "alarm":{
111
+ "added_at":"2013-05-21T16:32:24.000Z",
112
+ "alarm_type":null,
113
+ "component":null,
114
+ "confidence_factor":null,
115
+ "description":null,
116
+ "id":6,
117
+ "impact_level":"Unknown",
118
+ "impacted_business_process":null,
119
+ "is_active":true,
120
+ "last_reviewed_at":null,
121
+ "lower_threshold":null,
122
+ "name":"ALARM NAME 6",
123
+ "originating_system":"Source System",
124
+ "primary_owner":null,
125
+ "secondary_owner":null,
126
+ "sop":null,
127
+ "upper_threshold":null
128
+ }
129
+ },
130
+ {
131
+ "alarm":{
132
+ "added_at":"2013-05-21T16:33:14.000Z",
133
+ "alarm_type":null,
134
+ "component":null,
135
+ "confidence_factor":null,
136
+ "description":null,
137
+ "id":7,
138
+ "impact_level":"Unknown",
139
+ "impacted_business_process":null,
140
+ "is_active":true,
141
+ "last_reviewed_at":null,
142
+ "lower_threshold":null,
143
+ "name":"ALARM NAME 7",
144
+ "originating_system":"Source System",
145
+ "primary_owner":null,
146
+ "secondary_owner":null,
147
+ "sop":null,
148
+ "upper_threshold":null
149
+ }
150
+ },
151
+ {
152
+ "alarm":{
153
+ "added_at":"2013-05-21T16:58:41.000Z",
154
+ "alarm_type":null,
155
+ "component":null,
156
+ "confidence_factor":null,
157
+ "description":null,
158
+ "id":8,
159
+ "impact_level":"Unknown",
160
+ "impacted_business_process":null,
161
+ "is_active":true,
162
+ "last_reviewed_at":null,
163
+ "lower_threshold":null,
164
+ "name":"ALARM NAME 8",
165
+ "originating_system":"Source System",
166
+ "primary_owner":null,
167
+ "secondary_owner":null,
168
+ "sop":null,
169
+ "upper_threshold":null
170
+ }
171
+ },
172
+ {
173
+ "alarm":{
174
+ "added_at":"2013-05-21T17:29:50.000Z",
175
+ "alarm_type":"",
176
+ "component":"Component",
177
+ "confidence_factor":"medium",
178
+ "description":"",
179
+ "id":9,
180
+ "impact_level":"medium",
181
+ "impacted_business_process":"",
182
+ "is_active":true,
183
+ "last_reviewed_at":null,
184
+ "lower_threshold":"",
185
+ "name":"ALARM NAME 9",
186
+ "originating_system":"Source System",
187
+ "primary_owner":"Primary Owner",
188
+ "secondary_owner":"Owner",
189
+ "sop":"",
190
+ "upper_threshold":""
191
+ }
192
+ },
193
+ {
194
+ "alarm":{
195
+ "added_at":"2013-05-21T18:01:40.000Z",
196
+ "alarm_type":null,
197
+ "component":null,
198
+ "confidence_factor":null,
199
+ "description":null,
200
+ "id":10,
201
+ "impact_level":"Unknown",
202
+ "impacted_business_process":null,
203
+ "is_active":true,
204
+ "last_reviewed_at":null,
205
+ "lower_threshold":null,
206
+ "name":"ALARM NAME 10",
207
+ "originating_system":"Source System",
208
+ "primary_owner":null,
209
+ "secondary_owner":null,
210
+ "sop":null,
211
+ "upper_threshold":null
212
+ }
213
+ }
214
+ ],
215
+ "page":1,
216
+ "per_page":10,
217
+ "total_count":20,
218
+ "total_pages":2
219
+ }
220
+ ]
@@ -0,0 +1,220 @@
1
+ [
2
+ {
3
+ "alarms":[
4
+ {
5
+ "alarm":{
6
+ "added_at":"2013-05-21T16:03:39.000Z",
7
+ "alarm_type":null,
8
+ "component":null,
9
+ "confidence_factor":null,
10
+ "description":null,
11
+ "id":1,
12
+ "impact_level":"Unknown",
13
+ "impacted_business_process":null,
14
+ "is_active":true,
15
+ "last_reviewed_at":null,
16
+ "lower_threshold":null,
17
+ "name":"ALARM NAME 11",
18
+ "originating_system":"Source System",
19
+ "primary_owner":null,
20
+ "secondary_owner":null,
21
+ "sop":null,
22
+ "upper_threshold":null
23
+ }
24
+ },
25
+ {
26
+ "alarm":{
27
+ "added_at":"2013-05-21T16:08:24.000Z",
28
+ "alarm_type":null,
29
+ "component":null,
30
+ "confidence_factor":null,
31
+ "description":null,
32
+ "id":2,
33
+ "impact_level":"Unknown",
34
+ "impacted_business_process":null,
35
+ "is_active":true,
36
+ "last_reviewed_at":null,
37
+ "lower_threshold":null,
38
+ "name":"ALARM NAME 12",
39
+ "originating_system":"Source System",
40
+ "primary_owner":null,
41
+ "secondary_owner":null,
42
+ "sop":null,
43
+ "upper_threshold":null
44
+ }
45
+ },
46
+ {
47
+ "alarm":{
48
+ "added_at":"2013-05-21T16:08:25.000Z",
49
+ "alarm_type":null,
50
+ "component":null,
51
+ "confidence_factor":null,
52
+ "description":null,
53
+ "id":3,
54
+ "impact_level":"Unknown",
55
+ "impacted_business_process":null,
56
+ "is_active":true,
57
+ "last_reviewed_at":null,
58
+ "lower_threshold":null,
59
+ "name":"ALARM NAME 13",
60
+ "originating_system":"Source System",
61
+ "primary_owner":null,
62
+ "secondary_owner":null,
63
+ "sop":null,
64
+ "upper_threshold":null
65
+ }
66
+ },
67
+ {
68
+ "alarm":{
69
+ "added_at":"2013-05-21T16:10:09.000Z",
70
+ "alarm_type":null,
71
+ "component":null,
72
+ "confidence_factor":null,
73
+ "description":null,
74
+ "id":4,
75
+ "impact_level":"Unknown",
76
+ "impacted_business_process":null,
77
+ "is_active":true,
78
+ "last_reviewed_at":null,
79
+ "lower_threshold":null,
80
+ "name":"ALARM NAME 14",
81
+ "originating_system":"Source System",
82
+ "primary_owner":null,
83
+ "secondary_owner":null,
84
+ "sop":null,
85
+ "upper_threshold":null
86
+ }
87
+ },
88
+ {
89
+ "alarm":{
90
+ "added_at":"2013-05-21T16:24:09.000Z",
91
+ "alarm_type":null,
92
+ "component":null,
93
+ "confidence_factor":null,
94
+ "description":null,
95
+ "id":5,
96
+ "impact_level":"Unknown",
97
+ "impacted_business_process":null,
98
+ "is_active":true,
99
+ "last_reviewed_at":null,
100
+ "lower_threshold":null,
101
+ "name":"ALARM NAME 15",
102
+ "originating_system":"Source System",
103
+ "primary_owner":null,
104
+ "secondary_owner":null,
105
+ "sop":null,
106
+ "upper_threshold":null
107
+ }
108
+ },
109
+ {
110
+ "alarm":{
111
+ "added_at":"2013-05-21T16:32:24.000Z",
112
+ "alarm_type":null,
113
+ "component":null,
114
+ "confidence_factor":null,
115
+ "description":null,
116
+ "id":6,
117
+ "impact_level":"Unknown",
118
+ "impacted_business_process":null,
119
+ "is_active":true,
120
+ "last_reviewed_at":null,
121
+ "lower_threshold":null,
122
+ "name":"ALARM NAME 16",
123
+ "originating_system":"Source System",
124
+ "primary_owner":null,
125
+ "secondary_owner":null,
126
+ "sop":null,
127
+ "upper_threshold":null
128
+ }
129
+ },
130
+ {
131
+ "alarm":{
132
+ "added_at":"2013-05-21T16:33:14.000Z",
133
+ "alarm_type":null,
134
+ "component":null,
135
+ "confidence_factor":null,
136
+ "description":null,
137
+ "id":7,
138
+ "impact_level":"Unknown",
139
+ "impacted_business_process":null,
140
+ "is_active":true,
141
+ "last_reviewed_at":null,
142
+ "lower_threshold":null,
143
+ "name":"ALARM NAME 17",
144
+ "originating_system":"Source System",
145
+ "primary_owner":null,
146
+ "secondary_owner":null,
147
+ "sop":null,
148
+ "upper_threshold":null
149
+ }
150
+ },
151
+ {
152
+ "alarm":{
153
+ "added_at":"2013-05-21T16:58:41.000Z",
154
+ "alarm_type":null,
155
+ "component":null,
156
+ "confidence_factor":null,
157
+ "description":null,
158
+ "id":8,
159
+ "impact_level":"Unknown",
160
+ "impacted_business_process":null,
161
+ "is_active":true,
162
+ "last_reviewed_at":null,
163
+ "lower_threshold":null,
164
+ "name":"ALARM NAME 18",
165
+ "originating_system":"Source System",
166
+ "primary_owner":null,
167
+ "secondary_owner":null,
168
+ "sop":null,
169
+ "upper_threshold":null
170
+ }
171
+ },
172
+ {
173
+ "alarm":{
174
+ "added_at":"2013-05-21T17:29:50.000Z",
175
+ "alarm_type":"",
176
+ "component":"Component",
177
+ "confidence_factor":"medium",
178
+ "description":"",
179
+ "id":9,
180
+ "impact_level":"medium",
181
+ "impacted_business_process":"",
182
+ "is_active":true,
183
+ "last_reviewed_at":null,
184
+ "lower_threshold":"",
185
+ "name":"ALARM NAME 19",
186
+ "originating_system":"Source System",
187
+ "primary_owner":"Primary Owner",
188
+ "secondary_owner":"Owner",
189
+ "sop":"",
190
+ "upper_threshold":""
191
+ }
192
+ },
193
+ {
194
+ "alarm":{
195
+ "added_at":"2013-05-21T18:01:40.000Z",
196
+ "alarm_type":null,
197
+ "component":null,
198
+ "confidence_factor":null,
199
+ "description":null,
200
+ "id":10,
201
+ "impact_level":"Unknown",
202
+ "impacted_business_process":null,
203
+ "is_active":true,
204
+ "last_reviewed_at":null,
205
+ "lower_threshold":null,
206
+ "name":"ALARM NAME 20",
207
+ "originating_system":"Source System",
208
+ "primary_owner":null,
209
+ "secondary_owner":null,
210
+ "sop":null,
211
+ "upper_threshold":null
212
+ }
213
+ }
214
+ ],
215
+ "page":2,
216
+ "per_page":10,
217
+ "total_count":20,
218
+ "total_pages":2
219
+ }
220
+ ]
@@ -0,0 +1,27 @@
1
+ {
2
+ "message":"Alarm updated",
3
+ "alarm":{
4
+ "id":23,
5
+ "name":"Alarm Name",
6
+ "alarm_type":null,
7
+ "originating_system":"SourceSystem",
8
+ "component":null,
9
+ "primary_owner":null,
10
+ "secondary_owner":null,
11
+ "impact_level":"low",
12
+ "confidence_factor":null,
13
+ "impacted_business_process":null,
14
+ "description":null,
15
+ "sop":null,
16
+ "is_active":true,
17
+ "upper_threshold":null,
18
+ "lower_threshold":null,
19
+ "added_at":"2013-11-22T18:05:17.000Z",
20
+ "last_reviewed_at":null,
21
+ "created_at":"2013-11-22T18:05:17.000Z",
22
+ "updated_at":"2013-12-12T13:59:17.492Z",
23
+ "event_handlers":[
24
+
25
+ ]
26
+ }
27
+ }
@@ -0,0 +1 @@
1
+ {"message":"Your API key is invalid"}
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'xcal/parktronic/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'xcal-parktronic'
8
+ spec.version = Xcal::Parktronic::VERSION
9
+ spec.authors = ['Max Reznichenko']
10
+ spec.email = ['max.reznichenko@gmail.com']
11
+ spec.description = %q{OIV API gem}
12
+ spec.summary = %q{Get easy access to the most OIV data}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features|support)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.required_ruby_version = '>=1.9.2'
22
+
23
+ spec.add_dependency 'hashie'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.3'
26
+ spec.add_development_dependency 'rb-readline'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'rspec'
29
+ spec.add_development_dependency 'webmock'
30
+ spec.add_development_dependency 'sinatra'
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xcal-parktronic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Max Reznichenko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hashie
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rb-readline
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sinatra
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: OIV API gem
112
+ email:
113
+ - max.reznichenko@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - Gemfile
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - lib/xcal/parktronic.rb
124
+ - lib/xcal/parktronic/api_client.rb
125
+ - lib/xcal/parktronic/exceptions.rb
126
+ - lib/xcal/parktronic/generic_response.rb
127
+ - lib/xcal/parktronic/routes.rb
128
+ - lib/xcal/parktronic/routes/alarms.rb
129
+ - lib/xcal/parktronic/version.rb
130
+ - spec/lib/xcal/parktronic/api_client_spec.rb
131
+ - spec/lib/xcal/parktronic/generic_response_spec.rb
132
+ - spec/lib/xcal/parktronic/routes/alarms_route_spec.rb
133
+ - spec/lib/xcal/parktronic/routes/metrics_routes_spec.rb
134
+ - spec/spec_helper.rb
135
+ - spec/support/api_mock.rb
136
+ - spec/support/fixtures/responses/alarm.json
137
+ - spec/support/fixtures/responses/alarms_page_1.json
138
+ - spec/support/fixtures/responses/alarms_page_2.json
139
+ - spec/support/fixtures/responses/alarms_post.json
140
+ - spec/support/fixtures/responses/forbidden.json
141
+ - xcal-parktronic.gemspec
142
+ homepage: ''
143
+ licenses:
144
+ - MIT
145
+ metadata: {}
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: 1.9.2
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 2.0.3
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: Get easy access to the most OIV data
166
+ test_files:
167
+ - spec/lib/xcal/parktronic/api_client_spec.rb
168
+ - spec/lib/xcal/parktronic/generic_response_spec.rb
169
+ - spec/lib/xcal/parktronic/routes/alarms_route_spec.rb
170
+ - spec/lib/xcal/parktronic/routes/metrics_routes_spec.rb
171
+ - spec/spec_helper.rb
172
+ - spec/support/api_mock.rb
173
+ - spec/support/fixtures/responses/alarm.json
174
+ - spec/support/fixtures/responses/alarms_page_1.json
175
+ - spec/support/fixtures/responses/alarms_page_2.json
176
+ - spec/support/fixtures/responses/alarms_post.json
177
+ - spec/support/fixtures/responses/forbidden.json