/
scale_shift_api.go
736 lines (609 loc) · 31.2 KB
/
scale_shift_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
// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"net/http"
"strings"
errors "github.com/go-openapi/errors"
loads "github.com/go-openapi/loads"
runtime "github.com/go-openapi/runtime"
middleware "github.com/go-openapi/runtime/middleware"
security "github.com/go-openapi/runtime/security"
spec "github.com/go-openapi/spec"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/scaleshift/scaleshift/api/src/auth"
"github.com/scaleshift/scaleshift/api/src/generated/restapi/operations/app"
"github.com/scaleshift/scaleshift/api/src/generated/restapi/operations/app_errors"
"github.com/scaleshift/scaleshift/api/src/generated/restapi/operations/image"
"github.com/scaleshift/scaleshift/api/src/generated/restapi/operations/job"
"github.com/scaleshift/scaleshift/api/src/generated/restapi/operations/notebook"
"github.com/scaleshift/scaleshift/api/src/generated/restapi/operations/repository"
"github.com/scaleshift/scaleshift/api/src/generated/restapi/operations/rescale"
"github.com/scaleshift/scaleshift/api/src/generated/restapi/operations/workspace"
)
// NewScaleShiftAPI creates a new ScaleShift instance
func NewScaleShiftAPI(spec *loads.Document) *ScaleShiftAPI {
return &ScaleShiftAPI{
handlers: make(map[string]map[string]http.Handler),
formats: strfmt.Default,
defaultConsumes: "application/json",
defaultProduces: "application/json",
customConsumers: make(map[string]runtime.Consumer),
customProducers: make(map[string]runtime.Producer),
ServerShutdown: func() {},
spec: spec,
ServeError: errors.ServeError,
BasicAuthenticator: security.BasicAuth,
APIKeyAuthenticator: security.APIKeyAuth,
BearerAuthenticator: security.BearerAuth,
JSONConsumer: runtime.JSONConsumer(),
JSONProducer: runtime.JSONProducer(),
ImageDeleteImageHandler: image.DeleteImageHandlerFunc(func(params image.DeleteImageParams) middleware.Responder {
return middleware.NotImplemented("operation ImageDeleteImage has not yet been implemented")
}),
JobDeleteJobHandler: job.DeleteJobHandlerFunc(func(params job.DeleteJobParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation JobDeleteJob has not yet been implemented")
}),
NotebookDeleteNotebookHandler: notebook.DeleteNotebookHandlerFunc(func(params notebook.DeleteNotebookParams) middleware.Responder {
return middleware.NotImplemented("operation NotebookDeleteNotebook has not yet been implemented")
}),
WorkspaceDeleteWorkspaceHandler: workspace.DeleteWorkspaceHandlerFunc(func(params workspace.DeleteWorkspaceParams) middleware.Responder {
return middleware.NotImplemented("operation WorkspaceDeleteWorkspace has not yet been implemented")
}),
AppErrorsGetAppErrorsHandler: app_errors.GetAppErrorsHandlerFunc(func(params app_errors.GetAppErrorsParams) middleware.Responder {
return middleware.NotImplemented("operation AppErrorsGetAppErrors has not yet been implemented")
}),
AppGetConfigurationsHandler: app.GetConfigurationsHandlerFunc(func(params app.GetConfigurationsParams) middleware.Responder {
return middleware.NotImplemented("operation AppGetConfigurations has not yet been implemented")
}),
AppGetEndpointsHandler: app.GetEndpointsHandlerFunc(func(params app.GetEndpointsParams) middleware.Responder {
return middleware.NotImplemented("operation AppGetEndpoints has not yet been implemented")
}),
NotebookGetIpythonNotebooksHandler: notebook.GetIpythonNotebooksHandlerFunc(func(params notebook.GetIpythonNotebooksParams) middleware.Responder {
return middleware.NotImplemented("operation NotebookGetIpythonNotebooks has not yet been implemented")
}),
ImageGetImagesHandler: image.GetImagesHandlerFunc(func(params image.GetImagesParams) middleware.Responder {
return middleware.NotImplemented("operation ImageGetImages has not yet been implemented")
}),
JobGetJobDetailHandler: job.GetJobDetailHandlerFunc(func(params job.GetJobDetailParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation JobGetJobDetail has not yet been implemented")
}),
JobGetJobFilesHandler: job.GetJobFilesHandlerFunc(func(params job.GetJobFilesParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation JobGetJobFiles has not yet been implemented")
}),
JobGetJobLogsHandler: job.GetJobLogsHandlerFunc(func(params job.GetJobLogsParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation JobGetJobLogs has not yet been implemented")
}),
JobGetJobsHandler: job.GetJobsHandlerFunc(func(params job.GetJobsParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation JobGetJobs has not yet been implemented")
}),
RepositoryGetNgcImagesHandler: repository.GetNgcImagesHandlerFunc(func(params repository.GetNgcImagesParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation RepositoryGetNgcImages has not yet been implemented")
}),
RepositoryGetNgcRepositoriesHandler: repository.GetNgcRepositoriesHandlerFunc(func(params repository.GetNgcRepositoriesParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation RepositoryGetNgcRepositories has not yet been implemented")
}),
NotebookGetNotebookDetailsHandler: notebook.GetNotebookDetailsHandlerFunc(func(params notebook.GetNotebookDetailsParams) middleware.Responder {
return middleware.NotImplemented("operation NotebookGetNotebookDetails has not yet been implemented")
}),
NotebookGetNotebooksHandler: notebook.GetNotebooksHandlerFunc(func(params notebook.GetNotebooksParams) middleware.Responder {
return middleware.NotImplemented("operation NotebookGetNotebooks has not yet been implemented")
}),
RepositoryGetRemoteImagesHandler: repository.GetRemoteImagesHandlerFunc(func(params repository.GetRemoteImagesParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation RepositoryGetRemoteImages has not yet been implemented")
}),
RepositoryGetRemoteRepositoriesHandler: repository.GetRemoteRepositoriesHandlerFunc(func(params repository.GetRemoteRepositoriesParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation RepositoryGetRemoteRepositories has not yet been implemented")
}),
RescaleGetRescaleApplicationHandler: rescale.GetRescaleApplicationHandlerFunc(func(params rescale.GetRescaleApplicationParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation RescaleGetRescaleApplication has not yet been implemented")
}),
RescaleGetRescaleApplicationVersionHandler: rescale.GetRescaleApplicationVersionHandlerFunc(func(params rescale.GetRescaleApplicationVersionParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation RescaleGetRescaleApplicationVersion has not yet been implemented")
}),
RescaleGetRescaleCoreTypesHandler: rescale.GetRescaleCoreTypesHandlerFunc(func(params rescale.GetRescaleCoreTypesParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation RescaleGetRescaleCoreTypes has not yet been implemented")
}),
AppGetVersionsHandler: app.GetVersionsHandlerFunc(func(params app.GetVersionsParams) middleware.Responder {
return middleware.NotImplemented("operation AppGetVersions has not yet been implemented")
}),
WorkspaceGetWorkspacesHandler: workspace.GetWorkspacesHandlerFunc(func(params workspace.GetWorkspacesParams) middleware.Responder {
return middleware.NotImplemented("operation WorkspaceGetWorkspaces has not yet been implemented")
}),
JobModifyJobHandler: job.ModifyJobHandlerFunc(func(params job.ModifyJobParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation JobModifyJob has not yet been implemented")
}),
NotebookModifyNotebookHandler: notebook.ModifyNotebookHandlerFunc(func(params notebook.ModifyNotebookParams) middleware.Responder {
return middleware.NotImplemented("operation NotebookModifyNotebook has not yet been implemented")
}),
AppPostConfigurationsHandler: app.PostConfigurationsHandlerFunc(func(params app.PostConfigurationsParams) middleware.Responder {
return middleware.NotImplemented("operation AppPostConfigurations has not yet been implemented")
}),
ImagePostNewImageHandler: image.PostNewImageHandlerFunc(func(params image.PostNewImageParams) middleware.Responder {
return middleware.NotImplemented("operation ImagePostNewImage has not yet been implemented")
}),
JobPostNewJobHandler: job.PostNewJobHandlerFunc(func(params job.PostNewJobParams, principal *auth.Principal) middleware.Responder {
return middleware.NotImplemented("operation JobPostNewJob has not yet been implemented")
}),
NotebookPostNewNotebookHandler: notebook.PostNewNotebookHandlerFunc(func(params notebook.PostNewNotebookParams) middleware.Responder {
return middleware.NotImplemented("operation NotebookPostNewNotebook has not yet been implemented")
}),
AppPostNewSessionHandler: app.PostNewSessionHandlerFunc(func(params app.PostNewSessionParams) middleware.Responder {
return middleware.NotImplemented("operation AppPostNewSession has not yet been implemented")
}),
// Applies when the "Authorization" header is set
APIAuthorizerAuth: func(token string) (*auth.Principal, error) {
return nil, errors.NotImplemented("api key auth (api-authorizer) Authorization from header param [Authorization] has not yet been implemented")
},
// default authorizer is authorized meaning no requests are blocked
APIAuthorizer: security.Authorized(),
}
}
/*ScaleShiftAPI A platform for machine learning & high performance computing
*/
type ScaleShiftAPI struct {
spec *loads.Document
context *middleware.Context
handlers map[string]map[string]http.Handler
formats strfmt.Registry
customConsumers map[string]runtime.Consumer
customProducers map[string]runtime.Producer
defaultConsumes string
defaultProduces string
Middleware func(middleware.Builder) http.Handler
// BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function.
// It has a default implemention in the security package, however you can replace it for your particular usage.
BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator
// APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function.
// It has a default implemention in the security package, however you can replace it for your particular usage.
APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator
// BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function.
// It has a default implemention in the security package, however you can replace it for your particular usage.
BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator
// JSONConsumer registers a consumer for a "application/json" mime type
JSONConsumer runtime.Consumer
// JSONProducer registers a producer for a "application/json" mime type
JSONProducer runtime.Producer
// APIAuthorizerAuth registers a function that takes a token and returns a principal
// it performs authentication based on an api key Authorization provided in the header
APIAuthorizerAuth func(string) (*auth.Principal, error)
// APIAuthorizer provides access control (ACL/RBAC/ABAC) by providing access to the request and authenticated principal
APIAuthorizer runtime.Authorizer
// ImageDeleteImageHandler sets the operation handler for the delete image operation
ImageDeleteImageHandler image.DeleteImageHandler
// JobDeleteJobHandler sets the operation handler for the delete job operation
JobDeleteJobHandler job.DeleteJobHandler
// NotebookDeleteNotebookHandler sets the operation handler for the delete notebook operation
NotebookDeleteNotebookHandler notebook.DeleteNotebookHandler
// WorkspaceDeleteWorkspaceHandler sets the operation handler for the delete workspace operation
WorkspaceDeleteWorkspaceHandler workspace.DeleteWorkspaceHandler
// AppErrorsGetAppErrorsHandler sets the operation handler for the get app errors operation
AppErrorsGetAppErrorsHandler app_errors.GetAppErrorsHandler
// AppGetConfigurationsHandler sets the operation handler for the get configurations operation
AppGetConfigurationsHandler app.GetConfigurationsHandler
// AppGetEndpointsHandler sets the operation handler for the get endpoints operation
AppGetEndpointsHandler app.GetEndpointsHandler
// NotebookGetIpythonNotebooksHandler sets the operation handler for the get ipython notebooks operation
NotebookGetIpythonNotebooksHandler notebook.GetIpythonNotebooksHandler
// ImageGetImagesHandler sets the operation handler for the get images operation
ImageGetImagesHandler image.GetImagesHandler
// JobGetJobDetailHandler sets the operation handler for the get job detail operation
JobGetJobDetailHandler job.GetJobDetailHandler
// JobGetJobFilesHandler sets the operation handler for the get job files operation
JobGetJobFilesHandler job.GetJobFilesHandler
// JobGetJobLogsHandler sets the operation handler for the get job logs operation
JobGetJobLogsHandler job.GetJobLogsHandler
// JobGetJobsHandler sets the operation handler for the get jobs operation
JobGetJobsHandler job.GetJobsHandler
// RepositoryGetNgcImagesHandler sets the operation handler for the get ngc images operation
RepositoryGetNgcImagesHandler repository.GetNgcImagesHandler
// RepositoryGetNgcRepositoriesHandler sets the operation handler for the get ngc repositories operation
RepositoryGetNgcRepositoriesHandler repository.GetNgcRepositoriesHandler
// NotebookGetNotebookDetailsHandler sets the operation handler for the get notebook details operation
NotebookGetNotebookDetailsHandler notebook.GetNotebookDetailsHandler
// NotebookGetNotebooksHandler sets the operation handler for the get notebooks operation
NotebookGetNotebooksHandler notebook.GetNotebooksHandler
// RepositoryGetRemoteImagesHandler sets the operation handler for the get remote images operation
RepositoryGetRemoteImagesHandler repository.GetRemoteImagesHandler
// RepositoryGetRemoteRepositoriesHandler sets the operation handler for the get remote repositories operation
RepositoryGetRemoteRepositoriesHandler repository.GetRemoteRepositoriesHandler
// RescaleGetRescaleApplicationHandler sets the operation handler for the get rescale application operation
RescaleGetRescaleApplicationHandler rescale.GetRescaleApplicationHandler
// RescaleGetRescaleApplicationVersionHandler sets the operation handler for the get rescale application version operation
RescaleGetRescaleApplicationVersionHandler rescale.GetRescaleApplicationVersionHandler
// RescaleGetRescaleCoreTypesHandler sets the operation handler for the get rescale core types operation
RescaleGetRescaleCoreTypesHandler rescale.GetRescaleCoreTypesHandler
// AppGetVersionsHandler sets the operation handler for the get versions operation
AppGetVersionsHandler app.GetVersionsHandler
// WorkspaceGetWorkspacesHandler sets the operation handler for the get workspaces operation
WorkspaceGetWorkspacesHandler workspace.GetWorkspacesHandler
// JobModifyJobHandler sets the operation handler for the modify job operation
JobModifyJobHandler job.ModifyJobHandler
// NotebookModifyNotebookHandler sets the operation handler for the modify notebook operation
NotebookModifyNotebookHandler notebook.ModifyNotebookHandler
// AppPostConfigurationsHandler sets the operation handler for the post configurations operation
AppPostConfigurationsHandler app.PostConfigurationsHandler
// ImagePostNewImageHandler sets the operation handler for the post new image operation
ImagePostNewImageHandler image.PostNewImageHandler
// JobPostNewJobHandler sets the operation handler for the post new job operation
JobPostNewJobHandler job.PostNewJobHandler
// NotebookPostNewNotebookHandler sets the operation handler for the post new notebook operation
NotebookPostNewNotebookHandler notebook.PostNewNotebookHandler
// AppPostNewSessionHandler sets the operation handler for the post new session operation
AppPostNewSessionHandler app.PostNewSessionHandler
// ServeError is called when an error is received, there is a default handler
// but you can set your own with this
ServeError func(http.ResponseWriter, *http.Request, error)
// ServerShutdown is called when the HTTP(S) server is shut down and done
// handling all active connections and does not accept connections any more
ServerShutdown func()
// Custom command line argument groups with their descriptions
CommandLineOptionsGroups []swag.CommandLineOptionsGroup
// User defined logger function.
Logger func(string, ...interface{})
}
// SetDefaultProduces sets the default produces media type
func (o *ScaleShiftAPI) SetDefaultProduces(mediaType string) {
o.defaultProduces = mediaType
}
// SetDefaultConsumes returns the default consumes media type
func (o *ScaleShiftAPI) SetDefaultConsumes(mediaType string) {
o.defaultConsumes = mediaType
}
// SetSpec sets a spec that will be served for the clients.
func (o *ScaleShiftAPI) SetSpec(spec *loads.Document) {
o.spec = spec
}
// DefaultProduces returns the default produces media type
func (o *ScaleShiftAPI) DefaultProduces() string {
return o.defaultProduces
}
// DefaultConsumes returns the default consumes media type
func (o *ScaleShiftAPI) DefaultConsumes() string {
return o.defaultConsumes
}
// Formats returns the registered string formats
func (o *ScaleShiftAPI) Formats() strfmt.Registry {
return o.formats
}
// RegisterFormat registers a custom format validator
func (o *ScaleShiftAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) {
o.formats.Add(name, format, validator)
}
// Validate validates the registrations in the ScaleShiftAPI
func (o *ScaleShiftAPI) Validate() error {
var unregistered []string
if o.JSONConsumer == nil {
unregistered = append(unregistered, "JSONConsumer")
}
if o.JSONProducer == nil {
unregistered = append(unregistered, "JSONProducer")
}
if o.APIAuthorizerAuth == nil {
unregistered = append(unregistered, "AuthorizationAuth")
}
if o.ImageDeleteImageHandler == nil {
unregistered = append(unregistered, "image.DeleteImageHandler")
}
if o.JobDeleteJobHandler == nil {
unregistered = append(unregistered, "job.DeleteJobHandler")
}
if o.NotebookDeleteNotebookHandler == nil {
unregistered = append(unregistered, "notebook.DeleteNotebookHandler")
}
if o.WorkspaceDeleteWorkspaceHandler == nil {
unregistered = append(unregistered, "workspace.DeleteWorkspaceHandler")
}
if o.AppErrorsGetAppErrorsHandler == nil {
unregistered = append(unregistered, "app_errors.GetAppErrorsHandler")
}
if o.AppGetConfigurationsHandler == nil {
unregistered = append(unregistered, "app.GetConfigurationsHandler")
}
if o.AppGetEndpointsHandler == nil {
unregistered = append(unregistered, "app.GetEndpointsHandler")
}
if o.NotebookGetIpythonNotebooksHandler == nil {
unregistered = append(unregistered, "notebook.GetIpythonNotebooksHandler")
}
if o.ImageGetImagesHandler == nil {
unregistered = append(unregistered, "image.GetImagesHandler")
}
if o.JobGetJobDetailHandler == nil {
unregistered = append(unregistered, "job.GetJobDetailHandler")
}
if o.JobGetJobFilesHandler == nil {
unregistered = append(unregistered, "job.GetJobFilesHandler")
}
if o.JobGetJobLogsHandler == nil {
unregistered = append(unregistered, "job.GetJobLogsHandler")
}
if o.JobGetJobsHandler == nil {
unregistered = append(unregistered, "job.GetJobsHandler")
}
if o.RepositoryGetNgcImagesHandler == nil {
unregistered = append(unregistered, "repository.GetNgcImagesHandler")
}
if o.RepositoryGetNgcRepositoriesHandler == nil {
unregistered = append(unregistered, "repository.GetNgcRepositoriesHandler")
}
if o.NotebookGetNotebookDetailsHandler == nil {
unregistered = append(unregistered, "notebook.GetNotebookDetailsHandler")
}
if o.NotebookGetNotebooksHandler == nil {
unregistered = append(unregistered, "notebook.GetNotebooksHandler")
}
if o.RepositoryGetRemoteImagesHandler == nil {
unregistered = append(unregistered, "repository.GetRemoteImagesHandler")
}
if o.RepositoryGetRemoteRepositoriesHandler == nil {
unregistered = append(unregistered, "repository.GetRemoteRepositoriesHandler")
}
if o.RescaleGetRescaleApplicationHandler == nil {
unregistered = append(unregistered, "rescale.GetRescaleApplicationHandler")
}
if o.RescaleGetRescaleApplicationVersionHandler == nil {
unregistered = append(unregistered, "rescale.GetRescaleApplicationVersionHandler")
}
if o.RescaleGetRescaleCoreTypesHandler == nil {
unregistered = append(unregistered, "rescale.GetRescaleCoreTypesHandler")
}
if o.AppGetVersionsHandler == nil {
unregistered = append(unregistered, "app.GetVersionsHandler")
}
if o.WorkspaceGetWorkspacesHandler == nil {
unregistered = append(unregistered, "workspace.GetWorkspacesHandler")
}
if o.JobModifyJobHandler == nil {
unregistered = append(unregistered, "job.ModifyJobHandler")
}
if o.NotebookModifyNotebookHandler == nil {
unregistered = append(unregistered, "notebook.ModifyNotebookHandler")
}
if o.AppPostConfigurationsHandler == nil {
unregistered = append(unregistered, "app.PostConfigurationsHandler")
}
if o.ImagePostNewImageHandler == nil {
unregistered = append(unregistered, "image.PostNewImageHandler")
}
if o.JobPostNewJobHandler == nil {
unregistered = append(unregistered, "job.PostNewJobHandler")
}
if o.NotebookPostNewNotebookHandler == nil {
unregistered = append(unregistered, "notebook.PostNewNotebookHandler")
}
if o.AppPostNewSessionHandler == nil {
unregistered = append(unregistered, "app.PostNewSessionHandler")
}
if len(unregistered) > 0 {
return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", "))
}
return nil
}
// ServeErrorFor gets a error handler for a given operation id
func (o *ScaleShiftAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) {
return o.ServeError
}
// AuthenticatorsFor gets the authenticators for the specified security schemes
func (o *ScaleShiftAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator {
result := make(map[string]runtime.Authenticator)
for name, scheme := range schemes {
switch name {
case "api-authorizer":
result[name] = o.APIKeyAuthenticator(scheme.Name, scheme.In, func(token string) (interface{}, error) {
return o.APIAuthorizerAuth(token)
})
}
}
return result
}
// Authorizer returns the registered authorizer
func (o *ScaleShiftAPI) Authorizer() runtime.Authorizer {
return o.APIAuthorizer
}
// ConsumersFor gets the consumers for the specified media types
func (o *ScaleShiftAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer {
result := make(map[string]runtime.Consumer)
for _, mt := range mediaTypes {
switch mt {
case "application/json":
result["application/json"] = o.JSONConsumer
}
if c, ok := o.customConsumers[mt]; ok {
result[mt] = c
}
}
return result
}
// ProducersFor gets the producers for the specified media types
func (o *ScaleShiftAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer {
result := make(map[string]runtime.Producer)
for _, mt := range mediaTypes {
switch mt {
case "application/json":
result["application/json"] = o.JSONProducer
}
if p, ok := o.customProducers[mt]; ok {
result[mt] = p
}
}
return result
}
// HandlerFor gets a http.Handler for the provided operation method and path
func (o *ScaleShiftAPI) HandlerFor(method, path string) (http.Handler, bool) {
if o.handlers == nil {
return nil, false
}
um := strings.ToUpper(method)
if _, ok := o.handlers[um]; !ok {
return nil, false
}
if path == "/" {
path = ""
}
h, ok := o.handlers[um][path]
return h, ok
}
// Context returns the middleware context for the scale shift API
func (o *ScaleShiftAPI) Context() *middleware.Context {
if o.context == nil {
o.context = middleware.NewRoutableContext(o.spec, o, nil)
}
return o.context
}
func (o *ScaleShiftAPI) initHandlerCache() {
o.Context() // don't care about the result, just that the initialization happened
if o.handlers == nil {
o.handlers = make(map[string]map[string]http.Handler)
}
if o.handlers["DELETE"] == nil {
o.handlers["DELETE"] = make(map[string]http.Handler)
}
o.handlers["DELETE"]["/images"] = image.NewDeleteImage(o.context, o.ImageDeleteImageHandler)
if o.handlers["DELETE"] == nil {
o.handlers["DELETE"] = make(map[string]http.Handler)
}
o.handlers["DELETE"]["/jobs/{id}"] = job.NewDeleteJob(o.context, o.JobDeleteJobHandler)
if o.handlers["DELETE"] == nil {
o.handlers["DELETE"] = make(map[string]http.Handler)
}
o.handlers["DELETE"]["/notebooks/{id}"] = notebook.NewDeleteNotebook(o.context, o.NotebookDeleteNotebookHandler)
if o.handlers["DELETE"] == nil {
o.handlers["DELETE"] = make(map[string]http.Handler)
}
o.handlers["DELETE"]["/workspaces"] = workspace.NewDeleteWorkspace(o.context, o.WorkspaceDeleteWorkspaceHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/errors"] = app_errors.NewGetAppErrors(o.context, o.AppErrorsGetAppErrorsHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/configurations"] = app.NewGetConfigurations(o.context, o.AppGetConfigurationsHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/endpoints"] = app.NewGetEndpoints(o.context, o.AppGetEndpointsHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/notebooks/{id}/ipynbs"] = notebook.NewGetIpythonNotebooks(o.context, o.NotebookGetIpythonNotebooksHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/images"] = image.NewGetImages(o.context, o.ImageGetImagesHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/jobs/{id}"] = job.NewGetJobDetail(o.context, o.JobGetJobDetailHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/jobs/{id}/files"] = job.NewGetJobFiles(o.context, o.JobGetJobFilesHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/jobs/{id}/logs"] = job.NewGetJobLogs(o.context, o.JobGetJobLogsHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/jobs"] = job.NewGetJobs(o.context, o.JobGetJobsHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/nvidia/repositories/{namespace}/images/{id}"] = repository.NewGetNgcImages(o.context, o.RepositoryGetNgcImagesHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/nvidia/repositories"] = repository.NewGetNgcRepositories(o.context, o.RepositoryGetNgcRepositoriesHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/notebooks/{id}"] = notebook.NewGetNotebookDetails(o.context, o.NotebookGetNotebookDetailsHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/notebooks"] = notebook.NewGetNotebooks(o.context, o.NotebookGetNotebooksHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/remote-images/{id}"] = repository.NewGetRemoteImages(o.context, o.RepositoryGetRemoteImagesHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/repositories"] = repository.NewGetRemoteRepositories(o.context, o.RepositoryGetRemoteRepositoriesHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/rescale/applications/{code}"] = rescale.NewGetRescaleApplication(o.context, o.RescaleGetRescaleApplicationHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/rescale/applications/{code}/{version}"] = rescale.NewGetRescaleApplicationVersion(o.context, o.RescaleGetRescaleApplicationVersionHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/rescale/coretypes"] = rescale.NewGetRescaleCoreTypes(o.context, o.RescaleGetRescaleCoreTypesHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/versions"] = app.NewGetVersions(o.context, o.AppGetVersionsHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/workspaces"] = workspace.NewGetWorkspaces(o.context, o.WorkspaceGetWorkspacesHandler)
if o.handlers["PATCH"] == nil {
o.handlers["PATCH"] = make(map[string]http.Handler)
}
o.handlers["PATCH"]["/jobs/{id}"] = job.NewModifyJob(o.context, o.JobModifyJobHandler)
if o.handlers["PATCH"] == nil {
o.handlers["PATCH"] = make(map[string]http.Handler)
}
o.handlers["PATCH"]["/notebooks/{id}"] = notebook.NewModifyNotebook(o.context, o.NotebookModifyNotebookHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/configurations"] = app.NewPostConfigurations(o.context, o.AppPostConfigurationsHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/images"] = image.NewPostNewImage(o.context, o.ImagePostNewImageHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/jobs"] = job.NewPostNewJob(o.context, o.JobPostNewJobHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/notebooks"] = notebook.NewPostNewNotebook(o.context, o.NotebookPostNewNotebookHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/sessions"] = app.NewPostNewSession(o.context, o.AppPostNewSessionHandler)
}
// Serve creates a http handler to serve the API over HTTP
// can be used directly in http.ListenAndServe(":8000", api.Serve(nil))
func (o *ScaleShiftAPI) Serve(builder middleware.Builder) http.Handler {
o.Init()
if o.Middleware != nil {
return o.Middleware(builder)
}
return o.context.APIHandler(builder)
}
// Init allows you to just initialize the handler cache, you can then recompose the middleware as you see fit
func (o *ScaleShiftAPI) Init() {
if len(o.handlers) == 0 {
o.initHandlerCache()
}
}
// RegisterConsumer allows you to add (or override) a consumer for a media type.
func (o *ScaleShiftAPI) RegisterConsumer(mediaType string, consumer runtime.Consumer) {
o.customConsumers[mediaType] = consumer
}
// RegisterProducer allows you to add (or override) a producer for a media type.
func (o *ScaleShiftAPI) RegisterProducer(mediaType string, producer runtime.Producer) {
o.customProducers[mediaType] = producer
}