ittybit 0.7.4

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.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/lib/environment.rb +7 -0
  3. data/lib/gemconfig.rb +14 -0
  4. data/lib/ittybit/automations/client.rb +412 -0
  5. data/lib/ittybit/automations/types/automations_update_request_trigger.rb +75 -0
  6. data/lib/ittybit/automations/types/automations_update_request_trigger_conditions_item.rb +69 -0
  7. data/lib/ittybit/files/client.rb +437 -0
  8. data/lib/ittybit/files/types/files_delete_response.rb +89 -0
  9. data/lib/ittybit/files/types/files_delete_response_data.rb +60 -0
  10. data/lib/ittybit/media/client.rb +367 -0
  11. data/lib/ittybit/signatures/client.rb +132 -0
  12. data/lib/ittybit/signatures/types/signatures_create_request_method.rb +13 -0
  13. data/lib/ittybit/tasks/client.rb +379 -0
  14. data/lib/ittybit/tasks/types/tasks_create_request_kind.rb +22 -0
  15. data/lib/ittybit/tasks/types/tasks_list_request_kind.rb +26 -0
  16. data/lib/ittybit/tasks/types/tasks_list_request_status.rb +16 -0
  17. data/lib/ittybit/types/api_response_base.rb +5 -0
  18. data/lib/ittybit/types/automation.rb +141 -0
  19. data/lib/ittybit/types/automation_list_response.rb +90 -0
  20. data/lib/ittybit/types/automation_response.rb +87 -0
  21. data/lib/ittybit/types/automation_status.rb +10 -0
  22. data/lib/ittybit/types/automation_trigger.rb +72 -0
  23. data/lib/ittybit/types/automation_trigger_conditions_item.rb +65 -0
  24. data/lib/ittybit/types/confirmation_response.rb +87 -0
  25. data/lib/ittybit/types/confirmation_response_data.rb +55 -0
  26. data/lib/ittybit/types/error.rb +57 -0
  27. data/lib/ittybit/types/error_response.rb +74 -0
  28. data/lib/ittybit/types/file.rb +319 -0
  29. data/lib/ittybit/types/file_kind.rb +10 -0
  30. data/lib/ittybit/types/file_list_response.rb +90 -0
  31. data/lib/ittybit/types/file_object.rb +10 -0
  32. data/lib/ittybit/types/file_response.rb +87 -0
  33. data/lib/ittybit/types/file_status.rb +11 -0
  34. data/lib/ittybit/types/links.rb +67 -0
  35. data/lib/ittybit/types/links_list.rb +103 -0
  36. data/lib/ittybit/types/media.rb +195 -0
  37. data/lib/ittybit/types/media_kind.rb +10 -0
  38. data/lib/ittybit/types/media_list_response.rb +90 -0
  39. data/lib/ittybit/types/media_response.rb +87 -0
  40. data/lib/ittybit/types/media_source.rb +261 -0
  41. data/lib/ittybit/types/media_source_kind.rb +10 -0
  42. data/lib/ittybit/types/media_source_object.rb +10 -0
  43. data/lib/ittybit/types/media_source_status.rb +11 -0
  44. data/lib/ittybit/types/media_urls.rb +70 -0
  45. data/lib/ittybit/types/meta.rb +5 -0
  46. data/lib/ittybit/types/meta_list.rb +103 -0
  47. data/lib/ittybit/types/signature.rb +110 -0
  48. data/lib/ittybit/types/signature_response.rb +87 -0
  49. data/lib/ittybit/types/task.rb +204 -0
  50. data/lib/ittybit/types/task_kind.rb +5 -0
  51. data/lib/ittybit/types/task_list_response.rb +90 -0
  52. data/lib/ittybit/types/task_response.rb +87 -0
  53. data/lib/ittybit/types/task_results.rb +74 -0
  54. data/lib/ittybit/types/task_status.rb +15 -0
  55. data/lib/ittybit/types/task_summary.rb +138 -0
  56. data/lib/ittybit/types/task_summary_kind.rb +25 -0
  57. data/lib/ittybit/types/task_summary_status.rb +15 -0
  58. data/lib/ittybit/types/workflow_task_step.rb +112 -0
  59. data/lib/ittybit/types/workflow_task_step_kind.rb +25 -0
  60. data/lib/ittybit.rb +86 -0
  61. data/lib/requests.rb +177 -0
  62. data/lib/types_export.rb +53 -0
  63. metadata +185 -0
