sensit-client 0.0.1 → 0.0.2
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 +4 -4
- data/lib/sensit/api/feed.rb +6 -6
- data/lib/sensit/api/field.rb +6 -8
- data/lib/sensit/api/percolator.rb +6 -8
- data/lib/sensit/api/report.rb +6 -14
- data/lib/sensit/api/subscription.rb +6 -14
- data/lib/sensit/api/topic.rb +6 -6
- data/lib/sensit/http_client.rb +1 -2
- data/lib/sensit/http_client/auth_handler.rb +9 -29
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acaa09e779dfb2934972ecc850052fde44126e23
|
4
|
+
data.tar.gz: b3479f2dada5a5f7d1460154d3880d4794dd43ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ee542d1943ee1633dfddb71290005eb201e061615526b38fa1e35ebd96c13f7ff0128f9ab01f5c7044ad8759b266b01a3239faa7ca21088c9873bd660d6d8b0
|
7
|
+
data.tar.gz: c243636dceae571ea041f2eef7a2e2daef6b059fc1a5fa5b3645ffa478f1f7bb1191e2f1550b0ed7e50d4f5785bda53352007514b0bcfd7a0ff36c89480e8826
|
data/lib/sensit/api/feed.rb
CHANGED
@@ -39,10 +39,10 @@ module Sensit
|
|
39
39
|
# Create a feed on a given topic. Requires authorization of **read_any_data**, or **read_application_data**.
|
40
40
|
# '/topics/:topic_id/feeds' POST
|
41
41
|
#
|
42
|
-
#
|
43
|
-
def create(
|
42
|
+
# feed - A Hash containing `at`: a formatted time of the event. Defaults to the current time if not present.`tz`: The time zone of the time given in `at`. Defaults to UTC`data`:A hash of data to be stored
|
43
|
+
def create(feed, options = {})
|
44
44
|
body = options.has_key?(:body) ? options[:body] : {}
|
45
|
-
body[:
|
45
|
+
body[:feed] = feed
|
46
46
|
|
47
47
|
response = @client.post "/topics/#{@topic_id}/feeds", body, options
|
48
48
|
|
@@ -52,10 +52,10 @@ module Sensit
|
|
52
52
|
# Update an associated Feed to the Topic. Requires authorization of **read_any_data**, or **read_application_data**.
|
53
53
|
# '/topics/:topic_id/feeds/:id' PUT
|
54
54
|
#
|
55
|
-
#
|
56
|
-
def update(
|
55
|
+
# feed - A hash containing `data`:A hash of data to be stored
|
56
|
+
def update(feed, options = {})
|
57
57
|
body = options.has_key?(:body) ? options[:body] : {}
|
58
|
-
body[:
|
58
|
+
body[:feed] = feed
|
59
59
|
|
60
60
|
response = @client.put "/topics/#{@topic_id}/feeds/#{@id}", body, options
|
61
61
|
|
data/lib/sensit/api/field.rb
CHANGED
@@ -39,12 +39,10 @@ module Sensit
|
|
39
39
|
# Adds a new field that feed data can be added too. Requires authorization of **manage_any_data**, or **manage_application_data**
|
40
40
|
# '/topics/:topic_id/fields' POST
|
41
41
|
#
|
42
|
-
#
|
43
|
-
|
44
|
-
def create(name, key, options = {})
|
42
|
+
# field - A Hash containing`name`: A descriptive name of the field.`key`:The name that is used to identify the field in a feed (required).`datatype`:The type of data that is stored in the field. ie. integer, float, string, bool, datetime
|
43
|
+
def create(field, options = {})
|
45
44
|
body = options.has_key?(:body) ? options[:body] : {}
|
46
|
-
body[:
|
47
|
-
body[:key] = key
|
45
|
+
body[:field] = field
|
48
46
|
|
49
47
|
response = @client.post "/topics/#{@topic_id}/fields", body, options
|
50
48
|
|
@@ -54,10 +52,10 @@ module Sensit
|
|
54
52
|
# Updates the Field data and makes the corresponding changes in the index. Requires authorization of **manage_any_data**, or **manage_application_data**
|
55
53
|
# '/api/topics/:topic_id/fields/:id' PUT
|
56
54
|
#
|
57
|
-
#
|
58
|
-
def update(
|
55
|
+
# field - A Hash containing`name`: A descriptive name of the field.`key`:The name that is used to identify the field in a feed (required).`datatype`:The type of data that is stored in the field. ie. integer, float, string, bool, datetime
|
56
|
+
def update(field, options = {})
|
59
57
|
body = options.has_key?(:body) ? options[:body] : {}
|
60
|
-
body[:
|
58
|
+
body[:field] = field
|
61
59
|
|
62
60
|
response = @client.put "/api/topics/#{@topic_id}/fields/#{@id}", body, options
|
63
61
|
|
@@ -39,12 +39,10 @@ module Sensit
|
|
39
39
|
# Create a percolator on the associated Topic with the specified name and query. Requires authorization of **manage_any_percolators**, or **manage_application_percolators**.
|
40
40
|
# '/topics/:topic_id/percolators' POST
|
41
41
|
#
|
42
|
-
#
|
43
|
-
|
44
|
-
def create(name, query, options = {})
|
42
|
+
# percolator - A Hash containing `name`: The name of the percolator(required).`query`: The query hash according to the according the the [elasticsearch Query DSL](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html)
|
43
|
+
def create(percolator, options = {})
|
45
44
|
body = options.has_key?(:body) ? options[:body] : {}
|
46
|
-
body[:
|
47
|
-
body[:query] = query
|
45
|
+
body[:percolator] = percolator
|
48
46
|
|
49
47
|
response = @client.post "/topics/#{@topic_id}/percolators", body, options
|
50
48
|
|
@@ -54,10 +52,10 @@ module Sensit
|
|
54
52
|
# Update the query for a specific percolator. Requires authorization of **manage_any_percolators**, or **manage_application_percolators**.
|
55
53
|
# '/topics/:topic_id/percolators/:id' PUT
|
56
54
|
#
|
57
|
-
#
|
58
|
-
def update(
|
55
|
+
# percolator - A Hash containing the `query` hash according to the according the the [elasticsearch Query DSL](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html)
|
56
|
+
def update(percolator, options = {})
|
59
57
|
body = options.has_key?(:body) ? options[:body] : {}
|
60
|
-
body[:
|
58
|
+
body[:percolator] = percolator
|
61
59
|
|
62
60
|
response = @client.put "/topics/#{@topic_id}/percolators/#{@id}", body, options
|
63
61
|
|
data/lib/sensit/api/report.rb
CHANGED
@@ -39,14 +39,10 @@ module Sensit
|
|
39
39
|
# Create a new report on the associated Topic which can be easily retrieved later using an id. Requires authorization of **manage_any_reports**, or **manage_application_reports**.
|
40
40
|
# '/topics/:topic_id/reports' POST
|
41
41
|
#
|
42
|
-
#
|
43
|
-
|
44
|
-
# facets - An array of facet hashes which each contain a `name` ad type of the facet along with its query hash.
|
45
|
-
def create(name, query, facets, options = {})
|
42
|
+
# report - A Hash containing `name`: The name of the report (required).`query`:The search query acccording to the [elasticsearch Query DSL](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-queries.html) to filter the data for the facets (Defaults to match all).`facets`:An array of facet hashes which each contain a `name` ad type of the facet along with its query hash (required).
|
43
|
+
def create(report, options = {})
|
46
44
|
body = options.has_key?(:body) ? options[:body] : {}
|
47
|
-
body[:
|
48
|
-
body[:query] = query
|
49
|
-
body[:facets] = facets
|
45
|
+
body[:report] = report
|
50
46
|
|
51
47
|
response = @client.post "/topics/#{@topic_id}/reports", body, options
|
52
48
|
|
@@ -56,14 +52,10 @@ module Sensit
|
|
56
52
|
# Update the query, facets or name of the report. Requires authorization of **manage_any_reports**, or **manage_application_reports**.
|
57
53
|
# '/topics/:topic_id/reports/:id' PUT
|
58
54
|
#
|
59
|
-
#
|
60
|
-
|
61
|
-
# facets - An array of facet hashes which each contain a `name` ad type of the facet along with its query hash.
|
62
|
-
def update(name, query, facets, options = {})
|
55
|
+
# report - A Hash containing `name`: The name of the report (required).`query`:The search query acccording to the [elasticsearch Query DSL](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-queries.html) to filter the data for the facets (Defaults to match all).`facets`:An array of facet hashes which each contain a `name` ad type of the facet along with its query hash (required).
|
56
|
+
def update(report, options = {})
|
63
57
|
body = options.has_key?(:body) ? options[:body] : {}
|
64
|
-
body[:
|
65
|
-
body[:query] = query
|
66
|
-
body[:facets] = facets
|
58
|
+
body[:report] = report
|
67
59
|
|
68
60
|
response = @client.put "/topics/#{@topic_id}/reports/#{@id}", body, options
|
69
61
|
|
@@ -37,14 +37,10 @@ module Sensit
|
|
37
37
|
# Create a subscription which will connect to the server and listen for feed data for any of the associated topics. Requires authorization of **manage_any_subscriptions**, or **manage_application_subscriptions**.
|
38
38
|
# '/subscriptions' POST
|
39
39
|
#
|
40
|
-
#
|
41
|
-
|
42
|
-
# protocol - the protocol to comminivate over
|
43
|
-
def create(name, host, protocol, options = {})
|
40
|
+
# subscription - A Hash containing`name`:The channel or name to identify the subscription(required).`host`:The ip address or host of the connection(required).`protocol`:the protocol to communicate over (http, tcp, udp, mqtt) (required)`port`:The port of the connection.
|
41
|
+
def create(subscription, options = {})
|
44
42
|
body = options.has_key?(:body) ? options[:body] : {}
|
45
|
-
body[:
|
46
|
-
body[:host] = host
|
47
|
-
body[:protocol] = protocol
|
43
|
+
body[:subscription] = subscription
|
48
44
|
|
49
45
|
response = @client.post "/subscriptions", body, options
|
50
46
|
|
@@ -54,14 +50,10 @@ module Sensit
|
|
54
50
|
# Returns an object with the current configuration that Buffer is using, including supported services, their icons and the varying limits of character and schedules. Requires authorization of **manage_any_subscriptions**, or **manage_application_subscriptions**.
|
55
51
|
# '/subscriptions/:id' PUT
|
56
52
|
#
|
57
|
-
#
|
58
|
-
|
59
|
-
# protocol - the protocol to comminivate over
|
60
|
-
def update(name, host, protocol, options = {})
|
53
|
+
# subscription - A Hash containing`name`:The channel or name to identify the subscription(required).`host`:The ip address or host of the connection(required).`protocol`:the protocol to communicate over (http, tcp, udp, mqtt) (required)`port`:The port of the connection.
|
54
|
+
def update(subscription, options = {})
|
61
55
|
body = options.has_key?(:body) ? options[:body] : {}
|
62
|
-
body[:
|
63
|
-
body[:host] = host
|
64
|
-
body[:protocol] = protocol
|
56
|
+
body[:subscription] = subscription
|
65
57
|
|
66
58
|
response = @client.put "/subscriptions/#{@id}", body, options
|
67
59
|
|
data/lib/sensit/api/topic.rb
CHANGED
@@ -35,10 +35,10 @@ module Sensit
|
|
35
35
|
# Requires authorization of **manage_any_data**, or **manage_application_data**.
|
36
36
|
# '/topics' POST
|
37
37
|
#
|
38
|
-
#
|
39
|
-
def create(
|
38
|
+
# topic - A hash containing the name/id of the topic (required) and a description of the topic.
|
39
|
+
def create(topic, options = {})
|
40
40
|
body = options.has_key?(:body) ? options[:body] : {}
|
41
|
-
body[:
|
41
|
+
body[:topic] = topic
|
42
42
|
|
43
43
|
response = @client.post "/topics", body, options
|
44
44
|
|
@@ -48,10 +48,10 @@ module Sensit
|
|
48
48
|
# Requires authorization of **manage_any_data**, or **manage_application_data**.
|
49
49
|
# '/topics/:id' PUT
|
50
50
|
#
|
51
|
-
#
|
52
|
-
def update(
|
51
|
+
# topic - A hash containing the name/id of the topic (required) and a description of the topic.
|
52
|
+
def update(topic, options = {})
|
53
53
|
body = options.has_key?(:body) ? options[:body] : {}
|
54
|
-
body[:
|
54
|
+
body[:topic] = topic
|
55
55
|
|
56
56
|
response = @client.put "/topics/:id", body, options
|
57
57
|
|
data/lib/sensit/http_client.rb
CHANGED
@@ -16,12 +16,11 @@ module Sensit
|
|
16
16
|
def initialize(auth = {}, options = {})
|
17
17
|
|
18
18
|
if auth.is_a? String
|
19
|
-
auth = { :
|
19
|
+
auth = { :http_header => auth }
|
20
20
|
end
|
21
21
|
|
22
22
|
@options = {
|
23
23
|
:base => "http://sensit.herokuapp.com/api",
|
24
|
-
:api_version => "1",
|
25
24
|
:user_agent => "alpaca/0.2.0 (https://github.com/pksunkara/alpaca)"
|
26
25
|
}
|
27
26
|
|
@@ -7,8 +7,7 @@ module Sensit
|
|
7
7
|
# AuthHandler takes care of devising the auth type and using it
|
8
8
|
class AuthHandler < Faraday::Middleware
|
9
9
|
|
10
|
-
|
11
|
-
URL_TOKEN = 3
|
10
|
+
HTTP_HEADER = 1
|
12
11
|
|
13
12
|
def initialize(app, auth = {}, options = {})
|
14
13
|
@auth = auth
|
@@ -20,13 +19,8 @@ module Sensit
|
|
20
19
|
auth = get_auth_type
|
21
20
|
flag = false
|
22
21
|
|
23
|
-
if auth ==
|
24
|
-
env =
|
25
|
-
flag = true
|
26
|
-
end
|
27
|
-
|
28
|
-
if auth == URL_TOKEN
|
29
|
-
env = url_token env
|
22
|
+
if auth == HTTP_HEADER
|
23
|
+
env = http_header env
|
30
24
|
flag = true
|
31
25
|
end
|
32
26
|
|
@@ -41,32 +35,18 @@ module Sensit
|
|
41
35
|
# Calculating the Authentication Type
|
42
36
|
def get_auth_type()
|
43
37
|
|
44
|
-
if @auth.has_key?(:
|
45
|
-
return
|
46
|
-
end
|
47
|
-
|
48
|
-
if @auth.has_key?(:access_token)
|
49
|
-
return URL_TOKEN
|
38
|
+
if @auth.has_key?(:http_header)
|
39
|
+
return HTTP_HEADER
|
50
40
|
end
|
51
41
|
|
52
42
|
return -1
|
53
43
|
end
|
54
44
|
|
55
|
-
#
|
56
|
-
def
|
57
|
-
|
58
|
-
:client_id => @auth[:client_id],
|
59
|
-
:client_secret => @auth[:client_secret]
|
60
|
-
}
|
45
|
+
# Authorization with HTTP header
|
46
|
+
def http_header(env)
|
47
|
+
env[:request_headers]["Authorization"] = "Bearer #{@auth[:http_header]}"
|
61
48
|
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
# OAUTH2 Authorization with access token
|
66
|
-
def url_token(env)
|
67
|
-
query = { :access_token => @auth[:access_token] }
|
68
|
-
|
69
|
-
merge_query env, query
|
49
|
+
return env
|
70
50
|
end
|
71
51
|
|
72
52
|
def query_params(url)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensit-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Waddington
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|