Class: TreasureData::Client
- Inherits:
-
Object
- Object
- TreasureData::Client
- Defined in:
- lib/td/client.rb,
lib/td/client/version.rb
Constant Summary collapse
- VERSION =
'0.8.54'
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Class Method Summary collapse
Instance Method Summary collapse
-
#access_controls ⇒ Object
> [User].
-
#account ⇒ Object
> Account.
-
#add_apikey(user) ⇒ Object
> true.
-
#add_user(name, org, email, password) ⇒ Object
> true.
-
#aggregation_schema(name) ⇒ Object
> AggregationSchema.
-
#aggregation_schemas ⇒ Object
> [AggregationSchema].
- #apikey ⇒ Object
-
#bulk_import_delete_part(name, part_name) ⇒ Object
> nil.
-
#bulk_import_error_records(name, &block) ⇒ Object
> records:.
-
#bulk_import_upload_part(name, part_name, stream, size) ⇒ Object
> nil.
-
#bulk_imports ⇒ Object
> [BulkImport].
-
#change_email(user, email) ⇒ Object
> true.
-
#change_my_password(old_password, password) ⇒ Object
> true.
-
#change_password(user, password) ⇒ Object
> true.
-
#commit_bulk_import(name) ⇒ Object
> nil.
- #core_utilization(from, to) ⇒ Object
-
#create_aggregation_attr_entry(name, entry_name, comment, db, table, method_name, parameters) ⇒ Object
> true.
-
#create_aggregation_log_entry(name, entry_name, comment, db, table, okeys, value_key, count_key) ⇒ Object
> true.
-
#create_aggregation_schema(name, relation_key, params = {}) ⇒ Object
> true.
-
#create_bulk_import(name, database, table, opts = {}) ⇒ Object
> nil.
-
#create_database(db_name, opts = {}) ⇒ Object
> true.
-
#create_item_table(db_name, table_name) ⇒ Object
> true.
-
#create_log_table(db_name, table_name) ⇒ Object
> true.
-
#create_organization(organization) ⇒ Object
> true.
-
#create_result(name, url, opts = {}) ⇒ Object
> true.
-
#create_role(role, org) ⇒ Object
> true.
-
#create_schedule(name, opts) ⇒ Object
> first_time:Time.
-
#database(db_name) ⇒ Object
> Database.
-
#databases ⇒ Object
> [Database].
-
#delete_aggregation_attr_entry(name, entry_name) ⇒ Object
> true.
-
#delete_aggregation_log_entry(name, entry_name) ⇒ Object
> true.
-
#delete_aggregation_schema(name) ⇒ Object
> true.
-
#delete_bulk_import(name) ⇒ Object
> nil.
-
#delete_database(db_name) ⇒ Object
> true.
- #delete_ip_limit(org) ⇒ Object
-
#delete_organization(organization) ⇒ Object
> true.
-
#delete_result(name) ⇒ Object
> true.
-
#delete_role(role) ⇒ Object
> true.
-
#delete_schedule(name) ⇒ Object
> true.
-
#delete_table(db_name, table_name) ⇒ Object
> type:Symbol.
-
#export(db_name, table_name, storage_type, opts = {}) ⇒ Object
> Job.
-
#freeze_bulk_import(name) ⇒ Object
> nil.
-
#grant_access_control(subject, action, scope, grant_option) ⇒ Object
> true.
-
#grant_role(role, user) ⇒ Object
> true.
-
#history(name, from = nil, to = nil) ⇒ Object
[ScheduledJob].
-
#import(db_name, table_name, format, stream, size, unique_id = nil) ⇒ Object
> time:Flaot.
-
#initialize(apikey, opts = {}) ⇒ Client
constructor
A new instance of Client.
- #ip_limits ⇒ Object
-
#job(job_id) ⇒ Object
> Job.
-
#job_result(job_id) ⇒ Object
> result:.
-
#job_result_each(job_id, &block) ⇒ Object
> nil.
-
#job_result_format(job_id, format, io = nil) ⇒ Object
> result:String.
-
#job_status(job_id) ⇒ Object
> status:String.
-
#jobs(from = nil, to = nil, status = nil, conditions = nil) ⇒ Object
> [Job].
-
#kill(job_id) ⇒ Object
> former_status:String.
-
#list_apikeys(user) ⇒ Object
> [apikey:String].
- #list_bulk_import_parts(name) ⇒ Object
-
#organizations ⇒ Object
> [Organization].
-
#partial_delete(db_name, table_name, to, from, opts = {}) ⇒ Object
> Job.
-
#perform_bulk_import(name) ⇒ Object
> Job.
-
#query(db_name, q, result_url = nil, priority = nil, retry_limit = nil, opts = {}) ⇒ Object
> Job.
-
#remove_apikey(user, apikey) ⇒ Object
> true.
-
#remove_user(user) ⇒ Object
> true.
-
#results ⇒ Object
> [Result].
-
#revoke_access_control(subject, action, scope) ⇒ Object
> true.
-
#revoke_role(role, user) ⇒ Object
> true.
-
#roles ⇒ Object
> [Role].
-
#run_schedule(name, time, num) ⇒ Object
[ScheduledJob].
-
#schedules ⇒ Object
[Schedule].
- #server_status ⇒ Object
- #set_ip_limit(org, ip_ranges) ⇒ Object
-
#swap_table(db_name, table_name1, table_name2) ⇒ Object
> true.
-
#table(db_name, table_name) ⇒ Object
> Table.
-
#tables(db_name) ⇒ Object
> [Table].
- #tail(db_name, table_name, count, to = nil, from = nil, &block) ⇒ Object
-
#test_access_control(user, action, scope) ⇒ Object
> true.
-
#unfreeze_bulk_import(name) ⇒ Object
> nil.
-
#update_expire(db_name, table_name, expire_days) ⇒ Object
> true.
- #update_schedule(name, params) ⇒ Object
-
#update_schema(db_name, table_name, schema) ⇒ Object
> true.
-
#users ⇒ Object
> [User].
Constructor Details
#initialize(apikey, opts = {}) ⇒ Client
Returns a new instance of Client.
20 21 22 |
# File 'lib/td/client.rb', line 20 def initialize(apikey, opts={}) @api = API.new(apikey, opts) end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
24 25 26 |
# File 'lib/td/client.rb', line 24 def api @api end |
Class Method Details
.authenticate(user, password, opts = {}) ⇒ Object
9 10 11 12 13 |
# File 'lib/td/client.rb', line 9 def self.authenticate(user, password, opts={}) api = API.new(nil, opts) apikey = api.authenticate(user, password) new(apikey) end |
.server_status(opts = {}) ⇒ Object
15 16 17 18 |
# File 'lib/td/client.rb', line 15 def self.server_status(opts={}) api = API.new(nil, opts) api.server_status end |
Instance Method Details
#access_controls ⇒ Object
> [User]
408 409 410 411 412 413 |
# File 'lib/td/client.rb', line 408 def access_controls list = @api.list_access_controls list.map {|subject,action,scope,grant_option| AccessControl.new(self, subject, action, scope, grant_option) } end |
#account ⇒ Object
> Account
45 46 47 48 |
# File 'lib/td/client.rb', line 45 def account account_id, plan, storage, guaranteed_cores, maximum_cores, created_at = @api.show_account return Account.new(self, account_id, plan, storage, guaranteed_cores, maximum_cores, created_at) end |
#add_apikey(user) ⇒ Object
> true
388 389 390 |
# File 'lib/td/client.rb', line 388 def add_apikey(user) @api.add_apikey(user) end |
#add_user(name, org, email, password) ⇒ Object
> true
368 369 370 |
# File 'lib/td/client.rb', line 368 def add_user(name, org, email, password) @api.add_user(name, org, email, password) end |
#aggregation_schema(name) ⇒ Object
> AggregationSchema
464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'lib/td/client.rb', line 464 def aggregation_schema(name) relation_key, logs, attrs = @api.show_aggregation_schema(name) logs.map! {|name,comment,database,table,okeys,value_key,count_key| table = Table.new(self, database, table, 'log', nil, nil) LogAggregationSchemaEntry.new(self, name, comment, table, okeys, value_key, count_key) } attrs.map! {|name,comment,database,table,method_name,parameters| table = Table.new(self, database, table, 'log', nil, nil) AttributeAggregationSchemaEntry.new(self, name, comment, table, method_name, parameters) } AggregationSchema.new(self, name, relation_key, logs, attrs) end |
#aggregation_schemas ⇒ Object
> [AggregationSchema]
446 447 448 449 450 451 |
# File 'lib/td/client.rb', line 446 def aggregation_schemas list = @api.list_aggregation_schema list.map {|name,relation_key,timezone| AggregationSchema.new(self, name, relation_key, nil, nil, timezone) } end |
#apikey ⇒ Object
26 27 28 |
# File 'lib/td/client.rb', line 26 def apikey @api.apikey end |
#bulk_import_delete_part(name, part_name) ⇒ Object
> nil
238 239 240 |
# File 'lib/td/client.rb', line 238 def bulk_import_delete_part(name, part_name) @api.bulk_import_delete_part(name, part_name) end |
#bulk_import_error_records(name, &block) ⇒ Object
> records:
221 222 223 |
# File 'lib/td/client.rb', line 221 def bulk_import_error_records(name, &block) @api.bulk_import_error_records(name, &block) end |
#bulk_import_upload_part(name, part_name, stream, size) ⇒ Object
> nil
233 234 235 |
# File 'lib/td/client.rb', line 233 def bulk_import_upload_part(name, part_name, stream, size) @api.bulk_import_upload_part(name, part_name, stream, size) end |
#bulk_imports ⇒ Object
> [BulkImport]
226 227 228 229 230 |
# File 'lib/td/client.rb', line 226 def bulk_imports @api.list_bulk_imports.map {|data| BulkImport.new(self, data) } end |
#change_email(user, email) ⇒ Object
> true
378 379 380 |
# File 'lib/td/client.rb', line 378 def change_email(user, email) @api.change_email(user, email) end |
#change_my_password(old_password, password) ⇒ Object
> true
403 404 405 |
# File 'lib/td/client.rb', line 403 def change_my_password(old_password, password) @api.change_my_password(old_password, password) end |
#change_password(user, password) ⇒ Object
> true
398 399 400 |
# File 'lib/td/client.rb', line 398 def change_password(user, password) @api.change_password(user, password) end |
#commit_bulk_import(name) ⇒ Object
> nil
216 217 218 |
# File 'lib/td/client.rb', line 216 def commit_bulk_import(name) @api.commit_bulk_import(name) end |
#core_utilization(from, to) ⇒ Object
50 51 52 53 |
# File 'lib/td/client.rb', line 50 def core_utilization(from, to) from, to, interval, history = @api.account_core_utilization(from, to) return from, to, interval, history end |
#create_aggregation_attr_entry(name, entry_name, comment, db, table, method_name, parameters) ⇒ Object
> true
490 491 492 |
# File 'lib/td/client.rb', line 490 def create_aggregation_attr_entry(name, entry_name, comment, db, table, method_name, parameters) @api.create_aggregation_attr_entry(name, entry_name, comment, db, table, method_name, parameters) end |
#create_aggregation_log_entry(name, entry_name, comment, db, table, okeys, value_key, count_key) ⇒ Object
> true
480 481 482 |
# File 'lib/td/client.rb', line 480 def create_aggregation_log_entry(name, entry_name, comment, db, table, okeys, value_key, count_key) @api.create_aggregation_log_entry(name, entry_name, comment, db, table, okeys, value_key, count_key) end |
#create_aggregation_schema(name, relation_key, params = {}) ⇒ Object
> true
454 455 456 |
# File 'lib/td/client.rb', line 454 def create_aggregation_schema(name, relation_key, params={}) @api.create_aggregation_schema(name, relation_key, params) end |
#create_bulk_import(name, database, table, opts = {}) ⇒ Object
> nil
190 191 192 |
# File 'lib/td/client.rb', line 190 def create_bulk_import(name, database, table, opts={}) @api.create_bulk_import(name, database, table, opts) end |
#create_database(db_name, opts = {}) ⇒ Object
> true
35 36 37 |
# File 'lib/td/client.rb', line 35 def create_database(db_name, opts={}) @api.create_database(db_name, opts) end |
#create_item_table(db_name, table_name) ⇒ Object
> true
80 81 82 |
# File 'lib/td/client.rb', line 80 def create_item_table(db_name, table_name) @api.create_item_table(db_name, table_name) end |
#create_log_table(db_name, table_name) ⇒ Object
> true
75 76 77 |
# File 'lib/td/client.rb', line 75 def create_log_table(db_name, table_name) @api.create_log_table(db_name, table_name) end |
#create_organization(organization) ⇒ Object
> true
322 323 324 |
# File 'lib/td/client.rb', line 322 def create_organization(organization) @api.create_organization(organization) end |
#create_result(name, url, opts = {}) ⇒ Object
> true
304 305 306 |
# File 'lib/td/client.rb', line 304 def create_result(name, url, opts={}) @api.create_result(name, url, opts) end |
#create_role(role, org) ⇒ Object
> true
340 341 342 |
# File 'lib/td/client.rb', line 340 def create_role(role, org) @api.create_role(role, org) end |
#create_schedule(name, opts) ⇒ Object
> first_time:Time
247 248 249 250 251 252 |
# File 'lib/td/client.rb', line 247 def create_schedule(name, opts) raise ArgumentError, "'cron' option is required" unless opts[:cron] || opts['cron'] raise ArgumentError, "'query' option is required" unless opts[:query] || opts['query'] start = @api.create_schedule(name, opts) return Time.parse(start) end |
#database(db_name) ⇒ Object
> Database
64 65 66 67 68 69 70 71 72 |
# File 'lib/td/client.rb', line 64 def database(db_name) m = @api.list_databases m.each {|name,(count,created_at,updated_at,org)| if name == db_name return Database.new(self, name, nil, count, created_at, updated_at, org) end } raise NotFoundError, "Database '#{db_name}' does not exist" end |
#databases ⇒ Object
> [Database]
56 57 58 59 60 61 |
# File 'lib/td/client.rb', line 56 def databases m = @api.list_databases m.map {|db_name,(count,created_at,updated_at,org)| Database.new(self, db_name, nil, count, created_at, updated_at, org) } end |
#delete_aggregation_attr_entry(name, entry_name) ⇒ Object
> true
495 496 497 |
# File 'lib/td/client.rb', line 495 def delete_aggregation_attr_entry(name, entry_name) @api.delete_aggregation_attr_entry(name, entry_name) end |
#delete_aggregation_log_entry(name, entry_name) ⇒ Object
> true
485 486 487 |
# File 'lib/td/client.rb', line 485 def delete_aggregation_log_entry(name, entry_name) @api.delete_aggregation_log_entry(name, entry_name) end |
#delete_aggregation_schema(name) ⇒ Object
> true
459 460 461 |
# File 'lib/td/client.rb', line 459 def delete_aggregation_schema(name) @api.delete_aggregation_schema(name) end |
#delete_bulk_import(name) ⇒ Object
> nil
195 196 197 |
# File 'lib/td/client.rb', line 195 def delete_bulk_import(name) @api.delete_bulk_import(name) end |
#delete_database(db_name) ⇒ Object
> true
40 41 42 |
# File 'lib/td/client.rb', line 40 def delete_database(db_name) @api.delete_database(db_name) end |
#delete_ip_limit(org) ⇒ Object
441 442 443 |
# File 'lib/td/client.rb', line 441 def delete_ip_limit(org) @api.delete_ip_limit(org) end |
#delete_organization(organization) ⇒ Object
> true
327 328 329 |
# File 'lib/td/client.rb', line 327 def delete_organization(organization) @api.delete_organization(organization) end |
#delete_result(name) ⇒ Object
> true
309 310 311 |
# File 'lib/td/client.rb', line 309 def delete_result(name) @api.delete_result(name) end |
#delete_role(role) ⇒ Object
> true
345 346 347 |
# File 'lib/td/client.rb', line 345 def delete_role(role) @api.delete_role(role) end |
#delete_schedule(name) ⇒ Object
> true
255 256 257 |
# File 'lib/td/client.rb', line 255 def delete_schedule(name) @api.delete_schedule(name) end |
#delete_table(db_name, table_name) ⇒ Object
> type:Symbol
100 101 102 |
# File 'lib/td/client.rb', line 100 def delete_table(db_name, table_name) @api.delete_table(db_name, table_name) end |
#export(db_name, table_name, storage_type, opts = {}) ⇒ Object
> Job
178 179 180 181 |
# File 'lib/td/client.rb', line 178 def export(db_name, table_name, storage_type, opts={}) job_id = @api.export(db_name, table_name, storage_type, opts) Job.new(self, job_id, :export, nil) end |
#freeze_bulk_import(name) ⇒ Object
> nil
200 201 202 |
# File 'lib/td/client.rb', line 200 def freeze_bulk_import(name) @api.freeze_bulk_import(name) end |
#grant_access_control(subject, action, scope, grant_option) ⇒ Object
> true
416 417 418 |
# File 'lib/td/client.rb', line 416 def grant_access_control(subject, action, scope, grant_option) @api.grant_access_control(subject, action, scope, grant_option) end |
#grant_role(role, user) ⇒ Object
> true
350 351 352 |
# File 'lib/td/client.rb', line 350 def grant_role(role, user) @api.grant_role(role, user) end |
#history(name, from = nil, to = nil) ⇒ Object
- ScheduledJob
273 274 275 276 277 278 279 |
# File 'lib/td/client.rb', line 273 def history(name, from=nil, to=nil) result = @api.history(name, from, to) result.map {|scheduled_at,job_id,type,status,query,start_at,end_at,result_url,priority,database| # TODO org ScheduledJob.new(self, scheduled_at, job_id, type, query, status, nil, nil, start_at, end_at, nil, result_url, nil, priority,nil,nil,database) } end |
#import(db_name, table_name, format, stream, size, unique_id = nil) ⇒ Object
> time:Flaot
290 291 292 |
# File 'lib/td/client.rb', line 290 def import(db_name, table_name, format, stream, size, unique_id=nil) @api.import(db_name, table_name, format, stream, size, unique_id) end |
#ip_limits ⇒ Object
430 431 432 433 434 435 |
# File 'lib/td/client.rb', line 430 def ip_limits ips = @api.list_ip_limits ips.map { |org, ipaddr, mask| IpLimit.new(self, org, ipaddr, mask) } end |
#job(job_id) ⇒ Object
> Job
146 147 148 149 150 |
# File 'lib/td/client.rb', line 146 def job(job_id) job_id = job_id.to_s type, query, status, url, debug, start_at, end_at, result_url, hive_result_schema, priority, retry_limit, org, db = @api.show_job(job_id) Job.new(self, job_id, type, query, status, url, debug, start_at, end_at, nil, result_url, hive_result_schema, priority, retry_limit, org, db) end |
#job_result(job_id) ⇒ Object
> result:
158 159 160 |
# File 'lib/td/client.rb', line 158 def job_result(job_id) @api.job_result(job_id) end |
#job_result_each(job_id, &block) ⇒ Object
> nil
168 169 170 |
# File 'lib/td/client.rb', line 168 def job_result_each(job_id, &block) @api.job_result_each(job_id, &block) end |
#job_result_format(job_id, format, io = nil) ⇒ Object
> result:String
163 164 165 |
# File 'lib/td/client.rb', line 163 def job_result_format(job_id, format, io=nil) @api.job_result_format(job_id, format, io) end |
#job_status(job_id) ⇒ Object
> status:String
153 154 155 |
# File 'lib/td/client.rb', line 153 def job_status(job_id) return @api.job_status(job_id) end |
#jobs(from = nil, to = nil, status = nil, conditions = nil) ⇒ Object
> [Job]
138 139 140 141 142 143 |
# File 'lib/td/client.rb', line 138 def jobs(from=nil, to=nil, status=nil, conditions=nil) result = @api.list_jobs(from, to, status, conditions) result.map {|job_id,type,status,query,start_at,end_at,result_url,priority,retry_limit,org,db| Job.new(self, job_id, type, query, status, nil, nil, start_at, end_at, nil, result_url, nil, priority, retry_limit, org, db) } end |
#kill(job_id) ⇒ Object
> former_status:String
173 174 175 |
# File 'lib/td/client.rb', line 173 def kill(job_id) @api.kill(job_id) end |
#list_apikeys(user) ⇒ Object
> [apikey:String]
383 384 385 |
# File 'lib/td/client.rb', line 383 def list_apikeys(user) @api.list_apikeys(user) end |
#list_bulk_import_parts(name) ⇒ Object
242 243 244 |
# File 'lib/td/client.rb', line 242 def list_bulk_import_parts(name) @api.list_bulk_import_parts(name) end |
#organizations ⇒ Object
> [Organization]
314 315 316 317 318 319 |
# File 'lib/td/client.rb', line 314 def organizations list = @api.list_organizations list.map {|name| Organization.new(self, name) } end |
#partial_delete(db_name, table_name, to, from, opts = {}) ⇒ Object
> Job
184 185 186 187 |
# File 'lib/td/client.rb', line 184 def partial_delete(db_name, table_name, to, from, opts={}) job_id = @api.partial_delete(db_name, table_name, to, from, opts) Job.new(self, job_id, :partialdelete, nil) end |
#perform_bulk_import(name) ⇒ Object
> Job
210 211 212 213 |
# File 'lib/td/client.rb', line 210 def perform_bulk_import(name) job_id = @api.perform_bulk_import(name) Job.new(self, job_id, :bulk_import, nil) end |
#query(db_name, q, result_url = nil, priority = nil, retry_limit = nil, opts = {}) ⇒ Object
> Job
129 130 131 132 133 134 135 |
# File 'lib/td/client.rb', line 129 def query(db_name, q, result_url=nil, priority=nil, retry_limit=nil, opts={}) # for compatibility, assume type is hive unless specifically specified type = opts[:type] || opts['type'] || :hive raise ArgumentError, "The specified query type is not supported: #{type}" unless [:hive, :pig, :impala].include? type job_id = @api.query(q, type, db_name, result_url, priority, retry_limit, opts) Job.new(self, job_id, type, q) end |
#remove_apikey(user, apikey) ⇒ Object
> true
393 394 395 |
# File 'lib/td/client.rb', line 393 def remove_apikey(user, apikey) @api.remove_apikey(user, apikey) end |
#remove_user(user) ⇒ Object
> true
373 374 375 |
# File 'lib/td/client.rb', line 373 def remove_user(user) @api.remove_user(user) end |
#results ⇒ Object
> [Result]
295 296 297 298 299 300 301 |
# File 'lib/td/client.rb', line 295 def results results = @api.list_result rs = results.map {|name,url,organizations| Result.new(self, name, url, organizations) } return rs end |
#revoke_access_control(subject, action, scope) ⇒ Object
> true
421 422 423 |
# File 'lib/td/client.rb', line 421 def revoke_access_control(subject, action, scope) @api.revoke_access_control(subject, action, scope) end |
#revoke_role(role, user) ⇒ Object
> true
355 356 357 |
# File 'lib/td/client.rb', line 355 def revoke_role(role, user) @api.revoke_role(role, user) end |
#roles ⇒ Object
> [Role]
332 333 334 335 336 337 |
# File 'lib/td/client.rb', line 332 def roles list = @api.list_roles list.map {|name,org,users| Role.new(self, name, org, users) } end |
#run_schedule(name, time, num) ⇒ Object
- ScheduledJob
282 283 284 285 286 287 |
# File 'lib/td/client.rb', line 282 def run_schedule(name, time, num) results = @api.run_schedule(name, time, num) results.map {|job_id,type,scheduled_at| ScheduledJob.new(self, scheduled_at, job_id, type, nil) } end |
#schedules ⇒ Object
- Schedule
260 261 262 263 264 265 |
# File 'lib/td/client.rb', line 260 def schedules result = @api.list_schedules result.map {|name,cron,query,database,result_url,timezone,delay,next_time,priority,retry_limit,org_name| Schedule.new(self, name, cron, query, database, result_url, timezone, delay, next_time, priority, retry_limit, org_name) } end |
#server_status ⇒ Object
30 31 32 |
# File 'lib/td/client.rb', line 30 def server_status @api.server_status end |
#set_ip_limit(org, ip_ranges) ⇒ Object
437 438 439 |
# File 'lib/td/client.rb', line 437 def set_ip_limit(org, ip_ranges) @api.set_ip_limit(org, ip_ranges.to_json) end |
#swap_table(db_name, table_name1, table_name2) ⇒ Object
> true
85 86 87 |
# File 'lib/td/client.rb', line 85 def swap_table(db_name, table_name1, table_name2) @api.swap_table(db_name, table_name1, table_name2) end |
#table(db_name, table_name) ⇒ Object
> Table
115 116 117 118 119 120 121 122 |
# File 'lib/td/client.rb', line 115 def table(db_name, table_name) tables(db_name).each {|t| if t.name == table_name return t end } raise NotFoundError, "Table '#{db_name}.#{table_name}' does not exist" end |
#tables(db_name) ⇒ Object
> [Table]
105 106 107 108 109 110 111 112 |
# File 'lib/td/client.rb', line 105 def tables(db_name) m = @api.list_tables(db_name) m.map {|table_name,(type,schema,count,created_at,updated_at,estimated_storage_size, last_import, , expire_days)| schema = Schema.new.from_json(schema) Table.new(self, db_name, table_name, type, schema, count, created_at, updated_at, estimated_storage_size, last_import, , expire_days) } end |
#tail(db_name, table_name, count, to = nil, from = nil, &block) ⇒ Object
124 125 126 |
# File 'lib/td/client.rb', line 124 def tail(db_name, table_name, count, to=nil, from=nil, &block) @api.tail(db_name, table_name, count, to, from, &block) end |
#test_access_control(user, action, scope) ⇒ Object
> true
426 427 428 |
# File 'lib/td/client.rb', line 426 def test_access_control(user, action, scope) @api.test_access_control(user, action, scope) end |
#unfreeze_bulk_import(name) ⇒ Object
> nil
205 206 207 |
# File 'lib/td/client.rb', line 205 def unfreeze_bulk_import(name) @api.unfreeze_bulk_import(name) end |
#update_expire(db_name, table_name, expire_days) ⇒ Object
> true
95 96 97 |
# File 'lib/td/client.rb', line 95 def update_expire(db_name, table_name, expire_days) @api.update_expire(db_name, table_name, expire_days) end |
#update_schedule(name, params) ⇒ Object
267 268 269 270 |
# File 'lib/td/client.rb', line 267 def update_schedule(name, params) @api.update_schedule(name, params) nil end |
#update_schema(db_name, table_name, schema) ⇒ Object
> true
90 91 92 |
# File 'lib/td/client.rb', line 90 def update_schema(db_name, table_name, schema) @api.update_schema(db_name, table_name, schema.to_json) end |
#users ⇒ Object
> [User]
360 361 362 363 364 365 |
# File 'lib/td/client.rb', line 360 def users list = @api.list_users list.map {|name,org,roles,email| User.new(self, name, org, roles, email) } end |