@@ -0,0 +1,379 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../requests"
4
+ require_relative "types/tasks_list_request_status"
5
+ require_relative "types/tasks_list_request_kind"
6
+ require_relative "../types/task_list_response"
7
+ require_relative "types/tasks_create_request_kind"
8
+ require_relative "../types/task_response"
9
+ require "json"
10
+ require "async"
11
+
12
+ module Ittybit
13
+ class TasksClient
14
+ # @return [Ittybit::RequestClient]
15
+ attr_reader :request_client
16
+
17
+ # @param request_client [Ittybit::RequestClient]
18
+ # @return [Ittybit::TasksClient]
19
+ def initialize(request_client:)
20
+ @request_client = request_client
21
+ end
22
+
23
+ # Retrieves a list of tasks for the project, optionally filtered by status or
24
+ # kind.
25
+ #
26
+ # @param limit [Integer] Items per page.
27
+ # @param status [Ittybit::Tasks::TasksListRequestStatus] Filter by task status.
28
+ # @param kind [Ittybit::Tasks::TasksListRequestKind] Filter by task kind.
29
+ # @param request_options [Ittybit::RequestOptions]
30
+ # @return [Ittybit::TaskListResponse]
31
+ # @example
32
+ # api = Ittybit::Client.new(
33
+ # base_url: "https://api.example.com",
34
+ # environment: Ittybit::Environment::DEFAULT,
35
+ # token: "YOUR_AUTH_TOKEN"
36
+ # )
37
+ # api.tasks.list
38
+ def list(limit: nil, status: nil, kind: nil, request_options: nil)
39
+ response = @request_client.conn.get do |req|
40
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
41
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
42
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
43
+ req.headers = {
44
+ **(req.headers || {}),
45
+ **@request_client.get_headers,
46
+ **(request_options&.additional_headers || {})
47
+ }.compact
48
+ req.params = {
49
+ **(request_options&.additional_query_parameters || {}),
50
+ "limit": limit,
51
+ "status": status,
52
+ "kind": kind
53
+ }.compact
54
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
55
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
56
+ end
57
+ req.url "#{@request_client.get_url(request_options: request_options)}/tasks"
58
+ end
59
+ Ittybit::TaskListResponse.from_json(json_object: response.body)
60
+ end
61
+
62
+ # Creates a new processing task (e.g., ingest, video transcode, speech analysis)
63
+ # or a workflow task.
64
+ #
65
+ # @param kind [Ittybit::Tasks::TasksCreateRequestKind] The type of task to create.
66
+ # @param url [String] URL of the source file (required for 'ingest' kind unless file_id is used, can
67
+ # be used for others).
68
+ # @param input [Hash{String => Object}] Task-specific input parameters depending on the kind of task.
69
+ # @param file_id [String] ID of an existing file to use as input (alternative to url).
70
+ # @param workflow [Array<Hash{String => Object}>] An array of task definition objects for a workflow.
71
+ # @param webhook_url [String] An optional HTTPS URL to send a webhook notification to upon task completion or
72
+ # failure.
73
+ # @param filename [String] Desired filename for the output (if applicable).
74
+ # @param folder [String] Desired output folder (if applicable).
75
+ # @param format [String] Output format (e.g., for video/image tasks).
76
+ # @param width [Integer] Output width (for video/image tasks).
77
+ # @param height [Integer] Output height (for video/image tasks).
78
+ # @param quality [Integer] Output quality setting (e.g., for video/image tasks, 0-100).
79
+ # @param request_options [Ittybit::RequestOptions]
80
+ # @return [Ittybit::TaskResponse]
81
+ # @example
82
+ # api = Ittybit::Client.new(
83
+ # base_url: "https://api.example.com",
84
+ # environment: Ittybit::Environment::DEFAULT,
85
+ # token: "YOUR_AUTH_TOKEN"
86
+ # )
87
+ # api.tasks.create(
88
+ # kind: INGEST,
89
+ # url: "https://example.com/some_video.mov",
90
+ # input: { "options": {"filename":"custom_name.mov"} }
91
+ # )
92
+ def create(kind:, url: nil, input: nil, file_id: nil, workflow: nil, webhook_url: nil, filename: nil, folder: nil,
93
+ format: nil, width: nil, height: nil, quality: nil, request_options: nil)
94
+ response = @request_client.conn.post do |req|
95
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
96
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
97
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
98
+ req.headers = {
99
+ **(req.headers || {}),
100
+ **@request_client.get_headers,
101
+ **(request_options&.additional_headers || {})
102
+ }.compact
103
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
104
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
105
+ end
106
+ req.body = {
107
+ **(request_options&.additional_body_parameters || {}),
108
+ kind: kind,
109
+ url: url,
110
+ input: input,
111
+ file_id: file_id,
112
+ workflow: workflow,
113
+ webhook_url: webhook_url,
114
+ filename: filename,
115
+ folder: folder,
116
+ format: format,
117
+ width: width,
118
+ height: height,
119
+ quality: quality
120
+ }.compact
121
+ req.url "#{@request_client.get_url(request_options: request_options)}/tasks"
122
+ end
123
+ Ittybit::TaskResponse.from_json(json_object: response.body)
124
+ end
125
+
126
+ # Retrieves available task kinds and their configuration options.
127
+ #
128
+ # @param request_options [Ittybit::RequestOptions]
129
+ # @return [Hash{String => Object}]
130
+ # @example
131
+ # api = Ittybit::Client.new(
132
+ # base_url: "https://api.example.com",
133
+ # environment: Ittybit::Environment::DEFAULT,
134
+ # token: "YOUR_AUTH_TOKEN"
135
+ # )
136
+ # api.tasks.get_task_config
137
+ def get_task_config(request_options: nil)
138
+ response = @request_client.conn.get do |req|
139
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
140
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
141
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
142
+ req.headers = {
143
+ **(req.headers || {}),
144
+ **@request_client.get_headers,
145
+ **(request_options&.additional_headers || {})
146
+ }.compact
147
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
148
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
149
+ end
150
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
151
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
152
+ end
153
+ req.url "#{@request_client.get_url(request_options: request_options)}/tasks-config"
154
+ end
155
+ JSON.parse(response.body)
156
+ end
157
+
158
+ # Retrieves the details of a specific task by its ID.
159
+ #
160
+ # @param id [String]
161
+ # @param request_options [Ittybit::RequestOptions]
162
+ # @return [Ittybit::TaskResponse]
163
+ # @example
164
+ # api = Ittybit::Client.new(
165
+ # base_url: "https://api.example.com",
166
+ # environment: Ittybit::Environment::DEFAULT,
167
+ # token: "YOUR_AUTH_TOKEN"
168
+ # )
169
+ # api.tasks.get(id: "id")
170
+ def get(id:, request_options: nil)
171
+ response = @request_client.conn.get do |req|
172
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
173
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
174
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
175
+ req.headers = {
176
+ **(req.headers || {}),
177
+ **@request_client.get_headers,
178
+ **(request_options&.additional_headers || {})
179
+ }.compact
180
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
181
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
182
+ end
183
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
184
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
185
+ end
186
+ req.url "#{@request_client.get_url(request_options: request_options)}/tasks/#{id}"
187
+ end
188
+ Ittybit::TaskResponse.from_json(json_object: response.body)
189
+ end
190
+ end
191
+
192
+ class AsyncTasksClient
193
+ # @return [Ittybit::AsyncRequestClient]
194
+ attr_reader :request_client
195
+
196
+ # @param request_client [Ittybit::AsyncRequestClient]
197
+ # @return [Ittybit::AsyncTasksClient]
198
+ def initialize(request_client:)
199
+ @request_client = request_client
200
+ end
201
+
202
+ # Retrieves a list of tasks for the project, optionally filtered by status or
203
+ # kind.
204
+ #
205
+ # @param limit [Integer] Items per page.
206
+ # @param status [Ittybit::Tasks::TasksListRequestStatus] Filter by task status.
207
+ # @param kind [Ittybit::Tasks::TasksListRequestKind] Filter by task kind.
208
+ # @param request_options [Ittybit::RequestOptions]
209
+ # @return [Ittybit::TaskListResponse]
210
+ # @example
211
+ # api = Ittybit::Client.new(
212
+ # base_url: "https://api.example.com",
213
+ # environment: Ittybit::Environment::DEFAULT,
214
+ # token: "YOUR_AUTH_TOKEN"
215
+ # )
216
+ # api.tasks.list
217
+ def list(limit: nil, status: nil, kind: nil, request_options: nil)
218
+ Async do
219
+ response = @request_client.conn.get do |req|
220
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
221
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
222
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
223
+ req.headers = {
224
+ **(req.headers || {}),
225
+ **@request_client.get_headers,
226
+ **(request_options&.additional_headers || {})
227
+ }.compact
228
+ req.params = {
229
+ **(request_options&.additional_query_parameters || {}),
230
+ "limit": limit,
231
+ "status": status,
232
+ "kind": kind
233
+ }.compact
234
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
235
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
236
+ end
237
+ req.url "#{@request_client.get_url(request_options: request_options)}/tasks"
238
+ end
239
+ Ittybit::TaskListResponse.from_json(json_object: response.body)
240
+ end
241
+ end
242
+
243
+ # Creates a new processing task (e.g., ingest, video transcode, speech analysis)
244
+ # or a workflow task.
245
+ #
246
+ # @param kind [Ittybit::Tasks::TasksCreateRequestKind] The type of task to create.
247
+ # @param url [String] URL of the source file (required for 'ingest' kind unless file_id is used, can
248
+ # be used for others).
249
+ # @param input [Hash{String => Object}] Task-specific input parameters depending on the kind of task.
250
+ # @param file_id [String] ID of an existing file to use as input (alternative to url).
251
+ # @param workflow [Array<Hash{String => Object}>] An array of task definition objects for a workflow.
252
+ # @param webhook_url [String] An optional HTTPS URL to send a webhook notification to upon task completion or
253
+ # failure.
254
+ # @param filename [String] Desired filename for the output (if applicable).
255
+ # @param folder [String] Desired output folder (if applicable).
256
+ # @param format [String] Output format (e.g., for video/image tasks).
257
+ # @param width [Integer] Output width (for video/image tasks).
258
+ # @param height [Integer] Output height (for video/image tasks).
259
+ # @param quality [Integer] Output quality setting (e.g., for video/image tasks, 0-100).
260
+ # @param request_options [Ittybit::RequestOptions]
261
+ # @return [Ittybit::TaskResponse]
262
+ # @example
263
+ # api = Ittybit::Client.new(
264
+ # base_url: "https://api.example.com",
265
+ # environment: Ittybit::Environment::DEFAULT,
266
+ # token: "YOUR_AUTH_TOKEN"
267
+ # )
268
+ # api.tasks.create(
269
+ # kind: INGEST,
270
+ # url: "https://example.com/some_video.mov",
271
+ # input: { "options": {"filename":"custom_name.mov"} }
272
+ # )
273
+ def create(kind:, url: nil, input: nil, file_id: nil, workflow: nil, webhook_url: nil, filename: nil, folder: nil,
274
+ format: nil, width: nil, height: nil, quality: nil, request_options: nil)
275
+ Async do
276
+ response = @request_client.conn.post do |req|
277
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
278
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
279
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
280
+ req.headers = {
281
+ **(req.headers || {}),
282
+ **@request_client.get_headers,
283
+ **(request_options&.additional_headers || {})
284
+ }.compact
285
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
286
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
287
+ end
288
+ req.body = {
289
+ **(request_options&.additional_body_parameters || {}),
290
+ kind: kind,
291
+ url: url,
292
+ input: input,
293
+ file_id: file_id,
294
+ workflow: workflow,
295
+ webhook_url: webhook_url,
296
+ filename: filename,
297
+ folder: folder,
298
+ format: format,
299
+ width: width,
300
+ height: height,
301
+ quality: quality
302
+ }.compact
303
+ req.url "#{@request_client.get_url(request_options: request_options)}/tasks"
304
+ end
305
+ Ittybit::TaskResponse.from_json(json_object: response.body)
306
+ end
307
+ end
308
+
309
+ # Retrieves available task kinds and their configuration options.
310
+ #
311
+ # @param request_options [Ittybit::RequestOptions]
312
+ # @return [Hash{String => Object}]
313
+ # @example
314
+ # api = Ittybit::Client.new(
315
+ # base_url: "https://api.example.com",
316
+ # environment: Ittybit::Environment::DEFAULT,
317
+ # token: "YOUR_AUTH_TOKEN"
318
+ # )
319
+ # api.tasks.get_task_config
320
+ def get_task_config(request_options: nil)
321
+ Async do
322
+ response = @request_client.conn.get do |req|
323
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
324
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
325
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
326
+ req.headers = {
327
+ **(req.headers || {}),
328
+ **@request_client.get_headers,
329
+ **(request_options&.additional_headers || {})
330
+ }.compact
331
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
332
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
333
+ end
334
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
335
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
336
+ end
337
+ req.url "#{@request_client.get_url(request_options: request_options)}/tasks-config"
338
+ end
339
+ parsed_json = JSON.parse(response.body)
340
+ parsed_json
341
+ end
342
+ end
343
+
344
+ # Retrieves the details of a specific task by its ID.
345
+ #
346
+ # @param id [String]
347
+ # @param request_options [Ittybit::RequestOptions]
348
+ # @return [Ittybit::TaskResponse]
349
+ # @example
350
+ # api = Ittybit::Client.new(
351
+ # base_url: "https://api.example.com",
352
+ # environment: Ittybit::Environment::DEFAULT,
353
+ # token: "YOUR_AUTH_TOKEN"
354
+ # )
355
+ # api.tasks.get(id: "id")
356
+ def get(id:, request_options: nil)
357
+ Async do
358
+ response = @request_client.conn.get do |req|
359
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
360
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
361
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
362
+ req.headers = {
363
+ **(req.headers || {}),
364
+ **@request_client.get_headers,
365
+ **(request_options&.additional_headers || {})
366
+ }.compact
367
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
368
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
369
+ end
370
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
371
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
372
+ end
373
+ req.url "#{@request_client.get_url(request_options: request_options)}/tasks/#{id}"
374
+ end
375
+ Ittybit::TaskResponse.from_json(json_object: response.body)
376
+ end
377
+ end
378
+ end
379
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ittybit
4
+ class Tasks
5
+ # The type of task to create.
6
+ class TasksCreateRequestKind
7
+ INGEST = "ingest"
8
+ WORKFLOW = "workflow"
9
+ SPEECH = "speech"
10
+ VIDEO = "video"
11
+ IMAGE = "image"
12
+ AUDIO = "audio"
13
+ SUMMARY = "summary"
14
+ DESCRIBE = "describe"
15
+ CHAPTERS = "chapters"
16
+ OUTLINE = "outline"
17
+ SUBTITLES = "subtitles"
18
+ NSFW = "nsfw"
19
+ THUMBNAILS = "thumbnails"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ittybit
4
+ class Tasks
5
+ class TasksListRequestKind
6
+ INGEST = "ingest"
7
+ WORKFLOW = "workflow"
8
+ SPEECH = "speech"
9
+ OUTLINE = "outline"
10
+ CHAPTERS = "chapters"
11
+ SUBTITLES = "subtitles"
12
+ THUMBNAILS = "thumbnails"
13
+ NSFW = "nsfw"
14
+ SUMMARY = "summary"
15
+ DESCRIBE = "describe"
16
+ VIDEO = "video"
17
+ IMAGE = "image"
18
+ AUDIO = "audio"
19
+ HTTP = "http"
20
+ CONDITIONS = "conditions"
21
+ STORE = "store"
22
+ PROMPT = "prompt"
23
+ TAGS = "tags"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ittybit
4
+ class Tasks
5
+ class TasksListRequestStatus
6
+ PENDING = "pending"
7
+ WAITING = "waiting"
8
+ PROCESSING = "processing"
9
+ READY = "ready"
10
+ COMPLETED = "completed"
11
+ FAILED = "failed"
12
+ ERROR = "error"
13
+ CANCELLED = "cancelled"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ittybit
4
+ API_RESPONSE_BASE = Object
5
+ end
@@ -0,0 +1,141 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "automation_trigger"
4
+ require_relative "workflow_task_step"
5
+ require_relative "automation_status"
6
+ require "date"
7
+ require "ostruct"
8
+ require "json"
9
+
10
+ module Ittybit
11
+ class Automation
12
+ # @return [String] Unique identifier for the automation
13
+ attr_reader :id
14
+ # @return [String] User-defined name for the automation
15
+ attr_reader :name
16
+ # @return [String] Optional description for the automation
17
+ attr_reader :description
18
+ # @return [Hash{String => Object}] User-defined key-value metadata for the automation.
19
+ attr_reader :metadata
20
+ # @return [Ittybit::AutomationTrigger] The event and conditions that trigger this automation.
21
+ attr_reader :trigger
22
+ # @return [Array<Ittybit::WorkflowTaskStep>] The sequence of tasks to be executed when the automation is triggered. The
23
+ # structure of each task object varies depending on its 'kind'.
24
+ attr_reader :workflow
25
+ # @return [Ittybit::AutomationStatus] Current status of the automation
26
+ attr_reader :status
27
+ # @return [DateTime] Timestamp when the automation was created
28
+ attr_reader :created
29
+ # @return [DateTime] Timestamp when the automation was last updated
30
+ attr_reader :updated
31
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
32
+ attr_reader :additional_properties
33
+ # @return [Object]
34
+ attr_reader :_field_set
35
+ protected :_field_set
36
+
37
+ OMIT = Object.new
38
+
39
+ # @param id [String] Unique identifier for the automation
40
+ # @param name [String] User-defined name for the automation
41
+ # @param description [String] Optional description for the automation
42
+ # @param metadata [Hash{String => Object}] User-defined key-value metadata for the automation.
43
+ # @param trigger [Ittybit::AutomationTrigger] The event and conditions that trigger this automation.
44
+ # @param workflow [Array<Ittybit::WorkflowTaskStep>] The sequence of tasks to be executed when the automation is triggered. The
45
+ # structure of each task object varies depending on its 'kind'.
46
+ # @param status [Ittybit::AutomationStatus] Current status of the automation
47
+ # @param created [DateTime] Timestamp when the automation was created
48
+ # @param updated [DateTime] Timestamp when the automation was last updated
49
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
50
+ # @return [Ittybit::Automation]
51
+ def initialize(id:, name:, trigger:, workflow:, status:, created:, updated:, description: OMIT, metadata: OMIT,
52
+ additional_properties: nil)
53
+ @id = id
54
+ @name = name
55
+ @description = description if description != OMIT
56
+ @metadata = metadata if metadata != OMIT
57
+ @trigger = trigger
58
+ @workflow = workflow
59
+ @status = status
60
+ @created = created
61
+ @updated = updated
62
+ @additional_properties = additional_properties
63
+ @_field_set = {
64
+ "id": id,
65
+ "name": name,
66
+ "description": description,
67
+ "metadata": metadata,
68
+ "trigger": trigger,
69
+ "workflow": workflow,
70
+ "status": status,
71
+ "created": created,
72
+ "updated": updated
73
+ }.reject do |_k, v|
74
+ v == OMIT
75
+ end
76
+ end
77
+
78
+ # Deserialize a JSON object to an instance of Automation
79
+ #
80
+ # @param json_object [String]
81
+ # @return [Ittybit::Automation]
82
+ def self.from_json(json_object:)
83
+ struct = JSON.parse(json_object, object_class: OpenStruct)
84
+ parsed_json = JSON.parse(json_object)
85
+ id = parsed_json["id"]
86
+ name = parsed_json["name"]
87
+ description = parsed_json["description"]
88
+ metadata = parsed_json["metadata"]
89
+ if parsed_json["trigger"].nil?
90
+ trigger = nil
91
+ else
92
+ trigger = parsed_json["trigger"].to_json
93
+ trigger = Ittybit::AutomationTrigger.from_json(json_object: trigger)
94
+ end
95
+ workflow = parsed_json["workflow"]&.map do |item|
96
+ item = item.to_json
97
+ Ittybit::WorkflowTaskStep.from_json(json_object: item)
98
+ end
99
+ status = parsed_json["status"]
100
+ created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
101
+ updated = (DateTime.parse(parsed_json["updated"]) unless parsed_json["updated"].nil?)
102
+ new(
103
+ id: id,
104
+ name: name,
105
+ description: description,
106
+ metadata: metadata,
107
+ trigger: trigger,
108
+ workflow: workflow,
109
+ status: status,
110
+ created: created,
111
+ updated: updated,
112
+ additional_properties: struct
113
+ )
114
+ end
115
+
116
+ # Serialize an instance of Automation to a JSON object
117
+ #
118
+ # @return [String]
119
+ def to_json(*_args)
120
+ @_field_set&.to_json
121
+ end
122
+
123
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
124
+ # hash and check each fields type against the current object's property
125
+ # definitions.
126
+ #
127
+ # @param obj [Object]
128
+ # @return [Void]
129
+ def self.validate_raw(obj:)
130
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
131
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
132
+ obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
133
+ obj.metadata&.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.")
134
+ Ittybit::AutomationTrigger.validate_raw(obj: obj.trigger)
135
+ obj.workflow.is_a?(Array) != false || raise("Passed value for field obj.workflow is not the expected type, validation failed.")
136
+ obj.status.is_a?(Ittybit::AutomationStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
137
+ obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
138
+ obj.updated.is_a?(DateTime) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.")
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "meta_list"
4
+ require_relative "automation"
5
+ require_relative "links_list"
6
+ require "ostruct"
7
+ require "json"
8
+
9
+ module Ittybit
10
+ class AutomationListResponse
11
+ # @return [Ittybit::MetaList]
12
+ attr_reader :meta
13
+ # @return [Array<Ittybit::Automation>]
14
+ attr_reader :data
15
+ # @return [Ittybit::LinksList]
16
+ attr_reader :links
17
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
18
+ attr_reader :additional_properties
19
+ # @return [Object]
20
+ attr_reader :_field_set
21
+ protected :_field_set
22
+
23
+ OMIT = Object.new
24
+
25
+ # @param meta [Ittybit::MetaList]
26
+ # @param data [Array<Ittybit::Automation>]
27
+ # @param links [Ittybit::LinksList]
28
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
29
+ # @return [Ittybit::AutomationListResponse]
30
+ def initialize(meta: OMIT, data: OMIT, links: OMIT, additional_properties: nil)
31
+ @meta = meta if meta != OMIT
32
+ @data = data if data != OMIT
33
+ @links = links if links != OMIT
34
+ @additional_properties = additional_properties
35
+ @_field_set = { "meta": meta, "data": data, "links": links }.reject do |_k, v|
36
+ v == OMIT
37
+ end
38
+ end
39
+
40
+ # Deserialize a JSON object to an instance of AutomationListResponse
41
+ #
42
+ # @param json_object [String]
43
+ # @return [Ittybit::AutomationListResponse]
44
+ def self.from_json(json_object:)
45
+ struct = JSON.parse(json_object, object_class: OpenStruct)
46
+ parsed_json = JSON.parse(json_object)
47
+ if parsed_json["meta"].nil?
48
+ meta = nil
49
+ else
50
+ meta = parsed_json["meta"].to_json
51
+ meta = Ittybit::MetaList.from_json(json_object: meta)
52
+ end
53
+ data = parsed_json["data"]&.map do |item|
54
+ item = item.to_json
55
+ Ittybit::Automation.from_json(json_object: item)
56
+ end
57
+ if parsed_json["links"].nil?
58
+ links = nil
59
+ else
60
+ links = parsed_json["links"].to_json
61
+ links = Ittybit::LinksList.from_json(json_object: links)
62
+ end
63
+ new(
64
+ meta: meta,
65
+ data: data,
66
+ links: links,
67
+ additional_properties: struct
68
+ )
69
+ end
70
+
71
+ # Serialize an instance of AutomationListResponse to a JSON object
72
+ #
73
+ # @return [String]
74
+ def to_json(*_args)
75
+ @_field_set&.to_json
76
+ end
77
+
78
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
79
+ # hash and check each fields type against the current object's property
80
+ # definitions.
81
+ #
82
+ # @param obj [Object]
83
+ # @return [Void]
84
+ def self.validate_raw(obj:)
85
+ obj.meta.nil? || Ittybit::MetaList.validate_raw(obj: obj.meta)
86
+ obj.data&.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.")
87
+ obj.links.nil? || Ittybit::LinksList.validate_raw(obj: obj.links)
88
+ end
89
+ end
90
+ end