-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexamples_test.go
More file actions
4979 lines (4092 loc) · 142 KB
/
Copy pathexamples_test.go
File metadata and controls
4979 lines (4092 loc) · 142 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
// Code generated by `generate`. DO NOT EDIT.
package kittycad_test
import (
"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)
}
}
// 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.
// Prefer the ML copilot websocket (`/ws/ml/copilot`) for new integrations. This REST endpoint is kept for existing Text-to-CAD clients, but it is no longer the recommended way to generate CAD models from a prompt.
//
// 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 parts. Any other formats you request here will also be returned when you list your generated parts.
//
// 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 parts 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{KclVersion: "some-string", ModelVersion: "some-string", ProjectName: "some-string", Prompt: "some-string"})
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// GetAnnouncements: List all active announcements.
// No authentication is required.
func ExampleMetaService_GetAnnouncements() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Meta.GetAnnouncements()
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)
}
}
// 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)
}
// AuthAPIKey: Authenticate using an api-key. This is disabled on production but can be used in dev to login without email magic.
// This returns a session token.
func ExampleHiddenService_AuthAPIKey() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Hidden.AuthAPIKey()
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: "example@example.com"})
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// AuthEmailMarketingConfirmCreate: Consume a confirmation token and finalize double opt-in.
// Parameters
//
// - `body`: Request payload for confirming a double-opt-in token.
func ExampleHiddenService_AuthEmailMarketingConfirmCreate() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Hidden.AuthEmailMarketingConfirmCreate(kittycad.EmailMarketingConfirmTokenBody{Token: "some-string"}); err != nil {
panic(err)
}
}
// AuthEmailCallback: Listen for callbacks for email authentication for users.
// Parameters
//
// - `callbackUrl`
// - `token`
// - `email`
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"}}, "some-string", "example@example.com"); err != nil {
panic(err)
}
}
// GetAuthSamlByOrg: GET /auth/saml/{org_id}
// Redirects the browser straight to the org’s SAML IdP.
//
// Parameters
//
// - `orgId`: A UUID usually v4 or v7
// - `callbackUrl`
func ExampleHiddenService_GetAuthSamlByOrg() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Hidden.GetAuthSamlByOrg(kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"), kittycad.URL{&url.URL{Scheme: "https", Host: "example.com"}}); 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
//
// - `sso`
// - `sig`
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)
}
}
// 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
//
// - `srcFormat`: The valid types of source file formats.
// - `outputUnit`: The valid types of length units.
// - `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)
}
// CreateConversionOptions: Convert CAD file from one format to another.
// This takes a HTTP multipart body with these fields in any order:
//
// - The input and output format options (as JSON), name is 'body'. - The files to convert, in raw binary. Must supply filenames.
//
// This starts a conversion job and returns the `id` of the operation. 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`: Describes the file to convert (src) and what it should be converted into (output).
func ExampleFileService_CreateConversionOptions() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
form := kittycad.NewMultipartForm()
result, err := client.File.CreateConversionOptions(form)
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
//
// - `srcFormat`: The valid types of source file formats.
// - `outputFormat`: The valid types of output 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
//
// - `srcFormat`: The valid types of source file formats.
// - `materialMass`
// - `materialMassUnit`: The valid types of mass units.
// - `outputUnit`: The valid types for density units.
// - `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
//
// - `srcFormat`: The valid types of source file formats.
// - `materialDensity`
// - `materialDensityUnit`: The valid types for density units.
// - `outputUnit`: The valid types of mass units.
// - `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
//
// - `srcFormat`: The valid types of source file formats.
// - `outputUnit`: The valid types of area units.
// - `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
//
// - `srcFormat`: The valid types of source file formats.
// - `outputUnit`: The valid types of volume units.
// - `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 admin 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)
}
}
// ListConversationsForUser: List conversations
// This endpoint requires authentication by any Zoo user. It returns the conversations for the authenticated user.
//
// The conversations are returned in order of creation, with the most recently created conversations 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_ListConversationsForUser() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Ml.ListConversationsForUser(123, "some-string", "")
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateProprietaryToKcl: Converts a proprietary CAD format to KCL.
// This endpoint is used to convert a proprietary CAD format to KCL. The file passed MUST have feature tree data.
//
// A STEP file does not have feature tree data, so it will not work. A sldprt file does have feature tree data, so it will work.
//
// This endpoint is designed to work with any native proprietary CAD format, for example: - SolidWorks (.sldprt) - Creo (.prt) - Catia (.catpart) - NX (.prt) - Fusion 360 (.f3d)
//
// This endpoint is deterministic, it preserves the original design intent by using the feature tree data. This endpoint does not use any machine learning or AI.
//
// This endpoint is currently in beta, and is only available to users with access to the feature. Please contact support if you are interested in getting access.
//
// This endpoint might have limitations and bugs, please report any issues you encounter. It will be improved over time.
//
// Input filepaths will be normalized and re-canonicalized to be under the current working directory -- so returned paths may differ from provided paths, and care must be taken when handling user provided paths.
//
// Parameters
//
// - `codeOption`: `CodeOption`
//
// <details><summary>JSON schema</summary>
//
// ```json { "type": "string", "enum": [ "parse", "mock_execute", "execute" ] } ``` </details>
//
// - `body`
func ExampleMlService_CreateProprietaryToKcl() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
form := kittycad.NewMultipartForm()
result, err := client.Ml.CreateProprietaryToKcl(kittycad.CodeOptionParse, form)
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateCustomModel: Create a custom ML model that is backed by one or more org datasets.
// Dataset readiness is enforced via `OrgDatasetFileConversion::status_counts_for_datasets`: - At least one conversion must have status `success`. - No conversions may remain in `queued`. If even a single file is still queued the dataset is treated as “not ready for training.” - A dataset consisting only of `canceled` or `error_*` entries is rejected because there’s nothing usable.
//
// Parameters
//
// - `body`: Body for creating a custom ML model.
func ExampleMlService_CreateCustomModel() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Ml.CreateCustomModel(kittycad.CreateCustomModel{DatasetIds: []kittycad.UUID{}, Name: "some-string", SystemPrompt: "some-string"})
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// GetCustomModel: Retrieve the details of a single custom ML model so long as it belongs to the caller’s organization.
// Parameters
//
// - `id`: A UUID usually v4 or v7
func ExampleMlService_GetCustomModel() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Ml.GetCustomModel(kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// UpdateCustomModel: Update mutable metadata (name, system prompt) for a custom ML model owned by the caller's organization.
// Parameters
//
// - `id`: A UUID usually v4 or v7
// - `body`: Body for updating a custom ML model.
func ExampleMlService_UpdateCustomModel() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Ml.UpdateCustomModel(kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"), kittycad.UpdateCustomModel{Name: "some-string", SystemPrompt: "some-string"})
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// ListOrgDatasetsForModel: List the org datasets that are currently attached to a custom ML model owned by the caller’s organization.
// Parameters
//
// - `id`: A UUID usually v4 or v7
func ExampleMlService_ListOrgDatasetsForModel() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Ml.ListOrgDatasetsForModel(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, ModelVersion: "some-string", N: 123, Nwo: "some-string", Prompt: "some-string", Stop: []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.
// Prefer the ML copilot websocket (`/ws/ml/copilot`) for new prompt-to-edit integrations. This REST endpoint is kept for existing clients, but it is no longer the recommended way to edit KCL or CAD models from 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.
//
// This endpoint is deprecated in favor of `/ws/ml/copilot`.
//
// Parameters
//
// - `body`: Body for generating parts 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{KclVersion: "some-string", OriginalSourceCode: "some-string", ProjectName: "some-string", Prompt: "some-string", SourceRanges: []kittycad.SourceRangePrompt{}})
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// CreateTextToCadMultiFileIteration: Iterate on a multi-file CAD model with a prompt.
// Prefer the ML copilot websocket (`/ws/ml/copilot`) for new prompt-to-edit integrations. This REST endpoint is kept for existing multi-file iteration clients, but it is no longer the recommended way to edit KCL or CAD models from a prompt.
//
// This endpoint can iterate on multi-file projects.
//
// 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 endpoint will always return all the code back, including files that were not changed. If your original source code imported a stl/gltf/step/etc file, the output will not include that file since the model will never change non-kcl files. The endpoint will only return the kcl files that were changed.
//
// 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.
//
// Input filepaths will be normalized and re-canonicalized to be under the current working directory -- so returned paths may differ from provided paths, and care must be taken when handling user provided paths.
//
// Parameters
//
// - `body`: Body for iterating on models from text prompts.
func ExampleMlService_CreateTextToCadMultiFileIteration() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
form := kittycad.NewMultipartForm()
result, err := client.Ml.CreateTextToCadMultiFileIteration(form)
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// GetAuthorizationRequest: Get a pending OAuth 2.0 authorization request for the consent page.
// Parameters
//
// - `requestId`: A UUID usually v4 or v7
func ExampleOauth2Service_GetAuthorizationRequest() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Oauth2.GetAuthorizationRequest(kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// ApproveAuthorizationRequest: Approve a pending OAuth 2.0 authorization request.
// Parameters
//
// - `requestId`: A UUID usually v4 or v7
func ExampleOauth2Service_ApproveAuthorizationRequest() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Oauth2.ApproveAuthorizationRequest(kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// DenyAuthorizationRequest: Deny a pending OAuth 2.0 authorization request.
// Parameters
//
// - `requestId`: A UUID usually v4 or v7
func ExampleOauth2Service_DenyAuthorizationRequest() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
result, err := client.Oauth2.DenyAuthorizationRequest(kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
if err != nil {
panic(err)
}
fmt.Printf("%#v", result)
}
// Authorize: Start an OAuth 2.0 authorization code flow with PKCE.
// Parameters
//
// - `responseType`: The OAuth 2.0 authorization response type.
// - `clientId`
// - `redirectUri`
// - `state`
// - `scope`: OAuth 2.0 scopes encoded as a space-delimited string.
// - `codeChallenge`
// - `codeChallengeMethod`: The PKCE code challenge method.
func ExampleOauth2Service_Authorize() {
client, err := kittycad.NewClientFromEnv("your apps user agent")
if err != nil {
panic(err)
}
if err := client.Oauth2.Authorize("", kittycad.ParseUUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"), kittycad.URL{&url.URL{Scheme: "https", Host: "example.com"}}, "some-string", "some-string", "some-string", ""); err != nil {
panic(err)
}
}
// 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 confirm 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.DeviceAuthConfirmParams{UserCode: "some-string"}); err != nil {
panic(err)
}
}