-
Notifications
You must be signed in to change notification settings - Fork 851
Expand file tree
/
Copy pathbasic_components.html
More file actions
1805 lines (1723 loc) · 98.4 KB
/
basic_components.html
File metadata and controls
1805 lines (1723 loc) · 98.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<meta name="generator" content="pdoc3 0.11.6">
<title>slack_sdk.models.blocks.basic_components API documentation</title>
<meta name="description" content="">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/13.0.0/sanitize.min.css" integrity="sha512-y1dtMcuvtTMJc1yPgEqF0ZjQbhnc/bFhyvIyVNb9Zk5mIGtqVaAB1Ttl28su8AvFMOY0EwRbAe+HCLqj6W7/KA==" crossorigin>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/13.0.0/typography.min.css" integrity="sha512-Y1DYSb995BAfxobCkKepB1BqJJTPrOp3zPL74AWFugHHmmdcvO+C48WLrUOlhGMc0QG7AE3f7gmvvcrmX2fDoA==" crossorigin>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css" crossorigin>
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:1.5em;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:2em 0 .50em 0}h3{font-size:1.4em;margin:1.6em 0 .7em 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .2s ease-in-out}a:visited{color:#503}a:hover{color:#b62}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900;font-weight:bold}pre code{font-size:.8em;line-height:1.4em;padding:1em;display:block}code{background:#f3f3f3;font-family:"DejaVu Sans Mono",monospace;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source > summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible;min-width:max-content}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em 1em;margin:1em 0}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul ul{padding-left:1em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" integrity="sha512-D9gUyxqja7hBtkWpPWGt9wfbfaMGVt9gnyCvYa+jojwwPHLCzUm5i8rpk7vD7wNee9bA35eYIjobYPaQuKS1MQ==" crossorigin></script>
<script>window.addEventListener('DOMContentLoaded', () => {
hljs.configure({languages: ['bash', 'css', 'diff', 'graphql', 'ini', 'javascript', 'json', 'plaintext', 'python', 'python-repl', 'rust', 'shell', 'sql', 'typescript', 'xml', 'yaml']});
hljs.highlightAll();
/* Collapse source docstrings */
setTimeout(() => {
[...document.querySelectorAll('.hljs.language-python > .hljs-string')]
.filter(el => el.innerHTML.length > 200 && ['"""', "'''"].includes(el.innerHTML.substring(0, 3)))
.forEach(el => {
let d = document.createElement('details');
d.classList.add('hljs-string');
d.innerHTML = '<summary>"""</summary>' + el.innerHTML.substring(3);
el.replaceWith(d);
});
}, 100);
})</script>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>slack_sdk.models.blocks.basic_components</code></h1>
</header>
<section id="section-intro">
</section>
<section>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.ConfirmObject"><code class="flex name class">
<span>class <span class="ident">ConfirmObject</span></span>
<span>(</span><span>*,<br>title: str | Dict[str, Any] | <a title="slack_sdk.models.blocks.basic_components.PlainTextObject" href="#slack_sdk.models.blocks.basic_components.PlainTextObject">PlainTextObject</a>,<br>text: str | Dict[str, Any] | <a title="slack_sdk.models.blocks.basic_components.TextObject" href="#slack_sdk.models.blocks.basic_components.TextObject">TextObject</a>,<br>confirm: str | Dict[str, Any] | <a title="slack_sdk.models.blocks.basic_components.PlainTextObject" href="#slack_sdk.models.blocks.basic_components.PlainTextObject">PlainTextObject</a> = 'Yes',<br>deny: str | Dict[str, Any] | <a title="slack_sdk.models.blocks.basic_components.PlainTextObject" href="#slack_sdk.models.blocks.basic_components.PlainTextObject">PlainTextObject</a> = 'No',<br>style: str | None = None)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class ConfirmObject(JsonObject):
attributes: Set[str] = set()
title_max_length = 100
text_max_length = 300
confirm_max_length = 30
deny_max_length = 30
@classmethod
def parse(cls, confirm: Union["ConfirmObject", Dict[str, Any]]):
if confirm:
if isinstance(confirm, ConfirmObject):
return confirm
elif isinstance(confirm, dict):
return ConfirmObject(**confirm)
else:
# Not yet implemented: show some warning here
return None
return None
def __init__(
self,
*,
title: Union[str, Dict[str, Any], PlainTextObject],
text: Union[str, Dict[str, Any], TextObject],
confirm: Union[str, Dict[str, Any], PlainTextObject] = "Yes",
deny: Union[str, Dict[str, Any], PlainTextObject] = "No",
style: Optional[str] = None,
):
"""
An object that defines a dialog that provides a confirmation step to any
interactive element. This dialog will ask the user to confirm their action by
offering a confirm and deny button.
https://docs.slack.dev/reference/block-kit/composition-objects/confirmation-dialog-object/
"""
self._title = TextObject.parse(title, default_type=PlainTextObject.type)
self._text = TextObject.parse(text, default_type=MarkdownTextObject.type)
self._confirm = TextObject.parse(confirm, default_type=PlainTextObject.type)
self._deny = TextObject.parse(deny, default_type=PlainTextObject.type)
self._style = style
# for backward-compatibility with version 2.0-2.5, the following fields return str values
self.title = self._title.text if self._title else None
self.text = self._text.text if self._text else None
self.confirm = self._confirm.text if self._confirm else None
self.deny = self._deny.text if self._deny else None
self.style = self._style
@JsonValidator(f"title attribute cannot exceed {title_max_length} characters")
def title_length(self) -> bool:
return self._title is None or len(self._title.text) <= self.title_max_length
@JsonValidator(f"text attribute cannot exceed {text_max_length} characters")
def text_length(self) -> bool:
return self._text is None or len(self._text.text) <= self.text_max_length
@JsonValidator(f"confirm attribute cannot exceed {confirm_max_length} characters")
def confirm_length(self) -> bool:
return self._confirm is None or len(self._confirm.text) <= self.confirm_max_length
@JsonValidator(f"deny attribute cannot exceed {deny_max_length} characters")
def deny_length(self) -> bool:
return self._deny is None or len(self._deny.text) <= self.deny_max_length
@JsonValidator('style for confirm must be either "primary" or "danger"')
def _validate_confirm_style(self) -> bool:
return self._style is None or self._style in ["primary", "danger"]
def to_dict(self, option_type: str = "block") -> Dict[str, Any]:
if option_type == "action":
# deliberately skipping JSON validators here - can't find documentation
# on actual limits here
json: Dict[str, Union[str, dict]] = {
"ok_text": self._confirm.text if self._confirm and self._confirm.text != "Yes" else "Okay",
"dismiss_text": self._deny.text if self._deny and self._deny.text != "No" else "Cancel",
}
if self._title:
json["title"] = self._title.text
if self._text:
json["text"] = self._text.text
return json
else:
self.validate_json()
json = {}
if self._title:
json["title"] = self._title.to_dict()
if self._text:
json["text"] = self._text.to_dict()
if self._confirm:
json["confirm"] = self._confirm.to_dict()
if self._deny:
json["deny"] = self._deny.to_dict()
if self._style:
json["style"] = self._style
return json</code></pre>
</details>
<div class="desc"><p>The base class for JSON serializable class objects</p>
<p>An object that defines a dialog that provides a confirmation step to any
interactive element. This dialog will ask the user to confirm their action by
offering a confirm and deny button.
<a href="https://docs.slack.dev/reference/block-kit/composition-objects/confirmation-dialog-object/">https://docs.slack.dev/reference/block-kit/composition-objects/confirmation-dialog-object/</a></p></div>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="slack_sdk.models.basic_objects.JsonObject" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject">JsonObject</a></li>
<li><a title="slack_sdk.models.basic_objects.BaseObject" href="../basic_objects.html#slack_sdk.models.basic_objects.BaseObject">BaseObject</a></li>
</ul>
<h3>Class variables</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.ConfirmObject.attributes"><code class="name">var <span class="ident">attributes</span> : Set[str]</code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.ConfirmObject.confirm_max_length"><code class="name">var <span class="ident">confirm_max_length</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.ConfirmObject.deny_max_length"><code class="name">var <span class="ident">deny_max_length</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.ConfirmObject.text_max_length"><code class="name">var <span class="ident">text_max_length</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.ConfirmObject.title_max_length"><code class="name">var <span class="ident">title_max_length</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
</dl>
<h3>Static methods</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.ConfirmObject.parse"><code class="name flex">
<span>def <span class="ident">parse</span></span>(<span>confirm: <a title="slack_sdk.models.blocks.basic_components.ConfirmObject" href="#slack_sdk.models.blocks.basic_components.ConfirmObject">ConfirmObject</a> | Dict[str, Any])</span>
</code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.ConfirmObject.confirm_length"><code class="name flex">
<span>def <span class="ident">confirm_length</span></span>(<span>self) ‑> bool</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@JsonValidator(f"confirm attribute cannot exceed {confirm_max_length} characters")
def confirm_length(self) -> bool:
return self._confirm is None or len(self._confirm.text) <= self.confirm_max_length</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.ConfirmObject.deny_length"><code class="name flex">
<span>def <span class="ident">deny_length</span></span>(<span>self) ‑> bool</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@JsonValidator(f"deny attribute cannot exceed {deny_max_length} characters")
def deny_length(self) -> bool:
return self._deny is None or len(self._deny.text) <= self.deny_max_length</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.ConfirmObject.text_length"><code class="name flex">
<span>def <span class="ident">text_length</span></span>(<span>self) ‑> bool</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@JsonValidator(f"text attribute cannot exceed {text_max_length} characters")
def text_length(self) -> bool:
return self._text is None or len(self._text.text) <= self.text_max_length</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.ConfirmObject.title_length"><code class="name flex">
<span>def <span class="ident">title_length</span></span>(<span>self) ‑> bool</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@JsonValidator(f"title attribute cannot exceed {title_max_length} characters")
def title_length(self) -> bool:
return self._title is None or len(self._title.text) <= self.title_max_length</code></pre>
</details>
<div class="desc"></div>
</dd>
</dl>
<h3>Inherited members</h3>
<ul class="hlist">
<li><code><b><a title="slack_sdk.models.basic_objects.JsonObject" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject">JsonObject</a></b></code>:
<ul class="hlist">
<li><code><a title="slack_sdk.models.basic_objects.JsonObject.get_non_null_attributes" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.get_non_null_attributes">get_non_null_attributes</a></code></li>
<li><code><a title="slack_sdk.models.basic_objects.JsonObject.to_dict" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.to_dict">to_dict</a></code></li>
<li><code><a title="slack_sdk.models.basic_objects.JsonObject.validate_json" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.validate_json">validate_json</a></code></li>
</ul>
</li>
</ul>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.DispatchActionConfig"><code class="flex name class">
<span>class <span class="ident">DispatchActionConfig</span></span>
<span>(</span><span>*, trigger_actions_on: List[Any] | None = None)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class DispatchActionConfig(JsonObject):
attributes = {"trigger_actions_on"}
@classmethod
def parse(cls, config: Union["DispatchActionConfig", Dict[str, Any]]):
if config:
if isinstance(config, DispatchActionConfig):
return config
elif isinstance(config, dict):
return DispatchActionConfig(**config)
else:
# Not yet implemented: show some warning here
return None
return None
def __init__(
self,
*,
trigger_actions_on: Optional[List[Any]] = None,
):
"""
Determines when a plain-text input element will return a block_actions interaction payload.
https://docs.slack.dev/reference/block-kit/composition-objects/dispatch-action-configuration-object
"""
self._trigger_actions_on = trigger_actions_on or []
def to_dict(self) -> Dict[str, Any]:
self.validate_json()
json = {}
if self._trigger_actions_on:
json["trigger_actions_on"] = self._trigger_actions_on
return json</code></pre>
</details>
<div class="desc"><p>The base class for JSON serializable class objects</p>
<p>Determines when a plain-text input element will return a block_actions interaction payload.
<a href="https://docs.slack.dev/reference/block-kit/composition-objects/dispatch-action-configuration-object">https://docs.slack.dev/reference/block-kit/composition-objects/dispatch-action-configuration-object</a></p></div>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="slack_sdk.models.basic_objects.JsonObject" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject">JsonObject</a></li>
<li><a title="slack_sdk.models.basic_objects.BaseObject" href="../basic_objects.html#slack_sdk.models.basic_objects.BaseObject">BaseObject</a></li>
</ul>
<h3>Class variables</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.DispatchActionConfig.attributes"><code class="name">var <span class="ident">attributes</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
</dl>
<h3>Static methods</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.DispatchActionConfig.parse"><code class="name flex">
<span>def <span class="ident">parse</span></span>(<span>config: <a title="slack_sdk.models.blocks.basic_components.DispatchActionConfig" href="#slack_sdk.models.blocks.basic_components.DispatchActionConfig">DispatchActionConfig</a> | Dict[str, Any])</span>
</code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
<h3>Inherited members</h3>
<ul class="hlist">
<li><code><b><a title="slack_sdk.models.basic_objects.JsonObject" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject">JsonObject</a></b></code>:
<ul class="hlist">
<li><code><a title="slack_sdk.models.basic_objects.JsonObject.get_non_null_attributes" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.get_non_null_attributes">get_non_null_attributes</a></code></li>
<li><code><a title="slack_sdk.models.basic_objects.JsonObject.to_dict" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.to_dict">to_dict</a></code></li>
<li><code><a title="slack_sdk.models.basic_objects.JsonObject.validate_json" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.validate_json">validate_json</a></code></li>
</ul>
</li>
</ul>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.FeedbackButtonObject"><code class="flex name class">
<span>class <span class="ident">FeedbackButtonObject</span></span>
<span>(</span><span>*,<br>text: str | Dict[str, Any] | <a title="slack_sdk.models.blocks.basic_components.PlainTextObject" href="#slack_sdk.models.blocks.basic_components.PlainTextObject">PlainTextObject</a>,<br>accessibility_label: str | None = None,<br>value: str,<br>**others: Dict[str, Any])</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class FeedbackButtonObject(JsonObject):
attributes: Set[str] = set()
text_max_length = 75
value_max_length = 2000
@classmethod
def parse(cls, feedback_button: Union["FeedbackButtonObject", Dict[str, Any]]):
if feedback_button:
if isinstance(feedback_button, FeedbackButtonObject):
return feedback_button
elif isinstance(feedback_button, dict):
return FeedbackButtonObject(**feedback_button)
else:
# Not yet implemented: show some warning here
return None
return None
def __init__(
self,
*,
text: Union[str, Dict[str, Any], PlainTextObject],
accessibility_label: Optional[str] = None,
value: str,
**others: Dict[str, Any],
):
"""
A feedback button element object for either positive or negative feedback.
https://docs.slack.dev/reference/block-kit/block-elements/feedback-buttons-element#button-object-fields
Args:
text (required): An object containing some text. Maximum length for this field is 75 characters.
accessibility_label: A label for longer descriptive text about a button element. This label will be read out by
screen readers instead of the button `text` object.
value (required): The button value. Maximum length for this field is 2000 characters.
"""
self._text: Optional[TextObject] = PlainTextObject.parse(text, default_type=PlainTextObject.type)
self._accessibility_label: Optional[str] = accessibility_label
self._value: Optional[str] = value
show_unknown_key_warning(self, others)
@JsonValidator(f"text attribute cannot exceed {text_max_length} characters")
def text_length(self) -> bool:
return self._text is None or len(self._text.text) <= self.text_max_length
@JsonValidator(f"value attribute cannot exceed {value_max_length} characters")
def value_length(self) -> bool:
return self._value is None or len(self._value) <= self.value_max_length
def to_dict(self) -> Dict[str, Any]:
self.validate_json()
json: Dict[str, Union[str, dict]] = {}
if self._text:
json["text"] = self._text.to_dict()
if self._accessibility_label:
json["accessibility_label"] = self._accessibility_label
if self._value:
json["value"] = self._value
return json</code></pre>
</details>
<div class="desc"><p>The base class for JSON serializable class objects</p>
<p>A feedback button element object for either positive or negative feedback.
<a href="https://docs.slack.dev/reference/block-kit/block-elements/feedback-buttons-element#button-object-fields">https://docs.slack.dev/reference/block-kit/block-elements/feedback-buttons-element#button-object-fields</a></p>
<h2 id="args">Args</h2>
<dl>
<dt><strong><code>text</code></strong> : <code>required</code></dt>
<dd>An object containing some text. Maximum length for this field is 75 characters.</dd>
<dt><strong><code>accessibility_label</code></strong></dt>
<dd>A label for longer descriptive text about a button element. This label will be read out by
screen readers instead of the button <code>text</code> object.</dd>
<dt><strong><code>value</code></strong> : <code>required</code></dt>
<dd>The button value. Maximum length for this field is 2000 characters.</dd>
</dl></div>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="slack_sdk.models.basic_objects.JsonObject" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject">JsonObject</a></li>
<li><a title="slack_sdk.models.basic_objects.BaseObject" href="../basic_objects.html#slack_sdk.models.basic_objects.BaseObject">BaseObject</a></li>
</ul>
<h3>Class variables</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.FeedbackButtonObject.attributes"><code class="name">var <span class="ident">attributes</span> : Set[str]</code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.FeedbackButtonObject.text_max_length"><code class="name">var <span class="ident">text_max_length</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.FeedbackButtonObject.value_max_length"><code class="name">var <span class="ident">value_max_length</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
</dl>
<h3>Static methods</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.FeedbackButtonObject.parse"><code class="name flex">
<span>def <span class="ident">parse</span></span>(<span>feedback_button: <a title="slack_sdk.models.blocks.basic_components.FeedbackButtonObject" href="#slack_sdk.models.blocks.basic_components.FeedbackButtonObject">FeedbackButtonObject</a> | Dict[str, Any])</span>
</code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.FeedbackButtonObject.text_length"><code class="name flex">
<span>def <span class="ident">text_length</span></span>(<span>self) ‑> bool</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@JsonValidator(f"text attribute cannot exceed {text_max_length} characters")
def text_length(self) -> bool:
return self._text is None or len(self._text.text) <= self.text_max_length</code></pre>
</details>
<div class="desc"></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.FeedbackButtonObject.value_length"><code class="name flex">
<span>def <span class="ident">value_length</span></span>(<span>self) ‑> bool</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@JsonValidator(f"value attribute cannot exceed {value_max_length} characters")
def value_length(self) -> bool:
return self._value is None or len(self._value) <= self.value_max_length</code></pre>
</details>
<div class="desc"></div>
</dd>
</dl>
<h3>Inherited members</h3>
<ul class="hlist">
<li><code><b><a title="slack_sdk.models.basic_objects.JsonObject" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject">JsonObject</a></b></code>:
<ul class="hlist">
<li><code><a title="slack_sdk.models.basic_objects.JsonObject.get_non_null_attributes" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.get_non_null_attributes">get_non_null_attributes</a></code></li>
<li><code><a title="slack_sdk.models.basic_objects.JsonObject.to_dict" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.to_dict">to_dict</a></code></li>
<li><code><a title="slack_sdk.models.basic_objects.JsonObject.validate_json" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.validate_json">validate_json</a></code></li>
</ul>
</li>
</ul>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.MarkdownTextObject"><code class="flex name class">
<span>class <span class="ident">MarkdownTextObject</span></span>
<span>(</span><span>*, text: str, verbatim: bool | None = None)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class MarkdownTextObject(TextObject):
"""mrkdwn typed text object"""
type = "mrkdwn"
@property
def attributes(self) -> Set[str]: # type: ignore[override]
return super().attributes.union({"verbatim"})
def __init__(self, *, text: str, verbatim: Optional[bool] = None):
"""A Markdown text object, meaning markdown characters will be parsed as
formatting information.
https://docs.slack.dev/reference/block-kit/composition-objects/text-object
Args:
text (required): The text for the block. This field accepts any of the standard text formatting markup
when type is mrkdwn.
verbatim: When set to false (as is default) URLs will be auto-converted into links,
conversation names will be link-ified, and certain mentions will be automatically parsed.
Using a value of true will skip any preprocessing of this nature,
although you can still include manual parsing strings. This field is only usable when type is mrkdwn.
"""
super().__init__(text=text, type=self.type)
self.verbatim = verbatim
@staticmethod
def from_str(text: str) -> "MarkdownTextObject":
"""Transforms a string into the required object shape to act as a MarkdownTextObject"""
return MarkdownTextObject(text=text)
@staticmethod
def direct_from_string(text: str) -> Dict[str, Any]:
"""Transforms a string into the required object shape to act as a MarkdownTextObject"""
return MarkdownTextObject.from_str(text).to_dict()
@staticmethod
def from_link(link: Link, title: str = "") -> "MarkdownTextObject":
"""
Transform a Link object directly into the required object shape
to act as a MarkdownTextObject
"""
if title:
title = f": {title}"
return MarkdownTextObject(text=f"{link}{title}")
@staticmethod
def direct_from_link(link: Link, title: str = "") -> Dict[str, Any]:
"""
Transform a Link object directly into the required object shape
to act as a MarkdownTextObject
"""
return MarkdownTextObject.from_link(link, title).to_dict()</code></pre>
</details>
<div class="desc"><p>mrkdwn typed text object</p>
<p>A Markdown text object, meaning markdown characters will be parsed as
formatting information.
<a href="https://docs.slack.dev/reference/block-kit/composition-objects/text-object">https://docs.slack.dev/reference/block-kit/composition-objects/text-object</a></p>
<h2 id="args">Args</h2>
<dl>
<dt><strong><code>text</code></strong> : <code>required</code></dt>
<dd>The text for the block. This field accepts any of the standard text formatting markup
when type is mrkdwn.</dd>
<dt><strong><code>verbatim</code></strong></dt>
<dd>When set to false (as is default) URLs will be auto-converted into links,
conversation names will be link-ified, and certain mentions will be automatically parsed.
Using a value of true will skip any preprocessing of this nature,
although you can still include manual parsing strings. This field is only usable when type is mrkdwn.</dd>
</dl></div>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="slack_sdk.models.blocks.basic_components.TextObject" href="#slack_sdk.models.blocks.basic_components.TextObject">TextObject</a></li>
<li><a title="slack_sdk.models.basic_objects.JsonObject" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject">JsonObject</a></li>
<li><a title="slack_sdk.models.basic_objects.BaseObject" href="../basic_objects.html#slack_sdk.models.basic_objects.BaseObject">BaseObject</a></li>
</ul>
<h3>Class variables</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.MarkdownTextObject.type"><code class="name">var <span class="ident">type</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
</dl>
<h3>Static methods</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.MarkdownTextObject.direct_from_link"><code class="name flex">
<span>def <span class="ident">direct_from_link</span></span>(<span>link: <a title="slack_sdk.models.messages.Link" href="../messages/index.html#slack_sdk.models.messages.Link">Link</a>,<br>title: str = '') ‑> Dict[str, Any]</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@staticmethod
def direct_from_link(link: Link, title: str = "") -> Dict[str, Any]:
"""
Transform a Link object directly into the required object shape
to act as a MarkdownTextObject
"""
return MarkdownTextObject.from_link(link, title).to_dict()</code></pre>
</details>
<div class="desc"><p>Transform a Link object directly into the required object shape
to act as a MarkdownTextObject</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.MarkdownTextObject.direct_from_string"><code class="name flex">
<span>def <span class="ident">direct_from_string</span></span>(<span>text: str) ‑> Dict[str, Any]</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@staticmethod
def direct_from_string(text: str) -> Dict[str, Any]:
"""Transforms a string into the required object shape to act as a MarkdownTextObject"""
return MarkdownTextObject.from_str(text).to_dict()</code></pre>
</details>
<div class="desc"><p>Transforms a string into the required object shape to act as a MarkdownTextObject</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.MarkdownTextObject.from_link"><code class="name flex">
<span>def <span class="ident">from_link</span></span>(<span>link: <a title="slack_sdk.models.messages.Link" href="../messages/index.html#slack_sdk.models.messages.Link">Link</a>,<br>title: str = '') ‑> <a title="slack_sdk.models.blocks.basic_components.MarkdownTextObject" href="#slack_sdk.models.blocks.basic_components.MarkdownTextObject">MarkdownTextObject</a></span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@staticmethod
def from_link(link: Link, title: str = "") -> "MarkdownTextObject":
"""
Transform a Link object directly into the required object shape
to act as a MarkdownTextObject
"""
if title:
title = f": {title}"
return MarkdownTextObject(text=f"{link}{title}")</code></pre>
</details>
<div class="desc"><p>Transform a Link object directly into the required object shape
to act as a MarkdownTextObject</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.MarkdownTextObject.from_str"><code class="name flex">
<span>def <span class="ident">from_str</span></span>(<span>text: str) ‑> <a title="slack_sdk.models.blocks.basic_components.MarkdownTextObject" href="#slack_sdk.models.blocks.basic_components.MarkdownTextObject">MarkdownTextObject</a></span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@staticmethod
def from_str(text: str) -> "MarkdownTextObject":
"""Transforms a string into the required object shape to act as a MarkdownTextObject"""
return MarkdownTextObject(text=text)</code></pre>
</details>
<div class="desc"><p>Transforms a string into the required object shape to act as a MarkdownTextObject</p></div>
</dd>
</dl>
<h3>Instance variables</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.MarkdownTextObject.attributes"><code class="name">prop <span class="ident">attributes</span> : Set[str]</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def attributes(self) -> Set[str]: # type: ignore[override]
return super().attributes.union({"verbatim"})</code></pre>
</details>
<div class="desc"><p>Build an unordered collection of unique elements.</p></div>
</dd>
</dl>
<h3>Inherited members</h3>
<ul class="hlist">
<li><code><b><a title="slack_sdk.models.blocks.basic_components.TextObject" href="#slack_sdk.models.blocks.basic_components.TextObject">TextObject</a></b></code>:
<ul class="hlist">
<li><code><a title="slack_sdk.models.blocks.basic_components.TextObject.get_non_null_attributes" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.get_non_null_attributes">get_non_null_attributes</a></code></li>
<li><code><a title="slack_sdk.models.blocks.basic_components.TextObject.logger" href="#slack_sdk.models.blocks.basic_components.TextObject.logger">logger</a></code></li>
<li><code><a title="slack_sdk.models.blocks.basic_components.TextObject.to_dict" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.to_dict">to_dict</a></code></li>
<li><code><a title="slack_sdk.models.blocks.basic_components.TextObject.validate_json" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.validate_json">validate_json</a></code></li>
</ul>
</li>
</ul>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.Option"><code class="flex name class">
<span>class <span class="ident">Option</span></span>
<span>(</span><span>*,<br>value: str,<br>label: str | None = None,<br>text: str | Dict[str, Any] | <a title="slack_sdk.models.blocks.basic_components.TextObject" href="#slack_sdk.models.blocks.basic_components.TextObject">TextObject</a> | None = None,<br>description: str | Dict[str, Any] | <a title="slack_sdk.models.blocks.basic_components.TextObject" href="#slack_sdk.models.blocks.basic_components.TextObject">TextObject</a> | None = None,<br>url: str | None = None,<br>**others: Dict[str, Any])</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class Option(JsonObject):
"""Option object used in dialogs, legacy message actions (interactivity in attachments),
and blocks. JSON must be retrieved with an explicit option_type - the Slack API has
different required formats in different situations
"""
attributes: Set[str] = set()
logger = logging.getLogger(__name__)
label_max_length = 75
value_max_length = 150
def __init__(
self,
*,
value: str,
label: Optional[str] = None,
text: Optional[Union[str, Dict[str, Any], TextObject]] = None, # Block Kit
description: Optional[Union[str, Dict[str, Any], TextObject]] = None,
url: Optional[str] = None,
**others: Dict[str, Any],
):
"""
An object that represents a single selectable item in a block element (
SelectElement, OverflowMenuElement) or dialog element
(StaticDialogSelectElement)
Blocks:
https://docs.slack.dev/reference/block-kit/composition-objects/option-object
Dialogs:
https://docs.slack.dev/legacy/legacy-dialogs/#select_elements
Legacy interactive attachments:
https://docs.slack.dev/legacy/legacy-messaging/legacy-interactive-message-field-guide/#option_fields
Args:
label: A short, user-facing string to label this option to users.
Cannot exceed 75 characters.
value: A short string that identifies this particular option to your
application. It will be part of the payload when this option is selected
. Cannot exceed 150 characters.
description: A user-facing string that provides more details about
this option. Only supported in legacy message actions, not in blocks or
dialogs.
"""
if text:
# For better compatibility with Block Kit ("mrkdwn" does not work for it),
# we've changed the default text object type to plain_text since version 3.10.0
self._text: Optional[TextObject] = TextObject.parse(
text=text, # "text" here can be either a str or a TextObject
default_type=PlainTextObject.type,
)
self._label: Optional[str] = None
else:
self._text = None
self._label = label
# for backward-compatibility with version 2.0-2.5, the following fields return str values
self.text: Optional[str] = self._text.text if self._text else None
self.label: Optional[str] = self._label
self.value: str = value
# for backward-compatibility with version 2.0-2.5, the following fields return str values
if isinstance(description, str):
self.description = description
self._block_description = PlainTextObject.from_str(description)
elif isinstance(description, dict):
self.description = description["text"]
self._block_description = TextObject.parse(description) # type: ignore[assignment]
elif isinstance(description, TextObject):
self.description = description.text
self._block_description = description # type: ignore[assignment]
else:
self.description = None # type: ignore[assignment]
self._block_description = None # type: ignore[assignment]
# A URL to load in the user's browser when the option is clicked.
# The url attribute is only available in overflow menus.
# Maximum length for this field is 3000 characters.
# If you're using url, you'll still receive an interaction payload
# and will need to send an acknowledgement response.
self.url: Optional[str] = url
show_unknown_key_warning(self, others)
@JsonValidator(f"label attribute cannot exceed {label_max_length} characters")
def _validate_label_length(self) -> bool:
return self._label is None or len(self._label) <= self.label_max_length
@JsonValidator(f"text attribute cannot exceed {label_max_length} characters")
def _validate_text_length(self) -> bool:
return self._text is None or self._text.text is None or len(self._text.text) <= self.label_max_length
@JsonValidator(f"value attribute cannot exceed {value_max_length} characters")
def _validate_value_length(self) -> bool:
return len(self.value) <= self.value_max_length
@classmethod
def parse_all(cls, options: Optional[Sequence[Union[Dict[str, Any], "Option"]]]) -> Optional[List["Option"]]:
if options is None:
return None
option_objects: List[Option] = []
for o in options:
if isinstance(o, dict):
d = copy.copy(o)
option_objects.append(Option(**d))
elif isinstance(o, Option):
option_objects.append(o)
else:
cls.logger.warning(f"Unknown option object detected and skipped ({o})")
return option_objects
def to_dict(self, option_type: str = "block") -> Dict[str, Any]:
"""
Different parent classes must call this with a valid value from OptionTypes -
either "dialog", "action", or "block", so that JSON is returned in the
correct shape.
"""
self.validate_json()
if option_type == "dialog":
return {"label": self.label, "value": self.value}
elif option_type == "action" or option_type == "attachment":
# "action" can be confusing but it means a legacy message action in attachments
# we don't remove the type name for backward compatibility though
json: Dict[str, Any] = {"text": self.label, "value": self.value}
if self.description is not None:
json["description"] = self.description
return json
else: # if option_type == "block"; this should be the most common case
text: TextObject = self._text or PlainTextObject.from_str(self.label) # type: ignore[arg-type]
json = {
"text": text.to_dict(),
"value": self.value,
}
if self._block_description:
json["description"] = self._block_description.to_dict()
if self.url:
json["url"] = self.url
return json
@staticmethod
def from_single_value(value_and_label: str):
"""Creates a simple Option instance with the same value and label"""
return Option(value=value_and_label, label=value_and_label)</code></pre>
</details>
<div class="desc"><p>Option object used in dialogs, legacy message actions (interactivity in attachments),
and blocks. JSON must be retrieved with an explicit option_type - the Slack API has
different required formats in different situations</p>
<p>An object that represents a single selectable item in a block element (
SelectElement, OverflowMenuElement) or dialog element
(StaticDialogSelectElement)</p>
<p>Blocks:
<a href="https://docs.slack.dev/reference/block-kit/composition-objects/option-object">https://docs.slack.dev/reference/block-kit/composition-objects/option-object</a></p>
<p>Dialogs:
<a href="https://docs.slack.dev/legacy/legacy-dialogs/#select_elements">https://docs.slack.dev/legacy/legacy-dialogs/#select_elements</a></p>
<p>Legacy interactive attachments:
<a href="https://docs.slack.dev/legacy/legacy-messaging/legacy-interactive-message-field-guide/#option_fields">https://docs.slack.dev/legacy/legacy-messaging/legacy-interactive-message-field-guide/#option_fields</a></p>
<h2 id="args">Args</h2>
<dl>
<dt><strong><code>label</code></strong></dt>
<dd>A short, user-facing string to label this option to users.
Cannot exceed 75 characters.</dd>
<dt><strong><code>value</code></strong></dt>
<dd>A short string that identifies this particular option to your
application. It will be part of the payload when this option is selected
. Cannot exceed 150 characters.</dd>
<dt><strong><code>description</code></strong></dt>
<dd>A user-facing string that provides more details about
this option. Only supported in legacy message actions, not in blocks or
dialogs.</dd>
</dl></div>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="slack_sdk.models.basic_objects.JsonObject" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject">JsonObject</a></li>
<li><a title="slack_sdk.models.basic_objects.BaseObject" href="../basic_objects.html#slack_sdk.models.basic_objects.BaseObject">BaseObject</a></li>
</ul>
<h3>Class variables</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.Option.attributes"><code class="name">var <span class="ident">attributes</span> : Set[str]</code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.Option.label_max_length"><code class="name">var <span class="ident">label_max_length</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.Option.logger"><code class="name">var <span class="ident">logger</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.Option.value_max_length"><code class="name">var <span class="ident">value_max_length</span></code></dt>
<dd>
<div class="desc"><p>The type of the None singleton.</p></div>
</dd>
</dl>
<h3>Static methods</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.Option.from_single_value"><code class="name flex">
<span>def <span class="ident">from_single_value</span></span>(<span>value_and_label: str)</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@staticmethod
def from_single_value(value_and_label: str):
"""Creates a simple Option instance with the same value and label"""
return Option(value=value_and_label, label=value_and_label)</code></pre>
</details>
<div class="desc"><p>Creates a simple Option instance with the same value and label</p></div>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.Option.parse_all"><code class="name flex">
<span>def <span class="ident">parse_all</span></span>(<span>options: Sequence[Dict[str, Any] | <a title="slack_sdk.models.blocks.basic_components.Option" href="#slack_sdk.models.blocks.basic_components.Option">Option</a>] | None) ‑> List[<a title="slack_sdk.models.blocks.basic_components.Option" href="#slack_sdk.models.blocks.basic_components.Option">Option</a>] | None</span>
</code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="slack_sdk.models.blocks.basic_components.Option.to_dict"><code class="name flex">
<span>def <span class="ident">to_dict</span></span>(<span>self, option_type: str = 'block') ‑> Dict[str, Any]</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def to_dict(self, option_type: str = "block") -> Dict[str, Any]:
"""
Different parent classes must call this with a valid value from OptionTypes -
either "dialog", "action", or "block", so that JSON is returned in the
correct shape.
"""
self.validate_json()
if option_type == "dialog":
return {"label": self.label, "value": self.value}
elif option_type == "action" or option_type == "attachment":
# "action" can be confusing but it means a legacy message action in attachments
# we don't remove the type name for backward compatibility though
json: Dict[str, Any] = {"text": self.label, "value": self.value}
if self.description is not None:
json["description"] = self.description
return json
else: # if option_type == "block"; this should be the most common case
text: TextObject = self._text or PlainTextObject.from_str(self.label) # type: ignore[arg-type]
json = {
"text": text.to_dict(),
"value": self.value,
}
if self._block_description:
json["description"] = self._block_description.to_dict()
if self.url:
json["url"] = self.url
return json</code></pre>
</details>
<div class="desc"><p>Different parent classes must call this with a valid value from OptionTypes -
either "dialog", "action", or "block", so that JSON is returned in the
correct shape.</p></div>
</dd>
</dl>
<h3>Inherited members</h3>
<ul class="hlist">
<li><code><b><a title="slack_sdk.models.basic_objects.JsonObject" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject">JsonObject</a></b></code>:
<ul class="hlist">
<li><code><a title="slack_sdk.models.basic_objects.JsonObject.get_non_null_attributes" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.get_non_null_attributes">get_non_null_attributes</a></code></li>
<li><code><a title="slack_sdk.models.basic_objects.JsonObject.validate_json" href="../basic_objects.html#slack_sdk.models.basic_objects.JsonObject.validate_json">validate_json</a></code></li>
</ul>
</li>
</ul>
</dd>
<dt id="slack_sdk.models.blocks.basic_components.OptionGroup"><code class="flex name class">
<span>class <span class="ident">OptionGroup</span></span>
<span>(</span><span>*,<br>label: str | Dict[str, Any] | <a title="slack_sdk.models.blocks.basic_components.TextObject" href="#slack_sdk.models.blocks.basic_components.TextObject">TextObject</a> | None = None,<br>options: Sequence[Dict[str, Any] | <a title="slack_sdk.models.blocks.basic_components.Option" href="#slack_sdk.models.blocks.basic_components.Option">Option</a>],<br>**others: Dict[str, Any])</span>
</code></dt>
<dd>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class OptionGroup(JsonObject):
"""
JSON must be retrieved with an explicit option_type - the Slack API has
different required formats in different situations
"""
attributes: Set[str] = set()
label_max_length = 75
options_max_length = 100
logger = logging.getLogger(__name__)
def __init__(
self,
*,
label: Optional[Union[str, Dict[str, Any], TextObject]] = None,
options: Sequence[Union[Dict[str, Any], Option]],
**others: Dict[str, Any],
):
"""
Create a group of Option objects - pass in a label (that will be part of the
UI) and a list of Option objects.
Blocks: