files.com 1.1.784 → 1.1.786
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/_VERSION +1 -1
- data/lib/files.com/api_client.rb +14 -3
- data/lib/files.com/version.rb +3 -1
- data/spec/lib/api_client_spec.rb +48 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 297ac56fe0c1ad0e834dcd371599ce418443650c0c136adbd6530e42da051e09
|
|
4
|
+
data.tar.gz: 20c046024f6830e02e7b73daccbe7dbe32ec9cce8ca38509a8c932bc4b826ab3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a0ceefe70ae7603de8bdfcaa0856a40c08201ec2a601ec2a4003cb093c8cb0eab0ace565d4a704ce93e487cc1d57bce3b85363da27a80f426f74c0000918a118
|
|
7
|
+
data.tar.gz: 6e9c93ff74b7f96d603b1da2249373c57c4843fbfbc66508d46b62e55ff1880a1d80c33427247db753f633649adfdc7f66dc17fcac9894fa756d8707a354e78f
|
data/_VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.1.
|
|
1
|
+
1.1.786
|
data/lib/files.com/api_client.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Files
|
|
|
8
8
|
QUERY_METHODS = %i[get head delete].freeze
|
|
9
9
|
private_constant :QUERY_METHODS
|
|
10
10
|
|
|
11
|
-
# The default for
|
|
11
|
+
# The default for an option this client does not set itself.
|
|
12
12
|
USE_GLOBAL = Object.new.freeze
|
|
13
13
|
private_constant :USE_GLOBAL
|
|
14
14
|
|
|
@@ -27,10 +27,16 @@ module Files
|
|
|
27
27
|
# Files.log_level is set.
|
|
28
28
|
#
|
|
29
29
|
# A client created with logger: nil, log_level: nil logs no ordinary API messages.
|
|
30
|
-
|
|
30
|
+
#
|
|
31
|
+
# Its API requests likewise name the library-wide Files.workspace_id, read for each request, unless
|
|
32
|
+
# +workspace_id+ gives this client its own workspace; 0 is sent as "0". A request's own workspace_id option still
|
|
33
|
+
# takes precedence, and a request whose workspace_id is nil uses this client's. Pass workspace_id: nil to name no
|
|
34
|
+
# workspace for this client's requests even when Files.workspace_id is set.
|
|
35
|
+
def initialize(conn = nil, logger: USE_GLOBAL, log_level: USE_GLOBAL, workspace_id: USE_GLOBAL)
|
|
31
36
|
self.conn = conn || self.class.default_conn
|
|
32
37
|
@logger = logger
|
|
33
38
|
@log_level = log_level.equal?(USE_GLOBAL) ? log_level : Util.normalize_log_level(log_level)
|
|
39
|
+
@workspace_id = workspace_id
|
|
34
40
|
@system_profiler = SystemProfiler.new
|
|
35
41
|
@last_request_metrics = nil
|
|
36
42
|
end
|
|
@@ -125,7 +131,7 @@ module Files
|
|
|
125
131
|
else
|
|
126
132
|
session_id = nil
|
|
127
133
|
end
|
|
128
|
-
workspace_id =
|
|
134
|
+
workspace_id = default_workspace_id if workspace_id.nil?
|
|
129
135
|
|
|
130
136
|
if session_id and session_id != ""
|
|
131
137
|
check_session_id!(session_id)
|
|
@@ -550,6 +556,11 @@ module Files
|
|
|
550
556
|
)
|
|
551
557
|
end
|
|
552
558
|
|
|
559
|
+
# This client's own workspace where it set one, and the library-wide one otherwise.
|
|
560
|
+
private def default_workspace_id
|
|
561
|
+
@workspace_id.equal?(USE_GLOBAL) ? Files.workspace_id : @workspace_id
|
|
562
|
+
end
|
|
563
|
+
|
|
553
564
|
class RequestLogContext
|
|
554
565
|
attr_accessor :body, :api_key, :method, :path, :query_params, :session_id
|
|
555
566
|
end
|
data/lib/files.com/version.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Files
|
|
4
|
-
|
|
4
|
+
# The SDK's release version, reported in the API User-Agent. The package's _VERSION file holds it; the gemspec
|
|
5
|
+
# reads the same file for the gem version, and releases write the new version there.
|
|
6
|
+
VERSION = File.read(File.expand_path("../../_VERSION", __dir__)).strip.freeze
|
|
5
7
|
end
|
data/spec/lib/api_client_spec.rb
CHANGED
|
@@ -402,6 +402,54 @@ RSpec.describe Files::ApiClient do
|
|
|
402
402
|
end
|
|
403
403
|
end
|
|
404
404
|
|
|
405
|
+
describe "client workspaces" do
|
|
406
|
+
around do |example|
|
|
407
|
+
original = Files.workspace_id
|
|
408
|
+
example.run
|
|
409
|
+
ensure
|
|
410
|
+
Files.workspace_id = original
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
it "sends each client's own workspace, and the library-wide one for clients without their own" do
|
|
414
|
+
workspace_headers = []
|
|
415
|
+
connection = Faraday.new do |builder|
|
|
416
|
+
builder.response :raise_error
|
|
417
|
+
builder.adapter :test do |stub|
|
|
418
|
+
stub.get("/api/rest/v1/workspaces/1") do |env|
|
|
419
|
+
workspace_headers << env.request_headers["X-Files-Workspace-Id"]
|
|
420
|
+
[ 200, { "Content-Type" => "application/json" }, { id: 1 }.to_json ]
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
end
|
|
424
|
+
find_workspace = ->(client, **options) { Files::Workspace.find(1, {}, api_key: "key", client: client, **options) }
|
|
425
|
+
Files.workspace_id = 5
|
|
426
|
+
client_a = described_class.new(connection, workspace_id: 0)
|
|
427
|
+
client_b = described_class.new(connection, workspace_id: 7)
|
|
428
|
+
|
|
429
|
+
find_workspace.call(client_a)
|
|
430
|
+
find_workspace.call(client_b)
|
|
431
|
+
Files.workspace_id = 6
|
|
432
|
+
find_workspace.call(client_a)
|
|
433
|
+
find_workspace.call(described_class.new(connection))
|
|
434
|
+
find_workspace.call(described_class.new(connection, workspace_id: nil))
|
|
435
|
+
find_workspace.call(client_b, workspace_id: 0)
|
|
436
|
+
find_workspace.call(client_b, workspace_id: "")
|
|
437
|
+
find_workspace.call(client_b, workspace_id: nil)
|
|
438
|
+
|
|
439
|
+
expect(workspace_headers).to eq([ "0", "7", "0", "6", nil, "0", nil, "7" ])
|
|
440
|
+
expect(Files.workspace_id).to eq(6)
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
describe "User-Agent" do
|
|
445
|
+
it "reports the SDK version the package declares" do
|
|
446
|
+
package_version = Gem::Specification.load(File.expand_path("../../files.com.gemspec", __dir__)).version.to_s
|
|
447
|
+
user_agent = described_class.new.send(:request_headers, nil, nil, :get, nil)["User-Agent"]
|
|
448
|
+
|
|
449
|
+
expect(user_agent).to match(/\AFiles\.com Ruby SDK v#{Regexp.escape(package_version)}(?: |\z)/)
|
|
450
|
+
end
|
|
451
|
+
end
|
|
452
|
+
|
|
405
453
|
describe "network timeouts" do
|
|
406
454
|
around do |example|
|
|
407
455
|
original = [ Files.open_timeout, Files.read_timeout ]
|