@seamapi/nextlove-sdk-generator 1.6.1 → 1.7.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.
- package/lib/generate-python-sdk/class-file.js +25 -21
- package/lib/generate-python-sdk/class-file.js.map +1 -1
- package/lib/generate-python-sdk/templates/readme.md.template.js +1 -1
- package/lib/generate-python-sdk/templates/seam.py.template.js +8 -2
- package/lib/generate-python-sdk/templates/seam.py.template.js.map +1 -1
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js +1 -0
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js.map +1 -1
- package/lib/generate-ruby-sdk/generate-ruby-sdk.js +4 -1
- package/lib/generate-ruby-sdk/generate-ruby-sdk.js.map +1 -1
- package/lib/generate-ruby-sdk/ruby-client.js +19 -12
- package/lib/generate-ruby-sdk/ruby-client.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/.rspec.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/.rspec.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/.ruby-version.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/.ruby-version.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/base_client.rb.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/base_client.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/base_resource.rb.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/base_resource.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/client.rb.template.js +62 -48
- package/lib/generate-ruby-sdk/templates/client.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/gemfile.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/gemfile.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/logger.rb.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/logger.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/lts_version.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/lts_version.rb.template.js +6 -0
- package/lib/generate-ruby-sdk/templates/lts_version.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/rakefile.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/rakefile.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/request.rb.template.js +5 -2
- package/lib/generate-ruby-sdk/templates/request.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/resource_error.rb.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/resource_error.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/resource_errors_support.rb.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/resource_errors_support.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/resource_warning.rb.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/resource_warning.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/resource_warnings_support.rb.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/resource_warnings_support.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/seamapi.gemspec.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/seamapi.gemspec.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/snippets/action-attempt-helpers-template.js +20 -8
- package/lib/generate-ruby-sdk/templates/snippets/action-attempt-helpers-template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.js +8 -8
- package/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/spec_helper.rb.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/spec_helper.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/support-helpers.rb.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/support-helpers.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/version.rb.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/version.rb.template.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/generate-python-sdk/class-file.ts +14 -11
- package/src/lib/generate-python-sdk/templates/readme.md.template.ts +1 -1
- package/src/lib/generate-python-sdk/templates/seam.py.template.ts +8 -2
- package/src/lib/generate-python-sdk/templates/snippets/abstract-seam.template.ts +1 -0
- package/src/lib/generate-ruby-sdk/generate-ruby-sdk.ts +4 -1
- package/src/lib/generate-ruby-sdk/ruby-client.ts +22 -14
- package/src/lib/generate-ruby-sdk/templates/.rspec.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/.ruby-version.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/base_client.rb.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/base_resource.rb.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/client.rb.template.ts +62 -48
- package/src/lib/generate-ruby-sdk/templates/gemfile.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/logger.rb.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/lts_version.rb.template.ts +5 -0
- package/src/lib/generate-ruby-sdk/templates/rakefile.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/request.rb.template.ts +5 -2
- package/src/lib/generate-ruby-sdk/templates/resource_error.rb.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/resource_errors_support.rb.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/resource_warning.rb.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/resource_warnings_support.rb.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/seamapi.gemspec.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/snippets/action-attempt-helpers-template.ts +20 -8
- package/src/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.ts +8 -8
- package/src/lib/generate-ruby-sdk/templates/spec_helper.rb.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/support-helpers.rb.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/version.rb.template.ts +1 -1
- package/lib/generate-ruby-sdk/request.rb.template.d.ts +0 -1
- package/lib/generate-ruby-sdk/request.rb.template.js +0 -2
- package/lib/generate-ruby-sdk/request.rb.template.js.map +0 -1
- package/src/lib/generate-ruby-sdk/request.rb.template.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource_warning.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/resource_warning.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;
|
|
1
|
+
{"version":3,"file":"resource_warning.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/resource_warning.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;MAQf,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource_warnings_support.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/resource_warnings_support.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;
|
|
1
|
+
{"version":3,"file":"resource_warnings_support.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/resource_warnings_support.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;MAQf,CAAA"}
|
|
@@ -37,5 +37,5 @@ Gem::Specification.new do |spec|
|
|
|
37
37
|
spec.add_development_dependency "simplecov-console", "~> 0.9"
|
|
38
38
|
spec.add_development_dependency "standard", "~> 1.3"
|
|
39
39
|
spec.add_development_dependency "webmock", "~> 3.0.0"
|
|
40
|
-
end`;
|
|
40
|
+
end\n`;
|
|
41
41
|
//# sourceMappingURL=seamapi.gemspec.template.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seamapi.gemspec.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/seamapi.gemspec.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"seamapi.gemspec.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/seamapi.gemspec.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAuCf,CAAA"}
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
export default () => `
|
|
2
|
-
|
|
1
|
+
export default () => `
|
|
2
|
+
def decide_and_wait(wait_for_action_attempt)
|
|
3
|
+
wait_decision = wait_for_action_attempt.nil? ? @client.wait_for_action_attempt : wait_for_action_attempt
|
|
4
|
+
|
|
5
|
+
if wait_decision == true
|
|
6
|
+
wait_until_finished
|
|
7
|
+
elsif wait_decision.is_a?(Hash)
|
|
8
|
+
wait_until_finished(timeout: wait_decision[:timeout], polling_interval: wait_decision[:polling_interval])
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def wait_until_finished(timeout: 5.0, polling_interval: 0.5)
|
|
13
|
+
time_waiting = 0.0
|
|
3
14
|
|
|
4
|
-
def wait_until_finished
|
|
5
|
-
attempts = 0
|
|
6
15
|
while @status == "pending"
|
|
16
|
+
sleep(polling_interval)
|
|
17
|
+
time_waiting += polling_interval
|
|
18
|
+
|
|
19
|
+
raise "Timed out waiting for action attempt to be finished" if time_waiting > timeout
|
|
20
|
+
|
|
7
21
|
update!
|
|
8
|
-
sleep(SLEEP_TIME)
|
|
9
|
-
attempts += 1
|
|
10
|
-
end
|
|
11
22
|
|
|
12
|
-
|
|
23
|
+
raise "Action Attempt failed: #{error['message']}" if @status == "failed"
|
|
24
|
+
end
|
|
13
25
|
|
|
14
26
|
self
|
|
15
27
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-attempt-helpers-template.js","sourceRoot":"","sources":["../../../../src/lib/generate-ruby-sdk/templates/snippets/action-attempt-helpers-template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC
|
|
1
|
+
{"version":3,"file":"action-attempt-helpers-template.js","sourceRoot":"","sources":["../../../../src/lib/generate-ruby-sdk/templates/snippets/action-attempt-helpers-template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAsCb,CAAA"}
|
|
@@ -7,13 +7,13 @@ export default ({ pascal_name, attrs, date_attrs, }) => {
|
|
|
7
7
|
.map((attr) => `:${attr}`)
|
|
8
8
|
.join(", ");
|
|
9
9
|
const date_accessors = date_attrs.length > 0
|
|
10
|
-
? `date_accessor ${date_attrs.map((attr) => `:${attr}`).join(", ")}`
|
|
10
|
+
? ` date_accessor ${date_attrs.map((attr) => `:${attr}`).join(", ")}`
|
|
11
11
|
: "";
|
|
12
12
|
const resource_errors_support = has_errors_attr
|
|
13
|
-
? "include Seam::ResourceErrorsSupport"
|
|
13
|
+
? " include Seam::ResourceErrorsSupport"
|
|
14
14
|
: "";
|
|
15
15
|
const resource_warnings_support = has_warnings_attr
|
|
16
|
-
? "include Seam::ResourceWarningsSupport"
|
|
16
|
+
? " include Seam::ResourceWarningsSupport"
|
|
17
17
|
: "";
|
|
18
18
|
const is_action_attempt_resource = pascal_name === "ActionAttempt";
|
|
19
19
|
return `# frozen_string_literal: true
|
|
@@ -22,13 +22,13 @@ module Seam
|
|
|
22
22
|
class ${pascal_name} < BaseResource
|
|
23
23
|
attr_accessor ${attr_accessors}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
${date_accessors}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
${resource_errors_support}
|
|
28
|
+
${resource_warnings_support}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
${is_action_attempt_resource ? actionAttemptHelpersTemplate() : ""}
|
|
31
31
|
end
|
|
32
|
-
end`;
|
|
32
|
+
end\n`;
|
|
33
33
|
};
|
|
34
34
|
//# sourceMappingURL=resource.rb.template.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.rb.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,sCAAsC,CAAA;AAE/E,eAAe,CAAC,EACd,WAAW,EACX,KAAK,EACL,UAAU,GAKX,EAAE,EAAE;IACH,MAAM,sBAAsB,GAAG,KAAK,CAAC,MAAM,CACzC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,UAAU,CACnD,CAAA;IACD,MAAM,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IACpD,MAAM,eAAe,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAEhD,MAAM,cAAc,GAAG,sBAAsB;SAC1C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;SACzB,IAAI,CAAC,IAAI,CAAC,CAAA;IACb,MAAM,cAAc,GAClB,UAAU,CAAC,MAAM,GAAG,CAAC;QACnB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"resource.rb.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,sCAAsC,CAAA;AAE/E,eAAe,CAAC,EACd,WAAW,EACX,KAAK,EACL,UAAU,GAKX,EAAE,EAAE;IACH,MAAM,sBAAsB,GAAG,KAAK,CAAC,MAAM,CACzC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,UAAU,CACnD,CAAA;IACD,MAAM,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IACpD,MAAM,eAAe,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAEhD,MAAM,cAAc,GAAG,sBAAsB;SAC1C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;SACzB,IAAI,CAAC,IAAI,CAAC,CAAA;IACb,MAAM,cAAc,GAClB,UAAU,CAAC,MAAM,GAAG,CAAC;QACnB,CAAC,CAAC,qBAAqB,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACxE,CAAC,CAAC,EAAE,CAAA;IAER,MAAM,uBAAuB,GAAG,eAAe;QAC7C,CAAC,CAAC,yCAAyC;QAC3C,CAAC,CAAC,EAAE,CAAA;IACN,MAAM,yBAAyB,GAAG,iBAAiB;QACjD,CAAC,CAAC,2CAA2C;QAC7C,CAAC,CAAC,EAAE,CAAA;IAEN,MAAM,0BAA0B,GAAG,WAAW,KAAK,eAAe,CAAA;IAElE,OAAO;;;UAGC,WAAW;oBACD,cAAc;;EAEhC,cAAc;;EAEd,uBAAuB;EACvB,yBAAyB;;EAEzB,0BAA0B,CAAC,CAAC,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC,EAAE;;MAE5D,CAAA;AACN,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec_helper.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/spec_helper.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"spec_helper.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/spec_helper.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2Bf,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"support-helpers.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/support-helpers.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"support-helpers.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/support-helpers.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;MAUf,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/version.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"version.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/version.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;MAIf,CAAA"}
|
package/package.json
CHANGED
|
@@ -90,12 +90,14 @@ export class ClassFile {
|
|
|
90
90
|
]
|
|
91
91
|
: []
|
|
92
92
|
)
|
|
93
|
-
.map(({ method_name, parameters }) =>
|
|
94
|
-
|
|
93
|
+
.map(({ method_name, parameters, return_resource }) => {
|
|
94
|
+
const has_params = parameters.length > 0
|
|
95
|
+
|
|
96
|
+
return [
|
|
95
97
|
"",
|
|
96
98
|
"",
|
|
97
99
|
`@abc.abstractmethod`,
|
|
98
|
-
`def ${method_name}(self
|
|
100
|
+
`def ${method_name}(self,${has_params ? " *," : ""} ${parameters
|
|
99
101
|
.sort(
|
|
100
102
|
(a, b) =>
|
|
101
103
|
(a.position ?? a.required ? 1000 : 9999) -
|
|
@@ -106,12 +108,12 @@ export class ClassFile {
|
|
|
106
108
|
? `${name}: ${type}`
|
|
107
109
|
: `${name}: Optional[${type}] = ${default_value ?? "None"}`
|
|
108
110
|
)
|
|
109
|
-
.join(", ")}):`,
|
|
111
|
+
.join(", ")}) -> ${return_resource}:`,
|
|
110
112
|
` raise NotImplementedError()`,
|
|
111
113
|
]
|
|
112
114
|
.map((s) => ` ${s}`)
|
|
113
115
|
.join("\n")
|
|
114
|
-
),
|
|
116
|
+
}),
|
|
115
117
|
].join("\n")
|
|
116
118
|
}
|
|
117
119
|
|
|
@@ -188,11 +190,12 @@ export class ClassFile {
|
|
|
188
190
|
const can_method_poll_action_attempt =
|
|
189
191
|
return_resource === "ActionAttempt" && !is_return_resource_list
|
|
190
192
|
const is_none_return_type = return_resource_item === "None"
|
|
193
|
+
const has_params = parameters.length > 0
|
|
191
194
|
|
|
192
195
|
return [
|
|
193
196
|
"",
|
|
194
197
|
"",
|
|
195
|
-
`def ${method_name}(self
|
|
198
|
+
`def ${method_name}(self,${has_params ? " *," : ""} ${parameters
|
|
196
199
|
.sort(
|
|
197
200
|
(a, b) =>
|
|
198
201
|
(a.position ?? a.required ? 1000 : 9999) -
|
|
@@ -232,13 +235,13 @@ export class ClassFile {
|
|
|
232
235
|
? [
|
|
233
236
|
" if isinstance(wait_for_action_attempt, dict):",
|
|
234
237
|
` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
|
|
235
|
-
" res['action_attempt']['action_attempt_id'],",
|
|
238
|
+
" action_attempt_id=res['action_attempt']['action_attempt_id'],",
|
|
236
239
|
" timeout=wait_for_action_attempt.get('timeout', None),",
|
|
237
240
|
" polling_interval=wait_for_action_attempt.get('polling_interval', None),",
|
|
238
241
|
" )",
|
|
239
242
|
" elif wait_for_action_attempt is True:",
|
|
240
243
|
` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
|
|
241
|
-
" res['action_attempt']['action_attempt_id']",
|
|
244
|
+
" action_attempt_id=res['action_attempt']['action_attempt_id']",
|
|
242
245
|
" )",
|
|
243
246
|
" else:",
|
|
244
247
|
` return ${return_resource}.from_dict(res["${return_path.join(
|
|
@@ -269,11 +272,11 @@ export class ClassFile {
|
|
|
269
272
|
this.name === "ActionAttempts"
|
|
270
273
|
? [
|
|
271
274
|
"",
|
|
272
|
-
" def poll_until_ready(self, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:",
|
|
275
|
+
" def poll_until_ready(self, *, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:",
|
|
273
276
|
" seam = self.seam",
|
|
274
277
|
" time_waiting = 0.0",
|
|
275
278
|
"",
|
|
276
|
-
" action_attempt = seam.action_attempts.get(action_attempt_id, wait_for_action_attempt=False)",
|
|
279
|
+
" action_attempt = seam.action_attempts.get(action_attempt_id=action_attempt_id, wait_for_action_attempt=False)",
|
|
277
280
|
"",
|
|
278
281
|
" while action_attempt.status == 'pending':",
|
|
279
282
|
" time.sleep(polling_interval)",
|
|
@@ -283,7 +286,7 @@ export class ClassFile {
|
|
|
283
286
|
" raise Exception('Timed out waiting for action attempt to be ready')",
|
|
284
287
|
"",
|
|
285
288
|
" action_attempt = seam.action_attempts.get(",
|
|
286
|
-
" action_attempt.action_attempt_id, wait_for_action_attempt=False",
|
|
289
|
+
" action_attempt_id=action_attempt.action_attempt_id, wait_for_action_attempt=False",
|
|
287
290
|
" )",
|
|
288
291
|
"",
|
|
289
292
|
" if action_attempt.status == 'failed':",
|
|
@@ -19,8 +19,10 @@ class Seam(AbstractSeam):
|
|
|
19
19
|
----------
|
|
20
20
|
api_key : str
|
|
21
21
|
API key (default None)
|
|
22
|
-
api_url : str
|
|
23
|
-
API url (default
|
|
22
|
+
api_url : str
|
|
23
|
+
API url (default "https://connect.getseam.com")
|
|
24
|
+
lts_version : str
|
|
25
|
+
LTS version
|
|
24
26
|
workspaces : Workspaces
|
|
25
27
|
Workspaces class
|
|
26
28
|
connected_accounts : ConnectedAccounts
|
|
@@ -41,10 +43,12 @@ class Seam(AbstractSeam):
|
|
|
41
43
|
|
|
42
44
|
api_key: str
|
|
43
45
|
api_url: str = "https://connect.getseam.com"
|
|
46
|
+
lts_version: str = '1.0.0'
|
|
44
47
|
|
|
45
48
|
def __init__(
|
|
46
49
|
self,
|
|
47
50
|
api_key: Optional[str] = None,
|
|
51
|
+
*,
|
|
48
52
|
workspace_id: Optional[str] = None,
|
|
49
53
|
api_url: Optional[str] = None,
|
|
50
54
|
should_report_exceptions: Optional[bool] = False,
|
|
@@ -73,6 +77,7 @@ class Seam(AbstractSeam):
|
|
|
73
77
|
workspace_id = os.environ.get("SEAM_WORKSPACE_ID", None)
|
|
74
78
|
self.api_key = api_key
|
|
75
79
|
self.workspace_id = workspace_id
|
|
80
|
+
self.lts_version = Seam.lts_version
|
|
76
81
|
|
|
77
82
|
if os.environ.get("SEAM_API_URL", None) is not None:
|
|
78
83
|
print(
|
|
@@ -120,6 +125,7 @@ class Seam(AbstractSeam):
|
|
|
120
125
|
"User-Agent": "Python SDK v" + sdk_version + " (https://github.com/seamapi/python)",
|
|
121
126
|
"seam-sdk-name": "seamapi/python",
|
|
122
127
|
"seam-sdk-version": sdk_version,
|
|
128
|
+
"seam-lts-version": self.lts_version,
|
|
123
129
|
}
|
|
124
130
|
if self.workspace_id is not None:
|
|
125
131
|
headers["seam-workspace"] = self.workspace_id
|
|
@@ -9,6 +9,7 @@ import base_clientRbTemplate from "./templates/base_client.rb.template.js"
|
|
|
9
9
|
import readmeMdTemplate from "./templates/readme.md.template.js"
|
|
10
10
|
import rakefileTemplate from "./templates/rakefile.template.js"
|
|
11
11
|
import versionRbTemplate from "./templates/version.rb.template.js"
|
|
12
|
+
import ltsVersionRbTemplate from "./templates/lts_version.rb.template.js"
|
|
12
13
|
import requestRbTemplate from "./templates/request.rb.template.js"
|
|
13
14
|
import loggerRbTemplate from "./templates/logger.rb.template.js"
|
|
14
15
|
import clientRbTemplate from "./templates/client.rb.template.js"
|
|
@@ -46,6 +47,7 @@ export const generateRubySDK = async () => {
|
|
|
46
47
|
fs[".rspec"] = rspecTemplate()
|
|
47
48
|
fs[".ruby-version"] = rubyVersionTemplate()
|
|
48
49
|
fs["lib/seam/version.rb"] = versionRbTemplate()
|
|
50
|
+
fs["lib/seam/lts_version.rb"] = ltsVersionRbTemplate()
|
|
49
51
|
fs["lib/seam/request.rb"] = requestRbTemplate()
|
|
50
52
|
fs["lib/seam/logger.rb"] = loggerRbTemplate()
|
|
51
53
|
fs["lib/seam/clients/base_client.rb"] = base_clientRbTemplate()
|
|
@@ -59,6 +61,7 @@ export const generateRubySDK = async () => {
|
|
|
59
61
|
|
|
60
62
|
const seamapi_rb_requires = [
|
|
61
63
|
"seam/version",
|
|
64
|
+
"seam/lts_version",
|
|
62
65
|
"seam/request",
|
|
63
66
|
"seam/logger",
|
|
64
67
|
"seam/client",
|
|
@@ -179,7 +182,7 @@ export const generateRubySDK = async () => {
|
|
|
179
182
|
...seamapi_rb_requires.map((r) => `require_relative "${r}"`),
|
|
180
183
|
"",
|
|
181
184
|
`module Seam`,
|
|
182
|
-
`end`,
|
|
185
|
+
`end\n`,
|
|
183
186
|
].join("\n")
|
|
184
187
|
|
|
185
188
|
return fs
|
|
@@ -70,11 +70,12 @@ export class RubyClient {
|
|
|
70
70
|
),
|
|
71
71
|
...this.methods.map(
|
|
72
72
|
({ method_name, path, parameters, return_resource, return_path }) => {
|
|
73
|
-
const
|
|
73
|
+
const has_return_value = return_resource && return_path
|
|
74
|
+
const returns_deprecated_action_attempt =
|
|
75
|
+
endpoints_returning_deprecated_action_attempt.includes(path)
|
|
74
76
|
const can_method_poll_action_attempt =
|
|
75
|
-
|
|
76
|
-
!
|
|
77
|
-
return_resource === "ActionAttempt"
|
|
77
|
+
return_path === "action_attempt" &&
|
|
78
|
+
!returns_deprecated_action_attempt
|
|
78
79
|
|
|
79
80
|
return [
|
|
80
81
|
`def ${method_name}(${parameters
|
|
@@ -83,24 +84,31 @@ export class RubyClient {
|
|
|
83
84
|
(a.position ?? a.required ? 1000 : 9999) -
|
|
84
85
|
(b.position ?? b.required ? 1000 : 9999)
|
|
85
86
|
)
|
|
86
|
-
.map((p) => `${p.name}${p.required ? "" : ": nil"}`)
|
|
87
|
+
.map((p) => `${p.name}${p.required ? ":" : ": nil"}`)
|
|
88
|
+
.concat(
|
|
89
|
+
can_method_poll_action_attempt
|
|
90
|
+
? ["wait_for_action_attempt: nil"]
|
|
91
|
+
: []
|
|
92
|
+
)
|
|
87
93
|
.join(", ")})`,
|
|
88
94
|
` ${can_method_poll_action_attempt ? "action_attempt = " : ""}${
|
|
89
|
-
|
|
95
|
+
has_return_value ? "request_seam_object" : "request_seam"
|
|
90
96
|
}(`,
|
|
91
97
|
` :post,`,
|
|
92
98
|
` "${path}",`,
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
has_return_value
|
|
100
|
+
? ` Seam::${return_resource},\n '${return_path}',`
|
|
101
|
+
: [],
|
|
95
102
|
` body: {${parameters
|
|
96
103
|
.map((p) => `${p.name}: ${p.name}`)
|
|
97
104
|
.join(", ")}}.compact`,
|
|
98
|
-
` )`,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
` )\n`,
|
|
106
|
+
can_method_poll_action_attempt
|
|
107
|
+
? " action_attempt.decide_and_wait(wait_for_action_attempt)\n action_attempt"
|
|
108
|
+
: [],
|
|
109
|
+
!has_return_value || returns_deprecated_action_attempt
|
|
110
|
+
? " nil"
|
|
111
|
+
: [],
|
|
104
112
|
`end`,
|
|
105
113
|
``,
|
|
106
114
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default () => `3.0.4`
|
|
1
|
+
export default () => `3.0.4\n`
|
|
@@ -4,59 +4,73 @@ export default (resource_client_names: string[]) => {
|
|
|
4
4
|
const resource_client_defs = resource_client_names
|
|
5
5
|
.map((client_name) => {
|
|
6
6
|
return `
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`
|
|
7
|
+
def ${client_name}
|
|
8
|
+
@${client_name} ||= Seam::Clients::${pascalCase(client_name)}.new(self)
|
|
9
|
+
end\n`
|
|
11
10
|
})
|
|
12
11
|
.join("")
|
|
13
12
|
|
|
14
13
|
return `# frozen_string_literal: true
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
# @deprecated Please use {#access_codes.unmanaged} instead.
|
|
37
|
-
def unmanaged_access_codes
|
|
38
|
-
warn "[DEPRECATION] 'unmanaged_access_codes' is deprecated. Please use 'access_codes.unmanaged' instead."
|
|
39
|
-
|
|
40
|
-
@unmanaged_access_codes ||= Seam::Clients::AccessCodesUnmanaged.new(self)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def request_seam_object(method, path, klass, inner_object, config = {})
|
|
44
|
-
response = request_seam(method, path, config)
|
|
45
|
-
|
|
46
|
-
data = response[inner_object]
|
|
47
|
-
|
|
48
|
-
klass.load_from_response(data, self)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def request_seam(method, path, config = {})
|
|
52
|
-
Seam::Request.new(
|
|
53
|
-
api_key: api_key,
|
|
54
|
-
base_uri: base_uri,
|
|
55
|
-
debug: debug
|
|
56
|
-
).perform(
|
|
57
|
-
method, path, config
|
|
58
|
-
)
|
|
15
|
+
module Seam
|
|
16
|
+
class Client
|
|
17
|
+
attr_accessor :api_key, :base_uri, :debug
|
|
18
|
+
|
|
19
|
+
def self.lts_version
|
|
20
|
+
Seam::LTS_VERSION
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def initialize(api_key: nil, base_uri: nil, wait_for_action_attempt: false, debug: false)
|
|
24
|
+
@api_key = api_key || ENV["SEAM_API_KEY"]
|
|
25
|
+
@base_uri = base_uri || ENV["SEAM_API_URL"] || ENV["SEAM_ENDPOINT"] || "https://connect.getseam.com"
|
|
26
|
+
@debug = debug
|
|
27
|
+
@wait_for_action_attempt = wait_for_action_attempt
|
|
28
|
+
|
|
29
|
+
raise ArgumentError, "SEAM_API_KEY not found in environment, and api_key not provided" if @api_key.to_s.empty?
|
|
30
|
+
|
|
31
|
+
if ENV["SEAM_API_URL"]
|
|
32
|
+
warn 'Using the SEAM_API_URL environment variable is deprecated. ' \\
|
|
33
|
+
'Support will be removed in a later major version. Use SEAM_ENDPOINT instead.'
|
|
59
34
|
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def lts_version
|
|
39
|
+
Seam::LTS_VERSION
|
|
40
|
+
end
|
|
41
|
+
${resource_client_defs}
|
|
42
|
+
|
|
43
|
+
# @deprecated Please use {#devices.unmanaged} instead.
|
|
44
|
+
def unmanaged_devices
|
|
45
|
+
warn "[DEPRECATION] 'unmanaged_devices' is deprecated. Please use 'devices.unmanaged' instead."
|
|
46
|
+
|
|
47
|
+
@unmanaged_devices ||= Seam::Clients::DevicesUnmanaged.new(self)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @deprecated Please use {#access_codes.unmanaged} instead.
|
|
51
|
+
def unmanaged_access_codes
|
|
52
|
+
warn "[DEPRECATION] 'unmanaged_access_codes' is deprecated. Please use 'access_codes.unmanaged' instead."
|
|
53
|
+
|
|
54
|
+
@unmanaged_access_codes ||= Seam::Clients::AccessCodesUnmanaged.new(self)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def request_seam_object(method, path, klass, inner_object, config = {})
|
|
58
|
+
response = request_seam(method, path, config)
|
|
59
|
+
|
|
60
|
+
data = response[inner_object]
|
|
61
|
+
|
|
62
|
+
klass.load_from_response(data, self)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def request_seam(method, path, config = {})
|
|
66
|
+
Seam::Request.new(
|
|
67
|
+
api_key: api_key,
|
|
68
|
+
base_uri: base_uri,
|
|
69
|
+
debug: debug
|
|
70
|
+
).perform(
|
|
71
|
+
method, path, config
|
|
72
|
+
)
|
|
60
73
|
end
|
|
61
|
-
end
|
|
74
|
+
end
|
|
75
|
+
end\n`
|
|
62
76
|
}
|
|
@@ -59,7 +59,10 @@ module Seam
|
|
|
59
59
|
{
|
|
60
60
|
"User-Agent" => user_agent,
|
|
61
61
|
"Content-Type" => "application/json",
|
|
62
|
-
"Authorization" => "Bearer #{api_key}"
|
|
62
|
+
"Authorization" => "Bearer #{api_key}",
|
|
63
|
+
"seam-sdk-name": "seamapi/ruby",
|
|
64
|
+
"seam-sdk-version": Seam::VERSION,
|
|
65
|
+
"seam-lts-version": Seam::LTS_VERSION
|
|
63
66
|
}
|
|
64
67
|
end
|
|
65
68
|
|
|
@@ -67,4 +70,4 @@ module Seam
|
|
|
67
70
|
"seam-ruby/#{Seam::VERSION}"
|
|
68
71
|
end
|
|
69
72
|
end
|
|
70
|
-
end`
|
|
73
|
+
end\n`
|