datasift 3.1.5 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -2
- data/.yardopts +4 -0
- data/CHANGELOG.md +23 -0
- data/Gemfile +13 -0
- data/README.md +17 -16
- data/VERSION +1 -1
- data/datasift.gemspec +8 -14
- data/examples/account_identity_eg.rb +48 -0
- data/examples/account_identity_limit_eg.rb +68 -0
- data/examples/account_identity_token_eg.rb +70 -0
- data/examples/auth.rb +4 -4
- data/examples/core_api_eg.rb +1 -2
- data/examples/historics_eg.rb +7 -1
- data/examples/pylon_eg.rb +116 -0
- data/lib/account.rb +6 -0
- data/lib/account_identity.rb +73 -0
- data/lib/account_identity_limit.rb +85 -0
- data/lib/account_identity_token.rb +86 -0
- data/lib/api/api_resource.rb +14 -5
- data/lib/cli.rb +306 -132
- data/lib/datasift.rb +82 -47
- data/lib/errors.rb +21 -5
- data/lib/historics.rb +71 -40
- data/lib/historics_preview.rb +25 -8
- data/lib/managed_source.rb +69 -25
- data/lib/managed_source_auth.rb +21 -6
- data/lib/managed_source_resource.rb +21 -6
- data/lib/push.rb +132 -65
- data/lib/pylon.rb +122 -0
- data/test/datasift/core_api_test.rb +116 -90
- data/test/datasift/historics_preview_api_test.rb +27 -58
- data/test/datasift/push_api_test.rb +156 -141
- data/test/fixtures/cassettes/core/after_historic_dpu.json +1 -0
- data/test/fixtures/cassettes/core/balance_get.json +1 -0
- data/test/fixtures/cassettes/core/before_dpu.json +1 -0
- data/test/fixtures/cassettes/core/before_historic_dpu.json +1 -0
- data/test/fixtures/cassettes/core/compile_success.json +1 -0
- data/test/fixtures/cassettes/core/dpu_get_cost.json +1 -0
- data/test/fixtures/cassettes/core/dpu_throw_badrequest.json +1 -0
- data/test/fixtures/cassettes/core/historic_dpu.json +1 -0
- data/test/fixtures/cassettes/core/usage_success.json +1 -0
- data/test/fixtures/cassettes/core/validate_invalid_hash.json +1 -0
- data/test/fixtures/cassettes/core/validate_success_bool.json +1 -0
- data/test/fixtures/cassettes/core/validate_success_hash.json +1 -0
- data/test/fixtures/cassettes/preview/before_preview_create.json +1 -0
- data/test/fixtures/cassettes/preview/before_preview_get.json +1 -0
- data/test/fixtures/cassettes/preview/preview_create_success.json +1 -0
- data/test/fixtures/cassettes/preview/preview_get_success.json +1 -0
- data/test/fixtures/cassettes/push/after_push_create.json +1 -0
- data/test/fixtures/cassettes/push/after_push_get.json +1 -0
- data/test/fixtures/cassettes/push/after_push_log.json +1 -0
- data/test/fixtures/cassettes/push/after_push_pause.json +1 -0
- data/test/fixtures/cassettes/push/after_push_resume.json +1 -0
- data/test/fixtures/cassettes/push/after_push_stop.json +1 -0
- data/test/fixtures/cassettes/push/after_push_update.json +1 -0
- data/test/fixtures/cassettes/push/before_push_create.json +1 -0
- data/test/fixtures/cassettes/push/before_push_delete.json +1 -0
- data/test/fixtures/cassettes/push/before_push_get.json +1 -0
- data/test/fixtures/cassettes/push/before_push_log.json +1 -0
- data/test/fixtures/cassettes/push/before_push_pause.json +1 -0
- data/test/fixtures/cassettes/push/before_push_resume.json +1 -0
- data/test/fixtures/cassettes/push/before_push_stop.json +1 -0
- data/test/fixtures/cassettes/push/before_push_update.json +1 -0
- data/test/fixtures/cassettes/push/push_create.json +1 -0
- data/test/fixtures/cassettes/push/push_delete.json +1 -0
- data/test/fixtures/cassettes/push/push_get_by_id.json +1 -0
- data/test/fixtures/cassettes/push/push_log_with_id.json +1 -0
- data/test/fixtures/cassettes/push/push_pause.json +1 -0
- data/test/fixtures/cassettes/push/push_resume.json +1 -0
- data/test/fixtures/cassettes/push/push_stop.json +1 -0
- data/test/fixtures/cassettes/push/push_update.json +1 -0
- data/test/fixtures/cassettes/push/push_validate.json +1 -0
- data/test/test_helper.rb +31 -1
- metadata +64 -104
- data/examples/dynamic_list_eg.rb +0 -74
- data/examples/dynamic_list_replace_eg.rb +0 -45
- data/lib/dynamic_list.rb +0 -66
- data/lib/dynamic_list_replace.rb +0 -45
- data/test/fixtures/balance.json +0 -1
- data/test/fixtures/compile_csdl_invalid.json +0 -1
- data/test/fixtures/compile_csdl_valid.json +0 -1
- data/test/fixtures/dpu_valid.json +0 -1
- data/test/fixtures/preview_create_valid.json +0 -1
- data/test/fixtures/preview_get_running.json +0 -1
- data/test/fixtures/preview_get_succeeded.json +0 -1
- data/test/fixtures/push_create_valid.json +0 -1
- data/test/fixtures/push_get_list_by_hash_valid.json +0 -1
- data/test/fixtures/push_get_list_by_historics_id_valid.json +0 -1
- data/test/fixtures/push_get_list_valid.json +0 -1
- data/test/fixtures/push_get_valid.json +0 -1
- data/test/fixtures/push_log_valid.json +0 -1
- data/test/fixtures/push_pause_valid.json +0 -1
- data/test/fixtures/push_stop_valid.json +0 -1
- data/test/fixtures/push_validate_valid.json +0 -1
- data/test/fixtures/usage_current.json +0 -1
- data/test/fixtures/validate_csdl_invalid.json +0 -1
- data/test/fixtures/validate_csdl_valid.json +0 -1
data/lib/managed_source.rb
CHANGED
@@ -1,28 +1,48 @@
|
|
1
1
|
module DataSift
|
2
|
+
# Methods for using {http://dev.datasift.com/docs/sources/managed-sources
|
3
|
+
# DataSift Managed Sources}
|
2
4
|
class ManagedSource < DataSift::ApiResource
|
3
|
-
|
4
|
-
##
|
5
5
|
# Creates a new managed source
|
6
|
-
|
6
|
+
#
|
7
|
+
# @param source_type [String] Type of Managed Source you are creating. e.g.
|
8
|
+
# facebook_page, instagram, etc
|
9
|
+
# @param name [String] Name of this Managed Source
|
10
|
+
# @param parameters [Hash] Source-specific configuration parameters
|
11
|
+
# @param resources [Array] Array of source-specific resources
|
12
|
+
# @param auth [Array] Array of source-specific auth credentials
|
7
13
|
def create(source_type, name, parameters = {}, resources = [], auth = [], options = {})
|
8
|
-
|
14
|
+
fail BadParametersError, 'source_type and name are required' if source_type.nil? || name.nil?
|
9
15
|
params = {
|
10
|
-
|
11
|
-
|
16
|
+
:source_type => source_type,
|
17
|
+
:name => name
|
12
18
|
}
|
13
19
|
params.merge!(options) unless options.empty?
|
14
|
-
params.merge!(
|
15
|
-
|
16
|
-
|
20
|
+
params.merge!(
|
21
|
+
{ :auth => auth.is_a?(String) ? auth : MultiJson.dump(auth) }
|
22
|
+
) unless auth.empty?
|
23
|
+
params.merge!(
|
24
|
+
{ :parameters => parameters.is_a?(String) ? parameters : MultiJson.dump(parameters) }
|
25
|
+
) unless parameters.empty?
|
26
|
+
params.merge!(
|
27
|
+
{ :resources => resources.is_a?(String) ? resources : MultiJson.dump(resources) }
|
28
|
+
) if resources.length > 0
|
17
29
|
DataSift.request(:POST, 'source/create', @config, params)
|
18
30
|
end
|
19
31
|
|
32
|
+
# Update a Managed Source
|
33
|
+
#
|
34
|
+
# @param id [String] ID of the Managed Source you are updating
|
35
|
+
# @param source_type [String] Type of Managed Source you are updating
|
36
|
+
# @param name [String] Name (or new name) of the Managed Source
|
37
|
+
# @param parameters [Hash] Source-specific configuration parameters
|
38
|
+
# @param resources [Array] Array of source-specific resources
|
39
|
+
# @param auth [Array] Array of source-specific auth credentials
|
20
40
|
def update(id, source_type, name, parameters = {}, resources = [], auth = [], options = {})
|
21
|
-
|
41
|
+
fail BadParametersError, 'ID, source_type and name are required' if id.nil? || source_type.nil? || name.nil?
|
22
42
|
params = {
|
23
|
-
|
24
|
-
|
25
|
-
|
43
|
+
:id => id,
|
44
|
+
:source_type => source_type,
|
45
|
+
:name => name
|
26
46
|
}
|
27
47
|
params.merge!(options) unless options.empty?
|
28
48
|
params.merge!({:auth => MultiJson.dump(auth)}) if !auth.empty?
|
@@ -32,33 +52,57 @@ module DataSift
|
|
32
52
|
DataSift.request(:POST, 'source/update', @config, params)
|
33
53
|
end
|
34
54
|
|
55
|
+
# Delete a Managed Source
|
56
|
+
#
|
57
|
+
# @param id [String] ID of the Managed Source you are deleting
|
35
58
|
def delete(id)
|
36
|
-
|
37
|
-
DataSift.request(:DELETE, 'source/delete', @config, {:id => id})
|
59
|
+
fail BadParametersError, 'ID is required' if id.nil?
|
60
|
+
DataSift.request(:DELETE, 'source/delete', @config, { :id => id })
|
38
61
|
end
|
39
62
|
|
63
|
+
# Stop a Managed Source
|
64
|
+
#
|
65
|
+
# @param id [String] ID of the Managed Source you are stopping
|
40
66
|
def stop(id)
|
41
|
-
|
42
|
-
DataSift.request(:POST, 'source/stop', @config, {:id => id})
|
67
|
+
fail BadParametersError, 'ID is required' if id.nil?
|
68
|
+
DataSift.request(:POST, 'source/stop', @config, { :id => id })
|
43
69
|
end
|
44
70
|
|
71
|
+
# Start a Managed Source
|
72
|
+
#
|
73
|
+
# @param id [String] ID of the Managed Source you are starting
|
45
74
|
def start(id)
|
46
|
-
|
47
|
-
DataSift.request(:POST, 'source/start', @config, {:id => id})
|
75
|
+
fail BadParametersError, 'ID is required' if id.nil?
|
76
|
+
DataSift.request(:POST, 'source/start', @config, { :id => id })
|
48
77
|
end
|
49
78
|
|
79
|
+
# Retrieve details of a Managed Source
|
80
|
+
#
|
81
|
+
# @param id [String] ID of the Managed Source you are getting. Omitting the
|
82
|
+
# ID will return a list of Managed Sources
|
83
|
+
# @param source_type [String] Limits the list of Managed Sources returned to
|
84
|
+
# only sources of a specific source type if specified
|
85
|
+
# @param page [Integer] Number of Managed Sources to return on one page of
|
86
|
+
# results
|
87
|
+
# @param per_page [Integer] Number of Managed Sources to return per page
|
50
88
|
def get(id = nil, source_type = nil, page = 1, per_page = 20)
|
51
|
-
params = {:page => page, :per_page => per_page}
|
52
|
-
params.merge!({:id => id}) if id
|
53
|
-
params.merge!({:source_type => source_type}) if source_type
|
89
|
+
params = { :page => page, :per_page => per_page }
|
90
|
+
params.merge!({ :id => id }) if !id.nil?
|
91
|
+
params.merge!({ :source_type => source_type }) if !source_type.nil?
|
54
92
|
|
55
93
|
DataSift.request(:GET, 'source/get', @config, params)
|
56
94
|
end
|
57
95
|
|
96
|
+
# Retrieve log details of Managed Sources
|
97
|
+
#
|
98
|
+
# @param id [String] ID of the Managed Source for which you are collecting
|
99
|
+
# logs
|
100
|
+
# @param page [Integer] Number of Managed Source logs to return on one page
|
101
|
+
# of results
|
102
|
+
# @param per_page [Integer] Number of Managed Source logs to return per page
|
58
103
|
def log(id, page = 1, per_page = 20)
|
59
|
-
|
60
|
-
DataSift.request(:POST, 'source/log', @config, {:id => id, :page => page, :per_page => per_page})
|
104
|
+
fail BadParametersError, 'ID is required' if id.nil?
|
105
|
+
DataSift.request(:POST, 'source/log', @config, { :id => id, :page => page, :per_page => per_page })
|
61
106
|
end
|
62
|
-
|
63
107
|
end
|
64
108
|
end
|
data/lib/managed_source_auth.rb
CHANGED
@@ -1,20 +1,35 @@
|
|
1
1
|
module DataSift
|
2
|
+
# Methods for using Auth specific Managed Sources API endpoints
|
2
3
|
class ManagedSourceAuth < DataSift::ApiResource
|
3
|
-
|
4
|
+
# Add auth tokens to a Managed Source
|
5
|
+
#
|
6
|
+
# @param id [String] ID of the Managed Source you are adding Auth tokens to
|
7
|
+
# @param auth [Array] Array of auth tokens you are adding to your source
|
8
|
+
# @param validate [Boolean] Whether you want to validate your new tokens
|
9
|
+
# against the third party API (i.e. the Facebook or Instagram API)
|
4
10
|
def add(id, auth, validate = 'true')
|
5
11
|
params = {
|
6
|
-
id:
|
12
|
+
id: id,
|
13
|
+
auth: auth,
|
7
14
|
validate: validate
|
8
15
|
}
|
9
|
-
params
|
16
|
+
requires params
|
10
17
|
DataSift.request(:PUT, 'source/auth/add', @config, params)
|
11
18
|
end
|
12
19
|
|
20
|
+
# Remove auth tokens from a Managed Source
|
21
|
+
#
|
22
|
+
# @param id [String] ID of the Managed Source you are removing auth tokens
|
23
|
+
# from
|
24
|
+
# @param auth_ids [Array] Array of auth_id strings you need to remove from
|
25
|
+
# your source
|
13
26
|
def remove(id, auth_ids)
|
14
|
-
params = {
|
15
|
-
|
27
|
+
params = {
|
28
|
+
id: id,
|
29
|
+
auth: auth_ids
|
30
|
+
}
|
31
|
+
requires params
|
16
32
|
DataSift.request(:PUT, 'source/auth/remove', @config, params)
|
17
33
|
end
|
18
|
-
|
19
34
|
end
|
20
35
|
end
|
@@ -1,20 +1,35 @@
|
|
1
1
|
module DataSift
|
2
|
+
# Methods for using Auth specific Managed Sources API endpoints
|
2
3
|
class ManagedSourceResource < DataSift::ApiResource
|
3
|
-
|
4
|
+
# Add resources to a Managed Source
|
5
|
+
#
|
6
|
+
# @param id [String] ID of the Managed Source you are adding resources to
|
7
|
+
# @param resources [Array] Array of resources you are adding to your source
|
8
|
+
# @param validate [Boolean] Whether you want to validate your new resources
|
9
|
+
# against the third party API (i.e. the Facebook or Instagram API)
|
4
10
|
def add(id, resources, validate = 'true')
|
5
11
|
params = {
|
6
|
-
id:
|
12
|
+
id: id,
|
13
|
+
resources: resources,
|
7
14
|
validate: validate
|
8
15
|
}
|
9
|
-
params
|
16
|
+
requires params
|
10
17
|
DataSift.request(:PUT, 'source/resource/add', @config, params)
|
11
18
|
end
|
12
19
|
|
20
|
+
# Remove resources from a Managed Source
|
21
|
+
#
|
22
|
+
# @param id [String] ID of the Managed Source you are removing resources
|
23
|
+
# from
|
24
|
+
# @param resource_ids [Array] Array of resource_id strings you need to
|
25
|
+
# remove from your source
|
13
26
|
def remove(id, resource_ids)
|
14
|
-
params = {
|
15
|
-
|
27
|
+
params = {
|
28
|
+
id: id,
|
29
|
+
resource_ids: resource_ids
|
30
|
+
}
|
31
|
+
requires params
|
16
32
|
DataSift.request(:PUT, 'source/resource/remove', @config, params)
|
17
33
|
end
|
18
|
-
|
19
34
|
end
|
20
35
|
end
|
data/lib/push.rb
CHANGED
@@ -1,148 +1,215 @@
|
|
1
1
|
module DataSift
|
2
2
|
##
|
3
|
-
# Push is a simple and robust mechanism for periodically delivering your data
|
4
|
-
# Several widely adopted storage locations
|
5
|
-
#
|
3
|
+
# Push is a simple and robust mechanism for periodically delivering your data
|
4
|
+
# directly to a given destination. Several widely adopted storage locations
|
5
|
+
# are available including Amazon S3, (S)FTP, HTTP, DynamoDB, CouchDB,
|
6
|
+
# MongoDB, Splunk, ElasticSearch and more! See
|
7
|
+
# http://dev.datasift.com/docs/push/connectors
|
6
8
|
class Push < DataSift::ApiResource
|
7
|
-
|
8
9
|
##
|
9
|
-
# Check that a subscription is
|
10
|
+
# Check that a Push subscription definition is valid
|
11
|
+
#
|
12
|
+
# @param params [Hash] Hash of Push subscription parameters
|
13
|
+
# @param bool_response [Boolean] True if you want a boolean response. False
|
14
|
+
# if you want the full response object
|
10
15
|
def valid?(params, bool_response = true)
|
11
16
|
requires params
|
12
17
|
res = DataSift.request(:POST, 'push/validate', @config, params)
|
13
18
|
bool_response ? res[:http][:status] == 200 : res
|
14
19
|
end
|
15
20
|
|
16
|
-
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# http://dev.datasift.com/docs/
|
22
|
-
#
|
21
|
+
# Create a new subscription to a live stream or historics query. Possible
|
22
|
+
# params are hash, historics_id, name, output_type, initial_status, start,
|
23
|
+
# end and output_params.* where output_params.* depends on the output_type
|
24
|
+
# for specific options see the documentation at
|
25
|
+
# http://dev.datasift.com/docs/rest-api/pushcreate For a list of available
|
26
|
+
# connectors see http://dev.datasift.com/docs/push/connectors
|
27
|
+
#
|
28
|
+
# @param params [Hash] Hash of Push subscription parameters
|
23
29
|
def create(params)
|
24
30
|
DataSift.request(:POST, 'push/create', @config, params)
|
25
31
|
end
|
26
32
|
|
27
|
-
##
|
28
33
|
# Update the name or output parameters for an existing subscription
|
29
|
-
|
34
|
+
#
|
35
|
+
# @param params [Hash] Hash of Push subscription parameters
|
36
|
+
def update(params)
|
30
37
|
DataSift.request(:POST, 'push/update', @config, params)
|
31
38
|
end
|
32
39
|
|
33
|
-
|
34
|
-
#
|
40
|
+
# Pause a subscription and buffer the data for up to an hour
|
41
|
+
#
|
42
|
+
# @param id [String] ID of the Push subscription to pause
|
35
43
|
def pause(id)
|
36
|
-
params = {:id => id}
|
44
|
+
params = { :id => id }
|
37
45
|
requires params
|
38
46
|
DataSift.request(:PUT, 'push/pause', @config, params)
|
39
47
|
end
|
40
48
|
|
41
|
-
|
42
|
-
#
|
49
|
+
# Resume a Push subscription that was previously paused
|
50
|
+
#
|
51
|
+
# @param id [String] ID of the Push subscription to resume
|
43
52
|
def resume(id)
|
44
|
-
params = {:id => id}
|
53
|
+
params = { :id => id }
|
45
54
|
requires params
|
46
55
|
DataSift.request(:PUT, 'push/resume', @config, params)
|
47
56
|
end
|
48
57
|
|
49
|
-
|
50
|
-
#
|
58
|
+
# Stop a Push subscription; you will not be able to resume this
|
59
|
+
#
|
60
|
+
# @param id [String] ID of the Push subscription to stop
|
51
61
|
def stop(id)
|
52
|
-
params = {:id => id}
|
62
|
+
params = { :id => id }
|
53
63
|
requires params
|
54
64
|
DataSift.request(:PUT, 'push/stop', @config, params)
|
55
65
|
end
|
56
66
|
|
57
|
-
##
|
58
67
|
# Deletes an existing push subscription
|
68
|
+
#
|
69
|
+
# @param id [String] ID of the Push subscription to delete
|
59
70
|
def delete(id)
|
60
71
|
params = {:id => id}
|
61
72
|
requires params
|
62
73
|
DataSift.request(:DELETE, 'push/delete', @config, params)
|
63
74
|
end
|
64
75
|
|
65
|
-
##
|
66
76
|
# Retrieve log messages for a specific subscription
|
77
|
+
#
|
78
|
+
# @param id [String] ID of the Push subscription to retrieve logs for
|
79
|
+
# @param page [Integer] Which page of logs to retreive
|
80
|
+
# @param per_page [Integer] How many logs to return per page
|
81
|
+
# @param order_by [String, Symbol] Which field to sort results by
|
82
|
+
# @param order_dir [String, Symbol] Order results in ascending or descending
|
67
83
|
def log_for(id, page = 1, per_page = 20, order_by = :request_time, order_dir = :desc)
|
68
84
|
params = {
|
69
|
-
|
70
|
-
:page => page,
|
71
|
-
:per_page => per_page,
|
72
|
-
:order_by => order_by,
|
73
|
-
:order_dir => order_dir
|
85
|
+
:id => id
|
74
86
|
}
|
87
|
+
requires params
|
88
|
+
params.merge!(
|
89
|
+
:page => page,
|
90
|
+
:per_page => per_page,
|
91
|
+
:order_by => order_by,
|
92
|
+
:order_dir => order_dir
|
93
|
+
)
|
75
94
|
DataSift.request(:GET, 'push/log', @config, params)
|
76
95
|
end
|
77
96
|
|
78
|
-
##
|
79
97
|
# Retrieve log messages for all subscriptions
|
98
|
+
#
|
99
|
+
# @param page [Integer] Which page of logs to retreive
|
100
|
+
# @param per_page [Integer] How many logs to return per page
|
101
|
+
# @param order_by [String, Symbol] Which field to sort results by
|
102
|
+
# @param order_dir [String, Symbol] Order results in ascending or descending
|
80
103
|
def log(page = 1, per_page = 20, order_by = :request_time, order_dir = :desc)
|
81
104
|
params = {
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
105
|
+
:page => page,
|
106
|
+
:per_page => per_page,
|
107
|
+
:order_by => order_by,
|
108
|
+
:order_dir => order_dir
|
86
109
|
}
|
87
110
|
DataSift.request(:GET, 'push/log', @config, params)
|
88
111
|
end
|
89
112
|
|
90
|
-
##
|
91
113
|
# Get details of the subscription with the given ID
|
114
|
+
#
|
115
|
+
# @param id [String] ID of the subscription to retrieve
|
92
116
|
def get_by_subscription(id)
|
93
117
|
params = { :id => id }
|
94
118
|
DataSift.request(:GET, 'push/get', @config, params)
|
95
119
|
end
|
96
120
|
|
97
|
-
|
98
|
-
#
|
99
|
-
|
121
|
+
# Get details of the subscription with the given filter hash
|
122
|
+
#
|
123
|
+
# @param hash [String] CSDL filter hash
|
124
|
+
# @param page [Integer] Which page of logs to retreive
|
125
|
+
# @param per_page [Integer] How many logs to return per page
|
126
|
+
# @param order_by [String, Symbol] Which field to sort results by
|
127
|
+
# @param order_dir [String, Symbol] Order results in ascending or descending
|
128
|
+
# @param include_finished [Integer] Include Push subscriptions in a
|
129
|
+
# 'finished' state in your results
|
130
|
+
# @param all [Boolean] Also include Push subscriptions created via the web
|
131
|
+
# UI in your results
|
132
|
+
def get_by_hash(hash, page = 1, per_page = 20, order_by = :created_at, order_dir = :desc, include_finished = 0, all = false)
|
100
133
|
params = {
|
101
|
-
|
102
|
-
:page => page,
|
103
|
-
:per_page => per_page,
|
104
|
-
:order_by => order_by,
|
105
|
-
:order_dir => order_dir
|
134
|
+
:hash => hash
|
106
135
|
}
|
136
|
+
requires params
|
137
|
+
params.merge!(
|
138
|
+
:page => page,
|
139
|
+
:per_page => per_page,
|
140
|
+
:order_by => order_by,
|
141
|
+
:order_dir => order_dir,
|
142
|
+
:include_finished => include_finished,
|
143
|
+
:all => all
|
144
|
+
)
|
107
145
|
DataSift.request(:GET, 'push/get', @config, params)
|
108
146
|
end
|
109
147
|
|
110
|
-
##
|
111
148
|
# Get details of the subscription with the given Historics ID
|
112
|
-
|
149
|
+
#
|
150
|
+
# @param historics_id [String] ID of the Historics query for which you are
|
151
|
+
# searching for the related Push subscription
|
152
|
+
# @param page [Integer] Which page of logs to retreive
|
153
|
+
# @param per_page [Integer] How many logs to return per page
|
154
|
+
# @param order_by [String, Symbol] Which field to sort results by
|
155
|
+
# @param order_dir [String, Symbol] Order results in ascending or descending
|
156
|
+
# @param include_finished [Integer] Include Push subscriptions in a
|
157
|
+
# 'finished' state in your results
|
158
|
+
# @param all [Boolean] Also include Push subscriptions created via the web
|
159
|
+
# UI in your results
|
160
|
+
def get_by_historics_id(historics_id, page = 1, per_page = 20, order_by = :created_at, order_dir = :desc, include_finished = 0, all = false)
|
113
161
|
params = {
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
162
|
+
:historics_id => historics_id,
|
163
|
+
:page => page,
|
164
|
+
:per_page => per_page,
|
165
|
+
:order_by => order_by,
|
166
|
+
:order_dir => order_dir,
|
167
|
+
:include_finished => include_finished,
|
168
|
+
:all => all
|
119
169
|
}
|
120
170
|
DataSift.request(:GET, 'push/get', @config, params)
|
121
171
|
end
|
122
172
|
|
123
|
-
##
|
124
173
|
# Get details of all subscriptions within the given page constraints
|
125
|
-
|
174
|
+
#
|
175
|
+
# @param page [Integer] Which page of logs to retreive
|
176
|
+
# @param per_page [Integer] How many logs to return per page
|
177
|
+
# @param order_by [String, Symbol] Which field to sort results by
|
178
|
+
# @param order_dir [String, Symbol] Order results in ascending or descending
|
179
|
+
# @param include_finished [Integer] Include Push subscriptions in a
|
180
|
+
# 'finished' state in your results
|
181
|
+
# @param all [Boolean] Also include Push subscriptions created via the web
|
182
|
+
# UI in your results
|
183
|
+
def get(page = 1, per_page = 20, order_by = :created_at, order_dir = :desc, include_finished = 0, all = false)
|
126
184
|
params = {
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
185
|
+
:page => page,
|
186
|
+
:per_page => per_page,
|
187
|
+
:order_by => order_by,
|
188
|
+
:order_dir => order_dir,
|
189
|
+
:include_finished => include_finished,
|
190
|
+
:all => all
|
131
191
|
}
|
132
192
|
DataSift.request(:GET, 'push/get', @config, params)
|
133
193
|
end
|
134
194
|
|
135
|
-
##
|
136
195
|
# Pull data from a 'pull' type Push Subscription
|
137
|
-
|
196
|
+
#
|
197
|
+
# @param id [String] ID of the Push subscription to pull data from
|
198
|
+
# @param size [Integer] Max size (bytes) of the data that should be returned
|
199
|
+
# @param cursor [String] Point to a specific point in your Push buffer using
|
200
|
+
# a cursor
|
201
|
+
# @param callback [Method] Pass a callback to process each interaction
|
202
|
+
# returned from a successful pull request
|
203
|
+
def pull(id, size = 52_428_800, cursor = '', callback = nil)
|
138
204
|
params = {
|
139
|
-
|
140
|
-
:size => size,
|
141
|
-
:cursor => cursor
|
205
|
+
:id => id
|
142
206
|
}
|
143
|
-
|
144
|
-
|
145
|
-
|
207
|
+
requires params
|
208
|
+
params.merge!(
|
209
|
+
:size => size,
|
210
|
+
:cursor => cursor
|
211
|
+
)
|
212
|
+
params.merge!({:on_interaction => callback}) unless callback.nil?
|
146
213
|
DataSift.request(:GET, 'pull', @config, params, {}, 30, 30, true)
|
147
214
|
end
|
148
215
|
end
|