volcano-sdk 0.29.0 → 0.31.0
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/volcano/auth.rb +10 -47
- data/lib/volcano/auth_email_change.rb +1 -1
- data/lib/volcano/auth_get_user.rb +36 -77
- data/lib/volcano/auth_notification_dispatch.rb +16 -0
- data/lib/volcano/auth_oauth.rb +4 -0
- data/lib/volcano/auth_oauth_api.rb +8 -3
- data/lib/volcano/auth_oauth_sign_in.rb +1 -1
- data/lib/volcano/auth_oauth_token.rb +2 -0
- data/lib/volcano/auth_profile_fields.rb +98 -0
- data/lib/volcano/auth_refresh.rb +29 -32
- data/lib/volcano/auth_session_binding.rb +25 -0
- data/lib/volcano/auth_session_construction.rb +67 -0
- data/lib/volcano/auth_sessions.rb +9 -45
- data/lib/volcano/auth_sign_out.rb +22 -14
- data/lib/volcano/auth_sign_up.rb +2 -0
- data/lib/volcano/auth_state.rb +3 -2
- data/lib/volcano/auth_state_notifications.rb +7 -4
- data/lib/volcano/auth_update_user.rb +1 -1
- data/lib/volcano/session.rb +0 -73
- data/lib/volcano/session_credentials.rb +82 -0
- data/lib/volcano/session_operations.rb +13 -6
- data/lib/volcano/session_page_mapping.rb +89 -0
- data/lib/volcano/storage.rb +18 -34
- data/lib/volcano/storage_models.rb +18 -5
- data/lib/volcano/storage_mutations.rb +8 -3
- data/lib/volcano/storage_object_response.rb +88 -0
- data/lib/volcano/storage_response.rb +92 -0
- data/lib/volcano/storage_resumable_upload.rb +13 -2
- data/lib/volcano/storage_session_adapter.rb +61 -0
- data/lib/volcano/storage_transport_adapter.rb +73 -0
- data/lib/volcano/storage_upload_models.rb +51 -27
- data/lib/volcano/storage_upload_sessions.rb +1 -35
- data/lib/volcano/version.rb +1 -1
- data/lib/volcano.rb +18 -7
- data/sig/auth_credentials.rbs +15 -0
- data/sig/auth_oauth.rbs +16 -0
- data/sig/auth_profile.rbs +10 -0
- data/sig/auth_sessions.rbs +7 -0
- data/sig/auth_subscription.rbs +6 -0
- data/sig/session.rbs +1 -1
- data/sig/storage.rbs +29 -0
- data/sig/storage_records.rbs +3 -1
- data/sig/upload_session_status.rbs +3 -1
- metadata +17 -1
|
@@ -11,7 +11,9 @@ module Volcano
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def move(from_path, to_path)
|
|
14
|
-
|
|
14
|
+
paths = storage_paths([from_path, to_path])
|
|
15
|
+
source = paths.fetch(0)
|
|
16
|
+
destination = paths.fetch(1)
|
|
15
17
|
response = storage_request do |token|
|
|
16
18
|
@transport.move_storage_object(
|
|
17
19
|
authorization: token,
|
|
@@ -24,7 +26,9 @@ module Volcano
|
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
def copy(from_path, to_path)
|
|
27
|
-
|
|
29
|
+
paths = storage_paths([from_path, to_path])
|
|
30
|
+
source = paths.fetch(0)
|
|
31
|
+
destination = paths.fetch(1)
|
|
28
32
|
response = storage_request do |token|
|
|
29
33
|
@transport.copy_storage_object(
|
|
30
34
|
authorization: token,
|
|
@@ -75,7 +79,8 @@ module Volcano
|
|
|
75
79
|
end
|
|
76
80
|
|
|
77
81
|
def visibility_value(value)
|
|
78
|
-
return
|
|
82
|
+
return true if value == true
|
|
83
|
+
return false if value == false
|
|
79
84
|
|
|
80
85
|
raise ArgumentError, 'public must be true or false'
|
|
81
86
|
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Volcano
|
|
4
|
+
# Validates object metadata and paginated storage responses.
|
|
5
|
+
module StorageObjectResponse
|
|
6
|
+
include StorageResponse
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def storage_object(payload)
|
|
11
|
+
payload = storage_payload(payload)
|
|
12
|
+
required = storage_object_required(payload)
|
|
13
|
+
optional = storage_object_optional(payload)
|
|
14
|
+
StorageObject.new(
|
|
15
|
+
id: required.fetch(0), bucket_id: required.fetch(1), name: required.fetch(2),
|
|
16
|
+
size: required.fetch(3), mime_type: required.fetch(4), is_public: required.fetch(5),
|
|
17
|
+
owner_id: optional.fetch(0), etag: optional.fetch(1), metadata: optional.fetch(2),
|
|
18
|
+
created_at: optional.fetch(3), updated_at: optional.fetch(4), public_url: optional.fetch(5)
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def storage_object_required(payload)
|
|
23
|
+
[
|
|
24
|
+
storage_string(payload.fetch('id')), storage_string(payload.fetch('bucket_id')),
|
|
25
|
+
storage_string(payload.fetch('name')), storage_integer(payload.fetch('size')),
|
|
26
|
+
storage_string(payload.fetch('mime_type')), storage_boolean(payload.fetch('is_public'))
|
|
27
|
+
]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def storage_object_optional(payload)
|
|
31
|
+
[
|
|
32
|
+
storage_optional_string(payload['owner_id']), storage_optional_string(payload['etag']),
|
|
33
|
+
storage_optional_metadata(payload['metadata']), storage_optional_time(payload['created_at']),
|
|
34
|
+
storage_optional_time(payload['updated_at']), storage_optional_string(payload['public_url'])
|
|
35
|
+
]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def storage_object_list(value)
|
|
39
|
+
raise Error::TransportError, 'invalid storage objects' unless value.is_a?(Array)
|
|
40
|
+
|
|
41
|
+
value.map { |object| storage_object(object) }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def storage_cursor(value)
|
|
45
|
+
return if value.nil? || value == ''
|
|
46
|
+
|
|
47
|
+
storage_string(value)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def storage_boolean(value)
|
|
51
|
+
return true if value == true
|
|
52
|
+
return false if value == false
|
|
53
|
+
|
|
54
|
+
raise Error::TransportError, 'invalid storage boolean'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def storage_optional_string(value)
|
|
58
|
+
value.nil? ? nil : storage_string(value)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def storage_optional_time(value)
|
|
62
|
+
value.nil? ? nil : storage_time(value)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def storage_optional_metadata(value)
|
|
66
|
+
value.nil? ? nil : storage_json_hash(value)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def storage_json_hash(value)
|
|
70
|
+
raise Error::TransportError, 'invalid storage JSON object' unless value.is_a?(Hash)
|
|
71
|
+
|
|
72
|
+
value.to_h do |key, item|
|
|
73
|
+
raise Error::TransportError, 'invalid storage JSON key' unless key.is_a?(String)
|
|
74
|
+
|
|
75
|
+
[key, storage_json_value(item)]
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def storage_json_value(value)
|
|
80
|
+
case value
|
|
81
|
+
when NilClass, TrueClass, FalseClass, Integer, Float, String then value
|
|
82
|
+
when Array then value.map { |item| storage_json_value(item) }
|
|
83
|
+
when Hash then storage_json_hash(value)
|
|
84
|
+
else raise Error::TransportError, 'invalid storage JSON value'
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Volcano
|
|
4
|
+
# Decodes resumable-upload responses before creating public records.
|
|
5
|
+
module StorageResponse
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def upload_session(payload)
|
|
9
|
+
payload = storage_payload(payload)
|
|
10
|
+
UploadSession.new(
|
|
11
|
+
session_id: storage_string(payload.fetch('session_id')),
|
|
12
|
+
part_size: storage_integer(payload.fetch('part_size')),
|
|
13
|
+
total_parts: storage_integer(payload.fetch('total_parts')),
|
|
14
|
+
expires_at: storage_time(payload.fetch('expires_at'))
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def upload_part_metadata(payload)
|
|
19
|
+
payload = storage_payload(payload)
|
|
20
|
+
UploadPart.new(
|
|
21
|
+
part_number: storage_integer(payload.fetch('part_number')),
|
|
22
|
+
etag: storage_string(payload.fetch('etag')),
|
|
23
|
+
size: storage_integer(payload.fetch('size'))
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def upload_session_status(payload)
|
|
28
|
+
payload = storage_payload(payload)
|
|
29
|
+
text = storage_status_text(payload)
|
|
30
|
+
counts = storage_status_counts(payload)
|
|
31
|
+
storage_status_record(payload, text, counts)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def storage_status_record(payload, text, counts)
|
|
35
|
+
UploadSessionStatus.new(
|
|
36
|
+
session_id: text.fetch(0), status: text.fetch(1), path: text.fetch(2),
|
|
37
|
+
content_type: text.fetch(3), total_size: counts.fetch(0), part_size: counts.fetch(1),
|
|
38
|
+
total_parts: counts.fetch(2), parts_uploaded: counts.fetch(3),
|
|
39
|
+
bytes_uploaded: counts.fetch(4), parts: storage_parts(payload.fetch('parts', [])),
|
|
40
|
+
expires_at: storage_time(payload.fetch('expires_at')),
|
|
41
|
+
created_at: storage_time(payload.fetch('created_at'))
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def storage_status_text(payload)
|
|
46
|
+
[
|
|
47
|
+
storage_string(payload.fetch('session_id')), storage_string(payload.fetch('status')),
|
|
48
|
+
storage_string(payload.fetch('path')), storage_string(payload.fetch('content_type'))
|
|
49
|
+
]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def storage_status_counts(payload)
|
|
53
|
+
[
|
|
54
|
+
storage_integer(payload.fetch('total_size')), storage_integer(payload.fetch('part_size')),
|
|
55
|
+
storage_integer(payload.fetch('total_parts')), storage_integer(payload.fetch('parts_uploaded')),
|
|
56
|
+
storage_integer(payload.fetch('bytes_uploaded'))
|
|
57
|
+
]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def storage_parts(value)
|
|
61
|
+
raise Error::TransportError, 'invalid upload parts' unless value.is_a?(Array)
|
|
62
|
+
|
|
63
|
+
value.map { |part| upload_part_metadata(part) }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def storage_payload(value)
|
|
67
|
+
raise Error::TransportError, 'invalid storage response' unless value.is_a?(Hash)
|
|
68
|
+
raise Error::TransportError, 'invalid storage response key' unless value.keys.all?(String)
|
|
69
|
+
|
|
70
|
+
value
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def storage_string(value)
|
|
74
|
+
raise Error::TransportError, 'invalid storage string' unless value.is_a?(String)
|
|
75
|
+
|
|
76
|
+
value
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def storage_integer(value)
|
|
80
|
+
raise Error::TransportError, 'invalid storage integer' unless value.is_a?(Integer)
|
|
81
|
+
|
|
82
|
+
value
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def storage_time(value)
|
|
86
|
+
return value if value.is_a?(Time)
|
|
87
|
+
return Time.iso8601(value) if value.is_a?(String)
|
|
88
|
+
|
|
89
|
+
raise Error::TransportError, 'invalid storage time'
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -30,7 +30,7 @@ module Volcano
|
|
|
30
30
|
def upload_session_parts(path, source, session, total_size, on_progress)
|
|
31
31
|
uploaded = 0
|
|
32
32
|
session.total_parts.times do |part_index|
|
|
33
|
-
part = source.read(session.part_size)
|
|
33
|
+
part = source.read(session.part_size) || raise(IOError, 'upload source ended before completion')
|
|
34
34
|
upload_part(
|
|
35
35
|
path,
|
|
36
36
|
session_id: session.session_id,
|
|
@@ -64,11 +64,22 @@ module Volcano
|
|
|
64
64
|
def remaining_upload_bytes(source)
|
|
65
65
|
return unless source.respond_to?(:size) && source.respond_to?(:pos)
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
dimensions = upload_source_dimensions(source)
|
|
68
|
+
return unless dimensions
|
|
69
|
+
|
|
70
|
+
dimensions.fetch(0) - dimensions.fetch(1)
|
|
68
71
|
rescue IOError, SystemCallError
|
|
69
72
|
nil
|
|
70
73
|
end
|
|
71
74
|
|
|
75
|
+
def upload_source_dimensions(source)
|
|
76
|
+
size = source.method(:size).call
|
|
77
|
+
position = source.method(:pos).call
|
|
78
|
+
return unless size.is_a?(Integer) && position.is_a?(Integer)
|
|
79
|
+
|
|
80
|
+
[size, position]
|
|
81
|
+
end
|
|
82
|
+
|
|
72
83
|
def with_spooled_upload_source(source)
|
|
73
84
|
Tempfile.create('volcano-upload') do |file|
|
|
74
85
|
file.binmode
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Volcano
|
|
4
|
+
# Validates the client methods that storage uses for session-scoped requests.
|
|
5
|
+
class StorageSessionAdapter
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def capture_session_binding
|
|
11
|
+
binding = storage_binding_array(@client.method(:capture_session_binding).call)
|
|
12
|
+
generation, owner, session = binding
|
|
13
|
+
[storage_generation(generation), storage_owner(owner), storage_session(session)]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def session_token
|
|
17
|
+
token = @client.method(:session_token).call
|
|
18
|
+
raise Error::TransportError, 'invalid storage session token' unless token.is_a?(String)
|
|
19
|
+
|
|
20
|
+
token
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def session_request(binding:, &)
|
|
24
|
+
method_name = :session_request
|
|
25
|
+
response = @client.public_send(method_name, binding: binding) do |token|
|
|
26
|
+
raise Error::TransportError, 'invalid storage session token' unless token.is_a?(String)
|
|
27
|
+
|
|
28
|
+
yield token
|
|
29
|
+
end
|
|
30
|
+
raise Error::TransportError, 'invalid storage session response' unless response.is_a?(Transport::Response)
|
|
31
|
+
|
|
32
|
+
response
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def storage_binding_array(value)
|
|
38
|
+
raise Error::TransportError, 'invalid storage session binding' unless value.is_a?(Array) && value.size == 3
|
|
39
|
+
|
|
40
|
+
value
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def storage_generation(value)
|
|
44
|
+
raise Error::TransportError, 'invalid storage session binding' unless value.is_a?(Integer)
|
|
45
|
+
|
|
46
|
+
value
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def storage_owner(value)
|
|
50
|
+
raise Error::TransportError, 'invalid storage session binding' unless value.is_a?(SessionOperations)
|
|
51
|
+
|
|
52
|
+
value
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def storage_session(value)
|
|
56
|
+
raise Error::TransportError, 'invalid storage session binding' unless value.nil? || value.is_a?(Session)
|
|
57
|
+
|
|
58
|
+
value
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Volcano
|
|
4
|
+
# Narrows generated and test transport calls to checked storage responses.
|
|
5
|
+
class StorageTransportAdapter
|
|
6
|
+
def initialize(transport)
|
|
7
|
+
@transport = transport
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def upload_storage_object(authorization:, bucket_name:, path:, data:, content_type:)
|
|
11
|
+
invoke(:upload_storage_object, authorization: authorization, bucket_name: bucket_name,
|
|
12
|
+
path: path, data: data, content_type: content_type)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def download_storage_object(authorization:, bucket_name:, path:, byte_range:)
|
|
16
|
+
invoke(:download_storage_object, authorization: authorization, bucket_name: bucket_name,
|
|
17
|
+
path: path, byte_range: byte_range)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def list_storage_objects(authorization:, bucket_name:, prefix:, limit:, cursor:)
|
|
21
|
+
invoke(:list_storage_objects, authorization: authorization, bucket_name: bucket_name,
|
|
22
|
+
prefix: prefix, limit: limit, cursor: cursor)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def delete_storage_object(authorization:, bucket_name:, path:)
|
|
26
|
+
invoke(:delete_storage_object, authorization: authorization, bucket_name: bucket_name, path: path)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def move_storage_object(authorization:, bucket_name:, from_path:, to_path:)
|
|
30
|
+
invoke(:move_storage_object, authorization: authorization, bucket_name: bucket_name,
|
|
31
|
+
from_path: from_path, to_path: to_path)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def copy_storage_object(authorization:, bucket_name:, from_path:, to_path:)
|
|
35
|
+
invoke(:copy_storage_object, authorization: authorization, bucket_name: bucket_name,
|
|
36
|
+
from_path: from_path, to_path: to_path)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def update_storage_object_visibility(authorization:, bucket_name:, path:, is_public:)
|
|
40
|
+
invoke(:update_storage_object_visibility, authorization: authorization, bucket_name: bucket_name,
|
|
41
|
+
path: path, is_public: is_public)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def create_upload_session(authorization:, bucket_name:, request:)
|
|
45
|
+
invoke(:create_upload_session, authorization: authorization, bucket_name: bucket_name, request: request)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def upload_part(authorization:, bucket_name:, request:)
|
|
49
|
+
invoke(:upload_part, authorization: authorization, bucket_name: bucket_name, request: request)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def complete_upload_session(authorization:, bucket_name:, request:)
|
|
53
|
+
invoke(:complete_upload_session, authorization: authorization, bucket_name: bucket_name, request: request)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def get_upload_session(authorization:, bucket_name:, request:)
|
|
57
|
+
invoke(:get_upload_session, authorization: authorization, bucket_name: bucket_name, request: request)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def abort_upload_session(authorization:, bucket_name:, request:)
|
|
61
|
+
invoke(:abort_upload_session, authorization: authorization, bucket_name: bucket_name, request: request)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
def invoke(name, **arguments)
|
|
67
|
+
response = @transport.public_send(name, **arguments)
|
|
68
|
+
raise Error::TransportError, 'invalid storage transport response' unless response.is_a?(Transport::Response)
|
|
69
|
+
|
|
70
|
+
response
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -1,51 +1,68 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Volcano
|
|
4
|
-
UploadSessionRequest = Data.define(:path, :content_type, :total_size, :part_size)
|
|
4
|
+
UploadSessionRequest = Data.define(:path, :content_type, :total_size, :part_size)
|
|
5
|
+
|
|
6
|
+
# Freezes the arguments sent to create a resumable upload.
|
|
7
|
+
class UploadSessionRequest
|
|
8
|
+
# @dynamic path, content_type, total_size, part_size
|
|
5
9
|
def initialize(path:, content_type:, total_size:, part_size: nil)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
total_size: total_size,
|
|
10
|
-
part_size: part_size
|
|
11
|
-
)
|
|
10
|
+
path = path.dup.freeze
|
|
11
|
+
content_type = content_type.dup.freeze
|
|
12
|
+
super
|
|
12
13
|
end
|
|
13
14
|
end
|
|
14
15
|
private_constant :UploadSessionRequest
|
|
15
16
|
|
|
16
|
-
UploadPartRequest = Data.define(:path, :session_id, :part_number, :data)
|
|
17
|
+
UploadPartRequest = Data.define(:path, :session_id, :part_number, :data)
|
|
18
|
+
|
|
19
|
+
# Freezes one resumable upload part before transport dispatch.
|
|
20
|
+
class UploadPartRequest
|
|
21
|
+
# @dynamic path, session_id, part_number, data
|
|
17
22
|
def initialize(path:, session_id:, part_number:, data:)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
data: data.dup.freeze
|
|
23
|
-
)
|
|
23
|
+
path = path.dup.freeze
|
|
24
|
+
session_id = session_id.dup.freeze
|
|
25
|
+
data = data.dup.freeze
|
|
26
|
+
super
|
|
24
27
|
end
|
|
25
28
|
end
|
|
26
29
|
private_constant :UploadPartRequest
|
|
27
30
|
|
|
28
|
-
UploadSessionReference = Data.define(:path, :session_id)
|
|
31
|
+
UploadSessionReference = Data.define(:path, :session_id)
|
|
32
|
+
|
|
33
|
+
# Freezes the path and identifier used for upload session operations.
|
|
34
|
+
class UploadSessionReference
|
|
35
|
+
# @dynamic path, session_id
|
|
29
36
|
def initialize(path:, session_id:)
|
|
30
|
-
|
|
37
|
+
path = path.dup.freeze
|
|
38
|
+
session_id = session_id.dup.freeze
|
|
39
|
+
super
|
|
31
40
|
end
|
|
32
41
|
end
|
|
33
42
|
private_constant :UploadSessionReference
|
|
34
43
|
|
|
35
|
-
UploadSession = Data.define(:session_id, :part_size, :total_parts, :expires_at)
|
|
44
|
+
UploadSession = Data.define(:session_id, :part_size, :total_parts, :expires_at)
|
|
45
|
+
|
|
46
|
+
# Describes a newly created upload session.
|
|
47
|
+
class UploadSession
|
|
48
|
+
# @dynamic session_id, part_size, total_parts, expires_at, members, with, to_h, deconstruct, deconstruct_keys
|
|
49
|
+
# @dynamic self.[], self.members
|
|
36
50
|
def initialize(session_id:, part_size:, total_parts:, expires_at:)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
total_parts: total_parts,
|
|
41
|
-
expires_at: expires_at.dup.freeze
|
|
42
|
-
)
|
|
51
|
+
session_id = session_id.dup.freeze
|
|
52
|
+
expires_at = expires_at.dup.freeze
|
|
53
|
+
super
|
|
43
54
|
end
|
|
44
55
|
end
|
|
45
56
|
|
|
46
|
-
UploadPart = Data.define(:part_number, :etag, :size)
|
|
57
|
+
UploadPart = Data.define(:part_number, :etag, :size)
|
|
58
|
+
|
|
59
|
+
# Describes an accepted upload part.
|
|
60
|
+
class UploadPart
|
|
61
|
+
# @dynamic part_number, etag, size, members, with, to_h, deconstruct, deconstruct_keys
|
|
62
|
+
# @dynamic self.[], self.members
|
|
47
63
|
def initialize(part_number:, etag:, size:)
|
|
48
|
-
|
|
64
|
+
etag = etag.dup.freeze
|
|
65
|
+
super
|
|
49
66
|
end
|
|
50
67
|
end
|
|
51
68
|
|
|
@@ -55,7 +72,13 @@ module Volcano
|
|
|
55
72
|
].freeze
|
|
56
73
|
private_constant :UPLOAD_SESSION_STATUS_ATTRIBUTES
|
|
57
74
|
|
|
58
|
-
UploadSessionStatus = Data.define(*UPLOAD_SESSION_STATUS_ATTRIBUTES)
|
|
75
|
+
UploadSessionStatus = Data.define(*UPLOAD_SESSION_STATUS_ATTRIBUTES)
|
|
76
|
+
|
|
77
|
+
# Freezes upload progress returned by storage.
|
|
78
|
+
class UploadSessionStatus
|
|
79
|
+
# @dynamic session_id, status, path, content_type, total_size, part_size
|
|
80
|
+
# @dynamic total_parts, parts_uploaded, bytes_uploaded, parts, expires_at, created_at
|
|
81
|
+
# @dynamic members, with, to_h, deconstruct, deconstruct_keys, self.[], self.members
|
|
59
82
|
def initialize(**attributes)
|
|
60
83
|
unknown = attributes.keys - UPLOAD_SESSION_STATUS_ATTRIBUTES
|
|
61
84
|
raise ArgumentError, "unknown keywords: #{unknown.join(', ')}" unless unknown.empty?
|
|
@@ -66,7 +89,8 @@ module Volcano
|
|
|
66
89
|
values = UPLOAD_SESSION_STATUS_ATTRIBUTES.to_h do |name|
|
|
67
90
|
[name, immutable_value(attributes.fetch(name))]
|
|
68
91
|
end
|
|
69
|
-
|
|
92
|
+
attributes = values
|
|
93
|
+
super
|
|
70
94
|
end
|
|
71
95
|
|
|
72
96
|
private
|
|
@@ -51,7 +51,7 @@ module Volcano
|
|
|
51
51
|
request: request
|
|
52
52
|
)
|
|
53
53
|
end
|
|
54
|
-
storage_object(Transport.body(response, 200).fetch('object'))
|
|
54
|
+
storage_object(storage_payload(Transport.body(response, 200)).fetch('object'))
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def get_upload_session(path, session_id:)
|
|
@@ -78,39 +78,5 @@ module Volcano
|
|
|
78
78
|
Transport.body(response, 200)
|
|
79
79
|
nil
|
|
80
80
|
end
|
|
81
|
-
|
|
82
|
-
private
|
|
83
|
-
|
|
84
|
-
def upload_session(payload)
|
|
85
|
-
UploadSession.new(
|
|
86
|
-
session_id: payload.fetch('session_id'),
|
|
87
|
-
part_size: payload.fetch('part_size'),
|
|
88
|
-
total_parts: payload.fetch('total_parts'),
|
|
89
|
-
expires_at: parse_time(payload.fetch('expires_at'))
|
|
90
|
-
)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def upload_part_metadata(payload)
|
|
94
|
-
UploadPart.new(
|
|
95
|
-
part_number: payload.fetch('part_number'),
|
|
96
|
-
etag: payload.fetch('etag'),
|
|
97
|
-
size: payload.fetch('size')
|
|
98
|
-
)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def upload_session_status(payload)
|
|
102
|
-
attributes = upload_session_status_attributes(payload)
|
|
103
|
-
attributes[:parts] = attributes.fetch(:parts).map { |part| upload_part_metadata(part) }
|
|
104
|
-
attributes[:expires_at] = parse_time(attributes.fetch(:expires_at))
|
|
105
|
-
attributes[:created_at] = parse_time(attributes.fetch(:created_at))
|
|
106
|
-
UploadSessionStatus.new(**attributes)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def upload_session_status_attributes(payload)
|
|
110
|
-
UPLOAD_SESSION_STATUS_ATTRIBUTES.to_h do |name|
|
|
111
|
-
value = name == :parts ? payload.fetch(name.to_s, []) : payload.fetch(name.to_s)
|
|
112
|
-
[name, value]
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
81
|
end
|
|
116
82
|
end
|
data/lib/volcano/version.rb
CHANGED
data/lib/volcano.rb
CHANGED
|
@@ -5,6 +5,7 @@ require_relative 'volcano/connection_string'
|
|
|
5
5
|
require_relative 'volcano/models'
|
|
6
6
|
require_relative 'volcano/user'
|
|
7
7
|
require_relative 'volcano/session'
|
|
8
|
+
require_relative 'volcano/session_credentials'
|
|
8
9
|
require_relative 'volcano/function_response'
|
|
9
10
|
require_relative 'volcano/durable_models'
|
|
10
11
|
require_relative 'volcano/log_responses'
|
|
@@ -16,16 +17,22 @@ require_relative 'volcano/errors'
|
|
|
16
17
|
require_relative 'volcano/redaction'
|
|
17
18
|
require_relative 'volcano/transport'
|
|
18
19
|
require_relative 'volcano/generated_transport'
|
|
19
|
-
require_relative 'volcano/
|
|
20
|
+
require_relative 'volcano/auth_notification_dispatch'
|
|
21
|
+
require_relative 'volcano/auth_session_binding'
|
|
20
22
|
require_relative 'volcano/auth_sign_out'
|
|
21
23
|
require_relative 'volcano/auth_refresh'
|
|
24
|
+
require_relative 'volcano/auth_profile_fields'
|
|
25
|
+
require_relative 'volcano/auth_get_user'
|
|
26
|
+
require_relative 'volcano/auth_update_user'
|
|
27
|
+
require_relative 'volcano/auth_email_change'
|
|
28
|
+
require_relative 'volcano/auth_sessions'
|
|
29
|
+
require_relative 'volcano/auth_session_construction'
|
|
30
|
+
require_relative 'volcano/auth'
|
|
22
31
|
require_relative 'volcano/auth_sign_up'
|
|
23
32
|
require_relative 'volcano/sign_up_result'
|
|
24
33
|
require_relative 'volcano/auth_anonymous'
|
|
25
34
|
require_relative 'volcano/auth_confirm_email'
|
|
26
35
|
require_relative 'volcano/auth_resend_confirmation'
|
|
27
|
-
require_relative 'volcano/auth_email_change'
|
|
28
|
-
require_relative 'volcano/auth_sessions'
|
|
29
36
|
require_relative 'volcano/auth_oauth'
|
|
30
37
|
require_relative 'volcano/auth_oauth_sign_in'
|
|
31
38
|
require_relative 'volcano/auth_hosted'
|
|
@@ -33,13 +40,15 @@ require_relative 'volcano/auth_oauth_token'
|
|
|
33
40
|
require_relative 'volcano/auth_oauth_api'
|
|
34
41
|
require_relative 'volcano/auth_reset_password_for_email'
|
|
35
42
|
require_relative 'volcano/auth_reset_password'
|
|
36
|
-
require_relative 'volcano/auth_get_user'
|
|
37
|
-
require_relative 'volcano/auth_update_user'
|
|
38
43
|
require_relative 'volcano/database'
|
|
39
44
|
require_relative 'volcano/function_resolution'
|
|
40
45
|
require_relative 'volcano/functions'
|
|
41
46
|
require_relative 'volcano/durable'
|
|
42
47
|
require_relative 'volcano/logs'
|
|
48
|
+
require_relative 'volcano/storage_session_adapter'
|
|
49
|
+
require_relative 'volcano/storage_transport_adapter'
|
|
50
|
+
require_relative 'volcano/storage_response'
|
|
51
|
+
require_relative 'volcano/storage_object_response'
|
|
43
52
|
require_relative 'volcano/storage'
|
|
44
53
|
require_relative 'volcano/storage_upload_sessions'
|
|
45
54
|
require_relative 'volcano/storage_resumable_upload'
|
|
@@ -58,8 +67,10 @@ require_relative 'volcano/client'
|
|
|
58
67
|
|
|
59
68
|
# Public namespace for the Volcano Ruby SDK.
|
|
60
69
|
module Volcano
|
|
61
|
-
private_constant :
|
|
62
|
-
:
|
|
70
|
+
private_constant :AuthRefresh, :AuthSignOut, :AuthProfile, :AuthProfileFields, :AuthUpdateUser, :AuthEmailChange,
|
|
71
|
+
:AuthSessions, :AuthSessionConstruction,
|
|
72
|
+
:GeneratedTransport, :LockAutoRenewal, :LockLeaseClock, :LockRenewer,
|
|
73
|
+
:LockSession, :LockResponse, :Redaction, :SessionOperations
|
|
63
74
|
|
|
64
75
|
Realtime.private_constant :Protocol, :ProtocolDispatch, :ProtocolPublicationDispatch, :ProtocolRecovery,
|
|
65
76
|
:ProtocolRecoveryDispatch, :ProtocolRecoveryPosition
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Volcano
|
|
2
|
+
class Auth
|
|
3
|
+
def current_session: () -> Session?
|
|
4
|
+
def current_session=: (Session session) -> void
|
|
5
|
+
def on_auth_state_change: () { (Symbol, Session?) -> void } -> AuthSubscription
|
|
6
|
+
def sign_in: (email: String, password: String) -> Session
|
|
7
|
+
def sign_up: (email: String, password: String, ?metadata: session_user_input, ?sign_in_when_allowed: bool) -> SignUpResult
|
|
8
|
+
def sign_in_anonymously: (?metadata: session_user_input) -> Session
|
|
9
|
+
def convert_anonymous: (email: String, password: String, ?metadata: session_user_input) -> User
|
|
10
|
+
def confirm_email: (token: String) -> nil
|
|
11
|
+
def resend_confirmation: (email: String) -> nil
|
|
12
|
+
def reset_password_for_email: (email: String) -> nil
|
|
13
|
+
def reset_password: (token: String, new_password: String) -> nil
|
|
14
|
+
end
|
|
15
|
+
end
|
data/sig/auth_oauth.rbs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Volcano
|
|
2
|
+
type oauth_api_input = session_input
|
|
3
|
+
|
|
4
|
+
class Auth
|
|
5
|
+
def list_linked_oauth_providers: () -> Array[LinkedOAuthProvider]
|
|
6
|
+
def link_oauth_provider: (String provider) -> String
|
|
7
|
+
def unlink_oauth_provider: (String provider) -> nil
|
|
8
|
+
def get_oauth_provider_token: (String provider) -> OAuthProviderTokenStatus
|
|
9
|
+
def refresh_oauth_provider_token: (String provider) -> OAuthProviderTokenStatus
|
|
10
|
+
def call_oauth_api: (String provider, endpoint: String, ?method: String, ?body: oauth_api_input) -> Object?
|
|
11
|
+
def sign_in_with_oauth: (String provider, redirect_to: String, state: String) -> String
|
|
12
|
+
def exchange_oauth_code: (code: String, redirect_to: String, state: String, expected_state: String) -> Session
|
|
13
|
+
def get_hosted_auth_url: (project_id: String, state: String, ?action: String) -> String
|
|
14
|
+
def adopt_hosted_auth_session: (Session session, state: String, expected_state: String) -> Session
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module Volcano
|
|
2
|
+
class Auth
|
|
3
|
+
def user: () -> User
|
|
4
|
+
def get_user: () -> User
|
|
5
|
+
def update_user: (?password: String?, ?metadata: session_user_input?) -> User
|
|
6
|
+
def request_email_change: (new_email: String) -> EmailChangeResult
|
|
7
|
+
def cancel_email_change: () -> nil
|
|
8
|
+
def confirm_email_change: (token: String) -> User
|
|
9
|
+
end
|
|
10
|
+
end
|