datasift 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +13 -2
- data/VERSION +1 -1
- data/datasift.gemspec +3 -3
- data/examples/auth.rb +16 -10
- data/lib/datasift.rb +23 -23
- metadata +8 -9
- data/lib/DataSift/managed_source.rb +0 -263
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa899a750cdf5d358c93ab071c4dc35c796f3114
|
4
|
+
data.tar.gz: 2d2a1b150ec62f0e689be3ebf48749183e5d5fba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7931605c899901c11f9563d31b695a1b41f8dc9fe3d5c7de8204e06eb272620502064ea212cb620586f2da80507b12ab85d1c6e892e1b6a3102d86e3e1bba28b
|
7
|
+
data.tar.gz: 5ad02f8dd35ca6f4bd6230087a70d5145482f2778d9b9fe86e335cca5703afad257ca28395bc7fe0642c91bccc4e22ec98a5e650ab47db17a5238249c4d8090c
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
================================
|
3
3
|
|
4
|
+
v.3.1.1 (2014-08-14)
|
5
|
+
--------------------
|
6
|
+
|
7
|
+
####Fixes
|
8
|
+
Resolves [#59](https://github.com/datasift/datasift-ruby/issues/59); we now use CGI.escape rather than URI.escape to ensure special characters such as '+' or '\' are escaped correctly when submitted.
|
9
|
+
|
4
10
|
v.3.1.0 (2014-07-30)
|
5
11
|
--------------------
|
6
12
|
|
data/README.md
CHANGED
@@ -1,20 +1,31 @@
|
|
1
1
|
DataSift
|
2
2
|
========
|
3
3
|
|
4
|
+
[![Gem Version](http://img.shields.io/gem/v/datasift.svg)][gem]
|
5
|
+
[![Build Status](http://img.shields.io/travis/datasift/datasift-ruby.svg)][travis]
|
6
|
+
|
7
|
+
[gem]: https://rubygems.org/gems/datasift
|
8
|
+
[travis]: https://travis-ci.org/datasift/datasift-ruby
|
9
|
+
|
10
|
+
|
4
11
|
The official Ruby library for accessing the DataSift API. See
|
5
|
-
http://datasift.com/ for full details and to sign up for an account.
|
12
|
+
[datasift.com](http://datasift.com/) for full details and to sign up for an account.
|
6
13
|
|
7
14
|
Install Instructions
|
8
15
|
--------------------
|
9
16
|
|
17
|
+
```
|
10
18
|
sudo gem install datasift
|
19
|
+
```
|
11
20
|
|
12
21
|
Dependencies
|
13
22
|
------------
|
14
23
|
|
15
24
|
If you're using the source you'll need to install the dependencies.
|
16
25
|
|
26
|
+
```
|
17
27
|
sudo gem install rest-client multi_json websocket-td
|
28
|
+
```
|
18
29
|
|
19
30
|
The library will use SSL connections by default. While we recommend using SSL
|
20
31
|
you may disable it if required by passing ':enable_ssl => false' as the third
|
@@ -24,7 +35,7 @@ Getting Started
|
|
24
35
|
---------------
|
25
36
|
Before you can begin using this library, you will need to have an active [DataSift](http://datasift.com) account - you can sign up for a new account at [datasift.com/get-started](http://datasift.com/get-started/).
|
26
37
|
|
27
|
-
Many of the examples and API endpoints used in this library require you have enabled certain data sources before you can receive any data (you should do this at [datasift.com/source](https://datasift.com/source)). Certain API features, such as [Historics](http://datasift.com/platform/historics/) and [Managed Sources](http://datasift.com/platform/datasources/) will require you have signed up to a monthly subscription before you can access them.
|
38
|
+
Many of the examples and API endpoints used in this library require you have enabled certain data sources before you can receive any data (you should do this at [datasift.com/source](https://datasift.com/source)). Certain API features, such as [Historics](http://datasift.com/platform/historics/) and [Managed Sources](http://datasift.com/platform/datasources/) will require you have signed up to a monthly subscription before you can access them.
|
28
39
|
|
29
40
|
If you are interested in using these features, or would like more information about DataSift, please [get in touch](http://datasift.com/contact-us/)!
|
30
41
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.1
|
data/datasift.gemspec
CHANGED
@@ -15,12 +15,12 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.add_runtime_dependency('multi_json', '~> 1.8.0')
|
16
16
|
s.add_runtime_dependency('websocket-td', '~> 0.0.4')
|
17
17
|
|
18
|
-
s.add_development_dependency('rdoc', '
|
18
|
+
s.add_development_dependency('rdoc', '>= 0')
|
19
19
|
s.add_development_dependency('webmock', '~> 1.17.1')
|
20
20
|
s.add_development_dependency('shoulda', '~> 2.11.3')
|
21
21
|
s.add_development_dependency('minitest', '~> 5.0')
|
22
|
-
s.add_development_dependency('rake', '
|
23
|
-
s.add_development_dependency('simplecov', '
|
22
|
+
s.add_development_dependency('rake', '>= 0')
|
23
|
+
s.add_development_dependency('simplecov', '>= 0')
|
24
24
|
|
25
25
|
s.files = `git ls-files`.split("\n")
|
26
26
|
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
data/examples/auth.rb
CHANGED
@@ -6,19 +6,25 @@ class DataSiftExample
|
|
6
6
|
@api_key = 'DATASIFT_API_KEY'
|
7
7
|
@config = {:username => @username, :api_key => @api_key, :enable_ssl => true}
|
8
8
|
@params = {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
'
|
17
|
-
|
9
|
+
:output_type => 's3',
|
10
|
+
:output_params => {
|
11
|
+
:bucket => 'YOUR_BUCKET_NAME',
|
12
|
+
:directory => 'ruby',
|
13
|
+
:acl => 'private',
|
14
|
+
:delivery_frequency => 0,
|
15
|
+
:max_size => 104857600,
|
16
|
+
:file_prefix => 'DataSift',
|
17
|
+
:auth => {
|
18
|
+
:access_key => 'ADD_YOUR_ACCESS_KEY',
|
19
|
+
:secret_key => 'ADD_YOUR_SECRET_KEY',
|
20
|
+
}
|
21
|
+
}
|
18
22
|
}
|
19
23
|
@pull_params = {
|
20
24
|
:output_type => 'pull',
|
21
|
-
|
25
|
+
:output_params => {
|
26
|
+
:max_size => 52428800
|
27
|
+
}
|
22
28
|
}
|
23
29
|
@datasift = DataSift::Client.new(@config)
|
24
30
|
end
|
data/lib/datasift.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
dir = File.dirname(__FILE__)
|
2
2
|
#
|
3
3
|
require 'uri'
|
4
|
+
require 'cgi'
|
4
5
|
require 'rest_client'
|
5
6
|
require 'multi_json'
|
6
7
|
require 'websocket_td'
|
@@ -134,9 +135,9 @@ module DataSift
|
|
134
135
|
url = build_url(path, config)
|
135
136
|
|
136
137
|
headers.update ({
|
137
|
-
|
138
|
-
|
139
|
-
|
138
|
+
:user_agent => "DataSift/#{config[:api_version]} Ruby/v#{VERSION}",
|
139
|
+
:authorization => "#{config[:username]}:#{config[:api_key]}",
|
140
|
+
:content_type => 'application/x-www-form-urlencoded'
|
140
141
|
})
|
141
142
|
|
142
143
|
case method.to_s.downcase.to_sym
|
@@ -144,19 +145,18 @@ module DataSift
|
|
144
145
|
url += "#{URI.parse(url).query ? '&' : '?'}#{encode params}"
|
145
146
|
payload = nil
|
146
147
|
else
|
147
|
-
#payload = encode params
|
148
148
|
payload = MultiJson.dump(params)
|
149
149
|
headers.update ({ :content_type => 'application/json' })
|
150
150
|
end
|
151
151
|
|
152
152
|
options.update(
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
153
|
+
:headers => headers,
|
154
|
+
:method => method,
|
155
|
+
:open_timeout => open_timeout,
|
156
|
+
:timeout => timeout,
|
157
|
+
:payload => payload,
|
158
|
+
:url => url,
|
159
|
+
:ssl_version => 'TLSv1'
|
160
160
|
)
|
161
161
|
|
162
162
|
begin
|
@@ -179,16 +179,16 @@ module DataSift
|
|
179
179
|
data = {}
|
180
180
|
end
|
181
181
|
{
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
182
|
+
:data => data,
|
183
|
+
:datasift => {
|
184
|
+
:x_ratelimit_limit => response.headers[:x_ratelimit_limit],
|
185
|
+
:x_ratelimit_remaining => response.headers[:x_ratelimit_remaining],
|
186
|
+
:x_ratelimit_cost => response.headers[:x_ratelimit_cost]
|
187
|
+
},
|
188
|
+
:http => {
|
189
|
+
:status => response.code,
|
190
|
+
:headers => response.headers
|
191
|
+
}
|
192
192
|
}
|
193
193
|
rescue MultiJson::DecodeError => de
|
194
194
|
raise DataSiftError.new response
|
@@ -228,7 +228,7 @@ module DataSift
|
|
228
228
|
end
|
229
229
|
|
230
230
|
def self.encode params
|
231
|
-
|
231
|
+
params.collect { |param, value| [param, CGI.escape(value.to_s)].join('=') }.join('&')
|
232
232
|
end
|
233
233
|
|
234
234
|
def self.handle_api_error(code, body)
|
@@ -282,7 +282,7 @@ module DataSift
|
|
282
282
|
stream.on_ping = lambda { |data|
|
283
283
|
KNOWN_SOCKETS[connection] = Time.new.to_i
|
284
284
|
}
|
285
|
-
stream.on_open =lambda {
|
285
|
+
stream.on_open = lambda {
|
286
286
|
connection.connected = true
|
287
287
|
connection.retry_timeout = 0
|
288
288
|
on_open.call(connection) if on_open != nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datasift
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DataSift
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -112,28 +112,28 @@ dependencies:
|
|
112
112
|
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: simplecov
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - "
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - "
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
description: The official Ruby library for accessing the DataSift API. See http://datasift.com/
|
@@ -165,7 +165,6 @@ files:
|
|
165
165
|
- examples/managed_source_eg.rb
|
166
166
|
- examples/pull.rb
|
167
167
|
- examples/push_eg.rb
|
168
|
-
- lib/DataSift/managed_source.rb
|
169
168
|
- lib/api/api_resource.rb
|
170
169
|
- lib/cli.rb
|
171
170
|
- lib/datasift.rb
|
@@ -1,263 +0,0 @@
|
|
1
|
-
require 'yajl/json_gem'
|
2
|
-
### Usage ###
|
3
|
-
# user = DataSift::User.new(config['username'], config['api_key'])
|
4
|
-
# user.createManagedSource(:token => "CAAIUKbXn8xsBAILlxGCZADEZAM87tRqJXo9OqWskCs6jej3wfQ1LRRZAgHJQEZCHU0ABBXDwiq9o7D4uytC5LpsAcx7oiDusagsJiKtmPaZBeMkuGh4jYt1zsXo4EQuZCWPcZAIdQQLZBtjTpQlbbAZCTuJ4SSrlmOPQZD", :source_type => "facebook_page", :name => "test", :parameters=> {:likes => true, :posts_by_others => true, :comments => true}, :resources => [{ :url => "http://www.facebook.com/theguardian", :title => "The Guardian", :id => 10513336322 } ] )
|
5
|
-
|
6
|
-
module DataSift
|
7
|
-
#The ManagedSource class represents a ManagedSource query.
|
8
|
-
class ManagedSource
|
9
|
-
#The ID of this Managed Source
|
10
|
-
attr_reader :managed_source_id
|
11
|
-
#The Managed Source type
|
12
|
-
attr_reader :source_type
|
13
|
-
#The current status of this Managed Source.
|
14
|
-
attr_reader :status
|
15
|
-
#The title for this Managed Source.
|
16
|
-
attr_reader :name
|
17
|
-
#The date/time when this Managed Source was created.
|
18
|
-
attr_reader :created_at
|
19
|
-
#The Managed Source source_type
|
20
|
-
attr_reader :source_type
|
21
|
-
#The Managed Source parameters
|
22
|
-
attr_reader :parameters
|
23
|
-
#The Managed Source resources
|
24
|
-
attr_reader :resources
|
25
|
-
#The Managed Source token
|
26
|
-
attr_reader :token
|
27
|
-
#The Managed Source auth
|
28
|
-
attr_reader :auth
|
29
|
-
#Api raw response
|
30
|
-
attr_reader :raw_attributes
|
31
|
-
|
32
|
-
#Constructor. Pass all parameters to create a new Managed Source, or provide a User object and a managed_source_id to load an existing Managed Source from the API.
|
33
|
-
#=== Parameters
|
34
|
-
#* +user+ - The DataSift::User object.
|
35
|
-
def initialize(user, hash)
|
36
|
-
raise InvalidDataError, 'Please supply a valid User object when creating a Managed Source object.' unless user.is_a? DataSift::User
|
37
|
-
@user = user
|
38
|
-
|
39
|
-
if hash.kind_of?(Hash)
|
40
|
-
if hash.has_key?('id')
|
41
|
-
# Initialising from an array
|
42
|
-
@managed_source_id = hash['id']
|
43
|
-
initFromArray(hash)
|
44
|
-
else
|
45
|
-
@source_type = hash[:source_type]
|
46
|
-
@name = hash[:name]
|
47
|
-
@parameters = hash[:parameters]
|
48
|
-
@resources = hash[:resources]
|
49
|
-
@auth = hash[:auth]
|
50
|
-
end
|
51
|
-
else
|
52
|
-
# Fetching from the API
|
53
|
-
@managed_source_id = hash
|
54
|
-
reloadData()
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
#Get a single Managed Source by ID.
|
59
|
-
#=== Parameters
|
60
|
-
#* +id+ - The Managed Source ID.
|
61
|
-
#=== Returns
|
62
|
-
#A ManagedSource object
|
63
|
-
def self.get(user, managed_source_id)
|
64
|
-
return new(user, user.callAPI('source/get', { 'id' => managed_source_id }))
|
65
|
-
end
|
66
|
-
|
67
|
-
def self.list(user, page = 1, per_page = 20, source_type = '')
|
68
|
-
begin
|
69
|
-
res = user.callAPI(
|
70
|
-
'source/get', {
|
71
|
-
'page' => page,
|
72
|
-
'per_page' => per_page,
|
73
|
-
'source_type' => source_type
|
74
|
-
})
|
75
|
-
retval = { 'count' => res['count'], 'managed_sources' => [] }
|
76
|
-
for source in res['sources']
|
77
|
-
retval['managed_sources'].push(new(user, source))
|
78
|
-
end
|
79
|
-
retval
|
80
|
-
rescue APIError => err
|
81
|
-
case err.http_code
|
82
|
-
when 400
|
83
|
-
#Missing or invalid parameters
|
84
|
-
raise InvalidDataError, err
|
85
|
-
else
|
86
|
-
raise APIError.new(err.http_code), 'Unexpected APIError code: ' + err.http_code.to_s + ' [' + err.message + ']'
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
#Call the DataSift API to create the Managed Source
|
92
|
-
def create()
|
93
|
-
raise InvalidDataError, 'This Managed Source has already been created' unless not @managed_source_id
|
94
|
-
|
95
|
-
begin
|
96
|
-
res = @user.callAPI(
|
97
|
-
'source/create', {
|
98
|
-
'source_type' => @source_type,
|
99
|
-
'name' => @name,
|
100
|
-
'parameters' => @parameters.to_json,
|
101
|
-
'resources' => @resources.to_json,
|
102
|
-
'auth' => @auth.to_json
|
103
|
-
})
|
104
|
-
raise InvalidDataError, 'Prepared successfully but no managed_source_id ID in the response' unless res.has_key?('id')
|
105
|
-
@managed_source_id = res['id']
|
106
|
-
|
107
|
-
rescue APIError => err
|
108
|
-
case err.http_code
|
109
|
-
when 400
|
110
|
-
raise InvalidDataError, err
|
111
|
-
else
|
112
|
-
raise APIError.new(err.http_code), 'Unexpected APIError code: ' + err.http_code.to_s + ' [' + err.message + ']'
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
# Reload the data so we get the created_at date, initial status and the rest.
|
117
|
-
reloadData()
|
118
|
-
end
|
119
|
-
|
120
|
-
#Reload the data for this object from the API.
|
121
|
-
def reloadData()
|
122
|
-
#Can't do this without a playback ID
|
123
|
-
raise InvalidDataError, 'Cannot reload the data with a Managed Source with no Managed Source ID' unless @managed_source_id
|
124
|
-
|
125
|
-
begin
|
126
|
-
initFromArray(@user.callAPI('source/get', { 'id' => @managed_source_id }))
|
127
|
-
rescue APIError => err
|
128
|
-
case err.http_code
|
129
|
-
when 400
|
130
|
-
raise InvalidDataError, err
|
131
|
-
else
|
132
|
-
raise APIError.new(err.http_code), 'Unexpected APIError code: ' + err.http_code.to_s + ' [' + err.message + ']'
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
#Initialise this object from the data in a Hash.
|
138
|
-
#=== Parameters
|
139
|
-
#* +data+ - The Hash containing the data.
|
140
|
-
def initFromArray(data)
|
141
|
-
raise APIError, 'No managed source ID in the response' unless data.has_key?('id')
|
142
|
-
raise APIError, 'Incorrect managed source ID in the response' unless not @managed_source_id or data['id'] == @managed_source_id
|
143
|
-
@managed_source_id = data['id']
|
144
|
-
|
145
|
-
raise APIError, 'No name in the response' unless data.has_key?('name')
|
146
|
-
@name = data['name']
|
147
|
-
|
148
|
-
raise APIError, 'No auth in the response' unless data.has_key?('auth')
|
149
|
-
@auth = data['auth']
|
150
|
-
|
151
|
-
raise APIError, 'No created at timstamp in the response' unless data.has_key?('created_at')
|
152
|
-
@created_at = DateTime.strptime(String(data['created_at']), '%s')
|
153
|
-
|
154
|
-
raise APIError, 'No status in the response' unless data.has_key?('status')
|
155
|
-
@status = data['status']
|
156
|
-
|
157
|
-
raise APIError, 'No source_type in the response' unless data.has_key?('source_type')
|
158
|
-
@source_type = data['source_type']
|
159
|
-
|
160
|
-
raise APIError, 'No parameters in the response' unless data.has_key?('parameters')
|
161
|
-
@parameters = data['parameters']
|
162
|
-
|
163
|
-
raise APIError, 'No resources in the response' unless data.has_key?('resources')
|
164
|
-
@resources = data['resources']
|
165
|
-
|
166
|
-
@raw_attributes = data
|
167
|
-
|
168
|
-
return true
|
169
|
-
end
|
170
|
-
|
171
|
-
#Start this Managed Source query.
|
172
|
-
def start()
|
173
|
-
raise InvalidDataError, 'Cannot start a Managed souce query that hasn\'t been created' unless @managed_source_id
|
174
|
-
|
175
|
-
begin
|
176
|
-
res = @user.callAPI('source/start', { 'id' => @managed_source_id })
|
177
|
-
rescue APIError => err
|
178
|
-
case err.http_code
|
179
|
-
when 400
|
180
|
-
# Missing or invalid parameters
|
181
|
-
raise InvalidDataError, err
|
182
|
-
when 404
|
183
|
-
# Managed Source not found
|
184
|
-
raise InvalidDataError, err
|
185
|
-
else
|
186
|
-
raise APIError.new(err.http_code), 'Unexpected APIError code: ' + err.http_code.to_s + ' [' + err.message + ']'
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
#Stop this Managed Source
|
192
|
-
def stop()
|
193
|
-
raise InvalidDataError, 'Cannot stop a Managed Source query that hasn\'t been prepared' unless @managed_source_id
|
194
|
-
|
195
|
-
begin
|
196
|
-
res = @user.callAPI('source/stop', { 'id' => @managed_source_id })
|
197
|
-
rescue APIError => err
|
198
|
-
case err.http_code
|
199
|
-
when 400
|
200
|
-
# Missing or invalid parameters
|
201
|
-
raise InvalidDataError, err
|
202
|
-
when 404
|
203
|
-
# Managed Source not found
|
204
|
-
raise InvalidDataError, err
|
205
|
-
else
|
206
|
-
raise APIError.new(err.http_code), 'Unexpected APIError code: ' + err.http_code.to_s + ' [' + err.message + ']'
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
#Delete this Managed Source
|
212
|
-
def delete()
|
213
|
-
raise InvalidDataError, 'Cannot delete a Managed source query that hasn\'t been prepared' unless @managed_source_id
|
214
|
-
|
215
|
-
begin
|
216
|
-
@user.callAPI('source/delete', { 'id' => @managed_source_id })
|
217
|
-
rescue APIError => err
|
218
|
-
case err.http_code
|
219
|
-
when 400
|
220
|
-
# Missing or invalid parameters
|
221
|
-
raise InvalidDataError, err
|
222
|
-
when 404
|
223
|
-
# Managed Source not found
|
224
|
-
raise InvalidDataError, err
|
225
|
-
else
|
226
|
-
raise APIError.new(err.http_code), 'Unexpected APIError code: ' + err.http_code.to_s + ' [' + err.message + ']'
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
#Page through recent Managed Sources log entries
|
232
|
-
#=== Parameters
|
233
|
-
#* +page+ - The page number to get.
|
234
|
-
#* +per_page+ - The number of items per page.
|
235
|
-
#=== Returns
|
236
|
-
#A Hash containing...
|
237
|
-
#* +count+ - The total number of matching log entries.
|
238
|
-
#* +log_entries+ - An array of Hashes where each Hash is a log entry.
|
239
|
-
def getLogs(page = 1, per_page = 20)
|
240
|
-
begin
|
241
|
-
raise InvalidDataError, 'The specified page number is invalid' unless page >= 1
|
242
|
-
raise InvalidDataError, 'The specified per_page value is invalid' unless per_page >= 1
|
243
|
-
|
244
|
-
params = {
|
245
|
-
'id' => @managed_source_id,
|
246
|
-
'page' => page,
|
247
|
-
'per_page' => per_page
|
248
|
-
}
|
249
|
-
|
250
|
-
return @user.callAPI('source/log', params)
|
251
|
-
rescue APIError => err
|
252
|
-
case err.http_code
|
253
|
-
when 400
|
254
|
-
# Missing or invalid parameters
|
255
|
-
raise InvalidDataError, err
|
256
|
-
else
|
257
|
-
raise APIError.new(err.http_code), 'Unexpected APIError code: ' + err.http_code.to_s + ' [' + err.message + ']'
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
end
|
263
|
-
end
|