datahen 0.14.3 → 0.14.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b00adfb4f357beeae276a130cc5e0ee1d34ddd8bdef4a0374f4b55f89f894460
4
- data.tar.gz: 6363d591d93d99addcaaea6d964b2fb07e4d8222f873c3a8f6496f48c97b1483
3
+ metadata.gz: 678f01c798cd52a29da298f48e65b1139f13c80a1214d2c1328f4a4c49abbc63
4
+ data.tar.gz: 0f787dc429274bb1cd0521237883615e7f8c83316d36fcb319e542cd0fe22d7c
5
5
  SHA512:
6
- metadata.gz: 75e9f1b1e5ba61563c3ff9d12071cb76d77382353003776d88817940623e37aeb300df2114260f86a5a18a59e1dc9f74a33c00029e183c0681c616dce109d6c6
7
- data.tar.gz: 8e2a07b11d20fe88c93aa0af0abf10ceb6593d5d2db63d9b5c3744c6f8b59754274a3949b6331d7d71a3018f7cf65e1a7d31e2ab6f4dbbcde494b33357dab40a
6
+ metadata.gz: dcaf8fbd6dcfb04f74b8b65ffdcbc127c3e8f179bf0b6da3f2e55acbd2f8d0e425f09a79287bc3ff1791b3fd20e1503c31af3a3128af6eaaedf43e149f1bc995
7
+ data.tar.gz: 577dda3f28fe7303c08aa290f2fa82150e6f1e679184fac739f839f9de6200be11df7111eddd79f7db7fcfa3aa03f925933db85bed382a1c5c0211534b384e67
@@ -16,6 +16,7 @@ require 'datahen/cli/parser'
16
16
  require 'datahen/cli/seeder'
17
17
  require 'datahen/cli/finisher'
18
18
  require 'datahen/cli/env_var'
19
+ require 'datahen/cli/account'
19
20
 
20
21
 
21
22
 
@@ -41,5 +42,8 @@ module Datahen
41
42
 
42
43
  desc "var SUBCOMMAND ...ARGS", "for environment variable related activities"
43
44
  subcommand "var", EnvVar
45
+
46
+ desc "account SUBCOMMAND ...ARGS", "for account related activities"
47
+ subcommand "account", Account
44
48
  end
45
49
  end
@@ -0,0 +1,17 @@
1
+ module Datahen
2
+ class CLI < Thor
3
+ class Account < Thor
4
+
5
+ desc "profile", "displays the account applied profile"
6
+ long_desc <<-LONGDESC
7
+ Displays the account applied profile
8
+ LONGDESC
9
+ def profile()
10
+ client = Client::Account.new(options)
11
+ puts "#{client.profile()}"
12
+ end
13
+
14
+ end
15
+ end
16
+
17
+ end
@@ -2,7 +2,7 @@ module Datahen
2
2
  class CLI < Thor
3
3
  class EnvVar < Thor
4
4
  desc "list", "List environment variables on the account"
5
-
5
+
6
6
  long_desc <<-LONGDESC
7
7
  List all environment variables on the account.
8
8
  LONGDESC
@@ -19,7 +19,7 @@ module Datahen
19
19
  <name>: Var name can only consist of alphabets, numbers, underscores. Name must be unique to your account, otherwise it will be overwritten.\x5
20
20
  <value>: Value of variable.\x5
21
21
  LONGDESC
22
- option :secret, type: :boolean, desc: 'Set true to make it decrypt the value. Default: false'
22
+ option :secret, type: :boolean, desc: 'Set true to make it decrypt the value. Default: false'
23
23
  def set(name, value)
24
24
  # puts "options #{options}"
25
25
  client = Client::EnvVar.new(options)
@@ -38,10 +38,6 @@ module Datahen
38
38
  puts "#{client.unset(name)}"
39
39
  end
40
40
 
41
-
42
-
43
-
44
-
45
41
  end
46
42
  end
47
43
 
@@ -10,6 +10,7 @@ module Datahen
10
10
  desc "list", "gets a list of jobs"
11
11
  option :page, :aliases => :p, type: :numeric, desc: 'Get the next set of records by page.'
12
12
  option :per_page, :aliases => :P, type: :numeric, desc: 'Number of records per page. Max 500 per page.'
13
+ option :status, type: :string, desc: 'Returns jobs with a certain status'
13
14
  long_desc <<-LONGDESC
14
15
  List scrape jobs.
15
16
  LONGDESC
@@ -1,8 +1,8 @@
1
1
  module Datahen
2
2
  class CLI < Thor
3
3
  class Scraper < Thor
