Files
zeekay 56f560f991
build / build (push) Failing after 0s
rename: ziti → zt across all paths
- Repo names: ziti-* → zt-*
- Go modules: github.com/hanzozt/ziti → github.com/hanzozt/zt
- Docker images: hanzozt/ziti-* → hanzozt/zt-*
- C/Java/JS symbols: ziti_* → zt_*
- File and directory names updated
2026-02-18 18:34:06 -08:00

171 lines
4.9 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 swagger generate command
import (
stderrors "errors"
"io"
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/validate"
"github.com/hanzozt/edge-api/rest_model"
)
// NewEnrollTokenParams creates a new EnrollTokenParams object
//
// There are no default values defined in the spec.
func NewEnrollTokenParams() EnrollTokenParams {
return EnrollTokenParams{}
}
// EnrollTokenParams contains all the bound params for the enroll token operation
// typically these are obtained from a http.Request
//
// swagger:parameters enrollToken
type EnrollTokenParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*An identifying token to enroll with
Required: true
In: header
*/
Authorization string
/*A enrollment request with or without a CSR. Including a CSR indicated an attempt to enroll with certificate
credentials. If no CSR is included, the request is assumed to be a token enrollment request that will
authenticate via tokens.
Required: true
In: body
*/
TokenEnrollmentRequest *rest_model.TokenEnrollmentRequest
/*The id of the token issuer to use for enrollment, optional as long the the token is not opaque
In: header
*/
ZitiTokenIssuerID *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 NewEnrollTokenParams() beforehand.
func (o *EnrollTokenParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if err := o.bindAuthorization(r.Header[http.CanonicalHeaderKey("Authorization")], true, route.Formats); err != nil {
res = append(res, err)
}
if runtime.HasBody(r) {
defer func() {
_ = r.Body.Close()
}()
var body rest_model.TokenEnrollmentRequest
if err := route.Consumer.Consume(r.Body, &body); err != nil {
if stderrors.Is(err, io.EOF) {
res = append(res, errors.Required("tokenEnrollmentRequest", "body", ""))
} else {
res = append(res, errors.NewParseError("tokenEnrollmentRequest", "body", "", err))
}
} else {
// validate body object
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
ctx := validate.WithOperationRequest(r.Context())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.TokenEnrollmentRequest = &body
}
}
} else {
res = append(res, errors.Required("tokenEnrollmentRequest", "body", ""))
}
if err := o.bindZitiTokenIssuerID(r.Header[http.CanonicalHeaderKey("zt-token-issuer-id")], true, route.Formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// bindAuthorization binds and validates parameter Authorization from header.
func (o *EnrollTokenParams) bindAuthorization(rawData []string, hasKey bool, formats strfmt.Registry) error {
if !hasKey {
return errors.Required("Authorization", "header", rawData)
}
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: true
if err := validate.RequiredString("Authorization", "header", raw); err != nil {
return err
}
o.Authorization = raw
return nil
}
// bindZitiTokenIssuerID binds and validates parameter ZitiTokenIssuerID from header.
func (o *EnrollTokenParams) bindZitiTokenIssuerID(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
if raw == "" { // empty values pass all other validations
return nil
}
o.ZitiTokenIssuerID = &raw
return nil
}