mirror of
https://github.com/openziti/ziti.git
synced 2026-10-13 23:59:53 +00:00
Merge pull request openziti/fabric#288 from openziti/rest-mgmt
Add xweb based REST API for the fabric
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package build
|
||||
|
||||
var defaultBuildInfo = defaultInfo{}
|
||||
var info Info = defaultBuildInfo
|
||||
|
||||
func GetBuildInfo() Info {
|
||||
return info
|
||||
}
|
||||
|
||||
func InitBuildInfo(buildInfo Info) {
|
||||
if info == defaultBuildInfo {
|
||||
info = buildInfo
|
||||
}
|
||||
}
|
||||
|
||||
type Info interface {
|
||||
Version() string
|
||||
Revision() string
|
||||
BuildDate() string
|
||||
Branch() string
|
||||
}
|
||||
|
||||
type defaultInfo struct{}
|
||||
|
||||
func (d defaultInfo) Version() string {
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
func (d defaultInfo) Revision() string {
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
func (d defaultInfo) BuildDate() string {
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
func (d defaultInfo) Branch() string {
|
||||
return "unknown"
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/openziti/fabric/controller/apierror"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Responder interface {
|
||||
Respond(data interface{}, httpStatus int)
|
||||
RespondWithProducer(producer runtime.Producer, data interface{}, httpStatus int)
|
||||
RespondWithEmptyOk()
|
||||
RespondWithError(err error)
|
||||
RespondWithApiError(err *errorz.ApiError)
|
||||
SetProducer(producer runtime.Producer)
|
||||
GetProducer() runtime.Producer
|
||||
RespondWithCouldNotReadBody(err error)
|
||||
RespondWithCouldNotParseBody(err error)
|
||||
RespondWithValidationErrors(errors *apierror.ValidationErrors)
|
||||
RespondWithNotFound()
|
||||
RespondWithNotFoundWithCause(cause error)
|
||||
RespondWithFieldError(fe *errorz.FieldError)
|
||||
}
|
||||
|
||||
type ResponseMapper interface {
|
||||
EmptyOkData() interface{}
|
||||
MapApiError(requestId string, err *errorz.ApiError) interface{}
|
||||
}
|
||||
|
||||
type RequestContext interface {
|
||||
Responder
|
||||
GetId() string
|
||||
GetBody() []byte
|
||||
GetRequest() *http.Request
|
||||
GetResponseWriter() http.ResponseWriter
|
||||
SetEntityId(id string)
|
||||
SetEntitySubId(id string)
|
||||
GetEntityId() (string, error)
|
||||
GetEntitySubId() (string, error)
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type RequestContextImpl struct {
|
||||
Responder
|
||||
Id string
|
||||
ResponseWriter http.ResponseWriter
|
||||
Request *http.Request
|
||||
entityId string
|
||||
entitySubId string
|
||||
Body []byte
|
||||
}
|
||||
|
||||
const (
|
||||
IdPropertyName = "id"
|
||||
SubIdPropertyName = "subId"
|
||||
)
|
||||
|
||||
func (rc *RequestContextImpl) GetId() string {
|
||||
return rc.Id
|
||||
}
|
||||
|
||||
func (rc *RequestContextImpl) GetBody() []byte {
|
||||
return rc.Body
|
||||
}
|
||||
|
||||
func (rc *RequestContextImpl) GetRequest() *http.Request {
|
||||
return rc.Request
|
||||
}
|
||||
|
||||
func (rc *RequestContextImpl) GetResponseWriter() http.ResponseWriter {
|
||||
return rc.ResponseWriter
|
||||
}
|
||||
|
||||
func (rc *RequestContextImpl) SetEntityId(id string) {
|
||||
rc.entityId = id
|
||||
}
|
||||
|
||||
func (rc *RequestContextImpl) SetEntitySubId(id string) {
|
||||
rc.entitySubId = id
|
||||
}
|
||||
|
||||
func (rc *RequestContextImpl) GetEntityId() (string, error) {
|
||||
if rc.entityId == "" {
|
||||
return "", errors.New("id not found")
|
||||
}
|
||||
return rc.entityId, nil
|
||||
}
|
||||
|
||||
func (rc *RequestContextImpl) GetEntitySubId() (string, error) {
|
||||
if rc.entitySubId == "" {
|
||||
return "", errors.New("subId not found")
|
||||
}
|
||||
|
||||
return rc.entitySubId, nil
|
||||
}
|
||||
|
||||
// ContextKey is used a custom type to avoid accidental context key collisions
|
||||
type ContextKey string
|
||||
|
||||
const ZitiContextKey = ContextKey("context")
|
||||
|
||||
func AddRequestContextToHttpContext(r *http.Request, rc RequestContext) {
|
||||
ctx := context.WithValue(r.Context(), ZitiContextKey, rc)
|
||||
*r = *r.WithContext(ctx)
|
||||
}
|
||||
|
||||
func GetRequestContextFromHttpContext(r *http.Request) (RequestContext, error) {
|
||||
val := r.Context().Value(ZitiContextKey)
|
||||
if val == nil {
|
||||
return nil, fmt.Errorf("value for key %s no found in context", ZitiContextKey)
|
||||
}
|
||||
|
||||
requestContext := val.(RequestContext)
|
||||
|
||||
if requestContext == nil {
|
||||
return nil, fmt.Errorf("value for key %s is not a request context", ZitiContextKey)
|
||||
}
|
||||
|
||||
return requestContext, nil
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/openziti/foundation/common/constants"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func WrapCorsHandler(innerHandler http.Handler) http.Handler {
|
||||
corsOpts := []handlers.CORSOption{
|
||||
handlers.AllowedOrigins([]string{"*"}),
|
||||
handlers.OptionStatusCode(200),
|
||||
handlers.AllowedHeaders([]string{
|
||||
"content-type",
|
||||
"Accept",
|
||||
constants.ZitiSession,
|
||||
}),
|
||||
handlers.AllowedMethods([]string{
|
||||
http.MethodGet,
|
||||
http.MethodHead,
|
||||
http.MethodPost,
|
||||
http.MethodPut,
|
||||
http.MethodPatch,
|
||||
http.MethodDelete}),
|
||||
handlers.AllowCredentials(),
|
||||
}
|
||||
|
||||
return handlers.CORS(corsOpts...)(innerHandler)
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/openziti/fabric/controller/apierror"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type JsonFields map[string]bool
|
||||
|
||||
func (j JsonFields) IsUpdated(key string) bool {
|
||||
_, ok := j[key]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (j JsonFields) AddField(key string) {
|
||||
j[key] = true
|
||||
}
|
||||
|
||||
func (j JsonFields) ConcatNestedNames() JsonFields {
|
||||
for key, val := range j {
|
||||
if strings.Contains(key, ".") {
|
||||
delete(j, key)
|
||||
key = strings.ReplaceAll(key, ".", "")
|
||||
j[key] = val
|
||||
}
|
||||
}
|
||||
return j
|
||||
}
|
||||
|
||||
func (j JsonFields) FilterMaps(mapNames ...string) JsonFields {
|
||||
nameMap := map[string]string{}
|
||||
for _, name := range mapNames {
|
||||
nameMap[name] = name + "."
|
||||
}
|
||||
for key := range j {
|
||||
for name, dotName := range nameMap {
|
||||
if strings.HasPrefix(key, dotName) {
|
||||
delete(j, key)
|
||||
j[name] = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return j
|
||||
}
|
||||
|
||||
func GetFields(body []byte) (JsonFields, error) {
|
||||
jsonMap := map[string]interface{}{}
|
||||
err := json.Unmarshal(body, &jsonMap)
|
||||
|
||||
if err != nil {
|
||||
return nil, apierror.GetJsonParseError(err, body)
|
||||
}
|
||||
|
||||
resultMap := JsonFields{}
|
||||
GetJsonFields("", jsonMap, resultMap)
|
||||
return resultMap, nil
|
||||
}
|
||||
|
||||
func GetJsonFields(prefix string, m map[string]interface{}, result JsonFields) {
|
||||
for k, v := range m {
|
||||
name := k
|
||||
if subMap, ok := v.(map[string]interface{}); ok {
|
||||
GetJsonFields(prefix+name+".", subMap, result)
|
||||
} else {
|
||||
isSet := v != nil
|
||||
result[prefix+name] = isSet
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/apierror"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func NewResponder(rc RequestContext, mapper ResponseMapper) *ResponderImpl {
|
||||
return &ResponderImpl{
|
||||
rc: rc,
|
||||
mapper: mapper,
|
||||
producer: runtime.JSONProducer(),
|
||||
}
|
||||
}
|
||||
|
||||
type ResponderImpl struct {
|
||||
rc RequestContext
|
||||
mapper ResponseMapper
|
||||
producer runtime.Producer
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) SetProducer(producer runtime.Producer) {
|
||||
responder.producer = producer
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) GetProducer() runtime.Producer {
|
||||
return responder.producer
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) RespondWithCouldNotReadBody(err error) {
|
||||
responder.RespondWithApiError(apierror.NewCouldNotReadBody(err))
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) RespondWithCouldNotParseBody(err error) {
|
||||
responder.RespondWithApiError(apierror.NewCouldNotParseBody(err))
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) RespondWithValidationErrors(errors *apierror.ValidationErrors) {
|
||||
responder.RespondWithApiError(errorz.NewCouldNotValidate(errors))
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) RespondWithNotFound() {
|
||||
responder.RespondWithApiError(errorz.NewNotFound())
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) RespondWithNotFoundWithCause(cause error) {
|
||||
apiErr := errorz.NewNotFound()
|
||||
apiErr.Cause = cause
|
||||
responder.RespondWithApiError(apiErr)
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) RespondWithFieldError(fe *errorz.FieldError) {
|
||||
responder.RespondWithApiError(errorz.NewFieldApiError(errorz.NewFieldError(fe.Reason, fe.FieldName, fe.FieldValue)))
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) RespondWithEmptyOk() {
|
||||
responder.Respond(responder.mapper.EmptyOkData(), http.StatusOK)
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) Respond(data interface{}, httpStatus int) {
|
||||
responder.RespondWithProducer(responder.GetProducer(), data, httpStatus)
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) RespondWithProducer(producer runtime.Producer, data interface{}, httpStatus int) {
|
||||
w := responder.rc.GetResponseWriter()
|
||||
w.WriteHeader(httpStatus)
|
||||
|
||||
err := producer.Produce(w, data)
|
||||
|
||||
if err != nil {
|
||||
pfxlog.Logger().WithError(err).
|
||||
WithField("requestId", responder.rc.GetId()).
|
||||
WithField("path", responder.rc.GetRequest().URL.Path).
|
||||
Debug("could not respond, producer errored, possible timeout")
|
||||
}
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) RespondWithError(err error) {
|
||||
var apiError *errorz.ApiError
|
||||
var ok bool
|
||||
|
||||
if apiError, ok = err.(*errorz.ApiError); !ok {
|
||||
apiError = errorz.NewUnhandled(err)
|
||||
}
|
||||
|
||||
responder.RespondWithApiError(apiError)
|
||||
}
|
||||
|
||||
func (responder *ResponderImpl) RespondWithApiError(apiError *errorz.ApiError) {
|
||||
data := responder.mapper.MapApiError(responder.rc.GetId(), apiError)
|
||||
|
||||
producer := responder.rc.GetProducer()
|
||||
w := responder.rc.GetResponseWriter()
|
||||
|
||||
if canRespondWithJson(responder.rc.GetRequest()) {
|
||||
producer = runtime.JSONProducer()
|
||||
w.Header().Set("content-type", "application/json")
|
||||
}
|
||||
|
||||
w.WriteHeader(apiError.Status)
|
||||
err := producer.Produce(w, data)
|
||||
|
||||
if err != nil {
|
||||
pfxlog.Logger().WithError(err).WithField("requestId", responder.rc.GetId()).Error("could not respond with error, producer errored")
|
||||
}
|
||||
}
|
||||
|
||||
func canRespondWithJson(request *http.Request) bool {
|
||||
//if we can return JSON for errors we should as they provide the most
|
||||
//information
|
||||
|
||||
canReturnJson := false
|
||||
|
||||
acceptHeaders := request.Header.Values("accept")
|
||||
if len(acceptHeaders) == 0 {
|
||||
//no accept == "*/*"
|
||||
canReturnJson = true
|
||||
} else {
|
||||
for _, acceptHeader := range acceptHeaders { //look at all headers values
|
||||
if canReturnJson {
|
||||
break
|
||||
}
|
||||
|
||||
for _, value := range strings.Split(acceptHeader, ",") { //each header can have multiple mimeTypes
|
||||
mimeType := strings.Split(value, ";")[0] //remove quotients
|
||||
mimeType = strings.TrimSpace(mimeType)
|
||||
|
||||
if mimeType == "*/*" || mimeType == "application/json" {
|
||||
canReturnJson = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return canReturnJson
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/foundation/util/debugz"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
"net/http"
|
||||
"path"
|
||||
goruntime "runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TimeoutHandler(h http.Handler, dt time.Duration, apiErr *errorz.ApiError, mapper ResponseMapper) http.Handler {
|
||||
return &timeoutHandler{
|
||||
handler: h,
|
||||
apiError: apiErr,
|
||||
dt: dt,
|
||||
producer: runtime.JSONProducer(),
|
||||
resopnseMapper: mapper,
|
||||
}
|
||||
}
|
||||
|
||||
type timeoutHandler struct {
|
||||
handler http.Handler
|
||||
dt time.Duration
|
||||
apiError *errorz.ApiError
|
||||
producer runtime.Producer
|
||||
resopnseMapper ResponseMapper
|
||||
}
|
||||
|
||||
func (h *timeoutHandler) errorBody(w http.ResponseWriter, r *http.Request) error {
|
||||
if h.apiError != nil {
|
||||
requestId := ""
|
||||
rc, _ := GetRequestContextFromHttpContext(r)
|
||||
if rc != nil {
|
||||
requestId = rc.GetId()
|
||||
}
|
||||
apiError := h.resopnseMapper.MapApiError(requestId, h.apiError)
|
||||
err := h.producer.Produce(w, apiError)
|
||||
|
||||
return err
|
||||
}
|
||||
return errors.New("no timout api error specified")
|
||||
}
|
||||
|
||||
func (h *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, cancelCtx := context.WithTimeout(r.Context(), h.dt)
|
||||
defer cancelCtx()
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
done := make(chan struct{})
|
||||
tw := &timeoutWriter{
|
||||
w: w,
|
||||
h: make(http.Header),
|
||||
req: r,
|
||||
}
|
||||
panicChan := make(chan interface{}, 1)
|
||||
go func() {
|
||||
defer func() {
|
||||
if p := recover(); p != nil {
|
||||
pfxlog.Logger().Errorf("panic caught by timeout handler: %v\n%v", p, debugz.GenerateLocalStack())
|
||||
panicChan <- p
|
||||
}
|
||||
}()
|
||||
h.handler.ServeHTTP(tw, r)
|
||||
close(done)
|
||||
}()
|
||||
select {
|
||||
case <-panicChan:
|
||||
case <-done:
|
||||
tw.mu.Lock()
|
||||
defer tw.mu.Unlock()
|
||||
dst := w.Header()
|
||||
for k, vv := range tw.h {
|
||||
dst[k] = vv
|
||||
}
|
||||
if !tw.wroteHeader {
|
||||
tw.code = http.StatusOK
|
||||
}
|
||||
w.WriteHeader(tw.code)
|
||||
_, _ = w.Write(tw.wbuf.Bytes())
|
||||
case <-ctx.Done():
|
||||
tw.mu.Lock()
|
||||
defer tw.mu.Unlock()
|
||||
w.Header().Set("content-type", "application/json")
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
_ = h.errorBody(w, r)
|
||||
tw.timedOut = true
|
||||
}
|
||||
}
|
||||
|
||||
type timeoutWriter struct {
|
||||
w http.ResponseWriter
|
||||
h http.Header
|
||||
wbuf bytes.Buffer
|
||||
req *http.Request
|
||||
|
||||
mu sync.Mutex
|
||||
timedOut bool
|
||||
wroteHeader bool
|
||||
code int
|
||||
}
|
||||
|
||||
var _ http.Pusher = (*timeoutWriter)(nil)
|
||||
|
||||
func (tw *timeoutWriter) Push(target string, opts *http.PushOptions) error {
|
||||
if pusher, ok := tw.w.(http.Pusher); ok {
|
||||
return pusher.Push(target, opts)
|
||||
}
|
||||
return http.ErrNotSupported
|
||||
}
|
||||
|
||||
func (tw *timeoutWriter) Header() http.Header { return tw.h }
|
||||
|
||||
func (tw *timeoutWriter) Write(p []byte) (int, error) {
|
||||
tw.mu.Lock()
|
||||
defer tw.mu.Unlock()
|
||||
if tw.timedOut {
|
||||
return 0, http.ErrHandlerTimeout
|
||||
}
|
||||
if !tw.wroteHeader {
|
||||
tw.writeHeaderLocked(http.StatusOK)
|
||||
}
|
||||
return tw.wbuf.Write(p)
|
||||
}
|
||||
|
||||
func (tw *timeoutWriter) writeHeaderLocked(code int) {
|
||||
checkWriteHeaderCode(code)
|
||||
|
||||
switch {
|
||||
case tw.timedOut:
|
||||
return
|
||||
case tw.wroteHeader:
|
||||
if tw.req != nil {
|
||||
caller := relevantCaller()
|
||||
pfxlog.Logger().Errorf("http: superfluous response.WriteHeader call from %s (%s:%d)", caller.Function, path.Base(caller.File), caller.Line)
|
||||
}
|
||||
default:
|
||||
tw.wroteHeader = true
|
||||
tw.code = code
|
||||
}
|
||||
}
|
||||
|
||||
func (tw *timeoutWriter) WriteHeader(code int) {
|
||||
tw.mu.Lock()
|
||||
defer tw.mu.Unlock()
|
||||
tw.writeHeaderLocked(code)
|
||||
}
|
||||
|
||||
func checkWriteHeaderCode(code int) {
|
||||
if code < 100 || code > 999 {
|
||||
panic(fmt.Sprintf("invalid WriteHeader code %v", code))
|
||||
}
|
||||
}
|
||||
|
||||
func relevantCaller() goruntime.Frame {
|
||||
pc := make([]uintptr, 16)
|
||||
n := goruntime.Callers(1, pc)
|
||||
frames := goruntime.CallersFrames(pc[:n])
|
||||
var frame goruntime.Frame
|
||||
for {
|
||||
frame, more := frames.Next()
|
||||
if !strings.HasPrefix(frame.Function, "net/http.") && !strings.HasPrefix(frame.Function, "github.com/openziti/fabric/controller/api_impl/timeout") {
|
||||
return frame
|
||||
}
|
||||
if !more {
|
||||
break
|
||||
}
|
||||
}
|
||||
return frame
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
"path"
|
||||
)
|
||||
|
||||
func BaseEntityToRestModel(entity models.Entity, linkFactory LinksFactory) rest_model.BaseEntity {
|
||||
id := entity.GetId()
|
||||
createdAt := strfmt.DateTime(entity.GetCreatedAt())
|
||||
updatedAt := strfmt.DateTime(entity.GetUpdatedAt())
|
||||
|
||||
tags := rest_model.Tags{
|
||||
SubTags: entity.GetTags(),
|
||||
}
|
||||
ret := rest_model.BaseEntity{
|
||||
ID: &id,
|
||||
CreatedAt: &createdAt,
|
||||
UpdatedAt: &updatedAt,
|
||||
Links: linkFactory.Links(entity),
|
||||
Tags: &tags,
|
||||
}
|
||||
|
||||
if ret.Tags.SubTags == nil {
|
||||
ret.Tags.SubTags = map[string]interface{}{}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type FullLinkFactory interface {
|
||||
LinksFactory
|
||||
SelfLinkFactory
|
||||
}
|
||||
|
||||
type LinksFactory interface {
|
||||
Links(entity LinkEntity) rest_model.Links
|
||||
EntityName() string
|
||||
}
|
||||
|
||||
type SelfLinkFactory interface {
|
||||
SelfLink(entity models.Entity) rest_model.Link
|
||||
}
|
||||
|
||||
type CreateLinkFactory interface {
|
||||
SelfLinkFromId(id string) rest_model.Link
|
||||
}
|
||||
|
||||
func NewBasicLinkFactory(entityName string) *BasicLinkFactory {
|
||||
return &BasicLinkFactory{entityName: entityName}
|
||||
}
|
||||
|
||||
type BasicLinkFactory struct {
|
||||
entityName string
|
||||
}
|
||||
|
||||
func (factory *BasicLinkFactory) SelfLinkFromId(id string) rest_model.Link {
|
||||
return NewLink(factory.SelfUrlString(id))
|
||||
}
|
||||
|
||||
func (factory *BasicLinkFactory) SelfUrlString(id string) string {
|
||||
//path.Join will remove the ./ prefix in its "clean" operation
|
||||
return "./" + path.Join(factory.entityName, id)
|
||||
}
|
||||
|
||||
func (factory *BasicLinkFactory) SelfLink(entity LinkEntity) rest_model.Link {
|
||||
return NewLink(factory.SelfUrlString(entity.GetId()))
|
||||
}
|
||||
|
||||
func (factory *BasicLinkFactory) Links(entity LinkEntity) rest_model.Links {
|
||||
return rest_model.Links{
|
||||
EntityNameSelf: factory.SelfLink(entity),
|
||||
}
|
||||
}
|
||||
|
||||
func (factory BasicLinkFactory) NewNestedLink(entity LinkEntity, elem ...string) rest_model.Link {
|
||||
elem = append([]string{factory.SelfUrlString(entity.GetId())}, elem...)
|
||||
//path.Join will remove the ./ prefix in its "clean" operation
|
||||
return NewLink("./" + path.Join(elem...))
|
||||
}
|
||||
|
||||
func (factory *BasicLinkFactory) EntityName() string {
|
||||
return factory.entityName
|
||||
}
|
||||
|
||||
type LinkEntity interface {
|
||||
GetId() string
|
||||
}
|
||||
|
||||
func ToEntityRef(name string, entity LinkEntity, factory LinksFactory) *rest_model.EntityRef {
|
||||
return &rest_model.EntityRef{
|
||||
Links: factory.Links(entity),
|
||||
Entity: factory.EntityName(),
|
||||
ID: entity.GetId(),
|
||||
Name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func NewLink(path string) rest_model.Link {
|
||||
href := strfmt.URI(path)
|
||||
return rest_model.Link{
|
||||
Href: &href,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,415 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/apierror"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
"github.com/openziti/foundation/storage/ast"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
"net/http"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
const (
|
||||
EntityNameSelf = "self"
|
||||
)
|
||||
|
||||
func modelToApi(network *network.Network, rc api.RequestContext, mapper ModelToApiMapper, es []models.Entity) ([]interface{}, error) {
|
||||
apiEntities := make([]interface{}, 0)
|
||||
|
||||
for _, e := range es {
|
||||
al, err := mapper(network, rc, e)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiEntities = append(apiEntities, al)
|
||||
}
|
||||
|
||||
return apiEntities, nil
|
||||
}
|
||||
|
||||
func ListWithHandler(n *network.Network, rc api.RequestContext, lister models.EntityRetriever, mapper ModelToApiMapper) {
|
||||
ListWithQueryF(n, rc, lister, mapper, lister.BasePreparedList)
|
||||
}
|
||||
|
||||
type queryF func(query ast.Query) (*models.EntityListResult, error)
|
||||
|
||||
func ListWithQueryF(n *network.Network, rc api.RequestContext, lister models.EntityRetriever, mapper ModelToApiMapper, qf queryF) {
|
||||
ListWithQueryFAndCollector(n, rc, lister, mapper, defaultToListEnvelope, qf)
|
||||
}
|
||||
|
||||
func defaultToListEnvelope(data []interface{}, meta *rest_model.Meta) interface{} {
|
||||
return rest_model.Empty{
|
||||
Data: data,
|
||||
Meta: meta,
|
||||
}
|
||||
}
|
||||
|
||||
type ApiListEnvelopeFactory func(data []interface{}, meta *rest_model.Meta) interface{}
|
||||
type ApiEntityEnvelopeFactory func(data interface{}, meta *rest_model.Meta) interface{}
|
||||
|
||||
func ListWithQueryFAndCollector(n *network.Network, rc api.RequestContext, lister models.EntityRetriever, mapper ModelToApiMapper, toEnvelope ApiListEnvelopeFactory, qf queryF) {
|
||||
ListWithEnvelopeFactory(rc, toEnvelope, func(rc api.RequestContext, queryOptions *PublicQueryOptions) (*QueryResult, error) {
|
||||
// validate that the submitted query is only using public symbols. The query options may contain an final
|
||||
// query which has been modified with additional filters
|
||||
query, err := queryOptions.getFullQuery(lister.GetStore())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result, err := qf(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiEntities, err := modelToApi(n, rc, mapper, result.GetEntities())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewQueryResult(apiEntities, result.GetMetaData()), nil
|
||||
})
|
||||
}
|
||||
|
||||
type modelListF func(rc api.RequestContext, queryOptions *PublicQueryOptions) (*QueryResult, error)
|
||||
|
||||
func List(rc api.RequestContext, f modelListF) {
|
||||
ListWithEnvelopeFactory(rc, defaultToListEnvelope, f)
|
||||
}
|
||||
|
||||
func ListWithEnvelopeFactory(rc api.RequestContext, toEnvelope ApiListEnvelopeFactory, f modelListF) {
|
||||
qo, err := GetModelQueryOptionsFromRequest(rc.GetRequest())
|
||||
|
||||
if err != nil {
|
||||
log := pfxlog.Logger()
|
||||
log.WithField("cause", err).Error("could not build query options")
|
||||
rc.RespondWithError(err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := f(rc, qo)
|
||||
|
||||
if err != nil {
|
||||
log := pfxlog.Logger()
|
||||
log.WithField("cause", err).Error("could not convert list")
|
||||
rc.RespondWithError(err)
|
||||
return
|
||||
}
|
||||
|
||||
if result.Result == nil {
|
||||
result.Result = []interface{}{}
|
||||
}
|
||||
|
||||
meta := &rest_model.Meta{
|
||||
Pagination: &rest_model.Pagination{
|
||||
Limit: &result.Limit,
|
||||
Offset: &result.Offset,
|
||||
TotalCount: &result.Count,
|
||||
},
|
||||
FilterableFields: result.FilterableFields,
|
||||
}
|
||||
|
||||
switch reflect.TypeOf(result.Result).Kind() {
|
||||
case reflect.Slice:
|
||||
slice := reflect.ValueOf(result.Result)
|
||||
|
||||
//noinspection GoPreferNilSlice
|
||||
elements := []interface{}{}
|
||||
for i := 0; i < slice.Len(); i++ {
|
||||
elem := slice.Index(i)
|
||||
elements = append(elements, elem.Interface())
|
||||
}
|
||||
|
||||
envelope := toEnvelope(elements, meta)
|
||||
rc.Respond(envelope, http.StatusOK)
|
||||
default:
|
||||
envelope := toEnvelope([]interface{}{result.Result}, meta)
|
||||
rc.Respond(envelope, http.StatusOK)
|
||||
}
|
||||
}
|
||||
|
||||
type ModelCreateF func() (string, error)
|
||||
|
||||
func Create(rc api.RequestContext, linkFactory CreateLinkFactory, creator ModelCreateF) {
|
||||
CreateWithResponder(rc, linkFactory, creator)
|
||||
}
|
||||
|
||||
func CreateWithResponder(rsp api.Responder, linkFactory CreateLinkFactory, creator ModelCreateF) {
|
||||
id, err := creator()
|
||||
if err != nil {
|
||||
if boltz.IsErrNotFoundErr(err) {
|
||||
rsp.RespondWithNotFoundWithCause(err)
|
||||
return
|
||||
}
|
||||
|
||||
if fe, ok := err.(*errorz.FieldError); ok {
|
||||
rsp.RespondWithFieldError(fe)
|
||||
return
|
||||
}
|
||||
|
||||
if sve, ok := err.(*apierror.ValidationErrors); ok {
|
||||
rsp.RespondWithValidationErrors(sve)
|
||||
return
|
||||
}
|
||||
|
||||
rsp.RespondWithError(err)
|
||||
return
|
||||
}
|
||||
|
||||
RespondWithCreatedId(rsp, id, linkFactory.SelfLinkFromId(id))
|
||||
}
|
||||
|
||||
func DetailWithHandler(network *network.Network, rc api.RequestContext, loader models.EntityRetriever, mapper ModelToApiMapper) {
|
||||
Detail(rc, func(rc api.RequestContext, id string) (interface{}, error) {
|
||||
entity, err := loader.BaseLoad(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mapper(network, rc, entity)
|
||||
})
|
||||
}
|
||||
|
||||
type ModelDetailF func(rc api.RequestContext, id string) (interface{}, error)
|
||||
|
||||
func Detail(rc api.RequestContext, f ModelDetailF) {
|
||||
id, err := rc.GetEntityId()
|
||||
|
||||
if err != nil {
|
||||
pfxlog.Logger().Error(err)
|
||||
rc.RespondWithError(err)
|
||||
return
|
||||
}
|
||||
|
||||
apiEntity, err := f(rc, id)
|
||||
|
||||
if err != nil {
|
||||
if boltz.IsErrNotFoundErr(err) {
|
||||
rc.RespondWithNotFoundWithCause(err)
|
||||
return
|
||||
}
|
||||
|
||||
pfxlog.Logger().WithField("id", id).WithError(err).Error("could not load entity by id")
|
||||
rc.RespondWithError(err)
|
||||
return
|
||||
}
|
||||
|
||||
RespondWithOk(rc, apiEntity, &rest_model.Meta{})
|
||||
}
|
||||
|
||||
type ModelDeleteF func(rc api.RequestContext, id string) error
|
||||
|
||||
type DeleteHandler interface {
|
||||
Delete(id string) error
|
||||
}
|
||||
|
||||
type DeleteHandlerF func(id string) error
|
||||
|
||||
func (self DeleteHandlerF) Delete(id string) error {
|
||||
return self(id)
|
||||
}
|
||||
|
||||
func DeleteWithHandler(rc api.RequestContext, deleteHandler DeleteHandler) {
|
||||
Delete(rc, func(rc api.RequestContext, id string) error {
|
||||
return deleteHandler.Delete(id)
|
||||
})
|
||||
}
|
||||
|
||||
func Delete(rc api.RequestContext, deleteF ModelDeleteF) {
|
||||
id, err := rc.GetEntityId()
|
||||
|
||||
if err != nil {
|
||||
log := pfxlog.Logger()
|
||||
log.Error(err)
|
||||
rc.RespondWithError(err)
|
||||
return
|
||||
}
|
||||
|
||||
err = deleteF(rc, id)
|
||||
|
||||
if err != nil {
|
||||
if boltz.IsErrNotFoundErr(err) {
|
||||
rc.RespondWithNotFoundWithCause(err)
|
||||
} else {
|
||||
rc.RespondWithError(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
rc.RespondWithEmptyOk()
|
||||
}
|
||||
|
||||
type ModelUpdateF func(id string) error
|
||||
|
||||
func Update(rc api.RequestContext, updateF ModelUpdateF) {
|
||||
UpdateAllowEmptyBody(rc, updateF)
|
||||
}
|
||||
|
||||
func UpdateAllowEmptyBody(rc api.RequestContext, updateF ModelUpdateF) {
|
||||
id, err := rc.GetEntityId()
|
||||
|
||||
if err != nil {
|
||||
log := pfxlog.Logger()
|
||||
log.Error(err)
|
||||
rc.RespondWithError(fmt.Errorf("error during update, retrieving id: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
if err = updateF(id); err != nil {
|
||||
if boltz.IsErrNotFoundErr(err) {
|
||||
rc.RespondWithNotFoundWithCause(err)
|
||||
return
|
||||
}
|
||||
|
||||
if fe, ok := err.(*errorz.FieldError); ok {
|
||||
rc.RespondWithFieldError(fe)
|
||||
return
|
||||
}
|
||||
|
||||
if sve, ok := err.(*apierror.ValidationErrors); ok {
|
||||
rc.RespondWithValidationErrors(sve)
|
||||
return
|
||||
}
|
||||
|
||||
rc.RespondWithError(err)
|
||||
return
|
||||
}
|
||||
|
||||
rc.RespondWithEmptyOk()
|
||||
}
|
||||
|
||||
type ModelPatchF func(id string, fields api.JsonFields) error
|
||||
|
||||
func Patch(rc api.RequestContext, patchF ModelPatchF) {
|
||||
id, err := rc.GetEntityId()
|
||||
|
||||
if err != nil {
|
||||
log := pfxlog.Logger()
|
||||
log.Error(err)
|
||||
rc.RespondWithError(fmt.Errorf("error during patch, retrieving id: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
jsonFields, err := api.GetFields(rc.GetBody())
|
||||
if err != nil {
|
||||
rc.RespondWithCouldNotParseBody(err)
|
||||
}
|
||||
|
||||
err = patchF(id, jsonFields)
|
||||
if err != nil {
|
||||
if boltz.IsErrNotFoundErr(err) {
|
||||
rc.RespondWithNotFoundWithCause(err)
|
||||
return
|
||||
}
|
||||
|
||||
if fe, ok := err.(*errorz.FieldError); ok {
|
||||
rc.RespondWithFieldError(fe)
|
||||
return
|
||||
}
|
||||
|
||||
if sve, ok := err.(*apierror.ValidationErrors); ok {
|
||||
rc.RespondWithValidationErrors(sve)
|
||||
return
|
||||
}
|
||||
|
||||
rc.RespondWithError(err)
|
||||
return
|
||||
}
|
||||
|
||||
rc.RespondWithEmptyOk()
|
||||
}
|
||||
|
||||
// type ListAssocF func(string, func(models.Entity)) error
|
||||
type listAssocF func(rc api.RequestContext, id string, queryOptions *PublicQueryOptions) (*QueryResult, error)
|
||||
|
||||
func ListAssociationWithHandler(n *network.Network, rc api.RequestContext, lister models.EntityRetriever, associationLoader models.EntityRetriever, mapper ModelToApiMapper) {
|
||||
ListAssociations(rc, func(rc api.RequestContext, id string, queryOptions *PublicQueryOptions) (*QueryResult, error) {
|
||||
// validate that the submitted query is only using public symbols. The query options may contain an final
|
||||
// query which has been modified with additional filters
|
||||
query, err := queryOptions.getFullQuery(associationLoader.GetStore())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result, err := lister.BasePreparedListAssociated(id, associationLoader, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiEntities, err := modelToApi(n, rc, mapper, result.GetEntities())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewQueryResult(apiEntities, result.GetMetaData()), nil
|
||||
})
|
||||
}
|
||||
|
||||
func ListAssociations(rc api.RequestContext, listF listAssocF) {
|
||||
id, err := rc.GetEntityId()
|
||||
|
||||
if err != nil {
|
||||
log := pfxlog.Logger()
|
||||
logErr := fmt.Errorf("could not find id property: %v", api.IdPropertyName)
|
||||
log.WithField("property", api.IdPropertyName).Error(logErr)
|
||||
rc.RespondWithError(err)
|
||||
return
|
||||
}
|
||||
|
||||
queryOptions, err := GetModelQueryOptionsFromRequest(rc.GetRequest())
|
||||
|
||||
if err != nil {
|
||||
rc.RespondWithError(err)
|
||||
}
|
||||
|
||||
result, err := listF(rc, id, queryOptions)
|
||||
|
||||
if err != nil {
|
||||
if boltz.IsErrNotFoundErr(err) {
|
||||
rc.RespondWithNotFoundWithCause(err)
|
||||
return
|
||||
}
|
||||
|
||||
log := pfxlog.Logger()
|
||||
log.WithField("cause", err).Error("could not convert list")
|
||||
rc.RespondWithError(err)
|
||||
return
|
||||
}
|
||||
|
||||
if result.Result == nil {
|
||||
result.Result = []interface{}{}
|
||||
}
|
||||
|
||||
meta := &rest_model.Meta{
|
||||
Pagination: &rest_model.Pagination{
|
||||
Limit: &result.Limit,
|
||||
Offset: &result.Offset,
|
||||
TotalCount: &result.Count,
|
||||
},
|
||||
FilterableFields: result.FilterableFields,
|
||||
}
|
||||
|
||||
RespondWithOk(rc, result.Result, meta)
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
const EntityNameCircuit = "circuits"
|
||||
|
||||
var CircuitLinkFactory = NewCircuitLinkFactory()
|
||||
|
||||
type CircuitLinkFactoryIml struct {
|
||||
BasicLinkFactory
|
||||
}
|
||||
|
||||
func NewCircuitLinkFactory() *CircuitLinkFactoryIml {
|
||||
return &CircuitLinkFactoryIml{
|
||||
BasicLinkFactory: *NewBasicLinkFactory(EntityNameCircuit),
|
||||
}
|
||||
}
|
||||
|
||||
func (factory *CircuitLinkFactoryIml) Links(entity LinkEntity) rest_model.Links {
|
||||
links := factory.BasicLinkFactory.Links(entity)
|
||||
links[EntityNameTerminator] = factory.NewNestedLink(entity, EntityNameTerminator)
|
||||
links[EntityNameService] = factory.NewNestedLink(entity, EntityNameService)
|
||||
return links
|
||||
}
|
||||
|
||||
func MapCircuitToRestModel(_ *network.Network, _ api.RequestContext, circuit *network.Circuit) (*rest_model.CircuitDetail, error) {
|
||||
path := &rest_model.CircuitDetailPath{}
|
||||
for _, node := range circuit.Path.Nodes {
|
||||
path.Nodes = append(path.Nodes, ToEntityRef(node.Name, node, RouterLinkFactory))
|
||||
}
|
||||
for _, link := range circuit.Path.Links {
|
||||
path.Links = append(path.Nodes, ToEntityRef(link.Id, link, LinkLinkFactory))
|
||||
}
|
||||
ret := &rest_model.CircuitDetail{
|
||||
ID: &circuit.Id,
|
||||
ClientID: circuit.ClientId,
|
||||
Path: path,
|
||||
Service: ToEntityRef(circuit.Service.Name, circuit.Service, ServiceLinkFactory),
|
||||
Terminator: ToEntityRef(circuit.Terminator.GetId(), circuit.Terminator, TerminatorLinkFactory),
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
"github.com/openziti/fabric/rest_server/operations"
|
||||
"github.com/openziti/fabric/rest_server/operations/circuit"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func init() {
|
||||
r := NewCircuitRouter()
|
||||
AddRouter(r)
|
||||
}
|
||||
|
||||
type CircuitRouter struct {
|
||||
BasePath string
|
||||
}
|
||||
|
||||
func NewCircuitRouter() *CircuitRouter {
|
||||
return &CircuitRouter{
|
||||
BasePath: "/" + EntityNameCircuit,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *CircuitRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper) {
|
||||
fabricApi.CircuitDetailCircuitHandler = circuit.DetailCircuitHandlerFunc(func(params circuit.DetailCircuitParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.Detail, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.CircuitListCircuitsHandler = circuit.ListCircuitsHandlerFunc(func(params circuit.ListCircuitsParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.ListCircuits, params.HTTPRequest, "", "")
|
||||
})
|
||||
|
||||
fabricApi.CircuitDeleteCircuitHandler = circuit.DeleteCircuitHandlerFunc(func(params circuit.DeleteCircuitParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(func(n *network.Network, rc api.RequestContext) { r.Delete(n, rc, params) }, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
}
|
||||
|
||||
func (r *CircuitRouter) ListCircuits(n *network.Network, rc api.RequestContext) {
|
||||
ListWithEnvelopeFactory(rc, defaultToListEnvelope, func(rc api.RequestContext, queryOptions *PublicQueryOptions) (*QueryResult, error) {
|
||||
circuits := n.GetAllCircuits()
|
||||
sort.Slice(circuits, func(i, j int) bool {
|
||||
return circuits[i].Id < circuits[j].Id
|
||||
})
|
||||
apiCircuits := make([]*rest_model.CircuitDetail, 0, len(circuits))
|
||||
for _, modelCircuit := range circuits {
|
||||
apiCircuit, err := MapCircuitToRestModel(n, rc, modelCircuit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
apiCircuits = append(apiCircuits, apiCircuit)
|
||||
}
|
||||
result := &QueryResult{
|
||||
Result: apiCircuits,
|
||||
Count: int64(len(circuits)),
|
||||
Limit: -1,
|
||||
Offset: 0,
|
||||
FilterableFields: nil,
|
||||
}
|
||||
return result, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (r *CircuitRouter) Detail(n *network.Network, rc api.RequestContext) {
|
||||
Detail(rc, func(rc api.RequestContext, id string) (interface{}, error) {
|
||||
l, found := n.GetCircuit(id)
|
||||
if !found {
|
||||
return nil, boltz.NewNotFoundError("circuit", "id", id)
|
||||
}
|
||||
apiCircuit, err := MapCircuitToRestModel(n, rc, l)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiCircuit, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (r *CircuitRouter) Delete(network *network.Network, rc api.RequestContext, p circuit.DeleteCircuitParams) {
|
||||
DeleteWithHandler(rc, DeleteHandlerF(func(id string) error {
|
||||
return network.RemoveCircuit(id, p.Options.Immediate)
|
||||
}))
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/idgen"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func NewRequestContext(rw http.ResponseWriter, r *http.Request) api.RequestContext {
|
||||
rid := idgen.New()
|
||||
|
||||
body, _ := ioutil.ReadAll(r.Body)
|
||||
r.Body = ioutil.NopCloser(bytes.NewReader(body))
|
||||
|
||||
requestContext := &api.RequestContextImpl{
|
||||
Id: rid,
|
||||
Body: body,
|
||||
ResponseWriter: rw,
|
||||
Request: r,
|
||||
}
|
||||
|
||||
requestContext.Responder = api.NewResponder(requestContext, fabricResponseMapper{})
|
||||
|
||||
return requestContext
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
openApiErrors "github.com/go-openapi/errors"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
apierror2 "github.com/openziti/fabric/controller/apierror"
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Wrapper for the OpenAPI REST server to allow the the Edge API Error message responses to be used
|
||||
func ServeError(rw http.ResponseWriter, r *http.Request, inErr error) {
|
||||
if openApiError, ok := inErr.(openApiErrors.Error); ok {
|
||||
//openApiErrors from the Open API framework mean that we never hit any of the Edge logic and thus
|
||||
//do not have any context established (i.e. no request id)
|
||||
var apiError *errorz.ApiError
|
||||
if openApiError.Code() == http.StatusUnprocessableEntity {
|
||||
// triggered by validation failures and consumer errors
|
||||
var newApiError *errorz.ApiError
|
||||
|
||||
if compositeError, ok := openApiError.(*openApiErrors.CompositeError); ok {
|
||||
if len(compositeError.Errors) > 0 {
|
||||
//validation errors
|
||||
if validationError, ok := compositeError.Errors[0].(*openApiErrors.Validation); ok {
|
||||
newApiError = errorz.NewCouldNotValidate(validationError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// only other option is could not parse
|
||||
if newApiError == nil {
|
||||
newApiError = apierror2.NewCouldNotParseBody(openApiError)
|
||||
}
|
||||
|
||||
apiError = newApiError
|
||||
|
||||
} else if openApiError.Code() == http.StatusNotFound {
|
||||
// handle open API openApiErrors we have existing ApiErrors for
|
||||
apiError = errorz.NewNotFound()
|
||||
} else if openApiError.Code() == http.StatusMethodNotAllowed {
|
||||
apiError = apierror2.NewMethodNotAllowed()
|
||||
} else if openApiError.Code() == http.StatusUnauthorized {
|
||||
apiError = errorz.NewUnauthorized()
|
||||
} else if openApiError.Code() >= 600 && openApiError.Code() < 700 {
|
||||
//openapi defines error codes 601+ for validation errors
|
||||
apiError = errorz.NewCouldNotValidate(inErr)
|
||||
|
||||
} else {
|
||||
apiError = errorz.NewUnhandled(openApiError)
|
||||
}
|
||||
apiError.Cause = openApiError
|
||||
|
||||
NewRequestContext(rw, r).RespondWithApiError(apiError)
|
||||
return
|
||||
}
|
||||
|
||||
requestContext, err := api.GetRequestContextFromHttpContext(r)
|
||||
if requestContext == nil || err != nil {
|
||||
pfxlog.Logger().WithError(err).Error("failed to retrieve request context")
|
||||
requestContext = NewRequestContext(rw, r)
|
||||
}
|
||||
|
||||
requestContext.RespondWithError(inErr)
|
||||
}
|
||||
|
||||
func ToRestModel(e *errorz.ApiError, requestId string) *rest_model.APIError {
|
||||
ret := &rest_model.APIError{
|
||||
Args: nil,
|
||||
Code: e.Code,
|
||||
Message: e.Message,
|
||||
RequestID: requestId,
|
||||
}
|
||||
|
||||
if e.Cause != nil {
|
||||
|
||||
//unwrap first error in composite error
|
||||
compositeErr, ok := e.Cause.(*openApiErrors.CompositeError)
|
||||
for ok {
|
||||
e.Cause = compositeErr.Errors[0]
|
||||
compositeErr, ok = e.Cause.(*openApiErrors.CompositeError)
|
||||
}
|
||||
|
||||
if causeApiError, ok := e.Cause.(*errorz.ApiError); ok {
|
||||
//standard apierror
|
||||
ret.Cause = &rest_model.APIErrorCause{
|
||||
APIError: *ToRestModel(causeApiError, requestId),
|
||||
}
|
||||
} else if causeJsonSchemaError, ok := e.Cause.(*apierror2.ValidationErrors); ok {
|
||||
//only possible from config type JSON schema validation
|
||||
ret.Cause = &rest_model.APIErrorCause{
|
||||
APIFieldError: rest_model.APIFieldError{
|
||||
Field: causeJsonSchemaError.Errors[0].Field,
|
||||
Reason: causeJsonSchemaError.Errors[0].Error(),
|
||||
Value: fmt.Sprintf("%v", causeJsonSchemaError.Errors[0].Value),
|
||||
},
|
||||
}
|
||||
} else if causeFieldErr, ok := e.Cause.(*errorz.FieldError); ok {
|
||||
//authenticator modules and enrollment only
|
||||
//todo: see if we can remove this by not using FieldError
|
||||
ret.Cause = &rest_model.APIErrorCause{
|
||||
APIFieldError: rest_model.APIFieldError{
|
||||
Field: causeFieldErr.FieldName,
|
||||
Value: fmt.Sprintf("%v", causeFieldErr.FieldValue),
|
||||
Reason: causeFieldErr.Reason,
|
||||
},
|
||||
}
|
||||
if ret.Code == errorz.InvalidFieldCode {
|
||||
ret.Code = errorz.CouldNotValidateCode
|
||||
ret.Message = errorz.CouldNotValidateMessage
|
||||
}
|
||||
|
||||
} else if causeFieldErr, ok := e.Cause.(*openApiErrors.Validation); ok {
|
||||
//open api validation errors
|
||||
ret.Cause = &rest_model.APIErrorCause{
|
||||
APIFieldError: rest_model.APIFieldError{
|
||||
Field: causeFieldErr.Name,
|
||||
Reason: causeFieldErr.Error(),
|
||||
Value: fmt.Sprintf("%v", causeFieldErr.Value),
|
||||
},
|
||||
}
|
||||
ret.Code = errorz.CouldNotValidateCode
|
||||
ret.Message = errorz.CouldNotValidateMessage
|
||||
|
||||
} else if genericErr, ok := e.Cause.(apierror2.GenericCauseError); ok {
|
||||
ret.Cause = &rest_model.APIErrorCause{
|
||||
APIError: rest_model.APIError{
|
||||
Data: genericErr.DataMap,
|
||||
Message: genericErr.Error(),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
ret.Cause = &rest_model.APIErrorCause{
|
||||
APIError: rest_model.APIError{
|
||||
Code: errorz.UnhandledCode,
|
||||
Message: e.Cause.Error(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
const EntityNameLink = "links"
|
||||
|
||||
var LinkLinkFactory = NewLinkLinkFactory()
|
||||
|
||||
type LinkLinkFactoryIml struct {
|
||||
BasicLinkFactory
|
||||
}
|
||||
|
||||
func NewLinkLinkFactory() *LinkLinkFactoryIml {
|
||||
return &LinkLinkFactoryIml{
|
||||
BasicLinkFactory: *NewBasicLinkFactory(EntityNameLink),
|
||||
}
|
||||
}
|
||||
|
||||
func (factory *LinkLinkFactoryIml) Links(entity LinkEntity) rest_model.Links {
|
||||
links := factory.BasicLinkFactory.Links(entity)
|
||||
return links
|
||||
}
|
||||
|
||||
func MapLinkToRestModel(_ *network.Network, _ api.RequestContext, link *network.Link) (*rest_model.LinkDetail, error) {
|
||||
staticCost := int64(link.StaticCost)
|
||||
linkState := link.CurrentState()
|
||||
linkStateStr := ""
|
||||
if linkState != nil {
|
||||
linkStateStr = linkState.Mode.String()
|
||||
}
|
||||
|
||||
down := link.IsDown()
|
||||
|
||||
ret := &rest_model.LinkDetail{
|
||||
Cost: &link.Cost,
|
||||
DestLatency: &link.DstLatency,
|
||||
DestRouter: ToEntityRef(link.Dst.Name, link.Dst, RouterLinkFactory),
|
||||
Down: &down,
|
||||
ID: &link.Id,
|
||||
SourceLatency: &link.SrcLatency,
|
||||
SourceRouter: ToEntityRef(link.Src.Name, link.Src, RouterLinkFactory),
|
||||
State: &linkStateStr,
|
||||
StaticCost: &staticCost,
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
"github.com/openziti/fabric/rest_server/operations"
|
||||
"github.com/openziti/fabric/rest_server/operations/link"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func init() {
|
||||
r := NewLinkRouter()
|
||||
AddRouter(r)
|
||||
}
|
||||
|
||||
type LinkRouter struct {
|
||||
BasePath string
|
||||
}
|
||||
|
||||
func NewLinkRouter() *LinkRouter {
|
||||
return &LinkRouter{
|
||||
BasePath: "/" + EntityNameLink,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *LinkRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper) {
|
||||
fabricApi.LinkDetailLinkHandler = link.DetailLinkHandlerFunc(func(params link.DetailLinkParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.Detail, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.LinkListLinksHandler = link.ListLinksHandlerFunc(func(params link.ListLinksParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.ListLinks, params.HTTPRequest, "", "")
|
||||
})
|
||||
|
||||
fabricApi.LinkPatchLinkHandler = link.PatchLinkHandlerFunc(func(params link.PatchLinkParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(func(n *network.Network, rc api.RequestContext) { r.Patch(n, rc, params) }, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
}
|
||||
|
||||
func (r *LinkRouter) ListLinks(n *network.Network, rc api.RequestContext) {
|
||||
ListWithEnvelopeFactory(rc, defaultToListEnvelope, func(rc api.RequestContext, queryOptions *PublicQueryOptions) (*QueryResult, error) {
|
||||
links := n.GetAllLinks()
|
||||
sort.Slice(links, func(i, j int) bool {
|
||||
return links[i].Id < links[j].Id
|
||||
})
|
||||
apiLinks := make([]*rest_model.LinkDetail, 0, len(links))
|
||||
for _, modelLink := range links {
|
||||
apiLink, err := MapLinkToRestModel(n, rc, modelLink)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
apiLinks = append(apiLinks, apiLink)
|
||||
}
|
||||
result := &QueryResult{
|
||||
Result: apiLinks,
|
||||
Count: int64(len(links)),
|
||||
Limit: -1,
|
||||
Offset: 0,
|
||||
FilterableFields: nil,
|
||||
}
|
||||
return result, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (r *LinkRouter) Detail(n *network.Network, rc api.RequestContext) {
|
||||
Detail(rc, func(rc api.RequestContext, id string) (interface{}, error) {
|
||||
l, found := n.GetLink(id)
|
||||
if !found {
|
||||
return nil, boltz.NewNotFoundError("link", "id", id)
|
||||
}
|
||||
apiLink, err := MapLinkToRestModel(n, rc, l)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiLink, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (r *LinkRouter) Patch(n *network.Network, rc api.RequestContext, params link.PatchLinkParams) {
|
||||
Patch(rc, func(id string, fields api.JsonFields) error {
|
||||
l, found := n.GetLink(id)
|
||||
if !found {
|
||||
return boltz.NewNotFoundError("link", "id", id)
|
||||
}
|
||||
if fields.IsUpdated("staticCost") {
|
||||
l.SetStaticCost(int32(params.Link.StaticCost))
|
||||
}
|
||||
if fields.IsUpdated("down") {
|
||||
l.SetDown(params.Link.Down)
|
||||
}
|
||||
n.LinkChanged(l)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/go-openapi/loads"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/rest_client"
|
||||
"github.com/openziti/fabric/rest_server"
|
||||
"github.com/openziti/fabric/rest_server/operations"
|
||||
"github.com/openziti/fabric/xweb"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
ServerHeader = "server"
|
||||
)
|
||||
|
||||
var _ xweb.WebHandlerFactory = &ManagementApiFactory{}
|
||||
|
||||
type ManagementApiFactory struct {
|
||||
InitFunc func(managementApi *ManagementApiHandler) error
|
||||
network *network.Network
|
||||
routerId identity.Identity
|
||||
}
|
||||
|
||||
func (factory ManagementApiFactory) Validate(_ *xweb.Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewManagementApiFactory(routerId identity.Identity, network *network.Network) *ManagementApiFactory {
|
||||
return &ManagementApiFactory{
|
||||
network: network,
|
||||
routerId: routerId,
|
||||
}
|
||||
}
|
||||
|
||||
func (factory ManagementApiFactory) Binding() string {
|
||||
return FabricApiBinding
|
||||
}
|
||||
|
||||
func (factory ManagementApiFactory) New(_ *xweb.WebListener, options map[interface{}]interface{}) (xweb.WebHandler, error) {
|
||||
managementSpec, err := loads.Embedded(rest_server.SwaggerJSON, rest_server.FlatSwaggerJSON)
|
||||
if err != nil {
|
||||
pfxlog.Logger().Fatalln(err)
|
||||
}
|
||||
|
||||
fabricAPI := operations.NewZitiFabricAPI(managementSpec)
|
||||
fabricAPI.ServeError = ServeError
|
||||
|
||||
if requestWrapper == nil {
|
||||
requestWrapper = &FabricRequestWrapper{
|
||||
network: factory.network,
|
||||
}
|
||||
}
|
||||
|
||||
for _, router := range routers {
|
||||
router.Register(fabricAPI, requestWrapper)
|
||||
}
|
||||
|
||||
managementApiHandler, err := NewManagementApiHandler(fabricAPI, options)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if factory.InitFunc != nil {
|
||||
if err := factory.InitFunc(managementApiHandler); err != nil {
|
||||
return nil, fmt.Errorf("error running on init func: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return managementApiHandler, nil
|
||||
}
|
||||
|
||||
type ManagementApiHandler struct {
|
||||
fabricApi *operations.ZitiFabricAPI
|
||||
handler http.Handler
|
||||
options map[interface{}]interface{}
|
||||
}
|
||||
|
||||
func (managementApi ManagementApiHandler) Binding() string {
|
||||
return FabricApiBinding
|
||||
}
|
||||
|
||||
func (managementApi ManagementApiHandler) Options() map[interface{}]interface{} {
|
||||
return managementApi.options
|
||||
}
|
||||
|
||||
func (managementApi ManagementApiHandler) RootPath() string {
|
||||
return rest_client.DefaultBasePath
|
||||
}
|
||||
|
||||
func (managementApi ManagementApiHandler) IsHandler(r *http.Request) bool {
|
||||
return strings.HasPrefix(r.URL.Path, managementApi.RootPath())
|
||||
}
|
||||
|
||||
func (managementApi ManagementApiHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
|
||||
managementApi.handler.ServeHTTP(writer, request)
|
||||
}
|
||||
|
||||
func NewManagementApiHandler(fabricApi *operations.ZitiFabricAPI, options map[interface{}]interface{}) (*ManagementApiHandler, error) {
|
||||
managementApi := &ManagementApiHandler{
|
||||
fabricApi: fabricApi,
|
||||
options: options,
|
||||
}
|
||||
|
||||
managementApi.handler = managementApi.newHandler()
|
||||
|
||||
return managementApi, nil
|
||||
}
|
||||
|
||||
func (managementApi ManagementApiHandler) newHandler() http.Handler {
|
||||
innerManagementHandler := managementApi.fabricApi.Serve(nil)
|
||||
return requestWrapper.WrapHttpHandler(innerManagementHandler)
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/foundation/storage/ast"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
)
|
||||
|
||||
const (
|
||||
LimitMax = 500
|
||||
)
|
||||
|
||||
// PublicQueryOptions represents external query options, which limits some query options (i.e. return all vs max limit). PublicQueryOptions
|
||||
// can be used internally as long as the public option limitations are fitting.
|
||||
type PublicQueryOptions struct {
|
||||
Predicate string
|
||||
Sort string
|
||||
Paging *Paging
|
||||
}
|
||||
|
||||
func (qo *PublicQueryOptions) String() string {
|
||||
if qo == nil {
|
||||
return "nil"
|
||||
}
|
||||
return fmt.Sprintf("[QueryOption Predicate: '%v', Sort: '%v', Paging: '%v']", qo.Predicate, qo.Sort, qo.Paging)
|
||||
}
|
||||
|
||||
func (qo *PublicQueryOptions) getFullQuery(store boltz.ListStore) (ast.Query, error) {
|
||||
if qo.Predicate == "" {
|
||||
qo.Predicate = "true"
|
||||
}
|
||||
|
||||
query, err := ast.Parse(store, qo.Predicate)
|
||||
if err != nil {
|
||||
return nil, errorz.NewInvalidFilter(err)
|
||||
}
|
||||
|
||||
if err = boltz.ValidateSymbolsArePublic(query, store); err != nil {
|
||||
return nil, errorz.NewInvalidFilter(err)
|
||||
}
|
||||
|
||||
pfxlog.Logger().Debugf("query: %v", qo)
|
||||
|
||||
if qo.Paging != nil {
|
||||
if query.GetLimit() == nil {
|
||||
if qo.Paging.ReturnAll {
|
||||
//public external queries cannot be "return all"
|
||||
query.SetLimit(LimitMax)
|
||||
} else {
|
||||
query.SetLimit(qo.Paging.Limit)
|
||||
}
|
||||
}
|
||||
if query.GetSkip() == nil {
|
||||
query.SetSkip(qo.Paging.Offset)
|
||||
}
|
||||
}
|
||||
|
||||
// sort out sorts
|
||||
sortFields := query.GetSortFields()
|
||||
if len(sortFields) == 0 && qo.Sort != "" {
|
||||
sortQueryString := "true sort by " + qo.Sort
|
||||
|
||||
sortQuery, err := ast.Parse(store, sortQueryString)
|
||||
if err != nil {
|
||||
return nil, errorz.NewInvalidSort(err)
|
||||
}
|
||||
|
||||
if err = boltz.ValidateSymbolsArePublic(sortQuery, store); err != nil {
|
||||
return nil, errorz.NewInvalidSort(err)
|
||||
}
|
||||
|
||||
if err = query.AdoptSortFields(sortQuery); err != nil {
|
||||
return nil, errorz.NewInvalidSort(err)
|
||||
}
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
type Paging struct {
|
||||
Offset int64
|
||||
Limit int64
|
||||
ReturnAll bool
|
||||
}
|
||||
|
||||
func (paging *Paging) String() string {
|
||||
if paging == nil {
|
||||
return "nil"
|
||||
}
|
||||
return fmt.Sprintf("[Paging Offset: '%v', Limit: '%v', ReturnAll: '%v']", paging.Offset, paging.Limit, paging.ReturnAll)
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func RespondWithCreatedId(responder api.Responder, id string, link rest_model.Link) {
|
||||
createEnvelope := &rest_model.CreateEnvelope{
|
||||
Data: &rest_model.CreateLocation{
|
||||
Links: rest_model.Links{
|
||||
"self": link,
|
||||
},
|
||||
ID: id,
|
||||
},
|
||||
Meta: &rest_model.Meta{},
|
||||
}
|
||||
|
||||
responder.Respond(createEnvelope, http.StatusCreated)
|
||||
}
|
||||
|
||||
func RespondWithOk(responder api.Responder, data interface{}, meta *rest_model.Meta) {
|
||||
responder.Respond(&rest_model.Empty{
|
||||
Data: data,
|
||||
Meta: meta,
|
||||
}, http.StatusOK)
|
||||
}
|
||||
|
||||
type fabricResponseMapper struct{}
|
||||
|
||||
func (self fabricResponseMapper) EmptyOkData() interface{} {
|
||||
return &rest_model.Empty{
|
||||
Data: map[string]interface{}{},
|
||||
Meta: &rest_model.Meta{},
|
||||
}
|
||||
}
|
||||
|
||||
func (self fabricResponseMapper) MapApiError(requestId string, apiError *errorz.ApiError) interface{} {
|
||||
return &rest_model.APIErrorEnvelope{
|
||||
Error: ToRestModel(apiError, requestId),
|
||||
Meta: &rest_model.Meta{
|
||||
APIEnrollmentVersion: ApiVersion,
|
||||
APIVersion: ApiVersion,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/foundation/util/stringz"
|
||||
)
|
||||
|
||||
const EntityNameRouter = "routers"
|
||||
|
||||
var RouterLinkFactory = NewRouterLinkFactory()
|
||||
|
||||
type RouterLinkFactoryIml struct {
|
||||
BasicLinkFactory
|
||||
}
|
||||
|
||||
func NewRouterLinkFactory() *RouterLinkFactoryIml {
|
||||
return &RouterLinkFactoryIml{
|
||||
BasicLinkFactory: *NewBasicLinkFactory(EntityNameRouter),
|
||||
}
|
||||
}
|
||||
|
||||
func (factory *RouterLinkFactoryIml) Links(entity LinkEntity) rest_model.Links {
|
||||
links := factory.BasicLinkFactory.Links(entity)
|
||||
links[EntityNameTerminator] = factory.NewNestedLink(entity, EntityNameTerminator)
|
||||
return links
|
||||
}
|
||||
|
||||
func MapCreateRouterToModel(router *rest_model.RouterCreate) *network.Router {
|
||||
ret := &network.Router{
|
||||
BaseEntity: models.BaseEntity{
|
||||
Id: stringz.OrEmpty(router.ID),
|
||||
Tags: TagsOrDefault(router.Tags),
|
||||
},
|
||||
Name: stringz.OrEmpty(router.Name),
|
||||
Fingerprint: router.Fingerprint,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func MapUpdateRouterToModel(id string, router *rest_model.RouterUpdate) *network.Router {
|
||||
ret := &network.Router{
|
||||
BaseEntity: models.BaseEntity{
|
||||
Tags: TagsOrDefault(router.Tags),
|
||||
Id: id,
|
||||
},
|
||||
Name: stringz.OrEmpty(router.Name),
|
||||
Fingerprint: router.Fingerprint,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func MapPatchRouterToModel(id string, router *rest_model.RouterPatch) *network.Router {
|
||||
ret := &network.Router{
|
||||
BaseEntity: models.BaseEntity{
|
||||
Tags: TagsOrDefault(router.Tags),
|
||||
Id: id,
|
||||
},
|
||||
Name: router.Name,
|
||||
Fingerprint: router.Fingerprint,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func MapRouterToRestEntity(n *network.Network, rc api.RequestContext, e models.Entity) (interface{}, error) {
|
||||
router, ok := e.(*network.Router)
|
||||
|
||||
if !ok {
|
||||
err := fmt.Errorf("entity is not a Router \"%s\"", e.GetId())
|
||||
log := pfxlog.Logger()
|
||||
log.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
restModel, err := MapRouterToRestModel(n, rc, router)
|
||||
|
||||
if err != nil {
|
||||
err := fmt.Errorf("could not convert to API entity \"%s\": %s", e.GetId(), err)
|
||||
log := pfxlog.Logger()
|
||||
log.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
return restModel, nil
|
||||
}
|
||||
|
||||
func MapRouterToRestModel(n *network.Network, _ api.RequestContext, router *network.Router) (*rest_model.RouterDetail, error) {
|
||||
connected := n.GetConnectedRouter(router.Id)
|
||||
var restVersionInfo *rest_model.VersionInfo
|
||||
if connected != nil && connected.VersionInfo != nil {
|
||||
versionInfo := connected.VersionInfo
|
||||
restVersionInfo = &rest_model.VersionInfo{
|
||||
Arch: versionInfo.Arch,
|
||||
BuildDate: versionInfo.BuildDate,
|
||||
Os: versionInfo.OS,
|
||||
Revision: versionInfo.Revision,
|
||||
Version: versionInfo.Version,
|
||||
}
|
||||
}
|
||||
|
||||
isConnected := connected != nil
|
||||
ret := &rest_model.RouterDetail{
|
||||
BaseEntity: BaseEntityToRestModel(router, RouterLinkFactory),
|
||||
Fingerprint: router.Fingerprint,
|
||||
Name: &router.Name,
|
||||
Connected: &isConnected,
|
||||
VersionInfo: restVersionInfo,
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/rest_server/operations"
|
||||
"github.com/openziti/fabric/rest_server/operations/router"
|
||||
)
|
||||
|
||||
func init() {
|
||||
r := NewRouterRouter()
|
||||
AddRouter(r)
|
||||
}
|
||||
|
||||
type RouterRouter struct {
|
||||
BasePath string
|
||||
}
|
||||
|
||||
func NewRouterRouter() *RouterRouter {
|
||||
return &RouterRouter{
|
||||
BasePath: "/" + EntityNameRouter,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RouterRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper) {
|
||||
fabricApi.RouterDeleteRouterHandler = router.DeleteRouterHandlerFunc(func(params router.DeleteRouterParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.Delete, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.RouterDetailRouterHandler = router.DetailRouterHandlerFunc(func(params router.DetailRouterParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.Detail, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.RouterListRoutersHandler = router.ListRoutersHandlerFunc(func(params router.ListRoutersParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.ListRouters, params.HTTPRequest, "", "")
|
||||
})
|
||||
|
||||
fabricApi.RouterCreateRouterHandler = router.CreateRouterHandlerFunc(func(params router.CreateRouterParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(func(n *network.Network, rc api.RequestContext) { r.Create(n, rc, params) }, params.HTTPRequest, "", "")
|
||||
})
|
||||
|
||||
fabricApi.RouterUpdateRouterHandler = router.UpdateRouterHandlerFunc(func(params router.UpdateRouterParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(func(n *network.Network, rc api.RequestContext) { r.Update(n, rc, params) }, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.RouterPatchRouterHandler = router.PatchRouterHandlerFunc(func(params router.PatchRouterParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(func(n *network.Network, rc api.RequestContext) { r.Patch(n, rc, params) }, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.RouterListRouterTerminatorsHandler = router.ListRouterTerminatorsHandlerFunc(func(params router.ListRouterTerminatorsParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.listManagementTerminators, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
}
|
||||
|
||||
func (r *RouterRouter) ListRouters(n *network.Network, rc api.RequestContext) {
|
||||
ListWithHandler(n, rc, n.Controllers.Routers, MapRouterToRestEntity)
|
||||
}
|
||||
|
||||
func (r *RouterRouter) Detail(n *network.Network, rc api.RequestContext) {
|
||||
DetailWithHandler(n, rc, n.Controllers.Routers, MapRouterToRestEntity)
|
||||
}
|
||||
|
||||
func (r *RouterRouter) Create(n *network.Network, rc api.RequestContext, params router.CreateRouterParams) {
|
||||
Create(rc, RouterLinkFactory, func() (string, error) {
|
||||
router := MapCreateRouterToModel(params.Router)
|
||||
err := n.Routers.Create(router)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return router.Id, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (r *RouterRouter) Delete(network *network.Network, rc api.RequestContext) {
|
||||
DeleteWithHandler(rc, network.Controllers.Routers)
|
||||
}
|
||||
|
||||
func (r *RouterRouter) Update(n *network.Network, rc api.RequestContext, params router.UpdateRouterParams) {
|
||||
Update(rc, func(id string) error {
|
||||
return n.Controllers.Routers.Update(MapUpdateRouterToModel(params.ID, params.Router))
|
||||
})
|
||||
}
|
||||
|
||||
func (r *RouterRouter) Patch(n *network.Network, rc api.RequestContext, params router.PatchRouterParams) {
|
||||
Patch(rc, func(id string, fields api.JsonFields) error {
|
||||
return n.Controllers.Routers.Patch(MapPatchRouterToModel(params.ID, params.Router), fields.ConcatNestedNames().FilterMaps("tags"))
|
||||
})
|
||||
}
|
||||
|
||||
func (r *RouterRouter) listManagementTerminators(n *network.Network, rc api.RequestContext) {
|
||||
r.listAssociations(n, rc, n.Controllers.Terminators, MapTerminatorToRestEntity)
|
||||
}
|
||||
|
||||
func (r *RouterRouter) listAssociations(n *network.Network, rc api.RequestContext, associationLoader models.EntityRetriever, mapper ModelToApiMapper) {
|
||||
ListAssociationWithHandler(n, rc, n.Controllers.Routers, associationLoader, mapper)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package api_impl
|
||||
|
||||
import "github.com/openziti/fabric/rest_server/operations"
|
||||
|
||||
var routers []Router
|
||||
|
||||
func AddRouter(router Router) {
|
||||
routers = append(routers, router)
|
||||
}
|
||||
|
||||
type Router interface {
|
||||
Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper)
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type ModelToApiMapper func(*network.Network, api.RequestContext, models.Entity) (interface{}, error)
|
||||
|
||||
func GetModelQueryOptionsFromRequest(r *http.Request) (*PublicQueryOptions, error) {
|
||||
filter := r.URL.Query().Get("filter")
|
||||
sort := r.URL.Query().Get("sort")
|
||||
|
||||
pg, err := GetRequestPaging(r)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PublicQueryOptions{
|
||||
Predicate: filter,
|
||||
Sort: sort,
|
||||
Paging: pg,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func GetRequestPaging(r *http.Request) (*Paging, error) {
|
||||
l := r.URL.Query().Get("limit")
|
||||
o := r.URL.Query().Get("offset")
|
||||
|
||||
var p *Paging
|
||||
|
||||
if l != "" {
|
||||
i, err := strconv.ParseInt(l, 10, 64)
|
||||
|
||||
if err != nil {
|
||||
return nil, errorz.NewInvalidPagination(errorz.NewFieldError("could not parse limit, value is not an integer", "limit", l))
|
||||
}
|
||||
p = &Paging{}
|
||||
p.Limit = i
|
||||
}
|
||||
|
||||
if o != "" {
|
||||
i, err := strconv.ParseInt(o, 10, 64)
|
||||
|
||||
if err != nil {
|
||||
return nil, errorz.NewInvalidPagination(errorz.NewFieldError("could not parse offset, value is not an integer", "offset", o))
|
||||
}
|
||||
if p == nil {
|
||||
p = &Paging{}
|
||||
}
|
||||
p.Offset = i
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
type QueryResult struct {
|
||||
Result interface{}
|
||||
Count int64
|
||||
Limit int64
|
||||
Offset int64
|
||||
FilterableFields []string
|
||||
}
|
||||
|
||||
func NewQueryResult(result interface{}, metadata *models.QueryMetaData) *QueryResult {
|
||||
return &QueryResult{
|
||||
Result: result,
|
||||
Count: metadata.Count,
|
||||
Limit: metadata.Limit,
|
||||
Offset: metadata.Offset,
|
||||
FilterableFields: metadata.FilterableFields,
|
||||
}
|
||||
}
|
||||
|
||||
func TagsOrDefault(tags *rest_model.Tags) map[string]interface{} {
|
||||
if tags == nil || tags.SubTags == nil {
|
||||
return map[string]interface{}{}
|
||||
}
|
||||
return tags.SubTags
|
||||
}
|
||||
|
||||
func BoolOrDefault(val *bool) bool {
|
||||
if val == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return *val
|
||||
}
|
||||
|
||||
func Int64OrDefault(val *int64) int64 {
|
||||
if val == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
return *val
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/idgen"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/foundation/util/stringz"
|
||||
)
|
||||
|
||||
const EntityNameService = "services"
|
||||
|
||||
var ServiceLinkFactory = NewServiceLinkFactory()
|
||||
|
||||
type ServiceLinkFactoryIml struct {
|
||||
BasicLinkFactory
|
||||
}
|
||||
|
||||
func NewServiceLinkFactory() *ServiceLinkFactoryIml {
|
||||
return &ServiceLinkFactoryIml{
|
||||
BasicLinkFactory: *NewBasicLinkFactory(EntityNameService),
|
||||
}
|
||||
}
|
||||
|
||||
func (factory *ServiceLinkFactoryIml) Links(entity LinkEntity) rest_model.Links {
|
||||
links := factory.BasicLinkFactory.Links(entity)
|
||||
links[EntityNameTerminator] = factory.NewNestedLink(entity, EntityNameTerminator)
|
||||
return links
|
||||
}
|
||||
|
||||
func MapCreateServiceToModel(service *rest_model.ServiceCreate) *network.Service {
|
||||
ret := &network.Service{
|
||||
BaseEntity: models.BaseEntity{
|
||||
Tags: TagsOrDefault(service.Tags),
|
||||
},
|
||||
Name: stringz.OrEmpty(service.Name),
|
||||
TerminatorStrategy: service.TerminatorStrategy,
|
||||
}
|
||||
|
||||
if ret.Id == "" {
|
||||
ret.Id = idgen.New()
|
||||
}
|
||||
|
||||
if ret.Id != "" && ret.Name == "" {
|
||||
ret.Name = ret.Id
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func MapUpdateServiceToModel(id string, service *rest_model.ServiceUpdate) *network.Service {
|
||||
ret := &network.Service{
|
||||
BaseEntity: models.BaseEntity{
|
||||
Tags: TagsOrDefault(service.Tags),
|
||||
Id: id,
|
||||
},
|
||||
Name: stringz.OrEmpty(service.Name),
|
||||
TerminatorStrategy: service.TerminatorStrategy,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func MapPatchServiceToModel(id string, service *rest_model.ServicePatch) *network.Service {
|
||||
ret := &network.Service{
|
||||
BaseEntity: models.BaseEntity{
|
||||
Tags: TagsOrDefault(service.Tags),
|
||||
Id: id,
|
||||
},
|
||||
Name: service.Name,
|
||||
TerminatorStrategy: service.TerminatorStrategy,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func MapServiceToRestEntity(n *network.Network, rc api.RequestContext, e models.Entity) (interface{}, error) {
|
||||
service, ok := e.(*network.Service)
|
||||
|
||||
if !ok {
|
||||
err := fmt.Errorf("entity is not a Service \"%s\"", e.GetId())
|
||||
log := pfxlog.Logger()
|
||||
log.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
restModel, err := MapServiceToRestModel(n, rc, service)
|
||||
|
||||
if err != nil {
|
||||
err := fmt.Errorf("could not convert to API entity \"%s\": %s", e.GetId(), err)
|
||||
log := pfxlog.Logger()
|
||||
log.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
return restModel, nil
|
||||
}
|
||||
|
||||
func MapServiceToRestModel(_ *network.Network, _ api.RequestContext, service *network.Service) (*rest_model.ServiceDetail, error) {
|
||||
ret := &rest_model.ServiceDetail{
|
||||
BaseEntity: BaseEntityToRestModel(service, ServiceLinkFactory),
|
||||
Name: &service.Name,
|
||||
TerminatorStrategy: &service.TerminatorStrategy,
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/rest_server/operations"
|
||||
"github.com/openziti/fabric/rest_server/operations/service"
|
||||
)
|
||||
|
||||
func init() {
|
||||
r := NewServiceRouter()
|
||||
AddRouter(r)
|
||||
}
|
||||
|
||||
type ServiceRouter struct {
|
||||
BasePath string
|
||||
}
|
||||
|
||||
func NewServiceRouter() *ServiceRouter {
|
||||
return &ServiceRouter{
|
||||
BasePath: "/" + EntityNameService,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *ServiceRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper) {
|
||||
fabricApi.ServiceDeleteServiceHandler = service.DeleteServiceHandlerFunc(func(params service.DeleteServiceParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.Delete, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.ServiceDetailServiceHandler = service.DetailServiceHandlerFunc(func(params service.DetailServiceParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.Detail, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.ServiceListServicesHandler = service.ListServicesHandlerFunc(func(params service.ListServicesParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.ListServices, params.HTTPRequest, "", "")
|
||||
})
|
||||
|
||||
fabricApi.ServiceUpdateServiceHandler = service.UpdateServiceHandlerFunc(func(params service.UpdateServiceParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(func(n *network.Network, rc api.RequestContext) { r.Update(n, rc, params) }, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.ServiceCreateServiceHandler = service.CreateServiceHandlerFunc(func(params service.CreateServiceParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(func(n *network.Network, rc api.RequestContext) { r.Create(n, rc, params) }, params.HTTPRequest, "", "")
|
||||
})
|
||||
|
||||
fabricApi.ServicePatchServiceHandler = service.PatchServiceHandlerFunc(func(params service.PatchServiceParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(func(n *network.Network, rc api.RequestContext) { r.Patch(n, rc, params) }, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.ServiceListServiceTerminatorsHandler = service.ListServiceTerminatorsHandlerFunc(func(params service.ListServiceTerminatorsParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.listManagementTerminators, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
}
|
||||
|
||||
func (r *ServiceRouter) ListServices(n *network.Network, rc api.RequestContext) {
|
||||
ListWithHandler(n, rc, n.Controllers.Services, MapServiceToRestEntity)
|
||||
}
|
||||
|
||||
func (r *ServiceRouter) Detail(n *network.Network, rc api.RequestContext) {
|
||||
DetailWithHandler(n, rc, n.Controllers.Services, MapServiceToRestEntity)
|
||||
}
|
||||
|
||||
func (r *ServiceRouter) Create(n *network.Network, rc api.RequestContext, params service.CreateServiceParams) {
|
||||
Create(rc, ServiceLinkFactory, func() (string, error) {
|
||||
svc := MapCreateServiceToModel(params.Service)
|
||||
err := n.Services.Create(svc)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return svc.Id, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (r *ServiceRouter) Delete(network *network.Network, rc api.RequestContext) {
|
||||
DeleteWithHandler(rc, network.Controllers.Services)
|
||||
}
|
||||
|
||||
func (r *ServiceRouter) Update(n *network.Network, rc api.RequestContext, params service.UpdateServiceParams) {
|
||||
Update(rc, func(id string) error {
|
||||
return n.Controllers.Services.Update(MapUpdateServiceToModel(params.ID, params.Service))
|
||||
})
|
||||
}
|
||||
|
||||
func (r *ServiceRouter) Patch(n *network.Network, rc api.RequestContext, params service.PatchServiceParams) {
|
||||
Patch(rc, func(id string, fields api.JsonFields) error {
|
||||
return n.Controllers.Services.Patch(MapPatchServiceToModel(params.ID, params.Service), fields.ConcatNestedNames().FilterMaps("tags"))
|
||||
})
|
||||
}
|
||||
|
||||
func (r *ServiceRouter) listManagementTerminators(n *network.Network, rc api.RequestContext) {
|
||||
r.listAssociations(n, rc, n.Controllers.Terminators, MapTerminatorToRestEntity)
|
||||
}
|
||||
|
||||
func (r *ServiceRouter) listAssociations(n *network.Network, rc api.RequestContext, associationLoader models.EntityRetriever, mapper ModelToApiMapper) {
|
||||
ListAssociationWithHandler(n, rc, n.Controllers.Services, associationLoader, mapper)
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/controller/xt"
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
"github.com/openziti/foundation/util/stringz"
|
||||
)
|
||||
|
||||
const EntityNameTerminator = "terminators"
|
||||
|
||||
var TerminatorLinkFactory = NewBasicLinkFactory(EntityNameTerminator)
|
||||
|
||||
func MapCreateTerminatorToModel(terminator *rest_model.TerminatorCreate) *network.Terminator {
|
||||
ret := &network.Terminator{
|
||||
BaseEntity: models.BaseEntity{
|
||||
Tags: TagsOrDefault(terminator.Tags),
|
||||
},
|
||||
Service: stringz.OrEmpty(terminator.Service),
|
||||
Router: stringz.OrEmpty(terminator.Router),
|
||||
Binding: stringz.OrEmpty(terminator.Binding),
|
||||
Address: stringz.OrEmpty(terminator.Address),
|
||||
Identity: terminator.Identity,
|
||||
IdentitySecret: terminator.IdentitySecret,
|
||||
Precedence: xt.GetPrecedenceForName(string(terminator.Precedence)),
|
||||
}
|
||||
|
||||
if terminator.Cost != nil {
|
||||
ret.Cost = uint16(*terminator.Cost)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func MapUpdateTerminatorToModel(id string, terminator *rest_model.TerminatorUpdate) *network.Terminator {
|
||||
ret := &network.Terminator{
|
||||
BaseEntity: models.BaseEntity{
|
||||
Tags: TagsOrDefault(terminator.Tags),
|
||||
Id: id,
|
||||
},
|
||||
Service: stringz.OrEmpty(terminator.Service),
|
||||
Router: stringz.OrEmpty(terminator.Router),
|
||||
Binding: stringz.OrEmpty(terminator.Binding),
|
||||
Address: stringz.OrEmpty(terminator.Address),
|
||||
Precedence: xt.GetPrecedenceForName(string(terminator.Precedence)),
|
||||
}
|
||||
|
||||
if terminator.Cost != nil {
|
||||
ret.Cost = uint16(*terminator.Cost)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func MapPatchTerminatorToModel(id string, terminator *rest_model.TerminatorPatch) *network.Terminator {
|
||||
ret := &network.Terminator{
|
||||
BaseEntity: models.BaseEntity{
|
||||
Tags: TagsOrDefault(terminator.Tags),
|
||||
Id: id,
|
||||
},
|
||||
Service: terminator.Service,
|
||||
Router: terminator.Router,
|
||||
Binding: terminator.Binding,
|
||||
Address: terminator.Address,
|
||||
Precedence: xt.GetPrecedenceForName(string(terminator.Precedence)),
|
||||
}
|
||||
|
||||
if terminator.Cost != nil {
|
||||
ret.Cost = uint16(*terminator.Cost)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func MapTerminatorToRestEntity(n *network.Network, _ api.RequestContext, e models.Entity) (interface{}, error) {
|
||||
terminator, ok := e.(*network.Terminator)
|
||||
|
||||
if !ok {
|
||||
err := fmt.Errorf("entity is not a Terminator \"%s\"", e.GetId())
|
||||
log := pfxlog.Logger()
|
||||
log.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
restModel, err := MapTerminatorToRestModel(n, terminator)
|
||||
|
||||
if err != nil {
|
||||
err := fmt.Errorf("could not convert to API entity \"%s\": %s", e.GetId(), err)
|
||||
log := pfxlog.Logger()
|
||||
log.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
return restModel, nil
|
||||
}
|
||||
|
||||
func MapTerminatorToRestModel(n *network.Network, terminator *network.Terminator) (*rest_model.TerminatorDetail, error) {
|
||||
|
||||
service, err := n.Controllers.Services.Read(terminator.Service)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
router, err := n.Controllers.Routers.Read(terminator.Router)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cost := rest_model.TerminatorCost(int64(terminator.Cost))
|
||||
dynamicCost := rest_model.TerminatorCost(xt.GlobalCosts().GetDynamicCost(terminator.Id))
|
||||
|
||||
ret := &rest_model.TerminatorDetail{
|
||||
BaseEntity: BaseEntityToRestModel(terminator, TerminatorLinkFactory),
|
||||
ServiceID: &terminator.Service,
|
||||
Service: ToEntityRef(service.Name, service, ServiceLinkFactory),
|
||||
RouterID: &terminator.Router,
|
||||
Router: ToEntityRef(router.Name, router, RouterLinkFactory),
|
||||
Binding: &terminator.Binding,
|
||||
Address: &terminator.Address,
|
||||
Identity: &terminator.Identity,
|
||||
Cost: &cost,
|
||||
DynamicCost: &dynamicCost,
|
||||
}
|
||||
|
||||
precedence := terminator.Precedence
|
||||
|
||||
resultPrecedence := rest_model.TerminatorPrecedenceDefault
|
||||
|
||||
if precedence.IsRequired() {
|
||||
resultPrecedence = rest_model.TerminatorPrecedenceRequired
|
||||
} else if precedence.IsFailed() {
|
||||
resultPrecedence = rest_model.TerminatorPrecedenceFailed
|
||||
}
|
||||
|
||||
ret.Precedence = &resultPrecedence
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/rest_server/operations"
|
||||
"github.com/openziti/fabric/rest_server/operations/terminator"
|
||||
)
|
||||
|
||||
func init() {
|
||||
r := NewTerminatorRouter()
|
||||
AddRouter(r)
|
||||
}
|
||||
|
||||
type TerminatorRouter struct {
|
||||
BasePath string
|
||||
}
|
||||
|
||||
func NewTerminatorRouter() *TerminatorRouter {
|
||||
return &TerminatorRouter{
|
||||
BasePath: "/" + EntityNameTerminator,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *TerminatorRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper) {
|
||||
fabricApi.TerminatorDeleteTerminatorHandler = terminator.DeleteTerminatorHandlerFunc(func(params terminator.DeleteTerminatorParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.Delete, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.TerminatorDetailTerminatorHandler = terminator.DetailTerminatorHandlerFunc(func(params terminator.DetailTerminatorParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.Detail, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.TerminatorListTerminatorsHandler = terminator.ListTerminatorsHandlerFunc(func(params terminator.ListTerminatorsParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(r.List, params.HTTPRequest, "", "")
|
||||
})
|
||||
|
||||
fabricApi.TerminatorUpdateTerminatorHandler = terminator.UpdateTerminatorHandlerFunc(func(params terminator.UpdateTerminatorParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(func(n *network.Network, rc api.RequestContext) { r.Update(n, rc, params) }, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
|
||||
fabricApi.TerminatorCreateTerminatorHandler = terminator.CreateTerminatorHandlerFunc(func(params terminator.CreateTerminatorParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(func(n *network.Network, rc api.RequestContext) { r.Create(n, rc, params) }, params.HTTPRequest, "", "")
|
||||
})
|
||||
|
||||
fabricApi.TerminatorPatchTerminatorHandler = terminator.PatchTerminatorHandlerFunc(func(params terminator.PatchTerminatorParams) middleware.Responder {
|
||||
return wrapper.WrapRequest(func(n *network.Network, rc api.RequestContext) { r.Patch(n, rc, params) }, params.HTTPRequest, params.ID, "")
|
||||
})
|
||||
}
|
||||
|
||||
func (r *TerminatorRouter) List(n *network.Network, rc api.RequestContext) {
|
||||
ListWithHandler(n, rc, n.Controllers.Terminators, MapTerminatorToRestEntity)
|
||||
}
|
||||
|
||||
func (r *TerminatorRouter) Detail(n *network.Network, rc api.RequestContext) {
|
||||
DetailWithHandler(n, rc, n.Controllers.Terminators, MapTerminatorToRestEntity)
|
||||
}
|
||||
|
||||
func (r *TerminatorRouter) Create(n *network.Network, rc api.RequestContext, params terminator.CreateTerminatorParams) {
|
||||
Create(rc, TerminatorLinkFactory, func() (string, error) {
|
||||
return n.Controllers.Terminators.Create(MapCreateTerminatorToModel(params.Terminator))
|
||||
})
|
||||
}
|
||||
|
||||
func (r *TerminatorRouter) Delete(n *network.Network, rc api.RequestContext) {
|
||||
DeleteWithHandler(rc, n.Controllers.Terminators)
|
||||
}
|
||||
|
||||
func (r *TerminatorRouter) Update(n *network.Network, rc api.RequestContext, params terminator.UpdateTerminatorParams) {
|
||||
Update(rc, func(id string) error {
|
||||
return n.Controllers.Terminators.Update(MapUpdateTerminatorToModel(params.ID, params.Terminator))
|
||||
})
|
||||
}
|
||||
|
||||
func (r *TerminatorRouter) Patch(n *network.Network, rc api.RequestContext, params terminator.PatchTerminatorParams) {
|
||||
Patch(rc, func(id string, fields api.JsonFields) error {
|
||||
return n.Controllers.Terminators.Patch(MapPatchTerminatorToModel(params.ID, params.Terminator), fields.FilterMaps("tags"))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package api_impl
|
||||
|
||||
const (
|
||||
ApiVersion = "1.0.0"
|
||||
|
||||
VersionV1 = "v1"
|
||||
|
||||
RestApiV1 = "/" + VersionV1
|
||||
|
||||
FabricRestApiRootPath = "/fabric"
|
||||
|
||||
FabricRestApiBaseUrlV1 = FabricRestApiRootPath + RestApiV1
|
||||
|
||||
FabricRestApiBaseUrlLatest = FabricRestApiBaseUrlV1
|
||||
|
||||
FabricRestApiSpecUrl = FabricRestApiBaseUrlLatest + "/swagger.json"
|
||||
|
||||
FabricApiBinding = "fabric"
|
||||
)
|
||||
|
||||
// AllApiBindingVersions is a map of: API Binding -> Api Version -> API Path
|
||||
// Adding values here will add them to the /versions REST API endpoint
|
||||
var AllApiBindingVersions = map[string]map[string]string{
|
||||
FabricApiBinding: {
|
||||
VersionV1: FabricRestApiBaseUrlV1,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package api_impl
|
||||
|
||||
import (
|
||||
"crypto/x509"
|
||||
"github.com/go-openapi/runtime"
|
||||
openApiMiddleware "github.com/go-openapi/runtime/middleware"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/build"
|
||||
"github.com/openziti/fabric/controller/api"
|
||||
"github.com/openziti/fabric/controller/apierror"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/rest_server"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
"github.com/pkg/errors"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
var requestWrapper RequestWrapper
|
||||
|
||||
func OverrideRequestWrapper(rw RequestWrapper) {
|
||||
if requestWrapper != nil {
|
||||
pfxlog.Logger().Warn("requestWrapper overridden more than once")
|
||||
}
|
||||
requestWrapper = rw
|
||||
}
|
||||
|
||||
type RequestHandler func(network *network.Network, rc api.RequestContext)
|
||||
|
||||
type RequestWrapper interface {
|
||||
WrapRequest(handler RequestHandler, request *http.Request, entityId, entitySubId string) openApiMiddleware.Responder
|
||||
WrapHttpHandler(handler http.Handler) http.Handler
|
||||
}
|
||||
|
||||
type FabricRequestWrapper struct {
|
||||
routerId identity.Identity
|
||||
network *network.Network
|
||||
}
|
||||
|
||||
func (self *FabricRequestWrapper) WrapRequest(handler RequestHandler, request *http.Request, entityId, entitySubId string) openApiMiddleware.Responder {
|
||||
return openApiMiddleware.ResponderFunc(func(writer http.ResponseWriter, producer runtime.Producer) {
|
||||
rc, err := api.GetRequestContextFromHttpContext(request)
|
||||
|
||||
if rc == nil {
|
||||
rc = NewRequestContext(writer, request)
|
||||
}
|
||||
|
||||
rc.SetProducer(producer)
|
||||
rc.SetEntityId(entityId)
|
||||
rc.SetEntitySubId(entitySubId)
|
||||
|
||||
if err != nil {
|
||||
pfxlog.Logger().WithError(err).Error("could not retrieve request context")
|
||||
rc.RespondWithError(err)
|
||||
return
|
||||
}
|
||||
|
||||
handler(self.network, rc)
|
||||
})
|
||||
}
|
||||
|
||||
func (self *FabricRequestWrapper) WrapHttpHandler(handler http.Handler) http.Handler {
|
||||
wrapper := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path == FabricRestApiSpecUrl {
|
||||
rw.Header().Set("content-type", "application/json")
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
_, _ = rw.Write(rest_server.SwaggerJSON)
|
||||
return
|
||||
}
|
||||
|
||||
rc := NewRequestContext(rw, r)
|
||||
|
||||
api.AddRequestContextToHttpContext(r, rc)
|
||||
|
||||
//after request context is filled so that api session is present for session expiration headers
|
||||
buildInfo := build.GetBuildInfo()
|
||||
if buildInfo != nil {
|
||||
rc.GetResponseWriter().Header().Set(ServerHeader, "ziti-controller/"+buildInfo.Version())
|
||||
}
|
||||
|
||||
handler.ServeHTTP(rw, r)
|
||||
})
|
||||
|
||||
return api.TimeoutHandler(api.WrapCorsHandler(wrapper), 10*time.Second, apierror.NewTimeoutError(), fabricResponseMapper{})
|
||||
}
|
||||
|
||||
func (self *FabricRequestWrapper) verifyCert(r *http.Request) error {
|
||||
certificates := r.TLS.PeerCertificates
|
||||
if len(certificates) == 0 {
|
||||
return errors.New("no certificates provided, unable to verify dialer")
|
||||
}
|
||||
|
||||
config := self.routerId.ServerTLSConfig()
|
||||
|
||||
opts := x509.VerifyOptions{
|
||||
Roots: config.RootCAs,
|
||||
Intermediates: x509.NewCertPool(),
|
||||
KeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageAny},
|
||||
}
|
||||
|
||||
var errorList errorz.MultipleErrors
|
||||
|
||||
for _, cert := range certificates {
|
||||
if _, err := cert.Verify(opts); err == nil {
|
||||
return nil
|
||||
} else {
|
||||
errorList = append(errorList, err)
|
||||
}
|
||||
}
|
||||
|
||||
//goland:noinspection GoNilness
|
||||
return errorList.ToError()
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package apierror
|
||||
|
||||
import (
|
||||
"github.com/Jeffail/gabs"
|
||||
)
|
||||
|
||||
type GenericCauseError struct {
|
||||
Message string
|
||||
DataMap map[string]interface{}
|
||||
}
|
||||
|
||||
func (e GenericCauseError) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
func (e *GenericCauseError) MarshalJSON() ([]byte, error) {
|
||||
data, err := gabs.Consume(e.DataMap) //gabs to avoid zero values being omitted
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return data.Bytes(), nil
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package apierror
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type BodyParseTypeError struct {
|
||||
Near string `json:"near"`
|
||||
ExpectedType string `json:"expectedType"`
|
||||
EncounteredType string `json:"encounteredType"`
|
||||
Offset int64 `json:"totalOffset"`
|
||||
Line int64 `json:"line"`
|
||||
}
|
||||
|
||||
func (e BodyParseTypeError) Error() string {
|
||||
return fmt.Sprintf("Expected type %s, but encountered %s near %s", e.ExpectedType, e.ExpectedType, e.Near)
|
||||
}
|
||||
|
||||
func NewBodyParseTypeError(e *json.UnmarshalTypeError, body string) *BodyParseTypeError {
|
||||
nearStart := e.Offset - 10
|
||||
nearEnd := e.Offset
|
||||
|
||||
if nearStart < 0 {
|
||||
nearStart = 0
|
||||
}
|
||||
|
||||
near := body[nearStart:nearEnd]
|
||||
|
||||
bodyToError := body[:e.Offset]
|
||||
|
||||
line := strings.Count(bodyToError, "\n") + 1
|
||||
|
||||
return &BodyParseTypeError{
|
||||
ExpectedType: e.Type.String(),
|
||||
EncounteredType: e.Value,
|
||||
Near: near,
|
||||
Offset: e.Offset,
|
||||
Line: int64(line),
|
||||
}
|
||||
}
|
||||
|
||||
type BodyParseSyntaxError struct {
|
||||
Near string `json:"near"`
|
||||
Offset int64 `json:"totalOffset"`
|
||||
Line int64 `json:"line"`
|
||||
}
|
||||
|
||||
func (e BodyParseSyntaxError) Error() string {
|
||||
return fmt.Sprintf("Invalid syntax on line %d", e.Line)
|
||||
}
|
||||
|
||||
func NewBodyParseSyntaxError(e *json.SyntaxError, body string) *BodyParseSyntaxError {
|
||||
nearStart := e.Offset - 10
|
||||
nearEnd := e.Offset
|
||||
|
||||
if nearStart < 0 {
|
||||
nearStart = 0
|
||||
nearEnd = 5
|
||||
}
|
||||
|
||||
if nearEnd > int64(len(body)) {
|
||||
nearEnd = int64(len(body))
|
||||
}
|
||||
|
||||
near := body[nearStart:nearEnd]
|
||||
|
||||
bodyToError := body[:e.Offset]
|
||||
|
||||
line := strings.Count(bodyToError, "\n") + 1
|
||||
|
||||
return &BodyParseSyntaxError{
|
||||
Near: near,
|
||||
Offset: e.Offset,
|
||||
Line: int64(line),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package apierror
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
)
|
||||
|
||||
func NewCouldNotParseBody(err error) *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: CouldNotParseBodyCode,
|
||||
Message: CouldNotParseBodyMessage,
|
||||
Status: CouldNotParseBodyStatus,
|
||||
Cause: err,
|
||||
}
|
||||
}
|
||||
|
||||
func NewInvalidContentType(contentType string) *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: InvalidContentTypeCode,
|
||||
Message: InvalidContentTypeMessage + ": " + contentType,
|
||||
Status: InvalidContentTypeStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewCouldNotReadBody(err error) *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: CouldNotReadBodyCode,
|
||||
Message: CouldNotReadBodyMessage,
|
||||
Status: CouldNotReadBodyStatus,
|
||||
Cause: err,
|
||||
AppendCause: false,
|
||||
}
|
||||
}
|
||||
|
||||
func NewInvalidAuth() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: InvalidAuthCode,
|
||||
Message: InvalidAuthMessage,
|
||||
Status: InvalidAuthStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewInvalidAuthMethod() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: InvalidAuthMethodCode,
|
||||
Message: InvalidAuthMethodMessage,
|
||||
Status: InvalidAuthMethodStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewEnrollmentExpired() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: EnrollmentExpiredCode,
|
||||
Message: EnrollmentExpiredMessage,
|
||||
Status: EnrollmentExpiredStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewCouldNotProcessCsr() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: CouldNotProcessCsrCode,
|
||||
Message: CouldNotProcessCsrMessage,
|
||||
Status: CouldNotProcessCsrStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewEnrollmentCaNoLongValid() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: EnrollmentCaNoLongValidCode,
|
||||
Message: EnrollmentCaNoLongValidMessage,
|
||||
Status: EnrollmentCaNoLongValidStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewEnrollmentNoValidCas() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: EnrollmentNoValidCasCode,
|
||||
Message: EnrollmentNoValidCasMessage,
|
||||
Status: EnrollmentNoValidCasStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewInvalidEnrollmentToken() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: InvalidEnrollmentTokenCode,
|
||||
Message: InvalidEnrollmentTokenMessage,
|
||||
Status: InvalidEnrollmentTokenStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewInvalidEnrollMethod() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: InvalidEnrollMethodCode,
|
||||
Message: InvalidEnrollMethodMessage,
|
||||
Status: InvalidEnrollMethodStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewCouldNotParseX509FromDer() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: CouldNotParseX509FromDerCode,
|
||||
Message: CouldNotParseX509FromDerMessage,
|
||||
Status: CouldNotParseX509FromDerStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewCertFailedValidation() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: CertFailedValidationCode,
|
||||
Message: CertFailedValidationMessage,
|
||||
Status: CertFailedValidationStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewCertInUse() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: CertInUseCode,
|
||||
Message: CertInUseMessage,
|
||||
Status: CertInUseStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewCaAlreadyVerified() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: CaAlreadyVerifiedCode,
|
||||
Message: CaAlreadyVerifiedMessage,
|
||||
Status: CaAlreadyVerifiedStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewExpectedPemBlockCertificate() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: ExpectedPemBlockCertificateCode,
|
||||
Message: ExpectedPemBlockCertificateMessage,
|
||||
Status: ExpectedPemBlockCertificateStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewCouldNotParseDerBlock() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: CouldNotParseDerBlockCode,
|
||||
Message: CouldNotParseDerBlockMessage,
|
||||
Status: CouldNotParseDerBlockStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewCouldNotParsePem() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: CouldNotParsePemCode,
|
||||
Message: CouldNotParsePemMessage,
|
||||
Status: CouldNotParsePemStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewInvalidCommonName() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: InvalidCommonNameCode,
|
||||
Message: InvalidCommonNameMessage,
|
||||
Status: InvalidCommonNameStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewFailedCertificateValidation() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: FailedCertificateValidationCode,
|
||||
Message: FailedCertificateValidationMessage,
|
||||
Status: FailedCertificateValidationStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewInvalidEnrollmentMissingCsr(cause error) *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Cause: cause,
|
||||
Code: InvalidEnrollmentMissingCsrCode,
|
||||
Message: InvalidEnrollmentMissingCsrMessage,
|
||||
Status: InvalidEnrollmentMissingCsrStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewCertificateIsNotCa() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: CertificateIsNotCaCode,
|
||||
Message: CertificateIsNotCaMessage,
|
||||
Status: CertificateIsNotCaStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewInvalidUuid(val string) *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: InvalidUuidCode,
|
||||
Message: InvalidUuidMessage,
|
||||
Status: InvalidUuidStatus,
|
||||
Cause: &GenericCauseError{
|
||||
Message: "invalid uuid",
|
||||
DataMap: map[string]interface{}{
|
||||
"uuid": val,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NewInvalidAuthenticatorProperties() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: InvalidAuthenticatorPropertiesCode,
|
||||
Message: InvalidAuthenticatorPropertiesMessage,
|
||||
Status: InvalidAuthenticatorPropertiesStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewAuthenticatorCannotBeUpdated() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: AuthenticatorCanNotBeUpdatedCode,
|
||||
Message: AuthenticatorCanNotBeUpdatedMessage,
|
||||
Status: AuthenticatorCanNotBeUpdatedStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewFabricRouterCannotBeUpdate() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: RouterCanNotBeUpdatedCode,
|
||||
Message: RouterCanNotBeUpdatedMessage,
|
||||
Status: RouterCanNotBeUpdatedStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewAuthenticatorMethodMax() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: AuthenticatorMethodMaxCode,
|
||||
Message: AuthenticatorMethodMaxMessage,
|
||||
Status: AuthenticatorMethodMaxStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewMethodNotAllowed() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: MethodNotAllowedCode,
|
||||
Message: MethodNotAllowedMessage,
|
||||
Status: MethodNotAllowedStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewRateLimited() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: RateLimitedCode,
|
||||
Message: RateLimitedMessage,
|
||||
Status: RateLimitedStatus,
|
||||
}
|
||||
}
|
||||
|
||||
func NewTimeoutError() *errorz.ApiError {
|
||||
return &errorz.ApiError{
|
||||
Code: TimeoutCode,
|
||||
Message: TimeoutMessage,
|
||||
Status: TimeoutStatus,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package apierror
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func GetJsonParseError(e error, body []byte) error {
|
||||
if ute, ok := e.(*json.UnmarshalTypeError); ok {
|
||||
e = NewBodyParseTypeError(ute, string(body))
|
||||
} else if se, ok := e.(*json.SyntaxError); ok {
|
||||
e = NewBodyParseSyntaxError(se, string(body))
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package apierror
|
||||
|
||||
import "net/http"
|
||||
|
||||
const (
|
||||
MethodNotAllowedCode string = "METHOD_NOT_ALLOWED"
|
||||
MethodNotAllowedMessage string = "The resource requested does not support this HTTP verb"
|
||||
MethodNotAllowedStatus int = http.StatusMethodNotAllowed
|
||||
|
||||
CouldNotParseBodyCode string = "COULD_NOT_PARSE_BODY"
|
||||
CouldNotParseBodyMessage string = "The body of the request could not be parsed"
|
||||
CouldNotParseBodyStatus int = http.StatusBadRequest
|
||||
|
||||
CouldNotReadBodyCode string = "COULD_NOT_READ_BODY"
|
||||
CouldNotReadBodyMessage string = "The body of the request could not be read"
|
||||
CouldNotReadBodyStatus int = http.StatusInternalServerError
|
||||
|
||||
InvalidUuidCode string = "INVALID_UUID"
|
||||
InvalidUuidMessage string = "The supplied UUID is invalid"
|
||||
InvalidUuidStatus int = http.StatusBadRequest
|
||||
|
||||
InvalidContentTypeCode string = "INVALID_CONTENT_TYPE"
|
||||
InvalidContentTypeMessage string = "The content type supplied is not acceptable"
|
||||
InvalidContentTypeStatus int = http.StatusBadRequest
|
||||
)
|
||||
|
||||
// specific
|
||||
const (
|
||||
InvalidAuthCode string = "INVALID_AUTH"
|
||||
InvalidAuthMessage string = "The authentication request failed"
|
||||
InvalidAuthStatus int = http.StatusUnauthorized
|
||||
|
||||
InvalidAuthMethodCode string = "INVALID_AUTH_METHOD"
|
||||
InvalidAuthMethodMessage string = "The supplied authentication method is not valid"
|
||||
InvalidAuthMethodStatus int = http.StatusBadRequest
|
||||
|
||||
EnrollmentExpiredCode string = "ENROLLMENT_EXPIRED"
|
||||
EnrollmentExpiredMessage string = "The window for this enrollment has expired"
|
||||
EnrollmentExpiredStatus int = http.StatusBadRequest
|
||||
|
||||
CouldNotProcessCsrCode string = "COULD_NOT_PROCESS_CSR"
|
||||
CouldNotProcessCsrMessage string = "The supplied csr could not be processed"
|
||||
CouldNotProcessCsrStatus int = http.StatusBadRequest
|
||||
|
||||
EnrollmentCaNoLongValidCode string = "ENROLLMENT_CA_NOT_VALID"
|
||||
EnrollmentCaNoLongValidMessage string = "The CA tied to the supplied token is no longer valid"
|
||||
EnrollmentCaNoLongValidStatus int = http.StatusBadRequest
|
||||
|
||||
EnrollmentNoValidCasCode string = "ENROLLMENT_NO_VALID_CAS"
|
||||
EnrollmentNoValidCasMessage string = "No CAs are valid for this request"
|
||||
EnrollmentNoValidCasStatus int = http.StatusBadRequest
|
||||
|
||||
InvalidEnrollmentTokenCode string = "INVALID_ENROLLMENT_TOKEN"
|
||||
InvalidEnrollmentTokenMessage string = "The supplied token is not valid"
|
||||
InvalidEnrollmentTokenStatus int = http.StatusBadRequest
|
||||
|
||||
InvalidEnrollMethodCode string = "INVALID_ENROLL_METHOD"
|
||||
InvalidEnrollMethodMessage string = "The supplied enrollment method is not valid"
|
||||
InvalidEnrollMethodStatus int = http.StatusBadRequest
|
||||
|
||||
InvalidEnrollmentMissingCsrCode string = "MISSING_OR_INVALID_CSR"
|
||||
InvalidEnrollmentMissingCsrMessage string = "The supplied enrollment request is missing or contains an invalid CSR"
|
||||
InvalidEnrollmentMissingCsrStatus int = http.StatusBadRequest
|
||||
|
||||
NoEdgeRoutersAvailableCode string = "NO_EDGE_ROUTERS_AVAILABLE"
|
||||
NoEdgeRoutersAvailableMessage string = "No edge routers are assigned and online to handle the requested connection"
|
||||
NoEdgeRoutersAvailableStatus int = http.StatusBadRequest
|
||||
|
||||
CouldNotParseX509FromDerCode string = "COULD_NOT_PARSE_x509_FROM_DER"
|
||||
CouldNotParseX509FromDerMessage string = "could not parse x509 from DER"
|
||||
CouldNotParseX509FromDerStatus int = http.StatusBadRequest
|
||||
|
||||
CertFailedValidationCode string = "CERT_FAILED_VALIDATION"
|
||||
CertFailedValidationMessage string = "certificate failed to validate against CA"
|
||||
CertFailedValidationStatus int = http.StatusBadRequest
|
||||
|
||||
CertInUseCode string = "CERT_IN_USE"
|
||||
CertInUseMessage string = "The certificate supplied is already associated with another identity"
|
||||
CertInUseStatus int = http.StatusConflict
|
||||
|
||||
CaAlreadyVerifiedCode string = "CA_ALREADY_VERIFIED"
|
||||
CaAlreadyVerifiedMessage string = "CA has already been verified"
|
||||
CaAlreadyVerifiedStatus int = http.StatusConflict
|
||||
|
||||
ExpectedPemBlockCertificateCode = "EXPECTED_PEM_CERTIFICATE"
|
||||
ExpectedPemBlockCertificateMessage string = "expected PEM block type 'CERTIFICATE'"
|
||||
ExpectedPemBlockCertificateStatus int = http.StatusBadRequest
|
||||
|
||||
CouldNotParseDerBlockCode string = "COULD_NOT_PARSE_DER_BLOCK"
|
||||
CouldNotParseDerBlockMessage string = "The certificate's DER block could not be parsed"
|
||||
CouldNotParseDerBlockStatus int = http.StatusBadRequest
|
||||
|
||||
CouldNotParsePemCode string = "COULD_NOT_PARSE_PEM_BLOCK"
|
||||
CouldNotParsePemMessage string = "The certificate's PEM block could not be parsed"
|
||||
CouldNotParsePemStatus int = http.StatusBadRequest
|
||||
|
||||
InvalidCommonNameCode string = "INVALID_COMMON_NAME"
|
||||
InvalidCommonNameMessage string = "The common name of the supplied certificate is invalid"
|
||||
InvalidCommonNameStatus int = http.StatusBadRequest
|
||||
|
||||
FailedCertificateValidationCode string = "CERTIFICATE_FAILED_VALIDATION"
|
||||
FailedCertificateValidationMessage string = "The supplied certificate failed to validate against the CA's certificate chain"
|
||||
FailedCertificateValidationStatus int = http.StatusBadRequest
|
||||
|
||||
CertificateIsNotCaCode string = "CERTIFICATE_IS_NOT_CA"
|
||||
CertificateIsNotCaMessage string = "Leading certificate is not a CA"
|
||||
CertificateIsNotCaStatus int = http.StatusBadRequest
|
||||
|
||||
InvalidAuthenticatorPropertiesCode string = "INVALID_AUTHENTICATOR_PROPERTIES"
|
||||
InvalidAuthenticatorPropertiesMessage string = "The properties supplied did not match the authenticator method"
|
||||
InvalidAuthenticatorPropertiesStatus int = http.StatusBadRequest
|
||||
|
||||
AuthenticatorCanNotBeUpdatedCode string = "CAN_NOT_UPDATE_AUTHENTICATOR"
|
||||
AuthenticatorCanNotBeUpdatedMessage string = "The authenticator cannot be updated in this fashion"
|
||||
AuthenticatorCanNotBeUpdatedStatus int = http.StatusConflict
|
||||
|
||||
RouterCanNotBeUpdatedCode string = "CAN_NOT_UPDATE_ROUTER"
|
||||
RouterCanNotBeUpdatedMessage string = "The router was not added via the Edge API and cannot be updated"
|
||||
RouterCanNotBeUpdatedStatus int = http.StatusConflict
|
||||
|
||||
AuthenticatorMethodMaxCode string = "MAX_AUTHENTICATOR_METHODS_REACHED"
|
||||
AuthenticatorMethodMaxMessage string = "The identity already has the maximum authenticators of the specified method"
|
||||
AuthenticatorMethodMaxStatus int = http.StatusConflict
|
||||
|
||||
RateLimitedCode string = "RATE_LIMITED"
|
||||
RateLimitedMessage string = "The requested operation is rate limited and the rate limit has been exceeded. Please try again later"
|
||||
RateLimitedStatus int = http.StatusTooManyRequests
|
||||
|
||||
TimeoutCode string = "TIMEOUT"
|
||||
TimeoutMessage string = "The requested operation took too much time to reply"
|
||||
TimeoutStatus int = http.StatusServiceUnavailable
|
||||
|
||||
InvalidPostureCode string = "INVALID_POSTURE"
|
||||
InvalidPostureMessage string = "Posture response data is missing or wrong"
|
||||
InvalidPostureStatus int = http.StatusConflict
|
||||
|
||||
MfaExistsCode string = "MFA_EXISTS"
|
||||
MfaExistsMessage string = "An MFA record already exists, try removing it"
|
||||
MfaExistsStatus int = http.StatusConflict
|
||||
|
||||
/* #nosec */
|
||||
MfaInvalidTokenCode string = "MFA_INVALID_TOKEN"
|
||||
MfaInvalidTokenMessage string = "An invalid token/code was provided"
|
||||
MfaInvalidTokenStatus int = http.StatusBadRequest
|
||||
|
||||
MfaNotEnrolledCode string = "MFA_NOT_ENROLLED"
|
||||
MfaNotEnrolledMessage string = "The current identity is not enrolled in MFA"
|
||||
MfaNotEnrolledStatus int = http.StatusConflict
|
||||
)
|
||||
@@ -0,0 +1,61 @@
|
||||
package apierror
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/xeipuuv/gojsonschema"
|
||||
)
|
||||
|
||||
type ValidationErrors struct {
|
||||
Errors []*ValidationError
|
||||
}
|
||||
|
||||
func (e ValidationErrors) Error() string {
|
||||
return "schema validation failed"
|
||||
}
|
||||
|
||||
func (e ValidationErrors) MarshalJSON() ([]byte, error) {
|
||||
if len(e.Errors) > 1 {
|
||||
errMap := map[string]interface{}{
|
||||
"Reason": "multiple validation errors occurred",
|
||||
"Errors": e.Errors,
|
||||
}
|
||||
return json.Marshal(errMap)
|
||||
}
|
||||
|
||||
if len(e.Errors) == 1 {
|
||||
return json.Marshal(e.Errors[0])
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type ValidationError struct {
|
||||
Field string `json:"field"`
|
||||
Type string `json:"type"`
|
||||
Value interface{} `json:"value"`
|
||||
Message string `json:"message"`
|
||||
Details map[string]interface{} `json:"details"`
|
||||
}
|
||||
|
||||
func (e ValidationError) Error() string {
|
||||
return fmt.Sprintf("%s is invalid: %s", e.Field, e.Message)
|
||||
}
|
||||
|
||||
func NewValidationError(err gojsonschema.ResultError) *ValidationError {
|
||||
return &ValidationError{
|
||||
Field: err.Field(),
|
||||
Type: err.Type(),
|
||||
Value: err.Value(),
|
||||
Message: err.String(),
|
||||
Details: err.Details(),
|
||||
}
|
||||
}
|
||||
|
||||
func NewValidationErrors(result *gojsonschema.Result) *ValidationErrors {
|
||||
var errs []*ValidationError
|
||||
for _, re := range result.Errors() {
|
||||
errs = append(errs, NewValidationError(re))
|
||||
}
|
||||
return &ValidationErrors{Errors: errs}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/api_impl"
|
||||
"github.com/openziti/fabric/controller/handler_ctrl"
|
||||
"github.com/openziti/fabric/controller/handler_mgmt"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
@@ -82,6 +83,12 @@ func NewController(cfg *Config, versionProvider common.VersionProvider) (*Contro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c.initWeb()
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *Controller) initWeb() {
|
||||
healthChecker, err := c.initializeHealthChecks()
|
||||
if err != nil {
|
||||
logrus.WithError(err).Fatalf("failed to create health checker")
|
||||
@@ -91,7 +98,9 @@ func NewController(cfg *Config, versionProvider common.VersionProvider) (*Contro
|
||||
logrus.WithError(err).Fatalf("failed to create health checks api factory")
|
||||
}
|
||||
|
||||
return c, nil
|
||||
if err := c.RegisterXWebHandlerFactory(api_impl.NewManagementApiFactory(c.config.Id, c.network)); err != nil {
|
||||
logrus.WithError(err).Fatalf("failed to create management api factory")
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Controller) Run() error {
|
||||
|
||||
@@ -32,3 +32,8 @@ type baseStore struct {
|
||||
stores *stores
|
||||
*boltz.BaseStore
|
||||
}
|
||||
|
||||
type NameIndexedStore interface {
|
||||
boltz.CrudStore
|
||||
GetNameIndex() boltz.ReadIndex
|
||||
}
|
||||
|
||||
@@ -56,6 +56,10 @@ func (entity *Terminator) GetCost() uint16 {
|
||||
return entity.Cost
|
||||
}
|
||||
|
||||
func (entity *Terminator) GetPrecedence() xt.Precedence {
|
||||
return xt.GetPrecedenceForName(entity.Precedence)
|
||||
}
|
||||
|
||||
func (entity *Terminator) GetServiceId() string {
|
||||
return entity.Service
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -57,12 +56,12 @@ func (h *faultHandler) handleFault(msg *channel2.Message, ch channel2.Channel, f
|
||||
|
||||
switch fault.Subject {
|
||||
case ctrl_pb.FaultSubject_LinkFault:
|
||||
linkId := &identity.TokenId{Token: fault.Id}
|
||||
linkId := fault.Id
|
||||
if err := h.network.LinkConnected(linkId, false); err == nil {
|
||||
if link, found := h.network.GetLink(linkId); found {
|
||||
h.network.LinkChanged(link)
|
||||
}
|
||||
log.Infof("link fault [l/%s]", linkId.Token)
|
||||
log.Infof("link fault [l/%s]", linkId)
|
||||
}
|
||||
|
||||
case ctrl_pb.FaultSubject_IngressFault:
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
)
|
||||
|
||||
type linkHandler struct {
|
||||
@@ -53,7 +52,7 @@ func (h *linkHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel)
|
||||
func (h *linkHandler) HandleLink(msg *channel2.Message, ch channel2.Channel, link *ctrl_pb.Link) {
|
||||
log := pfxlog.ContextLogger(ch.Label())
|
||||
|
||||
if err := h.network.LinkConnected(&identity.TokenId{Token: link.Id}, true); err == nil {
|
||||
if err := h.network.LinkConnected(link.Id, true); err == nil {
|
||||
log.Infof("link connected [l/%s]", link.Id)
|
||||
} else {
|
||||
log.WithError(err).Error("unexpected error marking link connected")
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
)
|
||||
|
||||
type verifyLinkHandler struct {
|
||||
@@ -48,7 +47,7 @@ func (h *verifyLinkHandler) HandleReceive(msg *channel2.Message, ch channel2.Cha
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.network.VerifyLinkSource(h.r, &identity.TokenId{Token: verifyLink.LinkId}, verifyLink.Fingerprints); err == nil {
|
||||
if err := h.network.VerifyLinkSource(h.r, verifyLink.LinkId, verifyLink.Fingerprints); err == nil {
|
||||
go handler_common.SendSuccess(msg, ch, "link verified")
|
||||
log.Debugf("link verification successful [l/%s]", verifyLink.LinkId)
|
||||
} else {
|
||||
|
||||
@@ -76,7 +76,7 @@ func NewPath(path *network.Path) *mgmt_pb.Path {
|
||||
mgmtPath.Nodes = append(mgmtPath.Nodes, r.Id)
|
||||
}
|
||||
for _, l := range path.Links {
|
||||
mgmtPath.Links = append(mgmtPath.Links, l.Id.Token)
|
||||
mgmtPath.Links = append(mgmtPath.Links, l.Id)
|
||||
}
|
||||
return mgmtPath
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func (h *listLinksHandler) HandleReceive(msg *channel2.Message, ch channel2.Chan
|
||||
}
|
||||
for _, l := range links {
|
||||
responseLink := &mgmt_pb.Link{
|
||||
Id: l.Id.Token,
|
||||
Id: l.Id,
|
||||
Src: l.Src.Id,
|
||||
Dst: l.Dst.Id,
|
||||
State: l.CurrentState().Mode.String(),
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
)
|
||||
|
||||
type setLinkCostHandler struct {
|
||||
@@ -44,7 +43,7 @@ func (h *setLinkCostHandler) HandleReceive(msg *channel2.Message, ch channel2.Ch
|
||||
|
||||
set := &mgmt_pb.SetLinkCostRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, set); err == nil {
|
||||
if l, found := h.network.GetLink(&identity.TokenId{Token: set.LinkId}); found {
|
||||
if l, found := h.network.GetLink(set.LinkId); found {
|
||||
l.SetStaticCost(set.Cost)
|
||||
h.network.LinkChanged(l)
|
||||
log.Infof("set cost of link [l/%s] to [%d]", set.LinkId, set.Cost)
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
)
|
||||
|
||||
type setLinkDownHandler struct {
|
||||
@@ -44,7 +43,7 @@ func (h *setLinkDownHandler) HandleReceive(msg *channel2.Message, ch channel2.Ch
|
||||
|
||||
set := &mgmt_pb.SetLinkDownRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, set); err == nil {
|
||||
if l, found := h.network.GetLink(&identity.TokenId{Token: set.LinkId}); found {
|
||||
if l, found := h.network.GetLink(set.LinkId); found {
|
||||
l.SetDown(set.Down)
|
||||
h.network.LinkChanged(l)
|
||||
log.Infof("set down state of link [l/%s] to [%t]", set.LinkId, set.Down)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package idgen
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"github.com/teris-io/shortid"
|
||||
)
|
||||
|
||||
const Alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-"
|
||||
|
||||
var idGenerator Generator
|
||||
|
||||
func NewGenerator() Generator {
|
||||
buf := make([]byte, 8)
|
||||
_, _ = rand.Read(buf)
|
||||
seed := binary.LittleEndian.Uint64(buf)
|
||||
return &shortIdGenerator{
|
||||
Shortid: shortid.MustNew(0, Alphabet, seed),
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
idGenerator = NewGenerator()
|
||||
}
|
||||
|
||||
func New() string {
|
||||
id, _ := idGenerator.NextId()
|
||||
return id
|
||||
}
|
||||
|
||||
type Generator interface {
|
||||
NextId() (string, error)
|
||||
NextAlphaNumericPrefixedId() (string, error)
|
||||
}
|
||||
|
||||
type shortIdGenerator struct {
|
||||
*shortid.Shortid
|
||||
}
|
||||
|
||||
func (self *shortIdGenerator) NextId() (string, error) {
|
||||
return self.Generate()
|
||||
}
|
||||
|
||||
func (self *shortIdGenerator) NextAlphaNumericPrefixedId() (string, error) {
|
||||
for {
|
||||
id, err := self.NextId()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if id[0] != '-' && id[0] != '.' {
|
||||
return id, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,14 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/db"
|
||||
"github.com/openziti/foundation/storage/ast"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
"github.com/pkg/errors"
|
||||
"go.etcd.io/bbolt"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -224,3 +228,23 @@ func (ctrl *BaseController) PreparedListIndexedWithTx(tx *bbolt.Tx, cursorProvid
|
||||
|
||||
return resultHandler(tx, keys, qmd)
|
||||
}
|
||||
|
||||
func (ctrl *BaseController) ValidateNameOnUpdate(ctx boltz.MutateContext, updatedEntity, existingEntity boltz.Entity, checker boltz.FieldChecker) error {
|
||||
// validate name for named entities
|
||||
if namedEntity, ok := updatedEntity.(boltz.NamedExtEntity); ok {
|
||||
existingNamed := existingEntity.(boltz.NamedExtEntity)
|
||||
if (checker == nil || checker.IsUpdated("name")) && namedEntity.GetName() != existingNamed.GetName() {
|
||||
if namedEntity.GetName() == "" {
|
||||
return errorz.NewFieldError("name is required", "name", namedEntity.GetName())
|
||||
}
|
||||
if nameIndexStore, ok := ctrl.GetStore().(db.NameIndexedStore); ok {
|
||||
if nameIndexStore.GetNameIndex().Read(ctx.Tx(), []byte(namedEntity.GetName())) != nil {
|
||||
return errorz.NewFieldError("name is must be unique", "name", namedEntity.GetName())
|
||||
}
|
||||
} else {
|
||||
pfxlog.Logger().Errorf("entity of type %v is named, but store doesn't have name index", reflect.TypeOf(updatedEntity))
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func (network *Network) assemble() {
|
||||
network.linkController.add(missingLink)
|
||||
|
||||
dial := &ctrl_pb.Dial{
|
||||
LinkId: missingLink.Id.Token,
|
||||
LinkId: missingLink.Id,
|
||||
Address: missingLink.Dst.AdvertisedListener,
|
||||
RouterId: missingLink.Dst.Id,
|
||||
}
|
||||
@@ -65,11 +65,11 @@ func (network *Network) clean() {
|
||||
lRemove := make(map[string]*Link)
|
||||
for _, l := range failedLinks {
|
||||
if now-l.CurrentState().Timestamp >= 30000 {
|
||||
lRemove[l.Id.Token] = l
|
||||
lRemove[l.Id] = l
|
||||
}
|
||||
}
|
||||
for _, lr := range lRemove {
|
||||
log.Infof("removing [l/%s]", lr.Id.Token)
|
||||
log.Infof("removing [l/%s]", lr.Id)
|
||||
network.linkController.remove(lr)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"github.com/openziti/fabric/controller/idgen"
|
||||
"github.com/openziti/fabric/controller/xt"
|
||||
"github.com/openziti/foundation/util/concurrenz"
|
||||
"github.com/orcaman/concurrent-map"
|
||||
@@ -42,15 +43,21 @@ func (self *Circuit) latency() int64 {
|
||||
}
|
||||
|
||||
type circuitController struct {
|
||||
circuits cmap.ConcurrentMap // map[string]*Circuit
|
||||
circuits cmap.ConcurrentMap // map[string]*Circuit
|
||||
idGenerator idgen.Generator
|
||||
}
|
||||
|
||||
func newCircuitController() *circuitController {
|
||||
return &circuitController{
|
||||
circuits: cmap.New(),
|
||||
circuits: cmap.New(),
|
||||
idGenerator: idgen.NewGenerator(),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *circuitController) nextCircuitId() (string, error) {
|
||||
return c.idGenerator.NextAlphaNumericPrefixedId()
|
||||
}
|
||||
|
||||
func (c *circuitController) add(sn *Circuit) {
|
||||
c.circuits.Set(sn.Id, sn)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/db"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/foundation/storage/ast"
|
||||
@@ -155,3 +156,34 @@ func (ctrl *baseController) BasePreparedListAssociated(id string, typeLoader mod
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type boltEntitySource interface {
|
||||
models.Entity
|
||||
toBolt() boltz.Entity
|
||||
}
|
||||
|
||||
func (ctrl *baseController) updateGeneral(modelEntity boltEntitySource, checker boltz.FieldChecker) error {
|
||||
return ctrl.db.Update(func(tx *bbolt.Tx) error {
|
||||
ctx := boltz.NewMutateContext(tx)
|
||||
existing := ctrl.GetStore().NewStoreEntity()
|
||||
found, err := ctrl.GetStore().BaseLoadOneById(tx, modelEntity.GetId(), existing)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !found {
|
||||
return boltz.NewNotFoundError(ctrl.GetStore().GetSingularEntityType(), "id", modelEntity.GetId())
|
||||
}
|
||||
|
||||
boltEntity := modelEntity.toBolt()
|
||||
|
||||
if err := ctrl.ValidateNameOnUpdate(ctx, boltEntity, existing, checker); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := ctrl.GetStore().Update(ctx, boltEntity, checker); err != nil {
|
||||
pfxlog.Logger().WithError(err).Errorf("could not update %v entity", ctrl.GetStore().GetEntityType())
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/openziti/foundation/util/concurrenz"
|
||||
"github.com/openziti/foundation/util/info"
|
||||
"sync"
|
||||
@@ -25,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
type Link struct {
|
||||
Id *identity.TokenId
|
||||
Id string
|
||||
Src *Router
|
||||
Dst *Router
|
||||
state []*LinkState
|
||||
@@ -38,7 +37,7 @@ type Link struct {
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
func newLink(id *identity.TokenId) *Link {
|
||||
func newLink(id string) *Link {
|
||||
l := &Link{
|
||||
Id: id,
|
||||
state: make([]*LinkState, 0),
|
||||
@@ -50,6 +49,10 @@ func newLink(id *identity.TokenId) *Link {
|
||||
return l
|
||||
}
|
||||
|
||||
func (link *Link) GetId() string {
|
||||
return link.Id
|
||||
}
|
||||
|
||||
func (link *Link) CurrentState() *LinkState {
|
||||
link.lock.Lock()
|
||||
defer link.lock.Unlock()
|
||||
|
||||
@@ -17,23 +17,22 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/openziti/fabric/controller/idgen"
|
||||
"github.com/openziti/foundation/util/info"
|
||||
"github.com/openziti/foundation/util/sequence"
|
||||
"github.com/orcaman/concurrent-map"
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
type linkController struct {
|
||||
linkTable *linkTable
|
||||
sequence *sequence.Sequence
|
||||
linkTable *linkTable
|
||||
idGenerator idgen.Generator
|
||||
}
|
||||
|
||||
func newLinkController() *linkController {
|
||||
return &linkController{
|
||||
linkTable: newLinkTable(),
|
||||
sequence: sequence.NewSequence(),
|
||||
linkTable: newLinkTable(),
|
||||
idGenerator: idgen.NewGenerator(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +46,7 @@ func (linkController *linkController) has(link *Link) bool {
|
||||
return linkController.linkTable.has(link)
|
||||
}
|
||||
|
||||
func (linkController *linkController) get(linkId *identity.TokenId) (*Link, bool) {
|
||||
func (linkController *linkController) get(linkId string) (*Link, bool) {
|
||||
link, found := linkController.linkTable.get(linkId)
|
||||
return link, found
|
||||
}
|
||||
@@ -126,11 +125,11 @@ func (linkController *linkController) missingLinks(routers []*Router, pendingTim
|
||||
for _, dstR := range routers {
|
||||
if srcR != dstR && dstR.AdvertisedListener != "" {
|
||||
if !linkController.hasLink(srcR, dstR, pendingLimit) {
|
||||
id, err := linkController.sequence.NextHash()
|
||||
id, err := linkController.idGenerator.NextAlphaNumericPrefixedId()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
link := newLink(&identity.TokenId{Token: id})
|
||||
link := newLink(id)
|
||||
link.Src = srcR
|
||||
link.Dst = dstR
|
||||
missingLinks = append(missingLinks, link)
|
||||
@@ -176,11 +175,11 @@ func newLinkTable() *linkTable {
|
||||
}
|
||||
|
||||
func (lt *linkTable) add(link *Link) {
|
||||
lt.links.Set(link.Id.Token, link)
|
||||
lt.links.Set(link.Id, link)
|
||||
}
|
||||
|
||||
func (lt *linkTable) get(linkId *identity.TokenId) (*Link, bool) {
|
||||
link, found := lt.links.Get(linkId.Token)
|
||||
func (lt *linkTable) get(linkId string) (*Link, bool) {
|
||||
link, found := lt.links.Get(linkId)
|
||||
if link != nil {
|
||||
return link.(*Link), found
|
||||
}
|
||||
@@ -188,7 +187,7 @@ func (lt *linkTable) get(linkId *identity.TokenId) (*Link, bool) {
|
||||
}
|
||||
|
||||
func (lt *linkTable) has(link *Link) bool {
|
||||
if i, found := lt.links.Get(link.Id.Token); found {
|
||||
if i, found := lt.links.Get(link.Id); found {
|
||||
if i.(*Link) == link {
|
||||
return true
|
||||
}
|
||||
@@ -197,7 +196,7 @@ func (lt *linkTable) has(link *Link) bool {
|
||||
}
|
||||
|
||||
func (lt *linkTable) all() []*Link {
|
||||
links := make([]*Link, 0)
|
||||
links := make([]*Link, 0, lt.links.Count())
|
||||
for i := range lt.links.IterBuffered() {
|
||||
links = append(links, i.Val.(*Link))
|
||||
}
|
||||
@@ -216,7 +215,7 @@ func (lt *linkTable) allInMode(mode LinkMode) []*Link {
|
||||
}
|
||||
|
||||
func (lt *linkTable) remove(link *Link) {
|
||||
lt.links.Remove(link.Id.Token)
|
||||
lt.links.Remove(link.Id)
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
@@ -28,7 +27,7 @@ func TestLifecycle(t *testing.T) {
|
||||
r0 := NewRouter("r0", "", "")
|
||||
r1 := NewRouter("r1", "", "")
|
||||
l0 := &Link{
|
||||
Id: &identity.TokenId{Token: "l0"},
|
||||
Id: "l0",
|
||||
Src: r0,
|
||||
Dst: r1,
|
||||
}
|
||||
@@ -60,7 +59,7 @@ func TestNeighbors(t *testing.T) {
|
||||
r0 := newRouterForTest("r0", "", nil, nil)
|
||||
r1 := newRouterForTest("r1", "", nil, nil)
|
||||
l0 := &Link{
|
||||
Id: &identity.TokenId{Token: "l0"},
|
||||
Id: "l0",
|
||||
Src: r0,
|
||||
Dst: r1,
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ func (network *Network) AllConnectedRouters() []*Router {
|
||||
return network.Routers.allConnected()
|
||||
}
|
||||
|
||||
func (network *Network) GetLink(linkId *identity.TokenId) (*Link, bool) {
|
||||
func (network *Network) GetLink(linkId string) (*Link, bool) {
|
||||
return network.linkController.get(linkId)
|
||||
}
|
||||
|
||||
@@ -308,35 +308,35 @@ func (network *Network) DisconnectRouter(r *Router) {
|
||||
}
|
||||
}
|
||||
|
||||
func (network *Network) LinkConnected(id *identity.TokenId, connected bool) error {
|
||||
func (network *Network) LinkConnected(id string, connected bool) error {
|
||||
log := pfxlog.Logger()
|
||||
|
||||
if l, found := network.linkController.get(id); found {
|
||||
if connected {
|
||||
l.addState(newLinkState(Connected))
|
||||
log.Infof("link [l/%s] connected", id.Token)
|
||||
log.Infof("link [l/%s] connected", id)
|
||||
return nil
|
||||
}
|
||||
l.addState(newLinkState(Failed))
|
||||
log.Infof("link [l/%s] failed", id.Token)
|
||||
log.Infof("link [l/%s] failed", id)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("no such link [l/%s]", id.Token)
|
||||
return fmt.Errorf("no such link [l/%s]", id)
|
||||
}
|
||||
|
||||
func (network *Network) VerifyLinkSource(targetRouter *Router, id *identity.TokenId, fingerprints []string) error {
|
||||
l, found := network.linkController.get(id)
|
||||
func (network *Network) VerifyLinkSource(targetRouter *Router, linkId string, fingerprints []string) error {
|
||||
l, found := network.linkController.get(linkId)
|
||||
if !found {
|
||||
return errors.Errorf("invalid link %v", id.Token)
|
||||
return errors.Errorf("invalid link %v", linkId)
|
||||
}
|
||||
|
||||
if l.Dst.Id != targetRouter.Id {
|
||||
return errors.Errorf("incorrect link target router. link=%v, expected router=%v, actual router=%v", l.Id.Token, l.Dst.Id, targetRouter.Id)
|
||||
return errors.Errorf("incorrect link target router. link=%v, expected router=%v, actual router=%v", l.Id, l.Dst.Id, targetRouter.Id)
|
||||
}
|
||||
|
||||
routerFingerprint := l.Src.Fingerprint
|
||||
if routerFingerprint == nil {
|
||||
return errors.Errorf("invalid source router %v for link %v, not yet enrolled", l.Src.Id, l.Id.Token)
|
||||
return errors.Errorf("invalid source router %v for link %v, not yet enrolled", l.Src.Id, l.Id)
|
||||
}
|
||||
|
||||
for _, fp := range fingerprints {
|
||||
@@ -345,7 +345,7 @@ func (network *Network) VerifyLinkSource(targetRouter *Router, id *identity.Toke
|
||||
}
|
||||
}
|
||||
|
||||
return errors.Errorf("could not verify fingerprint for router %v on link %v", l.Src.Id, l.Id.Token)
|
||||
return errors.Errorf("could not verify fingerprint for router %v on link %v", l.Src.Id, l.Id)
|
||||
}
|
||||
|
||||
func (network *Network) LinkChanged(l *Link) {
|
||||
@@ -357,7 +357,7 @@ func (network *Network) LinkChanged(l *Link) {
|
||||
|
||||
func (network *Network) CreateCircuit(srcR *Router, clientId *identity.TokenId, service string, ctx logcontext.Context) (*Circuit, error) {
|
||||
// 1: Allocate Circuit Identifier
|
||||
circuitId, err := network.sequence.NextHash()
|
||||
circuitId, err := network.circuitController.nextCircuitId()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -461,7 +461,7 @@ func (network *Network) CreateCircuit(srcR *Router, clientId *identity.TokenId,
|
||||
logger.Debugf("cleaned up [%d] abandoned routers for [s/%s]", cleanupCount, circuitId)
|
||||
|
||||
// 6: Create Circuit Object
|
||||
ss := &Circuit{
|
||||
circuit := &Circuit{
|
||||
Id: circuitId,
|
||||
ClientId: clientId.Token,
|
||||
Service: svc,
|
||||
@@ -469,11 +469,11 @@ func (network *Network) CreateCircuit(srcR *Router, clientId *identity.TokenId,
|
||||
Terminator: terminator,
|
||||
PeerData: peerData,
|
||||
}
|
||||
network.circuitController.add(ss)
|
||||
network.CircuitCreated(ss.Id, ss.ClientId, ss.Service.Id, ss.Path)
|
||||
network.circuitController.add(circuit)
|
||||
network.CircuitCreated(circuit.Id, circuit.ClientId, circuit.Service.Id, circuit.Path)
|
||||
|
||||
logger.Debugf("created circuit [s/%s] ==> %s", circuitId, ss.Path)
|
||||
return ss, nil
|
||||
logger.Debugf("created circuit [s/%s] ==> %s", circuitId, circuit.Path)
|
||||
return circuit, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,7 +729,7 @@ func (network *Network) Run() {
|
||||
}
|
||||
|
||||
func (network *Network) handleLinkChanged(l *Link) {
|
||||
logrus.Infof("changed link [l/%s]", l.Id.Token)
|
||||
logrus.Infof("changed link [l/%s]", l.Id)
|
||||
if err := network.rerouteLink(l); err != nil {
|
||||
logrus.Errorf("unexpected error rerouting link (%s)", err)
|
||||
}
|
||||
@@ -752,12 +752,12 @@ func (network *Network) GetCapabilities() []string {
|
||||
}
|
||||
|
||||
func (network *Network) rerouteLink(l *Link) error {
|
||||
logrus.Infof("link [l/%s] changed", l.Id.Token)
|
||||
logrus.Infof("link [l/%s] changed", l.Id)
|
||||
|
||||
circuits := network.circuitController.all()
|
||||
for _, s := range circuits {
|
||||
if s.Path.usesLink(l) {
|
||||
logrus.Infof("circuit [s/%s] uses link [l/%s]", s.Id, l.Id.Token)
|
||||
logrus.Infof("circuit [s/%s] uses link [l/%s]", s.Id, l.Id)
|
||||
if err := network.rerouteCircuit(s); err != nil {
|
||||
logrus.Errorf("error rerouting circuit [s/%s], removing", s.Id)
|
||||
if err := network.RemoveCircuit(s.Id, true); err != nil {
|
||||
@@ -849,7 +849,7 @@ func (network *Network) AcceptMetrics(metrics *metrics_pb.MetricsMessage) {
|
||||
}
|
||||
|
||||
for _, link := range network.GetAllLinksForRouter(router.Id) {
|
||||
metricId := "link." + link.Id.Token + ".latency"
|
||||
metricId := "link." + link.Id + ".latency"
|
||||
if latency, ok := metrics.Histograms[metricId]; ok {
|
||||
if link.Src.Id == router.Id {
|
||||
link.SetSrcLatency(int64(latency.Mean)) // latency is in nanoseconds
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *Path) String() string {
|
||||
}
|
||||
out := fmt.Sprintf("[r/%s]", self.Nodes[0].Id)
|
||||
for i := 0; i < len(self.Links); i++ {
|
||||
out += fmt.Sprintf("->[l/%s]", self.Links[i].Id.Token)
|
||||
out += fmt.Sprintf("->[l/%s]", self.Links[i].Id)
|
||||
out += fmt.Sprintf("->[r/%s]", self.Nodes[i+1].Id)
|
||||
}
|
||||
return out
|
||||
@@ -100,10 +100,10 @@ func (self *Path) CreateRouteMessages(attempt uint32, circuitId string, terminat
|
||||
routeMessage := &ctrl_pb.Route{CircuitId: circuitId, Attempt: attempt}
|
||||
routeMessage.Forwards = append(routeMessage.Forwards, &ctrl_pb.Route_Forward{
|
||||
SrcAddress: self.IngressId,
|
||||
DstAddress: link.Id.Token,
|
||||
DstAddress: link.Id,
|
||||
})
|
||||
routeMessage.Forwards = append(routeMessage.Forwards, &ctrl_pb.Route_Forward{
|
||||
SrcAddress: link.Id.Token,
|
||||
SrcAddress: link.Id,
|
||||
DstAddress: self.IngressId,
|
||||
})
|
||||
routeMessages = append(routeMessages, routeMessage)
|
||||
@@ -113,12 +113,12 @@ func (self *Path) CreateRouteMessages(attempt uint32, circuitId string, terminat
|
||||
nextLink := self.Links[i+1]
|
||||
routeMessage := &ctrl_pb.Route{CircuitId: circuitId, Attempt: attempt}
|
||||
routeMessage.Forwards = append(routeMessage.Forwards, &ctrl_pb.Route_Forward{
|
||||
SrcAddress: link.Id.Token,
|
||||
DstAddress: nextLink.Id.Token,
|
||||
SrcAddress: link.Id,
|
||||
DstAddress: nextLink.Id,
|
||||
})
|
||||
routeMessage.Forwards = append(routeMessage.Forwards, &ctrl_pb.Route_Forward{
|
||||
SrcAddress: nextLink.Id.Token,
|
||||
DstAddress: link.Id.Token,
|
||||
SrcAddress: nextLink.Id,
|
||||
DstAddress: link.Id,
|
||||
})
|
||||
routeMessages = append(routeMessages, routeMessage)
|
||||
}
|
||||
@@ -132,10 +132,10 @@ func (self *Path) CreateRouteMessages(attempt uint32, circuitId string, terminat
|
||||
}
|
||||
routeMessage.Forwards = append(routeMessage.Forwards, &ctrl_pb.Route_Forward{
|
||||
SrcAddress: self.EgressId,
|
||||
DstAddress: link.Id.Token,
|
||||
DstAddress: link.Id,
|
||||
})
|
||||
routeMessage.Forwards = append(routeMessage.Forwards, &ctrl_pb.Route_Forward{
|
||||
SrcAddress: link.Id.Token,
|
||||
SrcAddress: link.Id,
|
||||
DstAddress: self.EgressId,
|
||||
})
|
||||
routeMessages = append(routeMessages, routeMessage)
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/common"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/openziti/foundation/transport"
|
||||
"github.com/openziti/foundation/transport/tcp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -50,7 +49,7 @@ func TestSimplePath2(t *testing.T) {
|
||||
r1 := newRouterForTest("r1", "", transportAddr, nil)
|
||||
network.Routers.markConnected(r1)
|
||||
|
||||
l0 := newLink(&identity.TokenId{Token: "l0"})
|
||||
l0 := newLink("l0")
|
||||
l0.Src = r0
|
||||
l0.Dst = r1
|
||||
l0.addState(newLinkState(Connected))
|
||||
@@ -78,8 +77,8 @@ func TestSimplePath2(t *testing.T) {
|
||||
assert.Nil(t, rm0.Egress)
|
||||
assert.Equal(t, 2, len(rm0.Forwards))
|
||||
assert.Equal(t, path.IngressId, rm0.Forwards[0].SrcAddress)
|
||||
assert.Equal(t, l0.Id.Token, rm0.Forwards[0].DstAddress)
|
||||
assert.Equal(t, l0.Id.Token, rm0.Forwards[1].SrcAddress)
|
||||
assert.Equal(t, l0.Id, rm0.Forwards[0].DstAddress)
|
||||
assert.Equal(t, l0.Id, rm0.Forwards[1].SrcAddress)
|
||||
assert.Equal(t, path.IngressId, rm0.Forwards[1].DstAddress)
|
||||
|
||||
// egress route message
|
||||
@@ -89,8 +88,8 @@ func TestSimplePath2(t *testing.T) {
|
||||
assert.Equal(t, path.EgressId, rm1.Egress.Address)
|
||||
assert.Equal(t, addr, rm1.Egress.Destination)
|
||||
assert.Equal(t, path.EgressId, rm1.Forwards[0].SrcAddress)
|
||||
assert.Equal(t, l0.Id.Token, rm1.Forwards[0].DstAddress)
|
||||
assert.Equal(t, l0.Id.Token, rm1.Forwards[1].SrcAddress)
|
||||
assert.Equal(t, l0.Id, rm1.Forwards[0].DstAddress)
|
||||
assert.Equal(t, l0.Id, rm1.Forwards[1].SrcAddress)
|
||||
assert.Equal(t, path.EgressId, rm1.Forwards[1].DstAddress)
|
||||
}
|
||||
|
||||
@@ -117,13 +116,13 @@ func TestTransitPath2(t *testing.T) {
|
||||
r2 := newRouterForTest("r2", "", transportAddr, nil)
|
||||
network.Routers.markConnected(r2)
|
||||
|
||||
l0 := newLink(&identity.TokenId{Token: "l0"})
|
||||
l0 := newLink("l0")
|
||||
l0.Src = r0
|
||||
l0.Dst = r1
|
||||
l0.addState(newLinkState(Connected))
|
||||
network.linkController.add(l0)
|
||||
|
||||
l1 := newLink(&identity.TokenId{Token: "l1"})
|
||||
l1 := newLink("l1")
|
||||
l1.Src = r1
|
||||
l1.Dst = r2
|
||||
l1.addState(newLinkState(Connected))
|
||||
@@ -153,8 +152,8 @@ func TestTransitPath2(t *testing.T) {
|
||||
assert.Nil(t, rm0.Egress)
|
||||
assert.Equal(t, 2, len(rm0.Forwards))
|
||||
assert.Equal(t, path.IngressId, rm0.Forwards[0].SrcAddress)
|
||||
assert.Equal(t, l0.Id.Token, rm0.Forwards[0].DstAddress)
|
||||
assert.Equal(t, l0.Id.Token, rm0.Forwards[1].SrcAddress)
|
||||
assert.Equal(t, l0.Id, rm0.Forwards[0].DstAddress)
|
||||
assert.Equal(t, l0.Id, rm0.Forwards[1].SrcAddress)
|
||||
assert.Equal(t, path.IngressId, rm0.Forwards[1].DstAddress)
|
||||
|
||||
// transit route message
|
||||
@@ -162,10 +161,10 @@ func TestTransitPath2(t *testing.T) {
|
||||
assert.Equal(t, "s0", rm1.CircuitId)
|
||||
assert.Nil(t, rm1.Egress)
|
||||
assert.Equal(t, 2, len(rm1.Forwards))
|
||||
assert.Equal(t, l0.Id.Token, rm1.Forwards[0].SrcAddress)
|
||||
assert.Equal(t, l1.Id.Token, rm1.Forwards[0].DstAddress)
|
||||
assert.Equal(t, l1.Id.Token, rm1.Forwards[1].SrcAddress)
|
||||
assert.Equal(t, l0.Id.Token, rm1.Forwards[1].DstAddress)
|
||||
assert.Equal(t, l0.Id, rm1.Forwards[0].SrcAddress)
|
||||
assert.Equal(t, l1.Id, rm1.Forwards[0].DstAddress)
|
||||
assert.Equal(t, l1.Id, rm1.Forwards[1].SrcAddress)
|
||||
assert.Equal(t, l0.Id, rm1.Forwards[1].DstAddress)
|
||||
|
||||
// egress route message
|
||||
rm2 := routeMessages[2]
|
||||
@@ -174,8 +173,8 @@ func TestTransitPath2(t *testing.T) {
|
||||
assert.Equal(t, path.EgressId, rm2.Egress.Address)
|
||||
assert.Equal(t, transportAddr.String(), rm2.Egress.Destination)
|
||||
assert.Equal(t, path.EgressId, rm2.Forwards[0].SrcAddress)
|
||||
assert.Equal(t, l1.Id.Token, rm2.Forwards[0].DstAddress)
|
||||
assert.Equal(t, l1.Id.Token, rm2.Forwards[1].SrcAddress)
|
||||
assert.Equal(t, l1.Id, rm2.Forwards[0].DstAddress)
|
||||
assert.Equal(t, l1.Id, rm2.Forwards[1].SrcAddress)
|
||||
assert.Equal(t, path.EgressId, rm2.Forwards[1].DstAddress)
|
||||
}
|
||||
|
||||
@@ -256,7 +255,7 @@ func TestShortestPath(t *testing.T) {
|
||||
r3 := newRouterForTest("r3", "", transportAddr, nil)
|
||||
network.Routers.markConnected(r3)
|
||||
|
||||
link := newLink(&identity.TokenId{Token: "l0"})
|
||||
link := newLink("l0")
|
||||
link.SetStaticCost(2)
|
||||
link.SetDstLatency(10 * 1_000_000)
|
||||
link.SetSrcLatency(11 * 1_000_000)
|
||||
@@ -265,7 +264,7 @@ func TestShortestPath(t *testing.T) {
|
||||
link.addState(newLinkState(Connected))
|
||||
network.linkController.add(link)
|
||||
|
||||
link = newLink(&identity.TokenId{Token: "l1"})
|
||||
link = newLink("l1")
|
||||
link.SetStaticCost(5)
|
||||
link.SetDstLatency(15 * 1_000_000)
|
||||
link.SetSrcLatency(16 * 1_000_000)
|
||||
@@ -274,7 +273,7 @@ func TestShortestPath(t *testing.T) {
|
||||
link.addState(newLinkState(Connected))
|
||||
network.linkController.add(link)
|
||||
|
||||
link = newLink(&identity.TokenId{Token: "l2"})
|
||||
link = newLink("l2")
|
||||
link.SetStaticCost(9)
|
||||
link.SetDstLatency(20 * 1_000_000)
|
||||
link.SetSrcLatency(21 * 1_000_000)
|
||||
@@ -283,7 +282,7 @@ func TestShortestPath(t *testing.T) {
|
||||
link.addState(newLinkState(Connected))
|
||||
network.linkController.add(link)
|
||||
|
||||
link = newLink(&identity.TokenId{Token: "l3"})
|
||||
link = newLink("l3")
|
||||
link.SetStaticCost(13)
|
||||
link.SetDstLatency(25 * 1_000_000)
|
||||
link.SetSrcLatency(26 * 1_000_000)
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/db"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/sirupsen/logrus"
|
||||
"math/rand"
|
||||
"testing"
|
||||
@@ -58,7 +57,7 @@ func TestShortestPathAgainstEstablished(t *testing.T) {
|
||||
|
||||
addLink := func(srcRouter, dstRouter *Router) {
|
||||
if srcRouter != dstRouter {
|
||||
link := newLink(&identity.TokenId{Token: fmt.Sprintf("link-%04d", linkIdx)})
|
||||
link := newLink(fmt.Sprintf("link-%04d", linkIdx))
|
||||
link.SetStaticCost(int32(nextCost()))
|
||||
link.SetDstLatency(nextCost() * 100_000)
|
||||
link.SetSrcLatency(nextCost() * 100_000)
|
||||
@@ -184,7 +183,7 @@ func BenchmarkShortestPathPerfWithRouterChanges(b *testing.B) {
|
||||
|
||||
addLink := func(srcRouter, dstRouter *Router) {
|
||||
if srcRouter != dstRouter {
|
||||
link := newLink(&identity.TokenId{Token: fmt.Sprintf("link-%04d", linkIdx)})
|
||||
link := newLink(fmt.Sprintf("link-%04d", linkIdx))
|
||||
link.SetStaticCost(int32(nextCost()))
|
||||
link.SetDstLatency(nextCost() * 100_000)
|
||||
link.SetSrcLatency(nextCost() * 100_000)
|
||||
@@ -278,7 +277,7 @@ func BenchmarkShortestPathPerf(b *testing.B) {
|
||||
|
||||
addLink := func(srcRouter, dstRouter *Router) {
|
||||
if srcRouter != dstRouter {
|
||||
link := newLink(&identity.TokenId{Token: fmt.Sprintf("link-%04d", linkIdx)})
|
||||
link := newLink(fmt.Sprintf("link-%04d", linkIdx))
|
||||
link.SetStaticCost(int32(nextCost()))
|
||||
link.SetDstLatency(nextCost() * 100_000)
|
||||
link.SetSrcLatency(nextCost() * 100_000)
|
||||
@@ -352,7 +351,7 @@ func BenchmarkMoreRealisticShortestPathPerf(b *testing.B) {
|
||||
|
||||
addLink := func(srcRouter, dstRouter *Router) {
|
||||
if srcRouter != dstRouter {
|
||||
link := newLink(&identity.TokenId{Token: fmt.Sprintf("link-%04d", linkIdx)})
|
||||
link := newLink(fmt.Sprintf("link-%04d", linkIdx))
|
||||
link.SetStaticCost(int32(nextCost()))
|
||||
link.SetDstLatency(nextCost() * 100_000)
|
||||
link.SetSrcLatency(nextCost() * 100_000)
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/openziti/foundation/common"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"github.com/openziti/foundation/util/concurrenz"
|
||||
"github.com/openziti/foundation/util/stringz"
|
||||
"github.com/orcaman/concurrent-map"
|
||||
"github.com/pkg/errors"
|
||||
"go.etcd.io/bbolt"
|
||||
@@ -54,7 +55,7 @@ func (entity *Router) fillFrom(_ Controller, _ *bbolt.Tx, boltEntity boltz.Entit
|
||||
return nil
|
||||
}
|
||||
|
||||
func (entity *Router) toBolt() *db.Router {
|
||||
func (entity *Router) toBolt() boltz.Entity {
|
||||
return &db.Router{
|
||||
BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags),
|
||||
Name: entity.Name,
|
||||
@@ -241,6 +242,28 @@ func (ctrl *RouterController) UpdateCachedFingerprint(id, fingerprint string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (ctrl *RouterController) Update(r *Router) error {
|
||||
if err := ctrl.updateGeneral(r, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ctrl.UpdateCachedFingerprint(r.Id, stringz.OrEmpty(r.Fingerprint))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ctrl *RouterController) Patch(r *Router, checker boltz.FieldChecker) error {
|
||||
if err := ctrl.updateGeneral(r, checker); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if checker.IsUpdated("fingerprint") {
|
||||
ctrl.UpdateCachedFingerprint(r.Id, stringz.OrEmpty(r.Fingerprint))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type RouterLinks struct {
|
||||
sync.Mutex
|
||||
allLinks atomic.Value
|
||||
|
||||
@@ -53,7 +53,7 @@ func (entity *Service) fillFrom(ctrl Controller, tx *bbolt.Tx, boltEntity boltz.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (entity *Service) toBolt() *db.Service {
|
||||
func (entity *Service) toBolt() boltz.Entity {
|
||||
return &db.Service{
|
||||
BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags),
|
||||
Name: entity.Name,
|
||||
@@ -126,10 +126,17 @@ func (ctrl *ServiceController) Create(s *Service) error {
|
||||
}
|
||||
|
||||
func (ctrl *ServiceController) Update(s *Service) error {
|
||||
err := ctrl.db.Update(func(tx *bbolt.Tx) error {
|
||||
return ctrl.store.Update(boltz.NewMutateContext(tx), s.toBolt(), nil)
|
||||
})
|
||||
if err != nil {
|
||||
if err := ctrl.updateGeneral(s, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ctrl.RemoveFromCache(s.Id) // don't cache entity as not all fields may be changed, wait for read to reload
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ctrl *ServiceController) Patch(s *Service, checker boltz.FieldChecker) error {
|
||||
if err := ctrl.updateGeneral(s, checker); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ func debugPath(p *Path) {
|
||||
if len(p.Links) > 0 {
|
||||
nodes = nodes[1:]
|
||||
for _, link := range p.Links {
|
||||
debugf(" -> [l/%v cost=%v] -> [r/%v]", link.Id.Token, link.Cost, nodes[0].Id)
|
||||
debugf(" -> [l/%v cost=%v] -> [r/%v]", link.Id, link.Cost, nodes[0].Id)
|
||||
}
|
||||
}
|
||||
debugf("\n")
|
||||
@@ -125,11 +125,11 @@ func debugNetwork(n *Network) {
|
||||
debugf("%v router: %v\n", rIdx, router.Id)
|
||||
links := router.routerLinks.GetLinks()
|
||||
sort.Slice(links, func(i, j int) bool {
|
||||
return links[i].Id.Token < links[j].Id.Token
|
||||
return links[i].Id < links[j].Id
|
||||
})
|
||||
for lIdx, link := range links {
|
||||
debugf(" %v link %v for (%v -> %v) c: %v sc: %v sl:%v dl: %v\n",
|
||||
lIdx, link.Id.Token, link.Src.Id, link.Dst.Id, link.GetCost(), link.StaticCost, link.SrcLatency, link.DstLatency)
|
||||
lIdx, link.Id, link.Src.Id, link.Dst.Id, link.GetCost(), link.StaticCost, link.SrcLatency, link.DstLatency)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,6 +33,7 @@ type Factory interface {
|
||||
|
||||
type Terminator interface {
|
||||
GetId() string
|
||||
GetPrecedence() Precedence
|
||||
GetCost() uint16
|
||||
GetServiceId() string
|
||||
GetRouterId() string
|
||||
@@ -47,7 +48,6 @@ type PeerData map[uint32][]byte
|
||||
type CostedTerminator interface {
|
||||
Terminator
|
||||
GetRouteCost() uint32
|
||||
GetPrecedence() Precedence
|
||||
}
|
||||
|
||||
type StrategyChangeEvent interface {
|
||||
|
||||
+1
-2
@@ -5,7 +5,6 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/foundation/events"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/openziti/foundation/metrics/metrics_pb"
|
||||
"github.com/pkg/errors"
|
||||
"reflect"
|
||||
@@ -47,7 +46,7 @@ func mapLinkMetrics(_ *metrics_pb.MetricsMessage, event *MetricsEvent) {
|
||||
event.Metric = name
|
||||
event.SourceEntityId = linkId
|
||||
|
||||
if link, _ := currentNetwork.GetLink(&identity.TokenId{Token: linkId}); link != nil {
|
||||
if link, _ := currentNetwork.GetLink(linkId); link != nil {
|
||||
sourceTags := event.Tags
|
||||
event.Tags = map[string]string{}
|
||||
for k, v := range sourceTags {
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
// 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 circuit
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// New creates a new circuit API client.
|
||||
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
|
||||
return &Client{transport: transport, formats: formats}
|
||||
}
|
||||
|
||||
/*
|
||||
Client for circuit API
|
||||
*/
|
||||
type Client struct {
|
||||
transport runtime.ClientTransport
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ClientOption is the option for Client methods
|
||||
type ClientOption func(*runtime.ClientOperation)
|
||||
|
||||
// ClientService is the interface for Client methods
|
||||
type ClientService interface {
|
||||
DeleteCircuit(params *DeleteCircuitParams, opts ...ClientOption) (*DeleteCircuitOK, error)
|
||||
|
||||
DetailCircuit(params *DetailCircuitParams, opts ...ClientOption) (*DetailCircuitOK, error)
|
||||
|
||||
ListCircuits(params *ListCircuitsParams, opts ...ClientOption) (*ListCircuitsOK, error)
|
||||
|
||||
SetTransport(transport runtime.ClientTransport)
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteCircuit deletes a circuit
|
||||
|
||||
Delete a circuit by id. Requires admin access.
|
||||
*/
|
||||
func (a *Client) DeleteCircuit(params *DeleteCircuitParams, opts ...ClientOption) (*DeleteCircuitOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewDeleteCircuitParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "deleteCircuit",
|
||||
Method: "DELETE",
|
||||
PathPattern: "/circuits/{id}",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &DeleteCircuitReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*DeleteCircuitOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for deleteCircuit: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
DetailCircuit retrieves a single circuit
|
||||
|
||||
Retrieves a single circuit by id. Requires admin access.
|
||||
*/
|
||||
func (a *Client) DetailCircuit(params *DetailCircuitParams, opts ...ClientOption) (*DetailCircuitOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewDetailCircuitParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "detailCircuit",
|
||||
Method: "GET",
|
||||
PathPattern: "/circuits/{id}",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &DetailCircuitReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*DetailCircuitOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for detailCircuit: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
ListCircuits lists circuits
|
||||
|
||||
Retrieves a list of circuit resources; does not supports filtering, sorting, or pagination. Requires admin access.
|
||||
|
||||
*/
|
||||
func (a *Client) ListCircuits(params *ListCircuitsParams, opts ...ClientOption) (*ListCircuitsOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewListCircuitsParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "listCircuits",
|
||||
Method: "GET",
|
||||
PathPattern: "/circuits",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &ListCircuitsReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*ListCircuitsOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for listCircuits: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client
|
||||
func (a *Client) SetTransport(transport runtime.ClientTransport) {
|
||||
a.transport = transport
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// 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 circuit
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// NewDeleteCircuitParams creates a new DeleteCircuitParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewDeleteCircuitParams() *DeleteCircuitParams {
|
||||
return &DeleteCircuitParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteCircuitParamsWithTimeout creates a new DeleteCircuitParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewDeleteCircuitParamsWithTimeout(timeout time.Duration) *DeleteCircuitParams {
|
||||
return &DeleteCircuitParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteCircuitParamsWithContext creates a new DeleteCircuitParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewDeleteCircuitParamsWithContext(ctx context.Context) *DeleteCircuitParams {
|
||||
return &DeleteCircuitParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteCircuitParamsWithHTTPClient creates a new DeleteCircuitParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewDeleteCircuitParamsWithHTTPClient(client *http.Client) *DeleteCircuitParams {
|
||||
return &DeleteCircuitParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* DeleteCircuitParams contains all the parameters to send to the API endpoint
|
||||
for the delete circuit operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type DeleteCircuitParams struct {
|
||||
|
||||
/* ID.
|
||||
|
||||
The id of the requested resource
|
||||
*/
|
||||
ID string
|
||||
|
||||
/* Options.
|
||||
|
||||
A circuit delete object
|
||||
*/
|
||||
Options *rest_model.CircuitDelete
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the delete circuit params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DeleteCircuitParams) WithDefaults() *DeleteCircuitParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the delete circuit params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DeleteCircuitParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the delete circuit params
|
||||
func (o *DeleteCircuitParams) WithTimeout(timeout time.Duration) *DeleteCircuitParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the delete circuit params
|
||||
func (o *DeleteCircuitParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the delete circuit params
|
||||
func (o *DeleteCircuitParams) WithContext(ctx context.Context) *DeleteCircuitParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the delete circuit params
|
||||
func (o *DeleteCircuitParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the delete circuit params
|
||||
func (o *DeleteCircuitParams) WithHTTPClient(client *http.Client) *DeleteCircuitParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the delete circuit params
|
||||
func (o *DeleteCircuitParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the delete circuit params
|
||||
func (o *DeleteCircuitParams) WithID(id string) *DeleteCircuitParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the delete circuit params
|
||||
func (o *DeleteCircuitParams) SetID(id string) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WithOptions adds the options to the delete circuit params
|
||||
func (o *DeleteCircuitParams) WithOptions(options *rest_model.CircuitDelete) *DeleteCircuitParams {
|
||||
o.SetOptions(options)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetOptions adds the options to the delete circuit params
|
||||
func (o *DeleteCircuitParams) SetOptions(options *rest_model.CircuitDelete) {
|
||||
o.Options = options
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *DeleteCircuitParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
if o.Options != nil {
|
||||
if err := r.SetBodyParam(o.Options); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
// 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 circuit
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// DeleteCircuitReader is a Reader for the DeleteCircuit structure.
|
||||
type DeleteCircuitReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *DeleteCircuitReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewDeleteCircuitOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 400:
|
||||
result := NewDeleteCircuitBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 401:
|
||||
result := NewDeleteCircuitUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 409:
|
||||
result := NewDeleteCircuitConflict()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteCircuitOK creates a DeleteCircuitOK with default headers values
|
||||
func NewDeleteCircuitOK() *DeleteCircuitOK {
|
||||
return &DeleteCircuitOK{}
|
||||
}
|
||||
|
||||
/* DeleteCircuitOK describes a response with status code 200, with default header values.
|
||||
|
||||
The delete request was successful and the resource has been removed
|
||||
*/
|
||||
type DeleteCircuitOK struct {
|
||||
Payload *rest_model.Empty
|
||||
}
|
||||
|
||||
func (o *DeleteCircuitOK) Error() string {
|
||||
return fmt.Sprintf("[DELETE /circuits/{id}][%d] deleteCircuitOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *DeleteCircuitOK) GetPayload() *rest_model.Empty {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteCircuitOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.Empty)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteCircuitBadRequest creates a DeleteCircuitBadRequest with default headers values
|
||||
func NewDeleteCircuitBadRequest() *DeleteCircuitBadRequest {
|
||||
return &DeleteCircuitBadRequest{}
|
||||
}
|
||||
|
||||
/* DeleteCircuitBadRequest describes a response with status code 400, with default header values.
|
||||
|
||||
The supplied request contains invalid fields or could not be parsed (json and non-json bodies). The error's code, message, and cause fields can be inspected for further information
|
||||
*/
|
||||
type DeleteCircuitBadRequest struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DeleteCircuitBadRequest) Error() string {
|
||||
return fmt.Sprintf("[DELETE /circuits/{id}][%d] deleteCircuitBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
func (o *DeleteCircuitBadRequest) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteCircuitBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteCircuitUnauthorized creates a DeleteCircuitUnauthorized with default headers values
|
||||
func NewDeleteCircuitUnauthorized() *DeleteCircuitUnauthorized {
|
||||
return &DeleteCircuitUnauthorized{}
|
||||
}
|
||||
|
||||
/* DeleteCircuitUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type DeleteCircuitUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DeleteCircuitUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[DELETE /circuits/{id}][%d] deleteCircuitUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *DeleteCircuitUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteCircuitUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteCircuitConflict creates a DeleteCircuitConflict with default headers values
|
||||
func NewDeleteCircuitConflict() *DeleteCircuitConflict {
|
||||
return &DeleteCircuitConflict{}
|
||||
}
|
||||
|
||||
/* DeleteCircuitConflict describes a response with status code 409, with default header values.
|
||||
|
||||
The resource requested to be removed/altered cannot be as it is referenced by another object.
|
||||
*/
|
||||
type DeleteCircuitConflict struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DeleteCircuitConflict) Error() string {
|
||||
return fmt.Sprintf("[DELETE /circuits/{id}][%d] deleteCircuitConflict %+v", 409, o.Payload)
|
||||
}
|
||||
func (o *DeleteCircuitConflict) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteCircuitConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
// 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 circuit
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewDetailCircuitParams creates a new DetailCircuitParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewDetailCircuitParams() *DetailCircuitParams {
|
||||
return &DetailCircuitParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailCircuitParamsWithTimeout creates a new DetailCircuitParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewDetailCircuitParamsWithTimeout(timeout time.Duration) *DetailCircuitParams {
|
||||
return &DetailCircuitParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailCircuitParamsWithContext creates a new DetailCircuitParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewDetailCircuitParamsWithContext(ctx context.Context) *DetailCircuitParams {
|
||||
return &DetailCircuitParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailCircuitParamsWithHTTPClient creates a new DetailCircuitParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewDetailCircuitParamsWithHTTPClient(client *http.Client) *DetailCircuitParams {
|
||||
return &DetailCircuitParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* DetailCircuitParams contains all the parameters to send to the API endpoint
|
||||
for the detail circuit operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type DetailCircuitParams struct {
|
||||
|
||||
/* ID.
|
||||
|
||||
The id of the requested resource
|
||||
*/
|
||||
ID string
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the detail circuit params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DetailCircuitParams) WithDefaults() *DetailCircuitParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the detail circuit params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DetailCircuitParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the detail circuit params
|
||||
func (o *DetailCircuitParams) WithTimeout(timeout time.Duration) *DetailCircuitParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the detail circuit params
|
||||
func (o *DetailCircuitParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the detail circuit params
|
||||
func (o *DetailCircuitParams) WithContext(ctx context.Context) *DetailCircuitParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the detail circuit params
|
||||
func (o *DetailCircuitParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the detail circuit params
|
||||
func (o *DetailCircuitParams) WithHTTPClient(client *http.Client) *DetailCircuitParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the detail circuit params
|
||||
func (o *DetailCircuitParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the detail circuit params
|
||||
func (o *DetailCircuitParams) WithID(id string) *DetailCircuitParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the detail circuit params
|
||||
func (o *DetailCircuitParams) SetID(id string) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *DetailCircuitParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// 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 circuit
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// DetailCircuitReader is a Reader for the DetailCircuit structure.
|
||||
type DetailCircuitReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *DetailCircuitReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewDetailCircuitOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 401:
|
||||
result := NewDetailCircuitUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 404:
|
||||
result := NewDetailCircuitNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailCircuitOK creates a DetailCircuitOK with default headers values
|
||||
func NewDetailCircuitOK() *DetailCircuitOK {
|
||||
return &DetailCircuitOK{}
|
||||
}
|
||||
|
||||
/* DetailCircuitOK describes a response with status code 200, with default header values.
|
||||
|
||||
A single circuit
|
||||
*/
|
||||
type DetailCircuitOK struct {
|
||||
Payload *rest_model.DetailCircuitEnvelope
|
||||
}
|
||||
|
||||
func (o *DetailCircuitOK) Error() string {
|
||||
return fmt.Sprintf("[GET /circuits/{id}][%d] detailCircuitOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *DetailCircuitOK) GetPayload() *rest_model.DetailCircuitEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DetailCircuitOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.DetailCircuitEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDetailCircuitUnauthorized creates a DetailCircuitUnauthorized with default headers values
|
||||
func NewDetailCircuitUnauthorized() *DetailCircuitUnauthorized {
|
||||
return &DetailCircuitUnauthorized{}
|
||||
}
|
||||
|
||||
/* DetailCircuitUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type DetailCircuitUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DetailCircuitUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[GET /circuits/{id}][%d] detailCircuitUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *DetailCircuitUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DetailCircuitUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDetailCircuitNotFound creates a DetailCircuitNotFound with default headers values
|
||||
func NewDetailCircuitNotFound() *DetailCircuitNotFound {
|
||||
return &DetailCircuitNotFound{}
|
||||
}
|
||||
|
||||
/* DetailCircuitNotFound describes a response with status code 404, with default header values.
|
||||
|
||||
The requested resource does not exist
|
||||
*/
|
||||
type DetailCircuitNotFound struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DetailCircuitNotFound) Error() string {
|
||||
return fmt.Sprintf("[GET /circuits/{id}][%d] detailCircuitNotFound %+v", 404, o.Payload)
|
||||
}
|
||||
func (o *DetailCircuitNotFound) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DetailCircuitNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
// 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 circuit
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewListCircuitsParams creates a new ListCircuitsParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewListCircuitsParams() *ListCircuitsParams {
|
||||
return &ListCircuitsParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListCircuitsParamsWithTimeout creates a new ListCircuitsParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewListCircuitsParamsWithTimeout(timeout time.Duration) *ListCircuitsParams {
|
||||
return &ListCircuitsParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListCircuitsParamsWithContext creates a new ListCircuitsParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewListCircuitsParamsWithContext(ctx context.Context) *ListCircuitsParams {
|
||||
return &ListCircuitsParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListCircuitsParamsWithHTTPClient creates a new ListCircuitsParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewListCircuitsParamsWithHTTPClient(client *http.Client) *ListCircuitsParams {
|
||||
return &ListCircuitsParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* ListCircuitsParams contains all the parameters to send to the API endpoint
|
||||
for the list circuits operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ListCircuitsParams struct {
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the list circuits params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ListCircuitsParams) WithDefaults() *ListCircuitsParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the list circuits params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ListCircuitsParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the list circuits params
|
||||
func (o *ListCircuitsParams) WithTimeout(timeout time.Duration) *ListCircuitsParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the list circuits params
|
||||
func (o *ListCircuitsParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the list circuits params
|
||||
func (o *ListCircuitsParams) WithContext(ctx context.Context) *ListCircuitsParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the list circuits params
|
||||
func (o *ListCircuitsParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the list circuits params
|
||||
func (o *ListCircuitsParams) WithHTTPClient(client *http.Client) *ListCircuitsParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the list circuits params
|
||||
func (o *ListCircuitsParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ListCircuitsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// 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 circuit
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// ListCircuitsReader is a Reader for the ListCircuits structure.
|
||||
type ListCircuitsReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ListCircuitsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewListCircuitsOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 401:
|
||||
result := NewListCircuitsUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewListCircuitsOK creates a ListCircuitsOK with default headers values
|
||||
func NewListCircuitsOK() *ListCircuitsOK {
|
||||
return &ListCircuitsOK{}
|
||||
}
|
||||
|
||||
/* ListCircuitsOK describes a response with status code 200, with default header values.
|
||||
|
||||
A list of circuits
|
||||
*/
|
||||
type ListCircuitsOK struct {
|
||||
Payload *rest_model.ListCircuitsEnvelope
|
||||
}
|
||||
|
||||
func (o *ListCircuitsOK) Error() string {
|
||||
return fmt.Sprintf("[GET /circuits][%d] listCircuitsOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *ListCircuitsOK) GetPayload() *rest_model.ListCircuitsEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListCircuitsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.ListCircuitsEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewListCircuitsUnauthorized creates a ListCircuitsUnauthorized with default headers values
|
||||
func NewListCircuitsUnauthorized() *ListCircuitsUnauthorized {
|
||||
return &ListCircuitsUnauthorized{}
|
||||
}
|
||||
|
||||
/* ListCircuitsUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type ListCircuitsUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *ListCircuitsUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[GET /circuits][%d] listCircuitsUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *ListCircuitsUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListCircuitsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
// 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 link
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewDetailLinkParams creates a new DetailLinkParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewDetailLinkParams() *DetailLinkParams {
|
||||
return &DetailLinkParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailLinkParamsWithTimeout creates a new DetailLinkParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewDetailLinkParamsWithTimeout(timeout time.Duration) *DetailLinkParams {
|
||||
return &DetailLinkParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailLinkParamsWithContext creates a new DetailLinkParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewDetailLinkParamsWithContext(ctx context.Context) *DetailLinkParams {
|
||||
return &DetailLinkParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailLinkParamsWithHTTPClient creates a new DetailLinkParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewDetailLinkParamsWithHTTPClient(client *http.Client) *DetailLinkParams {
|
||||
return &DetailLinkParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* DetailLinkParams contains all the parameters to send to the API endpoint
|
||||
for the detail link operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type DetailLinkParams struct {
|
||||
|
||||
/* ID.
|
||||
|
||||
The id of the requested resource
|
||||
*/
|
||||
ID string
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the detail link params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DetailLinkParams) WithDefaults() *DetailLinkParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the detail link params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DetailLinkParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the detail link params
|
||||
func (o *DetailLinkParams) WithTimeout(timeout time.Duration) *DetailLinkParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the detail link params
|
||||
func (o *DetailLinkParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the detail link params
|
||||
func (o *DetailLinkParams) WithContext(ctx context.Context) *DetailLinkParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the detail link params
|
||||
func (o *DetailLinkParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the detail link params
|
||||
func (o *DetailLinkParams) WithHTTPClient(client *http.Client) *DetailLinkParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the detail link params
|
||||
func (o *DetailLinkParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the detail link params
|
||||
func (o *DetailLinkParams) WithID(id string) *DetailLinkParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the detail link params
|
||||
func (o *DetailLinkParams) SetID(id string) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *DetailLinkParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// 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 link
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// DetailLinkReader is a Reader for the DetailLink structure.
|
||||
type DetailLinkReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *DetailLinkReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewDetailLinkOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 401:
|
||||
result := NewDetailLinkUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 404:
|
||||
result := NewDetailLinkNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailLinkOK creates a DetailLinkOK with default headers values
|
||||
func NewDetailLinkOK() *DetailLinkOK {
|
||||
return &DetailLinkOK{}
|
||||
}
|
||||
|
||||
/* DetailLinkOK describes a response with status code 200, with default header values.
|
||||
|
||||
A single link
|
||||
*/
|
||||
type DetailLinkOK struct {
|
||||
Payload *rest_model.DetailLinkEnvelope
|
||||
}
|
||||
|
||||
func (o *DetailLinkOK) Error() string {
|
||||
return fmt.Sprintf("[GET /links/{id}][%d] detailLinkOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *DetailLinkOK) GetPayload() *rest_model.DetailLinkEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DetailLinkOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.DetailLinkEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDetailLinkUnauthorized creates a DetailLinkUnauthorized with default headers values
|
||||
func NewDetailLinkUnauthorized() *DetailLinkUnauthorized {
|
||||
return &DetailLinkUnauthorized{}
|
||||
}
|
||||
|
||||
/* DetailLinkUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type DetailLinkUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DetailLinkUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[GET /links/{id}][%d] detailLinkUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *DetailLinkUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DetailLinkUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDetailLinkNotFound creates a DetailLinkNotFound with default headers values
|
||||
func NewDetailLinkNotFound() *DetailLinkNotFound {
|
||||
return &DetailLinkNotFound{}
|
||||
}
|
||||
|
||||
/* DetailLinkNotFound describes a response with status code 404, with default header values.
|
||||
|
||||
The requested resource does not exist
|
||||
*/
|
||||
type DetailLinkNotFound struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DetailLinkNotFound) Error() string {
|
||||
return fmt.Sprintf("[GET /links/{id}][%d] detailLinkNotFound %+v", 404, o.Payload)
|
||||
}
|
||||
func (o *DetailLinkNotFound) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DetailLinkNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
// 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 link
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// New creates a new link API client.
|
||||
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
|
||||
return &Client{transport: transport, formats: formats}
|
||||
}
|
||||
|
||||
/*
|
||||
Client for link API
|
||||
*/
|
||||
type Client struct {
|
||||
transport runtime.ClientTransport
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ClientOption is the option for Client methods
|
||||
type ClientOption func(*runtime.ClientOperation)
|
||||
|
||||
// ClientService is the interface for Client methods
|
||||
type ClientService interface {
|
||||
DetailLink(params *DetailLinkParams, opts ...ClientOption) (*DetailLinkOK, error)
|
||||
|
||||
ListLinks(params *ListLinksParams, opts ...ClientOption) (*ListLinksOK, error)
|
||||
|
||||
PatchLink(params *PatchLinkParams, opts ...ClientOption) (*PatchLinkOK, error)
|
||||
|
||||
SetTransport(transport runtime.ClientTransport)
|
||||
}
|
||||
|
||||
/*
|
||||
DetailLink retrieves a single link
|
||||
|
||||
Retrieves a single link by id. Requires admin access.
|
||||
*/
|
||||
func (a *Client) DetailLink(params *DetailLinkParams, opts ...ClientOption) (*DetailLinkOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewDetailLinkParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "detailLink",
|
||||
Method: "GET",
|
||||
PathPattern: "/links/{id}",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &DetailLinkReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*DetailLinkOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for detailLink: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
ListLinks lists links
|
||||
|
||||
Retrieves a list of link resources; does not supports filtering, sorting, or pagination. Requires admin access.
|
||||
|
||||
*/
|
||||
func (a *Client) ListLinks(params *ListLinksParams, opts ...ClientOption) (*ListLinksOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewListLinksParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "listLinks",
|
||||
Method: "GET",
|
||||
PathPattern: "/links",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &ListLinksReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*ListLinksOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for listLinks: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
PatchLink updates the supplied fields on a link
|
||||
|
||||
Update the supplied fields on a link. Requires admin access.
|
||||
*/
|
||||
func (a *Client) PatchLink(params *PatchLinkParams, opts ...ClientOption) (*PatchLinkOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewPatchLinkParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "patchLink",
|
||||
Method: "PATCH",
|
||||
PathPattern: "/links/{id}",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &PatchLinkReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*PatchLinkOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for patchLink: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client
|
||||
func (a *Client) SetTransport(transport runtime.ClientTransport) {
|
||||
a.transport = transport
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
// 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 link
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewListLinksParams creates a new ListLinksParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewListLinksParams() *ListLinksParams {
|
||||
return &ListLinksParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListLinksParamsWithTimeout creates a new ListLinksParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewListLinksParamsWithTimeout(timeout time.Duration) *ListLinksParams {
|
||||
return &ListLinksParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListLinksParamsWithContext creates a new ListLinksParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewListLinksParamsWithContext(ctx context.Context) *ListLinksParams {
|
||||
return &ListLinksParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListLinksParamsWithHTTPClient creates a new ListLinksParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewListLinksParamsWithHTTPClient(client *http.Client) *ListLinksParams {
|
||||
return &ListLinksParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* ListLinksParams contains all the parameters to send to the API endpoint
|
||||
for the list links operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ListLinksParams struct {
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the list links params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ListLinksParams) WithDefaults() *ListLinksParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the list links params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ListLinksParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the list links params
|
||||
func (o *ListLinksParams) WithTimeout(timeout time.Duration) *ListLinksParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the list links params
|
||||
func (o *ListLinksParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the list links params
|
||||
func (o *ListLinksParams) WithContext(ctx context.Context) *ListLinksParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the list links params
|
||||
func (o *ListLinksParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the list links params
|
||||
func (o *ListLinksParams) WithHTTPClient(client *http.Client) *ListLinksParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the list links params
|
||||
func (o *ListLinksParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ListLinksParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// 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 link
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// ListLinksReader is a Reader for the ListLinks structure.
|
||||
type ListLinksReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ListLinksReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewListLinksOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 401:
|
||||
result := NewListLinksUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewListLinksOK creates a ListLinksOK with default headers values
|
||||
func NewListLinksOK() *ListLinksOK {
|
||||
return &ListLinksOK{}
|
||||
}
|
||||
|
||||
/* ListLinksOK describes a response with status code 200, with default header values.
|
||||
|
||||
A list of links
|
||||
*/
|
||||
type ListLinksOK struct {
|
||||
Payload *rest_model.ListLinksEnvelope
|
||||
}
|
||||
|
||||
func (o *ListLinksOK) Error() string {
|
||||
return fmt.Sprintf("[GET /links][%d] listLinksOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *ListLinksOK) GetPayload() *rest_model.ListLinksEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListLinksOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.ListLinksEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewListLinksUnauthorized creates a ListLinksUnauthorized with default headers values
|
||||
func NewListLinksUnauthorized() *ListLinksUnauthorized {
|
||||
return &ListLinksUnauthorized{}
|
||||
}
|
||||
|
||||
/* ListLinksUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type ListLinksUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *ListLinksUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[GET /links][%d] listLinksUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *ListLinksUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListLinksUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// 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 link
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// NewPatchLinkParams creates a new PatchLinkParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewPatchLinkParams() *PatchLinkParams {
|
||||
return &PatchLinkParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewPatchLinkParamsWithTimeout creates a new PatchLinkParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewPatchLinkParamsWithTimeout(timeout time.Duration) *PatchLinkParams {
|
||||
return &PatchLinkParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewPatchLinkParamsWithContext creates a new PatchLinkParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewPatchLinkParamsWithContext(ctx context.Context) *PatchLinkParams {
|
||||
return &PatchLinkParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewPatchLinkParamsWithHTTPClient creates a new PatchLinkParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewPatchLinkParamsWithHTTPClient(client *http.Client) *PatchLinkParams {
|
||||
return &PatchLinkParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* PatchLinkParams contains all the parameters to send to the API endpoint
|
||||
for the patch link operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type PatchLinkParams struct {
|
||||
|
||||
/* ID.
|
||||
|
||||
The id of the requested resource
|
||||
*/
|
||||
ID string
|
||||
|
||||
/* Link.
|
||||
|
||||
A link patch object
|
||||
*/
|
||||
Link *rest_model.LinkPatch
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the patch link params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *PatchLinkParams) WithDefaults() *PatchLinkParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the patch link params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *PatchLinkParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the patch link params
|
||||
func (o *PatchLinkParams) WithTimeout(timeout time.Duration) *PatchLinkParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the patch link params
|
||||
func (o *PatchLinkParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the patch link params
|
||||
func (o *PatchLinkParams) WithContext(ctx context.Context) *PatchLinkParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the patch link params
|
||||
func (o *PatchLinkParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the patch link params
|
||||
func (o *PatchLinkParams) WithHTTPClient(client *http.Client) *PatchLinkParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the patch link params
|
||||
func (o *PatchLinkParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the patch link params
|
||||
func (o *PatchLinkParams) WithID(id string) *PatchLinkParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the patch link params
|
||||
func (o *PatchLinkParams) SetID(id string) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WithLink adds the link to the patch link params
|
||||
func (o *PatchLinkParams) WithLink(link *rest_model.LinkPatch) *PatchLinkParams {
|
||||
o.SetLink(link)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetLink adds the link to the patch link params
|
||||
func (o *PatchLinkParams) SetLink(link *rest_model.LinkPatch) {
|
||||
o.Link = link
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *PatchLinkParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
if o.Link != nil {
|
||||
if err := r.SetBodyParam(o.Link); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
// 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 link
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// PatchLinkReader is a Reader for the PatchLink structure.
|
||||
type PatchLinkReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *PatchLinkReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewPatchLinkOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 400:
|
||||
result := NewPatchLinkBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 401:
|
||||
result := NewPatchLinkUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 404:
|
||||
result := NewPatchLinkNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewPatchLinkOK creates a PatchLinkOK with default headers values
|
||||
func NewPatchLinkOK() *PatchLinkOK {
|
||||
return &PatchLinkOK{}
|
||||
}
|
||||
|
||||
/* PatchLinkOK describes a response with status code 200, with default header values.
|
||||
|
||||
The patch request was successful and the resource has been altered
|
||||
*/
|
||||
type PatchLinkOK struct {
|
||||
Payload *rest_model.Empty
|
||||
}
|
||||
|
||||
func (o *PatchLinkOK) Error() string {
|
||||
return fmt.Sprintf("[PATCH /links/{id}][%d] patchLinkOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *PatchLinkOK) GetPayload() *rest_model.Empty {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PatchLinkOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.Empty)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewPatchLinkBadRequest creates a PatchLinkBadRequest with default headers values
|
||||
func NewPatchLinkBadRequest() *PatchLinkBadRequest {
|
||||
return &PatchLinkBadRequest{}
|
||||
}
|
||||
|
||||
/* PatchLinkBadRequest describes a response with status code 400, with default header values.
|
||||
|
||||
The supplied request contains invalid fields or could not be parsed (json and non-json bodies). The error's code, message, and cause fields can be inspected for further information
|
||||
*/
|
||||
type PatchLinkBadRequest struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *PatchLinkBadRequest) Error() string {
|
||||
return fmt.Sprintf("[PATCH /links/{id}][%d] patchLinkBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
func (o *PatchLinkBadRequest) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PatchLinkBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewPatchLinkUnauthorized creates a PatchLinkUnauthorized with default headers values
|
||||
func NewPatchLinkUnauthorized() *PatchLinkUnauthorized {
|
||||
return &PatchLinkUnauthorized{}
|
||||
}
|
||||
|
||||
/* PatchLinkUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type PatchLinkUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *PatchLinkUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[PATCH /links/{id}][%d] patchLinkUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *PatchLinkUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PatchLinkUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewPatchLinkNotFound creates a PatchLinkNotFound with default headers values
|
||||
func NewPatchLinkNotFound() *PatchLinkNotFound {
|
||||
return &PatchLinkNotFound{}
|
||||
}
|
||||
|
||||
/* PatchLinkNotFound describes a response with status code 404, with default header values.
|
||||
|
||||
The requested resource does not exist
|
||||
*/
|
||||
type PatchLinkNotFound struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *PatchLinkNotFound) Error() string {
|
||||
return fmt.Sprintf("[PATCH /links/{id}][%d] patchLinkNotFound %+v", 404, o.Payload)
|
||||
}
|
||||
func (o *PatchLinkNotFound) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PatchLinkNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// NewCreateRouterParams creates a new CreateRouterParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewCreateRouterParams() *CreateRouterParams {
|
||||
return &CreateRouterParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateRouterParamsWithTimeout creates a new CreateRouterParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewCreateRouterParamsWithTimeout(timeout time.Duration) *CreateRouterParams {
|
||||
return &CreateRouterParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateRouterParamsWithContext creates a new CreateRouterParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewCreateRouterParamsWithContext(ctx context.Context) *CreateRouterParams {
|
||||
return &CreateRouterParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateRouterParamsWithHTTPClient creates a new CreateRouterParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewCreateRouterParamsWithHTTPClient(client *http.Client) *CreateRouterParams {
|
||||
return &CreateRouterParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* CreateRouterParams contains all the parameters to send to the API endpoint
|
||||
for the create router operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type CreateRouterParams struct {
|
||||
|
||||
/* Router.
|
||||
|
||||
A router to create
|
||||
*/
|
||||
Router *rest_model.RouterCreate
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the create router params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *CreateRouterParams) WithDefaults() *CreateRouterParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the create router params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *CreateRouterParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the create router params
|
||||
func (o *CreateRouterParams) WithTimeout(timeout time.Duration) *CreateRouterParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the create router params
|
||||
func (o *CreateRouterParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the create router params
|
||||
func (o *CreateRouterParams) WithContext(ctx context.Context) *CreateRouterParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the create router params
|
||||
func (o *CreateRouterParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the create router params
|
||||
func (o *CreateRouterParams) WithHTTPClient(client *http.Client) *CreateRouterParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the create router params
|
||||
func (o *CreateRouterParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithRouter adds the router to the create router params
|
||||
func (o *CreateRouterParams) WithRouter(router *rest_model.RouterCreate) *CreateRouterParams {
|
||||
o.SetRouter(router)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetRouter adds the router to the create router params
|
||||
func (o *CreateRouterParams) SetRouter(router *rest_model.RouterCreate) {
|
||||
o.Router = router
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *CreateRouterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Router != nil {
|
||||
if err := r.SetBodyParam(o.Router); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// CreateRouterReader is a Reader for the CreateRouter structure.
|
||||
type CreateRouterReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *CreateRouterReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 201:
|
||||
result := NewCreateRouterCreated()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 400:
|
||||
result := NewCreateRouterBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 401:
|
||||
result := NewCreateRouterUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateRouterCreated creates a CreateRouterCreated with default headers values
|
||||
func NewCreateRouterCreated() *CreateRouterCreated {
|
||||
return &CreateRouterCreated{}
|
||||
}
|
||||
|
||||
/* CreateRouterCreated describes a response with status code 201, with default header values.
|
||||
|
||||
The create request was successful and the resource has been added at the following location
|
||||
*/
|
||||
type CreateRouterCreated struct {
|
||||
Payload *rest_model.CreateEnvelope
|
||||
}
|
||||
|
||||
func (o *CreateRouterCreated) Error() string {
|
||||
return fmt.Sprintf("[POST /routers][%d] createRouterCreated %+v", 201, o.Payload)
|
||||
}
|
||||
func (o *CreateRouterCreated) GetPayload() *rest_model.CreateEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *CreateRouterCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.CreateEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewCreateRouterBadRequest creates a CreateRouterBadRequest with default headers values
|
||||
func NewCreateRouterBadRequest() *CreateRouterBadRequest {
|
||||
return &CreateRouterBadRequest{}
|
||||
}
|
||||
|
||||
/* CreateRouterBadRequest describes a response with status code 400, with default header values.
|
||||
|
||||
The supplied request contains invalid fields or could not be parsed (json and non-json bodies). The error's code, message, and cause fields can be inspected for further information
|
||||
*/
|
||||
type CreateRouterBadRequest struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *CreateRouterBadRequest) Error() string {
|
||||
return fmt.Sprintf("[POST /routers][%d] createRouterBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
func (o *CreateRouterBadRequest) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *CreateRouterBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewCreateRouterUnauthorized creates a CreateRouterUnauthorized with default headers values
|
||||
func NewCreateRouterUnauthorized() *CreateRouterUnauthorized {
|
||||
return &CreateRouterUnauthorized{}
|
||||
}
|
||||
|
||||
/* CreateRouterUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type CreateRouterUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *CreateRouterUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[POST /routers][%d] createRouterUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *CreateRouterUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *CreateRouterUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewDeleteRouterParams creates a new DeleteRouterParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewDeleteRouterParams() *DeleteRouterParams {
|
||||
return &DeleteRouterParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteRouterParamsWithTimeout creates a new DeleteRouterParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewDeleteRouterParamsWithTimeout(timeout time.Duration) *DeleteRouterParams {
|
||||
return &DeleteRouterParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteRouterParamsWithContext creates a new DeleteRouterParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewDeleteRouterParamsWithContext(ctx context.Context) *DeleteRouterParams {
|
||||
return &DeleteRouterParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteRouterParamsWithHTTPClient creates a new DeleteRouterParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewDeleteRouterParamsWithHTTPClient(client *http.Client) *DeleteRouterParams {
|
||||
return &DeleteRouterParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* DeleteRouterParams contains all the parameters to send to the API endpoint
|
||||
for the delete router operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type DeleteRouterParams struct {
|
||||
|
||||
/* ID.
|
||||
|
||||
The id of the requested resource
|
||||
*/
|
||||
ID string
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the delete router params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DeleteRouterParams) WithDefaults() *DeleteRouterParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the delete router params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DeleteRouterParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the delete router params
|
||||
func (o *DeleteRouterParams) WithTimeout(timeout time.Duration) *DeleteRouterParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the delete router params
|
||||
func (o *DeleteRouterParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the delete router params
|
||||
func (o *DeleteRouterParams) WithContext(ctx context.Context) *DeleteRouterParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the delete router params
|
||||
func (o *DeleteRouterParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the delete router params
|
||||
func (o *DeleteRouterParams) WithHTTPClient(client *http.Client) *DeleteRouterParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the delete router params
|
||||
func (o *DeleteRouterParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the delete router params
|
||||
func (o *DeleteRouterParams) WithID(id string) *DeleteRouterParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the delete router params
|
||||
func (o *DeleteRouterParams) SetID(id string) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *DeleteRouterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// DeleteRouterReader is a Reader for the DeleteRouter structure.
|
||||
type DeleteRouterReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *DeleteRouterReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewDeleteRouterOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 400:
|
||||
result := NewDeleteRouterBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 401:
|
||||
result := NewDeleteRouterUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 409:
|
||||
result := NewDeleteRouterConflict()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteRouterOK creates a DeleteRouterOK with default headers values
|
||||
func NewDeleteRouterOK() *DeleteRouterOK {
|
||||
return &DeleteRouterOK{}
|
||||
}
|
||||
|
||||
/* DeleteRouterOK describes a response with status code 200, with default header values.
|
||||
|
||||
The delete request was successful and the resource has been removed
|
||||
*/
|
||||
type DeleteRouterOK struct {
|
||||
Payload *rest_model.Empty
|
||||
}
|
||||
|
||||
func (o *DeleteRouterOK) Error() string {
|
||||
return fmt.Sprintf("[DELETE /routers/{id}][%d] deleteRouterOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *DeleteRouterOK) GetPayload() *rest_model.Empty {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteRouterOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.Empty)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteRouterBadRequest creates a DeleteRouterBadRequest with default headers values
|
||||
func NewDeleteRouterBadRequest() *DeleteRouterBadRequest {
|
||||
return &DeleteRouterBadRequest{}
|
||||
}
|
||||
|
||||
/* DeleteRouterBadRequest describes a response with status code 400, with default header values.
|
||||
|
||||
The supplied request contains invalid fields or could not be parsed (json and non-json bodies). The error's code, message, and cause fields can be inspected for further information
|
||||
*/
|
||||
type DeleteRouterBadRequest struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DeleteRouterBadRequest) Error() string {
|
||||
return fmt.Sprintf("[DELETE /routers/{id}][%d] deleteRouterBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
func (o *DeleteRouterBadRequest) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteRouterBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteRouterUnauthorized creates a DeleteRouterUnauthorized with default headers values
|
||||
func NewDeleteRouterUnauthorized() *DeleteRouterUnauthorized {
|
||||
return &DeleteRouterUnauthorized{}
|
||||
}
|
||||
|
||||
/* DeleteRouterUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type DeleteRouterUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DeleteRouterUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[DELETE /routers/{id}][%d] deleteRouterUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *DeleteRouterUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteRouterUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteRouterConflict creates a DeleteRouterConflict with default headers values
|
||||
func NewDeleteRouterConflict() *DeleteRouterConflict {
|
||||
return &DeleteRouterConflict{}
|
||||
}
|
||||
|
||||
/* DeleteRouterConflict describes a response with status code 409, with default header values.
|
||||
|
||||
The resource requested to be removed/altered cannot be as it is referenced by another object.
|
||||
*/
|
||||
type DeleteRouterConflict struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DeleteRouterConflict) Error() string {
|
||||
return fmt.Sprintf("[DELETE /routers/{id}][%d] deleteRouterConflict %+v", 409, o.Payload)
|
||||
}
|
||||
func (o *DeleteRouterConflict) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteRouterConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewDetailRouterParams creates a new DetailRouterParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewDetailRouterParams() *DetailRouterParams {
|
||||
return &DetailRouterParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailRouterParamsWithTimeout creates a new DetailRouterParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewDetailRouterParamsWithTimeout(timeout time.Duration) *DetailRouterParams {
|
||||
return &DetailRouterParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailRouterParamsWithContext creates a new DetailRouterParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewDetailRouterParamsWithContext(ctx context.Context) *DetailRouterParams {
|
||||
return &DetailRouterParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailRouterParamsWithHTTPClient creates a new DetailRouterParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewDetailRouterParamsWithHTTPClient(client *http.Client) *DetailRouterParams {
|
||||
return &DetailRouterParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* DetailRouterParams contains all the parameters to send to the API endpoint
|
||||
for the detail router operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type DetailRouterParams struct {
|
||||
|
||||
/* ID.
|
||||
|
||||
The id of the requested resource
|
||||
*/
|
||||
ID string
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the detail router params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DetailRouterParams) WithDefaults() *DetailRouterParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the detail router params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DetailRouterParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the detail router params
|
||||
func (o *DetailRouterParams) WithTimeout(timeout time.Duration) *DetailRouterParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the detail router params
|
||||
func (o *DetailRouterParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the detail router params
|
||||
func (o *DetailRouterParams) WithContext(ctx context.Context) *DetailRouterParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the detail router params
|
||||
func (o *DetailRouterParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the detail router params
|
||||
func (o *DetailRouterParams) WithHTTPClient(client *http.Client) *DetailRouterParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the detail router params
|
||||
func (o *DetailRouterParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the detail router params
|
||||
func (o *DetailRouterParams) WithID(id string) *DetailRouterParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the detail router params
|
||||
func (o *DetailRouterParams) SetID(id string) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *DetailRouterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// DetailRouterReader is a Reader for the DetailRouter structure.
|
||||
type DetailRouterReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *DetailRouterReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewDetailRouterOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 401:
|
||||
result := NewDetailRouterUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 404:
|
||||
result := NewDetailRouterNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailRouterOK creates a DetailRouterOK with default headers values
|
||||
func NewDetailRouterOK() *DetailRouterOK {
|
||||
return &DetailRouterOK{}
|
||||
}
|
||||
|
||||
/* DetailRouterOK describes a response with status code 200, with default header values.
|
||||
|
||||
A single router
|
||||
*/
|
||||
type DetailRouterOK struct {
|
||||
Payload *rest_model.DetailRouterEnvelope
|
||||
}
|
||||
|
||||
func (o *DetailRouterOK) Error() string {
|
||||
return fmt.Sprintf("[GET /routers/{id}][%d] detailRouterOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *DetailRouterOK) GetPayload() *rest_model.DetailRouterEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DetailRouterOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.DetailRouterEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDetailRouterUnauthorized creates a DetailRouterUnauthorized with default headers values
|
||||
func NewDetailRouterUnauthorized() *DetailRouterUnauthorized {
|
||||
return &DetailRouterUnauthorized{}
|
||||
}
|
||||
|
||||
/* DetailRouterUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type DetailRouterUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DetailRouterUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[GET /routers/{id}][%d] detailRouterUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *DetailRouterUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DetailRouterUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDetailRouterNotFound creates a DetailRouterNotFound with default headers values
|
||||
func NewDetailRouterNotFound() *DetailRouterNotFound {
|
||||
return &DetailRouterNotFound{}
|
||||
}
|
||||
|
||||
/* DetailRouterNotFound describes a response with status code 404, with default header values.
|
||||
|
||||
The requested resource does not exist
|
||||
*/
|
||||
type DetailRouterNotFound struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DetailRouterNotFound) Error() string {
|
||||
return fmt.Sprintf("[GET /routers/{id}][%d] detailRouterNotFound %+v", 404, o.Payload)
|
||||
}
|
||||
func (o *DetailRouterNotFound) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DetailRouterNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// NewListRouterTerminatorsParams creates a new ListRouterTerminatorsParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewListRouterTerminatorsParams() *ListRouterTerminatorsParams {
|
||||
return &ListRouterTerminatorsParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListRouterTerminatorsParamsWithTimeout creates a new ListRouterTerminatorsParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewListRouterTerminatorsParamsWithTimeout(timeout time.Duration) *ListRouterTerminatorsParams {
|
||||
return &ListRouterTerminatorsParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListRouterTerminatorsParamsWithContext creates a new ListRouterTerminatorsParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewListRouterTerminatorsParamsWithContext(ctx context.Context) *ListRouterTerminatorsParams {
|
||||
return &ListRouterTerminatorsParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListRouterTerminatorsParamsWithHTTPClient creates a new ListRouterTerminatorsParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewListRouterTerminatorsParamsWithHTTPClient(client *http.Client) *ListRouterTerminatorsParams {
|
||||
return &ListRouterTerminatorsParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* ListRouterTerminatorsParams contains all the parameters to send to the API endpoint
|
||||
for the list router terminators operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ListRouterTerminatorsParams struct {
|
||||
|
||||
// Filter.
|
||||
Filter *string
|
||||
|
||||
/* ID.
|
||||
|
||||
The id of the requested resource
|
||||
*/
|
||||
ID string
|
||||
|
||||
// Limit.
|
||||
Limit *int64
|
||||
|
||||
// Offset.
|
||||
Offset *int64
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the list router terminators params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ListRouterTerminatorsParams) WithDefaults() *ListRouterTerminatorsParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the list router terminators params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ListRouterTerminatorsParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) WithTimeout(timeout time.Duration) *ListRouterTerminatorsParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) WithContext(ctx context.Context) *ListRouterTerminatorsParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) WithHTTPClient(client *http.Client) *ListRouterTerminatorsParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithFilter adds the filter to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) WithFilter(filter *string) *ListRouterTerminatorsParams {
|
||||
o.SetFilter(filter)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetFilter adds the filter to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) SetFilter(filter *string) {
|
||||
o.Filter = filter
|
||||
}
|
||||
|
||||
// WithID adds the id to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) WithID(id string) *ListRouterTerminatorsParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) SetID(id string) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WithLimit adds the limit to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) WithLimit(limit *int64) *ListRouterTerminatorsParams {
|
||||
o.SetLimit(limit)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetLimit adds the limit to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) SetLimit(limit *int64) {
|
||||
o.Limit = limit
|
||||
}
|
||||
|
||||
// WithOffset adds the offset to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) WithOffset(offset *int64) *ListRouterTerminatorsParams {
|
||||
o.SetOffset(offset)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetOffset adds the offset to the list router terminators params
|
||||
func (o *ListRouterTerminatorsParams) SetOffset(offset *int64) {
|
||||
o.Offset = offset
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ListRouterTerminatorsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if o.Filter != nil {
|
||||
|
||||
// query param filter
|
||||
var qrFilter string
|
||||
|
||||
if o.Filter != nil {
|
||||
qrFilter = *o.Filter
|
||||
}
|
||||
qFilter := qrFilter
|
||||
if qFilter != "" {
|
||||
|
||||
if err := r.SetQueryParam("filter", qFilter); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if o.Limit != nil {
|
||||
|
||||
// query param limit
|
||||
var qrLimit int64
|
||||
|
||||
if o.Limit != nil {
|
||||
qrLimit = *o.Limit
|
||||
}
|
||||
qLimit := swag.FormatInt64(qrLimit)
|
||||
if qLimit != "" {
|
||||
|
||||
if err := r.SetQueryParam("limit", qLimit); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if o.Offset != nil {
|
||||
|
||||
// query param offset
|
||||
var qrOffset int64
|
||||
|
||||
if o.Offset != nil {
|
||||
qrOffset = *o.Offset
|
||||
}
|
||||
qOffset := swag.FormatInt64(qrOffset)
|
||||
if qOffset != "" {
|
||||
|
||||
if err := r.SetQueryParam("offset", qOffset); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// ListRouterTerminatorsReader is a Reader for the ListRouterTerminators structure.
|
||||
type ListRouterTerminatorsReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ListRouterTerminatorsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewListRouterTerminatorsOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 400:
|
||||
result := NewListRouterTerminatorsBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 401:
|
||||
result := NewListRouterTerminatorsUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewListRouterTerminatorsOK creates a ListRouterTerminatorsOK with default headers values
|
||||
func NewListRouterTerminatorsOK() *ListRouterTerminatorsOK {
|
||||
return &ListRouterTerminatorsOK{}
|
||||
}
|
||||
|
||||
/* ListRouterTerminatorsOK describes a response with status code 200, with default header values.
|
||||
|
||||
A list of terminators
|
||||
*/
|
||||
type ListRouterTerminatorsOK struct {
|
||||
Payload *rest_model.ListTerminatorsEnvelope
|
||||
}
|
||||
|
||||
func (o *ListRouterTerminatorsOK) Error() string {
|
||||
return fmt.Sprintf("[GET /routers/{id}/terminators][%d] listRouterTerminatorsOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *ListRouterTerminatorsOK) GetPayload() *rest_model.ListTerminatorsEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListRouterTerminatorsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.ListTerminatorsEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewListRouterTerminatorsBadRequest creates a ListRouterTerminatorsBadRequest with default headers values
|
||||
func NewListRouterTerminatorsBadRequest() *ListRouterTerminatorsBadRequest {
|
||||
return &ListRouterTerminatorsBadRequest{}
|
||||
}
|
||||
|
||||
/* ListRouterTerminatorsBadRequest describes a response with status code 400, with default header values.
|
||||
|
||||
The supplied request contains invalid fields or could not be parsed (json and non-json bodies). The error's code, message, and cause fields can be inspected for further information
|
||||
*/
|
||||
type ListRouterTerminatorsBadRequest struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *ListRouterTerminatorsBadRequest) Error() string {
|
||||
return fmt.Sprintf("[GET /routers/{id}/terminators][%d] listRouterTerminatorsBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
func (o *ListRouterTerminatorsBadRequest) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListRouterTerminatorsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewListRouterTerminatorsUnauthorized creates a ListRouterTerminatorsUnauthorized with default headers values
|
||||
func NewListRouterTerminatorsUnauthorized() *ListRouterTerminatorsUnauthorized {
|
||||
return &ListRouterTerminatorsUnauthorized{}
|
||||
}
|
||||
|
||||
/* ListRouterTerminatorsUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type ListRouterTerminatorsUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *ListRouterTerminatorsUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[GET /routers/{id}/terminators][%d] listRouterTerminatorsUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *ListRouterTerminatorsUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListRouterTerminatorsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// NewListRoutersParams creates a new ListRoutersParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewListRoutersParams() *ListRoutersParams {
|
||||
return &ListRoutersParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListRoutersParamsWithTimeout creates a new ListRoutersParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewListRoutersParamsWithTimeout(timeout time.Duration) *ListRoutersParams {
|
||||
return &ListRoutersParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListRoutersParamsWithContext creates a new ListRoutersParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewListRoutersParamsWithContext(ctx context.Context) *ListRoutersParams {
|
||||
return &ListRoutersParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListRoutersParamsWithHTTPClient creates a new ListRoutersParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewListRoutersParamsWithHTTPClient(client *http.Client) *ListRoutersParams {
|
||||
return &ListRoutersParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* ListRoutersParams contains all the parameters to send to the API endpoint
|
||||
for the list routers operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ListRoutersParams struct {
|
||||
|
||||
// Filter.
|
||||
Filter *string
|
||||
|
||||
// Limit.
|
||||
Limit *int64
|
||||
|
||||
// Offset.
|
||||
Offset *int64
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the list routers params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ListRoutersParams) WithDefaults() *ListRoutersParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the list routers params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ListRoutersParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the list routers params
|
||||
func (o *ListRoutersParams) WithTimeout(timeout time.Duration) *ListRoutersParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the list routers params
|
||||
func (o *ListRoutersParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the list routers params
|
||||
func (o *ListRoutersParams) WithContext(ctx context.Context) *ListRoutersParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the list routers params
|
||||
func (o *ListRoutersParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the list routers params
|
||||
func (o *ListRoutersParams) WithHTTPClient(client *http.Client) *ListRoutersParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the list routers params
|
||||
func (o *ListRoutersParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithFilter adds the filter to the list routers params
|
||||
func (o *ListRoutersParams) WithFilter(filter *string) *ListRoutersParams {
|
||||
o.SetFilter(filter)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetFilter adds the filter to the list routers params
|
||||
func (o *ListRoutersParams) SetFilter(filter *string) {
|
||||
o.Filter = filter
|
||||
}
|
||||
|
||||
// WithLimit adds the limit to the list routers params
|
||||
func (o *ListRoutersParams) WithLimit(limit *int64) *ListRoutersParams {
|
||||
o.SetLimit(limit)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetLimit adds the limit to the list routers params
|
||||
func (o *ListRoutersParams) SetLimit(limit *int64) {
|
||||
o.Limit = limit
|
||||
}
|
||||
|
||||
// WithOffset adds the offset to the list routers params
|
||||
func (o *ListRoutersParams) WithOffset(offset *int64) *ListRoutersParams {
|
||||
o.SetOffset(offset)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetOffset adds the offset to the list routers params
|
||||
func (o *ListRoutersParams) SetOffset(offset *int64) {
|
||||
o.Offset = offset
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ListRoutersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if o.Filter != nil {
|
||||
|
||||
// query param filter
|
||||
var qrFilter string
|
||||
|
||||
if o.Filter != nil {
|
||||
qrFilter = *o.Filter
|
||||
}
|
||||
qFilter := qrFilter
|
||||
if qFilter != "" {
|
||||
|
||||
if err := r.SetQueryParam("filter", qFilter); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if o.Limit != nil {
|
||||
|
||||
// query param limit
|
||||
var qrLimit int64
|
||||
|
||||
if o.Limit != nil {
|
||||
qrLimit = *o.Limit
|
||||
}
|
||||
qLimit := swag.FormatInt64(qrLimit)
|
||||
if qLimit != "" {
|
||||
|
||||
if err := r.SetQueryParam("limit", qLimit); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if o.Offset != nil {
|
||||
|
||||
// query param offset
|
||||
var qrOffset int64
|
||||
|
||||
if o.Offset != nil {
|
||||
qrOffset = *o.Offset
|
||||
}
|
||||
qOffset := swag.FormatInt64(qrOffset)
|
||||
if qOffset != "" {
|
||||
|
||||
if err := r.SetQueryParam("offset", qOffset); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// ListRoutersReader is a Reader for the ListRouters structure.
|
||||
type ListRoutersReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ListRoutersReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewListRoutersOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 401:
|
||||
result := NewListRoutersUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewListRoutersOK creates a ListRoutersOK with default headers values
|
||||
func NewListRoutersOK() *ListRoutersOK {
|
||||
return &ListRoutersOK{}
|
||||
}
|
||||
|
||||
/* ListRoutersOK describes a response with status code 200, with default header values.
|
||||
|
||||
A list of routers
|
||||
*/
|
||||
type ListRoutersOK struct {
|
||||
Payload *rest_model.ListRoutersEnvelope
|
||||
}
|
||||
|
||||
func (o *ListRoutersOK) Error() string {
|
||||
return fmt.Sprintf("[GET /routers][%d] listRoutersOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *ListRoutersOK) GetPayload() *rest_model.ListRoutersEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListRoutersOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.ListRoutersEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewListRoutersUnauthorized creates a ListRoutersUnauthorized with default headers values
|
||||
func NewListRoutersUnauthorized() *ListRoutersUnauthorized {
|
||||
return &ListRoutersUnauthorized{}
|
||||
}
|
||||
|
||||
/* ListRoutersUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type ListRoutersUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *ListRoutersUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[GET /routers][%d] listRoutersUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *ListRoutersUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListRoutersUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// NewPatchRouterParams creates a new PatchRouterParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewPatchRouterParams() *PatchRouterParams {
|
||||
return &PatchRouterParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewPatchRouterParamsWithTimeout creates a new PatchRouterParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewPatchRouterParamsWithTimeout(timeout time.Duration) *PatchRouterParams {
|
||||
return &PatchRouterParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewPatchRouterParamsWithContext creates a new PatchRouterParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewPatchRouterParamsWithContext(ctx context.Context) *PatchRouterParams {
|
||||
return &PatchRouterParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewPatchRouterParamsWithHTTPClient creates a new PatchRouterParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewPatchRouterParamsWithHTTPClient(client *http.Client) *PatchRouterParams {
|
||||
return &PatchRouterParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* PatchRouterParams contains all the parameters to send to the API endpoint
|
||||
for the patch router operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type PatchRouterParams struct {
|
||||
|
||||
/* ID.
|
||||
|
||||
The id of the requested resource
|
||||
*/
|
||||
ID string
|
||||
|
||||
/* Router.
|
||||
|
||||
A router patch object
|
||||
*/
|
||||
Router *rest_model.RouterPatch
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the patch router params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *PatchRouterParams) WithDefaults() *PatchRouterParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the patch router params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *PatchRouterParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the patch router params
|
||||
func (o *PatchRouterParams) WithTimeout(timeout time.Duration) *PatchRouterParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the patch router params
|
||||
func (o *PatchRouterParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the patch router params
|
||||
func (o *PatchRouterParams) WithContext(ctx context.Context) *PatchRouterParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the patch router params
|
||||
func (o *PatchRouterParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the patch router params
|
||||
func (o *PatchRouterParams) WithHTTPClient(client *http.Client) *PatchRouterParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the patch router params
|
||||
func (o *PatchRouterParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the patch router params
|
||||
func (o *PatchRouterParams) WithID(id string) *PatchRouterParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the patch router params
|
||||
func (o *PatchRouterParams) SetID(id string) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WithRouter adds the router to the patch router params
|
||||
func (o *PatchRouterParams) WithRouter(router *rest_model.RouterPatch) *PatchRouterParams {
|
||||
o.SetRouter(router)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetRouter adds the router to the patch router params
|
||||
func (o *PatchRouterParams) SetRouter(router *rest_model.RouterPatch) {
|
||||
o.Router = router
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *PatchRouterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
if o.Router != nil {
|
||||
if err := r.SetBodyParam(o.Router); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// PatchRouterReader is a Reader for the PatchRouter structure.
|
||||
type PatchRouterReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *PatchRouterReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewPatchRouterOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 400:
|
||||
result := NewPatchRouterBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 401:
|
||||
result := NewPatchRouterUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 404:
|
||||
result := NewPatchRouterNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewPatchRouterOK creates a PatchRouterOK with default headers values
|
||||
func NewPatchRouterOK() *PatchRouterOK {
|
||||
return &PatchRouterOK{}
|
||||
}
|
||||
|
||||
/* PatchRouterOK describes a response with status code 200, with default header values.
|
||||
|
||||
The patch request was successful and the resource has been altered
|
||||
*/
|
||||
type PatchRouterOK struct {
|
||||
Payload *rest_model.Empty
|
||||
}
|
||||
|
||||
func (o *PatchRouterOK) Error() string {
|
||||
return fmt.Sprintf("[PATCH /routers/{id}][%d] patchRouterOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *PatchRouterOK) GetPayload() *rest_model.Empty {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PatchRouterOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.Empty)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewPatchRouterBadRequest creates a PatchRouterBadRequest with default headers values
|
||||
func NewPatchRouterBadRequest() *PatchRouterBadRequest {
|
||||
return &PatchRouterBadRequest{}
|
||||
}
|
||||
|
||||
/* PatchRouterBadRequest describes a response with status code 400, with default header values.
|
||||
|
||||
The supplied request contains invalid fields or could not be parsed (json and non-json bodies). The error's code, message, and cause fields can be inspected for further information
|
||||
*/
|
||||
type PatchRouterBadRequest struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *PatchRouterBadRequest) Error() string {
|
||||
return fmt.Sprintf("[PATCH /routers/{id}][%d] patchRouterBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
func (o *PatchRouterBadRequest) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PatchRouterBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewPatchRouterUnauthorized creates a PatchRouterUnauthorized with default headers values
|
||||
func NewPatchRouterUnauthorized() *PatchRouterUnauthorized {
|
||||
return &PatchRouterUnauthorized{}
|
||||
}
|
||||
|
||||
/* PatchRouterUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type PatchRouterUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *PatchRouterUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[PATCH /routers/{id}][%d] patchRouterUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *PatchRouterUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PatchRouterUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewPatchRouterNotFound creates a PatchRouterNotFound with default headers values
|
||||
func NewPatchRouterNotFound() *PatchRouterNotFound {
|
||||
return &PatchRouterNotFound{}
|
||||
}
|
||||
|
||||
/* PatchRouterNotFound describes a response with status code 404, with default header values.
|
||||
|
||||
The requested resource does not exist
|
||||
*/
|
||||
type PatchRouterNotFound struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *PatchRouterNotFound) Error() string {
|
||||
return fmt.Sprintf("[PATCH /routers/{id}][%d] patchRouterNotFound %+v", 404, o.Payload)
|
||||
}
|
||||
func (o *PatchRouterNotFound) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *PatchRouterNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// New creates a new router API client.
|
||||
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
|
||||
return &Client{transport: transport, formats: formats}
|
||||
}
|
||||
|
||||
/*
|
||||
Client for router API
|
||||
*/
|
||||
type Client struct {
|
||||
transport runtime.ClientTransport
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ClientOption is the option for Client methods
|
||||
type ClientOption func(*runtime.ClientOperation)
|
||||
|
||||
// ClientService is the interface for Client methods
|
||||
type ClientService interface {
|
||||
CreateRouter(params *CreateRouterParams, opts ...ClientOption) (*CreateRouterCreated, error)
|
||||
|
||||
DeleteRouter(params *DeleteRouterParams, opts ...ClientOption) (*DeleteRouterOK, error)
|
||||
|
||||
DetailRouter(params *DetailRouterParams, opts ...ClientOption) (*DetailRouterOK, error)
|
||||
|
||||
ListRouterTerminators(params *ListRouterTerminatorsParams, opts ...ClientOption) (*ListRouterTerminatorsOK, error)
|
||||
|
||||
ListRouters(params *ListRoutersParams, opts ...ClientOption) (*ListRoutersOK, error)
|
||||
|
||||
PatchRouter(params *PatchRouterParams, opts ...ClientOption) (*PatchRouterOK, error)
|
||||
|
||||
UpdateRouter(params *UpdateRouterParams, opts ...ClientOption) (*UpdateRouterOK, error)
|
||||
|
||||
SetTransport(transport runtime.ClientTransport)
|
||||
}
|
||||
|
||||
/*
|
||||
CreateRouter creates a router resource
|
||||
|
||||
Create a router resource. Requires admin access.
|
||||
*/
|
||||
func (a *Client) CreateRouter(params *CreateRouterParams, opts ...ClientOption) (*CreateRouterCreated, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewCreateRouterParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "createRouter",
|
||||
Method: "POST",
|
||||
PathPattern: "/routers",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &CreateRouterReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*CreateRouterCreated)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for createRouter: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteRouter deletes a router
|
||||
|
||||
Delete a router by id. Requires admin access.
|
||||
*/
|
||||
func (a *Client) DeleteRouter(params *DeleteRouterParams, opts ...ClientOption) (*DeleteRouterOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewDeleteRouterParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "deleteRouter",
|
||||
Method: "DELETE",
|
||||
PathPattern: "/routers/{id}",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &DeleteRouterReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*DeleteRouterOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for deleteRouter: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
DetailRouter retrieves a single router
|
||||
|
||||
Retrieves a single router by id. Requires admin access.
|
||||
*/
|
||||
func (a *Client) DetailRouter(params *DetailRouterParams, opts ...ClientOption) (*DetailRouterOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewDetailRouterParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "detailRouter",
|
||||
Method: "GET",
|
||||
PathPattern: "/routers/{id}",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &DetailRouterReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*DetailRouterOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for detailRouter: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
ListRouterTerminators lists of terminators assigned to a router
|
||||
|
||||
Retrieves a list of terminator resources that are assigned specific router; supports filtering, sorting, and pagination.
|
||||
|
||||
*/
|
||||
func (a *Client) ListRouterTerminators(params *ListRouterTerminatorsParams, opts ...ClientOption) (*ListRouterTerminatorsOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewListRouterTerminatorsParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "listRouterTerminators",
|
||||
Method: "GET",
|
||||
PathPattern: "/routers/{id}/terminators",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &ListRouterTerminatorsReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*ListRouterTerminatorsOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for listRouterTerminators: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
ListRouters lists routers
|
||||
|
||||
Retrieves a list of router resources; supports filtering, sorting, and pagination. Requires admin access.
|
||||
|
||||
*/
|
||||
func (a *Client) ListRouters(params *ListRoutersParams, opts ...ClientOption) (*ListRoutersOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewListRoutersParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "listRouters",
|
||||
Method: "GET",
|
||||
PathPattern: "/routers",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &ListRoutersReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*ListRoutersOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for listRouters: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
PatchRouter updates the supplied fields on a router
|
||||
|
||||
Update the supplied fields on a router. Requires admin access.
|
||||
*/
|
||||
func (a *Client) PatchRouter(params *PatchRouterParams, opts ...ClientOption) (*PatchRouterOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewPatchRouterParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "patchRouter",
|
||||
Method: "PATCH",
|
||||
PathPattern: "/routers/{id}",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &PatchRouterReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*PatchRouterOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for patchRouter: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
UpdateRouter updates all fields on a router
|
||||
|
||||
Update all fields on a router by id. Requires admin access.
|
||||
*/
|
||||
func (a *Client) UpdateRouter(params *UpdateRouterParams, opts ...ClientOption) (*UpdateRouterOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewUpdateRouterParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "updateRouter",
|
||||
Method: "PUT",
|
||||
PathPattern: "/routers/{id}",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"https"},
|
||||
Params: params,
|
||||
Reader: &UpdateRouterReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*UpdateRouterOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for updateRouter: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client
|
||||
func (a *Client) SetTransport(transport runtime.ClientTransport) {
|
||||
a.transport = transport
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// NewUpdateRouterParams creates a new UpdateRouterParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewUpdateRouterParams() *UpdateRouterParams {
|
||||
return &UpdateRouterParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateRouterParamsWithTimeout creates a new UpdateRouterParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewUpdateRouterParamsWithTimeout(timeout time.Duration) *UpdateRouterParams {
|
||||
return &UpdateRouterParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateRouterParamsWithContext creates a new UpdateRouterParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewUpdateRouterParamsWithContext(ctx context.Context) *UpdateRouterParams {
|
||||
return &UpdateRouterParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateRouterParamsWithHTTPClient creates a new UpdateRouterParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewUpdateRouterParamsWithHTTPClient(client *http.Client) *UpdateRouterParams {
|
||||
return &UpdateRouterParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* UpdateRouterParams contains all the parameters to send to the API endpoint
|
||||
for the update router operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type UpdateRouterParams struct {
|
||||
|
||||
/* ID.
|
||||
|
||||
The id of the requested resource
|
||||
*/
|
||||
ID string
|
||||
|
||||
/* Router.
|
||||
|
||||
A router update object
|
||||
*/
|
||||
Router *rest_model.RouterUpdate
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the update router params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *UpdateRouterParams) WithDefaults() *UpdateRouterParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the update router params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *UpdateRouterParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the update router params
|
||||
func (o *UpdateRouterParams) WithTimeout(timeout time.Duration) *UpdateRouterParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the update router params
|
||||
func (o *UpdateRouterParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the update router params
|
||||
func (o *UpdateRouterParams) WithContext(ctx context.Context) *UpdateRouterParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the update router params
|
||||
func (o *UpdateRouterParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the update router params
|
||||
func (o *UpdateRouterParams) WithHTTPClient(client *http.Client) *UpdateRouterParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the update router params
|
||||
func (o *UpdateRouterParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the update router params
|
||||
func (o *UpdateRouterParams) WithID(id string) *UpdateRouterParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the update router params
|
||||
func (o *UpdateRouterParams) SetID(id string) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WithRouter adds the router to the update router params
|
||||
func (o *UpdateRouterParams) WithRouter(router *rest_model.RouterUpdate) *UpdateRouterParams {
|
||||
o.SetRouter(router)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetRouter adds the router to the update router params
|
||||
func (o *UpdateRouterParams) SetRouter(router *rest_model.RouterUpdate) {
|
||||
o.Router = router
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *UpdateRouterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
if o.Router != nil {
|
||||
if err := r.SetBodyParam(o.Router); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
// 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 router
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// UpdateRouterReader is a Reader for the UpdateRouter structure.
|
||||
type UpdateRouterReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *UpdateRouterReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewUpdateRouterOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 400:
|
||||
result := NewUpdateRouterBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 401:
|
||||
result := NewUpdateRouterUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 404:
|
||||
result := NewUpdateRouterNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateRouterOK creates a UpdateRouterOK with default headers values
|
||||
func NewUpdateRouterOK() *UpdateRouterOK {
|
||||
return &UpdateRouterOK{}
|
||||
}
|
||||
|
||||
/* UpdateRouterOK describes a response with status code 200, with default header values.
|
||||
|
||||
The update request was successful and the resource has been altered
|
||||
*/
|
||||
type UpdateRouterOK struct {
|
||||
Payload *rest_model.Empty
|
||||
}
|
||||
|
||||
func (o *UpdateRouterOK) Error() string {
|
||||
return fmt.Sprintf("[PUT /routers/{id}][%d] updateRouterOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *UpdateRouterOK) GetPayload() *rest_model.Empty {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *UpdateRouterOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.Empty)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewUpdateRouterBadRequest creates a UpdateRouterBadRequest with default headers values
|
||||
func NewUpdateRouterBadRequest() *UpdateRouterBadRequest {
|
||||
return &UpdateRouterBadRequest{}
|
||||
}
|
||||
|
||||
/* UpdateRouterBadRequest describes a response with status code 400, with default header values.
|
||||
|
||||
The supplied request contains invalid fields or could not be parsed (json and non-json bodies). The error's code, message, and cause fields can be inspected for further information
|
||||
*/
|
||||
type UpdateRouterBadRequest struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *UpdateRouterBadRequest) Error() string {
|
||||
return fmt.Sprintf("[PUT /routers/{id}][%d] updateRouterBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
func (o *UpdateRouterBadRequest) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *UpdateRouterBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewUpdateRouterUnauthorized creates a UpdateRouterUnauthorized with default headers values
|
||||
func NewUpdateRouterUnauthorized() *UpdateRouterUnauthorized {
|
||||
return &UpdateRouterUnauthorized{}
|
||||
}
|
||||
|
||||
/* UpdateRouterUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type UpdateRouterUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *UpdateRouterUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[PUT /routers/{id}][%d] updateRouterUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *UpdateRouterUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *UpdateRouterUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewUpdateRouterNotFound creates a UpdateRouterNotFound with default headers values
|
||||
func NewUpdateRouterNotFound() *UpdateRouterNotFound {
|
||||
return &UpdateRouterNotFound{}
|
||||
}
|
||||
|
||||
/* UpdateRouterNotFound describes a response with status code 404, with default header values.
|
||||
|
||||
The requested resource does not exist
|
||||
*/
|
||||
type UpdateRouterNotFound struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *UpdateRouterNotFound) Error() string {
|
||||
return fmt.Sprintf("[PUT /routers/{id}][%d] updateRouterNotFound %+v", 404, o.Payload)
|
||||
}
|
||||
func (o *UpdateRouterNotFound) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *UpdateRouterNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
// 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 service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// NewCreateServiceParams creates a new CreateServiceParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewCreateServiceParams() *CreateServiceParams {
|
||||
return &CreateServiceParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateServiceParamsWithTimeout creates a new CreateServiceParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewCreateServiceParamsWithTimeout(timeout time.Duration) *CreateServiceParams {
|
||||
return &CreateServiceParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateServiceParamsWithContext creates a new CreateServiceParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewCreateServiceParamsWithContext(ctx context.Context) *CreateServiceParams {
|
||||
return &CreateServiceParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateServiceParamsWithHTTPClient creates a new CreateServiceParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewCreateServiceParamsWithHTTPClient(client *http.Client) *CreateServiceParams {
|
||||
return &CreateServiceParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* CreateServiceParams contains all the parameters to send to the API endpoint
|
||||
for the create service operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type CreateServiceParams struct {
|
||||
|
||||
/* Service.
|
||||
|
||||
A service to create
|
||||
*/
|
||||
Service *rest_model.ServiceCreate
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the create service params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *CreateServiceParams) WithDefaults() *CreateServiceParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the create service params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *CreateServiceParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the create service params
|
||||
func (o *CreateServiceParams) WithTimeout(timeout time.Duration) *CreateServiceParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the create service params
|
||||
func (o *CreateServiceParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the create service params
|
||||
func (o *CreateServiceParams) WithContext(ctx context.Context) *CreateServiceParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the create service params
|
||||
func (o *CreateServiceParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the create service params
|
||||
func (o *CreateServiceParams) WithHTTPClient(client *http.Client) *CreateServiceParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the create service params
|
||||
func (o *CreateServiceParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithService adds the service to the create service params
|
||||
func (o *CreateServiceParams) WithService(service *rest_model.ServiceCreate) *CreateServiceParams {
|
||||
o.SetService(service)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetService adds the service to the create service params
|
||||
func (o *CreateServiceParams) SetService(service *rest_model.ServiceCreate) {
|
||||
o.Service = service
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *CreateServiceParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Service != nil {
|
||||
if err := r.SetBodyParam(o.Service); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// 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 service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// CreateServiceReader is a Reader for the CreateService structure.
|
||||
type CreateServiceReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *CreateServiceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 201:
|
||||
result := NewCreateServiceCreated()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 400:
|
||||
result := NewCreateServiceBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 401:
|
||||
result := NewCreateServiceUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateServiceCreated creates a CreateServiceCreated with default headers values
|
||||
func NewCreateServiceCreated() *CreateServiceCreated {
|
||||
return &CreateServiceCreated{}
|
||||
}
|
||||
|
||||
/* CreateServiceCreated describes a response with status code 201, with default header values.
|
||||
|
||||
The create request was successful and the resource has been added at the following location
|
||||
*/
|
||||
type CreateServiceCreated struct {
|
||||
Payload *rest_model.CreateEnvelope
|
||||
}
|
||||
|
||||
func (o *CreateServiceCreated) Error() string {
|
||||
return fmt.Sprintf("[POST /services][%d] createServiceCreated %+v", 201, o.Payload)
|
||||
}
|
||||
func (o *CreateServiceCreated) GetPayload() *rest_model.CreateEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *CreateServiceCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.CreateEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewCreateServiceBadRequest creates a CreateServiceBadRequest with default headers values
|
||||
func NewCreateServiceBadRequest() *CreateServiceBadRequest {
|
||||
return &CreateServiceBadRequest{}
|
||||
}
|
||||
|
||||
/* CreateServiceBadRequest describes a response with status code 400, with default header values.
|
||||
|
||||
The supplied request contains invalid fields or could not be parsed (json and non-json bodies). The error's code, message, and cause fields can be inspected for further information
|
||||
*/
|
||||
type CreateServiceBadRequest struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *CreateServiceBadRequest) Error() string {
|
||||
return fmt.Sprintf("[POST /services][%d] createServiceBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
func (o *CreateServiceBadRequest) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *CreateServiceBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewCreateServiceUnauthorized creates a CreateServiceUnauthorized with default headers values
|
||||
func NewCreateServiceUnauthorized() *CreateServiceUnauthorized {
|
||||
return &CreateServiceUnauthorized{}
|
||||
}
|
||||
|
||||
/* CreateServiceUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type CreateServiceUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *CreateServiceUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[POST /services][%d] createServiceUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *CreateServiceUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *CreateServiceUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
// 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 service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewDeleteServiceParams creates a new DeleteServiceParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewDeleteServiceParams() *DeleteServiceParams {
|
||||
return &DeleteServiceParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteServiceParamsWithTimeout creates a new DeleteServiceParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewDeleteServiceParamsWithTimeout(timeout time.Duration) *DeleteServiceParams {
|
||||
return &DeleteServiceParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteServiceParamsWithContext creates a new DeleteServiceParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewDeleteServiceParamsWithContext(ctx context.Context) *DeleteServiceParams {
|
||||
return &DeleteServiceParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteServiceParamsWithHTTPClient creates a new DeleteServiceParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewDeleteServiceParamsWithHTTPClient(client *http.Client) *DeleteServiceParams {
|
||||
return &DeleteServiceParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* DeleteServiceParams contains all the parameters to send to the API endpoint
|
||||
for the delete service operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type DeleteServiceParams struct {
|
||||
|
||||
/* ID.
|
||||
|
||||
The id of the requested resource
|
||||
*/
|
||||
ID string
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the delete service params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DeleteServiceParams) WithDefaults() *DeleteServiceParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the delete service params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DeleteServiceParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the delete service params
|
||||
func (o *DeleteServiceParams) WithTimeout(timeout time.Duration) *DeleteServiceParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the delete service params
|
||||
func (o *DeleteServiceParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the delete service params
|
||||
func (o *DeleteServiceParams) WithContext(ctx context.Context) *DeleteServiceParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the delete service params
|
||||
func (o *DeleteServiceParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the delete service params
|
||||
func (o *DeleteServiceParams) WithHTTPClient(client *http.Client) *DeleteServiceParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the delete service params
|
||||
func (o *DeleteServiceParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the delete service params
|
||||
func (o *DeleteServiceParams) WithID(id string) *DeleteServiceParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the delete service params
|
||||
func (o *DeleteServiceParams) SetID(id string) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *DeleteServiceParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
// 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 service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// DeleteServiceReader is a Reader for the DeleteService structure.
|
||||
type DeleteServiceReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *DeleteServiceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewDeleteServiceOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 400:
|
||||
result := NewDeleteServiceBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 401:
|
||||
result := NewDeleteServiceUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 409:
|
||||
result := NewDeleteServiceConflict()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteServiceOK creates a DeleteServiceOK with default headers values
|
||||
func NewDeleteServiceOK() *DeleteServiceOK {
|
||||
return &DeleteServiceOK{}
|
||||
}
|
||||
|
||||
/* DeleteServiceOK describes a response with status code 200, with default header values.
|
||||
|
||||
The delete request was successful and the resource has been removed
|
||||
*/
|
||||
type DeleteServiceOK struct {
|
||||
Payload *rest_model.Empty
|
||||
}
|
||||
|
||||
func (o *DeleteServiceOK) Error() string {
|
||||
return fmt.Sprintf("[DELETE /services/{id}][%d] deleteServiceOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *DeleteServiceOK) GetPayload() *rest_model.Empty {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteServiceOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.Empty)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteServiceBadRequest creates a DeleteServiceBadRequest with default headers values
|
||||
func NewDeleteServiceBadRequest() *DeleteServiceBadRequest {
|
||||
return &DeleteServiceBadRequest{}
|
||||
}
|
||||
|
||||
/* DeleteServiceBadRequest describes a response with status code 400, with default header values.
|
||||
|
||||
The supplied request contains invalid fields or could not be parsed (json and non-json bodies). The error's code, message, and cause fields can be inspected for further information
|
||||
*/
|
||||
type DeleteServiceBadRequest struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DeleteServiceBadRequest) Error() string {
|
||||
return fmt.Sprintf("[DELETE /services/{id}][%d] deleteServiceBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
func (o *DeleteServiceBadRequest) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteServiceBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteServiceUnauthorized creates a DeleteServiceUnauthorized with default headers values
|
||||
func NewDeleteServiceUnauthorized() *DeleteServiceUnauthorized {
|
||||
return &DeleteServiceUnauthorized{}
|
||||
}
|
||||
|
||||
/* DeleteServiceUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type DeleteServiceUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DeleteServiceUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[DELETE /services/{id}][%d] deleteServiceUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *DeleteServiceUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteServiceUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteServiceConflict creates a DeleteServiceConflict with default headers values
|
||||
func NewDeleteServiceConflict() *DeleteServiceConflict {
|
||||
return &DeleteServiceConflict{}
|
||||
}
|
||||
|
||||
/* DeleteServiceConflict describes a response with status code 409, with default header values.
|
||||
|
||||
The resource requested to be removed/altered cannot be as it is referenced by another object.
|
||||
*/
|
||||
type DeleteServiceConflict struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DeleteServiceConflict) Error() string {
|
||||
return fmt.Sprintf("[DELETE /services/{id}][%d] deleteServiceConflict %+v", 409, o.Payload)
|
||||
}
|
||||
func (o *DeleteServiceConflict) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DeleteServiceConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
// 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 service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewDetailServiceParams creates a new DetailServiceParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewDetailServiceParams() *DetailServiceParams {
|
||||
return &DetailServiceParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailServiceParamsWithTimeout creates a new DetailServiceParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewDetailServiceParamsWithTimeout(timeout time.Duration) *DetailServiceParams {
|
||||
return &DetailServiceParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailServiceParamsWithContext creates a new DetailServiceParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewDetailServiceParamsWithContext(ctx context.Context) *DetailServiceParams {
|
||||
return &DetailServiceParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailServiceParamsWithHTTPClient creates a new DetailServiceParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewDetailServiceParamsWithHTTPClient(client *http.Client) *DetailServiceParams {
|
||||
return &DetailServiceParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* DetailServiceParams contains all the parameters to send to the API endpoint
|
||||
for the detail service operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type DetailServiceParams struct {
|
||||
|
||||
/* ID.
|
||||
|
||||
The id of the requested resource
|
||||
*/
|
||||
ID string
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the detail service params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DetailServiceParams) WithDefaults() *DetailServiceParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the detail service params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DetailServiceParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the detail service params
|
||||
func (o *DetailServiceParams) WithTimeout(timeout time.Duration) *DetailServiceParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the detail service params
|
||||
func (o *DetailServiceParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the detail service params
|
||||
func (o *DetailServiceParams) WithContext(ctx context.Context) *DetailServiceParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the detail service params
|
||||
func (o *DetailServiceParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the detail service params
|
||||
func (o *DetailServiceParams) WithHTTPClient(client *http.Client) *DetailServiceParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the detail service params
|
||||
func (o *DetailServiceParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the detail service params
|
||||
func (o *DetailServiceParams) WithID(id string) *DetailServiceParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the detail service params
|
||||
func (o *DetailServiceParams) SetID(id string) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *DetailServiceParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// 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 service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// DetailServiceReader is a Reader for the DetailService structure.
|
||||
type DetailServiceReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *DetailServiceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewDetailServiceOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 401:
|
||||
result := NewDetailServiceUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 404:
|
||||
result := NewDetailServiceNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewDetailServiceOK creates a DetailServiceOK with default headers values
|
||||
func NewDetailServiceOK() *DetailServiceOK {
|
||||
return &DetailServiceOK{}
|
||||
}
|
||||
|
||||
/* DetailServiceOK describes a response with status code 200, with default header values.
|
||||
|
||||
A single service
|
||||
*/
|
||||
type DetailServiceOK struct {
|
||||
Payload *rest_model.DetailServiceEnvelope
|
||||
}
|
||||
|
||||
func (o *DetailServiceOK) Error() string {
|
||||
return fmt.Sprintf("[GET /services/{id}][%d] detailServiceOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *DetailServiceOK) GetPayload() *rest_model.DetailServiceEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DetailServiceOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.DetailServiceEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDetailServiceUnauthorized creates a DetailServiceUnauthorized with default headers values
|
||||
func NewDetailServiceUnauthorized() *DetailServiceUnauthorized {
|
||||
return &DetailServiceUnauthorized{}
|
||||
}
|
||||
|
||||
/* DetailServiceUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type DetailServiceUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DetailServiceUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[GET /services/{id}][%d] detailServiceUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *DetailServiceUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DetailServiceUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDetailServiceNotFound creates a DetailServiceNotFound with default headers values
|
||||
func NewDetailServiceNotFound() *DetailServiceNotFound {
|
||||
return &DetailServiceNotFound{}
|
||||
}
|
||||
|
||||
/* DetailServiceNotFound describes a response with status code 404, with default header values.
|
||||
|
||||
The requested resource does not exist
|
||||
*/
|
||||
type DetailServiceNotFound struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *DetailServiceNotFound) Error() string {
|
||||
return fmt.Sprintf("[GET /services/{id}][%d] detailServiceNotFound %+v", 404, o.Payload)
|
||||
}
|
||||
func (o *DetailServiceNotFound) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *DetailServiceNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
// 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 service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// NewListServiceTerminatorsParams creates a new ListServiceTerminatorsParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewListServiceTerminatorsParams() *ListServiceTerminatorsParams {
|
||||
return &ListServiceTerminatorsParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListServiceTerminatorsParamsWithTimeout creates a new ListServiceTerminatorsParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewListServiceTerminatorsParamsWithTimeout(timeout time.Duration) *ListServiceTerminatorsParams {
|
||||
return &ListServiceTerminatorsParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListServiceTerminatorsParamsWithContext creates a new ListServiceTerminatorsParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewListServiceTerminatorsParamsWithContext(ctx context.Context) *ListServiceTerminatorsParams {
|
||||
return &ListServiceTerminatorsParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListServiceTerminatorsParamsWithHTTPClient creates a new ListServiceTerminatorsParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewListServiceTerminatorsParamsWithHTTPClient(client *http.Client) *ListServiceTerminatorsParams {
|
||||
return &ListServiceTerminatorsParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* ListServiceTerminatorsParams contains all the parameters to send to the API endpoint
|
||||
for the list service terminators operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ListServiceTerminatorsParams struct {
|
||||
|
||||
// Filter.
|
||||
Filter *string
|
||||
|
||||
/* ID.
|
||||
|
||||
The id of the requested resource
|
||||
*/
|
||||
ID string
|
||||
|
||||
// Limit.
|
||||
Limit *int64
|
||||
|
||||
// Offset.
|
||||
Offset *int64
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the list service terminators params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ListServiceTerminatorsParams) WithDefaults() *ListServiceTerminatorsParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the list service terminators params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ListServiceTerminatorsParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) WithTimeout(timeout time.Duration) *ListServiceTerminatorsParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) WithContext(ctx context.Context) *ListServiceTerminatorsParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) WithHTTPClient(client *http.Client) *ListServiceTerminatorsParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithFilter adds the filter to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) WithFilter(filter *string) *ListServiceTerminatorsParams {
|
||||
o.SetFilter(filter)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetFilter adds the filter to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) SetFilter(filter *string) {
|
||||
o.Filter = filter
|
||||
}
|
||||
|
||||
// WithID adds the id to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) WithID(id string) *ListServiceTerminatorsParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) SetID(id string) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WithLimit adds the limit to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) WithLimit(limit *int64) *ListServiceTerminatorsParams {
|
||||
o.SetLimit(limit)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetLimit adds the limit to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) SetLimit(limit *int64) {
|
||||
o.Limit = limit
|
||||
}
|
||||
|
||||
// WithOffset adds the offset to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) WithOffset(offset *int64) *ListServiceTerminatorsParams {
|
||||
o.SetOffset(offset)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetOffset adds the offset to the list service terminators params
|
||||
func (o *ListServiceTerminatorsParams) SetOffset(offset *int64) {
|
||||
o.Offset = offset
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ListServiceTerminatorsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if o.Filter != nil {
|
||||
|
||||
// query param filter
|
||||
var qrFilter string
|
||||
|
||||
if o.Filter != nil {
|
||||
qrFilter = *o.Filter
|
||||
}
|
||||
qFilter := qrFilter
|
||||
if qFilter != "" {
|
||||
|
||||
if err := r.SetQueryParam("filter", qFilter); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", o.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if o.Limit != nil {
|
||||
|
||||
// query param limit
|
||||
var qrLimit int64
|
||||
|
||||
if o.Limit != nil {
|
||||
qrLimit = *o.Limit
|
||||
}
|
||||
qLimit := swag.FormatInt64(qrLimit)
|
||||
if qLimit != "" {
|
||||
|
||||
if err := r.SetQueryParam("limit", qLimit); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if o.Offset != nil {
|
||||
|
||||
// query param offset
|
||||
var qrOffset int64
|
||||
|
||||
if o.Offset != nil {
|
||||
qrOffset = *o.Offset
|
||||
}
|
||||
qOffset := swag.FormatInt64(qrOffset)
|
||||
if qOffset != "" {
|
||||
|
||||
if err := r.SetQueryParam("offset", qOffset); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// 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 service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// ListServiceTerminatorsReader is a Reader for the ListServiceTerminators structure.
|
||||
type ListServiceTerminatorsReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ListServiceTerminatorsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewListServiceTerminatorsOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 400:
|
||||
result := NewListServiceTerminatorsBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 401:
|
||||
result := NewListServiceTerminatorsUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewListServiceTerminatorsOK creates a ListServiceTerminatorsOK with default headers values
|
||||
func NewListServiceTerminatorsOK() *ListServiceTerminatorsOK {
|
||||
return &ListServiceTerminatorsOK{}
|
||||
}
|
||||
|
||||
/* ListServiceTerminatorsOK describes a response with status code 200, with default header values.
|
||||
|
||||
A list of terminators
|
||||
*/
|
||||
type ListServiceTerminatorsOK struct {
|
||||
Payload *rest_model.ListTerminatorsEnvelope
|
||||
}
|
||||
|
||||
func (o *ListServiceTerminatorsOK) Error() string {
|
||||
return fmt.Sprintf("[GET /services/{id}/terminators][%d] listServiceTerminatorsOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *ListServiceTerminatorsOK) GetPayload() *rest_model.ListTerminatorsEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListServiceTerminatorsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.ListTerminatorsEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewListServiceTerminatorsBadRequest creates a ListServiceTerminatorsBadRequest with default headers values
|
||||
func NewListServiceTerminatorsBadRequest() *ListServiceTerminatorsBadRequest {
|
||||
return &ListServiceTerminatorsBadRequest{}
|
||||
}
|
||||
|
||||
/* ListServiceTerminatorsBadRequest describes a response with status code 400, with default header values.
|
||||
|
||||
The supplied request contains invalid fields or could not be parsed (json and non-json bodies). The error's code, message, and cause fields can be inspected for further information
|
||||
*/
|
||||
type ListServiceTerminatorsBadRequest struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *ListServiceTerminatorsBadRequest) Error() string {
|
||||
return fmt.Sprintf("[GET /services/{id}/terminators][%d] listServiceTerminatorsBadRequest %+v", 400, o.Payload)
|
||||
}
|
||||
func (o *ListServiceTerminatorsBadRequest) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListServiceTerminatorsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewListServiceTerminatorsUnauthorized creates a ListServiceTerminatorsUnauthorized with default headers values
|
||||
func NewListServiceTerminatorsUnauthorized() *ListServiceTerminatorsUnauthorized {
|
||||
return &ListServiceTerminatorsUnauthorized{}
|
||||
}
|
||||
|
||||
/* ListServiceTerminatorsUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type ListServiceTerminatorsUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *ListServiceTerminatorsUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[GET /services/{id}/terminators][%d] listServiceTerminatorsUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *ListServiceTerminatorsUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListServiceTerminatorsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
// 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 service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// NewListServicesParams creates a new ListServicesParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewListServicesParams() *ListServicesParams {
|
||||
return &ListServicesParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListServicesParamsWithTimeout creates a new ListServicesParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewListServicesParamsWithTimeout(timeout time.Duration) *ListServicesParams {
|
||||
return &ListServicesParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListServicesParamsWithContext creates a new ListServicesParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewListServicesParamsWithContext(ctx context.Context) *ListServicesParams {
|
||||
return &ListServicesParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListServicesParamsWithHTTPClient creates a new ListServicesParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewListServicesParamsWithHTTPClient(client *http.Client) *ListServicesParams {
|
||||
return &ListServicesParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* ListServicesParams contains all the parameters to send to the API endpoint
|
||||
for the list services operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ListServicesParams struct {
|
||||
|
||||
// Filter.
|
||||
Filter *string
|
||||
|
||||
// Limit.
|
||||
Limit *int64
|
||||
|
||||
// Offset.
|
||||
Offset *int64
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the list services params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ListServicesParams) WithDefaults() *ListServicesParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the list services params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ListServicesParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the list services params
|
||||
func (o *ListServicesParams) WithTimeout(timeout time.Duration) *ListServicesParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the list services params
|
||||
func (o *ListServicesParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the list services params
|
||||
func (o *ListServicesParams) WithContext(ctx context.Context) *ListServicesParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the list services params
|
||||
func (o *ListServicesParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the list services params
|
||||
func (o *ListServicesParams) WithHTTPClient(client *http.Client) *ListServicesParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the list services params
|
||||
func (o *ListServicesParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithFilter adds the filter to the list services params
|
||||
func (o *ListServicesParams) WithFilter(filter *string) *ListServicesParams {
|
||||
o.SetFilter(filter)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetFilter adds the filter to the list services params
|
||||
func (o *ListServicesParams) SetFilter(filter *string) {
|
||||
o.Filter = filter
|
||||
}
|
||||
|
||||
// WithLimit adds the limit to the list services params
|
||||
func (o *ListServicesParams) WithLimit(limit *int64) *ListServicesParams {
|
||||
o.SetLimit(limit)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetLimit adds the limit to the list services params
|
||||
func (o *ListServicesParams) SetLimit(limit *int64) {
|
||||
o.Limit = limit
|
||||
}
|
||||
|
||||
// WithOffset adds the offset to the list services params
|
||||
func (o *ListServicesParams) WithOffset(offset *int64) *ListServicesParams {
|
||||
o.SetOffset(offset)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetOffset adds the offset to the list services params
|
||||
func (o *ListServicesParams) SetOffset(offset *int64) {
|
||||
o.Offset = offset
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ListServicesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if o.Filter != nil {
|
||||
|
||||
// query param filter
|
||||
var qrFilter string
|
||||
|
||||
if o.Filter != nil {
|
||||
qrFilter = *o.Filter
|
||||
}
|
||||
qFilter := qrFilter
|
||||
if qFilter != "" {
|
||||
|
||||
if err := r.SetQueryParam("filter", qFilter); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if o.Limit != nil {
|
||||
|
||||
// query param limit
|
||||
var qrLimit int64
|
||||
|
||||
if o.Limit != nil {
|
||||
qrLimit = *o.Limit
|
||||
}
|
||||
qLimit := swag.FormatInt64(qrLimit)
|
||||
if qLimit != "" {
|
||||
|
||||
if err := r.SetQueryParam("limit", qLimit); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if o.Offset != nil {
|
||||
|
||||
// query param offset
|
||||
var qrOffset int64
|
||||
|
||||
if o.Offset != nil {
|
||||
qrOffset = *o.Offset
|
||||
}
|
||||
qOffset := swag.FormatInt64(qrOffset)
|
||||
if qOffset != "" {
|
||||
|
||||
if err := r.SetQueryParam("offset", qOffset); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// 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 service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti/fabric/rest_model"
|
||||
)
|
||||
|
||||
// ListServicesReader is a Reader for the ListServices structure.
|
||||
type ListServicesReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ListServicesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewListServicesOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 401:
|
||||
result := NewListServicesUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewListServicesOK creates a ListServicesOK with default headers values
|
||||
func NewListServicesOK() *ListServicesOK {
|
||||
return &ListServicesOK{}
|
||||
}
|
||||
|
||||
/* ListServicesOK describes a response with status code 200, with default header values.
|
||||
|
||||
A list of services
|
||||
*/
|
||||
type ListServicesOK struct {
|
||||
Payload *rest_model.ListServicesEnvelope
|
||||
}
|
||||
|
||||
func (o *ListServicesOK) Error() string {
|
||||
return fmt.Sprintf("[GET /services][%d] listServicesOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *ListServicesOK) GetPayload() *rest_model.ListServicesEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListServicesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.ListServicesEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewListServicesUnauthorized creates a ListServicesUnauthorized with default headers values
|
||||
func NewListServicesUnauthorized() *ListServicesUnauthorized {
|
||||
return &ListServicesUnauthorized{}
|
||||
}
|
||||
|
||||
/* ListServicesUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
The currently supplied session does not have the correct access rights to request this resource
|
||||
*/
|
||||
type ListServicesUnauthorized struct {
|
||||
Payload *rest_model.APIErrorEnvelope
|
||||
}
|
||||
|
||||
func (o *ListServicesUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[GET /services][%d] listServicesUnauthorized %+v", 401, o.Payload)
|
||||
}
|
||||
func (o *ListServicesUnauthorized) GetPayload() *rest_model.APIErrorEnvelope {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListServicesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.APIErrorEnvelope)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user