-
Notifications
You must be signed in to change notification settings - Fork 1
/
examples_test.go
3204 lines (2644 loc) · 87.3 KB
/
examples_test.go
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
// Code generated by `generate`. DO NOT EDIT.
package kittycad_test
import (
"bytes"
"fmt"
"log"
"net/url"
"os"
"os/signal"
"time"
"github.com/gorilla/websocket"
"github.com/kittycad/kittycad.go"
)
// Create a client with your token.
func ExampleNewClient() {
client, err := kittycad.NewClient("$TOKEN", "your apps user agent")
if err != nil {
panic(err)
}
// Call the client's methods.
result, err := client.Meta.Ping()
if err != nil {
panic(err)
}
fmt.Println(result)
}
// - OR -
// Create a new client with your token parsed from the environment
// variable: `ZOO_API_TOKEN`.
func ExampleNewClientFromEnv() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
// Call the client's methods.
result, err := client.Meta.Ping()
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// GetSchema: Get OpenAPI schema.
func ExampleMetaService_GetSchema() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Meta.GetSchema(); err != nil {
panic(err)
}
}
// Getdata: Get the metadata about our currently running server.
// This includes information on any of our other distributed systems it is connected to.
//
// You must be a Zoo employee to perform this request.
func ExampleMetaService_Getdata() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Meta.Getdata()
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// GetIpinfo: Get ip address information.
func ExampleMetaService_GetIpinfo() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Meta.GetIpinfo()
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateTextToCad: Generate a CAD model from text.
// Because our source of truth for the resulting model is a STEP file, you will always have STEP file contents when you list your generated models. Any other formats you request here will also be returned when you list your generated models.
//
// This operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.
//
// One thing to note, if you hit the cache, this endpoint will return right away. So you only have to wait if the status is not `Completed` or `Failed`.
//
// Parameters
//
// - `outputFormat`: The valid types of output file formats.
// - `kcl`
// - `body`: Body for generating models from text.
func ExampleMlService_CreateTextToCad() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Ml.CreateTextToCad("", true, kittycad.TextToCadCreateBody{Prompt: "some-string"})
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// GetMetrics: Get API call metrics.
// This endpoint requires authentication by a Zoo employee. The API calls are grouped by the parameter passed.
//
// Parameters
//
// - `groupBy`: The field of an API call to group by.
func ExampleAPICallService_GetMetrics() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.APICall.GetMetrics("")
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// List: List API calls.
// This endpoint requires authentication by a Zoo employee. The API calls are returned in order of creation, with the most recently created API calls first.
//
// Parameters
//
// - `limit`
//
// - `pageToken`
//
// - `sortBy`: Supported set of sort modes for scanning by created_at only.
//
// Currently, we only support scanning in ascending order.
func ExampleAPICallService_List() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.APICall.List(123, "some-string", "")
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// Get: Get details of an API call.
// This endpoint requires authentication by any Zoo user. It returns details of the requested API call for the user.
//
// If the user is not authenticated to view the specified API call, then it is not returned.
//
// Only Zoo employees can view API calls for other users.
//
// Parameters
//
// - `id`
func ExampleAPICallService_Get() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.APICall.Get(kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// GithubCallback: Listen for callbacks to GitHub app authentication.
// This is different than OAuth 2.0 authentication for users. This endpoint grants access for Zoo to access user's repos.
//
// The user doesn't need Zoo OAuth authorization for this endpoint, this is purely for the GitHub permissions to access repos.
//
// Parameters
//
// - `body`
func ExampleAppService_GithubCallback() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.App.GithubCallback(""); err != nil {
panic(err)
}
}
// GithubConsent: Get the consent URL for GitHub app authentication.
// This is different than OAuth 2.0 authentication for users. This endpoint grants access for Zoo to access user's repos.
//
// The user doesn't need Zoo OAuth authorization for this endpoint, this is purely for the GitHub permissions to access repos.
func ExampleAppService_GithubConsent() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.App.GithubConsent()
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// GithubWebhook: Listen for GitHub webhooks.
// These come from the GitHub app.
//
// Parameters
//
// - `body`
func ExampleAppService_GithubWebhook() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.App.GithubWebhook([]byte("some-binary")); err != nil {
panic(err)
}
}
// ListAsyncOperations: List async operations.
// For async file conversion operations, this endpoint does not return the contents of converted files (`output`). To get the contents use the `/async/operations/{id}` endpoint.
//
// This endpoint requires authentication by a Zoo employee.
//
// Parameters
//
// - `limit`
//
// - `pageToken`
//
// - `sortBy`: Supported set of sort modes for scanning by created_at only.
//
// Currently, we only support scanning in ascending order.
//
// - `status`: The status of an async API call.
func ExampleAPICallService_ListAsyncOperations() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.APICall.ListAsyncOperations(123, "some-string", "", "")
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// GetAsyncOperation: Get an async operation.
// Get the status and output of an async operation.
//
// This endpoint requires authentication by any Zoo user. It returns details of the requested async operation for the user.
//
// If the user is not authenticated to view the specified async operation, then it is not returned.
//
// Only Zoo employees with the proper access can view async operations for other users.
//
// Parameters
//
// - `id`
func ExampleAPICallService_GetAsyncOperation() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.APICall.GetAsyncOperation(kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// AuthEmail: Create an email verification request for a user.
// Parameters
//
// - `body`: The body of the form for email authentication.
func ExampleHiddenService_AuthEmail() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Hidden.AuthEmail(kittycad.EmailAuthenticationForm{CallbackUrl: kittycad.URL{&url.URL{Scheme: "https", Host: "example.com"}}, Email: "[email protected]"})
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// AuthEmailCallback: Listen for callbacks for email verification for users.
// Parameters
//
// - `callbackUrl`
// - `email`
// - `token`
func ExampleHiddenService_AuthEmailCallback() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Hidden.AuthEmailCallback(kittycad.URL{&url.URL{Scheme: "https", Host: "example.com"}}, "[email protected]", "some-string"); err != nil {
panic(err)
}
}
// GetAuthSaml: Get a redirect straight to the SAML IdP.
// The UI uses this to avoid having to ask the API anything about the IdP. It already knows the SAML IdP ID from the path, so it can just link to this path and rely on the API to redirect to the actual IdP.
//
// Parameters
//
// - `providerId`: A UUID usually v4 or v7
// - `callbackUrl`
func ExampleHiddenService_GetAuthSaml() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Hidden.GetAuthSaml(kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"), kittycad.URL{&url.URL{Scheme: "https", Host: "example.com"}}); err != nil {
panic(err)
}
}
// PostAuthSaml: Authenticate a user via SAML
// Parameters
//
// - `providerId`: A UUID usually v4 or v7
// - `body`
func ExampleHiddenService_PostAuthSaml() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Hidden.PostAuthSaml(kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"), []byte("some-binary")); err != nil {
panic(err)
}
}
// CommunitySso: Authorize an inbound auth request from our Community page.
// Parameters
//
// - `sig`
// - `sso`
func ExampleMetaService_CommunitySso() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Meta.CommunitySso("some-string", "some-string"); err != nil {
panic(err)
}
}
// CreateDebugUploads: Uploads files to public blob storage for debugging purposes.
// Do NOT send files here that you don't want to be public.
//
// Parameters
//
// - `body`
func ExampleMetaService_CreateDebugUploads() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
buf := new(bytes.Buffer)
result, err := client.Meta.CreateDebugUploads(buf)
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateEvent: Creates an internal telemetry event.
// We collect anonymous telemetry data for improving our product.
//
// Parameters
//
// - `body`: Telemetry data we are collecting
func ExampleMetaService_CreateEvent() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
buf := new(bytes.Buffer)
if err := client.Meta.CreateEvent(buf); err != nil {
panic(err)
}
}
// CreateCenterOfMass: Get CAD file center of mass.
// We assume any file given to us has one consistent unit throughout. We also assume the file is at the proper scale.
//
// This endpoint returns the cartesian coordinate in world space measure units.
//
// In the future, we will use the units inside the file if they are given and do any conversions if necessary for the calculation. But currently, that is not supported.
//
// Get the center of mass of an object in a CAD file. If the file is larger than 25MB, it will be performed asynchronously.
//
// If the operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.
//
// Parameters
//
// - `outputUnit`: The valid types of length units.
// - `srcFormat`: The valid types of source file formats.
// - `body`
func ExampleFileService_CreateCenterOfMass() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.File.CreateCenterOfMass("", "", []byte("some-binary"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateConversion: Convert CAD file with defaults.
// If you wish to specify the conversion options, use the `/file/conversion` endpoint instead.
//
// Convert a CAD file from one format to another. If the file being converted is larger than 25MB, it will be performed asynchronously.
//
// If the conversion is performed synchronously, the contents of the converted file (`output`) will be returned as a base64 encoded string.
//
// If the operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.
//
// Parameters
//
// - `outputFormat`: The valid types of output file formats.
// - `srcFormat`: The valid types of source file formats.
// - `body`
func ExampleFileService_CreateConversion() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.File.CreateConversion("", "", []byte("some-binary"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateDensity: Get CAD file density.
// We assume any file given to us has one consistent unit throughout. We also assume the file is at the proper scale.
//
// This endpoint assumes if you are giving a material mass in a specific mass units, we return a density in mass unit per cubic measure unit.
//
// In the future, we will use the units inside the file if they are given and do any conversions if necessary for the calculation. But currently, that is not supported.
//
// Get the density of an object in a CAD file. If the file is larger than 25MB, it will be performed asynchronously.
//
// If the operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.
//
// Parameters
//
// - `materialMass`
// - `materialMassUnit`: The valid types of mass units.
// - `outputUnit`: The valid types for density units.
// - `srcFormat`: The valid types of source file formats.
// - `body`
func ExampleFileService_CreateDensity() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.File.CreateDensity(123.45, "", "", "", []byte("some-binary"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateFileExecution: Execute a Zoo program in a specific language.
// Parameters
//
// - `lang`: The language code is written in.
//
// <details><summary>JSON schema</summary>
//
// ```json { "description": "The language code is written in.", "oneOf": [ { "description": "The `go` programming language.", "type": "string", "enum": [ "go" ] }, { "description": "The `python` programming language.", "type": "string", "enum": [ "python" ] }, { "description": "The `node` programming language.", "type": "string", "enum": [ "node" ] } ] } ``` </details>
//
// - `output`
//
// - `body`
func ExampleExecutorService_CreateFileExecution() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Executor.CreateFileExecution("", "some-string", []byte("some-binary"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateMass: Get CAD file mass.
// We assume any file given to us has one consistent unit throughout. We also assume the file is at the proper scale.
//
// This endpoint assumes if you are giving a material density in a specific mass unit per cubic measure unit, we return a mass in mass units. The same mass units as passed in the material density.
//
// In the future, we will use the units inside the file if they are given and do any conversions if necessary for the calculation. But currently, that is not supported.
//
// Get the mass of an object in a CAD file. If the file is larger than 25MB, it will be performed asynchronously.
//
// If the operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.
//
// Parameters
//
// - `materialDensity`
// - `materialDensityUnit`: The valid types for density units.
// - `outputUnit`: The valid types of mass units.
// - `srcFormat`: The valid types of source file formats.
// - `body`
func ExampleFileService_CreateMass() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.File.CreateMass(123.45, "", "", "", []byte("some-binary"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateSurfaceArea: Get CAD file surface area.
// We assume any file given to us has one consistent unit throughout. We also assume the file is at the proper scale.
//
// This endpoint returns the square measure units.
//
// In the future, we will use the units inside the file if they are given and do any conversions if necessary for the calculation. But currently, that is not supported.
//
// Get the surface area of an object in a CAD file. If the file is larger than 25MB, it will be performed asynchronously.
//
// If the operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.
//
// Parameters
//
// - `outputUnit`: The valid types of area units.
// - `srcFormat`: The valid types of source file formats.
// - `body`
func ExampleFileService_CreateSurfaceArea() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.File.CreateSurfaceArea("", "", []byte("some-binary"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateVolume: Get CAD file volume.
// We assume any file given to us has one consistent unit throughout. We also assume the file is at the proper scale.
//
// This endpoint returns the cubic measure units.
//
// In the future, we will use the units inside the file if they are given and do any conversions if necessary for the calculation. But currently, that is not supported.
//
// Get the volume of an object in a CAD file. If the file is larger than 25MB, it will be performed asynchronously.
//
// If the operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.
//
// Parameters
//
// - `outputUnit`: The valid types of volume units.
// - `srcFormat`: The valid types of source file formats.
// - `body`
func ExampleFileService_CreateVolume() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.File.CreateVolume("", "", []byte("some-binary"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// InternalGetAPITokenForDiscordUser: Get an API token for a user by their discord id.
// This endpoint allows us to run API calls from our discord bot on behalf of a user. The user must have a discord account linked to their Zoo Account via oauth2 for this to work.
//
// You must be a Zoo employee to use this endpoint.
//
// Parameters
//
// - `discordId`
func ExampleMetaService_InternalGetAPITokenForDiscordUser() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Meta.InternalGetAPITokenForDiscordUser("some-string")
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// Logout: This endpoint removes the session cookie for a user.
// This is used in logout scenarios.
func ExampleHiddenService_Logout() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Hidden.Logout(); err != nil {
panic(err)
}
}
// ListPrompts: List all ML prompts.
// For text-to-cad prompts, this will always return the STEP file contents as well as the format the user originally requested.
//
// This endpoint requires authentication by a Zoo employee.
//
// The ML prompts are returned in order of creation, with the most recently created ML prompts first.
//
// Parameters
//
// - `limit`
//
// - `pageToken`
//
// - `sortBy`: Supported set of sort modes for scanning by created_at only.
//
// Currently, we only support scanning in ascending order.
func ExampleMlService_ListPrompts() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Ml.ListPrompts(123, "some-string", "")
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// GetPrompt: Get a ML prompt.
// This endpoint requires authentication by a Zoo employee.
//
// Parameters
//
// - `id`
func ExampleMlService_GetPrompt() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Ml.GetPrompt(kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateKclCodeCompletions: Generate code completions for KCL.
// Parameters
//
// - `body`: A request to generate KCL code completions.
func ExampleMlService_CreateKclCodeCompletions() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Ml.CreateKclCodeCompletions(kittycad.KclCodeCompletionRequest{Extra: kittycad.KclCodeCompletionParams{Language: "some-string", NextIndent: 123, PromptTokens: 123, SuffixTokens: 123, TrimByIndentation: true}, MaxTokens: 123, N: 123, Nwo: "some-string", Prompt: "some-string", Stop: []string{"some-string"}, Stream: true, Suffix: "some-string", Temperature: 123.45, TopP: 123.45})
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateTextToCadIteration: Iterate on a CAD model with a prompt.
// Even if you give specific ranges to edit, the model might change more than just those in order to make the changes you requested without breaking the code.
//
// You always get the whole code back, even if you only changed a small part of it.
//
// This operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.
//
// Parameters
//
// - `body`: Body for generating models from text.
func ExampleMlService_CreateTextToCadIteration() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Ml.CreateTextToCadIteration(kittycad.TextToCadIterationBody{OriginalSourceCode: "some-string", Prompt: "some-string", SourceRanges: []kittycad.SourceRangePrompt{{Prompt: "some-string", Range: kittycad.SourceRange{End: kittycad.SourcePosition{Column: 123, Line: 123}, Start: kittycad.SourcePosition{Column: 123, Line: 123}}}}})
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// DeviceAuthRequest: Start an OAuth 2.0 Device Authorization Grant.
// This endpoint is designed to be accessed from an *unauthenticated* API client. It generates and records a `device_code` and `user_code` which must be verified and confirmed prior to a token being granted.
//
// Parameters
//
// - `body`: The request parameters for the OAuth 2.0 Device Authorization Grant flow.
func ExampleOauth2Service_DeviceAuthRequest() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Oauth2.DeviceAuthRequest(kittycad.DeviceAuthRequestForm{ClientID: kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8")}); err != nil {
panic(err)
}
}
// DeviceAuthConfirm: Confirm an OAuth 2.0 Device Authorization Grant.
// This endpoint is designed to be accessed by the user agent (browser), not the client requesting the token. So we do not actually return the token here; it will be returned in response to the poll on `/oauth2/device/token`.
//
// Parameters
//
// - `body`: The request parameters to verify the `user_code` for the OAuth 2.0 Device Authorization Grant.
func ExampleOauth2Service_DeviceAuthConfirm() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Oauth2.DeviceAuthConfirm(kittycad.DeviceAuthVerifyParams{UserCode: "some-string"}); err != nil {
panic(err)
}
}
// DeviceAccessToken: Request a device access token.
// This endpoint should be polled by the client until the user code is verified and the grant is confirmed.
//
// Parameters
//
// - `body`: The form for a device access token request.
func ExampleOauth2Service_DeviceAccessToken() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Oauth2.DeviceAccessToken(kittycad.DeviceAccessTokenRequestForm{ClientID: kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"), DeviceCode: kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"), GrantType: ""}); err != nil {
panic(err)
}
}
// DeviceAuthVerify: Verify an OAuth 2.0 Device Authorization Grant.
// This endpoint should be accessed in a full user agent (e.g., a browser). If the user is not logged in, we redirect them to the login page and use the `callback_url` parameter to get them to the UI verification form upon logging in. If they are logged in, we redirect them to the UI verification form on the website.
//
// Parameters
//
// - `userCode`
func ExampleOauth2Service_DeviceAuthVerify() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Oauth2.DeviceAuthVerify("some-string"); err != nil {
panic(err)
}
}
// ProviderCallback: Listen for callbacks for the OAuth 2.0 provider.
// Parameters
//
// - `provider`: An account provider.
// - `code`
// - `idToken`
// - `state`
// - `user`
func ExampleOauth2Service_ProviderCallback() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Oauth2.ProviderCallback("", "some-string", "some-string", "some-string", "some-string"); err != nil {
panic(err)
}
}
// ProviderCallbackCreate: Listen for callbacks for the OAuth 2.0 provider.
// This specific endpoint listens for posts of form data.
//
// Parameters
//
// - `provider`: An account provider.
// - `body`: The authentication callback from the OAuth 2.0 client. This is typically posted to the redirect URL as query params after authenticating.
func ExampleOauth2Service_ProviderCallbackCreate() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Oauth2.ProviderCallbackCreate("", kittycad.AuthCallback{Code: "some-string", IdToken: "some-string", State: "some-string", User: "some-string"}); err != nil {
panic(err)
}
}
// ProviderConsent: Get the consent URL and other information for the OAuth 2.0 provider.
// Parameters
//
// - `provider`: An account provider.
// - `callbackUrl`
func ExampleOauth2Service_ProviderConsent() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Oauth2.ProviderConsent("", "some-string")
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// TokenRevoke: Revoke an OAuth2 token.
// This endpoint is designed to be accessed from an *unauthenticated* API client.
//
// Parameters
//
// - `body`: The request parameters for the OAuth 2.0 token revocation flow.
func ExampleOauth2Service_TokenRevoke() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Oauth2.TokenRevoke(kittycad.TokenRevokeRequestForm{ClientID: kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"), ClientSecret: "some-string", Token: "some-string"}); err != nil {
panic(err)
}
}
// Get: Get an org.
// This endpoint requires authentication by an org admin. It gets the authenticated user's org.
func ExampleOrgService_Get() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Org.Get()
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// Create: Create an org.
// This endpoint requires authentication by a Zoo user that is not already in an org. It creates a new org for the authenticated user and makes them an admin.
//
// Parameters
//
// - `body`: The user-modifiable parts of an organization.
func ExampleOrgService_Create() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Org.Create(kittycad.OrgDetails{AllowUsersInDomainToAutoJoin: true, BillingEmail: "[email protected]", Domain: "some-string", Image: kittycad.URL{&url.URL{Scheme: "https", Host: "example.com"}}, Name: "some-string", Phone: "+1-555-555-555"})
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// Update: Update an org.
// This endpoint requires authentication by an org admin. It updates the authenticated user's org.
//
// Parameters
//
// - `body`: The user-modifiable parts of an organization.
func ExampleOrgService_Update() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Org.Update(kittycad.OrgDetails{AllowUsersInDomainToAutoJoin: true, BillingEmail: "[email protected]", Domain: "some-string", Image: kittycad.URL{&url.URL{Scheme: "https", Host: "example.com"}}, Name: "some-string", Phone: "+1-555-555-555"})
if err != nil {
panic(err)
}