diff options
Diffstat (limited to 'golang/gen/restapi/operations')
-rw-r--r-- | golang/gen/restapi/operations/fatcat_api.go | 288 | ||||
-rw-r--r-- | golang/gen/restapi/operations/get_creator_id.go | 58 | ||||
-rw-r--r-- | golang/gen/restapi/operations/get_creator_id_parameters.go | 72 | ||||
-rw-r--r-- | golang/gen/restapi/operations/get_creator_id_responses.go | 116 | ||||
-rw-r--r-- | golang/gen/restapi/operations/get_creator_id_urlbuilder.go | 99 | ||||
-rw-r--r-- | golang/gen/restapi/operations/post_creator.go | 58 | ||||
-rw-r--r-- | golang/gen/restapi/operations/post_creator_parameters.go | 70 | ||||
-rw-r--r-- | golang/gen/restapi/operations/post_creator_responses.go | 116 | ||||
-rw-r--r-- | golang/gen/restapi/operations/post_creator_urlbuilder.go | 87 |
9 files changed, 964 insertions, 0 deletions
diff --git a/golang/gen/restapi/operations/fatcat_api.go b/golang/gen/restapi/operations/fatcat_api.go new file mode 100644 index 00000000..7b60b34f --- /dev/null +++ b/golang/gen/restapi/operations/fatcat_api.go @@ -0,0 +1,288 @@ +// 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" +) + +// NewFatcatAPI creates a new Fatcat instance +func NewFatcatAPI(spec *loads.Document) *FatcatAPI { + return &FatcatAPI{ + 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(), + GetCreatorIDHandler: GetCreatorIDHandlerFunc(func(params GetCreatorIDParams) middleware.Responder { + return middleware.NotImplemented("operation GetCreatorID has not yet been implemented") + }), + PostCreatorHandler: PostCreatorHandlerFunc(func(params PostCreatorParams) middleware.Responder { + return middleware.NotImplemented("operation PostCreator has not yet been implemented") + }), + } +} + +/*FatcatAPI A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata */ +type FatcatAPI 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 + + // GetCreatorIDHandler sets the operation handler for the get creator ID operation + GetCreatorIDHandler GetCreatorIDHandler + // PostCreatorHandler sets the operation handler for the post creator operation + PostCreatorHandler PostCreatorHandler + + // 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 *FatcatAPI) SetDefaultProduces(mediaType string) { + o.defaultProduces = mediaType +} + +// SetDefaultConsumes returns the default consumes media type +func (o *FatcatAPI) SetDefaultConsumes(mediaType string) { + o.defaultConsumes = mediaType +} + +// SetSpec sets a spec that will be served for the clients. +func (o *FatcatAPI) SetSpec(spec *loads.Document) { + o.spec = spec +} + +// DefaultProduces returns the default produces media type +func (o *FatcatAPI) DefaultProduces() string { + return o.defaultProduces +} + +// DefaultConsumes returns the default consumes media type +func (o *FatcatAPI) DefaultConsumes() string { + return o.defaultConsumes +} + +// Formats returns the registered string formats +func (o *FatcatAPI) Formats() strfmt.Registry { + return o.formats +} + +// RegisterFormat registers a custom format validator +func (o *FatcatAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) { + o.formats.Add(name, format, validator) +} + +// Validate validates the registrations in the FatcatAPI +func (o *FatcatAPI) Validate() error { + var unregistered []string + + if o.JSONConsumer == nil { + unregistered = append(unregistered, "JSONConsumer") + } + + if o.JSONProducer == nil { + unregistered = append(unregistered, "JSONProducer") + } + + if o.GetCreatorIDHandler == nil { + unregistered = append(unregistered, "GetCreatorIDHandler") + } + + if o.PostCreatorHandler == nil { + unregistered = append(unregistered, "PostCreatorHandler") + } + + 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 *FatcatAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) { + return o.ServeError +} + +// AuthenticatorsFor gets the authenticators for the specified security schemes +func (o *FatcatAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator { + + return nil + +} + +// Authorizer returns the registered authorizer +func (o *FatcatAPI) Authorizer() runtime.Authorizer { + + return nil + +} + +// ConsumersFor gets the consumers for the specified media types +func (o *FatcatAPI) 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 *FatcatAPI) 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 *FatcatAPI) 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 fatcat API +func (o *FatcatAPI) Context() *middleware.Context { + if o.context == nil { + o.context = middleware.NewRoutableContext(o.spec, o, nil) + } + + return o.context +} + +func (o *FatcatAPI) 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"]["/creator/{id}"] = NewGetCreatorID(o.context, o.GetCreatorIDHandler) + + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/creator"] = NewPostCreator(o.context, o.PostCreatorHandler) + +} + +// Serve creates a http handler to serve the API over HTTP +// can be used directly in http.ListenAndServe(":8000", api.Serve(nil)) +func (o *FatcatAPI) 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 *FatcatAPI) Init() { + if len(o.handlers) == 0 { + o.initHandlerCache() + } +} + +// RegisterConsumer allows you to add (or override) a consumer for a media type. +func (o *FatcatAPI) 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 *FatcatAPI) RegisterProducer(mediaType string, producer runtime.Producer) { + o.customProducers[mediaType] = producer +} diff --git a/golang/gen/restapi/operations/get_creator_id.go b/golang/gen/restapi/operations/get_creator_id.go new file mode 100644 index 00000000..90185374 --- /dev/null +++ b/golang/gen/restapi/operations/get_creator_id.go @@ -0,0 +1,58 @@ +// 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 generate command + +import ( + "net/http" + + middleware "github.com/go-openapi/runtime/middleware" +) + +// GetCreatorIDHandlerFunc turns a function with the right signature into a get creator ID handler +type GetCreatorIDHandlerFunc func(GetCreatorIDParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCreatorIDHandlerFunc) Handle(params GetCreatorIDParams) middleware.Responder { + return fn(params) +} + +// GetCreatorIDHandler interface for that can handle valid get creator ID params +type GetCreatorIDHandler interface { + Handle(GetCreatorIDParams) middleware.Responder +} + +// NewGetCreatorID creates a new http.Handler for the get creator ID operation +func NewGetCreatorID(ctx *middleware.Context, handler GetCreatorIDHandler) *GetCreatorID { + return &GetCreatorID{Context: ctx, Handler: handler} +} + +/*GetCreatorID swagger:route GET /creator/{id} getCreatorId + +GetCreatorID get creator ID API + +*/ +type GetCreatorID struct { + Context *middleware.Context + Handler GetCreatorIDHandler +} + +func (o *GetCreatorID) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewGetCreatorIDParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/golang/gen/restapi/operations/get_creator_id_parameters.go b/golang/gen/restapi/operations/get_creator_id_parameters.go new file mode 100644 index 00000000..f1e338b6 --- /dev/null +++ b/golang/gen/restapi/operations/get_creator_id_parameters.go @@ -0,0 +1,72 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewGetCreatorIDParams creates a new GetCreatorIDParams object +// no default values defined in spec. +func NewGetCreatorIDParams() GetCreatorIDParams { + + return GetCreatorIDParams{} +} + +// GetCreatorIDParams contains all the bound params for the get creator ID operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetCreatorID +type GetCreatorIDParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCreatorIDParams() beforehand. +func (o *GetCreatorIDParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetCreatorIDParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.ID = raw + + return nil +} diff --git a/golang/gen/restapi/operations/get_creator_id_responses.go b/golang/gen/restapi/operations/get_creator_id_responses.go new file mode 100644 index 00000000..4c1cee1b --- /dev/null +++ b/golang/gen/restapi/operations/get_creator_id_responses.go @@ -0,0 +1,116 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + models "git.archive.org/bnewbold/fatcat/golang/gen/models" +) + +// GetCreatorIDOKCode is the HTTP code returned for type GetCreatorIDOK +const GetCreatorIDOKCode int = 200 + +/*GetCreatorIDOK fetch a single creator by id + +swagger:response getCreatorIdOK +*/ +type GetCreatorIDOK struct { + + /* + In: Body + */ + Payload *models.CreatorEntity `json:"body,omitempty"` +} + +// NewGetCreatorIDOK creates GetCreatorIDOK with default headers values +func NewGetCreatorIDOK() *GetCreatorIDOK { + + return &GetCreatorIDOK{} +} + +// WithPayload adds the payload to the get creator Id o k response +func (o *GetCreatorIDOK) WithPayload(payload *models.CreatorEntity) *GetCreatorIDOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get creator Id o k response +func (o *GetCreatorIDOK) SetPayload(payload *models.CreatorEntity) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCreatorIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/*GetCreatorIDDefault generic error response + +swagger:response getCreatorIdDefault +*/ +type GetCreatorIDDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCreatorIDDefault creates GetCreatorIDDefault with default headers values +func NewGetCreatorIDDefault(code int) *GetCreatorIDDefault { + if code <= 0 { + code = 500 + } + + return &GetCreatorIDDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get creator ID default response +func (o *GetCreatorIDDefault) WithStatusCode(code int) *GetCreatorIDDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get creator ID default response +func (o *GetCreatorIDDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the get creator ID default response +func (o *GetCreatorIDDefault) WithPayload(payload *models.Error) *GetCreatorIDDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get creator ID default response +func (o *GetCreatorIDDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCreatorIDDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/golang/gen/restapi/operations/get_creator_id_urlbuilder.go b/golang/gen/restapi/operations/get_creator_id_urlbuilder.go new file mode 100644 index 00000000..8f23373f --- /dev/null +++ b/golang/gen/restapi/operations/get_creator_id_urlbuilder.go @@ -0,0 +1,99 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetCreatorIDURL generates an URL for the get creator ID operation +type GetCreatorIDURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCreatorIDURL) WithBasePath(bp string) *GetCreatorIDURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCreatorIDURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCreatorIDURL) Build() (*url.URL, error) { + var result url.URL + + var _path = "/creator/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("ID is required on GetCreatorIDURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v0" + } + result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCreatorIDURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCreatorIDURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCreatorIDURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCreatorIDURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCreatorIDURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCreatorIDURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/golang/gen/restapi/operations/post_creator.go b/golang/gen/restapi/operations/post_creator.go new file mode 100644 index 00000000..b33694f1 --- /dev/null +++ b/golang/gen/restapi/operations/post_creator.go @@ -0,0 +1,58 @@ +// 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 generate command + +import ( + "net/http" + + middleware "github.com/go-openapi/runtime/middleware" +) + +// PostCreatorHandlerFunc turns a function with the right signature into a post creator handler +type PostCreatorHandlerFunc func(PostCreatorParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PostCreatorHandlerFunc) Handle(params PostCreatorParams) middleware.Responder { + return fn(params) +} + +// PostCreatorHandler interface for that can handle valid post creator params +type PostCreatorHandler interface { + Handle(PostCreatorParams) middleware.Responder +} + +// NewPostCreator creates a new http.Handler for the post creator operation +func NewPostCreator(ctx *middleware.Context, handler PostCreatorHandler) *PostCreator { + return &PostCreator{Context: ctx, Handler: handler} +} + +/*PostCreator swagger:route POST /creator postCreator + +PostCreator post creator API + +*/ +type PostCreator struct { + Context *middleware.Context + Handler PostCreatorHandler +} + +func (o *PostCreator) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewPostCreatorParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/golang/gen/restapi/operations/post_creator_parameters.go b/golang/gen/restapi/operations/post_creator_parameters.go new file mode 100644 index 00000000..f35cf2d5 --- /dev/null +++ b/golang/gen/restapi/operations/post_creator_parameters.go @@ -0,0 +1,70 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + + models "git.archive.org/bnewbold/fatcat/golang/gen/models" +) + +// NewPostCreatorParams creates a new PostCreatorParams object +// no default values defined in spec. +func NewPostCreatorParams() PostCreatorParams { + + return PostCreatorParams{} +} + +// PostCreatorParams contains all the bound params for the post creator operation +// typically these are obtained from a http.Request +// +// swagger:parameters PostCreator +type PostCreatorParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: body + */ + Body *models.CreatorEntity +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPostCreatorParams() beforehand. +func (o *PostCreatorParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.CreatorEntity + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("body", "body", "", err)) + } else { + + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Body = &body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/golang/gen/restapi/operations/post_creator_responses.go b/golang/gen/restapi/operations/post_creator_responses.go new file mode 100644 index 00000000..8f8ea571 --- /dev/null +++ b/golang/gen/restapi/operations/post_creator_responses.go @@ -0,0 +1,116 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + models "git.archive.org/bnewbold/fatcat/golang/gen/models" +) + +// PostCreatorCreatedCode is the HTTP code returned for type PostCreatorCreated +const PostCreatorCreatedCode int = 201 + +/*PostCreatorCreated created + +swagger:response postCreatorCreated +*/ +type PostCreatorCreated struct { + + /* + In: Body + */ + Payload *models.CreatorEntity `json:"body,omitempty"` +} + +// NewPostCreatorCreated creates PostCreatorCreated with default headers values +func NewPostCreatorCreated() *PostCreatorCreated { + + return &PostCreatorCreated{} +} + +// WithPayload adds the payload to the post creator created response +func (o *PostCreatorCreated) WithPayload(payload *models.CreatorEntity) *PostCreatorCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post creator created response +func (o *PostCreatorCreated) SetPayload(payload *models.CreatorEntity) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostCreatorCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/*PostCreatorDefault generic error response + +swagger:response postCreatorDefault +*/ +type PostCreatorDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostCreatorDefault creates PostCreatorDefault with default headers values +func NewPostCreatorDefault(code int) *PostCreatorDefault { + if code <= 0 { + code = 500 + } + + return &PostCreatorDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the post creator default response +func (o *PostCreatorDefault) WithStatusCode(code int) *PostCreatorDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the post creator default response +func (o *PostCreatorDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the post creator default response +func (o *PostCreatorDefault) WithPayload(payload *models.Error) *PostCreatorDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post creator default response +func (o *PostCreatorDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostCreatorDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/golang/gen/restapi/operations/post_creator_urlbuilder.go b/golang/gen/restapi/operations/post_creator_urlbuilder.go new file mode 100644 index 00000000..901edeb6 --- /dev/null +++ b/golang/gen/restapi/operations/post_creator_urlbuilder.go @@ -0,0 +1,87 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// PostCreatorURL generates an URL for the post creator operation +type PostCreatorURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostCreatorURL) WithBasePath(bp string) *PostCreatorURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostCreatorURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PostCreatorURL) Build() (*url.URL, error) { + var result url.URL + + var _path = "/creator" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v0" + } + result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PostCreatorURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PostCreatorURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PostCreatorURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PostCreatorURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PostCreatorURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PostCreatorURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} |