access-watch-ruby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +19 -0
- data/README.md +35 -0
- data/cacert.pem +4043 -0
- data/lib/access_watch.rb +42 -0
- metadata +80 -0
data/lib/access_watch.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "json/ext"
|
2
|
+
require "net/http"
|
3
|
+
require "uri"
|
4
|
+
require "openssl"
|
5
|
+
|
6
|
+
module AccessWatch
|
7
|
+
class Client
|
8
|
+
attr_reader :api_key, :api_secret, :api_endpoint
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
@api_secret = options[:api_secret]
|
12
|
+
@api_key = options[:api_key] or raise "AccessWatch api_key is mandatory."
|
13
|
+
@api_endpoint = options[:api_endpoint] || "https://access.watch/api/1.0/"
|
14
|
+
end
|
15
|
+
|
16
|
+
HTTPS = "https".freeze
|
17
|
+
CERTIFICATE_AUTHORITIES_PATH = File.expand_path("../../cacert.pem", __FILE__)
|
18
|
+
|
19
|
+
def post(path, data)
|
20
|
+
uri = URI(api_endpoint + path)
|
21
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
22
|
+
|
23
|
+
if uri.scheme == HTTPS
|
24
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
25
|
+
http.ca_file = CERTIFICATE_AUTHORITIES_PATH
|
26
|
+
http.use_ssl = true
|
27
|
+
end
|
28
|
+
|
29
|
+
post = Net::HTTP::Post.new(uri.path, default_headers)
|
30
|
+
post.body = data.to_json
|
31
|
+
http.request(post)
|
32
|
+
end
|
33
|
+
|
34
|
+
def default_headers
|
35
|
+
{
|
36
|
+
"Api-Key" => api_key,
|
37
|
+
"Accept" => "application/json",
|
38
|
+
"Content-Type" => "application/json",
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: access-watch-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexis Bernard
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-30 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.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
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
|
+
description: A Ruby library to log and analyse HTTP requests using the Access Watch
|
42
|
+
cloud service.
|
43
|
+
email:
|
44
|
+
- alexis@bernard.io
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- LICENSE
|
50
|
+
- README.md
|
51
|
+
- cacert.pem
|
52
|
+
- lib/access_watch.rb
|
53
|
+
homepage: https://access.watch/
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata:
|
57
|
+
allowed_push_host: https://rubygems.org
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 2.5.1
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: A Ruby library to log and analyse HTTP requests using the Access Watch cloud
|
78
|
+
service.
|
79
|
+
test_files: []
|
80
|
+
has_rdoc:
|