355 lines
14 KiB
355 lines
14 KiB
// 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"
|
|
|
|
"git.jonasfranz.software/JonasFranzDEV/Organizer/restapi/operations/examination_scheduling"
|
|
"git.jonasfranz.software/JonasFranzDEV/Organizer/restapi/operations/replacement_lessons"
|
|
"git.jonasfranz.software/JonasFranzDEV/Organizer/restapi/operations/timetable"
|
|
)
|
|
|
|
// NewOrganizerAPI creates a new Organizer instance
|
|
func NewOrganizerAPI(spec *loads.Document) *OrganizerAPI {
|
|
return &OrganizerAPI{
|
|
handlers: make(map[string]map[string]http.Handler),
|
|
formats: strfmt.Default,
|
|
defaultConsumes: "application/json",
|
|
defaultProduces: "application/json",
|
|
ServerShutdown: func() {},
|
|
spec: spec,
|
|
ServeError: errors.ServeError,
|
|
BasicAuthenticator: security.BasicAuth,
|
|
APIKeyAuthenticator: security.APIKeyAuth,
|
|
BearerAuthenticator: security.BearerAuth,
|
|
JSONConsumer: runtime.JSONConsumer(),
|
|
JSONProducer: runtime.JSONProducer(),
|
|
ReplacementLessonsFindReplacementLessonsHandler: replacement_lessons.FindReplacementLessonsHandlerFunc(func(params replacement_lessons.FindReplacementLessonsParams, principal interface{}) middleware.Responder {
|
|
return middleware.NotImplemented("operation ReplacementLessonsFindReplacementLessons has not yet been implemented")
|
|
}),
|
|
ReplacementLessonsFindReplacementLessonsByDateHandler: replacement_lessons.FindReplacementLessonsByDateHandlerFunc(func(params replacement_lessons.FindReplacementLessonsByDateParams, principal interface{}) middleware.Responder {
|
|
return middleware.NotImplemented("operation ReplacementLessonsFindReplacementLessonsByDate has not yet been implemented")
|
|
}),
|
|
ExaminationSchedulingGetExamsHandler: examination_scheduling.GetExamsHandlerFunc(func(params examination_scheduling.GetExamsParams, principal interface{}) middleware.Responder {
|
|
return middleware.NotImplemented("operation ExaminationSchedulingGetExams has not yet been implemented")
|
|
}),
|
|
ReplacementLessonsGetReplacementHandler: replacement_lessons.GetReplacementHandlerFunc(func(params replacement_lessons.GetReplacementParams, principal interface{}) middleware.Responder {
|
|
return middleware.NotImplemented("operation ReplacementLessonsGetReplacement has not yet been implemented")
|
|
}),
|
|
ReplacementLessonsGetReplacementByCourseHandler: replacement_lessons.GetReplacementByCourseHandlerFunc(func(params replacement_lessons.GetReplacementByCourseParams, principal interface{}) middleware.Responder {
|
|
return middleware.NotImplemented("operation ReplacementLessonsGetReplacementByCourse has not yet been implemented")
|
|
}),
|
|
TimetableGetTimetableHandler: timetable.GetTimetableHandlerFunc(func(params timetable.GetTimetableParams, principal interface{}) middleware.Responder {
|
|
return middleware.NotImplemented("operation TimetableGetTimetable has not yet been implemented")
|
|
}),
|
|
|
|
// Applies when the Authorization header is set with the Basic scheme
|
|
PasswordAuthAuth: func(user string, pass string) (interface{}, error) {
|
|
return nil, errors.NotImplemented("basic auth (passwordAuth) has not yet been implemented")
|
|
},
|
|
|
|
// default authorizer is authorized meaning no requests are blocked
|
|
APIAuthorizer: security.Authorized(),
|
|
}
|
|
}
|
|
|
|
/*OrganizerAPI Dies ist eine API, die es ermöglicht Daten zu Stunden-, Vertretungs-, oder Klausurplänen zu erhalten. */
|
|
type OrganizerAPI struct {
|
|
spec *loads.Document
|
|
context *middleware.Context
|
|
handlers map[string]map[string]http.Handler
|
|
formats strfmt.Registry
|
|
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
|
|
|
|
// PasswordAuthAuth registers a function that takes username and password and returns a principal
|
|
// it performs authentication with basic auth
|
|
PasswordAuthAuth func(string, string) (interface{}, error)
|
|
|
|
// APIAuthorizer provides access control (ACL/RBAC/ABAC) by providing access to the request and authenticated principal
|
|
APIAuthorizer runtime.Authorizer
|
|
|
|
// ReplacementLessonsFindReplacementLessonsHandler sets the operation handler for the find replacement lessons operation
|
|
ReplacementLessonsFindReplacementLessonsHandler replacement_lessons.FindReplacementLessonsHandler
|
|
// ReplacementLessonsFindReplacementLessonsByDateHandler sets the operation handler for the find replacement lessons by date operation
|
|
ReplacementLessonsFindReplacementLessonsByDateHandler replacement_lessons.FindReplacementLessonsByDateHandler
|
|
// ExaminationSchedulingGetExamsHandler sets the operation handler for the get exams operation
|
|
ExaminationSchedulingGetExamsHandler examination_scheduling.GetExamsHandler
|
|
// ReplacementLessonsGetReplacementHandler sets the operation handler for the get replacement operation
|
|
ReplacementLessonsGetReplacementHandler replacement_lessons.GetReplacementHandler
|
|
// ReplacementLessonsGetReplacementByCourseHandler sets the operation handler for the get replacement by course operation
|
|
ReplacementLessonsGetReplacementByCourseHandler replacement_lessons.GetReplacementByCourseHandler
|
|
// TimetableGetTimetableHandler sets the operation handler for the get timetable operation
|
|
TimetableGetTimetableHandler timetable.GetTimetableHandler
|
|
|
|
// 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 *OrganizerAPI) SetDefaultProduces(mediaType string) {
|
|
o.defaultProduces = mediaType
|
|
}
|
|
|
|
// SetDefaultConsumes returns the default consumes media type
|
|
func (o *OrganizerAPI) SetDefaultConsumes(mediaType string) {
|
|
o.defaultConsumes = mediaType
|
|
}
|
|
|
|
// SetSpec sets a spec that will be served for the clients.
|
|
func (o *OrganizerAPI) SetSpec(spec *loads.Document) {
|
|
o.spec = spec
|
|
}
|
|
|
|
// DefaultProduces returns the default produces media type
|
|
func (o *OrganizerAPI) DefaultProduces() string {
|
|
return o.defaultProduces
|
|
}
|
|
|
|
// DefaultConsumes returns the default consumes media type
|
|
func (o *OrganizerAPI) DefaultConsumes() string {
|
|
return o.defaultConsumes
|
|
}
|
|
|
|
// Formats returns the registered string formats
|
|
func (o *OrganizerAPI) Formats() strfmt.Registry {
|
|
return o.formats
|
|
}
|
|
|
|
// RegisterFormat registers a custom format validator
|
|
func (o *OrganizerAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) {
|
|
o.formats.Add(name, format, validator)
|
|
}
|
|
|
|
// Validate validates the registrations in the OrganizerAPI
|
|
func (o *OrganizerAPI) Validate() error {
|
|
var unregistered []string
|
|
|
|
if o.JSONConsumer == nil {
|
|
unregistered = append(unregistered, "JSONConsumer")
|
|
}
|
|
|
|
if o.JSONProducer == nil {
|
|
unregistered = append(unregistered, "JSONProducer")
|
|
}
|
|
|
|
if o.PasswordAuthAuth == nil {
|
|
unregistered = append(unregistered, "PasswordAuthAuth")
|
|
}
|
|
|
|
if o.ReplacementLessonsFindReplacementLessonsHandler == nil {
|
|
unregistered = append(unregistered, "replacement_lessons.FindReplacementLessonsHandler")
|
|
}
|
|
|
|
if o.ReplacementLessonsFindReplacementLessonsByDateHandler == nil {
|
|
unregistered = append(unregistered, "replacement_lessons.FindReplacementLessonsByDateHandler")
|
|
}
|
|
|
|
if o.ExaminationSchedulingGetExamsHandler == nil {
|
|
unregistered = append(unregistered, "examination_scheduling.GetExamsHandler")
|
|
}
|
|
|
|
if o.ReplacementLessonsGetReplacementHandler == nil {
|
|
unregistered = append(unregistered, "replacement_lessons.GetReplacementHandler")
|
|
}
|
|
|
|
if o.ReplacementLessonsGetReplacementByCourseHandler == nil {
|
|
unregistered = append(unregistered, "replacement_lessons.GetReplacementByCourseHandler")
|
|
}
|
|
|
|
if o.TimetableGetTimetableHandler == nil {
|
|
unregistered = append(unregistered, "timetable.GetTimetableHandler")
|
|
}
|
|
|
|
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 *OrganizerAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) {
|
|
return o.ServeError
|
|
}
|
|
|
|
// AuthenticatorsFor gets the authenticators for the specified security schemes
|
|
func (o *OrganizerAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator {
|
|
|
|
result := make(map[string]runtime.Authenticator)
|
|
for name, scheme := range schemes {
|
|
switch name {
|
|
|
|
case "passwordAuth":
|
|
_ = scheme
|
|
result[name] = o.BasicAuthenticator(o.PasswordAuthAuth)
|
|
|
|
}
|
|
}
|
|
return result
|
|
|
|
}
|
|
|
|
// Authorizer returns the registered authorizer
|
|
func (o *OrganizerAPI) Authorizer() runtime.Authorizer {
|
|
|
|
return o.APIAuthorizer
|
|
|
|
}
|
|
|
|
// ConsumersFor gets the consumers for the specified media types
|
|
func (o *OrganizerAPI) 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
|
|
|
|
}
|
|
}
|
|
return result
|
|
|
|
}
|
|
|
|
// ProducersFor gets the producers for the specified media types
|
|
func (o *OrganizerAPI) 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
|
|
|
|
}
|
|
}
|
|
return result
|
|
|
|
}
|
|
|
|
// HandlerFor gets a http.Handler for the provided operation method and path
|
|
func (o *OrganizerAPI) 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 organizer API
|
|
func (o *OrganizerAPI) Context() *middleware.Context {
|
|
if o.context == nil {
|
|
o.context = middleware.NewRoutableContext(o.spec, o, nil)
|
|
}
|
|
|
|
return o.context
|
|
}
|
|
|
|
func (o *OrganizerAPI) 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["GET"] == nil {
|
|
o.handlers["GET"] = make(map[string]http.Handler)
|
|
}
|
|
o.handlers["GET"]["/replacement/findAll"] = replacement_lessons.NewFindReplacementLessons(o.context, o.ReplacementLessonsFindReplacementLessonsHandler)
|
|
|
|
if o.handlers["GET"] == nil {
|
|
o.handlers["GET"] = make(map[string]http.Handler)
|
|
}
|
|
o.handlers["GET"]["/replacement/findByDate"] = replacement_lessons.NewFindReplacementLessonsByDate(o.context, o.ReplacementLessonsFindReplacementLessonsByDateHandler)
|
|
|
|
if o.handlers["GET"] == nil {
|
|
o.handlers["GET"] = make(map[string]http.Handler)
|
|
}
|
|
o.handlers["GET"]["/course/{course}/exams"] = examination_scheduling.NewGetExams(o.context, o.ExaminationSchedulingGetExamsHandler)
|
|
|
|
if o.handlers["GET"] == nil {
|
|
o.handlers["GET"] = make(map[string]http.Handler)
|
|
}
|
|
o.handlers["GET"]["/replacement/{id}"] = replacement_lessons.NewGetReplacement(o.context, o.ReplacementLessonsGetReplacementHandler)
|
|
|
|
if o.handlers["GET"] == nil {
|
|
o.handlers["GET"] = make(map[string]http.Handler)
|
|
}
|
|
o.handlers["GET"]["/course/{course}/replacements"] = replacement_lessons.NewGetReplacementByCourse(o.context, o.ReplacementLessonsGetReplacementByCourseHandler)
|
|
|
|
if o.handlers["GET"] == nil {
|
|
o.handlers["GET"] = make(map[string]http.Handler)
|
|
}
|
|
o.handlers["GET"]["/course/{course}/timetable"] = timetable.NewGetTimetable(o.context, o.TimetableGetTimetableHandler)
|
|
|
|
}
|
|
|
|
// Serve creates a http handler to serve the API over HTTP
|
|
// can be used directly in http.ListenAndServe(":8000", api.Serve(nil))
|
|
func (o *OrganizerAPI) 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 middelware as you see fit
|
|
func (o *OrganizerAPI) Init() {
|
|
if len(o.handlers) == 0 {
|
|
o.initHandlerCache()
|
|
}
|
|
}
|
|
|