td-client 1.0.5 → 1.0.6
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/td/client.rb +0 -33
- data/lib/td/client/api.rb +0 -2
- data/lib/td/client/api/export.rb +1 -1
- data/lib/td/client/api/job.rb +4 -1
- data/lib/td/client/version.rb +1 -1
- data/spec/td/client/job_api_spec.rb +3 -1
- metadata +4 -6
- data/lib/td/client/api/access_control.rb +0 -74
- data/spec/td/client/access_control_api_spec.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62d7b67418193055ae96afc611d3d60498dc31f2
|
4
|
+
data.tar.gz: 435833ca652ee44eb037425f6f4b5429d7bc770e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60fa14a70c5f1c4692482a9aea14355ddd7ace29da1caadced59b07fa076cd85bff27dbd4e008d3d90bf84c2d2511e497a29c25c7825a4c9afb57423b28799fc
|
7
|
+
data.tar.gz: 5a50764649b21f4f29a98e527d50c9bf6c7fa7f4887b95e4a14bb7dfb9d304ca52f89aa664c2142033cd34c67a97b2f0b08dc50f471c4c3841170ea3a6e6a4e8
|
data/lib/td/client.rb
CHANGED
@@ -534,39 +534,6 @@ class Client
|
|
534
534
|
@api.change_my_password(old_password, password)
|
535
535
|
end
|
536
536
|
|
537
|
-
# @return [Array<AccessControl>]
|
538
|
-
def access_controls
|
539
|
-
list = @api.list_access_controls
|
540
|
-
list.map {|subject,action,scope,grant_option|
|
541
|
-
AccessControl.new(self, subject, action, scope, grant_option)
|
542
|
-
}
|
543
|
-
end
|
544
|
-
|
545
|
-
# @param [String] subject
|
546
|
-
# @param [String] action
|
547
|
-
# @param [String] scope
|
548
|
-
# @param [Array] grant_option
|
549
|
-
# @return [true]
|
550
|
-
def grant_access_control(subject, action, scope, grant_option)
|
551
|
-
@api.grant_access_control(subject, action, scope, grant_option)
|
552
|
-
end
|
553
|
-
|
554
|
-
# @param [String] subject
|
555
|
-
# @param [String] action
|
556
|
-
# @param [String] scope
|
557
|
-
# @return [true]
|
558
|
-
def revoke_access_control(subject, action, scope)
|
559
|
-
@api.revoke_access_control(subject, action, scope)
|
560
|
-
end
|
561
|
-
|
562
|
-
# @param [String] user
|
563
|
-
# @param [String] action
|
564
|
-
# @param [String] scope
|
565
|
-
# @return [Array]
|
566
|
-
def test_access_control(user, action, scope)
|
567
|
-
@api.test_access_control(user, action, scope)
|
568
|
-
end
|
569
|
-
|
570
537
|
# => BulkLoad::Job
|
571
538
|
def bulk_load_guess(job)
|
572
539
|
@api.bulk_load_guess(job)
|
data/lib/td/client/api.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'td/client/api_error'
|
2
2
|
require 'td/client/version'
|
3
|
-
require 'td/client/api/access_control'
|
4
3
|
require 'td/client/api/account'
|
5
4
|
require 'td/client/api/bulk_import'
|
6
5
|
require 'td/client/api/bulk_load'
|
@@ -21,7 +20,6 @@ require 'td/core_ext/openssl/ssl/sslcontext/set_params'
|
|
21
20
|
module TreasureData
|
22
21
|
|
23
22
|
class API
|
24
|
-
include API::AccessControl
|
25
23
|
include API::Account
|
26
24
|
include API::BulkImport
|
27
25
|
include API::BulkLoad
|
data/lib/td/client/api/export.rb
CHANGED
@@ -28,7 +28,7 @@ module Export
|
|
28
28
|
# @return [String] job_id
|
29
29
|
def result_export(target_job_id, opts={})
|
30
30
|
code, body, res = post("/v3/job/result_export/#{target_job_id}", opts)
|
31
|
-
if code !=
|
31
|
+
if code[0] != ?2
|
32
32
|
raise_error("Result Export failed", res)
|
33
33
|
end
|
34
34
|
js = checked_json(body, %w[job_id])
|
data/lib/td/client/api/job.rb
CHANGED
@@ -67,6 +67,8 @@ module Job
|
|
67
67
|
num_records = js['num_records']
|
68
68
|
duration = js['duration']
|
69
69
|
result = js['result'] # result target URL
|
70
|
+
linked_result_export_job_id = js['linked_result_export_job_id']
|
71
|
+
result_export_target_job_id = js['result_export_target_job_id']
|
70
72
|
hive_result_schema = (js['hive_result_schema'] || '')
|
71
73
|
if hive_result_schema.empty?
|
72
74
|
hive_result_schema = nil
|
@@ -100,7 +102,8 @@ module Job
|
|
100
102
|
priority = js['priority']
|
101
103
|
retry_limit = js['retry_limit']
|
102
104
|
return [type, query, status, url, debug, start_at, end_at, cpu_time,
|
103
|
-
result_size, result, hive_result_schema, priority, retry_limit, nil, database, duration, num_records
|
105
|
+
result_size, result, hive_result_schema, priority, retry_limit, nil, database, duration, num_records,
|
106
|
+
linked_result_export_job_id, result_export_target_job_id]
|
104
107
|
end
|
105
108
|
|
106
109
|
# @param [String] job_id
|
data/lib/td/client/version.rb
CHANGED
@@ -31,7 +31,7 @@ describe 'Job API' do
|
|
31
31
|
jobs = api.list_jobs
|
32
32
|
jobs[i..i].map {|job_id, type, status, query, start_at, end_at, cpu_time,
|
33
33
|
result_size, result_url, priority, retry_limit, org, db,
|
34
|
-
duration, num_records|
|
34
|
+
duration, num_records, linked_result_export_job_id, result_export_target_job_id|
|
35
35
|
expect(job_id).to eq(job['job_id'])
|
36
36
|
expect(type).to eq(job['type'])
|
37
37
|
expect(status).to eq(job['status'])
|
@@ -47,6 +47,8 @@ describe 'Job API' do
|
|
47
47
|
expect(db).to eq(job['database'])
|
48
48
|
expect(duration).to eq(job['duration'])
|
49
49
|
expect(num_records).to eq(job['num_records'])
|
50
|
+
expect(linked_result_export_job_id).to eq(job['linked_result_export_job_id'])
|
51
|
+
expect(result_export_target_job_id).to eq(job['result_export_target_job_id'])
|
50
52
|
}
|
51
53
|
end
|
52
54
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: td-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Treasure Data, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -138,7 +138,6 @@ files:
|
|
138
138
|
- lib/td-client.rb
|
139
139
|
- lib/td/client.rb
|
140
140
|
- lib/td/client/api.rb
|
141
|
-
- lib/td/client/api/access_control.rb
|
142
141
|
- lib/td/client/api/account.rb
|
143
142
|
- lib/td/client/api/bulk_import.rb
|
144
143
|
- lib/td/client/api/bulk_load.rb
|
@@ -158,7 +157,6 @@ files:
|
|
158
157
|
- lib/td/client/version.rb
|
159
158
|
- lib/td/core_ext/openssl/ssl/sslcontext/set_params.rb
|
160
159
|
- spec/spec_helper.rb
|
161
|
-
- spec/td/client/access_control_api_spec.rb
|
162
160
|
- spec/td/client/account_api_spec.rb
|
163
161
|
- spec/td/client/api_error_spec.rb
|
164
162
|
- spec/td/client/api_spec.rb
|
@@ -182,7 +180,8 @@ files:
|
|
182
180
|
- spec/td/client_sched_spec.rb
|
183
181
|
- spec/td/client_spec.rb
|
184
182
|
homepage: http://treasuredata.com/
|
185
|
-
licenses:
|
183
|
+
licenses:
|
184
|
+
- Apache-2.0
|
186
185
|
metadata: {}
|
187
186
|
post_install_message:
|
188
187
|
rdoc_options: []
|
@@ -205,7 +204,6 @@ signing_key:
|
|
205
204
|
specification_version: 4
|
206
205
|
summary: Treasure Data API library for Ruby
|
207
206
|
test_files:
|
208
|
-
- spec/td/client/access_control_api_spec.rb
|
209
207
|
- spec/td/client/account_api_spec.rb
|
210
208
|
- spec/td/client/api_error_spec.rb
|
211
209
|
- spec/td/client/api_spec.rb
|
@@ -1,74 +0,0 @@
|
|
1
|
-
class TreasureData::API
|
2
|
-
module AccessControl
|
3
|
-
|
4
|
-
####
|
5
|
-
## Access Control API
|
6
|
-
##
|
7
|
-
|
8
|
-
# @param [String] subject
|
9
|
-
# @param [String] action
|
10
|
-
# @param [String] scope
|
11
|
-
# @param [Array] grant_option
|
12
|
-
# @return [true]
|
13
|
-
def grant_access_control(subject, action, scope, grant_option)
|
14
|
-
params = {'subject'=>subject, 'action'=>action, 'scope'=>scope, 'grant_option'=>grant_option.to_s}
|
15
|
-
code, body, res = post("/v3/acl/grant", params)
|
16
|
-
if code != "200"
|
17
|
-
raise_error("Granting access control failed", res)
|
18
|
-
end
|
19
|
-
return true
|
20
|
-
end
|
21
|
-
|
22
|
-
# @param [String] subject
|
23
|
-
# @param [String] action
|
24
|
-
# @param [String] scope
|
25
|
-
# @return [true]
|
26
|
-
def revoke_access_control(subject, action, scope)
|
27
|
-
params = {'subject'=>subject, 'action'=>action, 'scope'=>scope}
|
28
|
-
code, body, res = post("/v3/acl/revoke", params)
|
29
|
-
if code != "200"
|
30
|
-
raise_error("Revoking access control failed", res)
|
31
|
-
end
|
32
|
-
return true
|
33
|
-
end
|
34
|
-
|
35
|
-
# @param [String] user
|
36
|
-
# @param [String] action
|
37
|
-
# @param [String] scope
|
38
|
-
# @return [Array]
|
39
|
-
def test_access_control(user, action, scope)
|
40
|
-
params = {'user'=>user, 'action'=>action, 'scope'=>scope}
|
41
|
-
code, body, res = get("/v3/acl/test", params)
|
42
|
-
if code != "200"
|
43
|
-
raise_error("Testing access control failed", res)
|
44
|
-
end
|
45
|
-
js = checked_json(body, %w[permission access_controls])
|
46
|
-
perm = js["permission"]
|
47
|
-
acl = js["access_controls"].map {|roleinfo|
|
48
|
-
subject = roleinfo['subject']
|
49
|
-
action = roleinfo['action']
|
50
|
-
scope = roleinfo['scope']
|
51
|
-
[name, action, scope]
|
52
|
-
}
|
53
|
-
return perm, acl
|
54
|
-
end
|
55
|
-
|
56
|
-
# @return [Array]
|
57
|
-
def list_access_controls
|
58
|
-
code, body, res = get("/v3/acl/list")
|
59
|
-
if code != "200"
|
60
|
-
raise_error("Listing access control failed", res)
|
61
|
-
end
|
62
|
-
js = checked_json(body, %w[access_controls])
|
63
|
-
acl = js["access_controls"].map {|roleinfo|
|
64
|
-
subject = roleinfo['subject']
|
65
|
-
action = roleinfo['action']
|
66
|
-
scope = roleinfo['scope']
|
67
|
-
grant_option = roleinfo['grant_option']
|
68
|
-
[subject, action, scope, grant_option]
|
69
|
-
}
|
70
|
-
return acl
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'td/client/spec_resources'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
describe 'Access Control API' do
|
6
|
-
include_context 'spec symbols'
|
7
|
-
include_context 'common helper'
|
8
|
-
|
9
|
-
let :api do
|
10
|
-
# no retry for GET
|
11
|
-
API.new(nil, {:max_cumul_retry_delay => -1})
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'all apis' do
|
15
|
-
it 'is deprecated' do
|
16
|
-
stub_api_request(:post, "/v3/acl/grant").to_return(:status => 500)
|
17
|
-
expect {
|
18
|
-
api.grant_access_control('subject', 'action', 'scope', [])
|
19
|
-
}.to raise_error(TreasureData::APIError)
|
20
|
-
|
21
|
-
stub_api_request(:post, "/v3/acl/revoke").to_return(:status => 500)
|
22
|
-
expect {
|
23
|
-
api.revoke_access_control('subject', 'action', 'scope')
|
24
|
-
}.to raise_error(TreasureData::APIError)
|
25
|
-
|
26
|
-
stub_api_request(:get, "/v3/acl/test", :query => {'user' => 'user', 'action' => 'action', 'scope' => 'scope'}).to_return(:status => 422)
|
27
|
-
expect {
|
28
|
-
api.test_access_control('user', 'action', 'scope')
|
29
|
-
}.to raise_error(TreasureData::APIError)
|
30
|
-
|
31
|
-
stub_api_request(:get, "/v3/acl/list").to_return(:status => 500)
|
32
|
-
expect {
|
33
|
-
api.list_access_controls
|
34
|
-
}.to raise_error(TreasureData::APIError)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|