// Code generated by go-swagger; DO NOT EDIT. package agent // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the generate command import ( "context" "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/go-openapi/validate" "github.com/openziti/zrok/rest_model_zrok" ) // RemoteAccessHandlerFunc turns a function with the right signature into a remote access handler type RemoteAccessHandlerFunc func(RemoteAccessParams, *rest_model_zrok.Principal) middleware.Responder // Handle executing the request and returning a response func (fn RemoteAccessHandlerFunc) Handle(params RemoteAccessParams, principal *rest_model_zrok.Principal) middleware.Responder { return fn(params, principal) } // RemoteAccessHandler interface for that can handle valid remote access params type RemoteAccessHandler interface { Handle(RemoteAccessParams, *rest_model_zrok.Principal) middleware.Responder } // NewRemoteAccess creates a new http.Handler for the remote access operation func NewRemoteAccess(ctx *middleware.Context, handler RemoteAccessHandler) *RemoteAccess { return &RemoteAccess{Context: ctx, Handler: handler} } /* RemoteAccess swagger:route POST /agent/access agent remoteAccess RemoteAccess remote access API */ type RemoteAccess struct { Context *middleware.Context Handler RemoteAccessHandler } func (o *RemoteAccess) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { *r = *rCtx } var Params = NewRemoteAccessParams() uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { *r = *aCtx } var principal *rest_model_zrok.Principal if uprinc != nil { principal = uprinc.(*rest_model_zrok.Principal) // this is really a rest_model_zrok.Principal, I promise } 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, principal) // actually handle the request o.Context.Respond(rw, r, route.Produces, route, res) } // RemoteAccessBody remote access body // // swagger:model RemoteAccessBody type RemoteAccessBody struct { // auto address AutoAddress string `json:"autoAddress,omitempty"` // auto end port // Maximum: 65535 // Minimum: 1 AutoEndPort int64 `json:"autoEndPort,omitempty"` // auto mode AutoMode bool `json:"autoMode,omitempty"` // auto start port // Maximum: 65535 // Minimum: 1 AutoStartPort int64 `json:"autoStartPort,omitempty"` // bind address BindAddress string `json:"bindAddress,omitempty"` // env z Id EnvZID string `json:"envZId,omitempty"` // response headers ResponseHeaders []string `json:"responseHeaders"` // token Token string `json:"token,omitempty"` } // Validate validates this remote access body func (o *RemoteAccessBody) Validate(formats strfmt.Registry) error { var res []error if err := o.validateAutoEndPort(formats); err != nil { res = append(res, err) } if err := o.validateAutoStartPort(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (o *RemoteAccessBody) validateAutoEndPort(formats strfmt.Registry) error { if swag.IsZero(o.AutoEndPort) { // not required return nil } if err := validate.MinimumInt("body"+"."+"autoEndPort", "body", o.AutoEndPort, 1, false); err != nil { return err } if err := validate.MaximumInt("body"+"."+"autoEndPort", "body", o.AutoEndPort, 65535, false); err != nil { return err } return nil } func (o *RemoteAccessBody) validateAutoStartPort(formats strfmt.Registry) error { if swag.IsZero(o.AutoStartPort) { // not required return nil } if err := validate.MinimumInt("body"+"."+"autoStartPort", "body", o.AutoStartPort, 1, false); err != nil { return err } if err := validate.MaximumInt("body"+"."+"autoStartPort", "body", o.AutoStartPort, 65535, false); err != nil { return err } return nil } // ContextValidate validates this remote access body based on context it is used func (o *RemoteAccessBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil } // MarshalBinary interface implementation func (o *RemoteAccessBody) MarshalBinary() ([]byte, error) { if o == nil { return nil, nil } return swag.WriteJSON(o) } // UnmarshalBinary interface implementation func (o *RemoteAccessBody) UnmarshalBinary(b []byte) error { var res RemoteAccessBody if err := swag.ReadJSON(b, &res); err != nil { return err } *o = res return nil } // RemoteAccessOKBody remote access o k body // // swagger:model RemoteAccessOKBody type RemoteAccessOKBody struct { // frontend token FrontendToken string `json:"frontendToken,omitempty"` } // Validate validates this remote access o k body func (o *RemoteAccessOKBody) Validate(formats strfmt.Registry) error { return nil } // ContextValidate validates this remote access o k body based on context it is used func (o *RemoteAccessOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil } // MarshalBinary interface implementation func (o *RemoteAccessOKBody) MarshalBinary() ([]byte, error) { if o == nil { return nil, nil } return swag.WriteJSON(o) } // UnmarshalBinary interface implementation func (o *RemoteAccessOKBody) UnmarshalBinary(b []byte) error { var res RemoteAccessOKBody if err := swag.ReadJSON(b, &res); err != nil { return err } *o = res return nil }