summaryrefslogtreecommitdiff
path: root/server/operations/weles_api.go
diff options
context:
space:
mode:
Diffstat (limited to 'server/operations/weles_api.go')
-rw-r--r--server/operations/weles_api.go344
1 files changed, 344 insertions, 0 deletions
diff --git a/server/operations/weles_api.go b/server/operations/weles_api.go
new file mode 100644
index 0000000..a997979
--- /dev/null
+++ b/server/operations/weles_api.go
@@ -0,0 +1,344 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+//
+
+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.tizen.org/tools/weles/server/operations/artifacts"
+ "git.tizen.org/tools/weles/server/operations/jobs"
+)
+
+// NewWelesAPI creates a new Weles instance
+func NewWelesAPI(spec *loads.Document) *WelesAPI {
+ return &WelesAPI{
+ 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(),
+ MultipartformConsumer: runtime.DiscardConsumer,
+ JSONProducer: runtime.JSONProducer(),
+ ArtifactsArtifactListerHandler: artifacts.ArtifactListerHandlerFunc(func(params artifacts.ArtifactListerParams) middleware.Responder {
+ return middleware.NotImplemented("operation ArtifactsArtifactLister has not yet been implemented")
+ }),
+ JobsJobCancelerHandler: jobs.JobCancelerHandlerFunc(func(params jobs.JobCancelerParams) middleware.Responder {
+ return middleware.NotImplemented("operation JobsJobCanceler has not yet been implemented")
+ }),
+ JobsJobCreatorHandler: jobs.JobCreatorHandlerFunc(func(params jobs.JobCreatorParams) middleware.Responder {
+ return middleware.NotImplemented("operation JobsJobCreator has not yet been implemented")
+ }),
+ JobsJobListerHandler: jobs.JobListerHandlerFunc(func(params jobs.JobListerParams) middleware.Responder {
+ return middleware.NotImplemented("operation JobsJobLister has not yet been implemented")
+ }),
+ }
+}
+
+/*WelesAPI This is a Weles server. You can find out more about Weles at [http://tbd.tbd](http://tbd.tbd). */
+type WelesAPI 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
+ // MultipartformConsumer registers a consumer for a "multipart/form-data" mime type
+ MultipartformConsumer runtime.Consumer
+
+ // JSONProducer registers a producer for a "application/json" mime type
+ JSONProducer runtime.Producer
+
+ // ArtifactsArtifactListerHandler sets the operation handler for the artifact lister operation
+ ArtifactsArtifactListerHandler artifacts.ArtifactListerHandler
+ // JobsJobCancelerHandler sets the operation handler for the job canceler operation
+ JobsJobCancelerHandler jobs.JobCancelerHandler
+ // JobsJobCreatorHandler sets the operation handler for the job creator operation
+ JobsJobCreatorHandler jobs.JobCreatorHandler
+ // JobsJobListerHandler sets the operation handler for the job lister operation
+ JobsJobListerHandler jobs.JobListerHandler
+
+ // 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 *WelesAPI) SetDefaultProduces(mediaType string) {
+ o.defaultProduces = mediaType
+}
+
+// SetDefaultConsumes returns the default consumes media type
+func (o *WelesAPI) SetDefaultConsumes(mediaType string) {
+ o.defaultConsumes = mediaType
+}
+
+// SetSpec sets a spec that will be served for the clients.
+func (o *WelesAPI) SetSpec(spec *loads.Document) {
+ o.spec = spec
+}
+
+// DefaultProduces returns the default produces media type
+func (o *WelesAPI) DefaultProduces() string {
+ return o.defaultProduces
+}
+
+// DefaultConsumes returns the default consumes media type
+func (o *WelesAPI) DefaultConsumes() string {
+ return o.defaultConsumes
+}
+
+// Formats returns the registered string formats
+func (o *WelesAPI) Formats() strfmt.Registry {
+ return o.formats
+}
+
+// RegisterFormat registers a custom format validator
+func (o *WelesAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) {
+ o.formats.Add(name, format, validator)
+}
+
+// Validate validates the registrations in the WelesAPI
+func (o *WelesAPI) Validate() error {
+ var unregistered []string
+
+ if o.JSONConsumer == nil {
+ unregistered = append(unregistered, "JSONConsumer")
+ }
+
+ if o.MultipartformConsumer == nil {
+ unregistered = append(unregistered, "MultipartformConsumer")
+ }
+
+ if o.JSONProducer == nil {
+ unregistered = append(unregistered, "JSONProducer")
+ }
+
+ if o.ArtifactsArtifactListerHandler == nil {
+ unregistered = append(unregistered, "artifacts.ArtifactListerHandler")
+ }
+
+ if o.JobsJobCancelerHandler == nil {
+ unregistered = append(unregistered, "jobs.JobCancelerHandler")
+ }
+
+ if o.JobsJobCreatorHandler == nil {
+ unregistered = append(unregistered, "jobs.JobCreatorHandler")
+ }
+
+ if o.JobsJobListerHandler == nil {
+ unregistered = append(unregistered, "jobs.JobListerHandler")
+ }
+
+ 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 *WelesAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) {
+ return o.ServeError
+}
+
+// AuthenticatorsFor gets the authenticators for the specified security schemes
+func (o *WelesAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator {
+
+ return nil
+
+}
+
+// Authorizer returns the registered authorizer
+func (o *WelesAPI) Authorizer() runtime.Authorizer {
+
+ return nil
+
+}
+
+// ConsumersFor gets the consumers for the specified media types
+func (o *WelesAPI) 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
+
+ case "multipart/form-data":
+ result["multipart/form-data"] = o.MultipartformConsumer
+
+ }
+
+ if c, ok := o.customConsumers[mt]; ok {
+ result[mt] = c
+ }
+ }
+ return result
+
+}
+
+// ProducersFor gets the producers for the specified media types
+func (o *WelesAPI) 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 *WelesAPI) 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 weles API
+func (o *WelesAPI) Context() *middleware.Context {
+ if o.context == nil {
+ o.context = middleware.NewRoutableContext(o.spec, o, nil)
+ }
+
+ return o.context
+}
+
+func (o *WelesAPI) 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["POST"] == nil {
+ o.handlers["POST"] = make(map[string]http.Handler)
+ }
+ o.handlers["POST"]["/artifacts/list"] = artifacts.NewArtifactLister(o.context, o.ArtifactsArtifactListerHandler)
+
+ if o.handlers["POST"] == nil {
+ o.handlers["POST"] = make(map[string]http.Handler)
+ }
+ o.handlers["POST"]["/jobs/{JobID}/cancel"] = jobs.NewJobCanceler(o.context, o.JobsJobCancelerHandler)
+
+ if o.handlers["POST"] == nil {
+ o.handlers["POST"] = make(map[string]http.Handler)
+ }
+ o.handlers["POST"]["/jobs"] = jobs.NewJobCreator(o.context, o.JobsJobCreatorHandler)
+
+ if o.handlers["POST"] == nil {
+ o.handlers["POST"] = make(map[string]http.Handler)
+ }
+ o.handlers["POST"]["/jobs/list"] = jobs.NewJobLister(o.context, o.JobsJobListerHandler)
+
+}
+
+// Serve creates a http handler to serve the API over HTTP
+// can be used directly in http.ListenAndServe(":8000", api.Serve(nil))
+func (o *WelesAPI) 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 *WelesAPI) Init() {
+ if len(o.handlers) == 0 {
+ o.initHandlerCache()
+ }
+}
+
+// RegisterConsumer allows you to add (or override) a consumer for a media type.
+func (o *WelesAPI) 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 *WelesAPI) RegisterProducer(mediaType string, producer runtime.Producer) {
+ o.customProducers[mediaType] = producer
+}