4
- desc "list", "List scrapers"
5
4
 
5
+ desc "list", "List scrapers"
6
6
  long_desc <<-LONGDESC
7
7
  List all scrapers.
8
8
  LONGDESC
@@ -29,6 +29,7 @@ module Datahen
29
29
  option :cancel_current_job, type: :boolean, desc: 'Set true to cancel currently active job if scheduler starts. Default: false'
30
30
  option :schedule, type: :string, desc: 'Set the schedule of the scraper to run. Must be in CRON format.'
31
31
  option :timezone, type: :string, desc: "Set the scheduler's timezone. Must be in IANA Timezone format. Defaults to \"America/Toronto\""
32
+ option :profile, type: :string, desc: 'Set the profiles (comma separated) to apply to the job. Default: default'
32
33
  def create(scraper_name, git_repository)
33
34
  # puts "options #{options}"
34
35
  client = Client::Scraper.new(options)
@@ -51,6 +52,7 @@ module Datahen
51
52
  option :cancel_current_job, type: :boolean, desc: 'Set true to cancel currently active job if scheduler starts. Default: false'
52
53
  option :schedule, type: :string, desc: 'Set the schedule of the scraper to run. Must be in CRON format.'
53
54
  option :timezone, type: :string, desc: "Set the scheduler's timezone. Must be in IANA Timezone format. Defaults to \"America/Toronto\""
55
+ option :profile, type: :string, desc: 'Set the profiles (comma separated) to apply to the job. Default: default'
54
56
  def update(scraper_name)
55
57
  client = Client::Scraper.new(options)
56
58
  puts "#{client.update(scraper_name, options)}"
@@ -164,15 +166,25 @@ module Datahen
164
166
  option :"max-timestamp", type: :string, desc: 'Ending timestamp point in time to query historic stats (inclusive)'
165
167
  option :"limit", type: :numeric, desc: 'Limit stats retrieved'
166
168
  option :"order", type: :numeric, desc: 'Order stats by timestamp [DESC]'
169
+ option :live, type: :boolean, desc: 'Get data from the live stats history, not cached stats history.'
170
+ option :filter, type: :string, desc: 'Filter results on `day` or `hour`, if not specified will return all records.'
167
171
  def history(scraper_name)
168
172
  client = Client::JobStat.new(options)
169
173
  if options[:job]
170
- puts "#{client.job_stats_history(options[:job])}"
174
+ puts "#{client.job_stats_history(options[:job], options)}"
171
175
  else
172
- puts "#{client.scraper_job_stats_history(scraper_name)}"
176
+ puts "#{client.scraper_job_stats_history(scraper_name, options)}"
173
177
  end
174
178
  end
175
179
 
180
+ desc "profile <scraper_name>", "displays the scraper applied profile"
181
+ long_desc <<-LONGDESC
182
+ Displays the account applied profile
183
+ LONGDESC
184
+ def profile(scraper_name)
185
+ client = Client::Scraper.new(options)
186
+ puts "#{client.profile(scraper_name)}"
187
+ end
176
188
 
177
189
  desc "job SUBCOMMAND ...ARGS", "manage scrapers jobs"
178
190
  subcommand "job", ScraperJob
@@ -26,6 +26,7 @@ module Datahen
26
26
  LONGDESC
27
27
  option :page, :aliases => :p, type: :numeric, desc: 'Get the next set of records by page.'
28
28
  option :per_page, :aliases => :P, type: :numeric, desc: 'Number of records per page. Max 500 per page.'
29
+ option :status, type: :string, desc: 'Returns jobs with a certain status'
29
30
  def list(scraper_name)
30
31
  client = Client::ScraperJob.new(options)
31
32
  puts "#{client.all(scraper_name)}"
@@ -64,16 +65,17 @@ module Datahen
64
65
 
65
66
  desc "pause <scraper_name>", "pauses a scraper's current job"
66
67
  long_desc <<-LONGDESC
67
- pauses a scraper's current job
68
+ Pauses a scraper's current job
68
69
  LONGDESC
69
70
  option :job, :aliases => :j, type: :numeric, desc: 'Set a specific job ID'
71
+ option :force, :aliases => :f, type: :boolean, desc: 'Force a job to be paused from a done or cancelled status'
70
72
  def pause(scraper_name)
71
73
  if options[:job]
72
74
  client = Client::Job.new(options)
73
- puts "#{client.pause(options[:job])}"
75
+ puts "#{client.pause(options[:job], options)}"
74
76
  else
75
77
  client = Client::ScraperJob.new(options)
