mirror of
https://github.com/hanzozt/edge-api.git
synced 2026-10-30 14:44:05 +00:00
Global rebrand of all OpenZiti references to Hanzo ZT: - Go module paths: github.com/openziti/* → github.com/hanzozt/* - Docker images: openziti/* → hanzozt/* - Java packages: org.openziti.* → org.hanzozt.* - Brand: OpenZiti → Hanzo ZT - URLs: openziti.io → hanzozt.dev
243 lines
6.2 KiB
Go
243 lines
6.2 KiB
Go
// Code generated by go-swagger; DO NOT EDIT.
|
|
|
|
//
|
|
// Copyright NetFoundry Inc.
|
|
//
|
|
// 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
|
|
//
|
|
// https://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.
|
|
//
|
|
// __ __ _
|
|
// \ \ / / (_)
|
|
// \ \ /\ / /_ _ _ __ _ __ _ _ __ __ _
|
|
// \ \/ \/ / _` | '__| '_ \| | '_ \ / _` |
|
|
// \ /\ / (_| | | | | | | | | | | (_| | : This file is generated, do not edit it.
|
|
// \/ \/ \__,_|_| |_| |_|_|_| |_|\__, |
|
|
// __/ |
|
|
// |___/
|
|
|
|
package enroll
|
|
|
|
// This file was generated by the swagger tool.
|
|
// Editing this file might prove futile when you re-run the generate command
|
|
|
|
import (
|
|
"context"
|
|
stderrors "errors"
|
|
"net/http"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/runtime/middleware"
|
|
"github.com/go-openapi/strfmt"
|
|
"github.com/go-openapi/swag"
|
|
|
|
"github.com/hanzozt/edge-api/rest_model"
|
|
)
|
|
|
|
// EnrollUpdbHandlerFunc turns a function with the right signature into a enroll updb handler
|
|
type EnrollUpdbHandlerFunc func(EnrollUpdbParams) middleware.Responder
|
|
|
|
// Handle executing the request and returning a response
|
|
func (fn EnrollUpdbHandlerFunc) Handle(params EnrollUpdbParams) middleware.Responder {
|
|
return fn(params)
|
|
}
|
|
|
|
// EnrollUpdbHandler interface for that can handle valid enroll updb params
|
|
type EnrollUpdbHandler interface {
|
|
Handle(EnrollUpdbParams) middleware.Responder
|
|
}
|
|
|
|
// NewEnrollUpdb creates a new http.Handler for the enroll updb operation
|
|
func NewEnrollUpdb(ctx *middleware.Context, handler EnrollUpdbHandler) *EnrollUpdb {
|
|
return &EnrollUpdb{Context: ctx, Handler: handler}
|
|
}
|
|
|
|
/*
|
|
EnrollUpdb swagger:route POST /enroll/updb Enroll enrollUpdb
|
|
|
|
# Enroll an identity via one-time-token
|
|
|
|
Enrolls an identity via a one-time-token to establish an initial username and password combination
|
|
*/
|
|
type EnrollUpdb struct {
|
|
Context *middleware.Context
|
|
Handler EnrollUpdbHandler
|
|
}
|
|
|
|
func (o *EnrollUpdb) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
|
route, rCtx, _ := o.Context.RouteInfo(r)
|
|
if rCtx != nil {
|
|
*r = *rCtx
|
|
}
|
|
var Params = NewEnrollUpdbParams()
|
|
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)
|
|
|
|
}
|
|
|
|
// EnrollUpdbBody enroll updb body
|
|
//
|
|
// swagger:model EnrollUpdbBody
|
|
type EnrollUpdbBody struct {
|
|
|
|
// password
|
|
Password rest_model.Password `json:"password,omitempty"`
|
|
|
|
// username
|
|
Username rest_model.Username `json:"username,omitempty"`
|
|
}
|
|
|
|
// Validate validates this enroll updb body
|
|
func (o *EnrollUpdbBody) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := o.validatePassword(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := o.validateUsername(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (o *EnrollUpdbBody) validatePassword(formats strfmt.Registry) error {
|
|
if swag.IsZero(o.Password) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := o.Password.Validate(formats); err != nil {
|
|
ve := new(errors.Validation)
|
|
if stderrors.As(err, &ve) {
|
|
return ve.ValidateName("updbCredentials" + "." + "password")
|
|
}
|
|
ce := new(errors.CompositeError)
|
|
if stderrors.As(err, &ce) {
|
|
return ce.ValidateName("updbCredentials" + "." + "password")
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (o *EnrollUpdbBody) validateUsername(formats strfmt.Registry) error {
|
|
if swag.IsZero(o.Username) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := o.Username.Validate(formats); err != nil {
|
|
ve := new(errors.Validation)
|
|
if stderrors.As(err, &ve) {
|
|
return ve.ValidateName("updbCredentials" + "." + "username")
|
|
}
|
|
ce := new(errors.CompositeError)
|
|
if stderrors.As(err, &ce) {
|
|
return ce.ValidateName("updbCredentials" + "." + "username")
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ContextValidate validate this enroll updb body based on the context it is used
|
|
func (o *EnrollUpdbBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := o.contextValidatePassword(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := o.contextValidateUsername(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (o *EnrollUpdbBody) contextValidatePassword(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if swag.IsZero(o.Password) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := o.Password.ContextValidate(ctx, formats); err != nil {
|
|
ve := new(errors.Validation)
|
|
if stderrors.As(err, &ve) {
|
|
return ve.ValidateName("updbCredentials" + "." + "password")
|
|
}
|
|
ce := new(errors.CompositeError)
|
|
if stderrors.As(err, &ce) {
|
|
return ce.ValidateName("updbCredentials" + "." + "password")
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (o *EnrollUpdbBody) contextValidateUsername(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if swag.IsZero(o.Username) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := o.Username.ContextValidate(ctx, formats); err != nil {
|
|
ve := new(errors.Validation)
|
|
if stderrors.As(err, &ve) {
|
|
return ve.ValidateName("updbCredentials" + "." + "username")
|
|
}
|
|
ce := new(errors.CompositeError)
|
|
if stderrors.As(err, &ce) {
|
|
return ce.ValidateName("updbCredentials" + "." + "username")
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (o *EnrollUpdbBody) MarshalBinary() ([]byte, error) {
|
|
if o == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(o)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (o *EnrollUpdbBody) UnmarshalBinary(b []byte) error {
|
|
var res EnrollUpdbBody
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*o = res
|
|
return nil
|
|
}
|