moonbase-sdk 0.1.0.pre.alpha.3 → 0.1.0.pre.alpha.5
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/CHANGELOG.md +54 -0
- data/README.md +23 -1
- data/lib/moonbase/errors.rb +25 -11
- data/lib/moonbase/file_part.rb +10 -7
- data/lib/moonbase/internal/cursor_page.rb +1 -1
- data/lib/moonbase/internal/transport/base_client.rb +18 -8
- data/lib/moonbase/internal/transport/pooled_net_requester.rb +40 -33
- data/lib/moonbase/internal/type/base_page.rb +1 -1
- data/lib/moonbase/internal/type/file_input.rb +7 -4
- data/lib/moonbase/internal/util.rb +8 -7
- data/lib/moonbase/models/choice_field_option.rb +4 -4
- data/lib/moonbase/models/file_upload_params.rb +42 -0
- data/lib/moonbase/models/inbox.rb +7 -7
- data/lib/moonbase/models/inbox_list_params.rb +1 -1
- data/lib/moonbase/models/inbox_retrieve_params.rb +3 -3
- data/lib/moonbase/models/meeting.rb +61 -7
- data/lib/moonbase/models/meeting_list_params.rb +29 -1
- data/lib/moonbase/models/meeting_retrieve_params.rb +1 -0
- data/lib/moonbase/models/meeting_update_params.rb +98 -0
- data/lib/moonbase/models/moonbase_file.rb +9 -1
- data/lib/moonbase/models.rb +4 -0
- data/lib/moonbase/resources/files.rb +30 -0
- data/lib/moonbase/resources/meetings.rb +24 -1
- data/lib/moonbase/version.rb +1 -1
- data/lib/moonbase.rb +3 -0
- data/manifest.yaml +1 -0
- data/rbi/moonbase/errors.rbi +29 -2
- data/rbi/moonbase/file_part.rbi +1 -1
- data/rbi/moonbase/internal/transport/base_client.rbi +9 -5
- data/rbi/moonbase/internal/transport/pooled_net_requester.rbi +6 -2
- data/rbi/moonbase/internal/type/base_model.rbi +8 -4
- data/rbi/moonbase/internal/type/base_page.rbi +1 -1
- data/rbi/moonbase/internal/util.rbi +1 -1
- data/rbi/moonbase/models/choice_field_option.rbi +4 -6
- data/rbi/moonbase/models/file_upload_params.rbi +67 -0
- data/rbi/moonbase/models/inbox.rbi +11 -11
- data/rbi/moonbase/models/inbox_list_params.rbi +2 -2
- data/rbi/moonbase/models/inbox_retrieve_params.rbi +5 -5
- data/rbi/moonbase/models/meeting.rbi +124 -11
- data/rbi/moonbase/models/meeting_list_params.rbi +69 -0
- data/rbi/moonbase/models/meeting_retrieve_params.rbi +5 -0
- data/rbi/moonbase/models/meeting_update_params.rbi +177 -0
- data/rbi/moonbase/models/moonbase_file.rbi +8 -0
- data/rbi/moonbase/models.rbi +4 -0
- data/rbi/moonbase/resources/files.rbi +21 -0
- data/rbi/moonbase/resources/inboxes.rbi +1 -1
- data/rbi/moonbase/resources/meetings.rbi +13 -0
- data/sig/moonbase/errors.rbs +7 -0
- data/sig/moonbase/file_part.rbs +1 -1
- data/sig/moonbase/internal/transport/base_client.rbs +2 -0
- data/sig/moonbase/internal/transport/pooled_net_requester.rbs +4 -1
- data/sig/moonbase/models/choice_field_option.rbs +4 -4
- data/sig/moonbase/models/file_upload_params.rbs +42 -0
- data/sig/moonbase/models/inbox.rbs +5 -5
- data/sig/moonbase/models/inbox_list_params.rbs +2 -2
- data/sig/moonbase/models/inbox_retrieve_params.rbs +2 -2
- data/sig/moonbase/models/meeting.rbs +64 -6
- data/sig/moonbase/models/meeting_list_params.rbs +44 -1
- data/sig/moonbase/models/meeting_retrieve_params.rbs +2 -1
- data/sig/moonbase/models/meeting_update_params.rbs +115 -0
- data/sig/moonbase/models/moonbase_file.rbs +5 -0
- data/sig/moonbase/models.rbs +4 -0
- data/sig/moonbase/resources/files.rbs +7 -0
- data/sig/moonbase/resources/meetings.rbs +8 -0
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d9abd330fe8d3d9959ca6dec77410f82534e129d027cd7cc82e334b132df582
|
|
4
|
+
data.tar.gz: d0c68d2fbb0d6b9bf37b369309e1bfe079989497fd4d6d540aa82d09fb8b49b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 385f835ee07b14c3665cff1efa60ecec5d72b617f995f2882cbe69a9558c8b5a0877f94dfdd7602d989992329dddc48071f0066194f33dde1dfe6e24118a3ccc
|
|
7
|
+
data.tar.gz: 1ecace055b4932aa758e93c198332e74ef858ea0ff15460c8a2f5f1ec69869c2e10828254cbcfc33cf62ac32ac462f520096178983d10cc8944684815fc62fd4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.5 (2025-11-13)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.1.0-alpha.4...v0.1.0-alpha.5](https://github.com/moonbaseai/moonbase-sdk-ruby/compare/v0.1.0-alpha.4...v0.1.0-alpha.5)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* Add PATCH /v0/meetings/{id} ([2cb2339](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/2cb23391e356cd92aae56c0c1509f73018260482))
|
|
10
|
+
* **api:** manual updates ([fa67751](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/fa67751e7ec83a1f1ce33c47e8c94b5ab3ae31d6))
|
|
11
|
+
* **api:** update api ([e3c9ad0](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/e3c9ad0433de6cddd5f4a903d1593fac88efd9c9))
|
|
12
|
+
* expose response headers for both streams and errors ([39b34b0](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/39b34b0c68a778fd30d6349e577c8f64b1ff647d))
|
|
13
|
+
* handle thread interrupts in the core HTTP client ([ecedb52](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/ecedb5205ba87a29e5d650ca6d1600348c813c17))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* absolutely qualified uris should always override the default ([4f9d377](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/4f9d3776eec58bf9d57dd060bbd69b28c4b11acf))
|
|
19
|
+
* always send `filename=...` for multipart requests where a file is expected ([67a4aca](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/67a4aca74fb0f190800c6a514a2778453ff35c33))
|
|
20
|
+
* better thread safety via early initializing SSL store during HTTP client creation ([bd6d5d3](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/bd6d5d3ee42ef1218cebc1de4a20a7bec6df604c))
|
|
21
|
+
* coroutine leaks from connection pool ([ca7118b](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/ca7118b2108de43ef1fd07759a99cc4712777444))
|
|
22
|
+
* shorten multipart boundary sep to less than RFC specificed max length ([1325f54](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/1325f5410253d8f6bb41ef20552d95b452021185))
|
|
23
|
+
* should not reuse buffers for `IO.copy_stream` interop ([2a7f948](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/2a7f9482c054c3c7cc1a5ee89fcc10334db8f4fa))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Performance Improvements
|
|
27
|
+
|
|
28
|
+
* faster code formatting ([84f021f](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/84f021fc5251a01d8b836bcaa09de27ee8898f29))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Chores
|
|
32
|
+
|
|
33
|
+
* allow fast-format to use bsd sed as well ([80db719](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/80db719c03aad42092719fdedca8b54a1cae95cc))
|
|
34
|
+
* bump dependency version and update sorbet types ([22aaba5](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/22aaba59955a621fb070d977b654212cb1f0d45e))
|
|
35
|
+
* do not install brew dependencies in ./scripts/bootstrap by default ([91df728](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/91df728ae9d09148f185043a8193bc7235bf4884))
|
|
36
|
+
* ignore linter error for tests having large collections ([c0059a2](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/c0059a249133f0c39f08ba3a3418cfb8117e3890))
|
|
37
|
+
* **internal:** codegen related update ([dc876ed](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/dc876ed1ccfb8994dc415b23fa4b1bf3bfe6a2b0))
|
|
38
|
+
|
|
39
|
+
## 0.1.0-alpha.4 (2025-09-12)
|
|
40
|
+
|
|
41
|
+
Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/moonbaseai/moonbase-sdk-ruby/compare/v0.1.0-alpha.3...v0.1.0-alpha.4)
|
|
42
|
+
|
|
43
|
+
### Features
|
|
44
|
+
|
|
45
|
+
* Improve examples of API errors ([840de2a](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/840de2a8ea5438cc3f50f31fc13caba3469926a7))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Documentation
|
|
49
|
+
|
|
50
|
+
* improve webhook endpoints examples ([c7851fe](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/c7851fe6f336b8892ae016fdc8ac97175a71124f))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Refactors
|
|
54
|
+
|
|
55
|
+
* rename ChoiceFieldOption label to name for consistency ([0a9ef9a](https://github.com/moonbaseai/moonbase-sdk-ruby/commit/0a9ef9a75fb619b856d70c68ccb147ef5909b32a))
|
|
56
|
+
|
|
3
57
|
## 0.1.0-alpha.3 (2025-09-09)
|
|
4
58
|
|
|
5
59
|
Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/moonbaseai/moonbase-sdk-ruby/compare/v0.1.0-alpha.2...v0.1.0-alpha.3)
|
data/README.md
CHANGED
|
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
|
|
|
15
15
|
<!-- x-release-please-start-version -->
|
|
16
16
|
|
|
17
17
|
```ruby
|
|
18
|
-
gem "moonbase-sdk", "~> 0.1.0.pre.alpha.
|
|
18
|
+
gem "moonbase-sdk", "~> 0.1.0.pre.alpha.5"
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
<!-- x-release-please-end -->
|
|
@@ -63,6 +63,28 @@ if page.next_page?
|
|
|
63
63
|
end
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
+
### File uploads
|
|
67
|
+
|
|
68
|
+
Request parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more.
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
require "pathname"
|
|
72
|
+
|
|
73
|
+
# Use `Pathname` to send the filename and/or avoid paging a large file into memory:
|
|
74
|
+
moonbase_file = moonbase.files.upload(file: Pathname("/path/to/file"))
|
|
75
|
+
|
|
76
|
+
# Alternatively, pass file contents or a `StringIO` directly:
|
|
77
|
+
moonbase_file = moonbase.files.upload(file: File.read("/path/to/file"))
|
|
78
|
+
|
|
79
|
+
# Or, to control the filename and/or content type:
|
|
80
|
+
file = Moonbase::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")
|
|
81
|
+
moonbase_file = moonbase.files.upload(file: file)
|
|
82
|
+
|
|
83
|
+
puts(moonbase_file.id)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Note that you can also pass a raw `IO` descriptor, but this disables retries, as the library can't be sure if the descriptor is a file or pipe (which cannot be rewound).
|
|
87
|
+
|
|
66
88
|
### Handling errors
|
|
67
89
|
|
|
68
90
|
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Moonbase::Errors::APIError` will be thrown:
|
data/lib/moonbase/errors.rb
CHANGED
|
@@ -40,6 +40,9 @@ module Moonbase
|
|
|
40
40
|
# @return [Integer, nil]
|
|
41
41
|
attr_accessor :status
|
|
42
42
|
|
|
43
|
+
# @return [Hash{String=>String}, nil]
|
|
44
|
+
attr_accessor :headers
|
|
45
|
+
|
|
43
46
|
# @return [Object, nil]
|
|
44
47
|
attr_accessor :body
|
|
45
48
|
|
|
@@ -47,13 +50,15 @@ module Moonbase
|
|
|
47
50
|
#
|
|
48
51
|
# @param url [URI::Generic]
|
|
49
52
|
# @param status [Integer, nil]
|
|
53
|
+
# @param headers [Hash{String=>String}, nil]
|
|
50
54
|
# @param body [Object, nil]
|
|
51
55
|
# @param request [nil]
|
|
52
56
|
# @param response [nil]
|
|
53
57
|
# @param message [String, nil]
|
|
54
|
-
def initialize(url:, status: nil, body: nil, request: nil, response: nil, message: nil)
|
|
58
|
+
def initialize(url:, status: nil, headers: nil, body: nil, request: nil, response: nil, message: nil)
|
|
55
59
|
@url = url
|
|
56
60
|
@status = status
|
|
61
|
+
@headers = headers
|
|
57
62
|
@body = body
|
|
58
63
|
@request = request
|
|
59
64
|
@response = response
|
|
@@ -74,6 +79,7 @@ module Moonbase
|
|
|
74
79
|
#
|
|
75
80
|
# @param url [URI::Generic]
|
|
76
81
|
# @param status [nil]
|
|
82
|
+
# @param headers [Hash{String=>String}, nil]
|
|
77
83
|
# @param body [nil]
|
|
78
84
|
# @param request [nil]
|
|
79
85
|
# @param response [nil]
|
|
@@ -81,6 +87,7 @@ module Moonbase
|
|
|
81
87
|
def initialize(
|
|
82
88
|
url:,
|
|
83
89
|
status: nil,
|
|
90
|
+
headers: nil,
|
|
84
91
|
body: nil,
|
|
85
92
|
request: nil,
|
|
86
93
|
response: nil,
|
|
@@ -95,6 +102,7 @@ module Moonbase
|
|
|
95
102
|
#
|
|
96
103
|
# @param url [URI::Generic]
|
|
97
104
|
# @param status [nil]
|
|
105
|
+
# @param headers [Hash{String=>String}, nil]
|
|
98
106
|
# @param body [nil]
|
|
99
107
|
# @param request [nil]
|
|
100
108
|
# @param response [nil]
|
|
@@ -102,6 +110,7 @@ module Moonbase
|
|
|
102
110
|
def initialize(
|
|
103
111
|
url:,
|
|
104
112
|
status: nil,
|
|
113
|
+
headers: nil,
|
|
105
114
|
body: nil,
|
|
106
115
|
request: nil,
|
|
107
116
|
response: nil,
|
|
@@ -116,21 +125,24 @@ module Moonbase
|
|
|
116
125
|
#
|
|
117
126
|
# @param url [URI::Generic]
|
|
118
127
|
# @param status [Integer]
|
|
128
|
+
# @param headers [Hash{String=>String}, nil]
|
|
119
129
|
# @param body [Object, nil]
|
|
120
130
|
# @param request [nil]
|
|
121
131
|
# @param response [nil]
|
|
122
132
|
# @param message [String, nil]
|
|
123
133
|
#
|
|
124
134
|
# @return [self]
|
|
125
|
-
def self.for(url:, status:, body:, request:, response:, message: nil)
|
|
126
|
-
kwargs =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
def self.for(url:, status:, headers:, body:, request:, response:, message: nil)
|
|
136
|
+
kwargs =
|
|
137
|
+
{
|
|
138
|
+
url: url,
|
|
139
|
+
status: status,
|
|
140
|
+
headers: headers,
|
|
141
|
+
body: body,
|
|
142
|
+
request: request,
|
|
143
|
+
response: response,
|
|
144
|
+
message: message
|
|
145
|
+
}
|
|
134
146
|
|
|
135
147
|
case status
|
|
136
148
|
in 400
|
|
@@ -162,15 +174,17 @@ module Moonbase
|
|
|
162
174
|
#
|
|
163
175
|
# @param url [URI::Generic]
|
|
164
176
|
# @param status [Integer]
|
|
177
|
+
# @param headers [Hash{String=>String}, nil]
|
|
165
178
|
# @param body [Object, nil]
|
|
166
179
|
# @param request [nil]
|
|
167
180
|
# @param response [nil]
|
|
168
181
|
# @param message [String, nil]
|
|
169
|
-
def initialize(url:, status:, body:, request:, response:, message: nil)
|
|
182
|
+
def initialize(url:, status:, headers:, body:, request:, response:, message: nil)
|
|
170
183
|
message ||= {url: url.to_s, status: status, body: body}
|
|
171
184
|
super(
|
|
172
185
|
url: url,
|
|
173
186
|
status: status,
|
|
187
|
+
headers: headers,
|
|
174
188
|
body: body,
|
|
175
189
|
request: request,
|
|
176
190
|
response: response,
|
data/lib/moonbase/file_part.rb
CHANGED
|
@@ -38,18 +38,21 @@ module Moonbase
|
|
|
38
38
|
def to_yaml(*a) = read.to_yaml(*a)
|
|
39
39
|
|
|
40
40
|
# @param content [Pathname, StringIO, IO, String]
|
|
41
|
-
# @param filename [String, nil]
|
|
41
|
+
# @param filename [Pathname, String, nil]
|
|
42
42
|
# @param content_type [String, nil]
|
|
43
43
|
def initialize(content, filename: nil, content_type: nil)
|
|
44
|
-
@
|
|
44
|
+
@content_type = content_type
|
|
45
45
|
@filename =
|
|
46
|
-
case content
|
|
47
|
-
in Pathname
|
|
48
|
-
|
|
46
|
+
case [filename, (@content = content)]
|
|
47
|
+
in [String | Pathname, _]
|
|
48
|
+
::File.basename(filename)
|
|
49
|
+
in [nil, Pathname]
|
|
50
|
+
content.basename.to_path
|
|
51
|
+
in [nil, IO]
|
|
52
|
+
content.to_path
|
|
49
53
|
else
|
|
50
|
-
filename
|
|
54
|
+
filename
|
|
51
55
|
end
|
|
52
|
-
@content_type = content_type
|
|
53
56
|
end
|
|
54
57
|
end
|
|
55
58
|
end
|
|
@@ -60,7 +60,7 @@ module Moonbase
|
|
|
60
60
|
#
|
|
61
61
|
# @param client [Moonbase::Internal::Transport::BaseClient]
|
|
62
62
|
# @param req [Hash{Symbol=>Object}]
|
|
63
|
-
# @param headers [Hash{String=>String}
|
|
63
|
+
# @param headers [Hash{String=>String}]
|
|
64
64
|
# @param page_data [Hash{Symbol=>Object}]
|
|
65
65
|
def initialize(client:, req:, headers:, page_data:)
|
|
66
66
|
super
|
|
@@ -47,7 +47,7 @@ module Moonbase
|
|
|
47
47
|
# @api private
|
|
48
48
|
#
|
|
49
49
|
# @param status [Integer]
|
|
50
|
-
# @param headers [Hash{String=>String}
|
|
50
|
+
# @param headers [Hash{String=>String}]
|
|
51
51
|
#
|
|
52
52
|
# @return [Boolean]
|
|
53
53
|
def should_retry?(status, headers:)
|
|
@@ -85,7 +85,7 @@ module Moonbase
|
|
|
85
85
|
#
|
|
86
86
|
# @param status [Integer]
|
|
87
87
|
#
|
|
88
|
-
# @param response_headers [Hash{String=>String}
|
|
88
|
+
# @param response_headers [Hash{String=>String}]
|
|
89
89
|
#
|
|
90
90
|
# @return [Hash{Symbol=>Object}]
|
|
91
91
|
def follow_redirect(request, status:, response_headers:)
|
|
@@ -201,7 +201,8 @@ module Moonbase
|
|
|
201
201
|
self.class::PLATFORM_HEADERS,
|
|
202
202
|
{
|
|
203
203
|
"accept" => "application/json",
|
|
204
|
-
"content-type" => "application/json"
|
|
204
|
+
"content-type" => "application/json",
|
|
205
|
+
"user-agent" => user_agent
|
|
205
206
|
},
|
|
206
207
|
headers
|
|
207
208
|
)
|
|
@@ -219,6 +220,11 @@ module Moonbase
|
|
|
219
220
|
# @return [Hash{String=>String}]
|
|
220
221
|
private def auth_headers = {}
|
|
221
222
|
|
|
223
|
+
# @api private
|
|
224
|
+
#
|
|
225
|
+
# @return [String]
|
|
226
|
+
private def user_agent = "#{self.class.name}/Ruby #{Moonbase::VERSION}"
|
|
227
|
+
|
|
222
228
|
# @api private
|
|
223
229
|
#
|
|
224
230
|
# @return [String]
|
|
@@ -378,6 +384,7 @@ module Moonbase
|
|
|
378
384
|
rescue Moonbase::Errors::APIConnectionError => e
|
|
379
385
|
status = e
|
|
380
386
|
end
|
|
387
|
+
headers = Moonbase::Internal::Util.normalized_headers(response&.each_header&.to_h)
|
|
381
388
|
|
|
382
389
|
case status
|
|
383
390
|
in ..299
|
|
@@ -390,7 +397,7 @@ module Moonbase
|
|
|
390
397
|
in 300..399
|
|
391
398
|
self.class.reap_connection!(status, stream: stream)
|
|
392
399
|
|
|
393
|
-
request = self.class.follow_redirect(request, status: status, response_headers:
|
|
400
|
+
request = self.class.follow_redirect(request, status: status, response_headers: headers)
|
|
394
401
|
send_request(
|
|
395
402
|
request,
|
|
396
403
|
redirect_count: redirect_count + 1,
|
|
@@ -399,9 +406,9 @@ module Moonbase
|
|
|
399
406
|
)
|
|
400
407
|
in Moonbase::Errors::APIConnectionError if retry_count >= max_retries
|
|
401
408
|
raise status
|
|
402
|
-
in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers:
|
|
409
|
+
in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers: headers)
|
|
403
410
|
decoded = Kernel.then do
|
|
404
|
-
Moonbase::Internal::Util.decode_content(
|
|
411
|
+
Moonbase::Internal::Util.decode_content(headers, stream: stream, suppress_error: true)
|
|
405
412
|
ensure
|
|
406
413
|
self.class.reap_connection!(status, stream: stream)
|
|
407
414
|
end
|
|
@@ -409,6 +416,7 @@ module Moonbase
|
|
|
409
416
|
raise Moonbase::Errors::APIStatusError.for(
|
|
410
417
|
url: url,
|
|
411
418
|
status: status,
|
|
419
|
+
headers: headers,
|
|
412
420
|
body: decoded,
|
|
413
421
|
request: nil,
|
|
414
422
|
response: response
|
|
@@ -485,19 +493,21 @@ module Moonbase
|
|
|
485
493
|
send_retry_header: send_retry_header
|
|
486
494
|
)
|
|
487
495
|
|
|
488
|
-
|
|
496
|
+
headers = Moonbase::Internal::Util.normalized_headers(response.each_header.to_h)
|
|
497
|
+
decoded = Moonbase::Internal::Util.decode_content(headers, stream: stream)
|
|
489
498
|
case req
|
|
490
499
|
in {stream: Class => st}
|
|
491
500
|
st.new(
|
|
492
501
|
model: model,
|
|
493
502
|
url: url,
|
|
494
503
|
status: status,
|
|
504
|
+
headers: headers,
|
|
495
505
|
response: response,
|
|
496
506
|
unwrap: unwrap,
|
|
497
507
|
stream: decoded
|
|
498
508
|
)
|
|
499
509
|
in {page: Class => page}
|
|
500
|
-
page.new(client: self, req: req, headers:
|
|
510
|
+
page.new(client: self, req: req, headers: headers, page_data: decoded)
|
|
501
511
|
else
|
|
502
512
|
unwrapped = Moonbase::Internal::Util.dig(decoded, unwrap)
|
|
503
513
|
Moonbase::Internal::Type::Converter.coerce(model, unwrapped)
|
|
@@ -16,10 +16,11 @@ module Moonbase
|
|
|
16
16
|
class << self
|
|
17
17
|
# @api private
|
|
18
18
|
#
|
|
19
|
+
# @param cert_store [OpenSSL::X509::Store]
|
|
19
20
|
# @param url [URI::Generic]
|
|
20
21
|
#
|
|
21
22
|
# @return [Net::HTTP]
|
|
22
|
-
def connect(url)
|
|
23
|
+
def connect(cert_store:, url:)
|
|
23
24
|
port =
|
|
24
25
|
case [url.port, url.scheme]
|
|
25
26
|
in [Integer, _]
|
|
@@ -33,6 +34,8 @@ module Moonbase
|
|
|
33
34
|
Net::HTTP.new(url.host, port).tap do
|
|
34
35
|
_1.use_ssl = %w[https wss].include?(url.scheme)
|
|
35
36
|
_1.max_retries = 0
|
|
37
|
+
|
|
38
|
+
(_1.cert_store = cert_store) if _1.use_ssl?
|
|
36
39
|
end
|
|
37
40
|
end
|
|
38
41
|
|
|
@@ -102,7 +105,7 @@ module Moonbase
|
|
|
102
105
|
pool =
|
|
103
106
|
@mutex.synchronize do
|
|
104
107
|
@pools[origin] ||= ConnectionPool.new(size: @size) do
|
|
105
|
-
self.class.connect(url)
|
|
108
|
+
self.class.connect(cert_store: @cert_store, url: url)
|
|
106
109
|
end
|
|
107
110
|
end
|
|
108
111
|
|
|
@@ -128,37 +131,47 @@ module Moonbase
|
|
|
128
131
|
url, deadline = request.fetch_values(:url, :deadline)
|
|
129
132
|
|
|
130
133
|
req = nil
|
|
131
|
-
eof = false
|
|
132
134
|
finished = false
|
|
133
|
-
closing = nil
|
|
134
135
|
|
|
135
136
|
# rubocop:disable Metrics/BlockLength
|
|
136
137
|
enum = Enumerator.new do |y|
|
|
137
|
-
|
|
138
|
-
next if finished
|
|
139
|
-
|
|
140
|
-
req, closing = self.class.build_request(request) do
|
|
141
|
-
self.class.calibrate_socket_timeout(conn, deadline)
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
self.class.calibrate_socket_timeout(conn, deadline)
|
|
145
|
-
unless conn.started?
|
|
146
|
-
conn.keep_alive_timeout = self.class::KEEP_ALIVE_TIMEOUT
|
|
147
|
-
conn.start
|
|
148
|
-
end
|
|
138
|
+
next if finished
|
|
149
139
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
140
|
+
with_pool(url, deadline: deadline) do |conn|
|
|
141
|
+
eof = false
|
|
142
|
+
closing = nil
|
|
143
|
+
::Thread.handle_interrupt(Object => :never) do
|
|
144
|
+
::Thread.handle_interrupt(Object => :immediate) do
|
|
145
|
+
req, closing = self.class.build_request(request) do
|
|
146
|
+
self.class.calibrate_socket_timeout(conn, deadline)
|
|
147
|
+
end
|
|
154
148
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
149
|
+
self.class.calibrate_socket_timeout(conn, deadline)
|
|
150
|
+
unless conn.started?
|
|
151
|
+
conn.keep_alive_timeout = self.class::KEEP_ALIVE_TIMEOUT
|
|
152
|
+
conn.start
|
|
153
|
+
end
|
|
158
154
|
|
|
159
155
|
self.class.calibrate_socket_timeout(conn, deadline)
|
|
156
|
+
conn.request(req) do |rsp|
|
|
157
|
+
y << [req, rsp]
|
|
158
|
+
break if finished
|
|
159
|
+
|
|
160
|
+
rsp.read_body do |bytes|
|
|
161
|
+
y << bytes.force_encoding(Encoding::BINARY)
|
|
162
|
+
break if finished
|
|
163
|
+
|
|
164
|
+
self.class.calibrate_socket_timeout(conn, deadline)
|
|
165
|
+
end
|
|
166
|
+
eof = true
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
ensure
|
|
170
|
+
begin
|
|
171
|
+
conn.finish if !eof && conn&.started?
|
|
172
|
+
ensure
|
|
173
|
+
closing&.call
|
|
160
174
|
end
|
|
161
|
-
eof = true
|
|
162
175
|
end
|
|
163
176
|
end
|
|
164
177
|
rescue Timeout::Error
|
|
@@ -168,17 +181,10 @@ module Moonbase
|
|
|
168
181
|
end
|
|
169
182
|
# rubocop:enable Metrics/BlockLength
|
|
170
183
|
|
|
171
|
-
|
|
184
|
+
_, response = enum.next
|
|
172
185
|
body = Moonbase::Internal::Util.fused_enum(enum, external: true) do
|
|
173
186
|
finished = true
|
|
174
|
-
|
|
175
|
-
enum.next
|
|
176
|
-
rescue StopIteration
|
|
177
|
-
nil
|
|
178
|
-
end
|
|
179
|
-
ensure
|
|
180
|
-
conn.finish if !eof && conn&.started?
|
|
181
|
-
closing&.call
|
|
187
|
+
loop { enum.next }
|
|
182
188
|
end
|
|
183
189
|
[Integer(response.code), response, body]
|
|
184
190
|
end
|
|
@@ -189,6 +195,7 @@ module Moonbase
|
|
|
189
195
|
def initialize(size: self.class::DEFAULT_MAX_CONNECTIONS)
|
|
190
196
|
@mutex = Mutex.new
|
|
191
197
|
@size = size
|
|
198
|
+
@cert_store = OpenSSL::X509::Store.new.tap(&:set_default_paths)
|
|
192
199
|
@pools = {}
|
|
193
200
|
end
|
|
194
201
|
|
|
@@ -39,7 +39,7 @@ module Moonbase
|
|
|
39
39
|
#
|
|
40
40
|
# @param client [Moonbase::Internal::Transport::BaseClient]
|
|
41
41
|
# @param req [Hash{Symbol=>Object}]
|
|
42
|
-
# @param headers [Hash{String=>String}
|
|
42
|
+
# @param headers [Hash{String=>String}]
|
|
43
43
|
# @param page_data [Object]
|
|
44
44
|
def initialize(client:, req:, headers:, page_data:)
|
|
45
45
|
@client = client
|
|
@@ -82,17 +82,20 @@ module Moonbase
|
|
|
82
82
|
#
|
|
83
83
|
# @return [Pathname, StringIO, IO, String, Object]
|
|
84
84
|
def dump(value, state:)
|
|
85
|
-
# rubocop:disable Lint/DuplicateBranch
|
|
86
85
|
case value
|
|
86
|
+
in StringIO | String
|
|
87
|
+
# https://datatracker.ietf.org/doc/html/rfc7578#section-4.2
|
|
88
|
+
# while not required, a filename is recommended, and in practice many servers do expect this
|
|
89
|
+
Moonbase::FilePart.new(value, filename: "upload")
|
|
87
90
|
in IO
|
|
88
91
|
state[:can_retry] = false
|
|
92
|
+
value.to_path.nil? ? Moonbase::FilePart.new(value, filename: "upload") : value
|
|
89
93
|
in Moonbase::FilePart if value.content.is_a?(IO)
|
|
90
94
|
state[:can_retry] = false
|
|
95
|
+
value
|
|
91
96
|
else
|
|
97
|
+
value
|
|
92
98
|
end
|
|
93
|
-
# rubocop:enable Lint/DuplicateBranch
|
|
94
|
-
|
|
95
|
-
value
|
|
96
99
|
end
|
|
97
100
|
|
|
98
101
|
# @api private
|
|
@@ -346,8 +346,9 @@ module Moonbase
|
|
|
346
346
|
base_path, base_query = lhs.fetch_values(:path, :query)
|
|
347
347
|
slashed = base_path.end_with?("/") ? base_path : "#{base_path}/"
|
|
348
348
|
|
|
349
|
-
|
|
350
|
-
|
|
349
|
+
merged = {**parse_uri(rhs.fetch(:path)), **rhs.except(:path, :query)}
|
|
350
|
+
parsed_path, parsed_query = merged.fetch_values(:path, :query)
|
|
351
|
+
override = URI::Generic.build(**merged.slice(:scheme, :host, :port), path: parsed_path)
|
|
351
352
|
|
|
352
353
|
joined = URI.join(URI::Generic.build(lhs.except(:path, :query)), slashed, override)
|
|
353
354
|
query = deep_merge(
|
|
@@ -473,10 +474,9 @@ module Moonbase
|
|
|
473
474
|
# @return [Enumerable<String>]
|
|
474
475
|
def writable_enum(&blk)
|
|
475
476
|
Enumerator.new do |y|
|
|
476
|
-
buf = String.new
|
|
477
477
|
y.define_singleton_method(:write) do
|
|
478
|
-
self <<
|
|
479
|
-
|
|
478
|
+
self << _1.dup
|
|
479
|
+
_1.bytesize
|
|
480
480
|
end
|
|
481
481
|
|
|
482
482
|
blk.call(y)
|
|
@@ -566,7 +566,8 @@ module Moonbase
|
|
|
566
566
|
#
|
|
567
567
|
# @return [Array(String, Enumerable<String>)]
|
|
568
568
|
private def encode_multipart_streaming(body)
|
|
569
|
-
|
|
569
|
+
# RFC 1521 Section 7.2.1 says we should have 70 char maximum for boundary length
|
|
570
|
+
boundary = SecureRandom.urlsafe_base64(46)
|
|
570
571
|
|
|
571
572
|
closing = []
|
|
572
573
|
strio = writable_enum do |y|
|
|
@@ -647,7 +648,7 @@ module Moonbase
|
|
|
647
648
|
#
|
|
648
649
|
# Assumes each chunk in stream has `Encoding::BINARY`.
|
|
649
650
|
#
|
|
650
|
-
# @param headers [Hash{String=>String}
|
|
651
|
+
# @param headers [Hash{String=>String}]
|
|
651
652
|
# @param stream [Enumerable<String>]
|
|
652
653
|
# @param suppress_error [Boolean]
|
|
653
654
|
#
|
|
@@ -9,11 +9,11 @@ module Moonbase
|
|
|
9
9
|
# @return [String]
|
|
10
10
|
required :id, String
|
|
11
11
|
|
|
12
|
-
# @!attribute
|
|
12
|
+
# @!attribute name
|
|
13
13
|
# The human-readable text displayed for this option.
|
|
14
14
|
#
|
|
15
15
|
# @return [String]
|
|
16
|
-
required :
|
|
16
|
+
required :name, String
|
|
17
17
|
|
|
18
18
|
# @!attribute type
|
|
19
19
|
# String representing the object’s type. Always `choice_field_option` for this
|
|
@@ -22,7 +22,7 @@ module Moonbase
|
|
|
22
22
|
# @return [Symbol, :choice_field_option]
|
|
23
23
|
required :type, const: :choice_field_option
|
|
24
24
|
|
|
25
|
-
# @!method initialize(id:,
|
|
25
|
+
# @!method initialize(id:, name:, type: :choice_field_option)
|
|
26
26
|
# Some parameter documentations has been truncated, see
|
|
27
27
|
# {Moonbase::Models::ChoiceFieldOption} for more details.
|
|
28
28
|
#
|
|
@@ -30,7 +30,7 @@ module Moonbase
|
|
|
30
30
|
#
|
|
31
31
|
# @param id [String] Unique identifier for the option.
|
|
32
32
|
#
|
|
33
|
-
# @param
|
|
33
|
+
# @param name [String] The human-readable text displayed for this option.
|
|
34
34
|
#
|
|
35
35
|
# @param type [Symbol, :choice_field_option] String representing the object’s type. Always `choice_field_option` for this obj
|
|
36
36
|
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Moonbase
|
|
4
|
+
module Models
|
|
5
|
+
# @see Moonbase::Resources::Files#upload
|
|
6
|
+
class FileUploadParams < Moonbase::Internal::Type::BaseModel
|
|
7
|
+
extend Moonbase::Internal::Type::RequestParameters::Converter
|
|
8
|
+
include Moonbase::Internal::Type::RequestParameters
|
|
9
|
+
|
|
10
|
+
# @!attribute file
|
|
11
|
+
# The File object to be uploaded.
|
|
12
|
+
#
|
|
13
|
+
# @return [Pathname, StringIO, IO, String, Moonbase::FilePart]
|
|
14
|
+
required :file, Moonbase::Internal::Type::FileInput
|
|
15
|
+
|
|
16
|
+
# @!attribute associations
|
|
17
|
+
# Link the File to Moonbase items like a person, organization, deal, task, or an
|
|
18
|
+
# item in a custom collection.
|
|
19
|
+
#
|
|
20
|
+
# @return [Array<Moonbase::Models::Pointer>, nil]
|
|
21
|
+
optional :associations, -> { Moonbase::Internal::Type::ArrayOf[Moonbase::Pointer] }
|
|
22
|
+
|
|
23
|
+
# @!attribute name
|
|
24
|
+
# The display name of the file.
|
|
25
|
+
#
|
|
26
|
+
# @return [String, nil]
|
|
27
|
+
optional :name, String
|
|
28
|
+
|
|
29
|
+
# @!method initialize(file:, associations: nil, name: nil, request_options: {})
|
|
30
|
+
# Some parameter documentations has been truncated, see
|
|
31
|
+
# {Moonbase::Models::FileUploadParams} for more details.
|
|
32
|
+
#
|
|
33
|
+
# @param file [Pathname, StringIO, IO, String, Moonbase::FilePart] The File object to be uploaded.
|
|
34
|
+
#
|
|
35
|
+
# @param associations [Array<Moonbase::Models::Pointer>] Link the File to Moonbase items like a person, organization, deal, task, or an i
|
|
36
|
+
#
|
|
37
|
+
# @param name [String] The display name of the file.
|
|
38
|
+
#
|
|
39
|
+
# @param request_options [Moonbase::RequestOptions, Hash{Symbol=>Object}]
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|