cnunciato-buildkite 0.0.49 → 0.0.51

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