/
impl.go
executable file
·361 lines (319 loc) · 14.7 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
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
package workspace
import (
"context"
"fmt"
"net/http"
"github.com/databricks/databricks-sdk-go/client"
)
// unexported type that holds implementations of just GitCredentials API methods
type gitCredentialsImpl struct {
client *client.DatabricksClient
}
func (a *gitCredentialsImpl) Create(ctx context.Context, request CreateCredentials) (*CreateCredentialsResponse, error) {
var createCredentialsResponse CreateCredentialsResponse
path := "/api/2.0/git-credentials"
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPost, path, headers, request, &createCredentialsResponse)
return &createCredentialsResponse, err
}
func (a *gitCredentialsImpl) Delete(ctx context.Context, request DeleteGitCredentialRequest) error {
var deleteResponse DeleteResponse
path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId)
headers := make(map[string]string)
err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &deleteResponse)
return err
}
func (a *gitCredentialsImpl) Get(ctx context.Context, request GetGitCredentialRequest) (*CredentialInfo, error) {
var credentialInfo CredentialInfo
path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId)
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &credentialInfo)
return &credentialInfo, err
}
func (a *gitCredentialsImpl) List(ctx context.Context) (*GetCredentialsResponse, error) {
var getCredentialsResponse GetCredentialsResponse
path := "/api/2.0/git-credentials"
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, nil, &getCredentialsResponse)
return &getCredentialsResponse, err
}
func (a *gitCredentialsImpl) Update(ctx context.Context, request UpdateCredentials) error {
var updateResponse UpdateResponse
path := fmt.Sprintf("/api/2.0/git-credentials/%v", request.CredentialId)
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPatch, path, headers, request, &updateResponse)
return err
}
// unexported type that holds implementations of just Repos API methods
type reposImpl struct {
client *client.DatabricksClient
}
func (a *reposImpl) Create(ctx context.Context, request CreateRepo) (*RepoInfo, error) {
var repoInfo RepoInfo
path := "/api/2.0/repos"
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPost, path, headers, request, &repoInfo)
return &repoInfo, err
}
func (a *reposImpl) Delete(ctx context.Context, request DeleteRepoRequest) error {
var deleteResponse DeleteResponse
path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId)
headers := make(map[string]string)
err := a.client.Do(ctx, http.MethodDelete, path, headers, request, &deleteResponse)
return err
}
func (a *reposImpl) Get(ctx context.Context, request GetRepoRequest) (*RepoInfo, error) {
var repoInfo RepoInfo
path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId)
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &repoInfo)
return &repoInfo, err
}
func (a *reposImpl) GetPermissionLevels(ctx context.Context, request GetRepoPermissionLevelsRequest) (*GetRepoPermissionLevelsResponse, error) {
var getRepoPermissionLevelsResponse GetRepoPermissionLevelsResponse
path := fmt.Sprintf("/api/2.0/permissions/repos/%v/permissionLevels", request.RepoId)
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &getRepoPermissionLevelsResponse)
return &getRepoPermissionLevelsResponse, err
}
func (a *reposImpl) GetPermissions(ctx context.Context, request GetRepoPermissionsRequest) (*RepoPermissions, error) {
var repoPermissions RepoPermissions
path := fmt.Sprintf("/api/2.0/permissions/repos/%v", request.RepoId)
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &repoPermissions)
return &repoPermissions, err
}
func (a *reposImpl) List(ctx context.Context, request ListReposRequest) (*ListReposResponse, error) {
var listReposResponse ListReposResponse
path := "/api/2.0/repos"
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &listReposResponse)
return &listReposResponse, err
}
func (a *reposImpl) SetPermissions(ctx context.Context, request RepoPermissionsRequest) (*RepoPermissions, error) {
var repoPermissions RepoPermissions
path := fmt.Sprintf("/api/2.0/permissions/repos/%v", request.RepoId)
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPut, path, headers, request, &repoPermissions)
return &repoPermissions, err
}
func (a *reposImpl) Update(ctx context.Context, request UpdateRepo) error {
var updateResponse UpdateResponse
path := fmt.Sprintf("/api/2.0/repos/%v", request.RepoId)
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPatch, path, headers, request, &updateResponse)
return err
}
func (a *reposImpl) UpdatePermissions(ctx context.Context, request RepoPermissionsRequest) (*RepoPermissions, error) {
var repoPermissions RepoPermissions
path := fmt.Sprintf("/api/2.0/permissions/repos/%v", request.RepoId)
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPatch, path, headers, request, &repoPermissions)
return &repoPermissions, err
}
// unexported type that holds implementations of just Secrets API methods
type secretsImpl struct {
client *client.DatabricksClient
}
func (a *secretsImpl) CreateScope(ctx context.Context, request CreateScope) error {
var createScopeResponse CreateScopeResponse
path := "/api/2.0/secrets/scopes/create"
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPost, path, headers, request, &createScopeResponse)
return err
}
func (a *secretsImpl) DeleteAcl(ctx context.Context, request DeleteAcl) error {
var deleteAclResponse DeleteAclResponse
path := "/api/2.0/secrets/acls/delete"
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPost, path, headers, request, &deleteAclResponse)
return err
}
func (a *secretsImpl) DeleteScope(ctx context.Context, request DeleteScope) error {
var deleteScopeResponse DeleteScopeResponse
path := "/api/2.0/secrets/scopes/delete"
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPost, path, headers, request, &deleteScopeResponse)
return err
}
func (a *secretsImpl) DeleteSecret(ctx context.Context, request DeleteSecret) error {
var deleteSecretResponse DeleteSecretResponse
path := "/api/2.0/secrets/delete"
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPost, path, headers, request, &deleteSecretResponse)
return err
}
func (a *secretsImpl) GetAcl(ctx context.Context, request GetAclRequest) (*AclItem, error) {
var aclItem AclItem
path := "/api/2.0/secrets/acls/get"
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &aclItem)
return &aclItem, err
}
func (a *secretsImpl) GetSecret(ctx context.Context, request GetSecretRequest) (*GetSecretResponse, error) {
var getSecretResponse GetSecretResponse
path := "/api/2.0/secrets/get"
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &getSecretResponse)
return &getSecretResponse, err
}
func (a *secretsImpl) ListAcls(ctx context.Context, request ListAclsRequest) (*ListAclsResponse, error) {
var listAclsResponse ListAclsResponse
path := "/api/2.0/secrets/acls/list"
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &listAclsResponse)
return &listAclsResponse, err
}
func (a *secretsImpl) ListScopes(ctx context.Context) (*ListScopesResponse, error) {
var listScopesResponse ListScopesResponse
path := "/api/2.0/secrets/scopes/list"
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, nil, &listScopesResponse)
return &listScopesResponse, err
}
func (a *secretsImpl) ListSecrets(ctx context.Context, request ListSecretsRequest) (*ListSecretsResponse, error) {
var listSecretsResponse ListSecretsResponse
path := "/api/2.0/secrets/list"
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &listSecretsResponse)
return &listSecretsResponse, err
}
func (a *secretsImpl) PutAcl(ctx context.Context, request PutAcl) error {
var putAclResponse PutAclResponse
path := "/api/2.0/secrets/acls/put"
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPost, path, headers, request, &putAclResponse)
return err
}
func (a *secretsImpl) PutSecret(ctx context.Context, request PutSecret) error {
var putSecretResponse PutSecretResponse
path := "/api/2.0/secrets/put"
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPost, path, headers, request, &putSecretResponse)
return err
}
// unexported type that holds implementations of just Workspace API methods
type workspaceImpl struct {
client *client.DatabricksClient
}
func (a *workspaceImpl) Delete(ctx context.Context, request Delete) error {
var deleteResponse DeleteResponse
path := "/api/2.0/workspace/delete"
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPost, path, headers, request, &deleteResponse)
return err
}
func (a *workspaceImpl) Export(ctx context.Context, request ExportRequest) (*ExportResponse, error) {
var exportResponse ExportResponse
path := "/api/2.0/workspace/export"
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &exportResponse)
return &exportResponse, err
}
func (a *workspaceImpl) GetPermissionLevels(ctx context.Context, request GetWorkspaceObjectPermissionLevelsRequest) (*GetWorkspaceObjectPermissionLevelsResponse, error) {
var getWorkspaceObjectPermissionLevelsResponse GetWorkspaceObjectPermissionLevelsResponse
path := fmt.Sprintf("/api/2.0/permissions/%v/%v/permissionLevels", request.WorkspaceObjectType, request.WorkspaceObjectId)
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &getWorkspaceObjectPermissionLevelsResponse)
return &getWorkspaceObjectPermissionLevelsResponse, err
}
func (a *workspaceImpl) GetPermissions(ctx context.Context, request GetWorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error) {
var workspaceObjectPermissions WorkspaceObjectPermissions
path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.WorkspaceObjectType, request.WorkspaceObjectId)
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &workspaceObjectPermissions)
return &workspaceObjectPermissions, err
}
func (a *workspaceImpl) GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error) {
var objectInfo ObjectInfo
path := "/api/2.0/workspace/get-status"
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &objectInfo)
return &objectInfo, err
}
func (a *workspaceImpl) Import(ctx context.Context, request Import) error {
var importResponse ImportResponse
path := "/api/2.0/workspace/import"
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPost, path, headers, request, &importResponse)
return err
}
func (a *workspaceImpl) List(ctx context.Context, request ListWorkspaceRequest) (*ListResponse, error) {
var listResponse ListResponse
path := "/api/2.0/workspace/list"
headers := make(map[string]string)
headers["Accept"] = "application/json"
err := a.client.Do(ctx, http.MethodGet, path, headers, request, &listResponse)
return &listResponse, err
}
func (a *workspaceImpl) Mkdirs(ctx context.Context, request Mkdirs) error {
var mkdirsResponse MkdirsResponse
path := "/api/2.0/workspace/mkdirs"
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPost, path, headers, request, &mkdirsResponse)
return err
}
func (a *workspaceImpl) SetPermissions(ctx context.Context, request WorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error) {
var workspaceObjectPermissions WorkspaceObjectPermissions
path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.WorkspaceObjectType, request.WorkspaceObjectId)
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPut, path, headers, request, &workspaceObjectPermissions)
return &workspaceObjectPermissions, err
}
func (a *workspaceImpl) UpdatePermissions(ctx context.Context, request WorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error) {
var workspaceObjectPermissions WorkspaceObjectPermissions
path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.WorkspaceObjectType, request.WorkspaceObjectId)
headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
err := a.client.Do(ctx, http.MethodPatch, path, headers, request, &workspaceObjectPermissions)
return &workspaceObjectPermissions, err
}