ops_genie 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +11 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/core_extensions/hash.rb +13 -0
- data/lib/core_extensions/string.rb +5 -0
- data/lib/generators/ops_genie/install_generator.rb +14 -0
- data/lib/generators/templates/ops_genie_initializer.rb +8 -0
- data/lib/ops_genie/alert.rb +16 -0
- data/lib/ops_genie/helper.rb +36 -0
- data/lib/ops_genie/version.rb +3 -0
- data/lib/ops_genie.rb +16 -0
- data/ops_genie.gemspec +35 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: adacefbfcdf8c5d82d344b763a1cffa24d5f0dc1
|
4
|
+
data.tar.gz: 086c365de6ec544f4f9a34fb0af5778df3c99979
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cbdc41c49504df4bbe1b73be5056d8859e33d8947e2de62371699fa36eeefaf278115228549f70336a44f91917832c509d02b52c40f1a40d866e6491b7953be8
|
7
|
+
data.tar.gz: 9784cc76f22930fdf5fb3bd5f4899195046f837c24edb2534fd945d69232acd3226cea0fba207c0f788170bdc50020eed13a44af1c02cd9669741154becc467b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Thomas Haratyk
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# OpsGenie
|
2
|
+
|
3
|
+
This gem is a work in progress and currently only allow the creation of alerts.
|
4
|
+
The purpose is to provide a structure for further implementation of OpsGenie web api ( https://www.opsgenie.com/docs/web-api )
|
5
|
+
|
6
|
+
run `rails g ops_genie:install` to generate the intializer and set up the api key
|
7
|
+
|
8
|
+
# Usage :
|
9
|
+
|
10
|
+
`OpsGenie::Alert.create({message: "your message", description: "a description", another_parameter: "a value"})`
|
11
|
+
see https://www.opsgenie.com/docs/web-api/alert-api#createAlertRequest for the list of parameters. Use the ruby standard snake case for the keys, it'll be camelized
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ops_genie"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "core_extensions/string"
|
2
|
+
class Hash
|
3
|
+
def camelize_lower_keys!
|
4
|
+
self.keys.each do |key|
|
5
|
+
value = delete(key)
|
6
|
+
if key.is_a? String
|
7
|
+
self[key.lcamelize] = value
|
8
|
+
elsif key.is_a? Symbol
|
9
|
+
self[key.to_s.lcamelize.to_sym] = value
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module OpsGenie
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../../templates", __FILE__)
|
5
|
+
desc "Creates OpsGenie initializer for your application"
|
6
|
+
|
7
|
+
def copy_initializer
|
8
|
+
template "ops_genie_initializer.rb", "config/initializers/ops_genie.rb"
|
9
|
+
|
10
|
+
puts "Created a configuration file in config/initializers/ops_genie.rb. Don't forget to set your API key!"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
OpsGenie.configure do |config|
|
2
|
+
config.api_key = "your api key"
|
3
|
+
config.base_url = 'https://api.opsgenie.com/'
|
4
|
+
|
5
|
+
# Optional :
|
6
|
+
# config.release_stage = "something" # Will automatically be setup to Rails.env if you use Rails
|
7
|
+
# config.alert_release_stages = ["production", "staging"] # Only send alerts on those release stages. If not set, it will always send alerts
|
8
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "core_extensions/string"
|
2
|
+
require "core_extensions/hash"
|
3
|
+
module OpsGenie
|
4
|
+
module Helper
|
5
|
+
|
6
|
+
def should_alert?
|
7
|
+
OpsGenie.configuration.release_stage.nil? ||
|
8
|
+
OpsGenie.configuration.alert_release_stages.nil? ||
|
9
|
+
OpsGenie.configuration.alert_release_stages.include?(OpsGenie.configuration.release_stage)
|
10
|
+
end
|
11
|
+
|
12
|
+
def http_post endpoint, params
|
13
|
+
uri = URI(File.join(OpsGenie.configuration.base_url, endpoint))
|
14
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
15
|
+
http.use_ssl = true
|
16
|
+
JSON.parse(http.post(uri.path, ops_params(params)).body)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def ops_params params
|
21
|
+
params.merge!(api_key: OpsGenie.configuration.api_key)
|
22
|
+
camelize_keys_recursive!(params).to_json
|
23
|
+
end
|
24
|
+
|
25
|
+
def camelize_keys_recursive!(hash)
|
26
|
+
if hash.is_a?(Array)
|
27
|
+
hash.each {|h| h.camelize_lower_keys!}
|
28
|
+
else
|
29
|
+
hash.camelize_lower_keys!
|
30
|
+
hash.each { |k, v| camelize_keys_recursive!(v) if (v.is_a?(Hash) || v.is_a?(Array)) }
|
31
|
+
end
|
32
|
+
hash
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
data/lib/ops_genie.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "ops_genie/helper"
|
2
|
+
require "ops_genie/alert"
|
3
|
+
|
4
|
+
module OpsGenie
|
5
|
+
class Configuration; attr_accessor :api_key, :base_url, :release_stage, :alert_release_stages; end
|
6
|
+
|
7
|
+
class << self
|
8
|
+
attr_accessor :configuration
|
9
|
+
|
10
|
+
def configure
|
11
|
+
self.configuration ||= Configuration.new
|
12
|
+
self.configuration.release_stage ||= (Rails.env if defined? Rails)
|
13
|
+
yield(configuration)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/ops_genie.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ops_genie/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ops_genie"
|
8
|
+
spec.version = OpsGenie::VERSION
|
9
|
+
spec.authors = ["Thomas Haratyk"]
|
10
|
+
spec.email = ["thomas.haratyk@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "OpsGenie API wrapper"
|
13
|
+
#spec.description = "TODO: Write a longer description or delete this line."
|
14
|
+
#spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec"
|
33
|
+
spec.add_development_dependency "webmock"
|
34
|
+
spec.add_development_dependency "pry"
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ops_genie
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas Haratyk
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
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: webmock
|
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: pry
|
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
|
+
description:
|
84
|
+
email:
|
85
|
+
- thomas.haratyk@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/console
|
96
|
+
- bin/setup
|
97
|
+
- lib/core_extensions/hash.rb
|
98
|
+
- lib/core_extensions/string.rb
|
99
|
+
- lib/generators/ops_genie/install_generator.rb
|
100
|
+
- lib/generators/templates/ops_genie_initializer.rb
|
101
|
+
- lib/ops_genie.rb
|
102
|
+
- lib/ops_genie/alert.rb
|
103
|
+
- lib/ops_genie/helper.rb
|
104
|
+
- lib/ops_genie/version.rb
|
105
|
+
- ops_genie.gemspec
|
106
|
+
homepage:
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata:
|
110
|
+
allowed_push_host: https://rubygems.org
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.4.5
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: OpsGenie API wrapper
|
131
|
+
test_files: []
|