-
Notifications
You must be signed in to change notification settings - Fork 41
/
impl.go
executable file
·442 lines (372 loc) · 18.6 KB
/
impl.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
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
package compute
import (
"context"
"fmt"
"net/http"
"github.com/databricks/databricks-sdk-go/client"
)
// unexported type that holds implementations of just ClusterPolicies API methods
type clusterPoliciesImpl struct {
client *client.DatabricksClient
}
func (a *clusterPoliciesImpl) Create(ctx context.Context, request CreatePolicy) (*CreatePolicyResponse, error) {
var createPolicyResponse CreatePolicyResponse
path := "/api/2.0/policies/clusters/create"
err := a.client.Do(ctx, http.MethodPost, path, request, &createPolicyResponse)
return &createPolicyResponse, err
}
func (a *clusterPoliciesImpl) Delete(ctx context.Context, request DeletePolicy) error {
path := "/api/2.0/policies/clusters/delete"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *clusterPoliciesImpl) Edit(ctx context.Context, request EditPolicy) error {
path := "/api/2.0/policies/clusters/edit"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *clusterPoliciesImpl) Get(ctx context.Context, request GetClusterPolicyRequest) (*Policy, error) {
var policy Policy
path := "/api/2.0/policies/clusters/get"
err := a.client.Do(ctx, http.MethodGet, path, request, &policy)
return &policy, err
}
func (a *clusterPoliciesImpl) GetClusterPolicyPermissionLevels(ctx context.Context, request GetClusterPolicyPermissionLevelsRequest) (*GetClusterPolicyPermissionLevelsResponse, error) {
var getClusterPolicyPermissionLevelsResponse GetClusterPolicyPermissionLevelsResponse
path := fmt.Sprintf("/api/2.0/permissions/cluster-policies/%v/permissionLevels", request.ClusterPolicyId)
err := a.client.Do(ctx, http.MethodGet, path, request, &getClusterPolicyPermissionLevelsResponse)
return &getClusterPolicyPermissionLevelsResponse, err
}
func (a *clusterPoliciesImpl) GetClusterPolicyPermissions(ctx context.Context, request GetClusterPolicyPermissionsRequest) (*ClusterPolicyPermissions, error) {
var clusterPolicyPermissions ClusterPolicyPermissions
path := fmt.Sprintf("/api/2.0/permissions/cluster-policies/%v", request.ClusterPolicyId)
err := a.client.Do(ctx, http.MethodGet, path, request, &clusterPolicyPermissions)
return &clusterPolicyPermissions, err
}
func (a *clusterPoliciesImpl) List(ctx context.Context, request ListClusterPoliciesRequest) (*ListPoliciesResponse, error) {
var listPoliciesResponse ListPoliciesResponse
path := "/api/2.0/policies/clusters/list"
err := a.client.Do(ctx, http.MethodGet, path, request, &listPoliciesResponse)
return &listPoliciesResponse, err
}
func (a *clusterPoliciesImpl) SetClusterPolicyPermissions(ctx context.Context, request ClusterPolicyPermissionsRequest) (*ClusterPolicyPermissions, error) {
var clusterPolicyPermissions ClusterPolicyPermissions
path := fmt.Sprintf("/api/2.0/permissions/cluster-policies/%v", request.ClusterPolicyId)
err := a.client.Do(ctx, http.MethodPut, path, request, &clusterPolicyPermissions)
return &clusterPolicyPermissions, err
}
func (a *clusterPoliciesImpl) UpdateClusterPolicyPermissions(ctx context.Context, request ClusterPolicyPermissionsRequest) (*ClusterPolicyPermissions, error) {
var clusterPolicyPermissions ClusterPolicyPermissions
path := fmt.Sprintf("/api/2.0/permissions/cluster-policies/%v", request.ClusterPolicyId)
err := a.client.Do(ctx, http.MethodPatch, path, request, &clusterPolicyPermissions)
return &clusterPolicyPermissions, err
}
// unexported type that holds implementations of just Clusters API methods
type clustersImpl struct {
client *client.DatabricksClient
}
func (a *clustersImpl) ChangeOwner(ctx context.Context, request ChangeClusterOwner) error {
path := "/api/2.0/clusters/change-owner"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *clustersImpl) Create(ctx context.Context, request CreateCluster) (*CreateClusterResponse, error) {
var createClusterResponse CreateClusterResponse
path := "/api/2.0/clusters/create"
err := a.client.Do(ctx, http.MethodPost, path, request, &createClusterResponse)
return &createClusterResponse, err
}
func (a *clustersImpl) Delete(ctx context.Context, request DeleteCluster) error {
path := "/api/2.0/clusters/delete"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *clustersImpl) Edit(ctx context.Context, request EditCluster) error {
path := "/api/2.0/clusters/edit"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *clustersImpl) Events(ctx context.Context, request GetEvents) (*GetEventsResponse, error) {
var getEventsResponse GetEventsResponse
path := "/api/2.0/clusters/events"
err := a.client.Do(ctx, http.MethodPost, path, request, &getEventsResponse)
return &getEventsResponse, err
}
func (a *clustersImpl) Get(ctx context.Context, request GetClusterRequest) (*ClusterDetails, error) {
var clusterDetails ClusterDetails
path := "/api/2.0/clusters/get"
err := a.client.Do(ctx, http.MethodGet, path, request, &clusterDetails)
return &clusterDetails, err
}
func (a *clustersImpl) GetClusterPermissionLevels(ctx context.Context, request GetClusterPermissionLevelsRequest) (*GetClusterPermissionLevelsResponse, error) {
var getClusterPermissionLevelsResponse GetClusterPermissionLevelsResponse
path := fmt.Sprintf("/api/2.0/permissions/clusters/%v/permissionLevels", request.ClusterId)
err := a.client.Do(ctx, http.MethodGet, path, request, &getClusterPermissionLevelsResponse)
return &getClusterPermissionLevelsResponse, err
}
func (a *clustersImpl) GetClusterPermissions(ctx context.Context, request GetClusterPermissionsRequest) (*ClusterPermissions, error) {
var clusterPermissions ClusterPermissions
path := fmt.Sprintf("/api/2.0/permissions/clusters/%v", request.ClusterId)
err := a.client.Do(ctx, http.MethodGet, path, request, &clusterPermissions)
return &clusterPermissions, err
}
func (a *clustersImpl) List(ctx context.Context, request ListClustersRequest) (*ListClustersResponse, error) {
var listClustersResponse ListClustersResponse
path := "/api/2.0/clusters/list"
err := a.client.Do(ctx, http.MethodGet, path, request, &listClustersResponse)
return &listClustersResponse, err
}
func (a *clustersImpl) ListNodeTypes(ctx context.Context) (*ListNodeTypesResponse, error) {
var listNodeTypesResponse ListNodeTypesResponse
path := "/api/2.0/clusters/list-node-types"
err := a.client.Do(ctx, http.MethodGet, path, nil, &listNodeTypesResponse)
return &listNodeTypesResponse, err
}
func (a *clustersImpl) ListZones(ctx context.Context) (*ListAvailableZonesResponse, error) {
var listAvailableZonesResponse ListAvailableZonesResponse
path := "/api/2.0/clusters/list-zones"
err := a.client.Do(ctx, http.MethodGet, path, nil, &listAvailableZonesResponse)
return &listAvailableZonesResponse, err
}
func (a *clustersImpl) PermanentDelete(ctx context.Context, request PermanentDeleteCluster) error {
path := "/api/2.0/clusters/permanent-delete"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *clustersImpl) Pin(ctx context.Context, request PinCluster) error {
path := "/api/2.0/clusters/pin"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *clustersImpl) Resize(ctx context.Context, request ResizeCluster) error {
path := "/api/2.0/clusters/resize"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *clustersImpl) Restart(ctx context.Context, request RestartCluster) error {
path := "/api/2.0/clusters/restart"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *clustersImpl) SetClusterPermissions(ctx context.Context, request ClusterPermissionsRequest) (*ClusterPermissions, error) {
var clusterPermissions ClusterPermissions
path := fmt.Sprintf("/api/2.0/permissions/clusters/%v", request.ClusterId)
err := a.client.Do(ctx, http.MethodPut, path, request, &clusterPermissions)
return &clusterPermissions, err
}
func (a *clustersImpl) SparkVersions(ctx context.Context) (*GetSparkVersionsResponse, error) {
var getSparkVersionsResponse GetSparkVersionsResponse
path := "/api/2.0/clusters/spark-versions"
err := a.client.Do(ctx, http.MethodGet, path, nil, &getSparkVersionsResponse)
return &getSparkVersionsResponse, err
}
func (a *clustersImpl) Start(ctx context.Context, request StartCluster) error {
path := "/api/2.0/clusters/start"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *clustersImpl) Unpin(ctx context.Context, request UnpinCluster) error {
path := "/api/2.0/clusters/unpin"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *clustersImpl) UpdateClusterPermissions(ctx context.Context, request ClusterPermissionsRequest) (*ClusterPermissions, error) {
var clusterPermissions ClusterPermissions
path := fmt.Sprintf("/api/2.0/permissions/clusters/%v", request.ClusterId)
err := a.client.Do(ctx, http.MethodPatch, path, request, &clusterPermissions)
return &clusterPermissions, err
}
// unexported type that holds implementations of just CommandExecution API methods
type commandExecutionImpl struct {
client *client.DatabricksClient
}
func (a *commandExecutionImpl) Cancel(ctx context.Context, request CancelCommand) error {
path := "/api/1.2/commands/cancel"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *commandExecutionImpl) CommandStatus(ctx context.Context, request CommandStatusRequest) (*CommandStatusResponse, error) {
var commandStatusResponse CommandStatusResponse
path := "/api/1.2/commands/status"
err := a.client.Do(ctx, http.MethodGet, path, request, &commandStatusResponse)
return &commandStatusResponse, err
}
func (a *commandExecutionImpl) ContextStatus(ctx context.Context, request ContextStatusRequest) (*ContextStatusResponse, error) {
var contextStatusResponse ContextStatusResponse
path := "/api/1.2/contexts/status"
err := a.client.Do(ctx, http.MethodGet, path, request, &contextStatusResponse)
return &contextStatusResponse, err
}
func (a *commandExecutionImpl) Create(ctx context.Context, request CreateContext) (*Created, error) {
var created Created
path := "/api/1.2/contexts/create"
err := a.client.Do(ctx, http.MethodPost, path, request, &created)
return &created, err
}
func (a *commandExecutionImpl) Destroy(ctx context.Context, request DestroyContext) error {
path := "/api/1.2/contexts/destroy"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *commandExecutionImpl) Execute(ctx context.Context, request Command) (*Created, error) {
var created Created
path := "/api/1.2/commands/execute"
err := a.client.Do(ctx, http.MethodPost, path, request, &created)
return &created, err
}
// unexported type that holds implementations of just GlobalInitScripts API methods
type globalInitScriptsImpl struct {
client *client.DatabricksClient
}
func (a *globalInitScriptsImpl) Create(ctx context.Context, request GlobalInitScriptCreateRequest) (*CreateResponse, error) {
var createResponse CreateResponse
path := "/api/2.0/global-init-scripts"
err := a.client.Do(ctx, http.MethodPost, path, request, &createResponse)
return &createResponse, err
}
func (a *globalInitScriptsImpl) Delete(ctx context.Context, request DeleteGlobalInitScriptRequest) error {
path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId)
err := a.client.Do(ctx, http.MethodDelete, path, request, nil)
return err
}
func (a *globalInitScriptsImpl) Get(ctx context.Context, request GetGlobalInitScriptRequest) (*GlobalInitScriptDetailsWithContent, error) {
var globalInitScriptDetailsWithContent GlobalInitScriptDetailsWithContent
path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId)
err := a.client.Do(ctx, http.MethodGet, path, request, &globalInitScriptDetailsWithContent)
return &globalInitScriptDetailsWithContent, err
}
func (a *globalInitScriptsImpl) List(ctx context.Context) (*ListGlobalInitScriptsResponse, error) {
var listGlobalInitScriptsResponse ListGlobalInitScriptsResponse
path := "/api/2.0/global-init-scripts"
err := a.client.Do(ctx, http.MethodGet, path, nil, &listGlobalInitScriptsResponse)
return &listGlobalInitScriptsResponse, err
}
func (a *globalInitScriptsImpl) Update(ctx context.Context, request GlobalInitScriptUpdateRequest) error {
path := fmt.Sprintf("/api/2.0/global-init-scripts/%v", request.ScriptId)
err := a.client.Do(ctx, http.MethodPatch, path, request, nil)
return err
}
// unexported type that holds implementations of just InstancePools API methods
type instancePoolsImpl struct {
client *client.DatabricksClient
}
func (a *instancePoolsImpl) Create(ctx context.Context, request CreateInstancePool) (*CreateInstancePoolResponse, error) {
var createInstancePoolResponse CreateInstancePoolResponse
path := "/api/2.0/instance-pools/create"
err := a.client.Do(ctx, http.MethodPost, path, request, &createInstancePoolResponse)
return &createInstancePoolResponse, err
}
func (a *instancePoolsImpl) Delete(ctx context.Context, request DeleteInstancePool) error {
path := "/api/2.0/instance-pools/delete"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *instancePoolsImpl) Edit(ctx context.Context, request EditInstancePool) error {
path := "/api/2.0/instance-pools/edit"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *instancePoolsImpl) Get(ctx context.Context, request GetInstancePoolRequest) (*GetInstancePool, error) {
var getInstancePool GetInstancePool
path := "/api/2.0/instance-pools/get"
err := a.client.Do(ctx, http.MethodGet, path, request, &getInstancePool)
return &getInstancePool, err
}
func (a *instancePoolsImpl) GetInstancePoolPermissionLevels(ctx context.Context, request GetInstancePoolPermissionLevelsRequest) (*GetInstancePoolPermissionLevelsResponse, error) {
var getInstancePoolPermissionLevelsResponse GetInstancePoolPermissionLevelsResponse
path := fmt.Sprintf("/api/2.0/permissions/instance-pools/%v/permissionLevels", request.InstancePoolId)
err := a.client.Do(ctx, http.MethodGet, path, request, &getInstancePoolPermissionLevelsResponse)
return &getInstancePoolPermissionLevelsResponse, err
}
func (a *instancePoolsImpl) GetInstancePoolPermissions(ctx context.Context, request GetInstancePoolPermissionsRequest) (*InstancePoolPermissions, error) {
var instancePoolPermissions InstancePoolPermissions
path := fmt.Sprintf("/api/2.0/permissions/instance-pools/%v", request.InstancePoolId)
err := a.client.Do(ctx, http.MethodGet, path, request, &instancePoolPermissions)
return &instancePoolPermissions, err
}
func (a *instancePoolsImpl) List(ctx context.Context) (*ListInstancePools, error) {
var listInstancePools ListInstancePools
path := "/api/2.0/instance-pools/list"
err := a.client.Do(ctx, http.MethodGet, path, nil, &listInstancePools)
return &listInstancePools, err
}
func (a *instancePoolsImpl) SetInstancePoolPermissions(ctx context.Context, request InstancePoolPermissionsRequest) (*InstancePoolPermissions, error) {
var instancePoolPermissions InstancePoolPermissions
path := fmt.Sprintf("/api/2.0/permissions/instance-pools/%v", request.InstancePoolId)
err := a.client.Do(ctx, http.MethodPut, path, request, &instancePoolPermissions)
return &instancePoolPermissions, err
}
func (a *instancePoolsImpl) UpdateInstancePoolPermissions(ctx context.Context, request InstancePoolPermissionsRequest) (*InstancePoolPermissions, error) {
var instancePoolPermissions InstancePoolPermissions
path := fmt.Sprintf("/api/2.0/permissions/instance-pools/%v", request.InstancePoolId)
err := a.client.Do(ctx, http.MethodPatch, path, request, &instancePoolPermissions)
return &instancePoolPermissions, err
}
// unexported type that holds implementations of just InstanceProfiles API methods
type instanceProfilesImpl struct {
client *client.DatabricksClient
}
func (a *instanceProfilesImpl) Add(ctx context.Context, request AddInstanceProfile) error {
path := "/api/2.0/instance-profiles/add"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *instanceProfilesImpl) Edit(ctx context.Context, request InstanceProfile) error {
path := "/api/2.0/instance-profiles/edit"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *instanceProfilesImpl) List(ctx context.Context) (*ListInstanceProfilesResponse, error) {
var listInstanceProfilesResponse ListInstanceProfilesResponse
path := "/api/2.0/instance-profiles/list"
err := a.client.Do(ctx, http.MethodGet, path, nil, &listInstanceProfilesResponse)
return &listInstanceProfilesResponse, err
}
func (a *instanceProfilesImpl) Remove(ctx context.Context, request RemoveInstanceProfile) error {
path := "/api/2.0/instance-profiles/remove"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
// unexported type that holds implementations of just Libraries API methods
type librariesImpl struct {
client *client.DatabricksClient
}
func (a *librariesImpl) AllClusterStatuses(ctx context.Context) (*ListAllClusterLibraryStatusesResponse, error) {
var listAllClusterLibraryStatusesResponse ListAllClusterLibraryStatusesResponse
path := "/api/2.0/libraries/all-cluster-statuses"
err := a.client.Do(ctx, http.MethodGet, path, nil, &listAllClusterLibraryStatusesResponse)
return &listAllClusterLibraryStatusesResponse, err
}
func (a *librariesImpl) ClusterStatus(ctx context.Context, request ClusterStatusRequest) (*ClusterLibraryStatuses, error) {
var clusterLibraryStatuses ClusterLibraryStatuses
path := "/api/2.0/libraries/cluster-status"
err := a.client.Do(ctx, http.MethodGet, path, request, &clusterLibraryStatuses)
return &clusterLibraryStatuses, err
}
func (a *librariesImpl) Install(ctx context.Context, request InstallLibraries) error {
path := "/api/2.0/libraries/install"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
func (a *librariesImpl) Uninstall(ctx context.Context, request UninstallLibraries) error {
path := "/api/2.0/libraries/uninstall"
err := a.client.Do(ctx, http.MethodPost, path, request, nil)
return err
}
// unexported type that holds implementations of just PolicyFamilies API methods
type policyFamiliesImpl struct {
client *client.DatabricksClient
}
func (a *policyFamiliesImpl) Get(ctx context.Context, request GetPolicyFamilyRequest) (*PolicyFamily, error) {
var policyFamily PolicyFamily
path := fmt.Sprintf("/api/2.0/policy-families/%v", request.PolicyFamilyId)
err := a.client.Do(ctx, http.MethodGet, path, request, &policyFamily)
return &policyFamily, err
}
func (a *policyFamiliesImpl) List(ctx context.Context, request ListPolicyFamiliesRequest) (*ListPolicyFamiliesResponse, error) {
var listPolicyFamiliesResponse ListPolicyFamiliesResponse
path := "/api/2.0/policy-families"
err := a.client.Do(ctx, http.MethodGet, path, request, &listPolicyFamiliesResponse)
return &listPolicyFamiliesResponse, err
}