buildkite-sdk 0.0.1 → 0.1.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.
data/lib/schema.rb ADDED
@@ -0,0 +1,2779 @@
1
+ # This code may look unusually verbose for Ruby (and it is), but
2
+ # it performs some subtle and complex validation of JSON data.
3
+ #
4
+ # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
5
+ #
6
+ # schema = Schema.from_json! "{…}"
7
+ # puts schema.steps.first
8
+ #
9
+ # If from_json! succeeds, the value returned matches the schema.
10
+
11
+ require "json"
12
+ require "dry-types"
13
+ require "dry-struct"
14
+
15
+ module Types
16
+ include Dry.Types(default: :nominal)
17
+
18
+ Integer = Strict::Integer
19
+ Nil = Strict::Nil
20
+ Bool = Strict::Bool
21
+ Hash = Strict::Hash
22
+ String = Strict::String
23
+ NotifyEnum = Strict::String.enum("github_check", "github_commit_status")
24
+ AllowDependencyFailureEnum = Strict::String.enum("false", "true")
25
+ BlockType = Strict::String.enum("block")
26
+ BlockedState = Strict::String.enum("failed", "passed", "running")
27
+ ExitStatusEnum = Strict::String.enum("*")
28
+ SignalReason = Strict::String.enum("agent_refused", "agent_stop", "cancel", "*", "none",
29
+ "process_run_error", "signature_rejected")
30
+ ScriptType = Strict::String.enum("command", "commands", "script")
31
+ ConcurrencyMethod = Strict::String.enum("eager", "ordered")
32
+ InputType = Strict::String.enum("input")
33
+ BlockStepType = Strict::String.enum("block", "command", "commands", "input", "script", "trigger",
34
+ "wait", "waiter")
35
+ TriggerType = Strict::String.enum("trigger")
36
+ WaiterType = Strict::String.enum("wait", "waiter")
37
+ StringStep = Strict::String.enum("block", "input", "wait", "waiter")
38
+ end
39
+
40
+ class Agents < Dry::Struct
41
+ attribute :anything_map, Types::Hash.meta(of: Types::Any).optional
42
+ attribute :string_array, Types.Array(Types::String).optional
43
+
44
+ def self.from_dynamic!(d)
45
+ begin
46
+ value = Types::Hash[d].transform_values { |v| Types::Any[v] }
47
+ return new(anything_map: value, string_array: nil) if schema[:anything_map].right.valid? value
48
+ rescue StandardError
49
+ end
50
+ return new(string_array: d, anything_map: nil) if schema[:string_array].right.valid? d
51
+
52
+ raise "Invalid union"
53
+ end
54
+
55
+ def self.from_json!(json)
56
+ from_dynamic!(JSON.parse(json))
57
+ end
58
+
59
+ def to_dynamic
60
+ if !anything_map.nil?
61
+ anything_map
62
+ elsif !string_array.nil?
63
+ string_array
64
+ end
65
+ end
66
+
67
+ def to_json(options = nil)
68
+ JSON.generate(to_dynamic, options)
69
+ end
70
+ end
71
+
72
+ class GithubCommitStatus1 < Dry::Struct
73
+ # GitHub commit status name
74
+ attribute :context, Types::String.optional
75
+
76
+ def self.from_dynamic!(d)
77
+ d = Types::Hash[d]
78
+ new(
79
+ context: d["context"]
80
+ )
81
+ end
82
+
83
+ def self.from_json!(json)
84
+ from_dynamic!(JSON.parse(json))
85
+ end
86
+
87
+ def to_dynamic
88
+ {
89
+ "context" => context
90
+ }
91
+ end
92
+
93
+ def to_json(options = nil)
94
+ JSON.generate(to_dynamic, options)
95
+ end
96
+ end
97
+
98
+ class Slack1 < Dry::Struct
99
+ attribute :channels, Types.Array(Types::String).optional
100
+ attribute :message, Types::String.optional
101
+
102
+ def self.from_dynamic!(d)
103
+ d = Types::Hash[d]
104
+ new(
105
+ channels: d["channels"],
106
+ message: d["message"]
107
+ )
108
+ end
109
+
110
+ def self.from_json!(json)
111
+ from_dynamic!(JSON.parse(json))
112
+ end
113
+
114
+ def to_dynamic
115
+ {
116
+ "channels" => channels,
117
+ "message" => message
118
+ }
119
+ end
120
+
121
+ def to_json(options = nil)
122
+ JSON.generate(to_dynamic, options)
123
+ end
124
+ end
125
+
126
+ class Slack4 < Dry::Struct
127
+ attribute :slack1, Slack1.optional
128
+ attribute :string, Types::String.optional
129
+
130
+ def self.from_dynamic!(d)
131
+ begin
132
+ value = Slack1.from_dynamic!(d)
133
+ return new(slack1: value, string: nil) if schema[:slack1].right.valid? value
134
+ rescue StandardError
135
+ end
136
+ return new(string: d, slack1: nil) if schema[:string].right.valid? d
137
+
138
+ raise "Invalid union"
139
+ end
140
+
141
+ def self.from_json!(json)
142
+ from_dynamic!(JSON.parse(json))
143
+ end
144
+
145
+ def to_dynamic
146
+ if !slack1.nil?
147
+ slack1.to_dynamic
148
+ elsif !string.nil?
149
+ string
150
+ end
151
+ end
152
+
153
+ def to_json(options = nil)
154
+ JSON.generate(to_dynamic, options)
155
+ end
156
+ end
157
+
158
+ class BuildNotify1 < Dry::Struct
159
+ attribute :email, Types::String.optional
160
+ attribute :build_notify_if, Types::String.optional
161
+ attribute :basecamp_campfire, Types::String.optional
162
+ attribute :slack, Types.Instance(Slack4).optional
163
+ attribute :webhook, Types::String.optional
164
+ attribute :pagerduty_change_event, Types::String.optional
165
+ attribute :github_commit_status, GithubCommitStatus1.optional
166
+ attribute :github_check, Types::Hash.meta(of: Types::Any).optional
167
+
168
+ def self.from_dynamic!(d)
169
+ d = Types::Hash[d]
170
+ new(
171
+ email: d["email"],
172
+ build_notify_if: d["if"],
173
+ basecamp_campfire: d["basecamp_campfire"],
174
+ slack: d["slack"] ? Slack4.from_dynamic!(d["slack"]) : nil,
175
+ webhook: d["webhook"],
176
+ pagerduty_change_event: d["pagerduty_change_event"],
177
+ github_commit_status: d["github_commit_status"] ? GithubCommitStatus1.from_dynamic!(d["github_commit_status"]) : nil,
178
+ github_check: Types::Hash.optional[d["github_check"]]&.transform_values { |v| Types::Any[v] }
179
+ )
180
+ end
181
+
182
+ def self.from_json!(json)
183
+ from_dynamic!(JSON.parse(json))
184
+ end
185
+
186
+ def to_dynamic
187
+ {
188
+ "email" => email,
189
+ "if" => build_notify_if,
190
+ "basecamp_campfire" => basecamp_campfire,
191
+ "slack" => slack&.to_dynamic,
192
+ "webhook" => webhook,
193
+ "pagerduty_change_event" => pagerduty_change_event,
194
+ "github_commit_status" => github_commit_status&.to_dynamic,
195
+ "github_check" => github_check
196
+ }
197
+ end
198
+
199
+ def to_json(options = nil)
200
+ JSON.generate(to_dynamic, options)
201
+ end
202
+ end
203
+
204
+ module NotifyEnum
205
+ GithubCheck = "github_check".freeze
206
+ GithubCommitStatus = "github_commit_status".freeze
207
+ end
208
+
209
+ # Array of notification options for this step
210
+ class SchemaNotify < Dry::Struct
211
+ attribute :build_notify1, BuildNotify1.optional
212
+ attribute :enum, Types::NotifyEnum.optional
213
+
214
+ def self.from_dynamic!(d)
215
+ begin
216
+ value = BuildNotify1.from_dynamic!(d)
217
+ return new(build_notify1: value, enum: nil) if schema[:build_notify1].right.valid? value
218
+ rescue StandardError
219
+ end
220
+ return new(enum: d, build_notify1: nil) if schema[:enum].right.valid? d
221
+
222
+ raise "Invalid union"
223
+ end
224
+
225
+ def self.from_json!(json)
226
+ from_dynamic!(JSON.parse(json))
227
+ end
228
+
229
+ def to_dynamic
230
+ if !build_notify1.nil?
231
+ build_notify1.to_dynamic
232
+ elsif !enum.nil?
233
+ enum
234
+ end
235
+ end
236
+
237
+ def to_json(options = nil)
238
+ JSON.generate(to_dynamic, options)
239
+ end
240
+ end
241
+
242
+ module AllowDependencyFailureEnum
243
+ False = "false".freeze
244
+ True = "true".freeze
245
+ end
246
+
247
+ class AllowDependencyFailureUnion < Dry::Struct
248
+ attribute :bool, Types::Bool.optional
249
+ attribute :enum, Types::AllowDependencyFailureEnum.optional
250
+
251
+ def self.from_dynamic!(d)
252
+ return new(bool: d, enum: nil) if schema[:bool].right.valid? d
253
+ return new(enum: d, bool: nil) if schema[:enum].right.valid? d
254
+
255
+ raise "Invalid union"
256
+ end
257
+
258
+ def self.from_json!(json)
259
+ from_dynamic!(JSON.parse(json))
260
+ end
261
+
262
+ def to_dynamic
263
+ if !bool.nil?
264
+ bool
265
+ elsif !enum.nil?
266
+ enum
267
+ end
268
+ end
269
+
270
+ def to_json(options = nil)
271
+ JSON.generate(to_dynamic, options)
272
+ end
273
+ end
274
+
275
+ # Which branches will include this step in their builds
276
+ #
277
+ # The value of the option(s) that will be pre-selected in the dropdown
278
+ #
279
+ # The glob path/s of artifacts to upload once this step has finished running
280
+ #
281
+ # The commands to run on the agent
282
+ class Branches < Dry::Struct
283
+ attribute :string, Types::String.optional
284
+ attribute :string_array, Types.Array(Types::String).optional
285
+
286
+ def self.from_dynamic!(d)
287
+ return new(string: d, string_array: nil) if schema[:string].right.valid? d
288
+ return new(string_array: d, string: nil) if schema[:string_array].right.valid? d
289
+
290
+ raise "Invalid union"
291
+ end
292
+
293
+ def self.from_json!(json)
294
+ from_dynamic!(JSON.parse(json))
295
+ end
296
+
297
+ def to_dynamic
298
+ if !string.nil?
299
+ string
300
+ elsif !string_array.nil?
301
+ string_array
302
+ end
303
+ end
304
+
305
+ def to_json(options = nil)
306
+ JSON.generate(to_dynamic, options)
307
+ end
308
+ end
309
+
310
+ module BlockType
311
+ Block = "block".freeze
312
+ end
313
+
314
+ # The state that the build is set to when the build is blocked by this block step
315
+ module BlockedState
316
+ Failed = "failed".freeze
317
+ Passed = "passed".freeze
318
+ Running = "running".freeze
319
+ end
320
+
321
+ class DependsOnClass < Dry::Struct
322
+ attribute :allow_failure, Types.Instance(AllowDependencyFailureUnion).optional
323
+ attribute :step, Types::String.optional
324
+
325
+ def self.from_dynamic!(d)
326
+ d = Types::Hash[d]
327
+ new(
328
+ allow_failure: d["allow_failure"] ? AllowDependencyFailureUnion.from_dynamic!(d["allow_failure"]) : nil,
329
+ step: d["step"]
330
+ )
331
+ end
332
+
333
+ def self.from_json!(json)
334
+ from_dynamic!(JSON.parse(json))
335
+ end
336
+
337
+ def to_dynamic
338
+ {
339
+ "allow_failure" => allow_failure&.to_dynamic,
340
+ "step" => step
341
+ }
342
+ end
343
+
344
+ def to_json(options = nil)
345
+ JSON.generate(to_dynamic, options)
346
+ end
347
+ end
348
+
349
+ class DependsOnElement < Dry::Struct
350
+ attribute :depends_on_class, DependsOnClass.optional
351
+ attribute :string, Types::String.optional
352
+
353
+ def self.from_dynamic!(d)
354
+ begin
355
+ value = DependsOnClass.from_dynamic!(d)
356
+ return new(depends_on_class: value, string: nil) if schema[:depends_on_class].right.valid? value
357
+ rescue StandardError
358
+ end
359
+ return new(string: d, depends_on_class: nil) if schema[:string].right.valid? d
360
+
361
+ raise "Invalid union"
362
+ end
363
+
364
+ def self.from_json!(json)
365
+ from_dynamic!(JSON.parse(json))
366
+ end
367
+
368
+ def to_dynamic
369
+ if !depends_on_class.nil?
370
+ depends_on_class.to_dynamic
371
+ elsif !string.nil?
372
+ string
373
+ end
374
+ end
375
+
376
+ def to_json(options = nil)
377
+ JSON.generate(to_dynamic, options)
378
+ end
379
+ end
380
+
381
+ # The step keys for a step to depend on
382
+ class DependsOn < Dry::Struct
383
+ attribute :null, Types::Nil.optional
384
+ attribute :string, Types::String.optional
385
+ attribute :union_array, Types.Array(Types.Instance(DependsOnElement)).optional
386
+
387
+ def self.from_dynamic!(d)
388
+ return new(null: d, union_array: nil, string: nil) if schema[:null].right.valid? d
389
+ return new(string: d, union_array: nil, null: nil) if schema[:string].right.valid? d
390
+
391
+ begin
392
+ value = d.map { |x| DependsOnElement.from_dynamic!(x) }
393
+ return new(union_array: value, null: nil, string: nil) if schema[:union_array].right.valid? value
394
+ rescue StandardError
395
+ end
396
+ raise "Invalid union"
397
+ end
398
+
399
+ def self.from_json!(json)
400
+ from_dynamic!(JSON.parse(json))
401
+ end
402
+
403
+ def to_dynamic
404
+ if !string.nil?
405
+ string
406
+ elsif !union_array.nil?
407
+ union_array.map(&:to_dynamic)
408
+ end
409
+ end
410
+
411
+ def to_json(options = nil)
412
+ JSON.generate(to_dynamic, options)
413
+ end
414
+ end
415
+
416
+ class Option < Dry::Struct
417
+ # The text displayed directly under the select field’s label
418
+ attribute :hint, Types::String.optional
419
+
420
+ # The text displayed on the select list item
421
+ attribute :label, Types::String
422
+
423
+ # Whether the field is required for form submission
424
+ attribute :required, Types.Instance(AllowDependencyFailureUnion).optional
425
+
426
+ # The value to be stored as meta-data
427
+ attribute :value, Types::String
428
+
429
+ def self.from_dynamic!(d)
430
+ d = Types::Hash[d]
431
+ new(
432
+ hint: d["hint"],
433
+ label: d.fetch("label"),
434
+ required: d["required"] ? AllowDependencyFailureUnion.from_dynamic!(d["required"]) : nil,
435
+ value: d.fetch("value")
436
+ )
437
+ end
438
+
439
+ def self.from_json!(json)
440
+ from_dynamic!(JSON.parse(json))
441
+ end
442
+
443
+ def to_dynamic
444
+ {
445
+ "hint" => hint,
446
+ "label" => label,
447
+ "required" => required&.to_dynamic,
448
+ "value" => value
449
+ }
450
+ end
451
+
452
+ def to_json(options = nil)
453
+ JSON.generate(to_dynamic, options)
454
+ end
455
+ end
456
+
457
+ # A list of input fields required to be filled out before unblocking the step
458
+ class Field < Dry::Struct
459
+ # The value that is pre-filled in the text field
460
+ #
461
+ # The value of the option(s) that will be pre-selected in the dropdown
462
+ attribute :field_default, Types.Instance(Branches).optional
463
+
464
+ # The format must be a regular expression implicitly anchored to the beginning and end of
465
+ # the input and is functionally equivalent to the HTML5 pattern attribute.
466
+ attribute :field_format, Types::String.optional
467
+
468
+ # The explanatory text that is shown after the label
469
+ attribute :hint, Types::String.optional
470
+
471
+ # The meta-data key that stores the field's input
472
+ attribute :key, Types::String
473
+
474
+ # Whether the field is required for form submission
475
+ attribute :required, Types.Instance(AllowDependencyFailureUnion).optional
476
+
477
+ # The text input name
478
+ attribute :text, Types::String.optional
479
+
480
+ # Whether more than one option may be selected
481
+ attribute :multiple, Types.Instance(AllowDependencyFailureUnion).optional
482
+
483
+ attribute :field_options, Types.Array(Option).optional
484
+
485
+ # The text input name
486
+ attribute :field_select, Types::String.optional
487
+
488
+ def self.from_dynamic!(d)
489
+ d = Types::Hash[d]
490
+ new(
491
+ field_default: d["default"] ? Branches.from_dynamic!(d["default"]) : nil,
492
+ field_format: d["format"],
493
+ hint: d["hint"],
494
+ key: d.fetch("key"),
495
+ required: d["required"] ? AllowDependencyFailureUnion.from_dynamic!(d["required"]) : nil,
496
+ text: d["text"],
497
+ multiple: d["multiple"] ? AllowDependencyFailureUnion.from_dynamic!(d["multiple"]) : nil,
498
+ field_options: d["options"]&.map { |x| Option.from_dynamic!(x) },
499
+ field_select: d["select"]
500
+ )
501
+ end
502
+
503
+ def self.from_json!(json)
504
+ from_dynamic!(JSON.parse(json))
505
+ end
506
+
507
+ def to_dynamic
508
+ {
509
+ "default" => field_default&.to_dynamic,
510
+ "format" => field_format,
511
+ "hint" => hint,
512
+ "key" => key,
513
+ "required" => required&.to_dynamic,
514
+ "text" => text,
515
+ "multiple" => multiple&.to_dynamic,
516
+ "options" => field_options&.map(&:to_dynamic),
517
+ "select" => field_select
518
+ }
519
+ end
520
+
521
+ def to_json(options = nil)
522
+ JSON.generate(to_dynamic, options)
523
+ end
524
+ end
525
+
526
+ class BlockStep < Dry::Struct
527
+ attribute :allow_dependency_failure, Types.Instance(AllowDependencyFailureUnion).optional
528
+
529
+ # The label of the block step
530
+ attribute :block, Types::String.optional
531
+
532
+ # The state that the build is set to when the build is blocked by this block step
533
+ attribute :blocked_state, Types::BlockedState.optional
534
+
535
+ attribute :branches, Types.Instance(Branches).optional
536
+ attribute :depends_on, Types.Instance(DependsOn).optional
537
+ attribute :fields, Types.Array(Field).optional
538
+ attribute :id, Types::String.optional
539
+ attribute :identifier, Types::String.optional
540
+ attribute :block_step_if, Types::String.optional
541
+ attribute :key, Types::String.optional
542
+ attribute :label, Types::String.optional
543
+ attribute :block_step_name, Types::String.optional
544
+ attribute :prompt, Types::String.optional
545
+ attribute :block_step_type, Types::BlockType.optional
546
+
547
+ def self.from_dynamic!(d)
548
+ d = Types::Hash[d]
549
+ new(
550
+ allow_dependency_failure: d["allow_dependency_failure"] ? AllowDependencyFailureUnion.from_dynamic!(d["allow_dependency_failure"]) : nil,
551
+ block: d["block"],
552
+ blocked_state: d["blocked_state"],
553
+ branches: d["branches"] ? Branches.from_dynamic!(d["branches"]) : nil,
554
+ depends_on: d["depends_on"] ? DependsOn.from_dynamic!(d["depends_on"]) : nil,
555
+ fields: d["fields"]&.map { |x| Field.from_dynamic!(x) },
556
+ id: d["id"],
557
+ identifier: d["identifier"],
558
+ block_step_if: d["if"],
559
+ key: d["key"],
560
+ label: d["label"],
561
+ block_step_name: d["name"],
562
+ prompt: d["prompt"],
563
+ block_step_type: d["type"]
564
+ )
565
+ end
566
+
567
+ def self.from_json!(json)
568
+ from_dynamic!(JSON.parse(json))
569
+ end
570
+
571
+ def to_dynamic
572
+ {
573
+ "allow_dependency_failure" => allow_dependency_failure&.to_dynamic,
574
+ "block" => block,
575
+ "blocked_state" => blocked_state,
576
+ "branches" => branches&.to_dynamic,
577
+ "depends_on" => depends_on&.to_dynamic,
578
+ "fields" => fields&.map(&:to_dynamic),
579
+ "id" => id,
580
+ "identifier" => identifier,
581
+ "if" => block_step_if,
582
+ "key" => key,
583
+ "label" => label,
584
+ "name" => block_step_name,
585
+ "prompt" => prompt,
586
+ "type" => block_step_type
587
+ }
588
+ end
589
+
590
+ def to_json(options = nil)
591
+ JSON.generate(to_dynamic, options)
592
+ end
593
+ end
594
+
595
+ class Block < Dry::Struct
596
+ attribute :block_step, BlockStep.optional
597
+ attribute :string, Types::String.optional
598
+
599
+ def self.from_dynamic!(d)
600
+ begin
601
+ value = BlockStep.from_dynamic!(d)
602
+ return new(block_step: value, string: nil) if schema[:block_step].right.valid? value
603
+ rescue StandardError
604
+ end
605
+ return new(string: d, block_step: nil) if schema[:string].right.valid? d
606
+
607
+ raise "Invalid union"
608
+ end
609
+
610
+ def self.from_json!(json)
611
+ from_dynamic!(JSON.parse(json))
612
+ end
613
+
614
+ def to_dynamic
615
+ if !block_step.nil?
616
+ block_step.to_dynamic
617
+ elsif !string.nil?
618
+ string
619
+ end
620
+ end
621
+
622
+ def to_json(options = nil)
623
+ JSON.generate(to_dynamic, options)
624
+ end
625
+ end
626
+
627
+ # Properties of the build that will be created when the step is triggered
628
+ class Build < Dry::Struct
629
+ # The branch for the build
630
+ attribute :branch, Types::String.optional
631
+
632
+ # The commit hash for the build
633
+ attribute :commit, Types::String.optional
634
+
635
+ attribute :env, Types::Hash.meta(of: Types::Any).optional
636
+
637
+ # The message for the build (supports emoji)
638
+ attribute :message, Types::String.optional
639
+
640
+ # Meta-data for the build
641
+ attribute :meta_data, Types::Hash.meta(of: Types::Any).optional
642
+
643
+ def self.from_dynamic!(d)
644
+ d = Types::Hash[d]
645
+ new(
646
+ branch: d["branch"],
647
+ commit: d["commit"],
648
+ env: Types::Hash.optional[d["env"]]&.transform_values { |v| Types::Any[v] },
649
+ message: d["message"],
650
+ meta_data: Types::Hash.optional[d["meta_data"]]&.transform_values { |v| Types::Any[v] }
651
+ )
652
+ end
653
+
654
+ def self.from_json!(json)
655
+ from_dynamic!(JSON.parse(json))
656
+ end
657
+
658
+ def to_dynamic
659
+ {
660
+ "branch" => branch,
661
+ "commit" => commit,
662
+ "env" => env,
663
+ "message" => message,
664
+ "meta_data" => meta_data
665
+ }
666
+ end
667
+
668
+ def to_json(options = nil)
669
+ JSON.generate(to_dynamic, options)
670
+ end
671
+ end
672
+
673
+ class CacheClass < Dry::Struct
674
+ attribute :cache_name, Types::String.optional
675
+ attribute :paths, Types.Array(Types::String)
676
+ attribute :size, Types::String.optional
677
+
678
+ def self.from_dynamic!(d)
679
+ d = Types::Hash[d]
680
+ new(
681
+ cache_name: d["name"],
682
+ paths: d.fetch("paths"),
683
+ size: d["size"]
684
+ )
685
+ end
686
+
687
+ def self.from_json!(json)
688
+ from_dynamic!(JSON.parse(json))
689
+ end
690
+
691
+ def to_dynamic
692
+ {
693
+ "name" => cache_name,
694
+ "paths" => paths,
695
+ "size" => size
696
+ }
697
+ end
698
+
699
+ def to_json(options = nil)
700
+ JSON.generate(to_dynamic, options)
701
+ end
702
+ end
703
+
704
+ # The paths for the caches to be used in the step
705
+ class Cache < Dry::Struct
706
+ attribute :cache_class, CacheClass.optional
707
+ attribute :string, Types::String.optional
708
+ attribute :string_array, Types.Array(Types::String).optional
709
+
710
+ def self.from_dynamic!(d)
711
+ begin
712
+ value = CacheClass.from_dynamic!(d)
713
+ return new(cache_class: value, string_array: nil, string: nil) if schema[:cache_class].right.valid? value
714
+ rescue StandardError
715
+ end
716
+ return new(string: d, string_array: nil, cache_class: nil) if schema[:string].right.valid? d
717
+ return new(string_array: d, cache_class: nil, string: nil) if schema[:string_array].right.valid? d
718
+
719
+ raise "Invalid union"
720
+ end
721
+
722
+ def self.from_json!(json)
723
+ from_dynamic!(JSON.parse(json))
724
+ end
725
+
726
+ def to_dynamic
727
+ if !cache_class.nil?
728
+ cache_class.to_dynamic
729
+ elsif !string.nil?
730
+ string
731
+ elsif !string_array.nil?
732
+ string_array
733
+ end
734
+ end
735
+
736
+ def to_json(options = nil)
737
+ JSON.generate(to_dynamic, options)
738
+ end
739
+ end
740
+
741
+ module ExitStatusEnum
742
+ Empty = "*".freeze
743
+ end
744
+
745
+ # The exit status number that will cause this job to retry
746
+ class AutomaticRetryExitStatus < Dry::Struct
747
+ attribute :enum, Types::ExitStatusEnum.optional
748
+ attribute :integer, Types::Integer.optional
749
+ attribute :integer_array, Types.Array(Types::Integer).optional
750
+
751
+ def self.from_dynamic!(d)
752
+ return new(enum: d, integer_array: nil, integer: nil) if schema[:enum].right.valid? d
753
+ return new(integer: d, integer_array: nil, enum: nil) if schema[:integer].right.valid? d
754
+ return new(integer_array: d, enum: nil, integer: nil) if schema[:integer_array].right.valid? d
755
+
756
+ raise "Invalid union"
757
+ end
758
+
759
+ def self.from_json!(json)
760
+ from_dynamic!(JSON.parse(json))
761
+ end
762
+
763
+ def to_dynamic
764
+ if !enum.nil?
765
+ enum
766
+ elsif !integer.nil?
767
+ integer
768
+ elsif !integer_array.nil?
769
+ integer_array
770
+ end
771
+ end
772
+
773
+ def to_json(options = nil)
774
+ JSON.generate(to_dynamic, options)
775
+ end
776
+ end
777
+
778
+ # The exit signal reason, if any, that may be retried
779
+ module SignalReason
780
+ AgentRefused = "agent_refused".freeze
781
+ AgentStop = "agent_stop".freeze
782
+ Cancel = "cancel".freeze
783
+ Empty = "*".freeze
784
+ None = "none".freeze
785
+ ProcessRunError = "process_run_error".freeze
786
+ SignatureRejected = "signature_rejected".freeze
787
+ end
788
+
789
+ class AutomaticRetry < Dry::Struct
790
+ # The exit status number that will cause this job to retry
791
+ attribute :exit_status, Types.Instance(AutomaticRetryExitStatus).optional
792
+
793
+ # The number of times this job can be retried
794
+ attribute :limit, Types::Integer.optional
795
+
796
+ # The exit signal, if any, that may be retried
797
+ attribute :signal, Types::String.optional
798
+
799
+ # The exit signal reason, if any, that may be retried
800
+ attribute :signal_reason, Types::SignalReason.optional
801
+
802
+ def self.from_dynamic!(d)
803
+ d = Types::Hash[d]
804
+ new(
805
+ exit_status: d["exit_status"] ? AutomaticRetryExitStatus.from_dynamic!(d["exit_status"]) : nil,
806
+ limit: d["limit"],
807
+ signal: d["signal"],
808
+ signal_reason: d["signal_reason"]
809
+ )
810
+ end
811
+
812
+ def self.from_json!(json)
813
+ from_dynamic!(JSON.parse(json))
814
+ end
815
+
816
+ def to_dynamic
817
+ {
818
+ "exit_status" => exit_status&.to_dynamic,
819
+ "limit" => limit,
820
+ "signal" => signal,
821
+ "signal_reason" => signal_reason
822
+ }
823
+ end
824
+
825
+ def to_json(options = nil)
826
+ JSON.generate(to_dynamic, options)
827
+ end
828
+ end
829
+
830
+ # Whether to allow a job to retry automatically. If set to true, the retry conditions are
831
+ # set to the default value.
832
+ class Automatic < Dry::Struct
833
+ attribute :automatic_retry, AutomaticRetry.optional
834
+ attribute :automatic_retry_array, Types.Array(AutomaticRetry).optional
835
+ attribute :bool, Types::Bool.optional
836
+ attribute :enum, Types::AllowDependencyFailureEnum.optional
837
+
838
+ def self.from_dynamic!(d)
839
+ begin
840
+ value = AutomaticRetry.from_dynamic!(d)
841
+ if schema[:automatic_retry].right.valid? value
842
+ return new(automatic_retry: value, automatic_retry_array: nil, bool: nil, enum: nil)
843
+ end
844
+ rescue StandardError
845
+ end
846
+ begin
847
+ value = d.map { |x| AutomaticRetry.from_dynamic!(x) }
848
+ if schema[:automatic_retry_array].right.valid? value
849
+ return new(automatic_retry_array: value, bool: nil, automatic_retry: nil, enum: nil)
850
+ end
851
+ rescue StandardError
852
+ end
853
+ return new(bool: d, automatic_retry_array: nil, automatic_retry: nil, enum: nil) if schema[:bool].right.valid? d
854
+ return new(enum: d, automatic_retry_array: nil, bool: nil, automatic_retry: nil) if schema[:enum].right.valid? d
855
+
856
+ raise "Invalid union"
857
+ end
858
+
859
+ def self.from_json!(json)
860
+ from_dynamic!(JSON.parse(json))
861
+ end
862
+
863
+ def to_dynamic
864
+ if !automatic_retry.nil?
865
+ automatic_retry.to_dynamic
866
+ elsif !automatic_retry_array.nil?
867
+ automatic_retry_array.map(&:to_dynamic)
868
+ elsif !bool.nil?
869
+ bool
870
+ elsif !enum.nil?
871
+ enum
872
+ end
873
+ end
874
+
875
+ def to_json(options = nil)
876
+ JSON.generate(to_dynamic, options)
877
+ end
878
+ end
879
+
880
+ class ManualClass < Dry::Struct
881
+ # Whether or not this job can be retried manually
882
+ attribute :allowed, Types.Instance(AllowDependencyFailureUnion).optional
883
+
884
+ # Whether or not this job can be retried after it has passed
885
+ attribute :permit_on_passed, Types.Instance(AllowDependencyFailureUnion).optional
886
+
887
+ # A string that will be displayed in a tooltip on the Retry button in Buildkite. This will
888
+ # only be displayed if the allowed attribute is set to false.
889
+ attribute :reason, Types::String.optional
890
+
891
+ def self.from_dynamic!(d)
892
+ d = Types::Hash[d]
893
+ new(
894
+ allowed: d["allowed"] ? AllowDependencyFailureUnion.from_dynamic!(d["allowed"]) : nil,
895
+ permit_on_passed: d["permit_on_passed"] ? AllowDependencyFailureUnion.from_dynamic!(d["permit_on_passed"]) : nil,
896
+ reason: d["reason"]
897
+ )
898
+ end
899
+
900
+ def self.from_json!(json)
901
+ from_dynamic!(JSON.parse(json))
902
+ end
903
+
904
+ def to_dynamic
905
+ {
906
+ "allowed" => allowed&.to_dynamic,
907
+ "permit_on_passed" => permit_on_passed&.to_dynamic,
908
+ "reason" => reason
909
+ }
910
+ end
911
+
912
+ def to_json(options = nil)
913
+ JSON.generate(to_dynamic, options)
914
+ end
915
+ end
916
+
917
+ # Whether to allow a job to be retried manually
918
+ class ManualUnion < Dry::Struct
919
+ attribute :bool, Types::Bool.optional
920
+ attribute :enum, Types::AllowDependencyFailureEnum.optional
921
+ attribute :manual_class, ManualClass.optional
922
+
923
+ def self.from_dynamic!(d)
924
+ return new(bool: d, manual_class: nil, enum: nil) if schema[:bool].right.valid? d
925
+ return new(enum: d, bool: nil, manual_class: nil) if schema[:enum].right.valid? d
926
+
927
+ begin
928
+ value = ManualClass.from_dynamic!(d)
929
+ return new(manual_class: value, bool: nil, enum: nil) if schema[:manual_class].right.valid? value
930
+ rescue StandardError
931
+ end
932
+ raise "Invalid union"
933
+ end
934
+
935
+ def self.from_json!(json)
936
+ from_dynamic!(JSON.parse(json))
937
+ end
938
+
939
+ def to_dynamic
940
+ if !bool.nil?
941
+ bool
942
+ elsif !enum.nil?
943
+ enum
944
+ elsif !manual_class.nil?
945
+ manual_class.to_dynamic
946
+ end
947
+ end
948
+
949
+ def to_json(options = nil)
950
+ JSON.generate(to_dynamic, options)
951
+ end
952
+ end
953
+
954
+ # The conditions for retrying this step.
955
+ class Retry < Dry::Struct
956
+ # Whether to allow a job to retry automatically. If set to true, the retry conditions are
957
+ # set to the default value.
958
+ attribute :automatic, Types.Instance(Automatic).optional
959
+
960
+ # Whether to allow a job to be retried manually
961
+ attribute :manual, Types.Instance(ManualUnion).optional
962
+
963
+ def self.from_dynamic!(d)
964
+ d = Types::Hash[d]
965
+ new(
966
+ automatic: d["automatic"] ? Automatic.from_dynamic!(d["automatic"]) : nil,
967
+ manual: d["manual"] ? ManualUnion.from_dynamic!(d["manual"]) : nil
968
+ )
969
+ end
970
+
971
+ def self.from_json!(json)
972
+ from_dynamic!(JSON.parse(json))
973
+ end
974
+
975
+ def to_dynamic
976
+ {
977
+ "automatic" => automatic&.to_dynamic,
978
+ "manual" => manual&.to_dynamic
979
+ }
980
+ end
981
+
982
+ def to_json(options = nil)
983
+ JSON.generate(to_dynamic, options)
984
+ end
985
+ end
986
+
987
+ module ScriptType
988
+ Command = "command".freeze
989
+ Commands = "commands".freeze
990
+ Script = "script".freeze
991
+ end
992
+
993
+ # Control command order, allowed values are 'ordered' (default) and 'eager'. If you use
994
+ # this attribute, you must also define concurrency_group and concurrency.
995
+ module ConcurrencyMethod
996
+ Eager = "eager".freeze
997
+ Ordered = "ordered".freeze
998
+ end
999
+
1000
+ # List of elements for simple single-dimension Build Matrix
1001
+ #
1002
+ # List of existing or new elements for single-dimension Build Matrix
1003
+ #
1004
+ # List of elements for single-dimension Build Matrix
1005
+ #
1006
+ # List of elements for this Build Matrix dimension
1007
+ class MatrixElement < Dry::Struct
1008
+ attribute :bool, Types::Bool.optional
1009
+ attribute :integer, Types::Integer.optional
1010
+ attribute :string, Types::String.optional
1011
+
1012
+ def self.from_dynamic!(d)
1013
+ return new(bool: d, integer: nil, string: nil) if schema[:bool].right.valid? d
1014
+ return new(integer: d, bool: nil, string: nil) if schema[:integer].right.valid? d
1015
+ return new(string: d, bool: nil, integer: nil) if schema[:string].right.valid? d
1016
+
1017
+ raise "Invalid union"
1018
+ end
1019
+
1020
+ def self.from_json!(json)
1021
+ from_dynamic!(JSON.parse(json))
1022
+ end
1023
+
1024
+ def to_dynamic
1025
+ if !bool.nil?
1026
+ bool
1027
+ elsif !integer.nil?
1028
+ integer
1029
+ elsif !string.nil?
1030
+ string
1031
+ end
1032
+ end
1033
+
1034
+ def to_json(options = nil)
1035
+ JSON.generate(to_dynamic, options)
1036
+ end
1037
+ end
1038
+
1039
+ class With < Dry::Struct
1040
+ attribute :string_map, Types::Hash.meta(of: Types::String).optional
1041
+ attribute :union_array, Types.Array(Types.Instance(MatrixElement)).optional
1042
+
1043
+ def self.from_dynamic!(d)
1044
+ begin
1045
+ value = Types::Hash[d].transform_values { |v| Types::String[v] }
1046
+ return new(string_map: value, union_array: nil) if schema[:string_map].right.valid? value
1047
+ rescue StandardError
1048
+ end
1049
+ begin
1050
+ value = d.map { |x| MatrixElement.from_dynamic!(x) }
1051
+ return new(union_array: value, string_map: nil) if schema[:union_array].right.valid? value
1052
+ rescue StandardError
1053
+ end
1054
+ raise "Invalid union"
1055
+ end
1056
+
1057
+ def self.from_json!(json)
1058
+ from_dynamic!(JSON.parse(json))
1059
+ end
1060
+
1061
+ def to_dynamic
1062
+ if !string_map.nil?
1063
+ string_map
1064
+ elsif !union_array.nil?
1065
+ union_array.map(&:to_dynamic)
1066
+ end
1067
+ end
1068
+
1069
+ def to_json(options = nil)
1070
+ JSON.generate(to_dynamic, options)
1071
+ end
1072
+ end
1073
+
1074
+ # Whether this step should be skipped. Passing a string provides a reason for skipping this
1075
+ # command
1076
+ class Skip < Dry::Struct
1077
+ attribute :bool, Types::Bool.optional
1078
+ attribute :string, Types::String.optional
1079
+
1080
+ def self.from_dynamic!(d)
1081
+ return new(bool: d, string: nil) if schema[:bool].right.valid? d
1082
+ return new(string: d, bool: nil) if schema[:string].right.valid? d
1083
+
1084
+ raise "Invalid union"
1085
+ end
1086
+
1087
+ def self.from_json!(json)
1088
+ from_dynamic!(JSON.parse(json))
1089
+ end
1090
+
1091
+ def to_dynamic
1092
+ if !bool.nil?
1093
+ bool
1094
+ elsif !string.nil?
1095
+ string
1096
+ end
1097
+ end
1098
+
1099
+ def to_json(options = nil)
1100
+ JSON.generate(to_dynamic, options)
1101
+ end
1102
+ end
1103
+
1104
+ # The exit status number that will cause this job to soft-fail
1105
+ class SoftFailExitStatus < Dry::Struct
1106
+ attribute :enum, Types::ExitStatusEnum.optional
1107
+ attribute :integer, Types::Integer.optional
1108
+
1109
+ def self.from_dynamic!(d)
1110
+ return new(enum: d, integer: nil) if schema[:enum].right.valid? d
1111
+ return new(integer: d, enum: nil) if schema[:integer].right.valid? d
1112
+
1113
+ raise "Invalid union"
1114
+ end
1115
+
1116
+ def self.from_json!(json)
1117
+ from_dynamic!(JSON.parse(json))
1118
+ end
1119
+
1120
+ def to_dynamic
1121
+ if !enum.nil?
1122
+ enum
1123
+ elsif !integer.nil?
1124
+ integer
1125
+ end
1126
+ end
1127
+
1128
+ def to_json(options = nil)
1129
+ JSON.generate(to_dynamic, options)
1130
+ end
1131
+ end
1132
+
1133
+ class SoftFailElement < Dry::Struct
1134
+ # The exit status number that will cause this job to soft-fail
1135
+ attribute :exit_status, Types.Instance(SoftFailExitStatus).optional
1136
+
1137
+ def self.from_dynamic!(d)
1138
+ d = Types::Hash[d]
1139
+ new(
1140
+ exit_status: d["exit_status"] ? SoftFailExitStatus.from_dynamic!(d["exit_status"]) : nil
1141
+ )
1142
+ end
1143
+
1144
+ def self.from_json!(json)
1145
+ from_dynamic!(JSON.parse(json))
1146
+ end
1147
+
1148
+ def to_dynamic
1149
+ {
1150
+ "exit_status" => exit_status&.to_dynamic
1151
+ }
1152
+ end
1153
+
1154
+ def to_json(options = nil)
1155
+ JSON.generate(to_dynamic, options)
1156
+ end
1157
+ end
1158
+
1159
+ # The conditions for marking the step as a soft-fail.
1160
+ class SoftFail < Dry::Struct
1161
+ attribute :bool, Types::Bool.optional
1162
+ attribute :enum, Types::AllowDependencyFailureEnum.optional
1163
+ attribute :soft_fail_element_array, Types.Array(SoftFailElement).optional
1164
+
1165
+ def self.from_dynamic!(d)
1166
+ return new(bool: d, soft_fail_element_array: nil, enum: nil) if schema[:bool].right.valid? d
1167
+ return new(enum: d, soft_fail_element_array: nil, bool: nil) if schema[:enum].right.valid? d
1168
+
1169
+ begin
1170
+ value = d.map { |x| SoftFailElement.from_dynamic!(x) }
1171
+ if schema[:soft_fail_element_array].right.valid? value
1172
+ return new(soft_fail_element_array: value, bool: nil, enum: nil)
1173
+ end
1174
+ rescue StandardError
1175
+ end
1176
+ raise "Invalid union"
1177
+ end
1178
+
1179
+ def self.from_json!(json)
1180
+ from_dynamic!(JSON.parse(json))
1181
+ end
1182
+
1183
+ def to_dynamic
1184
+ if !bool.nil?
1185
+ bool
1186
+ elsif !enum.nil?
1187
+ enum
1188
+ elsif !soft_fail_element_array.nil?
1189
+ soft_fail_element_array.map(&:to_dynamic)
1190
+ end
1191
+ end
1192
+
1193
+ def to_json(options = nil)
1194
+ JSON.generate(to_dynamic, options)
1195
+ end
1196
+ end
1197
+
1198
+ # An adjustment to a Build Matrix
1199
+ class Adjustment < Dry::Struct
1200
+ attribute :skip, Types.Instance(Skip).optional
1201
+ attribute :soft_fail, Types.Instance(SoftFail).optional
1202
+ attribute :adjustment_with, Types.Instance(With)
1203
+
1204
+ def self.from_dynamic!(d)
1205
+ d = Types::Hash[d]
1206
+ new(
1207
+ skip: d["skip"] ? Skip.from_dynamic!(d["skip"]) : nil,
1208
+ soft_fail: d["soft_fail"] ? SoftFail.from_dynamic!(d["soft_fail"]) : nil,
1209
+ adjustment_with: With.from_dynamic!(d.fetch("with"))
1210
+ )
1211
+ end
1212
+
1213
+ def self.from_json!(json)
1214
+ from_dynamic!(JSON.parse(json))
1215
+ end
1216
+
1217
+ def to_dynamic
1218
+ {
1219
+ "skip" => skip&.to_dynamic,
1220
+ "soft_fail" => soft_fail&.to_dynamic,
1221
+ "with" => adjustment_with.to_dynamic
1222
+ }
1223
+ end
1224
+
1225
+ def to_json(options = nil)
1226
+ JSON.generate(to_dynamic, options)
1227
+ end
1228
+ end
1229
+
1230
+ class Setup < Dry::Struct
1231
+ attribute :union_array, Types.Array(Types.Instance(MatrixElement)).optional
1232
+ attribute :union_array_map, Types::Hash.meta(of: Types.Array(Types.Instance(MatrixElement))).optional
1233
+
1234
+ def self.from_dynamic!(d)
1235
+ begin
1236
+ value = d.map { |x| MatrixElement.from_dynamic!(x) }
1237
+ return new(union_array: value, union_array_map: nil) if schema[:union_array].right.valid? value
1238
+ rescue StandardError
1239
+ end
1240
+ begin
1241
+ value = Types::Hash[d].transform_values { |v| v.map { |x| MatrixElement.from_dynamic!(x) } }
1242
+ return new(union_array_map: value, union_array: nil) if schema[:union_array_map].right.valid? value
1243
+ rescue StandardError
1244
+ end
1245
+ raise "Invalid union"
1246
+ end
1247
+
1248
+ def self.from_json!(json)
1249
+ from_dynamic!(JSON.parse(json))
1250
+ end
1251
+
1252
+ def to_dynamic
1253
+ if !union_array.nil?
1254
+ union_array.map(&:to_dynamic)
1255
+ elsif !union_array_map.nil?
1256
+ union_array_map.transform_values { |v| v.map(&:to_dynamic) }
1257
+ end
1258
+ end
1259
+
1260
+ def to_json(options = nil)
1261
+ JSON.generate(to_dynamic, options)
1262
+ end
1263
+ end
1264
+
1265
+ # Configuration for multi-dimension Build Matrix
1266
+ class MatrixClass < Dry::Struct
1267
+ # List of Build Matrix adjustments
1268
+ attribute :adjustments, Types.Array(Adjustment).optional
1269
+
1270
+ attribute :setup, Types.Instance(Setup)
1271
+
1272
+ def self.from_dynamic!(d)
1273
+ d = Types::Hash[d]
1274
+ new(
1275
+ adjustments: d["adjustments"]&.map { |x| Adjustment.from_dynamic!(x) },
1276
+ setup: Setup.from_dynamic!(d.fetch("setup"))
1277
+ )
1278
+ end
1279
+
1280
+ def self.from_json!(json)
1281
+ from_dynamic!(JSON.parse(json))
1282
+ end
1283
+
1284
+ def to_dynamic
1285
+ {
1286
+ "adjustments" => adjustments&.map(&:to_dynamic),
1287
+ "setup" => setup.to_dynamic
1288
+ }
1289
+ end
1290
+
1291
+ def to_json(options = nil)
1292
+ JSON.generate(to_dynamic, options)
1293
+ end
1294
+ end
1295
+
1296
+ class MatrixUnion < Dry::Struct
1297
+ attribute :matrix_class, MatrixClass.optional
1298
+ attribute :union_array, Types.Array(Types.Instance(MatrixElement)).optional
1299
+
1300
+ def self.from_dynamic!(d)
1301
+ begin
1302
+ value = MatrixClass.from_dynamic!(d)
1303
+ return new(matrix_class: value, union_array: nil) if schema[:matrix_class].right.valid? value
1304
+ rescue StandardError
1305
+ end
1306
+ begin
1307
+ value = d.map { |x| MatrixElement.from_dynamic!(x) }
1308
+ return new(union_array: value, matrix_class: nil) if schema[:union_array].right.valid? value
1309
+ rescue StandardError
1310
+ end
1311
+ raise "Invalid union"
1312
+ end
1313
+
1314
+ def self.from_json!(json)
1315
+ from_dynamic!(JSON.parse(json))
1316
+ end
1317
+
1318
+ def to_dynamic
1319
+ if !matrix_class.nil?
1320
+ matrix_class.to_dynamic
1321
+ elsif !union_array.nil?
1322
+ union_array.map(&:to_dynamic)
1323
+ end
1324
+ end
1325
+
1326
+ def to_json(options = nil)
1327
+ JSON.generate(to_dynamic, options)
1328
+ end
1329
+ end
1330
+
1331
+ class GithubCommitStatus2 < Dry::Struct
1332
+ # GitHub commit status name
1333
+ attribute :context, Types::String.optional
1334
+
1335
+ def self.from_dynamic!(d)
1336
+ d = Types::Hash[d]
1337
+ new(
1338
+ context: d["context"]
1339
+ )
1340
+ end
1341
+
1342
+ def self.from_json!(json)
1343
+ from_dynamic!(JSON.parse(json))
1344
+ end
1345
+
1346
+ def to_dynamic
1347
+ {
1348
+ "context" => context
1349
+ }
1350
+ end
1351
+
1352
+ def to_json(options = nil)
1353
+ JSON.generate(to_dynamic, options)
1354
+ end
1355
+ end
1356
+
1357
+ class Slack2 < Dry::Struct
1358
+ attribute :channels, Types.Array(Types::String).optional
1359
+ attribute :message, Types::String.optional
1360
+
1361
+ def self.from_dynamic!(d)
1362
+ d = Types::Hash[d]
1363
+ new(
1364
+ channels: d["channels"],
1365
+ message: d["message"]
1366
+ )
1367
+ end
1368
+
1369
+ def self.from_json!(json)
1370
+ from_dynamic!(JSON.parse(json))
1371
+ end
1372
+
1373
+ def to_dynamic
1374
+ {
1375
+ "channels" => channels,
1376
+ "message" => message
1377
+ }
1378
+ end
1379
+
1380
+ def to_json(options = nil)
1381
+ JSON.generate(to_dynamic, options)
1382
+ end
1383
+ end
1384
+
1385
+ class Slack5 < Dry::Struct
1386
+ attribute :slack2, Slack2.optional
1387
+ attribute :string, Types::String.optional
1388
+
1389
+ def self.from_dynamic!(d)
1390
+ begin
1391
+ value = Slack2.from_dynamic!(d)
1392
+ return new(slack2: value, string: nil) if schema[:slack2].right.valid? value
1393
+ rescue StandardError
1394
+ end
1395
+ return new(string: d, slack2: nil) if schema[:string].right.valid? d
1396
+
1397
+ raise "Invalid union"
1398
+ end
1399
+
1400
+ def self.from_json!(json)
1401
+ from_dynamic!(JSON.parse(json))
1402
+ end
1403
+
1404
+ def to_dynamic
1405
+ if !slack2.nil?
1406
+ slack2.to_dynamic
1407
+ elsif !string.nil?
1408
+ string
1409
+ end
1410
+ end
1411
+
1412
+ def to_json(options = nil)
1413
+ JSON.generate(to_dynamic, options)
1414
+ end
1415
+ end
1416
+
1417
+ class NotifyClass < Dry::Struct
1418
+ attribute :basecamp_campfire, Types::String.optional
1419
+ attribute :notify_if, Types::String.optional
1420
+ attribute :slack, Types.Instance(Slack5).optional
1421
+ attribute :github_commit_status, GithubCommitStatus2.optional
1422
+ attribute :github_check, Types::Hash.meta(of: Types::Any).optional
1423
+
1424
+ def self.from_dynamic!(d)
1425
+ d = Types::Hash[d]
1426
+ new(
1427
+ basecamp_campfire: d["basecamp_campfire"],
1428
+ notify_if: d["if"],
1429
+ slack: d["slack"] ? Slack5.from_dynamic!(d["slack"]) : nil,
1430
+ github_commit_status: d["github_commit_status"] ? GithubCommitStatus2.from_dynamic!(d["github_commit_status"]) : nil,
1431
+ github_check: Types::Hash.optional[d["github_check"]]&.transform_values { |v| Types::Any[v] }
1432
+ )
1433
+ end
1434
+
1435
+ def self.from_json!(json)
1436
+ from_dynamic!(JSON.parse(json))
1437
+ end
1438
+
1439
+ def to_dynamic
1440
+ {
1441
+ "basecamp_campfire" => basecamp_campfire,
1442
+ "if" => notify_if,
1443
+ "slack" => slack&.to_dynamic,
1444
+ "github_commit_status" => github_commit_status&.to_dynamic,
1445
+ "github_check" => github_check
1446
+ }
1447
+ end
1448
+
1449
+ def to_json(options = nil)
1450
+ JSON.generate(to_dynamic, options)
1451
+ end
1452
+ end
1453
+
1454
+ class NotifyElement < Dry::Struct
1455
+ attribute :enum, Types::NotifyEnum.optional
1456
+ attribute :notify_class, NotifyClass.optional
1457
+
1458
+ def self.from_dynamic!(d)
1459
+ return new(enum: d, notify_class: nil) if schema[:enum].right.valid? d
1460
+
1461
+ begin
1462
+ value = NotifyClass.from_dynamic!(d)
1463
+ return new(notify_class: value, enum: nil) if schema[:notify_class].right.valid? value
1464
+ rescue StandardError
1465
+ end
1466
+ raise "Invalid union"
1467
+ end
1468
+
1469
+ def self.from_json!(json)
1470
+ from_dynamic!(JSON.parse(json))
1471
+ end
1472
+
1473
+ def to_dynamic
1474
+ if !enum.nil?
1475
+ enum
1476
+ elsif !notify_class.nil?
1477
+ notify_class.to_dynamic
1478
+ end
1479
+ end
1480
+
1481
+ def to_json(options = nil)
1482
+ JSON.generate(to_dynamic, options)
1483
+ end
1484
+ end
1485
+
1486
+ # Array of plugins for this step
1487
+ class Plugin < Dry::Struct
1488
+ attribute :anything_map, Types::Hash.meta(of: Types::Any).optional
1489
+ attribute :string, Types::String.optional
1490
+
1491
+ def self.from_dynamic!(d)
1492
+ begin
1493
+ value = Types::Hash[d].transform_values { |v| Types::Any[v] }
1494
+ return new(anything_map: value, string: nil) if schema[:anything_map].right.valid? value
1495
+ rescue StandardError
1496
+ end
1497
+ return new(string: d, anything_map: nil) if schema[:string].right.valid? d
1498
+
1499
+ raise "Invalid union"
1500
+ end
1501
+
1502
+ def self.from_json!(json)
1503
+ from_dynamic!(JSON.parse(json))
1504
+ end
1505
+
1506
+ def to_dynamic
1507
+ if !anything_map.nil?
1508
+ anything_map
1509
+ elsif !string.nil?
1510
+ string
1511
+ end
1512
+ end
1513
+
1514
+ def to_json(options = nil)
1515
+ JSON.generate(to_dynamic, options)
1516
+ end
1517
+ end
1518
+
1519
+ class Plugins < Dry::Struct
1520
+ attribute :anything_map, Types::Hash.meta(of: Types::Any).optional
1521
+ attribute :union_array, Types.Array(Types.Instance(Plugin)).optional
1522
+
1523
+ def self.from_dynamic!(d)
1524
+ begin
1525
+ value = Types::Hash[d].transform_values { |v| Types::Any[v] }
1526
+ return new(anything_map: value, union_array: nil) if schema[:anything_map].right.valid? value
1527
+ rescue StandardError
1528
+ end
1529
+ begin
1530
+ value = d.map { |x| Plugin.from_dynamic!(x) }
1531
+ return new(union_array: value, anything_map: nil) if schema[:union_array].right.valid? value
1532
+ rescue StandardError
1533
+ end
1534
+ raise "Invalid union"
1535
+ end
1536
+
1537
+ def self.from_json!(json)
1538
+ from_dynamic!(JSON.parse(json))
1539
+ end
1540
+
1541
+ def to_dynamic
1542
+ if !anything_map.nil?
1543
+ anything_map
1544
+ elsif !union_array.nil?
1545
+ union_array.map(&:to_dynamic)
1546
+ end
1547
+ end
1548
+
1549
+ def to_json(options = nil)
1550
+ JSON.generate(to_dynamic, options)
1551
+ end
1552
+ end
1553
+
1554
+ # The signature of the command step, generally injected by agents at pipeline upload
1555
+ class Signature < Dry::Struct
1556
+ # The algorithm used to generate the signature
1557
+ attribute :algorithm, Types::String.optional
1558
+
1559
+ # The fields that were signed to form the signature value
1560
+ attribute :signed_fields, Types.Array(Types::String).optional
1561
+
1562
+ # The signature value, a JWS compact signature with a detached body
1563
+ attribute :value, Types::String.optional
1564
+
1565
+ def self.from_dynamic!(d)
1566
+ d = Types::Hash[d]
1567
+ new(
1568
+ algorithm: d["algorithm"],
1569
+ signed_fields: d["signed_fields"],
1570
+ value: d["value"]
1571
+ )
1572
+ end
1573
+
1574
+ def self.from_json!(json)
1575
+ from_dynamic!(JSON.parse(json))
1576
+ end
1577
+
1578
+ def to_dynamic
1579
+ {
1580
+ "algorithm" => algorithm,
1581
+ "signed_fields" => signed_fields,
1582
+ "value" => value
1583
+ }
1584
+ end
1585
+
1586
+ def to_json(options = nil)
1587
+ JSON.generate(to_dynamic, options)
1588
+ end
1589
+ end
1590
+
1591
+ class CommandStep < Dry::Struct
1592
+ attribute :agents, Types.Instance(Agents).optional
1593
+ attribute :allow_dependency_failure, Types.Instance(AllowDependencyFailureUnion).optional
1594
+
1595
+ # The glob path/s of artifacts to upload once this step has finished running
1596
+ attribute :artifact_paths, Types.Instance(Branches).optional
1597
+
1598
+ attribute :branches, Types.Instance(Branches).optional
1599
+ attribute :cache, Types.Instance(Cache).optional
1600
+ attribute :cancel_on_build_failing, Types.Instance(AllowDependencyFailureUnion).optional
1601
+
1602
+ # The commands to run on the agent
1603
+ attribute :command, Types.Instance(Branches).optional
1604
+
1605
+ # The commands to run on the agent
1606
+ attribute :commands, Types.Instance(Branches).optional
1607
+
1608
+ # The maximum number of jobs created from this step that are allowed to run at the same
1609
+ # time. If you use this attribute, you must also define concurrency_group.
1610
+ attribute :concurrency, Types::Integer.optional
1611
+
1612
+ # A unique name for the concurrency group that you are creating with the concurrency
1613
+ # attribute
1614
+ attribute :concurrency_group, Types::String.optional
1615
+
1616
+ # Control command order, allowed values are 'ordered' (default) and 'eager'. If you use
1617
+ # this attribute, you must also define concurrency_group and concurrency.
1618
+ attribute :concurrency_method, Types::ConcurrencyMethod.optional
1619
+
1620
+ attribute :depends_on, Types.Instance(DependsOn).optional
1621
+ attribute :env, Types::Hash.meta(of: Types::Any).optional
1622
+ attribute :id, Types::String.optional
1623
+ attribute :identifier, Types::String.optional
1624
+ attribute :command_step_if, Types::String.optional
1625
+ attribute :key, Types::String.optional
1626
+ attribute :label, Types::String.optional
1627
+ attribute :matrix, Types.Instance(MatrixUnion).optional
1628
+ attribute :command_step_name, Types::String.optional
1629
+
1630
+ # Array of notification options for this step
1631
+ attribute :notify, Types.Array(Types.Instance(NotifyElement)).optional
1632
+
1633
+ # The number of parallel jobs that will be created based on this step
1634
+ attribute :parallelism, Types::Integer.optional
1635
+
1636
+ attribute :plugins, Types.Instance(Plugins).optional
1637
+
1638
+ # Priority of the job, higher priorities are assigned to agents
1639
+ attribute :priority, Types::Integer.optional
1640
+
1641
+ # The conditions for retrying this step.
1642
+ attribute :command_step_retry, Retry.optional
1643
+
1644
+ # The signature of the command step, generally injected by agents at pipeline upload
1645
+ attribute :signature, Signature.optional
1646
+
1647
+ attribute :skip, Types.Instance(Skip).optional
1648
+ attribute :soft_fail, Types.Instance(SoftFail).optional
1649
+
1650
+ # The number of minutes to time out a job
1651
+ attribute :timeout_in_minutes, Types::Integer.optional
1652
+
1653
+ attribute :command_step_type, Types::ScriptType.optional
1654
+
1655
+ def self.from_dynamic!(d)
1656
+ d = Types::Hash[d]
1657
+ new(
1658
+ agents: d["agents"] ? Agents.from_dynamic!(d["agents"]) : nil,
1659
+ allow_dependency_failure: d["allow_dependency_failure"] ? AllowDependencyFailureUnion.from_dynamic!(d["allow_dependency_failure"]) : nil,
1660
+ artifact_paths: d["artifact_paths"] ? Branches.from_dynamic!(d["artifact_paths"]) : nil,
1661
+ branches: d["branches"] ? Branches.from_dynamic!(d["branches"]) : nil,
1662
+ cache: d["cache"] ? Cache.from_dynamic!(d["cache"]) : nil,
1663
+ cancel_on_build_failing: d["cancel_on_build_failing"] ? AllowDependencyFailureUnion.from_dynamic!(d["cancel_on_build_failing"]) : nil,
1664
+ command: d["command"] ? Branches.from_dynamic!(d["command"]) : nil,
1665
+ commands: d["commands"] ? Branches.from_dynamic!(d["commands"]) : nil,
1666
+ concurrency: d["concurrency"],
1667
+ concurrency_group: d["concurrency_group"],
1668
+ concurrency_method: d["concurrency_method"],
1669
+ depends_on: d["depends_on"] ? DependsOn.from_dynamic!(d["depends_on"]) : nil,
1670
+ env: Types::Hash.optional[d["env"]]&.transform_values { |v| Types::Any[v] },
1671
+ id: d["id"],
1672
+ identifier: d["identifier"],
1673
+ command_step_if: d["if"],
1674
+ key: d["key"],
1675
+ label: d["label"],
1676
+ matrix: d["matrix"] ? MatrixUnion.from_dynamic!(d["matrix"]) : nil,
1677
+ command_step_name: d["name"],
1678
+ notify: d["notify"]&.map { |x| NotifyElement.from_dynamic!(x) },
1679
+ parallelism: d["parallelism"],
1680
+ plugins: d["plugins"] ? Plugins.from_dynamic!(d["plugins"]) : nil,
1681
+ priority: d["priority"],
1682
+ command_step_retry: d["retry"] ? Retry.from_dynamic!(d["retry"]) : nil,
1683
+ signature: d["signature"] ? Signature.from_dynamic!(d["signature"]) : nil,
1684
+ skip: d["skip"] ? Skip.from_dynamic!(d["skip"]) : nil,
1685
+ soft_fail: d["soft_fail"] ? SoftFail.from_dynamic!(d["soft_fail"]) : nil,
1686
+ timeout_in_minutes: d["timeout_in_minutes"],
1687
+ command_step_type: d["type"]
1688
+ )
1689
+ end
1690
+
1691
+ def self.from_json!(json)
1692
+ from_dynamic!(JSON.parse(json))
1693
+ end
1694
+
1695
+ def to_dynamic
1696
+ {
1697
+ "agents" => agents&.to_dynamic,
1698
+ "allow_dependency_failure" => allow_dependency_failure&.to_dynamic,
1699
+ "artifact_paths" => artifact_paths&.to_dynamic,
1700
+ "branches" => branches&.to_dynamic,
1701
+ "cache" => cache&.to_dynamic,
1702
+ "cancel_on_build_failing" => cancel_on_build_failing&.to_dynamic,
1703
+ "command" => command&.to_dynamic,
1704
+ "commands" => commands&.to_dynamic,
1705
+ "concurrency" => concurrency,
1706
+ "concurrency_group" => concurrency_group,
1707
+ "concurrency_method" => concurrency_method,
1708
+ "depends_on" => depends_on&.to_dynamic,
1709
+ "env" => env,
1710
+ "id" => id,
1711
+ "identifier" => identifier,
1712
+ "if" => command_step_if,
1713
+ "key" => key,
1714
+ "label" => label,
1715
+ "matrix" => matrix&.to_dynamic,
1716
+ "name" => command_step_name,
1717
+ "notify" => notify&.map(&:to_dynamic),
1718
+ "parallelism" => parallelism,
1719
+ "plugins" => plugins&.to_dynamic,
1720
+ "priority" => priority,
1721
+ "retry" => command_step_retry&.to_dynamic,
1722
+ "signature" => signature&.to_dynamic,
1723
+ "skip" => skip&.to_dynamic,
1724
+ "soft_fail" => soft_fail&.to_dynamic,
1725
+ "timeout_in_minutes" => timeout_in_minutes,
1726
+ "type" => command_step_type
1727
+ }
1728
+ end
1729
+
1730
+ def to_json(options = nil)
1731
+ JSON.generate(to_dynamic, options)
1732
+ end
1733
+ end
1734
+
1735
+ class CommandUnion < Dry::Struct
1736
+ attribute :command_step, CommandStep.optional
1737
+ attribute :string, Types::String.optional
1738
+ attribute :string_array, Types.Array(Types::String).optional
1739
+
1740
+ def self.from_dynamic!(d)
1741
+ begin
1742
+ value = CommandStep.from_dynamic!(d)
1743
+ return new(command_step: value, string_array: nil, string: nil) if schema[:command_step].right.valid? value
1744
+ rescue StandardError
1745
+ end
1746
+ return new(string: d, string_array: nil, command_step: nil) if schema[:string].right.valid? d
1747
+ return new(string_array: d, command_step: nil, string: nil) if schema[:string_array].right.valid? d
1748
+
1749
+ raise "Invalid union"
1750
+ end
1751
+
1752
+ def self.from_json!(json)
1753
+ from_dynamic!(JSON.parse(json))
1754
+ end
1755
+
1756
+ def to_dynamic
1757
+ if !command_step.nil?
1758
+ command_step.to_dynamic
1759
+ elsif !string.nil?
1760
+ string
1761
+ elsif !string_array.nil?
1762
+ string_array
1763
+ end
1764
+ end
1765
+
1766
+ def to_json(options = nil)
1767
+ JSON.generate(to_dynamic, options)
1768
+ end
1769
+ end
1770
+
1771
+ module InputType
1772
+ Input = "input".freeze
1773
+ end
1774
+
1775
+ class InputStep < Dry::Struct
1776
+ attribute :allow_dependency_failure, Types.Instance(AllowDependencyFailureUnion).optional
1777
+ attribute :branches, Types.Instance(Branches).optional
1778
+ attribute :depends_on, Types.Instance(DependsOn).optional
1779
+ attribute :fields, Types.Array(Field).optional
1780
+ attribute :id, Types::String.optional
1781
+ attribute :identifier, Types::String.optional
1782
+ attribute :input_step_if, Types::String.optional
1783
+
1784
+ # The label of the input step
1785
+ attribute :input, Types::String.optional
1786
+
1787
+ attribute :key, Types::String.optional
1788
+ attribute :label, Types::String.optional
1789
+ attribute :input_step_name, Types::String.optional
1790
+ attribute :prompt, Types::String.optional
1791
+ attribute :input_step_type, Types::InputType.optional
1792
+
1793
+ def self.from_dynamic!(d)
1794
+ d = Types::Hash[d]
1795
+ new(
1796
+ allow_dependency_failure: d["allow_dependency_failure"] ? AllowDependencyFailureUnion.from_dynamic!(d["allow_dependency_failure"]) : nil,
1797
+ branches: d["branches"] ? Branches.from_dynamic!(d["branches"]) : nil,
1798
+ depends_on: d["depends_on"] ? DependsOn.from_dynamic!(d["depends_on"]) : nil,
1799
+ fields: d["fields"]&.map { |x| Field.from_dynamic!(x) },
1800
+ id: d["id"],
1801
+ identifier: d["identifier"],
1802
+ input_step_if: d["if"],
1803
+ input: d["input"],
1804
+ key: d["key"],
1805
+ label: d["label"],
1806
+ input_step_name: d["name"],
1807
+ prompt: d["prompt"],
1808
+ input_step_type: d["type"]
1809
+ )
1810
+ end
1811
+
1812
+ def self.from_json!(json)
1813
+ from_dynamic!(JSON.parse(json))
1814
+ end
1815
+
1816
+ def to_dynamic
1817
+ {
1818
+ "allow_dependency_failure" => allow_dependency_failure&.to_dynamic,
1819
+ "branches" => branches&.to_dynamic,
1820
+ "depends_on" => depends_on&.to_dynamic,
1821
+ "fields" => fields&.map(&:to_dynamic),
1822
+ "id" => id,
1823
+ "identifier" => identifier,
1824
+ "if" => input_step_if,
1825
+ "input" => input,
1826
+ "key" => key,
1827
+ "label" => label,
1828
+ "name" => input_step_name,
1829
+ "prompt" => prompt,
1830
+ "type" => input_step_type
1831
+ }
1832
+ end
1833
+
1834
+ def to_json(options = nil)
1835
+ JSON.generate(to_dynamic, options)
1836
+ end
1837
+ end
1838
+
1839
+ class Input < Dry::Struct
1840
+ attribute :input_step, InputStep.optional
1841
+ attribute :string, Types::String.optional
1842
+
1843
+ def self.from_dynamic!(d)
1844
+ begin
1845
+ value = InputStep.from_dynamic!(d)
1846
+ return new(input_step: value, string: nil) if schema[:input_step].right.valid? value
1847
+ rescue StandardError
1848
+ end
1849
+ return new(string: d, input_step: nil) if schema[:string].right.valid? d
1850
+
1851
+ raise "Invalid union"
1852
+ end
1853
+
1854
+ def self.from_json!(json)
1855
+ from_dynamic!(JSON.parse(json))
1856
+ end
1857
+
1858
+ def to_dynamic
1859
+ if !input_step.nil?
1860
+ input_step.to_dynamic
1861
+ elsif !string.nil?
1862
+ string
1863
+ end
1864
+ end
1865
+
1866
+ def to_json(options = nil)
1867
+ JSON.generate(to_dynamic, options)
1868
+ end
1869
+ end
1870
+
1871
+ class GithubCommitStatus3 < Dry::Struct
1872
+ # GitHub commit status name
1873
+ attribute :context, Types::String.optional
1874
+
1875
+ def self.from_dynamic!(d)
1876
+ d = Types::Hash[d]
1877
+ new(
1878
+ context: d["context"]
1879
+ )
1880
+ end
1881
+
1882
+ def self.from_json!(json)
1883
+ from_dynamic!(JSON.parse(json))
1884
+ end
1885
+
1886
+ def to_dynamic
1887
+ {
1888
+ "context" => context
1889
+ }
1890
+ end
1891
+
1892
+ def to_json(options = nil)
1893
+ JSON.generate(to_dynamic, options)
1894
+ end
1895
+ end
1896
+
1897
+ class Slack3 < Dry::Struct
1898
+ attribute :channels, Types.Array(Types::String).optional
1899
+ attribute :message, Types::String.optional
1900
+
1901
+ def self.from_dynamic!(d)
1902
+ d = Types::Hash[d]
1903
+ new(
1904
+ channels: d["channels"],
1905
+ message: d["message"]
1906
+ )
1907
+ end
1908
+
1909
+ def self.from_json!(json)
1910
+ from_dynamic!(JSON.parse(json))
1911
+ end
1912
+
1913
+ def to_dynamic
1914
+ {
1915
+ "channels" => channels,
1916
+ "message" => message
1917
+ }
1918
+ end
1919
+
1920
+ def to_json(options = nil)
1921
+ JSON.generate(to_dynamic, options)
1922
+ end
1923
+ end
1924
+
1925
+ class Slack6 < Dry::Struct
1926
+ attribute :slack3, Slack3.optional
1927
+ attribute :string, Types::String.optional
1928
+
1929
+ def self.from_dynamic!(d)
1930
+ begin
1931
+ value = Slack3.from_dynamic!(d)
1932
+ return new(slack3: value, string: nil) if schema[:slack3].right.valid? value
1933
+ rescue StandardError
1934
+ end
1935
+ return new(string: d, slack3: nil) if schema[:string].right.valid? d
1936
+
1937
+ raise "Invalid union"
1938
+ end
1939
+
1940
+ def self.from_json!(json)
1941
+ from_dynamic!(JSON.parse(json))
1942
+ end
1943
+
1944
+ def to_dynamic
1945
+ if !slack3.nil?
1946
+ slack3.to_dynamic
1947
+ elsif !string.nil?
1948
+ string
1949
+ end
1950
+ end
1951
+
1952
+ def to_json(options = nil)
1953
+ JSON.generate(to_dynamic, options)
1954
+ end
1955
+ end
1956
+
1957
+ class BuildNotify2 < Dry::Struct
1958
+ attribute :basecamp_campfire, Types::String.optional
1959
+ attribute :build_notify_if, Types::String.optional
1960
+ attribute :slack, Types.Instance(Slack6).optional
1961
+ attribute :github_commit_status, GithubCommitStatus3.optional
1962
+ attribute :github_check, Types::Hash.meta(of: Types::Any).optional
1963
+ attribute :email, Types::String.optional
1964
+ attribute :webhook, Types::String.optional
1965
+ attribute :pagerduty_change_event, Types::String.optional
1966
+
1967
+ def self.from_dynamic!(d)
1968
+ d = Types::Hash[d]
1969
+ new(
1970
+ basecamp_campfire: d["basecamp_campfire"],
1971
+ build_notify_if: d["if"],
1972
+ slack: d["slack"] ? Slack6.from_dynamic!(d["slack"]) : nil,
1973
+ github_commit_status: d["github_commit_status"] ? GithubCommitStatus3.from_dynamic!(d["github_commit_status"]) : nil,
1974
+ github_check: Types::Hash.optional[d["github_check"]]&.transform_values { |v| Types::Any[v] },
1975
+ email: d["email"],
1976
+ webhook: d["webhook"],
1977
+ pagerduty_change_event: d["pagerduty_change_event"]
1978
+ )
1979
+ end
1980
+
1981
+ def self.from_json!(json)
1982
+ from_dynamic!(JSON.parse(json))
1983
+ end
1984
+
1985
+ def to_dynamic
1986
+ {
1987
+ "basecamp_campfire" => basecamp_campfire,
1988
+ "if" => build_notify_if,
1989
+ "slack" => slack&.to_dynamic,
1990
+ "github_commit_status" => github_commit_status&.to_dynamic,
1991
+ "github_check" => github_check,
1992
+ "email" => email,
1993
+ "webhook" => webhook,
1994
+ "pagerduty_change_event" => pagerduty_change_event
1995
+ }
1996
+ end
1997
+
1998
+ def to_json(options = nil)
1999
+ JSON.generate(to_dynamic, options)
2000
+ end
2001
+ end
2002
+
2003
+ class BlockStepNotify < Dry::Struct
2004
+ attribute :build_notify2, BuildNotify2.optional
2005
+ attribute :enum, Types::NotifyEnum.optional
2006
+
2007
+ def self.from_dynamic!(d)
2008
+ begin
2009
+ value = BuildNotify2.from_dynamic!(d)
2010
+ return new(build_notify2: value, enum: nil) if schema[:build_notify2].right.valid? value
2011
+ rescue StandardError
2012
+ end
2013
+ return new(enum: d, build_notify2: nil) if schema[:enum].right.valid? d
2014
+
2015
+ raise "Invalid union"
2016
+ end
2017
+
2018
+ def self.from_json!(json)
2019
+ from_dynamic!(JSON.parse(json))
2020
+ end
2021
+
2022
+ def to_dynamic
2023
+ if !build_notify2.nil?
2024
+ build_notify2.to_dynamic
2025
+ elsif !enum.nil?
2026
+ enum
2027
+ end
2028
+ end
2029
+
2030
+ def to_json(options = nil)
2031
+ JSON.generate(to_dynamic, options)
2032
+ end
2033
+ end
2034
+
2035
+ module BlockStepType
2036
+ Block = "block".freeze
2037
+ Command = "command".freeze
2038
+ Commands = "commands".freeze
2039
+ Input = "input".freeze
2040
+ Script = "script".freeze
2041
+ Trigger = "trigger".freeze
2042
+ Wait = "wait".freeze
2043
+ Waiter = "waiter".freeze
2044
+ end
2045
+
2046
+ module TriggerType
2047
+ Trigger = "trigger".freeze
2048
+ end
2049
+
2050
+ class TriggerStep < Dry::Struct
2051
+ attribute :allow_dependency_failure, Types.Instance(AllowDependencyFailureUnion).optional
2052
+
2053
+ # Whether to continue the build without waiting for the triggered step to complete
2054
+ attribute :async, Types.Instance(AllowDependencyFailureUnion).optional
2055
+
2056
+ attribute :branches, Types.Instance(Branches).optional
2057
+
2058
+ # Properties of the build that will be created when the step is triggered
2059
+ attribute :build, Build.optional
2060
+
2061
+ attribute :depends_on, Types.Instance(DependsOn).optional
2062
+ attribute :id, Types::String.optional
2063
+ attribute :identifier, Types::String.optional
2064
+ attribute :trigger_step_if, Types::String.optional
2065
+ attribute :key, Types::String.optional
2066
+ attribute :label, Types::String.optional
2067
+ attribute :trigger_step_name, Types::String.optional
2068
+ attribute :skip, Types.Instance(Skip).optional
2069
+ attribute :soft_fail, Types.Instance(SoftFail).optional
2070
+
2071
+ # The slug of the pipeline to create a build
2072
+ attribute :trigger, Types::String
2073
+
2074
+ attribute :trigger_step_type, Types::TriggerType.optional
2075
+
2076
+ def self.from_dynamic!(d)
2077
+ d = Types::Hash[d]
2078
+ new(
2079
+ allow_dependency_failure: d["allow_dependency_failure"] ? AllowDependencyFailureUnion.from_dynamic!(d["allow_dependency_failure"]) : nil,
2080
+ async: d["async"] ? AllowDependencyFailureUnion.from_dynamic!(d["async"]) : nil,
2081
+ branches: d["branches"] ? Branches.from_dynamic!(d["branches"]) : nil,
2082
+ build: d["build"] ? Build.from_dynamic!(d["build"]) : nil,
2083
+ depends_on: d["depends_on"] ? DependsOn.from_dynamic!(d["depends_on"]) : nil,
2084
+ id: d["id"],
2085
+ identifier: d["identifier"],
2086
+ trigger_step_if: d["if"],
2087
+ key: d["key"],
2088
+ label: d["label"],
2089
+ trigger_step_name: d["name"],
2090
+ skip: d["skip"] ? Skip.from_dynamic!(d["skip"]) : nil,
2091
+ soft_fail: d["soft_fail"] ? SoftFail.from_dynamic!(d["soft_fail"]) : nil,
2092
+ trigger: d.fetch("trigger"),
2093
+ trigger_step_type: d["type"]
2094
+ )
2095
+ end
2096
+
2097
+ def self.from_json!(json)
2098
+ from_dynamic!(JSON.parse(json))
2099
+ end
2100
+
2101
+ def to_dynamic
2102
+ {
2103
+ "allow_dependency_failure" => allow_dependency_failure&.to_dynamic,
2104
+ "async" => async&.to_dynamic,
2105
+ "branches" => branches&.to_dynamic,
2106
+ "build" => build&.to_dynamic,
2107
+ "depends_on" => depends_on&.to_dynamic,
2108
+ "id" => id,
2109
+ "identifier" => identifier,
2110
+ "if" => trigger_step_if,
2111
+ "key" => key,
2112
+ "label" => label,
2113
+ "name" => trigger_step_name,
2114
+ "skip" => skip&.to_dynamic,
2115
+ "soft_fail" => soft_fail&.to_dynamic,
2116
+ "trigger" => trigger,
2117
+ "type" => trigger_step_type
2118
+ }
2119
+ end
2120
+
2121
+ def to_json(options = nil)
2122
+ JSON.generate(to_dynamic, options)
2123
+ end
2124
+ end
2125
+
2126
+ class Trigger < Dry::Struct
2127
+ attribute :string, Types::String.optional
2128
+ attribute :trigger_step, TriggerStep.optional
2129
+
2130
+ def self.from_dynamic!(d)
2131
+ return new(string: d, trigger_step: nil) if schema[:string].right.valid? d
2132
+
2133
+ begin
2134
+ value = TriggerStep.from_dynamic!(d)
2135
+ return new(trigger_step: value, string: nil) if schema[:trigger_step].right.valid? value
2136
+ rescue StandardError
2137
+ end
2138
+ raise "Invalid union"
2139
+ end
2140
+
2141
+ def self.from_json!(json)
2142
+ from_dynamic!(JSON.parse(json))
2143
+ end
2144
+
2145
+ def to_dynamic
2146
+ if !string.nil?
2147
+ string
2148
+ elsif !trigger_step.nil?
2149
+ trigger_step.to_dynamic
2150
+ end
2151
+ end
2152
+
2153
+ def to_json(options = nil)
2154
+ JSON.generate(to_dynamic, options)
2155
+ end
2156
+ end
2157
+
2158
+ module WaiterType
2159
+ Wait = "wait".freeze
2160
+ Waiter = "waiter".freeze
2161
+ end
2162
+
2163
+ # Waits for previous steps to pass before continuing
2164
+ class WaitStep < Dry::Struct
2165
+ attribute :allow_dependency_failure, Types.Instance(AllowDependencyFailureUnion).optional
2166
+ attribute :branches, Types.Instance(Branches).optional
2167
+
2168
+ # Continue to the next steps, even if the previous group of steps fail
2169
+ attribute :continue_on_failure, Types.Instance(AllowDependencyFailureUnion).optional
2170
+
2171
+ attribute :depends_on, Types.Instance(DependsOn).optional
2172
+ attribute :id, Types::String.optional
2173
+ attribute :identifier, Types::String.optional
2174
+ attribute :wait_step_if, Types::String.optional
2175
+ attribute :key, Types::String.optional
2176
+ attribute :label, Types::String.optional.optional
2177
+ attribute :wait_step_name, Types::String.optional.optional
2178
+ attribute :wait_step_type, Types::WaiterType.optional
2179
+
2180
+ # Waits for previous steps to pass before continuing
2181
+ attribute :wait, Types::String.optional.optional
2182
+
2183
+ def self.from_dynamic!(d)
2184
+ d = Types::Hash[d]
2185
+ new(
2186
+ allow_dependency_failure: d["allow_dependency_failure"] ? AllowDependencyFailureUnion.from_dynamic!(d["allow_dependency_failure"]) : nil,
2187
+ branches: d["branches"] ? Branches.from_dynamic!(d["branches"]) : nil,
2188
+ continue_on_failure: d["continue_on_failure"] ? AllowDependencyFailureUnion.from_dynamic!(d["continue_on_failure"]) : nil,
2189
+ depends_on: d["depends_on"] ? DependsOn.from_dynamic!(d["depends_on"]) : nil,
2190
+ id: d["id"],
2191
+ identifier: d["identifier"],
2192
+ wait_step_if: d["if"],
2193
+ key: d["key"],
2194
+ label: d["label"],
2195
+ wait_step_name: d["name"],
2196
+ wait_step_type: d["type"],
2197
+ wait: d["wait"]
2198
+ )
2199
+ end
2200
+
2201
+ def self.from_json!(json)
2202
+ from_dynamic!(JSON.parse(json))
2203
+ end
2204
+
2205
+ def to_dynamic
2206
+ {
2207
+ "allow_dependency_failure" => allow_dependency_failure&.to_dynamic,
2208
+ "branches" => branches&.to_dynamic,
2209
+ "continue_on_failure" => continue_on_failure&.to_dynamic,
2210
+ "depends_on" => depends_on&.to_dynamic,
2211
+ "id" => id,
2212
+ "identifier" => identifier,
2213
+ "if" => wait_step_if,
2214
+ "key" => key,
2215
+ "label" => label,
2216
+ "name" => wait_step_name,
2217
+ "type" => wait_step_type,
2218
+ "wait" => wait
2219
+ }
2220
+ end
2221
+
2222
+ def to_json(options = nil)
2223
+ JSON.generate(to_dynamic, options)
2224
+ end
2225
+ end
2226
+
2227
+ class Label < Dry::Struct
2228
+ attribute :null, Types::Nil.optional
2229
+ attribute :string, Types::String.optional
2230
+ attribute :wait_step, WaitStep.optional
2231
+
2232
+ def self.from_dynamic!(d)
2233
+ return new(null: d, wait_step: nil, string: nil) if schema[:null].right.valid? d
2234
+ return new(string: d, wait_step: nil, null: nil) if schema[:string].right.valid? d
2235
+
2236
+ begin
2237
+ value = WaitStep.from_dynamic!(d)
2238
+ return new(wait_step: value, null: nil, string: nil) if schema[:wait_step].right.valid? value
2239
+ rescue StandardError
2240
+ end
2241
+ raise "Invalid union"
2242
+ end
2243
+
2244
+ def self.from_json!(json)
2245
+ from_dynamic!(JSON.parse(json))
2246
+ end
2247
+
2248
+ def to_dynamic
2249
+ if !string.nil?
2250
+ string
2251
+ elsif !wait_step.nil?
2252
+ wait_step.to_dynamic
2253
+ end
2254
+ end
2255
+
2256
+ def to_json(options = nil)
2257
+ JSON.generate(to_dynamic, options)
2258
+ end
2259
+ end
2260
+
2261
+ # Waits for previous steps to pass before continuing
2262
+ class Step1 < Dry::Struct
2263
+ attribute :allow_dependency_failure, Types.Instance(AllowDependencyFailureUnion).optional
2264
+
2265
+ # The label of the block step
2266
+ attribute :block, Types.Instance(Block).optional
2267
+
2268
+ # The state that the build is set to when the build is blocked by this block step
2269
+ attribute :blocked_state, Types::BlockedState.optional
2270
+
2271
+ attribute :branches, Types.Instance(Branches).optional
2272
+ attribute :depends_on, Types.Instance(DependsOn).optional
2273
+ attribute :fields, Types.Array(Field).optional
2274
+ attribute :id, Types::String.optional
2275
+ attribute :identifier, Types::String.optional
2276
+ attribute :step_if, Types::String.optional
2277
+ attribute :key, Types::String.optional
2278
+ attribute :label, Types::String.optional.optional
2279
+ attribute :step_name, Types::String.optional.optional
2280
+ attribute :prompt, Types::String.optional
2281
+ attribute :step_type, Types::BlockStepType.optional
2282
+
2283
+ # The label of the input step
2284
+ attribute :input, Types.Instance(Input).optional
2285
+
2286
+ attribute :agents, Types.Instance(Agents).optional
2287
+
2288
+ # The glob path/s of artifacts to upload once this step has finished running
2289
+ attribute :artifact_paths, Types.Instance(Branches).optional
2290
+
2291
+ attribute :cache, Types.Instance(Cache).optional
2292
+ attribute :cancel_on_build_failing, Types.Instance(AllowDependencyFailureUnion).optional
2293
+
2294
+ # The commands to run on the agent
2295
+ attribute :command, Types.Instance(CommandUnion).optional
2296
+
2297
+ # The commands to run on the agent
2298
+ attribute :commands, Types.Instance(CommandUnion).optional
2299
+
2300
+ # The maximum number of jobs created from this step that are allowed to run at the same
2301
+ # time. If you use this attribute, you must also define concurrency_group.
2302
+ attribute :concurrency, Types::Integer.optional
2303
+
2304
+ # A unique name for the concurrency group that you are creating with the concurrency
2305
+ # attribute
2306
+ attribute :concurrency_group, Types::String.optional
2307
+
2308
+ # Control command order, allowed values are 'ordered' (default) and 'eager'. If you use
2309
+ # this attribute, you must also define concurrency_group and concurrency.
2310
+ attribute :concurrency_method, Types::ConcurrencyMethod.optional
2311
+
2312
+ attribute :env, Types::Hash.meta(of: Types::Any).optional
2313
+ attribute :matrix, Types.Instance(MatrixUnion).optional
2314
+
2315
+ # Array of notification options for this step
2316
+ attribute :notify, Types.Array(Types.Instance(NotifyElement)).optional
2317
+
2318
+ # The number of parallel jobs that will be created based on this step
2319
+ attribute :parallelism, Types::Integer.optional
2320
+
2321
+ attribute :plugins, Types.Instance(Plugins).optional
2322
+
2323
+ # Priority of the job, higher priorities are assigned to agents
2324
+ attribute :priority, Types::Integer.optional
2325
+
2326
+ # The conditions for retrying this step.
2327
+ attribute :step_retry, Retry.optional
2328
+
2329
+ # The signature of the command step, generally injected by agents at pipeline upload
2330
+ attribute :signature, Signature.optional
2331
+
2332
+ attribute :skip, Types.Instance(Skip).optional
2333
+ attribute :soft_fail, Types.Instance(SoftFail).optional
2334
+
2335
+ # The number of minutes to time out a job
2336
+ attribute :timeout_in_minutes, Types::Integer.optional
2337
+
2338
+ attribute :script, CommandStep.optional
2339
+
2340
+ # Continue to the next steps, even if the previous group of steps fail
2341
+ attribute :continue_on_failure, Types.Instance(AllowDependencyFailureUnion).optional
2342
+
2343
+ # Waits for previous steps to pass before continuing
2344
+ attribute :wait, Types.Instance(Label).optional
2345
+
2346
+ attribute :waiter, WaitStep.optional
2347
+
2348
+ # Whether to continue the build without waiting for the triggered step to complete
2349
+ attribute :async, Types.Instance(AllowDependencyFailureUnion).optional
2350
+
2351
+ # Properties of the build that will be created when the step is triggered
2352
+ attribute :build, Build.optional
2353
+
2354
+ # The slug of the pipeline to create a build
2355
+ attribute :trigger, Types.Instance(Trigger).optional
2356
+
2357
+ def self.from_dynamic!(d)
2358
+ d = Types::Hash[d]
2359
+ new(
2360
+ allow_dependency_failure: d["allow_dependency_failure"] ? AllowDependencyFailureUnion.from_dynamic!(d["allow_dependency_failure"]) : nil,
2361
+ block: d["block"] ? Block.from_dynamic!(d["block"]) : nil,
2362
+ blocked_state: d["blocked_state"],
2363
+ branches: d["branches"] ? Branches.from_dynamic!(d["branches"]) : nil,
2364
+ depends_on: d["depends_on"] ? DependsOn.from_dynamic!(d["depends_on"]) : nil,
2365
+ fields: d["fields"]&.map { |x| Field.from_dynamic!(x) },
2366
+ id: d["id"],
2367
+ identifier: d["identifier"],
2368
+ step_if: d["if"],
2369
+ key: d["key"],
2370
+ label: d["label"],
2371
+ step_name: d["name"],
2372
+ prompt: d["prompt"],
2373
+ step_type: d["type"],
2374
+ input: d["input"] ? Input.from_dynamic!(d["input"]) : nil,
2375
+ agents: d["agents"] ? Agents.from_dynamic!(d["agents"]) : nil,
2376
+ artifact_paths: d["artifact_paths"] ? Branches.from_dynamic!(d["artifact_paths"]) : nil,
2377
+ cache: d["cache"] ? Cache.from_dynamic!(d["cache"]) : nil,
2378
+ cancel_on_build_failing: d["cancel_on_build_failing"] ? AllowDependencyFailureUnion.from_dynamic!(d["cancel_on_build_failing"]) : nil,
2379
+ command: d["command"] ? CommandUnion.from_dynamic!(d["command"]) : nil,
2380
+ commands: d["commands"] ? CommandUnion.from_dynamic!(d["commands"]) : nil,
2381
+ concurrency: d["concurrency"],
2382
+ concurrency_group: d["concurrency_group"],
2383
+ concurrency_method: d["concurrency_method"],
2384
+ env: Types::Hash.optional[d["env"]]&.transform_values { |v| Types::Any[v] },
2385
+ matrix: d["matrix"] ? MatrixUnion.from_dynamic!(d["matrix"]) : nil,
2386
+ notify: d["notify"]&.map { |x| NotifyElement.from_dynamic!(x) },
2387
+ parallelism: d["parallelism"],
2388
+ plugins: d["plugins"] ? Plugins.from_dynamic!(d["plugins"]) : nil,
2389
+ priority: d["priority"],
2390
+ step_retry: d["retry"] ? Retry.from_dynamic!(d["retry"]) : nil,
2391
+ signature: d["signature"] ? Signature.from_dynamic!(d["signature"]) : nil,
2392
+ skip: d["skip"] ? Skip.from_dynamic!(d["skip"]) : nil,
2393
+ soft_fail: d["soft_fail"] ? SoftFail.from_dynamic!(d["soft_fail"]) : nil,
2394
+ timeout_in_minutes: d["timeout_in_minutes"],
2395
+ script: d["script"] ? CommandStep.from_dynamic!(d["script"]) : nil,
2396
+ continue_on_failure: d["continue_on_failure"] ? AllowDependencyFailureUnion.from_dynamic!(d["continue_on_failure"]) : nil,
2397
+ wait: d["wait"] ? Label.from_dynamic!(d["wait"]) : nil,
2398
+ waiter: d["waiter"] ? WaitStep.from_dynamic!(d["waiter"]) : nil,
2399
+ async: d["async"] ? AllowDependencyFailureUnion.from_dynamic!(d["async"]) : nil,
2400
+ build: d["build"] ? Build.from_dynamic!(d["build"]) : nil,
2401
+ trigger: d["trigger"] ? Trigger.from_dynamic!(d["trigger"]) : nil
2402
+ )
2403
+ end
2404
+
2405
+ def self.from_json!(json)
2406
+ from_dynamic!(JSON.parse(json))
2407
+ end
2408
+
2409
+ def to_dynamic
2410
+ {
2411
+ "allow_dependency_failure" => allow_dependency_failure&.to_dynamic,
2412
+ "block" => block&.to_dynamic,
2413
+ "blocked_state" => blocked_state,
2414
+ "branches" => branches&.to_dynamic,
2415
+ "depends_on" => depends_on&.to_dynamic,
2416
+ "fields" => fields&.map(&:to_dynamic),
2417
+ "id" => id,
2418
+ "identifier" => identifier,
2419
+ "if" => step_if,
2420
+ "key" => key,
2421
+ "label" => label,
2422
+ "name" => step_name,
2423
+ "prompt" => prompt,
2424
+ "type" => step_type,
2425
+ "input" => input&.to_dynamic,
2426
+ "agents" => agents&.to_dynamic,
2427
+ "artifact_paths" => artifact_paths&.to_dynamic,
2428
+ "cache" => cache&.to_dynamic,
2429
+ "cancel_on_build_failing" => cancel_on_build_failing&.to_dynamic,
2430
+ "command" => command&.to_dynamic,
2431
+ "commands" => commands&.to_dynamic,
2432
+ "concurrency" => concurrency,
2433
+ "concurrency_group" => concurrency_group,
2434
+ "concurrency_method" => concurrency_method,
2435
+ "env" => env,
2436
+ "matrix" => matrix&.to_dynamic,
2437
+ "notify" => notify&.map(&:to_dynamic),
2438
+ "parallelism" => parallelism,
2439
+ "plugins" => plugins&.to_dynamic,
2440
+ "priority" => priority,
2441
+ "retry" => step_retry&.to_dynamic,
2442
+ "signature" => signature&.to_dynamic,
2443
+ "skip" => skip&.to_dynamic,
2444
+ "soft_fail" => soft_fail&.to_dynamic,
2445
+ "timeout_in_minutes" => timeout_in_minutes,
2446
+ "script" => script&.to_dynamic,
2447
+ "continue_on_failure" => continue_on_failure&.to_dynamic,
2448
+ "wait" => wait&.to_dynamic,
2449
+ "waiter" => waiter&.to_dynamic,
2450
+ "async" => async&.to_dynamic,
2451
+ "build" => build&.to_dynamic,
2452
+ "trigger" => trigger&.to_dynamic
2453
+ }
2454
+ end
2455
+
2456
+ def to_json(options = nil)
2457
+ JSON.generate(to_dynamic, options)
2458
+ end
2459
+ end
2460
+
2461
+ # Pauses the execution of a build and waits on a user to unblock it
2462
+ #
2463
+ # Waits for previous steps to pass before continuing
2464
+ module StringStep
2465
+ Block = "block".freeze
2466
+ Input = "input".freeze
2467
+ Wait = "wait".freeze
2468
+ Waiter = "waiter".freeze
2469
+ end
2470
+
2471
+ class BlockStepStep < Dry::Struct
2472
+ attribute :enum, Types::StringStep.optional
2473
+ attribute :step1, Step1.optional
2474
+
2475
+ def self.from_dynamic!(d)
2476
+ return new(enum: d, step1: nil) if schema[:enum].right.valid? d
2477
+
2478
+ begin
2479
+ value = Step1.from_dynamic!(d)
2480
+ return new(step1: value, enum: nil) if schema[:step1].right.valid? value
2481
+ rescue StandardError
2482
+ end
2483
+ raise "Invalid union"
2484
+ end
2485
+
2486
+ def self.from_json!(json)
2487
+ from_dynamic!(JSON.parse(json))
2488
+ end
2489
+
2490
+ def to_dynamic
2491
+ if !enum.nil?
2492
+ enum
2493
+ elsif !step1.nil?
2494
+ step1.to_dynamic
2495
+ end
2496
+ end
2497
+
2498
+ def to_json(options = nil)
2499
+ JSON.generate(to_dynamic, options)
2500
+ end
2501
+ end
2502
+
2503
+ # Waits for previous steps to pass before continuing
2504
+ class GroupStepClass < Dry::Struct
2505
+ attribute :allow_dependency_failure, Types.Instance(AllowDependencyFailureUnion).optional
2506
+
2507
+ # The label of the block step
2508
+ attribute :block, Types.Instance(Block).optional
2509
+
2510
+ # The state that the build is set to when the build is blocked by this block step
2511
+ attribute :blocked_state, Types::BlockedState.optional
2512
+
2513
+ attribute :branches, Types.Instance(Branches).optional
2514
+ attribute :depends_on, Types.Instance(DependsOn).optional
2515
+ attribute :fields, Types.Array(Field).optional
2516
+ attribute :id, Types::String.optional
2517
+ attribute :identifier, Types::String.optional
2518
+ attribute :step_if, Types::String.optional
2519
+ attribute :key, Types::String.optional
2520
+ attribute :label, Types::String.optional.optional
2521
+ attribute :step_name, Types::String.optional.optional
2522
+ attribute :prompt, Types::String.optional
2523
+ attribute :step_type, Types::BlockStepType.optional
2524
+
2525
+ # The label of the input step
2526
+ attribute :input, Types.Instance(Input).optional
2527
+
2528
+ attribute :agents, Types.Instance(Agents).optional
2529
+
2530
+ # The glob path/s of artifacts to upload once this step has finished running
2531
+ attribute :artifact_paths, Types.Instance(Branches).optional
2532
+
2533
+ attribute :cache, Types.Instance(Cache).optional
2534
+ attribute :cancel_on_build_failing, Types.Instance(AllowDependencyFailureUnion).optional
2535
+
2536
+ # The commands to run on the agent
2537
+ attribute :command, Types.Instance(CommandUnion).optional
2538
+
2539
+ # The commands to run on the agent
2540
+ attribute :commands, Types.Instance(CommandUnion).optional
2541
+
2542
+ # The maximum number of jobs created from this step that are allowed to run at the same
2543
+ # time. If you use this attribute, you must also define concurrency_group.
2544
+ attribute :concurrency, Types::Integer.optional
2545
+
2546
+ # A unique name for the concurrency group that you are creating with the concurrency
2547
+ # attribute
2548
+ attribute :concurrency_group, Types::String.optional
2549
+
2550
+ # Control command order, allowed values are 'ordered' (default) and 'eager'. If you use
2551
+ # this attribute, you must also define concurrency_group and concurrency.
2552
+ attribute :concurrency_method, Types::ConcurrencyMethod.optional
2553
+
2554
+ attribute :env, Types::Hash.meta(of: Types::Any).optional
2555
+ attribute :matrix, Types.Instance(MatrixUnion).optional
2556
+
2557
+ # Array of notification options for this step
2558
+ attribute :notify, Types.Array(Types.Instance(BlockStepNotify)).optional
2559
+
2560
+ # The number of parallel jobs that will be created based on this step
2561
+ attribute :parallelism, Types::Integer.optional
2562
+
2563
+ attribute :plugins, Types.Instance(Plugins).optional
2564
+
2565
+ # Priority of the job, higher priorities are assigned to agents
2566
+ attribute :priority, Types::Integer.optional
2567
+
2568
+ # The conditions for retrying this step.
2569
+ attribute :step_retry, Retry.optional
2570
+
2571
+ # The signature of the command step, generally injected by agents at pipeline upload
2572
+ attribute :signature, Signature.optional
2573
+
2574
+ attribute :skip, Types.Instance(Skip).optional
2575
+ attribute :soft_fail, Types.Instance(SoftFail).optional
2576
+
2577
+ # The number of minutes to time out a job
2578
+ attribute :timeout_in_minutes, Types::Integer.optional
2579
+
2580
+ attribute :script, CommandStep.optional
2581
+
2582
+ # Continue to the next steps, even if the previous group of steps fail
2583
+ attribute :continue_on_failure, Types.Instance(AllowDependencyFailureUnion).optional
2584
+
2585
+ # Waits for previous steps to pass before continuing
2586
+ attribute :wait, Types.Instance(Label).optional
2587
+
2588
+ attribute :waiter, WaitStep.optional
2589
+
2590
+ # Whether to continue the build without waiting for the triggered step to complete
2591
+ attribute :async, Types.Instance(AllowDependencyFailureUnion).optional
2592
+
2593
+ # Properties of the build that will be created when the step is triggered
2594
+ attribute :build, Build.optional
2595
+
2596
+ # The slug of the pipeline to create a build
2597
+ attribute :trigger, Types.Instance(Trigger).optional
2598
+
2599
+ # The name to give to this group of steps
2600
+ attribute :group, Types::String.optional.optional
2601
+
2602
+ # A list of steps
2603
+ attribute :steps, Types.Array(Types.Instance(BlockStepStep)).optional
2604
+
2605
+ def self.from_dynamic!(d)
2606
+ d = Types::Hash[d]
2607
+ new(
2608
+ allow_dependency_failure: d["allow_dependency_failure"] ? AllowDependencyFailureUnion.from_dynamic!(d["allow_dependency_failure"]) : nil,
2609
+ block: d["block"] ? Block.from_dynamic!(d["block"]) : nil,
2610
+ blocked_state: d["blocked_state"],
2611
+ branches: d["branches"] ? Branches.from_dynamic!(d["branches"]) : nil,
2612
+ depends_on: d["depends_on"] ? DependsOn.from_dynamic!(d["depends_on"]) : nil,
2613
+ fields: d["fields"]&.map { |x| Field.from_dynamic!(x) },
2614
+ id: d["id"],
2615
+ identifier: d["identifier"],
2616
+ step_if: d["if"],
2617
+ key: d["key"],
2618
+ label: d["label"],
2619
+ step_name: d["name"],
2620
+ prompt: d["prompt"],
2621
+ step_type: d["type"],
2622
+ input: d["input"] ? Input.from_dynamic!(d["input"]) : nil,
2623
+ agents: d["agents"] ? Agents.from_dynamic!(d["agents"]) : nil,
2624
+ artifact_paths: d["artifact_paths"] ? Branches.from_dynamic!(d["artifact_paths"]) : nil,
2625
+ cache: d["cache"] ? Cache.from_dynamic!(d["cache"]) : nil,
2626
+ cancel_on_build_failing: d["cancel_on_build_failing"] ? AllowDependencyFailureUnion.from_dynamic!(d["cancel_on_build_failing"]) : nil,
2627
+ command: d["command"] ? CommandUnion.from_dynamic!(d["command"]) : nil,
2628
+ commands: d["commands"] ? CommandUnion.from_dynamic!(d["commands"]) : nil,
2629
+ concurrency: d["concurrency"],
2630
+ concurrency_group: d["concurrency_group"],
2631
+ concurrency_method: d["concurrency_method"],
2632
+ env: Types::Hash.optional[d["env"]]&.transform_values { |v| Types::Any[v] },
2633
+ matrix: d["matrix"] ? MatrixUnion.from_dynamic!(d["matrix"]) : nil,
2634
+ notify: d["notify"]&.map { |x| BlockStepNotify.from_dynamic!(x) },
2635
+ parallelism: d["parallelism"],
2636
+ plugins: d["plugins"] ? Plugins.from_dynamic!(d["plugins"]) : nil,
2637
+ priority: d["priority"],
2638
+ step_retry: d["retry"] ? Retry.from_dynamic!(d["retry"]) : nil,
2639
+ signature: d["signature"] ? Signature.from_dynamic!(d["signature"]) : nil,
2640
+ skip: d["skip"] ? Skip.from_dynamic!(d["skip"]) : nil,
2641
+ soft_fail: d["soft_fail"] ? SoftFail.from_dynamic!(d["soft_fail"]) : nil,
2642
+ timeout_in_minutes: d["timeout_in_minutes"],
2643
+ script: d["script"] ? CommandStep.from_dynamic!(d["script"]) : nil,
2644
+ continue_on_failure: d["continue_on_failure"] ? AllowDependencyFailureUnion.from_dynamic!(d["continue_on_failure"]) : nil,
2645
+ wait: d["wait"] ? Label.from_dynamic!(d["wait"]) : nil,
2646
+ waiter: d["waiter"] ? WaitStep.from_dynamic!(d["waiter"]) : nil,
2647
+ async: d["async"] ? AllowDependencyFailureUnion.from_dynamic!(d["async"]) : nil,
2648
+ build: d["build"] ? Build.from_dynamic!(d["build"]) : nil,
2649
+ trigger: d["trigger"] ? Trigger.from_dynamic!(d["trigger"]) : nil,
2650
+ group: d["group"],
2651
+ steps: d["steps"]&.map { |x| BlockStepStep.from_dynamic!(x) }
2652
+ )
2653
+ end
2654
+
2655
+ def self.from_json!(json)
2656
+ from_dynamic!(JSON.parse(json))
2657
+ end
2658
+
2659
+ def to_dynamic
2660
+ {
2661
+ "allow_dependency_failure" => allow_dependency_failure&.to_dynamic,
2662
+ "block" => block&.to_dynamic,
2663
+ "blocked_state" => blocked_state,
2664
+ "branches" => branches&.to_dynamic,
2665
+ "depends_on" => depends_on&.to_dynamic,
2666
+ "fields" => fields&.map(&:to_dynamic),
2667
+ "id" => id,
2668
+ "identifier" => identifier,
2669
+ "if" => step_if,
2670
+ "key" => key,
2671
+ "label" => label,
2672
+ "name" => step_name,
2673
+ "prompt" => prompt,
2674
+ "type" => step_type,
2675
+ "input" => input&.to_dynamic,
2676
+ "agents" => agents&.to_dynamic,
2677
+ "artifact_paths" => artifact_paths&.to_dynamic,
2678
+ "cache" => cache&.to_dynamic,
2679
+ "cancel_on_build_failing" => cancel_on_build_failing&.to_dynamic,
2680
+ "command" => command&.to_dynamic,
2681
+ "commands" => commands&.to_dynamic,
2682
+ "concurrency" => concurrency,
2683
+ "concurrency_group" => concurrency_group,
2684
+ "concurrency_method" => concurrency_method,
2685
+ "env" => env,
2686
+ "matrix" => matrix&.to_dynamic,
2687
+ "notify" => notify&.map(&:to_dynamic),
2688
+ "parallelism" => parallelism,
2689
+ "plugins" => plugins&.to_dynamic,
2690
+ "priority" => priority,
2691
+ "retry" => step_retry&.to_dynamic,
2692
+ "signature" => signature&.to_dynamic,
2693
+ "skip" => skip&.to_dynamic,
2694
+ "soft_fail" => soft_fail&.to_dynamic,
2695
+ "timeout_in_minutes" => timeout_in_minutes,
2696
+ "script" => script&.to_dynamic,
2697
+ "continue_on_failure" => continue_on_failure&.to_dynamic,
2698
+ "wait" => wait&.to_dynamic,
2699
+ "waiter" => waiter&.to_dynamic,
2700
+ "async" => async&.to_dynamic,
2701
+ "build" => build&.to_dynamic,
2702
+ "trigger" => trigger&.to_dynamic,
2703
+ "group" => group,
2704
+ "steps" => steps&.map(&:to_dynamic)
2705
+ }
2706
+ end
2707
+
2708
+ def to_json(options = nil)
2709
+ JSON.generate(to_dynamic, options)
2710
+ end
2711
+ end
2712
+
2713
+ class SchemaStep < Dry::Struct
2714
+ attribute :enum, Types::StringStep.optional
2715
+ attribute :group_step_class, GroupStepClass.optional
2716
+
2717
+ def self.from_dynamic!(d)
2718
+ return new(enum: d, group_step_class: nil) if schema[:enum].right.valid? d
2719
+
2720
+ begin
2721
+ value = GroupStepClass.from_dynamic!(d)
2722
+ return new(group_step_class: value, enum: nil) if schema[:group_step_class].right.valid? value
2723
+ rescue StandardError
2724
+ end
2725
+ raise "Invalid union"
2726
+ end
2727
+
2728
+ def self.from_json!(json)
2729
+ from_dynamic!(JSON.parse(json))
2730
+ end
2731
+
2732
+ def to_dynamic
2733
+ if !enum.nil?
2734
+ enum
2735
+ elsif !group_step_class.nil?
2736
+ group_step_class.to_dynamic
2737
+ end
2738
+ end
2739
+
2740
+ def to_json(options = nil)
2741
+ JSON.generate(to_dynamic, options)
2742
+ end
2743
+ end
2744
+
2745
+ class Schema < Dry::Struct
2746
+ attribute :agents, Types.Instance(Agents).optional
2747
+ attribute :env, Types::Hash.meta(of: Types::Any).optional
2748
+ attribute :notify, Types.Array(Types.Instance(SchemaNotify)).optional
2749
+
2750
+ # A list of steps
2751
+ attribute :steps, Types.Array(Types.Instance(SchemaStep))
2752
+
2753
+ def self.from_dynamic!(d)
2754
+ d = Types::Hash[d]
2755
+ new(
2756
+ agents: d["agents"] ? Agents.from_dynamic!(d["agents"]) : nil,
2757
+ env: Types::Hash.optional[d["env"]]&.transform_values { |v| Types::Any[v] },
2758
+ notify: d["notify"]&.map { |x| SchemaNotify.from_dynamic!(x) },
2759
+ steps: d.fetch("steps").map { |x| SchemaStep.from_dynamic!(x) }
2760
+ )
2761
+ end
2762
+
2763
+ def self.from_json!(json)
2764
+ from_dynamic!(JSON.parse(json))
2765
+ end
2766
+
2767
+ def to_dynamic
2768
+ {
2769
+ "agents" => agents&.to_dynamic,
2770
+ "env" => env,
2771
+ "notify" => notify&.map(&:to_dynamic),
2772
+ "steps" => steps.map(&:to_dynamic)
2773
+ }
2774
+ end
2775
+
2776
+ def to_json(options = nil)
2777
+ JSON.generate(to_dynamic, options)
2778
+ end
2779
+ end