forked from databricks/databricks-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
executable file
·1399 lines (1304 loc) · 56.5 KB
/
api.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 from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
// These APIs allow you to manage Credentials, Encryption Keys, Networks, Private Access, Storage, Vpc Endpoints, Workspaces, etc.
package provisioning
import (
"context"
"fmt"
"time"
"github.com/xuxiaoshuo/databricks-sdk-go/client"
"github.com/xuxiaoshuo/databricks-sdk-go/retries"
"github.com/xuxiaoshuo/databricks-sdk-go/useragent"
)
func NewCredentials(client *client.DatabricksClient) *CredentialsAPI {
return &CredentialsAPI{
impl: &credentialsImpl{
client: client,
},
}
}
// These APIs manage credential configurations for this workspace. Databricks
// needs access to a cross-account service IAM role in your AWS account so that
// Databricks can deploy clusters in the appropriate VPC for the new workspace.
// A credential configuration encapsulates this role information, and its ID is
// used when creating a new workspace.
type CredentialsAPI struct {
// impl contains low-level REST API interface, that could be overridden
// through WithImpl(CredentialsService)
impl CredentialsService
}
// WithImpl could be used to override low-level API implementations for unit
// testing purposes with [github.com/golang/mock] or other mocking frameworks.
func (a *CredentialsAPI) WithImpl(impl CredentialsService) *CredentialsAPI {
a.impl = impl
return a
}
// Impl returns low-level Credentials API implementation
func (a *CredentialsAPI) Impl() CredentialsService {
return a.impl
}
// Create credential configuration.
//
// Creates a Databricks credential configuration that represents cloud
// cross-account credentials for a specified account. Databricks uses this to
// set up network infrastructure properly to host Databricks clusters. For your
// AWS IAM role, you need to trust the External ID (the Databricks Account API
// account ID) in the returned credential object, and configure the required
// access policy.
//
// Save the response's `credentials_id` field, which is the ID for your new
// credential configuration object.
//
// For information about how to create a new workspace with this API, see
// [Create a new workspace using the Account API]
//
// [Create a new workspace using the Account API]: http://docs.databricks.com/administration-guide/account-api/new-workspace.html
func (a *CredentialsAPI) Create(ctx context.Context, request CreateCredentialRequest) (*Credential, error) {
return a.impl.Create(ctx, request)
}
// Delete credential configuration.
//
// Deletes a Databricks credential configuration object for an account, both
// specified by ID. You cannot delete a credential that is associated with any
// workspace.
func (a *CredentialsAPI) Delete(ctx context.Context, request DeleteCredentialRequest) error {
return a.impl.Delete(ctx, request)
}
// Delete credential configuration.
//
// Deletes a Databricks credential configuration object for an account, both
// specified by ID. You cannot delete a credential that is associated with any
// workspace.
func (a *CredentialsAPI) DeleteByCredentialsId(ctx context.Context, credentialsId string) error {
return a.impl.Delete(ctx, DeleteCredentialRequest{
CredentialsId: credentialsId,
})
}
// Get credential configuration.
//
// Gets a Databricks credential configuration object for an account, both
// specified by ID.
func (a *CredentialsAPI) Get(ctx context.Context, request GetCredentialRequest) (*Credential, error) {
return a.impl.Get(ctx, request)
}
// Get credential configuration.
//
// Gets a Databricks credential configuration object for an account, both
// specified by ID.
func (a *CredentialsAPI) GetByCredentialsId(ctx context.Context, credentialsId string) (*Credential, error) {
return a.impl.Get(ctx, GetCredentialRequest{
CredentialsId: credentialsId,
})
}
// Get all credential configurations.
//
// Gets all Databricks credential configurations associated with an account
// specified by ID.
func (a *CredentialsAPI) List(ctx context.Context) ([]Credential, error) {
return a.impl.List(ctx)
}
// CredentialCredentialsNameToCredentialsIdMap calls [CredentialsAPI.List] and creates a map of results with [Credential].CredentialsName as key and [Credential].CredentialsId as value.
//
// Returns an error if there's more than one [Credential] with the same .CredentialsName.
//
// Note: All [Credential] instances are loaded into memory before creating a map.
//
// This method is generated by Databricks SDK Code Generator.
func (a *CredentialsAPI) CredentialCredentialsNameToCredentialsIdMap(ctx context.Context) (map[string]string, error) {
ctx = useragent.InContext(ctx, "sdk-feature", "name-to-id")
mapping := map[string]string{}
result, err := a.List(ctx)
if err != nil {
return nil, err
}
for _, v := range result {
key := v.CredentialsName
_, duplicate := mapping[key]
if duplicate {
return nil, fmt.Errorf("duplicate .CredentialsName: %s", key)
}
mapping[key] = v.CredentialsId
}
return mapping, nil
}
// GetByCredentialsName calls [CredentialsAPI.CredentialCredentialsNameToCredentialsIdMap] and returns a single [Credential].
//
// Returns an error if there's more than one [Credential] with the same .CredentialsName.
//
// Note: All [Credential] instances are loaded into memory before returning matching by name.
//
// This method is generated by Databricks SDK Code Generator.
func (a *CredentialsAPI) GetByCredentialsName(ctx context.Context, name string) (*Credential, error) {
ctx = useragent.InContext(ctx, "sdk-feature", "get-by-name")
result, err := a.List(ctx)
if err != nil {
return nil, err
}
tmp := map[string][]Credential{}
for _, v := range result {
key := v.CredentialsName
tmp[key] = append(tmp[key], v)
}
alternatives, ok := tmp[name]
if !ok || len(alternatives) == 0 {
return nil, fmt.Errorf("Credential named '%s' does not exist", name)
}
if len(alternatives) > 1 {
return nil, fmt.Errorf("there are %d instances of Credential named '%s'", len(alternatives), name)
}
return &alternatives[0], nil
}
func NewEncryptionKeys(client *client.DatabricksClient) *EncryptionKeysAPI {
return &EncryptionKeysAPI{
impl: &encryptionKeysImpl{
client: client,
},
}
}
// These APIs manage encryption key configurations for this workspace
// (optional). A key configuration encapsulates the AWS KMS key information and
// some information about how the key configuration can be used. There are two
// possible uses for key configurations:
//
// * Managed services: A key configuration can be used to encrypt a workspace's
// notebook and secret data in the control plane, as well as Databricks SQL
// queries and query history. * Storage: A key configuration can be used to
// encrypt a workspace's DBFS and EBS data in the data plane.
//
// In both of these cases, the key configuration's ID is used when creating a
// new workspace. This Preview feature is available if your account is on the E2
// version of the platform. Updating a running workspace with workspace storage
// encryption requires that the workspace is on the E2 version of the platform.
// If you have an older workspace, it might not be on the E2 version of the
// platform. If you are not sure, contact your Databricks representative.
type EncryptionKeysAPI struct {
// impl contains low-level REST API interface, that could be overridden
// through WithImpl(EncryptionKeysService)
impl EncryptionKeysService
}
// WithImpl could be used to override low-level API implementations for unit
// testing purposes with [github.com/golang/mock] or other mocking frameworks.
func (a *EncryptionKeysAPI) WithImpl(impl EncryptionKeysService) *EncryptionKeysAPI {
a.impl = impl
return a
}
// Impl returns low-level EncryptionKeys API implementation
func (a *EncryptionKeysAPI) Impl() EncryptionKeysService {
return a.impl
}
// Create encryption key configuration.
//
// Creates a customer-managed key configuration object for an account, specified
// by ID. This operation uploads a reference to a customer-managed key to
// Databricks. If the key is assigned as a workspace's customer-managed key for
// managed services, Databricks uses the key to encrypt the workspaces notebooks
// and secrets in the control plane, in addition to Databricks SQL queries and
// query history. If it is specified as a workspace's customer-managed key for
// workspace storage, the key encrypts the workspace's root S3 bucket (which
// contains the workspace's root DBFS and system data) and, optionally, cluster
// EBS volume data.
//
// **Important**: Customer-managed keys are supported only for some deployment
// types, subscription types, and AWS regions that currently support creation of
// Databricks workspaces.
//
// This operation is available only if your account is on the E2 version of the
// platform or on a select custom plan that allows multiple workspaces per
// account.
func (a *EncryptionKeysAPI) Create(ctx context.Context, request CreateCustomerManagedKeyRequest) (*CustomerManagedKey, error) {
return a.impl.Create(ctx, request)
}
// Delete encryption key configuration.
//
// Deletes a customer-managed key configuration object for an account. You
// cannot delete a configuration that is associated with a running workspace.
func (a *EncryptionKeysAPI) Delete(ctx context.Context, request DeleteEncryptionKeyRequest) error {
return a.impl.Delete(ctx, request)
}
// Delete encryption key configuration.
//
// Deletes a customer-managed key configuration object for an account. You
// cannot delete a configuration that is associated with a running workspace.
func (a *EncryptionKeysAPI) DeleteByCustomerManagedKeyId(ctx context.Context, customerManagedKeyId string) error {
return a.impl.Delete(ctx, DeleteEncryptionKeyRequest{
CustomerManagedKeyId: customerManagedKeyId,
})
}
// Get encryption key configuration.
//
// Gets a customer-managed key configuration object for an account, specified by
// ID. This operation uploads a reference to a customer-managed key to
// Databricks. If assigned as a workspace's customer-managed key for managed
// services, Databricks uses the key to encrypt the workspaces notebooks and
// secrets in the control plane, in addition to Databricks SQL queries and query
// history. If it is specified as a workspace's customer-managed key for
// storage, the key encrypts the workspace's root S3 bucket (which contains the
// workspace's root DBFS and system data) and, optionally, cluster EBS volume
// data.
//
// **Important**: Customer-managed keys are supported only for some deployment
// types, subscription types, and AWS regions.
//
// This operation is available only if your account is on the E2 version of the
// platform.",
func (a *EncryptionKeysAPI) Get(ctx context.Context, request GetEncryptionKeyRequest) (*CustomerManagedKey, error) {
return a.impl.Get(ctx, request)
}
// Get encryption key configuration.
//
// Gets a customer-managed key configuration object for an account, specified by
// ID. This operation uploads a reference to a customer-managed key to
// Databricks. If assigned as a workspace's customer-managed key for managed
// services, Databricks uses the key to encrypt the workspaces notebooks and
// secrets in the control plane, in addition to Databricks SQL queries and query
// history. If it is specified as a workspace's customer-managed key for
// storage, the key encrypts the workspace's root S3 bucket (which contains the
// workspace's root DBFS and system data) and, optionally, cluster EBS volume
// data.
//
// **Important**: Customer-managed keys are supported only for some deployment
// types, subscription types, and AWS regions.
//
// This operation is available only if your account is on the E2 version of the
// platform.",
func (a *EncryptionKeysAPI) GetByCustomerManagedKeyId(ctx context.Context, customerManagedKeyId string) (*CustomerManagedKey, error) {
return a.impl.Get(ctx, GetEncryptionKeyRequest{
CustomerManagedKeyId: customerManagedKeyId,
})
}
// Get all encryption key configurations.
//
// Gets all customer-managed key configuration objects for an account. If the
// key is specified as a workspace's managed services customer-managed key,
// Databricks uses the key to encrypt the workspace's notebooks and secrets in
// the control plane, in addition to Databricks SQL queries and query history.
// If the key is specified as a workspace's storage customer-managed key, the
// key is used to encrypt the workspace's root S3 bucket and optionally can
// encrypt cluster EBS volumes data in the data plane.
//
// **Important**: Customer-managed keys are supported only for some deployment
// types, subscription types, and AWS regions.
//
// This operation is available only if your account is on the E2 version of the
// platform.
func (a *EncryptionKeysAPI) List(ctx context.Context) ([]CustomerManagedKey, error) {
return a.impl.List(ctx)
}
func NewNetworks(client *client.DatabricksClient) *NetworksAPI {
return &NetworksAPI{
impl: &networksImpl{
client: client,
},
}
}
// These APIs manage network configurations for customer-managed VPCs
// (optional). Its ID is used when creating a new workspace if you use
// customer-managed VPCs.
type NetworksAPI struct {
// impl contains low-level REST API interface, that could be overridden
// through WithImpl(NetworksService)
impl NetworksService
}
// WithImpl could be used to override low-level API implementations for unit
// testing purposes with [github.com/golang/mock] or other mocking frameworks.
func (a *NetworksAPI) WithImpl(impl NetworksService) *NetworksAPI {
a.impl = impl
return a
}
// Impl returns low-level Networks API implementation
func (a *NetworksAPI) Impl() NetworksService {
return a.impl
}
// Create network configuration.
//
// Creates a Databricks network configuration that represents an VPC and its
// resources. The VPC will be used for new Databricks clusters. This requires a
// pre-existing VPC and subnets.
func (a *NetworksAPI) Create(ctx context.Context, request CreateNetworkRequest) (*Network, error) {
return a.impl.Create(ctx, request)
}
// Delete a network configuration.
//
// Deletes a Databricks network configuration, which represents a cloud VPC and
// its resources. You cannot delete a network that is associated with a
// workspace.
//
// This operation is available only if your account is on the E2 version of the
// platform.
func (a *NetworksAPI) Delete(ctx context.Context, request DeleteNetworkRequest) error {
return a.impl.Delete(ctx, request)
}
// Delete a network configuration.
//
// Deletes a Databricks network configuration, which represents a cloud VPC and
// its resources. You cannot delete a network that is associated with a
// workspace.
//
// This operation is available only if your account is on the E2 version of the
// platform.
func (a *NetworksAPI) DeleteByNetworkId(ctx context.Context, networkId string) error {
return a.impl.Delete(ctx, DeleteNetworkRequest{
NetworkId: networkId,
})
}
// Get a network configuration.
//
// Gets a Databricks network configuration, which represents a cloud VPC and its
// resources.
func (a *NetworksAPI) Get(ctx context.Context, request GetNetworkRequest) (*Network, error) {
return a.impl.Get(ctx, request)
}
// Get a network configuration.
//
// Gets a Databricks network configuration, which represents a cloud VPC and its
// resources.
func (a *NetworksAPI) GetByNetworkId(ctx context.Context, networkId string) (*Network, error) {
return a.impl.Get(ctx, GetNetworkRequest{
NetworkId: networkId,
})
}
// Get all network configurations.
//
// Gets a list of all Databricks network configurations for an account,
// specified by ID.
//
// This operation is available only if your account is on the E2 version of the
// platform.
func (a *NetworksAPI) List(ctx context.Context) ([]Network, error) {
return a.impl.List(ctx)
}
// NetworkNetworkNameToNetworkIdMap calls [NetworksAPI.List] and creates a map of results with [Network].NetworkName as key and [Network].NetworkId as value.
//
// Returns an error if there's more than one [Network] with the same .NetworkName.
//
// Note: All [Network] instances are loaded into memory before creating a map.
//
// This method is generated by Databricks SDK Code Generator.
func (a *NetworksAPI) NetworkNetworkNameToNetworkIdMap(ctx context.Context) (map[string]string, error) {
ctx = useragent.InContext(ctx, "sdk-feature", "name-to-id")
mapping := map[string]string{}
result, err := a.List(ctx)
if err != nil {
return nil, err
}
for _, v := range result {
key := v.NetworkName
_, duplicate := mapping[key]
if duplicate {
return nil, fmt.Errorf("duplicate .NetworkName: %s", key)
}
mapping[key] = v.NetworkId
}
return mapping, nil
}
// GetByNetworkName calls [NetworksAPI.NetworkNetworkNameToNetworkIdMap] and returns a single [Network].
//
// Returns an error if there's more than one [Network] with the same .NetworkName.
//
// Note: All [Network] instances are loaded into memory before returning matching by name.
//
// This method is generated by Databricks SDK Code Generator.
func (a *NetworksAPI) GetByNetworkName(ctx context.Context, name string) (*Network, error) {
ctx = useragent.InContext(ctx, "sdk-feature", "get-by-name")
result, err := a.List(ctx)
if err != nil {
return nil, err
}
tmp := map[string][]Network{}
for _, v := range result {
key := v.NetworkName
tmp[key] = append(tmp[key], v)
}
alternatives, ok := tmp[name]
if !ok || len(alternatives) == 0 {
return nil, fmt.Errorf("Network named '%s' does not exist", name)
}
if len(alternatives) > 1 {
return nil, fmt.Errorf("there are %d instances of Network named '%s'", len(alternatives), name)
}
return &alternatives[0], nil
}
func NewPrivateAccess(client *client.DatabricksClient) *PrivateAccessAPI {
return &PrivateAccessAPI{
impl: &privateAccessImpl{
client: client,
},
}
}
// These APIs manage private access settings for this account.
type PrivateAccessAPI struct {
// impl contains low-level REST API interface, that could be overridden
// through WithImpl(PrivateAccessService)
impl PrivateAccessService
}
// WithImpl could be used to override low-level API implementations for unit
// testing purposes with [github.com/golang/mock] or other mocking frameworks.
func (a *PrivateAccessAPI) WithImpl(impl PrivateAccessService) *PrivateAccessAPI {
a.impl = impl
return a
}
// Impl returns low-level PrivateAccess API implementation
func (a *PrivateAccessAPI) Impl() PrivateAccessService {
return a.impl
}
// Create private access settings.
//
// Creates a private access settings object, which specifies how your workspace
// is accessed over [AWS PrivateLink]. To use AWS PrivateLink, a workspace must
// have a private access settings object referenced by ID in the workspace's
// `private_access_settings_id` property.
//
// You can share one private access settings with multiple workspaces in a
// single account. However, private access settings are specific to AWS regions,
// so only workspaces in the same AWS region can use a given private access
// settings object.
//
// Before configuring PrivateLink, read the [Databricks article about
// PrivateLink].
//
// [AWS PrivateLink]: https://aws.amazon.com/privatelink
// [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html
func (a *PrivateAccessAPI) Create(ctx context.Context, request UpsertPrivateAccessSettingsRequest) (*PrivateAccessSettings, error) {
return a.impl.Create(ctx, request)
}
// Delete a private access settings object.
//
// Deletes a private access settings object, which determines how your workspace
// is accessed over [AWS PrivateLink].
//
// Before configuring PrivateLink, read the [Databricks article about
// PrivateLink].
//
// [AWS PrivateLink]: https://aws.amazon.com/privatelink
// [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html
func (a *PrivateAccessAPI) Delete(ctx context.Context, request DeletePrivateAccesRequest) error {
return a.impl.Delete(ctx, request)
}
// Delete a private access settings object.
//
// Deletes a private access settings object, which determines how your workspace
// is accessed over [AWS PrivateLink].
//
// Before configuring PrivateLink, read the [Databricks article about
// PrivateLink].
//
// [AWS PrivateLink]: https://aws.amazon.com/privatelink
// [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html
func (a *PrivateAccessAPI) DeleteByPrivateAccessSettingsId(ctx context.Context, privateAccessSettingsId string) error {
return a.impl.Delete(ctx, DeletePrivateAccesRequest{
PrivateAccessSettingsId: privateAccessSettingsId,
})
}
// Get a private access settings object.
//
// Gets a private access settings object, which specifies how your workspace is
// accessed over [AWS PrivateLink].
//
// Before configuring PrivateLink, read the [Databricks article about
// PrivateLink].
//
// [AWS PrivateLink]: https://aws.amazon.com/privatelink
// [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html
func (a *PrivateAccessAPI) Get(ctx context.Context, request GetPrivateAccesRequest) (*PrivateAccessSettings, error) {
return a.impl.Get(ctx, request)
}
// Get a private access settings object.
//
// Gets a private access settings object, which specifies how your workspace is
// accessed over [AWS PrivateLink].
//
// Before configuring PrivateLink, read the [Databricks article about
// PrivateLink].
//
// [AWS PrivateLink]: https://aws.amazon.com/privatelink
// [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html
func (a *PrivateAccessAPI) GetByPrivateAccessSettingsId(ctx context.Context, privateAccessSettingsId string) (*PrivateAccessSettings, error) {
return a.impl.Get(ctx, GetPrivateAccesRequest{
PrivateAccessSettingsId: privateAccessSettingsId,
})
}
// Get all private access settings objects.
//
// Gets a list of all private access settings objects for an account, specified
// by ID.
func (a *PrivateAccessAPI) List(ctx context.Context) ([]PrivateAccessSettings, error) {
return a.impl.List(ctx)
}
// PrivateAccessSettingsPrivateAccessSettingsNameToPrivateAccessSettingsIdMap calls [PrivateAccessAPI.List] and creates a map of results with [PrivateAccessSettings].PrivateAccessSettingsName as key and [PrivateAccessSettings].PrivateAccessSettingsId as value.
//
// Returns an error if there's more than one [PrivateAccessSettings] with the same .PrivateAccessSettingsName.
//
// Note: All [PrivateAccessSettings] instances are loaded into memory before creating a map.
//
// This method is generated by Databricks SDK Code Generator.
func (a *PrivateAccessAPI) PrivateAccessSettingsPrivateAccessSettingsNameToPrivateAccessSettingsIdMap(ctx context.Context) (map[string]string, error) {
ctx = useragent.InContext(ctx, "sdk-feature", "name-to-id")
mapping := map[string]string{}
result, err := a.List(ctx)
if err != nil {
return nil, err
}
for _, v := range result {
key := v.PrivateAccessSettingsName
_, duplicate := mapping[key]
if duplicate {
return nil, fmt.Errorf("duplicate .PrivateAccessSettingsName: %s", key)
}
mapping[key] = v.PrivateAccessSettingsId
}
return mapping, nil
}
// GetByPrivateAccessSettingsName calls [PrivateAccessAPI.PrivateAccessSettingsPrivateAccessSettingsNameToPrivateAccessSettingsIdMap] and returns a single [PrivateAccessSettings].
//
// Returns an error if there's more than one [PrivateAccessSettings] with the same .PrivateAccessSettingsName.
//
// Note: All [PrivateAccessSettings] instances are loaded into memory before returning matching by name.
//
// This method is generated by Databricks SDK Code Generator.
func (a *PrivateAccessAPI) GetByPrivateAccessSettingsName(ctx context.Context, name string) (*PrivateAccessSettings, error) {
ctx = useragent.InContext(ctx, "sdk-feature", "get-by-name")
result, err := a.List(ctx)
if err != nil {
return nil, err
}
tmp := map[string][]PrivateAccessSettings{}
for _, v := range result {
key := v.PrivateAccessSettingsName
tmp[key] = append(tmp[key], v)
}
alternatives, ok := tmp[name]
if !ok || len(alternatives) == 0 {
return nil, fmt.Errorf("PrivateAccessSettings named '%s' does not exist", name)
}
if len(alternatives) > 1 {
return nil, fmt.Errorf("there are %d instances of PrivateAccessSettings named '%s'", len(alternatives), name)
}
return &alternatives[0], nil
}
// Replace private access settings.
//
// Updates an existing private access settings object, which specifies how your
// workspace is accessed over [AWS PrivateLink]. To use AWS PrivateLink, a
// workspace must have a private access settings object referenced by ID in the
// workspace's `private_access_settings_id` property.
//
// This operation completely overwrites your existing private access settings
// object attached to your workspaces. All workspaces attached to the private
// access settings are affected by any change. If `public_access_enabled`,
// `private_access_level`, or `allowed_vpc_endpoint_ids` are updated, effects of
// these changes might take several minutes to propagate to the workspace API.
//
// You can share one private access settings object with multiple workspaces in
// a single account. However, private access settings are specific to AWS
// regions, so only workspaces in the same AWS region can use a given private
// access settings object.
//
// Before configuring PrivateLink, read the [Databricks article about
// PrivateLink].
//
// [AWS PrivateLink]: https://aws.amazon.com/privatelink
// [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html
func (a *PrivateAccessAPI) Replace(ctx context.Context, request UpsertPrivateAccessSettingsRequest) error {
return a.impl.Replace(ctx, request)
}
func NewStorage(client *client.DatabricksClient) *StorageAPI {
return &StorageAPI{
impl: &storageImpl{
client: client,
},
}
}
// These APIs manage storage configurations for this workspace. A root storage
// S3 bucket in your account is required to store objects like cluster logs,
// notebook revisions, and job results. You can also use the root storage S3
// bucket for storage of non-production DBFS data. A storage configuration
// encapsulates this bucket information, and its ID is used when creating a new
// workspace.
type StorageAPI struct {
// impl contains low-level REST API interface, that could be overridden
// through WithImpl(StorageService)
impl StorageService
}
// WithImpl could be used to override low-level API implementations for unit
// testing purposes with [github.com/golang/mock] or other mocking frameworks.
func (a *StorageAPI) WithImpl(impl StorageService) *StorageAPI {
a.impl = impl
return a
}
// Impl returns low-level Storage API implementation
func (a *StorageAPI) Impl() StorageService {
return a.impl
}
// Create new storage configuration.
//
// Creates new storage configuration for an account, specified by ID. Uploads a
// storage configuration object that represents the root AWS S3 bucket in your
// account. Databricks stores related workspace assets including DBFS, cluster
// logs, and job results. For the AWS S3 bucket, you need to configure the
// required bucket policy.
//
// For information about how to create a new workspace with this API, see
// [Create a new workspace using the Account API]
//
// [Create a new workspace using the Account API]: http://docs.databricks.com/administration-guide/account-api/new-workspace.html
func (a *StorageAPI) Create(ctx context.Context, request CreateStorageConfigurationRequest) (*StorageConfiguration, error) {
return a.impl.Create(ctx, request)
}
// Delete storage configuration.
//
// Deletes a Databricks storage configuration. You cannot delete a storage
// configuration that is associated with any workspace.
func (a *StorageAPI) Delete(ctx context.Context, request DeleteStorageRequest) error {
return a.impl.Delete(ctx, request)
}
// Delete storage configuration.
//
// Deletes a Databricks storage configuration. You cannot delete a storage
// configuration that is associated with any workspace.
func (a *StorageAPI) DeleteByStorageConfigurationId(ctx context.Context, storageConfigurationId string) error {
return a.impl.Delete(ctx, DeleteStorageRequest{
StorageConfigurationId: storageConfigurationId,
})
}
// Get storage configuration.
//
// Gets a Databricks storage configuration for an account, both specified by ID.
func (a *StorageAPI) Get(ctx context.Context, request GetStorageRequest) (*StorageConfiguration, error) {
return a.impl.Get(ctx, request)
}
// Get storage configuration.
//
// Gets a Databricks storage configuration for an account, both specified by ID.
func (a *StorageAPI) GetByStorageConfigurationId(ctx context.Context, storageConfigurationId string) (*StorageConfiguration, error) {
return a.impl.Get(ctx, GetStorageRequest{
StorageConfigurationId: storageConfigurationId,
})
}
// Get all storage configurations.
//
// Gets a list of all Databricks storage configurations for your account,
// specified by ID.
func (a *StorageAPI) List(ctx context.Context) ([]StorageConfiguration, error) {
return a.impl.List(ctx)
}
// StorageConfigurationStorageConfigurationNameToStorageConfigurationIdMap calls [StorageAPI.List] and creates a map of results with [StorageConfiguration].StorageConfigurationName as key and [StorageConfiguration].StorageConfigurationId as value.
//
// Returns an error if there's more than one [StorageConfiguration] with the same .StorageConfigurationName.
//
// Note: All [StorageConfiguration] instances are loaded into memory before creating a map.
//
// This method is generated by Databricks SDK Code Generator.
func (a *StorageAPI) StorageConfigurationStorageConfigurationNameToStorageConfigurationIdMap(ctx context.Context) (map[string]string, error) {
ctx = useragent.InContext(ctx, "sdk-feature", "name-to-id")
mapping := map[string]string{}
result, err := a.List(ctx)
if err != nil {
return nil, err
}
for _, v := range result {
key := v.StorageConfigurationName
_, duplicate := mapping[key]
if duplicate {
return nil, fmt.Errorf("duplicate .StorageConfigurationName: %s", key)
}
mapping[key] = v.StorageConfigurationId
}
return mapping, nil
}
// GetByStorageConfigurationName calls [StorageAPI.StorageConfigurationStorageConfigurationNameToStorageConfigurationIdMap] and returns a single [StorageConfiguration].
//
// Returns an error if there's more than one [StorageConfiguration] with the same .StorageConfigurationName.
//
// Note: All [StorageConfiguration] instances are loaded into memory before returning matching by name.
//
// This method is generated by Databricks SDK Code Generator.
func (a *StorageAPI) GetByStorageConfigurationName(ctx context.Context, name string) (*StorageConfiguration, error) {
ctx = useragent.InContext(ctx, "sdk-feature", "get-by-name")
result, err := a.List(ctx)
if err != nil {
return nil, err
}
tmp := map[string][]StorageConfiguration{}
for _, v := range result {
key := v.StorageConfigurationName
tmp[key] = append(tmp[key], v)
}
alternatives, ok := tmp[name]
if !ok || len(alternatives) == 0 {
return nil, fmt.Errorf("StorageConfiguration named '%s' does not exist", name)
}
if len(alternatives) > 1 {
return nil, fmt.Errorf("there are %d instances of StorageConfiguration named '%s'", len(alternatives), name)
}
return &alternatives[0], nil
}
func NewVpcEndpoints(client *client.DatabricksClient) *VpcEndpointsAPI {
return &VpcEndpointsAPI{
impl: &vpcEndpointsImpl{
client: client,
},
}
}
// These APIs manage VPC endpoint configurations for this account.
type VpcEndpointsAPI struct {
// impl contains low-level REST API interface, that could be overridden
// through WithImpl(VpcEndpointsService)
impl VpcEndpointsService
}
// WithImpl could be used to override low-level API implementations for unit
// testing purposes with [github.com/golang/mock] or other mocking frameworks.
func (a *VpcEndpointsAPI) WithImpl(impl VpcEndpointsService) *VpcEndpointsAPI {
a.impl = impl
return a
}
// Impl returns low-level VpcEndpoints API implementation
func (a *VpcEndpointsAPI) Impl() VpcEndpointsService {
return a.impl
}
// Create VPC endpoint configuration.
//
// Creates a VPC endpoint configuration, which represents a [VPC endpoint]
// object in AWS used to communicate privately with Databricks over [AWS
// PrivateLink].
//
// After you create the VPC endpoint configuration, the Databricks [endpoint
// service] automatically accepts the VPC endpoint.
//
// Before configuring PrivateLink, read the [Databricks article about
// PrivateLink].
//
// [AWS PrivateLink]: https://aws.amazon.com/privatelink
// [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html
// [VPC endpoint]: https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints.html
// [endpoint service]: https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html
func (a *VpcEndpointsAPI) Create(ctx context.Context, request CreateVpcEndpointRequest) (*VpcEndpoint, error) {
return a.impl.Create(ctx, request)
}
// Delete VPC endpoint configuration.
//
// Deletes a VPC endpoint configuration, which represents an [AWS VPC endpoint]
// that can communicate privately with Databricks over [AWS PrivateLink].
//
// Before configuring PrivateLink, read the [Databricks article about
// PrivateLink].
//
// [AWS PrivateLink]: https://aws.amazon.com/privatelink
// [AWS VPC endpoint]: https://docs.aws.amazon.com/vpc/latest/privatelink/concepts.html
// [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html
func (a *VpcEndpointsAPI) Delete(ctx context.Context, request DeleteVpcEndpointRequest) error {
return a.impl.Delete(ctx, request)
}
// Delete VPC endpoint configuration.
//
// Deletes a VPC endpoint configuration, which represents an [AWS VPC endpoint]
// that can communicate privately with Databricks over [AWS PrivateLink].
//
// Before configuring PrivateLink, read the [Databricks article about
// PrivateLink].
//
// [AWS PrivateLink]: https://aws.amazon.com/privatelink
// [AWS VPC endpoint]: https://docs.aws.amazon.com/vpc/latest/privatelink/concepts.html
// [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html
func (a *VpcEndpointsAPI) DeleteByVpcEndpointId(ctx context.Context, vpcEndpointId string) error {
return a.impl.Delete(ctx, DeleteVpcEndpointRequest{
VpcEndpointId: vpcEndpointId,
})
}
// Get a VPC endpoint configuration.
//
// Gets a VPC endpoint configuration, which represents a [VPC endpoint] object
// in AWS used to communicate privately with Databricks over [AWS PrivateLink].
//
// [AWS PrivateLink]: https://aws.amazon.com/privatelink
// [VPC endpoint]: https://docs.aws.amazon.com/vpc/latest/privatelink/concepts.html
func (a *VpcEndpointsAPI) Get(ctx context.Context, request GetVpcEndpointRequest) (*VpcEndpoint, error) {
return a.impl.Get(ctx, request)
}
// Get a VPC endpoint configuration.
//
// Gets a VPC endpoint configuration, which represents a [VPC endpoint] object
// in AWS used to communicate privately with Databricks over [AWS PrivateLink].
//
// [AWS PrivateLink]: https://aws.amazon.com/privatelink
// [VPC endpoint]: https://docs.aws.amazon.com/vpc/latest/privatelink/concepts.html
func (a *VpcEndpointsAPI) GetByVpcEndpointId(ctx context.Context, vpcEndpointId string) (*VpcEndpoint, error) {
return a.impl.Get(ctx, GetVpcEndpointRequest{
VpcEndpointId: vpcEndpointId,
})
}
// Get all VPC endpoint configurations.
//
// Gets a list of all VPC endpoints for an account, specified by ID.
//
// Before configuring PrivateLink, read the [Databricks article about
// PrivateLink].
//
// [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html
func (a *VpcEndpointsAPI) List(ctx context.Context) ([]VpcEndpoint, error) {
return a.impl.List(ctx)
}
// VpcEndpointVpcEndpointNameToVpcEndpointIdMap calls [VpcEndpointsAPI.List] and creates a map of results with [VpcEndpoint].VpcEndpointName as key and [VpcEndpoint].VpcEndpointId as value.
//
// Returns an error if there's more than one [VpcEndpoint] with the same .VpcEndpointName.
//
// Note: All [VpcEndpoint] instances are loaded into memory before creating a map.
//
// This method is generated by Databricks SDK Code Generator.
func (a *VpcEndpointsAPI) VpcEndpointVpcEndpointNameToVpcEndpointIdMap(ctx context.Context) (map[string]string, error) {
ctx = useragent.InContext(ctx, "sdk-feature", "name-to-id")
mapping := map[string]string{}
result, err := a.List(ctx)
if err != nil {
return nil, err
}
for _, v := range result {
key := v.VpcEndpointName
_, duplicate := mapping[key]
if duplicate {
return nil, fmt.Errorf("duplicate .VpcEndpointName: %s", key)
}
mapping[key] = v.VpcEndpointId
}
return mapping, nil
}
// GetByVpcEndpointName calls [VpcEndpointsAPI.VpcEndpointVpcEndpointNameToVpcEndpointIdMap] and returns a single [VpcEndpoint].
//
// Returns an error if there's more than one [VpcEndpoint] with the same .VpcEndpointName.
//
// Note: All [VpcEndpoint] instances are loaded into memory before returning matching by name.
//
// This method is generated by Databricks SDK Code Generator.
func (a *VpcEndpointsAPI) GetByVpcEndpointName(ctx context.Context, name string) (*VpcEndpoint, error) {
ctx = useragent.InContext(ctx, "sdk-feature", "get-by-name")
result, err := a.List(ctx)
if err != nil {
return nil, err
}
tmp := map[string][]VpcEndpoint{}
for _, v := range result {
key := v.VpcEndpointName
tmp[key] = append(tmp[key], v)
}
alternatives, ok := tmp[name]
if !ok || len(alternatives) == 0 {
return nil, fmt.Errorf("VpcEndpoint named '%s' does not exist", name)
}
if len(alternatives) > 1 {
return nil, fmt.Errorf("there are %d instances of VpcEndpoint named '%s'", len(alternatives), name)
}
return &alternatives[0], nil
}
func NewWorkspaces(client *client.DatabricksClient) *WorkspacesAPI {
return &WorkspacesAPI{
impl: &workspacesImpl{
client: client,
},
}
}
// These APIs manage workspaces for this account. A Databricks workspace is an
// environment for accessing all of your Databricks assets. The workspace
// organizes objects (notebooks, libraries, and experiments) into folders, and
// provides access to data and computational resources such as clusters and
// jobs.
//
// These endpoints are available if your account is on the E2 version of the
// platform or on a select custom plan that allows multiple workspaces per
// account.
type WorkspacesAPI struct {
// impl contains low-level REST API interface, that could be overridden
// through WithImpl(WorkspacesService)
impl WorkspacesService
}
// WithImpl could be used to override low-level API implementations for unit
// testing purposes with [github.com/golang/mock] or other mocking frameworks.
func (a *WorkspacesAPI) WithImpl(impl WorkspacesService) *WorkspacesAPI {
a.impl = impl
return a
}
// Impl returns low-level Workspaces API implementation
func (a *WorkspacesAPI) Impl() WorkspacesService {
return a.impl
}
// WaitGetWorkspaceRunning repeatedly calls [WorkspacesAPI.Get] and waits to reach RUNNING state