76
- puts "#{client.pause(scraper_name)}"
78
+ puts "#{client.pause(scraper_name, options)}"
77
79
  end
78
80
  end
79
81
 
@@ -85,6 +87,7 @@ module Datahen
85
87
  option :workers, :aliases => :w, type: :numeric, desc: 'Set how many standard workers to use. Scraper job must be restarted(paused then resumed, or cancelled then resumed) for it to take effect. Default: 1. '
86
88
  option :browsers, type: :numeric, desc: 'Set how many browser workers to use. Scraper job must be restarted(paused then resumed, or cancelled then resumed) for it to take effect. Default: 0. '
87
89
  option :proxy_type, desc: 'Set the Proxy type. Default: standard'
90
+ option :profile, type: :string, desc: 'Set the profiles (comma separated) to apply to the job. Default: default'
88
91
  option :job, :aliases => :j, type: :numeric, desc: 'Set a specific job ID'
89
92
  def update(scraper_name)
90
93
  if options[:job]
@@ -96,6 +99,21 @@ module Datahen
96
99
  end
97
100
  end
98
101
 
102
+ desc "profile <scraper_name>", "displays a scraper's current job applied profile"
103
+ long_desc <<-LONGDESC
104
+ Displays a scraper's current job applied profile
105
+ LONGDESC
106
+ option :job, :aliases => :j, type: :numeric, desc: 'Set a specific job ID'
107
+ def profile(scraper_name)
108
+ if options[:job]
109
+ client = Client::Job.new(options)
110
+ puts "#{client.profile(options[:job])}"
111
+ else
112
+ client = Client::ScraperJob.new(options)
113
+ puts "#{client.profile(scraper_name)}"
114
+ end
115
+ end
116
+
99
117
  desc "var SUBCOMMAND ...ARGS", "for managing scraper's job variables"
100
118
  subcommand "var", ScraperJobVar
101
119
 
@@ -1,4 +1,5 @@
1
1
  require "datahen/client/base"
2
+ require "datahen/client/account"
2
3
  require "datahen/client/auth_token"
3
4
  require "datahen/client/deploy_key"
4
5
  require 'datahen/client/export'
@@ -24,7 +25,6 @@ require "datahen/client/job_var"
24
25
  require "datahen/client/scraper_job_var"
25
26
  require "datahen/client/job_finisher"
26
27
 
27
-
28
28
  module Datahen
29
29
  module Client
30
30
  end
@@ -0,0 +1,13 @@
1
+ module Datahen
2
+ module Client
3
+ class Account < Datahen::Client::Base
4
+
5
+ def profile(opts={})
6
+ params = @options.merge(opts)
7
+
8
+ self.class.get("/profile", params)
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -57,6 +57,8 @@ module Datahen
57
57
  query[:"max-timestamp"] = opts[:"max-timestamp"] if opts[:"max-timestamp"]
58
58
  query[:limit] = opts[:limit] if opts[:limit]
59
59
  query[:order] = opts[:order] if opts[:order]
60
+ query[:filter] = opts[:filter] if opts[:filter]
61
+ query[:force] = opts[:force] if opts[:force]
60
62
 
61
63
  if opts[:query]
62
64
  if opts[:query].is_a?(Hash)
@@ -20,6 +20,7 @@ module Datahen
20
20
  body[:standard_worker_count] = opts[:workers] if opts[:workers]
21
21
  body[:browser_worker_count] = opts[:browsers] if opts[:browsers]
22
22
  body[:proxy_type] = opts[:proxy_type] if opts[:proxy_type]
23
+ body[:profile] = opts[:profile] if opts[:profile]
23
24
  params = @options.merge({body: body.to_json})
24
25
 
25
26
  self.class.put("/jobs/#{job_id}", params)
@@ -64,6 +65,12 @@ module Datahen
64
65
  self.class.put("/jobs/#{job_id}/finisher_update", params)
65
66
  end
66
67
 
68
+ def profile(job_id, opts={})
69
+ params = @options.merge(opts)
70
+
71
+ self.class.get("/jobs/#{job_id}/profile", params)
72
+ end
73
+
67
74
  end
68
75
 
69
76
  end
@@ -18,12 +18,20 @@ module Datahen
18
18
  end
19
19
  end
20
20
 
21
- def job_stats_history(job_id)
22
- self.class.get("/jobs/#{job_id}/stats/history", @options)
21
+ def job_stats_history(job_id, opts={})
22
+ if opts[:live]
23
+ self.class.get("/jobs/#{job_id}/stats/history", @options)
24
+ else
25
+ self.class.get("/cached/jobs/#{job_id}/stats/history", @options)
26
+ end
23
27
  end
24
28
 
25
- def scraper_job_stats_history(scraper_name)
26
- self.class.get("/scrapers/#{scraper_name}/current_job/stats/history", @options)
29
+ def scraper_job_stats_history(scraper_name, opts={})
30
+ if opts[:live]
31
+ self.class.get("/scrapers/#{scraper_name}/current_job/stats/history", @options)
32
+ else
33
+ self.class.get("/cached/scrapers/#{scraper_name}/current_job/stats/history", @options)
34
+ end
27
35
  end
28
36
 
29
37
  end
@@ -25,6 +25,7 @@ module Datahen
25
25
  body[:cancel_current_job] = opts[:cancel_current_job] if opts[:cancel_current_job]
26
26
  body[:schedule] = opts[:schedule] if opts[:schedule]
27
27
  body[:timezone] = opts[:timezone] if opts[:timezone]
28
+ body[:profile] = opts[:profile] if opts[:profile]
28
29
  params = @options.merge({body: body.to_json})
29
30
  self.class.post("/scrapers", params)
30
31
  end
@@ -43,6 +44,7 @@ module Datahen
43
44
  body[:cancel_current_job] = opts[:cancel_current_job] if opts.has_key?("cancel_current_job") || opts.has_key?(:cancel_current_job)
44
45
  body[:schedule] = opts[:schedule] if opts[:schedule]
45
46
  body[:timezone] = opts[:timezone] if opts[:timezone]
47
+ body[:profile] = opts[:profile] if opts[:profile]
46
48
  params = @options.merge({body: body.to_json})
47
49
 
48
50
  self.class.put("/scrapers/#{scraper_name}", params)
@@ -52,6 +54,12 @@ module Datahen
52
54
  params = @options.merge(opts)
53
55
  self.class.delete("/scrapers/#{scraper_name}", params)
54
56
  end
57
+
58
+ def profile(scraper_name, opts={})
59
+ params = @options.merge(opts)
60
+
61
+ self.class.get("/scrapers/#{scraper_name}/profile", params)
62
+ end
55
63
  end
56
64
  end
57
65
  end
@@ -29,6 +29,7 @@ module Datahen
29
29
  body[:standard_worker_count] = opts[:workers] if opts[:workers]
30
30
  body[:browser_worker_count] = opts[:browsers] if opts[:browsers]
31
31
  body[:proxy_type] = opts[:proxy_type] if opts[:proxy_type]
32
+ body[:profile] = opts[:profile] if opts[:profile]
32
33
  params = @options.merge({body: body.to_json})
33
34
 
34
35
  self.class.put("/scrapers/#{scraper_name}/current_job", params)
@@ -48,6 +49,12 @@ module Datahen
48
49
  opts[:status] = 'paused'
49
50
  update(scraper_name, opts)
50
51
  end
52
+
53
+ def profile(scraper_name, opts={})
54
+ params = @options.merge(opts)
55
+
56
+ self.class.get("/scrapers/#{scraper_name}/current_job/profile", params)
57
+ end
51
58
  end
52
59
  end
53
60
  end
@@ -1,3 +1,3 @@
1
1
  module Datahen
2
- VERSION = "0.14.3"
2
+ VERSION = "0.14.11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datahen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.3
4
+ version: 0.14.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parama Danoesubroto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-02 00:00:00.000000000 Z
11
+ date: 2020-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -189,6 +189,7 @@ files:
189
189
  - exe/hen
190
190
  - lib/datahen.rb
191
191
  - lib/datahen/cli.rb
192
+ - lib/datahen/cli/account.rb
192
193
  - lib/datahen/cli/env_var.rb
193
194
  - lib/datahen/cli/finisher.rb
194
195
  - lib/datahen/cli/global_page.rb
@@ -206,6 +207,7 @@ files:
206
207
  - lib/datahen/cli/scraper_var.rb
207
208
  - lib/datahen/cli/seeder.rb
208
209
  - lib/datahen/client.rb
210
+ - lib/datahen/client/account.rb
209
211
  - lib/datahen/client/auth_token.rb
210
212
  - lib/datahen/client/backblaze_content.rb
211
213
  - lib/datahen/client/base.rb
@@ -264,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
266
  - !ruby/object:Gem::Version
265
267
  version: '0'
266
268
  requirements: []
267
- rubygems_version: 3.1.2
269
+ rubygems_version: 3.0.3
268
270
  signing_key:
269
271
  specification_version: 4
270
272
  summary: DataHen toolbelt for developers