From 52cfbbbe29deb657c96804dc55c073382bcb6f27 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Thu, 4 Nov 2021 21:58:54 -0400 Subject: [PATCH 1/7] Add REST based management API --- build/build_info.go | 39 + controller/api/api.go | 41 + controller/api/context.go | 87 + controller/api/cors.go | 29 + controller/api/json_fields.go | 71 + controller/api/responder.go | 140 + controller/api/timeouts.go | 178 + controller/api_impl/base_entity_api_model.go | 118 + controller/api_impl/base_router.go | 409 ++ controller/api_impl/context.go | 43 + controller/api_impl/helpers.go | 146 + controller/api_impl/management-api.go | 134 + controller/api_impl/query_options.go | 109 + controller/api_impl/responder.go | 48 + controller/api_impl/router_api_model.go | 135 + controller/api_impl/router_router.go | 114 + controller/api_impl/routers.go | 13 + controller/api_impl/routes.go | 119 + controller/api_impl/service_api_model.go | 127 + controller/api_impl/service_router.go | 114 + controller/api_impl/terminator_api_model.go | 157 + controller/api_impl/terminator_router.go | 96 + controller/api_impl/versions.go | 43 + controller/api_impl/wrapper.go | 114 + controller/apierror/api.go | 40 + controller/apierror/bodyparser.go | 94 + controller/apierror/helpers.go | 271 ++ controller/apierror/json.go | 30 + controller/apierror/messages.go | 165 + controller/apierror/schema.go | 61 + controller/controller.go | 11 +- controller/db/base_store.go | 5 + controller/eid/id.go | 23 + controller/models/base_model.go | 24 + controller/network/controllers.go | 32 + controller/network/service.go | 17 +- .../router/create_router_parameters.go | 175 + rest_client/router/create_router_responses.go | 167 + .../router/delete_router_parameters.go | 173 + rest_client/router/delete_router_responses.go | 205 + .../router/detail_router_parameters.go | 173 + rest_client/router/detail_router_responses.go | 167 + .../list_router_terminators_parameters.go | 267 ++ .../list_router_terminators_responses.go | 167 + rest_client/router/list_routers_parameters.go | 245 + rest_client/router/list_routers_responses.go | 129 + rest_client/router/router_client.go | 275 ++ .../service/create_service_parameters.go | 175 + .../service/create_service_responses.go | 167 + .../service/delete_service_parameters.go | 173 + .../service/delete_service_responses.go | 205 + .../service/detail_service_parameters.go | 173 + .../service/detail_service_responses.go | 167 + .../list_service_terminators_parameters.go | 267 ++ .../list_service_terminators_responses.go | 167 + .../service/list_services_parameters.go | 245 + .../service/list_services_responses.go | 129 + .../service/patch_service_parameters.go | 197 + .../service/patch_service_responses.go | 205 + rest_client/service/service_client.go | 359 ++ .../service/update_service_parameters.go | 197 + .../service/update_service_responses.go | 205 + .../create_terminator_parameters.go | 175 + .../terminator/create_terminator_responses.go | 167 + .../delete_terminator_parameters.go | 173 + .../terminator/delete_terminator_responses.go | 205 + .../detail_terminator_parameters.go | 173 + .../terminator/detail_terminator_responses.go | 167 + .../terminator/list_terminators_parameters.go | 245 + .../terminator/list_terminators_responses.go | 167 + .../terminator/patch_terminator_parameters.go | 197 + .../terminator/patch_terminator_responses.go | 205 + rest_client/terminator/terminator_client.go | 316 ++ .../update_terminator_parameters.go | 197 + .../terminator/update_terminator_responses.go | 205 + rest_client/ziti_fabric_client.go | 146 + rest_model/api_error.go | 189 + rest_model/api_error_args.go | 74 + rest_model/api_error_cause.go | 140 + rest_model/api_error_envelope.go | 179 + rest_model/api_field_error.go | 80 + rest_model/base_entity.go | 238 + rest_model/create_envelope.go | 174 + rest_model/create_location.go | 129 + rest_model/detail_router_envelope.go | 179 + rest_model/detail_service_envelope.go | 179 + rest_model/detail_terminator_envelope.go | 179 + rest_model/empty.go | 149 + rest_model/entity_ref.go | 135 + rest_model/link.go | 106 + rest_model/links.go | 86 + rest_model/list_routers_envelope.go | 175 + rest_model/list_services_envelope.go | 175 + rest_model/list_terminators_envelope.go | 175 + rest_model/meta.go | 137 + rest_model/pagination.go | 129 + rest_model/router_create.go | 166 + rest_model/router_detail.go | 272 ++ rest_model/router_list.go | 97 + rest_model/router_patch.go | 134 + rest_model/router_update.go | 149 + rest_model/service_create.go | 149 + rest_model/service_detail.go | 181 + rest_model/service_list.go | 97 + rest_model/service_patch.go | 134 + rest_model/service_update.go | 149 + rest_model/sub_tags.go | 51 + rest_model/tags.go | 117 + rest_model/terminator_cost.go | 66 + rest_model/terminator_cost_map.go | 86 + rest_model/terminator_create.go | 292 ++ rest_model/terminator_detail.go | 548 +++ rest_model/terminator_list.go | 97 + rest_model/terminator_patch.go | 228 + rest_model/terminator_precedence.go | 101 + rest_model/terminator_precedence_map.go | 82 + rest_model/terminator_update.go | 285 ++ rest_model/version_info.go | 86 + rest_server/configure_ziti_fabric.go | 187 + rest_server/doc.go | 42 + rest_server/embedded_spec.go | 4228 +++++++++++++++++ .../operations/router/create_router.go | 82 + .../router/create_router_parameters.go | 109 + .../router/create_router_responses.go | 170 + .../router/create_router_urlbuilder.go | 111 + .../operations/router/delete_router.go | 82 + .../router/delete_router_parameters.go | 95 + .../router/delete_router_responses.go | 214 + .../router/delete_router_urlbuilder.go | 123 + .../operations/router/detail_router.go | 82 + .../router/detail_router_parameters.go | 95 + .../router/detail_router_responses.go | 170 + .../router/detail_router_urlbuilder.go | 123 + .../router/list_router_terminators.go | 83 + .../list_router_terminators_parameters.go | 190 + .../list_router_terminators_responses.go | 170 + .../list_router_terminators_urlbuilder.go | 157 + rest_server/operations/router/list_routers.go | 83 + .../router/list_routers_parameters.go | 166 + .../router/list_routers_responses.go | 126 + .../router/list_routers_urlbuilder.go | 147 + .../operations/service/create_service.go | 82 + .../service/create_service_parameters.go | 109 + .../service/create_service_responses.go | 170 + .../service/create_service_urlbuilder.go | 111 + .../operations/service/delete_service.go | 82 + .../service/delete_service_parameters.go | 95 + .../service/delete_service_responses.go | 214 + .../service/delete_service_urlbuilder.go | 123 + .../operations/service/detail_service.go | 82 + .../service/detail_service_parameters.go | 95 + .../service/detail_service_responses.go | 170 + .../service/detail_service_urlbuilder.go | 123 + .../service/list_service_terminators.go | 83 + .../list_service_terminators_parameters.go | 190 + .../list_service_terminators_responses.go | 170 + .../list_service_terminators_urlbuilder.go | 157 + .../operations/service/list_services.go | 83 + .../service/list_services_parameters.go | 166 + .../service/list_services_responses.go | 126 + .../service/list_services_urlbuilder.go | 147 + .../operations/service/patch_service.go | 82 + .../service/patch_service_parameters.go | 134 + .../service/patch_service_responses.go | 214 + .../service/patch_service_urlbuilder.go | 123 + .../operations/service/update_service.go | 82 + .../service/update_service_parameters.go | 134 + .../service/update_service_responses.go | 214 + .../service/update_service_urlbuilder.go | 123 + .../terminator/create_terminator.go | 82 + .../create_terminator_parameters.go | 109 + .../terminator/create_terminator_responses.go | 170 + .../create_terminator_urlbuilder.go | 111 + .../terminator/delete_terminator.go | 82 + .../delete_terminator_parameters.go | 95 + .../terminator/delete_terminator_responses.go | 214 + .../delete_terminator_urlbuilder.go | 123 + .../terminator/detail_terminator.go | 82 + .../detail_terminator_parameters.go | 95 + .../terminator/detail_terminator_responses.go | 170 + .../detail_terminator_urlbuilder.go | 123 + .../operations/terminator/list_terminators.go | 83 + .../terminator/list_terminators_parameters.go | 166 + .../terminator/list_terminators_responses.go | 170 + .../terminator/list_terminators_urlbuilder.go | 147 + .../operations/terminator/patch_terminator.go | 82 + .../terminator/patch_terminator_parameters.go | 134 + .../terminator/patch_terminator_responses.go | 214 + .../terminator/patch_terminator_urlbuilder.go | 123 + .../terminator/update_terminator.go | 82 + .../update_terminator_parameters.go | 134 + .../terminator/update_terminator_responses.go | 214 + .../update_terminator_urlbuilder.go | 123 + rest_server/operations/ziti_fabric_api.go | 533 +++ rest_server/server.go | 532 +++ scripts/generate_rest.ps1 | 71 + scripts/generate_rest.sh | 44 + scripts/template.copyright.txt | 23 + specs/swagger.yml | 1130 +++++ version | 2 +- xweb/server.go | 5 +- 201 files changed, 34060 insertions(+), 10 deletions(-) create mode 100644 build/build_info.go create mode 100644 controller/api/api.go create mode 100644 controller/api/context.go create mode 100644 controller/api/cors.go create mode 100644 controller/api/json_fields.go create mode 100644 controller/api/responder.go create mode 100644 controller/api/timeouts.go create mode 100644 controller/api_impl/base_entity_api_model.go create mode 100644 controller/api_impl/base_router.go create mode 100644 controller/api_impl/context.go create mode 100644 controller/api_impl/helpers.go create mode 100644 controller/api_impl/management-api.go create mode 100644 controller/api_impl/query_options.go create mode 100644 controller/api_impl/responder.go create mode 100644 controller/api_impl/router_api_model.go create mode 100644 controller/api_impl/router_router.go create mode 100644 controller/api_impl/routers.go create mode 100644 controller/api_impl/routes.go create mode 100644 controller/api_impl/service_api_model.go create mode 100644 controller/api_impl/service_router.go create mode 100644 controller/api_impl/terminator_api_model.go create mode 100644 controller/api_impl/terminator_router.go create mode 100644 controller/api_impl/versions.go create mode 100644 controller/api_impl/wrapper.go create mode 100644 controller/apierror/api.go create mode 100644 controller/apierror/bodyparser.go create mode 100644 controller/apierror/helpers.go create mode 100644 controller/apierror/json.go create mode 100644 controller/apierror/messages.go create mode 100644 controller/apierror/schema.go create mode 100644 controller/eid/id.go create mode 100644 rest_client/router/create_router_parameters.go create mode 100644 rest_client/router/create_router_responses.go create mode 100644 rest_client/router/delete_router_parameters.go create mode 100644 rest_client/router/delete_router_responses.go create mode 100644 rest_client/router/detail_router_parameters.go create mode 100644 rest_client/router/detail_router_responses.go create mode 100644 rest_client/router/list_router_terminators_parameters.go create mode 100644 rest_client/router/list_router_terminators_responses.go create mode 100644 rest_client/router/list_routers_parameters.go create mode 100644 rest_client/router/list_routers_responses.go create mode 100644 rest_client/router/router_client.go create mode 100644 rest_client/service/create_service_parameters.go create mode 100644 rest_client/service/create_service_responses.go create mode 100644 rest_client/service/delete_service_parameters.go create mode 100644 rest_client/service/delete_service_responses.go create mode 100644 rest_client/service/detail_service_parameters.go create mode 100644 rest_client/service/detail_service_responses.go create mode 100644 rest_client/service/list_service_terminators_parameters.go create mode 100644 rest_client/service/list_service_terminators_responses.go create mode 100644 rest_client/service/list_services_parameters.go create mode 100644 rest_client/service/list_services_responses.go create mode 100644 rest_client/service/patch_service_parameters.go create mode 100644 rest_client/service/patch_service_responses.go create mode 100644 rest_client/service/service_client.go create mode 100644 rest_client/service/update_service_parameters.go create mode 100644 rest_client/service/update_service_responses.go create mode 100644 rest_client/terminator/create_terminator_parameters.go create mode 100644 rest_client/terminator/create_terminator_responses.go create mode 100644 rest_client/terminator/delete_terminator_parameters.go create mode 100644 rest_client/terminator/delete_terminator_responses.go create mode 100644 rest_client/terminator/detail_terminator_parameters.go create mode 100644 rest_client/terminator/detail_terminator_responses.go create mode 100644 rest_client/terminator/list_terminators_parameters.go create mode 100644 rest_client/terminator/list_terminators_responses.go create mode 100644 rest_client/terminator/patch_terminator_parameters.go create mode 100644 rest_client/terminator/patch_terminator_responses.go create mode 100644 rest_client/terminator/terminator_client.go create mode 100644 rest_client/terminator/update_terminator_parameters.go create mode 100644 rest_client/terminator/update_terminator_responses.go create mode 100644 rest_client/ziti_fabric_client.go create mode 100644 rest_model/api_error.go create mode 100644 rest_model/api_error_args.go create mode 100644 rest_model/api_error_cause.go create mode 100644 rest_model/api_error_envelope.go create mode 100644 rest_model/api_field_error.go create mode 100644 rest_model/base_entity.go create mode 100644 rest_model/create_envelope.go create mode 100644 rest_model/create_location.go create mode 100644 rest_model/detail_router_envelope.go create mode 100644 rest_model/detail_service_envelope.go create mode 100644 rest_model/detail_terminator_envelope.go create mode 100644 rest_model/empty.go create mode 100644 rest_model/entity_ref.go create mode 100644 rest_model/link.go create mode 100644 rest_model/links.go create mode 100644 rest_model/list_routers_envelope.go create mode 100644 rest_model/list_services_envelope.go create mode 100644 rest_model/list_terminators_envelope.go create mode 100644 rest_model/meta.go create mode 100644 rest_model/pagination.go create mode 100644 rest_model/router_create.go create mode 100644 rest_model/router_detail.go create mode 100644 rest_model/router_list.go create mode 100644 rest_model/router_patch.go create mode 100644 rest_model/router_update.go create mode 100644 rest_model/service_create.go create mode 100644 rest_model/service_detail.go create mode 100644 rest_model/service_list.go create mode 100644 rest_model/service_patch.go create mode 100644 rest_model/service_update.go create mode 100644 rest_model/sub_tags.go create mode 100644 rest_model/tags.go create mode 100644 rest_model/terminator_cost.go create mode 100644 rest_model/terminator_cost_map.go create mode 100644 rest_model/terminator_create.go create mode 100644 rest_model/terminator_detail.go create mode 100644 rest_model/terminator_list.go create mode 100644 rest_model/terminator_patch.go create mode 100644 rest_model/terminator_precedence.go create mode 100644 rest_model/terminator_precedence_map.go create mode 100644 rest_model/terminator_update.go create mode 100644 rest_model/version_info.go create mode 100644 rest_server/configure_ziti_fabric.go create mode 100644 rest_server/doc.go create mode 100644 rest_server/embedded_spec.go create mode 100644 rest_server/operations/router/create_router.go create mode 100644 rest_server/operations/router/create_router_parameters.go create mode 100644 rest_server/operations/router/create_router_responses.go create mode 100644 rest_server/operations/router/create_router_urlbuilder.go create mode 100644 rest_server/operations/router/delete_router.go create mode 100644 rest_server/operations/router/delete_router_parameters.go create mode 100644 rest_server/operations/router/delete_router_responses.go create mode 100644 rest_server/operations/router/delete_router_urlbuilder.go create mode 100644 rest_server/operations/router/detail_router.go create mode 100644 rest_server/operations/router/detail_router_parameters.go create mode 100644 rest_server/operations/router/detail_router_responses.go create mode 100644 rest_server/operations/router/detail_router_urlbuilder.go create mode 100644 rest_server/operations/router/list_router_terminators.go create mode 100644 rest_server/operations/router/list_router_terminators_parameters.go create mode 100644 rest_server/operations/router/list_router_terminators_responses.go create mode 100644 rest_server/operations/router/list_router_terminators_urlbuilder.go create mode 100644 rest_server/operations/router/list_routers.go create mode 100644 rest_server/operations/router/list_routers_parameters.go create mode 100644 rest_server/operations/router/list_routers_responses.go create mode 100644 rest_server/operations/router/list_routers_urlbuilder.go create mode 100644 rest_server/operations/service/create_service.go create mode 100644 rest_server/operations/service/create_service_parameters.go create mode 100644 rest_server/operations/service/create_service_responses.go create mode 100644 rest_server/operations/service/create_service_urlbuilder.go create mode 100644 rest_server/operations/service/delete_service.go create mode 100644 rest_server/operations/service/delete_service_parameters.go create mode 100644 rest_server/operations/service/delete_service_responses.go create mode 100644 rest_server/operations/service/delete_service_urlbuilder.go create mode 100644 rest_server/operations/service/detail_service.go create mode 100644 rest_server/operations/service/detail_service_parameters.go create mode 100644 rest_server/operations/service/detail_service_responses.go create mode 100644 rest_server/operations/service/detail_service_urlbuilder.go create mode 100644 rest_server/operations/service/list_service_terminators.go create mode 100644 rest_server/operations/service/list_service_terminators_parameters.go create mode 100644 rest_server/operations/service/list_service_terminators_responses.go create mode 100644 rest_server/operations/service/list_service_terminators_urlbuilder.go create mode 100644 rest_server/operations/service/list_services.go create mode 100644 rest_server/operations/service/list_services_parameters.go create mode 100644 rest_server/operations/service/list_services_responses.go create mode 100644 rest_server/operations/service/list_services_urlbuilder.go create mode 100644 rest_server/operations/service/patch_service.go create mode 100644 rest_server/operations/service/patch_service_parameters.go create mode 100644 rest_server/operations/service/patch_service_responses.go create mode 100644 rest_server/operations/service/patch_service_urlbuilder.go create mode 100644 rest_server/operations/service/update_service.go create mode 100644 rest_server/operations/service/update_service_parameters.go create mode 100644 rest_server/operations/service/update_service_responses.go create mode 100644 rest_server/operations/service/update_service_urlbuilder.go create mode 100644 rest_server/operations/terminator/create_terminator.go create mode 100644 rest_server/operations/terminator/create_terminator_parameters.go create mode 100644 rest_server/operations/terminator/create_terminator_responses.go create mode 100644 rest_server/operations/terminator/create_terminator_urlbuilder.go create mode 100644 rest_server/operations/terminator/delete_terminator.go create mode 100644 rest_server/operations/terminator/delete_terminator_parameters.go create mode 100644 rest_server/operations/terminator/delete_terminator_responses.go create mode 100644 rest_server/operations/terminator/delete_terminator_urlbuilder.go create mode 100644 rest_server/operations/terminator/detail_terminator.go create mode 100644 rest_server/operations/terminator/detail_terminator_parameters.go create mode 100644 rest_server/operations/terminator/detail_terminator_responses.go create mode 100644 rest_server/operations/terminator/detail_terminator_urlbuilder.go create mode 100644 rest_server/operations/terminator/list_terminators.go create mode 100644 rest_server/operations/terminator/list_terminators_parameters.go create mode 100644 rest_server/operations/terminator/list_terminators_responses.go create mode 100644 rest_server/operations/terminator/list_terminators_urlbuilder.go create mode 100644 rest_server/operations/terminator/patch_terminator.go create mode 100644 rest_server/operations/terminator/patch_terminator_parameters.go create mode 100644 rest_server/operations/terminator/patch_terminator_responses.go create mode 100644 rest_server/operations/terminator/patch_terminator_urlbuilder.go create mode 100644 rest_server/operations/terminator/update_terminator.go create mode 100644 rest_server/operations/terminator/update_terminator_parameters.go create mode 100644 rest_server/operations/terminator/update_terminator_responses.go create mode 100644 rest_server/operations/terminator/update_terminator_urlbuilder.go create mode 100644 rest_server/operations/ziti_fabric_api.go create mode 100644 rest_server/server.go create mode 100644 scripts/generate_rest.ps1 create mode 100755 scripts/generate_rest.sh create mode 100644 scripts/template.copyright.txt create mode 100644 specs/swagger.yml diff --git a/build/build_info.go b/build/build_info.go new file mode 100644 index 000000000..21c85ec48 --- /dev/null +++ b/build/build_info.go @@ -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" +} diff --git a/controller/api/api.go b/controller/api/api.go new file mode 100644 index 000000000..f23cade53 --- /dev/null +++ b/controller/api/api.go @@ -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) +} diff --git a/controller/api/context.go b/controller/api/context.go new file mode 100644 index 000000000..8bf023a74 --- /dev/null +++ b/controller/api/context.go @@ -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 +} diff --git a/controller/api/cors.go b/controller/api/cors.go new file mode 100644 index 000000000..ec08ff9b0 --- /dev/null +++ b/controller/api/cors.go @@ -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) +} diff --git a/controller/api/json_fields.go b/controller/api/json_fields.go new file mode 100644 index 000000000..77af85817 --- /dev/null +++ b/controller/api/json_fields.go @@ -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 + } + } +} diff --git a/controller/api/responder.go b/controller/api/responder.go new file mode 100644 index 000000000..83306320f --- /dev/null +++ b/controller/api/responder.go @@ -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 +} diff --git a/controller/api/timeouts.go b/controller/api/timeouts.go new file mode 100644 index 000000000..bdc88d2c1 --- /dev/null +++ b/controller/api/timeouts.go @@ -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 +} diff --git a/controller/api_impl/base_entity_api_model.go b/controller/api_impl/base_entity_api_model.go new file mode 100644 index 000000000..b9407d80c --- /dev/null +++ b/controller/api_impl/base_entity_api_model.go @@ -0,0 +1,118 @@ +/* + 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 models.Entity) 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 models.Entity) rest_model.Link { + return NewLink(factory.SelfUrlString(entity.GetId())) +} + +func (factory *BasicLinkFactory) Links(entity models.Entity) rest_model.Links { + return rest_model.Links{ + EntityNameSelf: factory.SelfLink(entity), + } +} + +func (factory BasicLinkFactory) NewNestedLink(entity models.Entity, 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 +} + +func ToEntityRef(name string, entity models.Entity, 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, + } +} diff --git a/controller/api_impl/base_router.go b/controller/api_impl/base_router.go new file mode 100644 index 000000000..53b7d4154 --- /dev/null +++ b/controller/api_impl/base_router.go @@ -0,0 +1,409 @@ +/* + 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 +} + +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) +} diff --git a/controller/api_impl/context.go b/controller/api_impl/context.go new file mode 100644 index 000000000..253e34c58 --- /dev/null +++ b/controller/api_impl/context.go @@ -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/eid" + "io/ioutil" + "net/http" +) + +func NewRequestContext(rw http.ResponseWriter, r *http.Request) api.RequestContext { + rid := eid.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 +} diff --git a/controller/api_impl/helpers.go b/controller/api_impl/helpers.go new file mode 100644 index 000000000..383968e01 --- /dev/null +++ b/controller/api_impl/helpers.go @@ -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 +} diff --git a/controller/api_impl/management-api.go b/controller/api_impl/management-api.go new file mode 100644 index 000000000..cefa184e3 --- /dev/null +++ b/controller/api_impl/management-api.go @@ -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) +} diff --git a/controller/api_impl/query_options.go b/controller/api_impl/query_options.go new file mode 100644 index 000000000..94471e756 --- /dev/null +++ b/controller/api_impl/query_options.go @@ -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) +} diff --git a/controller/api_impl/responder.go b/controller/api_impl/responder.go new file mode 100644 index 000000000..0f11b9ae0 --- /dev/null +++ b/controller/api_impl/responder.go @@ -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, + }, + } +} diff --git a/controller/api_impl/router_api_model.go b/controller/api_impl/router_api_model.go new file mode 100644 index 000000000..21f98ed3e --- /dev/null +++ b/controller/api_impl/router_api_model.go @@ -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 models.Entity) 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 +} diff --git a/controller/api_impl/router_router.go b/controller/api_impl/router_router.go new file mode 100644 index 000000000..04aeedd9f --- /dev/null +++ b/controller/api_impl/router_router.go @@ -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) +} diff --git a/controller/api_impl/routers.go b/controller/api_impl/routers.go new file mode 100644 index 000000000..6dd8ef59a --- /dev/null +++ b/controller/api_impl/routers.go @@ -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) +} diff --git a/controller/api_impl/routes.go b/controller/api_impl/routes.go new file mode 100644 index 000000000..aa8118928 --- /dev/null +++ b/controller/api_impl/routes.go @@ -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 +} diff --git a/controller/api_impl/service_api_model.go b/controller/api_impl/service_api_model.go new file mode 100644 index 000000000..8a782024b --- /dev/null +++ b/controller/api_impl/service_api_model.go @@ -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/eid" + "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 models.Entity) 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 = eid.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 +} diff --git a/controller/api_impl/service_router.go b/controller/api_impl/service_router.go new file mode 100644 index 000000000..24603c561 --- /dev/null +++ b/controller/api_impl/service_router.go @@ -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) +} diff --git a/controller/api_impl/terminator_api_model.go b/controller/api_impl/terminator_api_model.go new file mode 100644 index 000000000..dce6cf2a0 --- /dev/null +++ b/controller/api_impl/terminator_api_model.go @@ -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 +} diff --git a/controller/api_impl/terminator_router.go b/controller/api_impl/terminator_router.go new file mode 100644 index 000000000..ec9aae2cd --- /dev/null +++ b/controller/api_impl/terminator_router.go @@ -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")) + }) +} diff --git a/controller/api_impl/versions.go b/controller/api_impl/versions.go new file mode 100644 index 000000000..9c3f8aba9 --- /dev/null +++ b/controller/api_impl/versions.go @@ -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, + }, +} diff --git a/controller/api_impl/wrapper.go b/controller/api_impl/wrapper.go new file mode 100644 index 000000000..2eb3d2633 --- /dev/null +++ b/controller/api_impl/wrapper.go @@ -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() +} diff --git a/controller/apierror/api.go b/controller/apierror/api.go new file mode 100644 index 000000000..a42e35571 --- /dev/null +++ b/controller/apierror/api.go @@ -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 +} diff --git a/controller/apierror/bodyparser.go b/controller/apierror/bodyparser.go new file mode 100644 index 000000000..a0d6f6b61 --- /dev/null +++ b/controller/apierror/bodyparser.go @@ -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), + } +} diff --git a/controller/apierror/helpers.go b/controller/apierror/helpers.go new file mode 100644 index 000000000..e9128b4a4 --- /dev/null +++ b/controller/apierror/helpers.go @@ -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, + } +} diff --git a/controller/apierror/json.go b/controller/apierror/json.go new file mode 100644 index 000000000..3c20cd374 --- /dev/null +++ b/controller/apierror/json.go @@ -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 +} diff --git a/controller/apierror/messages.go b/controller/apierror/messages.go new file mode 100644 index 000000000..ae0cc7f76 --- /dev/null +++ b/controller/apierror/messages.go @@ -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 +) diff --git a/controller/apierror/schema.go b/controller/apierror/schema.go new file mode 100644 index 000000000..c76cc4c00 --- /dev/null +++ b/controller/apierror/schema.go @@ -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} +} diff --git a/controller/controller.go b/controller/controller.go index e7bb2b9a3..2bd5bf936 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -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 { diff --git a/controller/db/base_store.go b/controller/db/base_store.go index 633861632..b242dbd31 100644 --- a/controller/db/base_store.go +++ b/controller/db/base_store.go @@ -32,3 +32,8 @@ type baseStore struct { stores *stores *boltz.BaseStore } + +type NameIndexedStore interface { + boltz.CrudStore + GetNameIndex() boltz.ReadIndex +} diff --git a/controller/eid/id.go b/controller/eid/id.go new file mode 100644 index 000000000..5b17c39f8 --- /dev/null +++ b/controller/eid/id.go @@ -0,0 +1,23 @@ +package eid + +import ( + "crypto/rand" + "encoding/binary" + "github.com/teris-io/shortid" +) + +const Alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-" + +var idGenerator *shortid.Shortid + +func init() { + buf := make([]byte, 8) + _, _ = rand.Read(buf) + seed := binary.LittleEndian.Uint64(buf) + idGenerator = shortid.MustNew(0, Alphabet, seed) +} + +func New() string { + id, _ := idGenerator.Generate() + return id +} diff --git a/controller/models/base_model.go b/controller/models/base_model.go index 456a23bbc..c58f85ba5 100644 --- a/controller/models/base_model.go +++ b/controller/models/base_model.go @@ -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 +} diff --git a/controller/network/controllers.go b/controller/network/controllers.go index fba2441b7..bedf9852d 100644 --- a/controller/network/controllers.go +++ b/controller/network/controllers.go @@ -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 + }) +} diff --git a/controller/network/service.go b/controller/network/service.go index ff18ab1aa..94c68cf7e 100644 --- a/controller/network/service.go +++ b/controller/network/service.go @@ -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 } diff --git a/rest_client/router/create_router_parameters.go b/rest_client/router/create_router_parameters.go new file mode 100644 index 000000000..53dd7e188 --- /dev/null +++ b/rest_client/router/create_router_parameters.go @@ -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 +} diff --git a/rest_client/router/create_router_responses.go b/rest_client/router/create_router_responses.go new file mode 100644 index 000000000..8073756e9 --- /dev/null +++ b/rest_client/router/create_router_responses.go @@ -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 +} diff --git a/rest_client/router/delete_router_parameters.go b/rest_client/router/delete_router_parameters.go new file mode 100644 index 000000000..abe45bcf5 --- /dev/null +++ b/rest_client/router/delete_router_parameters.go @@ -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 +} diff --git a/rest_client/router/delete_router_responses.go b/rest_client/router/delete_router_responses.go new file mode 100644 index 000000000..7f47e5af2 --- /dev/null +++ b/rest_client/router/delete_router_responses.go @@ -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 +} diff --git a/rest_client/router/detail_router_parameters.go b/rest_client/router/detail_router_parameters.go new file mode 100644 index 000000000..36d91bf68 --- /dev/null +++ b/rest_client/router/detail_router_parameters.go @@ -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 +} diff --git a/rest_client/router/detail_router_responses.go b/rest_client/router/detail_router_responses.go new file mode 100644 index 000000000..3a298fed4 --- /dev/null +++ b/rest_client/router/detail_router_responses.go @@ -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 +} diff --git a/rest_client/router/list_router_terminators_parameters.go b/rest_client/router/list_router_terminators_parameters.go new file mode 100644 index 000000000..f45d61d23 --- /dev/null +++ b/rest_client/router/list_router_terminators_parameters.go @@ -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 +} diff --git a/rest_client/router/list_router_terminators_responses.go b/rest_client/router/list_router_terminators_responses.go new file mode 100644 index 000000000..de33a50cc --- /dev/null +++ b/rest_client/router/list_router_terminators_responses.go @@ -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 +} diff --git a/rest_client/router/list_routers_parameters.go b/rest_client/router/list_routers_parameters.go new file mode 100644 index 000000000..f28c70254 --- /dev/null +++ b/rest_client/router/list_routers_parameters.go @@ -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 +} diff --git a/rest_client/router/list_routers_responses.go b/rest_client/router/list_routers_responses.go new file mode 100644 index 000000000..2d462768b --- /dev/null +++ b/rest_client/router/list_routers_responses.go @@ -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 +} diff --git a/rest_client/router/router_client.go b/rest_client/router/router_client.go new file mode 100644 index 000000000..2aa61d63d --- /dev/null +++ b/rest_client/router/router_client.go @@ -0,0 +1,275 @@ +// 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) + + 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) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/rest_client/service/create_service_parameters.go b/rest_client/service/create_service_parameters.go new file mode 100644 index 000000000..7fab2807d --- /dev/null +++ b/rest_client/service/create_service_parameters.go @@ -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 +} diff --git a/rest_client/service/create_service_responses.go b/rest_client/service/create_service_responses.go new file mode 100644 index 000000000..2382dba96 --- /dev/null +++ b/rest_client/service/create_service_responses.go @@ -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 +} diff --git a/rest_client/service/delete_service_parameters.go b/rest_client/service/delete_service_parameters.go new file mode 100644 index 000000000..e4381338c --- /dev/null +++ b/rest_client/service/delete_service_parameters.go @@ -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 +} diff --git a/rest_client/service/delete_service_responses.go b/rest_client/service/delete_service_responses.go new file mode 100644 index 000000000..633cc7ae5 --- /dev/null +++ b/rest_client/service/delete_service_responses.go @@ -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 +} diff --git a/rest_client/service/detail_service_parameters.go b/rest_client/service/detail_service_parameters.go new file mode 100644 index 000000000..2b6d3bfc5 --- /dev/null +++ b/rest_client/service/detail_service_parameters.go @@ -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 +} diff --git a/rest_client/service/detail_service_responses.go b/rest_client/service/detail_service_responses.go new file mode 100644 index 000000000..a7060f6ff --- /dev/null +++ b/rest_client/service/detail_service_responses.go @@ -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 +} diff --git a/rest_client/service/list_service_terminators_parameters.go b/rest_client/service/list_service_terminators_parameters.go new file mode 100644 index 000000000..61702324d --- /dev/null +++ b/rest_client/service/list_service_terminators_parameters.go @@ -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 +} diff --git a/rest_client/service/list_service_terminators_responses.go b/rest_client/service/list_service_terminators_responses.go new file mode 100644 index 000000000..3d4d85591 --- /dev/null +++ b/rest_client/service/list_service_terminators_responses.go @@ -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 +} diff --git a/rest_client/service/list_services_parameters.go b/rest_client/service/list_services_parameters.go new file mode 100644 index 000000000..4fd7d6617 --- /dev/null +++ b/rest_client/service/list_services_parameters.go @@ -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 +} diff --git a/rest_client/service/list_services_responses.go b/rest_client/service/list_services_responses.go new file mode 100644 index 000000000..769614969 --- /dev/null +++ b/rest_client/service/list_services_responses.go @@ -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 +} diff --git a/rest_client/service/patch_service_parameters.go b/rest_client/service/patch_service_parameters.go new file mode 100644 index 000000000..e8e2ea329 --- /dev/null +++ b/rest_client/service/patch_service_parameters.go @@ -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 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" +) + +// NewPatchServiceParams creates a new PatchServiceParams 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 NewPatchServiceParams() *PatchServiceParams { + return &PatchServiceParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPatchServiceParamsWithTimeout creates a new PatchServiceParams object +// with the ability to set a timeout on a request. +func NewPatchServiceParamsWithTimeout(timeout time.Duration) *PatchServiceParams { + return &PatchServiceParams{ + timeout: timeout, + } +} + +// NewPatchServiceParamsWithContext creates a new PatchServiceParams object +// with the ability to set a context for a request. +func NewPatchServiceParamsWithContext(ctx context.Context) *PatchServiceParams { + return &PatchServiceParams{ + Context: ctx, + } +} + +// NewPatchServiceParamsWithHTTPClient creates a new PatchServiceParams object +// with the ability to set a custom HTTPClient for a request. +func NewPatchServiceParamsWithHTTPClient(client *http.Client) *PatchServiceParams { + return &PatchServiceParams{ + HTTPClient: client, + } +} + +/* PatchServiceParams contains all the parameters to send to the API endpoint + for the patch service operation. + + Typically these are written to a http.Request. +*/ +type PatchServiceParams struct { + + /* ID. + + The id of the requested resource + */ + ID string + + /* Service. + + A service patch object + */ + Service *rest_model.ServicePatch + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the patch service params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchServiceParams) WithDefaults() *PatchServiceParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the patch service params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchServiceParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the patch service params +func (o *PatchServiceParams) WithTimeout(timeout time.Duration) *PatchServiceParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the patch service params +func (o *PatchServiceParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the patch service params +func (o *PatchServiceParams) WithContext(ctx context.Context) *PatchServiceParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the patch service params +func (o *PatchServiceParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the patch service params +func (o *PatchServiceParams) WithHTTPClient(client *http.Client) *PatchServiceParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the patch service params +func (o *PatchServiceParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithID adds the id to the patch service params +func (o *PatchServiceParams) WithID(id string) *PatchServiceParams { + o.SetID(id) + return o +} + +// SetID adds the id to the patch service params +func (o *PatchServiceParams) SetID(id string) { + o.ID = id +} + +// WithService adds the service to the patch service params +func (o *PatchServiceParams) WithService(service *rest_model.ServicePatch) *PatchServiceParams { + o.SetService(service) + return o +} + +// SetService adds the service to the patch service params +func (o *PatchServiceParams) SetService(service *rest_model.ServicePatch) { + o.Service = service +} + +// WriteToRequest writes these params to a swagger request +func (o *PatchServiceParams) 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.Service != nil { + if err := r.SetBodyParam(o.Service); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client/service/patch_service_responses.go b/rest_client/service/patch_service_responses.go new file mode 100644 index 000000000..c4bec0b94 --- /dev/null +++ b/rest_client/service/patch_service_responses.go @@ -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" +) + +// PatchServiceReader is a Reader for the PatchService structure. +type PatchServiceReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PatchServiceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPatchServiceOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPatchServiceBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPatchServiceUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPatchServiceNotFound() + 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()) + } +} + +// NewPatchServiceOK creates a PatchServiceOK with default headers values +func NewPatchServiceOK() *PatchServiceOK { + return &PatchServiceOK{} +} + +/* PatchServiceOK describes a response with status code 200, with default header values. + +The patch request was successful and the resource has been altered +*/ +type PatchServiceOK struct { + Payload *rest_model.Empty +} + +func (o *PatchServiceOK) Error() string { + return fmt.Sprintf("[PATCH /services/{id}][%d] patchServiceOK %+v", 200, o.Payload) +} +func (o *PatchServiceOK) GetPayload() *rest_model.Empty { + return o.Payload +} + +func (o *PatchServiceOK) 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 +} + +// NewPatchServiceBadRequest creates a PatchServiceBadRequest with default headers values +func NewPatchServiceBadRequest() *PatchServiceBadRequest { + return &PatchServiceBadRequest{} +} + +/* PatchServiceBadRequest 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 PatchServiceBadRequest struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *PatchServiceBadRequest) Error() string { + return fmt.Sprintf("[PATCH /services/{id}][%d] patchServiceBadRequest %+v", 400, o.Payload) +} +func (o *PatchServiceBadRequest) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *PatchServiceBadRequest) 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 +} + +// NewPatchServiceUnauthorized creates a PatchServiceUnauthorized with default headers values +func NewPatchServiceUnauthorized() *PatchServiceUnauthorized { + return &PatchServiceUnauthorized{} +} + +/* PatchServiceUnauthorized 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 PatchServiceUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *PatchServiceUnauthorized) Error() string { + return fmt.Sprintf("[PATCH /services/{id}][%d] patchServiceUnauthorized %+v", 401, o.Payload) +} +func (o *PatchServiceUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *PatchServiceUnauthorized) 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 +} + +// NewPatchServiceNotFound creates a PatchServiceNotFound with default headers values +func NewPatchServiceNotFound() *PatchServiceNotFound { + return &PatchServiceNotFound{} +} + +/* PatchServiceNotFound describes a response with status code 404, with default header values. + +The requested resource does not exist +*/ +type PatchServiceNotFound struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *PatchServiceNotFound) Error() string { + return fmt.Sprintf("[PATCH /services/{id}][%d] patchServiceNotFound %+v", 404, o.Payload) +} +func (o *PatchServiceNotFound) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *PatchServiceNotFound) 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 +} diff --git a/rest_client/service/service_client.go b/rest_client/service/service_client.go new file mode 100644 index 000000000..20bca0c19 --- /dev/null +++ b/rest_client/service/service_client.go @@ -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 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" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new service API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for service 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 { + CreateService(params *CreateServiceParams, opts ...ClientOption) (*CreateServiceCreated, error) + + DeleteService(params *DeleteServiceParams, opts ...ClientOption) (*DeleteServiceOK, error) + + DetailService(params *DetailServiceParams, opts ...ClientOption) (*DetailServiceOK, error) + + ListServiceTerminators(params *ListServiceTerminatorsParams, opts ...ClientOption) (*ListServiceTerminatorsOK, error) + + ListServices(params *ListServicesParams, opts ...ClientOption) (*ListServicesOK, error) + + PatchService(params *PatchServiceParams, opts ...ClientOption) (*PatchServiceOK, error) + + UpdateService(params *UpdateServiceParams, opts ...ClientOption) (*UpdateServiceOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + CreateService creates a service resource + + Create a service resource. Requires admin access. +*/ +func (a *Client) CreateService(params *CreateServiceParams, opts ...ClientOption) (*CreateServiceCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewCreateServiceParams() + } + op := &runtime.ClientOperation{ + ID: "createService", + Method: "POST", + PathPattern: "/services", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &CreateServiceReader{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.(*CreateServiceCreated) + 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 createService: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + DeleteService deletes a service + + Delete a service by id. Requires admin access. +*/ +func (a *Client) DeleteService(params *DeleteServiceParams, opts ...ClientOption) (*DeleteServiceOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewDeleteServiceParams() + } + op := &runtime.ClientOperation{ + ID: "deleteService", + Method: "DELETE", + PathPattern: "/services/{id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &DeleteServiceReader{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.(*DeleteServiceOK) + 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 deleteService: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + DetailService retrieves a single service + + Retrieves a single service by id. Requires admin access. +*/ +func (a *Client) DetailService(params *DetailServiceParams, opts ...ClientOption) (*DetailServiceOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewDetailServiceParams() + } + op := &runtime.ClientOperation{ + ID: "detailService", + Method: "GET", + PathPattern: "/services/{id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &DetailServiceReader{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.(*DetailServiceOK) + 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 detailService: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ListServiceTerminators lists of terminators assigned to a service + + Retrieves a list of terminator resources that are assigned specific service; supports filtering, sorting, and pagination. + +*/ +func (a *Client) ListServiceTerminators(params *ListServiceTerminatorsParams, opts ...ClientOption) (*ListServiceTerminatorsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListServiceTerminatorsParams() + } + op := &runtime.ClientOperation{ + ID: "listServiceTerminators", + Method: "GET", + PathPattern: "/services/{id}/terminators", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &ListServiceTerminatorsReader{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.(*ListServiceTerminatorsOK) + 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 listServiceTerminators: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ListServices lists services + + Retrieves a list of service resources; supports filtering, sorting, and pagination. Requires admin access. + +*/ +func (a *Client) ListServices(params *ListServicesParams, opts ...ClientOption) (*ListServicesOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListServicesParams() + } + op := &runtime.ClientOperation{ + ID: "listServices", + Method: "GET", + PathPattern: "/services", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &ListServicesReader{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.(*ListServicesOK) + 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 listServices: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PatchService updates the supplied fields on a service + + Update the supplied fields on a service. Requires admin access. +*/ +func (a *Client) PatchService(params *PatchServiceParams, opts ...ClientOption) (*PatchServiceOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPatchServiceParams() + } + op := &runtime.ClientOperation{ + ID: "patchService", + Method: "PATCH", + PathPattern: "/services/{id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &PatchServiceReader{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.(*PatchServiceOK) + 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 patchService: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + UpdateService updates all fields on a service + + Update all fields on a service by id. Requires admin access. +*/ +func (a *Client) UpdateService(params *UpdateServiceParams, opts ...ClientOption) (*UpdateServiceOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewUpdateServiceParams() + } + op := &runtime.ClientOperation{ + ID: "updateService", + Method: "PUT", + PathPattern: "/services/{id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &UpdateServiceReader{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.(*UpdateServiceOK) + 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 updateService: 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 +} diff --git a/rest_client/service/update_service_parameters.go b/rest_client/service/update_service_parameters.go new file mode 100644 index 000000000..1e4c8ad27 --- /dev/null +++ b/rest_client/service/update_service_parameters.go @@ -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 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" +) + +// NewUpdateServiceParams creates a new UpdateServiceParams 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 NewUpdateServiceParams() *UpdateServiceParams { + return &UpdateServiceParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewUpdateServiceParamsWithTimeout creates a new UpdateServiceParams object +// with the ability to set a timeout on a request. +func NewUpdateServiceParamsWithTimeout(timeout time.Duration) *UpdateServiceParams { + return &UpdateServiceParams{ + timeout: timeout, + } +} + +// NewUpdateServiceParamsWithContext creates a new UpdateServiceParams object +// with the ability to set a context for a request. +func NewUpdateServiceParamsWithContext(ctx context.Context) *UpdateServiceParams { + return &UpdateServiceParams{ + Context: ctx, + } +} + +// NewUpdateServiceParamsWithHTTPClient creates a new UpdateServiceParams object +// with the ability to set a custom HTTPClient for a request. +func NewUpdateServiceParamsWithHTTPClient(client *http.Client) *UpdateServiceParams { + return &UpdateServiceParams{ + HTTPClient: client, + } +} + +/* UpdateServiceParams contains all the parameters to send to the API endpoint + for the update service operation. + + Typically these are written to a http.Request. +*/ +type UpdateServiceParams struct { + + /* ID. + + The id of the requested resource + */ + ID string + + /* Service. + + A service update object + */ + Service *rest_model.ServiceUpdate + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the update service params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateServiceParams) WithDefaults() *UpdateServiceParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update service params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateServiceParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the update service params +func (o *UpdateServiceParams) WithTimeout(timeout time.Duration) *UpdateServiceParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the update service params +func (o *UpdateServiceParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the update service params +func (o *UpdateServiceParams) WithContext(ctx context.Context) *UpdateServiceParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the update service params +func (o *UpdateServiceParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the update service params +func (o *UpdateServiceParams) WithHTTPClient(client *http.Client) *UpdateServiceParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the update service params +func (o *UpdateServiceParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithID adds the id to the update service params +func (o *UpdateServiceParams) WithID(id string) *UpdateServiceParams { + o.SetID(id) + return o +} + +// SetID adds the id to the update service params +func (o *UpdateServiceParams) SetID(id string) { + o.ID = id +} + +// WithService adds the service to the update service params +func (o *UpdateServiceParams) WithService(service *rest_model.ServiceUpdate) *UpdateServiceParams { + o.SetService(service) + return o +} + +// SetService adds the service to the update service params +func (o *UpdateServiceParams) SetService(service *rest_model.ServiceUpdate) { + o.Service = service +} + +// WriteToRequest writes these params to a swagger request +func (o *UpdateServiceParams) 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.Service != nil { + if err := r.SetBodyParam(o.Service); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client/service/update_service_responses.go b/rest_client/service/update_service_responses.go new file mode 100644 index 000000000..51270483a --- /dev/null +++ b/rest_client/service/update_service_responses.go @@ -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" +) + +// UpdateServiceReader is a Reader for the UpdateService structure. +type UpdateServiceReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UpdateServiceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewUpdateServiceOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewUpdateServiceBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewUpdateServiceUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewUpdateServiceNotFound() + 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()) + } +} + +// NewUpdateServiceOK creates a UpdateServiceOK with default headers values +func NewUpdateServiceOK() *UpdateServiceOK { + return &UpdateServiceOK{} +} + +/* UpdateServiceOK describes a response with status code 200, with default header values. + +The update request was successful and the resource has been altered +*/ +type UpdateServiceOK struct { + Payload *rest_model.Empty +} + +func (o *UpdateServiceOK) Error() string { + return fmt.Sprintf("[PUT /services/{id}][%d] updateServiceOK %+v", 200, o.Payload) +} +func (o *UpdateServiceOK) GetPayload() *rest_model.Empty { + return o.Payload +} + +func (o *UpdateServiceOK) 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 +} + +// NewUpdateServiceBadRequest creates a UpdateServiceBadRequest with default headers values +func NewUpdateServiceBadRequest() *UpdateServiceBadRequest { + return &UpdateServiceBadRequest{} +} + +/* UpdateServiceBadRequest 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 UpdateServiceBadRequest struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *UpdateServiceBadRequest) Error() string { + return fmt.Sprintf("[PUT /services/{id}][%d] updateServiceBadRequest %+v", 400, o.Payload) +} +func (o *UpdateServiceBadRequest) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *UpdateServiceBadRequest) 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 +} + +// NewUpdateServiceUnauthorized creates a UpdateServiceUnauthorized with default headers values +func NewUpdateServiceUnauthorized() *UpdateServiceUnauthorized { + return &UpdateServiceUnauthorized{} +} + +/* UpdateServiceUnauthorized 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 UpdateServiceUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *UpdateServiceUnauthorized) Error() string { + return fmt.Sprintf("[PUT /services/{id}][%d] updateServiceUnauthorized %+v", 401, o.Payload) +} +func (o *UpdateServiceUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *UpdateServiceUnauthorized) 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 +} + +// NewUpdateServiceNotFound creates a UpdateServiceNotFound with default headers values +func NewUpdateServiceNotFound() *UpdateServiceNotFound { + return &UpdateServiceNotFound{} +} + +/* UpdateServiceNotFound describes a response with status code 404, with default header values. + +The requested resource does not exist +*/ +type UpdateServiceNotFound struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *UpdateServiceNotFound) Error() string { + return fmt.Sprintf("[PUT /services/{id}][%d] updateServiceNotFound %+v", 404, o.Payload) +} +func (o *UpdateServiceNotFound) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *UpdateServiceNotFound) 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 +} diff --git a/rest_client/terminator/create_terminator_parameters.go b/rest_client/terminator/create_terminator_parameters.go new file mode 100644 index 000000000..211a40ede --- /dev/null +++ b/rest_client/terminator/create_terminator_parameters.go @@ -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 terminator + +// 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" +) + +// NewCreateTerminatorParams creates a new CreateTerminatorParams 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 NewCreateTerminatorParams() *CreateTerminatorParams { + return &CreateTerminatorParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewCreateTerminatorParamsWithTimeout creates a new CreateTerminatorParams object +// with the ability to set a timeout on a request. +func NewCreateTerminatorParamsWithTimeout(timeout time.Duration) *CreateTerminatorParams { + return &CreateTerminatorParams{ + timeout: timeout, + } +} + +// NewCreateTerminatorParamsWithContext creates a new CreateTerminatorParams object +// with the ability to set a context for a request. +func NewCreateTerminatorParamsWithContext(ctx context.Context) *CreateTerminatorParams { + return &CreateTerminatorParams{ + Context: ctx, + } +} + +// NewCreateTerminatorParamsWithHTTPClient creates a new CreateTerminatorParams object +// with the ability to set a custom HTTPClient for a request. +func NewCreateTerminatorParamsWithHTTPClient(client *http.Client) *CreateTerminatorParams { + return &CreateTerminatorParams{ + HTTPClient: client, + } +} + +/* CreateTerminatorParams contains all the parameters to send to the API endpoint + for the create terminator operation. + + Typically these are written to a http.Request. +*/ +type CreateTerminatorParams struct { + + /* Terminator. + + A terminator to create + */ + Terminator *rest_model.TerminatorCreate + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the create terminator params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateTerminatorParams) WithDefaults() *CreateTerminatorParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create terminator params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateTerminatorParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the create terminator params +func (o *CreateTerminatorParams) WithTimeout(timeout time.Duration) *CreateTerminatorParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the create terminator params +func (o *CreateTerminatorParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the create terminator params +func (o *CreateTerminatorParams) WithContext(ctx context.Context) *CreateTerminatorParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the create terminator params +func (o *CreateTerminatorParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the create terminator params +func (o *CreateTerminatorParams) WithHTTPClient(client *http.Client) *CreateTerminatorParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the create terminator params +func (o *CreateTerminatorParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithTerminator adds the terminator to the create terminator params +func (o *CreateTerminatorParams) WithTerminator(terminator *rest_model.TerminatorCreate) *CreateTerminatorParams { + o.SetTerminator(terminator) + return o +} + +// SetTerminator adds the terminator to the create terminator params +func (o *CreateTerminatorParams) SetTerminator(terminator *rest_model.TerminatorCreate) { + o.Terminator = terminator +} + +// WriteToRequest writes these params to a swagger request +func (o *CreateTerminatorParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Terminator != nil { + if err := r.SetBodyParam(o.Terminator); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client/terminator/create_terminator_responses.go b/rest_client/terminator/create_terminator_responses.go new file mode 100644 index 000000000..9ec724ee7 --- /dev/null +++ b/rest_client/terminator/create_terminator_responses.go @@ -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 terminator + +// 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" +) + +// CreateTerminatorReader is a Reader for the CreateTerminator structure. +type CreateTerminatorReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *CreateTerminatorReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 201: + result := NewCreateTerminatorCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewCreateTerminatorBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewCreateTerminatorUnauthorized() + 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()) + } +} + +// NewCreateTerminatorCreated creates a CreateTerminatorCreated with default headers values +func NewCreateTerminatorCreated() *CreateTerminatorCreated { + return &CreateTerminatorCreated{} +} + +/* CreateTerminatorCreated 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 CreateTerminatorCreated struct { + Payload *rest_model.CreateEnvelope +} + +func (o *CreateTerminatorCreated) Error() string { + return fmt.Sprintf("[POST /terminators][%d] createTerminatorCreated %+v", 201, o.Payload) +} +func (o *CreateTerminatorCreated) GetPayload() *rest_model.CreateEnvelope { + return o.Payload +} + +func (o *CreateTerminatorCreated) 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 +} + +// NewCreateTerminatorBadRequest creates a CreateTerminatorBadRequest with default headers values +func NewCreateTerminatorBadRequest() *CreateTerminatorBadRequest { + return &CreateTerminatorBadRequest{} +} + +/* CreateTerminatorBadRequest 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 CreateTerminatorBadRequest struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *CreateTerminatorBadRequest) Error() string { + return fmt.Sprintf("[POST /terminators][%d] createTerminatorBadRequest %+v", 400, o.Payload) +} +func (o *CreateTerminatorBadRequest) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *CreateTerminatorBadRequest) 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 +} + +// NewCreateTerminatorUnauthorized creates a CreateTerminatorUnauthorized with default headers values +func NewCreateTerminatorUnauthorized() *CreateTerminatorUnauthorized { + return &CreateTerminatorUnauthorized{} +} + +/* CreateTerminatorUnauthorized 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 CreateTerminatorUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *CreateTerminatorUnauthorized) Error() string { + return fmt.Sprintf("[POST /terminators][%d] createTerminatorUnauthorized %+v", 401, o.Payload) +} +func (o *CreateTerminatorUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *CreateTerminatorUnauthorized) 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 +} diff --git a/rest_client/terminator/delete_terminator_parameters.go b/rest_client/terminator/delete_terminator_parameters.go new file mode 100644 index 000000000..a15376627 --- /dev/null +++ b/rest_client/terminator/delete_terminator_parameters.go @@ -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 terminator + +// 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" +) + +// NewDeleteTerminatorParams creates a new DeleteTerminatorParams 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 NewDeleteTerminatorParams() *DeleteTerminatorParams { + return &DeleteTerminatorParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewDeleteTerminatorParamsWithTimeout creates a new DeleteTerminatorParams object +// with the ability to set a timeout on a request. +func NewDeleteTerminatorParamsWithTimeout(timeout time.Duration) *DeleteTerminatorParams { + return &DeleteTerminatorParams{ + timeout: timeout, + } +} + +// NewDeleteTerminatorParamsWithContext creates a new DeleteTerminatorParams object +// with the ability to set a context for a request. +func NewDeleteTerminatorParamsWithContext(ctx context.Context) *DeleteTerminatorParams { + return &DeleteTerminatorParams{ + Context: ctx, + } +} + +// NewDeleteTerminatorParamsWithHTTPClient creates a new DeleteTerminatorParams object +// with the ability to set a custom HTTPClient for a request. +func NewDeleteTerminatorParamsWithHTTPClient(client *http.Client) *DeleteTerminatorParams { + return &DeleteTerminatorParams{ + HTTPClient: client, + } +} + +/* DeleteTerminatorParams contains all the parameters to send to the API endpoint + for the delete terminator operation. + + Typically these are written to a http.Request. +*/ +type DeleteTerminatorParams 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 terminator params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteTerminatorParams) WithDefaults() *DeleteTerminatorParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete terminator params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteTerminatorParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the delete terminator params +func (o *DeleteTerminatorParams) WithTimeout(timeout time.Duration) *DeleteTerminatorParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the delete terminator params +func (o *DeleteTerminatorParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the delete terminator params +func (o *DeleteTerminatorParams) WithContext(ctx context.Context) *DeleteTerminatorParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the delete terminator params +func (o *DeleteTerminatorParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the delete terminator params +func (o *DeleteTerminatorParams) WithHTTPClient(client *http.Client) *DeleteTerminatorParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the delete terminator params +func (o *DeleteTerminatorParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithID adds the id to the delete terminator params +func (o *DeleteTerminatorParams) WithID(id string) *DeleteTerminatorParams { + o.SetID(id) + return o +} + +// SetID adds the id to the delete terminator params +func (o *DeleteTerminatorParams) SetID(id string) { + o.ID = id +} + +// WriteToRequest writes these params to a swagger request +func (o *DeleteTerminatorParams) 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 +} diff --git a/rest_client/terminator/delete_terminator_responses.go b/rest_client/terminator/delete_terminator_responses.go new file mode 100644 index 000000000..645ced220 --- /dev/null +++ b/rest_client/terminator/delete_terminator_responses.go @@ -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 terminator + +// 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" +) + +// DeleteTerminatorReader is a Reader for the DeleteTerminator structure. +type DeleteTerminatorReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *DeleteTerminatorReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewDeleteTerminatorOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewDeleteTerminatorBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewDeleteTerminatorUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewDeleteTerminatorConflict() + 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()) + } +} + +// NewDeleteTerminatorOK creates a DeleteTerminatorOK with default headers values +func NewDeleteTerminatorOK() *DeleteTerminatorOK { + return &DeleteTerminatorOK{} +} + +/* DeleteTerminatorOK describes a response with status code 200, with default header values. + +The delete request was successful and the resource has been removed +*/ +type DeleteTerminatorOK struct { + Payload *rest_model.Empty +} + +func (o *DeleteTerminatorOK) Error() string { + return fmt.Sprintf("[DELETE /terminators/{id}][%d] deleteTerminatorOK %+v", 200, o.Payload) +} +func (o *DeleteTerminatorOK) GetPayload() *rest_model.Empty { + return o.Payload +} + +func (o *DeleteTerminatorOK) 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 +} + +// NewDeleteTerminatorBadRequest creates a DeleteTerminatorBadRequest with default headers values +func NewDeleteTerminatorBadRequest() *DeleteTerminatorBadRequest { + return &DeleteTerminatorBadRequest{} +} + +/* DeleteTerminatorBadRequest 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 DeleteTerminatorBadRequest struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *DeleteTerminatorBadRequest) Error() string { + return fmt.Sprintf("[DELETE /terminators/{id}][%d] deleteTerminatorBadRequest %+v", 400, o.Payload) +} +func (o *DeleteTerminatorBadRequest) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *DeleteTerminatorBadRequest) 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 +} + +// NewDeleteTerminatorUnauthorized creates a DeleteTerminatorUnauthorized with default headers values +func NewDeleteTerminatorUnauthorized() *DeleteTerminatorUnauthorized { + return &DeleteTerminatorUnauthorized{} +} + +/* DeleteTerminatorUnauthorized 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 DeleteTerminatorUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *DeleteTerminatorUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /terminators/{id}][%d] deleteTerminatorUnauthorized %+v", 401, o.Payload) +} +func (o *DeleteTerminatorUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *DeleteTerminatorUnauthorized) 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 +} + +// NewDeleteTerminatorConflict creates a DeleteTerminatorConflict with default headers values +func NewDeleteTerminatorConflict() *DeleteTerminatorConflict { + return &DeleteTerminatorConflict{} +} + +/* DeleteTerminatorConflict 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 DeleteTerminatorConflict struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *DeleteTerminatorConflict) Error() string { + return fmt.Sprintf("[DELETE /terminators/{id}][%d] deleteTerminatorConflict %+v", 409, o.Payload) +} +func (o *DeleteTerminatorConflict) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *DeleteTerminatorConflict) 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 +} diff --git a/rest_client/terminator/detail_terminator_parameters.go b/rest_client/terminator/detail_terminator_parameters.go new file mode 100644 index 000000000..87b72e0a9 --- /dev/null +++ b/rest_client/terminator/detail_terminator_parameters.go @@ -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 terminator + +// 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" +) + +// NewDetailTerminatorParams creates a new DetailTerminatorParams 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 NewDetailTerminatorParams() *DetailTerminatorParams { + return &DetailTerminatorParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewDetailTerminatorParamsWithTimeout creates a new DetailTerminatorParams object +// with the ability to set a timeout on a request. +func NewDetailTerminatorParamsWithTimeout(timeout time.Duration) *DetailTerminatorParams { + return &DetailTerminatorParams{ + timeout: timeout, + } +} + +// NewDetailTerminatorParamsWithContext creates a new DetailTerminatorParams object +// with the ability to set a context for a request. +func NewDetailTerminatorParamsWithContext(ctx context.Context) *DetailTerminatorParams { + return &DetailTerminatorParams{ + Context: ctx, + } +} + +// NewDetailTerminatorParamsWithHTTPClient creates a new DetailTerminatorParams object +// with the ability to set a custom HTTPClient for a request. +func NewDetailTerminatorParamsWithHTTPClient(client *http.Client) *DetailTerminatorParams { + return &DetailTerminatorParams{ + HTTPClient: client, + } +} + +/* DetailTerminatorParams contains all the parameters to send to the API endpoint + for the detail terminator operation. + + Typically these are written to a http.Request. +*/ +type DetailTerminatorParams 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 terminator params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DetailTerminatorParams) WithDefaults() *DetailTerminatorParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the detail terminator params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DetailTerminatorParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the detail terminator params +func (o *DetailTerminatorParams) WithTimeout(timeout time.Duration) *DetailTerminatorParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the detail terminator params +func (o *DetailTerminatorParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the detail terminator params +func (o *DetailTerminatorParams) WithContext(ctx context.Context) *DetailTerminatorParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the detail terminator params +func (o *DetailTerminatorParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the detail terminator params +func (o *DetailTerminatorParams) WithHTTPClient(client *http.Client) *DetailTerminatorParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the detail terminator params +func (o *DetailTerminatorParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithID adds the id to the detail terminator params +func (o *DetailTerminatorParams) WithID(id string) *DetailTerminatorParams { + o.SetID(id) + return o +} + +// SetID adds the id to the detail terminator params +func (o *DetailTerminatorParams) SetID(id string) { + o.ID = id +} + +// WriteToRequest writes these params to a swagger request +func (o *DetailTerminatorParams) 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 +} diff --git a/rest_client/terminator/detail_terminator_responses.go b/rest_client/terminator/detail_terminator_responses.go new file mode 100644 index 000000000..33e58fcba --- /dev/null +++ b/rest_client/terminator/detail_terminator_responses.go @@ -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 terminator + +// 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" +) + +// DetailTerminatorReader is a Reader for the DetailTerminator structure. +type DetailTerminatorReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *DetailTerminatorReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewDetailTerminatorOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewDetailTerminatorUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewDetailTerminatorNotFound() + 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()) + } +} + +// NewDetailTerminatorOK creates a DetailTerminatorOK with default headers values +func NewDetailTerminatorOK() *DetailTerminatorOK { + return &DetailTerminatorOK{} +} + +/* DetailTerminatorOK describes a response with status code 200, with default header values. + +A single terminator +*/ +type DetailTerminatorOK struct { + Payload *rest_model.DetailTerminatorEnvelope +} + +func (o *DetailTerminatorOK) Error() string { + return fmt.Sprintf("[GET /terminators/{id}][%d] detailTerminatorOK %+v", 200, o.Payload) +} +func (o *DetailTerminatorOK) GetPayload() *rest_model.DetailTerminatorEnvelope { + return o.Payload +} + +func (o *DetailTerminatorOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(rest_model.DetailTerminatorEnvelope) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDetailTerminatorUnauthorized creates a DetailTerminatorUnauthorized with default headers values +func NewDetailTerminatorUnauthorized() *DetailTerminatorUnauthorized { + return &DetailTerminatorUnauthorized{} +} + +/* DetailTerminatorUnauthorized 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 DetailTerminatorUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *DetailTerminatorUnauthorized) Error() string { + return fmt.Sprintf("[GET /terminators/{id}][%d] detailTerminatorUnauthorized %+v", 401, o.Payload) +} +func (o *DetailTerminatorUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *DetailTerminatorUnauthorized) 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 +} + +// NewDetailTerminatorNotFound creates a DetailTerminatorNotFound with default headers values +func NewDetailTerminatorNotFound() *DetailTerminatorNotFound { + return &DetailTerminatorNotFound{} +} + +/* DetailTerminatorNotFound describes a response with status code 404, with default header values. + +The requested resource does not exist +*/ +type DetailTerminatorNotFound struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *DetailTerminatorNotFound) Error() string { + return fmt.Sprintf("[GET /terminators/{id}][%d] detailTerminatorNotFound %+v", 404, o.Payload) +} +func (o *DetailTerminatorNotFound) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *DetailTerminatorNotFound) 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 +} diff --git a/rest_client/terminator/list_terminators_parameters.go b/rest_client/terminator/list_terminators_parameters.go new file mode 100644 index 000000000..8254fcfff --- /dev/null +++ b/rest_client/terminator/list_terminators_parameters.go @@ -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 terminator + +// 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" +) + +// NewListTerminatorsParams creates a new ListTerminatorsParams 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 NewListTerminatorsParams() *ListTerminatorsParams { + return &ListTerminatorsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListTerminatorsParamsWithTimeout creates a new ListTerminatorsParams object +// with the ability to set a timeout on a request. +func NewListTerminatorsParamsWithTimeout(timeout time.Duration) *ListTerminatorsParams { + return &ListTerminatorsParams{ + timeout: timeout, + } +} + +// NewListTerminatorsParamsWithContext creates a new ListTerminatorsParams object +// with the ability to set a context for a request. +func NewListTerminatorsParamsWithContext(ctx context.Context) *ListTerminatorsParams { + return &ListTerminatorsParams{ + Context: ctx, + } +} + +// NewListTerminatorsParamsWithHTTPClient creates a new ListTerminatorsParams object +// with the ability to set a custom HTTPClient for a request. +func NewListTerminatorsParamsWithHTTPClient(client *http.Client) *ListTerminatorsParams { + return &ListTerminatorsParams{ + HTTPClient: client, + } +} + +/* ListTerminatorsParams contains all the parameters to send to the API endpoint + for the list terminators operation. + + Typically these are written to a http.Request. +*/ +type ListTerminatorsParams 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 terminators params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListTerminatorsParams) WithDefaults() *ListTerminatorsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list terminators params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListTerminatorsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the list terminators params +func (o *ListTerminatorsParams) WithTimeout(timeout time.Duration) *ListTerminatorsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list terminators params +func (o *ListTerminatorsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list terminators params +func (o *ListTerminatorsParams) WithContext(ctx context.Context) *ListTerminatorsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list terminators params +func (o *ListTerminatorsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list terminators params +func (o *ListTerminatorsParams) WithHTTPClient(client *http.Client) *ListTerminatorsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list terminators params +func (o *ListTerminatorsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithFilter adds the filter to the list terminators params +func (o *ListTerminatorsParams) WithFilter(filter *string) *ListTerminatorsParams { + o.SetFilter(filter) + return o +} + +// SetFilter adds the filter to the list terminators params +func (o *ListTerminatorsParams) SetFilter(filter *string) { + o.Filter = filter +} + +// WithLimit adds the limit to the list terminators params +func (o *ListTerminatorsParams) WithLimit(limit *int64) *ListTerminatorsParams { + o.SetLimit(limit) + return o +} + +// SetLimit adds the limit to the list terminators params +func (o *ListTerminatorsParams) SetLimit(limit *int64) { + o.Limit = limit +} + +// WithOffset adds the offset to the list terminators params +func (o *ListTerminatorsParams) WithOffset(offset *int64) *ListTerminatorsParams { + o.SetOffset(offset) + return o +} + +// SetOffset adds the offset to the list terminators params +func (o *ListTerminatorsParams) SetOffset(offset *int64) { + o.Offset = offset +} + +// WriteToRequest writes these params to a swagger request +func (o *ListTerminatorsParams) 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 +} diff --git a/rest_client/terminator/list_terminators_responses.go b/rest_client/terminator/list_terminators_responses.go new file mode 100644 index 000000000..c95fee236 --- /dev/null +++ b/rest_client/terminator/list_terminators_responses.go @@ -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 terminator + +// 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" +) + +// ListTerminatorsReader is a Reader for the ListTerminators structure. +type ListTerminatorsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListTerminatorsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListTerminatorsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewListTerminatorsBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewListTerminatorsUnauthorized() + 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()) + } +} + +// NewListTerminatorsOK creates a ListTerminatorsOK with default headers values +func NewListTerminatorsOK() *ListTerminatorsOK { + return &ListTerminatorsOK{} +} + +/* ListTerminatorsOK describes a response with status code 200, with default header values. + +A list of terminators +*/ +type ListTerminatorsOK struct { + Payload *rest_model.ListTerminatorsEnvelope +} + +func (o *ListTerminatorsOK) Error() string { + return fmt.Sprintf("[GET /terminators][%d] listTerminatorsOK %+v", 200, o.Payload) +} +func (o *ListTerminatorsOK) GetPayload() *rest_model.ListTerminatorsEnvelope { + return o.Payload +} + +func (o *ListTerminatorsOK) 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 +} + +// NewListTerminatorsBadRequest creates a ListTerminatorsBadRequest with default headers values +func NewListTerminatorsBadRequest() *ListTerminatorsBadRequest { + return &ListTerminatorsBadRequest{} +} + +/* ListTerminatorsBadRequest 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 ListTerminatorsBadRequest struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *ListTerminatorsBadRequest) Error() string { + return fmt.Sprintf("[GET /terminators][%d] listTerminatorsBadRequest %+v", 400, o.Payload) +} +func (o *ListTerminatorsBadRequest) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *ListTerminatorsBadRequest) 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 +} + +// NewListTerminatorsUnauthorized creates a ListTerminatorsUnauthorized with default headers values +func NewListTerminatorsUnauthorized() *ListTerminatorsUnauthorized { + return &ListTerminatorsUnauthorized{} +} + +/* ListTerminatorsUnauthorized 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 ListTerminatorsUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *ListTerminatorsUnauthorized) Error() string { + return fmt.Sprintf("[GET /terminators][%d] listTerminatorsUnauthorized %+v", 401, o.Payload) +} +func (o *ListTerminatorsUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *ListTerminatorsUnauthorized) 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 +} diff --git a/rest_client/terminator/patch_terminator_parameters.go b/rest_client/terminator/patch_terminator_parameters.go new file mode 100644 index 000000000..4e1a519f8 --- /dev/null +++ b/rest_client/terminator/patch_terminator_parameters.go @@ -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 terminator + +// 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" +) + +// NewPatchTerminatorParams creates a new PatchTerminatorParams 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 NewPatchTerminatorParams() *PatchTerminatorParams { + return &PatchTerminatorParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPatchTerminatorParamsWithTimeout creates a new PatchTerminatorParams object +// with the ability to set a timeout on a request. +func NewPatchTerminatorParamsWithTimeout(timeout time.Duration) *PatchTerminatorParams { + return &PatchTerminatorParams{ + timeout: timeout, + } +} + +// NewPatchTerminatorParamsWithContext creates a new PatchTerminatorParams object +// with the ability to set a context for a request. +func NewPatchTerminatorParamsWithContext(ctx context.Context) *PatchTerminatorParams { + return &PatchTerminatorParams{ + Context: ctx, + } +} + +// NewPatchTerminatorParamsWithHTTPClient creates a new PatchTerminatorParams object +// with the ability to set a custom HTTPClient for a request. +func NewPatchTerminatorParamsWithHTTPClient(client *http.Client) *PatchTerminatorParams { + return &PatchTerminatorParams{ + HTTPClient: client, + } +} + +/* PatchTerminatorParams contains all the parameters to send to the API endpoint + for the patch terminator operation. + + Typically these are written to a http.Request. +*/ +type PatchTerminatorParams struct { + + /* ID. + + The id of the requested resource + */ + ID string + + /* Terminator. + + A terminator patch object + */ + Terminator *rest_model.TerminatorPatch + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the patch terminator params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchTerminatorParams) WithDefaults() *PatchTerminatorParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the patch terminator params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchTerminatorParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the patch terminator params +func (o *PatchTerminatorParams) WithTimeout(timeout time.Duration) *PatchTerminatorParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the patch terminator params +func (o *PatchTerminatorParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the patch terminator params +func (o *PatchTerminatorParams) WithContext(ctx context.Context) *PatchTerminatorParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the patch terminator params +func (o *PatchTerminatorParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the patch terminator params +func (o *PatchTerminatorParams) WithHTTPClient(client *http.Client) *PatchTerminatorParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the patch terminator params +func (o *PatchTerminatorParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithID adds the id to the patch terminator params +func (o *PatchTerminatorParams) WithID(id string) *PatchTerminatorParams { + o.SetID(id) + return o +} + +// SetID adds the id to the patch terminator params +func (o *PatchTerminatorParams) SetID(id string) { + o.ID = id +} + +// WithTerminator adds the terminator to the patch terminator params +func (o *PatchTerminatorParams) WithTerminator(terminator *rest_model.TerminatorPatch) *PatchTerminatorParams { + o.SetTerminator(terminator) + return o +} + +// SetTerminator adds the terminator to the patch terminator params +func (o *PatchTerminatorParams) SetTerminator(terminator *rest_model.TerminatorPatch) { + o.Terminator = terminator +} + +// WriteToRequest writes these params to a swagger request +func (o *PatchTerminatorParams) 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.Terminator != nil { + if err := r.SetBodyParam(o.Terminator); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client/terminator/patch_terminator_responses.go b/rest_client/terminator/patch_terminator_responses.go new file mode 100644 index 000000000..bc2f41d96 --- /dev/null +++ b/rest_client/terminator/patch_terminator_responses.go @@ -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 terminator + +// 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" +) + +// PatchTerminatorReader is a Reader for the PatchTerminator structure. +type PatchTerminatorReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PatchTerminatorReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPatchTerminatorOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPatchTerminatorBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPatchTerminatorUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPatchTerminatorNotFound() + 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()) + } +} + +// NewPatchTerminatorOK creates a PatchTerminatorOK with default headers values +func NewPatchTerminatorOK() *PatchTerminatorOK { + return &PatchTerminatorOK{} +} + +/* PatchTerminatorOK describes a response with status code 200, with default header values. + +The patch request was successful and the resource has been altered +*/ +type PatchTerminatorOK struct { + Payload *rest_model.Empty +} + +func (o *PatchTerminatorOK) Error() string { + return fmt.Sprintf("[PATCH /terminators/{id}][%d] patchTerminatorOK %+v", 200, o.Payload) +} +func (o *PatchTerminatorOK) GetPayload() *rest_model.Empty { + return o.Payload +} + +func (o *PatchTerminatorOK) 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 +} + +// NewPatchTerminatorBadRequest creates a PatchTerminatorBadRequest with default headers values +func NewPatchTerminatorBadRequest() *PatchTerminatorBadRequest { + return &PatchTerminatorBadRequest{} +} + +/* PatchTerminatorBadRequest 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 PatchTerminatorBadRequest struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *PatchTerminatorBadRequest) Error() string { + return fmt.Sprintf("[PATCH /terminators/{id}][%d] patchTerminatorBadRequest %+v", 400, o.Payload) +} +func (o *PatchTerminatorBadRequest) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *PatchTerminatorBadRequest) 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 +} + +// NewPatchTerminatorUnauthorized creates a PatchTerminatorUnauthorized with default headers values +func NewPatchTerminatorUnauthorized() *PatchTerminatorUnauthorized { + return &PatchTerminatorUnauthorized{} +} + +/* PatchTerminatorUnauthorized 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 PatchTerminatorUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *PatchTerminatorUnauthorized) Error() string { + return fmt.Sprintf("[PATCH /terminators/{id}][%d] patchTerminatorUnauthorized %+v", 401, o.Payload) +} +func (o *PatchTerminatorUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *PatchTerminatorUnauthorized) 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 +} + +// NewPatchTerminatorNotFound creates a PatchTerminatorNotFound with default headers values +func NewPatchTerminatorNotFound() *PatchTerminatorNotFound { + return &PatchTerminatorNotFound{} +} + +/* PatchTerminatorNotFound describes a response with status code 404, with default header values. + +The requested resource does not exist +*/ +type PatchTerminatorNotFound struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *PatchTerminatorNotFound) Error() string { + return fmt.Sprintf("[PATCH /terminators/{id}][%d] patchTerminatorNotFound %+v", 404, o.Payload) +} +func (o *PatchTerminatorNotFound) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *PatchTerminatorNotFound) 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 +} diff --git a/rest_client/terminator/terminator_client.go b/rest_client/terminator/terminator_client.go new file mode 100644 index 000000000..8a53e0f71 --- /dev/null +++ b/rest_client/terminator/terminator_client.go @@ -0,0 +1,316 @@ +// 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 terminator + +// 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 terminator API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for terminator 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 { + CreateTerminator(params *CreateTerminatorParams, opts ...ClientOption) (*CreateTerminatorCreated, error) + + DeleteTerminator(params *DeleteTerminatorParams, opts ...ClientOption) (*DeleteTerminatorOK, error) + + DetailTerminator(params *DetailTerminatorParams, opts ...ClientOption) (*DetailTerminatorOK, error) + + ListTerminators(params *ListTerminatorsParams, opts ...ClientOption) (*ListTerminatorsOK, error) + + PatchTerminator(params *PatchTerminatorParams, opts ...ClientOption) (*PatchTerminatorOK, error) + + UpdateTerminator(params *UpdateTerminatorParams, opts ...ClientOption) (*UpdateTerminatorOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* + CreateTerminator creates a terminator resource + + Create a terminator resource. Requires admin access. +*/ +func (a *Client) CreateTerminator(params *CreateTerminatorParams, opts ...ClientOption) (*CreateTerminatorCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewCreateTerminatorParams() + } + op := &runtime.ClientOperation{ + ID: "createTerminator", + Method: "POST", + PathPattern: "/terminators", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &CreateTerminatorReader{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.(*CreateTerminatorCreated) + 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 createTerminator: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + DeleteTerminator deletes a terminator + + Delete a terminator by id. Requires admin access. +*/ +func (a *Client) DeleteTerminator(params *DeleteTerminatorParams, opts ...ClientOption) (*DeleteTerminatorOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewDeleteTerminatorParams() + } + op := &runtime.ClientOperation{ + ID: "deleteTerminator", + Method: "DELETE", + PathPattern: "/terminators/{id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &DeleteTerminatorReader{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.(*DeleteTerminatorOK) + 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 deleteTerminator: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + DetailTerminator retrieves a single terminator + + Retrieves a single terminator by id. Requires admin access. +*/ +func (a *Client) DetailTerminator(params *DetailTerminatorParams, opts ...ClientOption) (*DetailTerminatorOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewDetailTerminatorParams() + } + op := &runtime.ClientOperation{ + ID: "detailTerminator", + Method: "GET", + PathPattern: "/terminators/{id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &DetailTerminatorReader{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.(*DetailTerminatorOK) + 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 detailTerminator: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + ListTerminators lists terminators + + Retrieves a list of terminator resources; supports filtering, sorting, and pagination. Requires admin access. + +*/ +func (a *Client) ListTerminators(params *ListTerminatorsParams, opts ...ClientOption) (*ListTerminatorsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListTerminatorsParams() + } + op := &runtime.ClientOperation{ + ID: "listTerminators", + Method: "GET", + PathPattern: "/terminators", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &ListTerminatorsReader{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.(*ListTerminatorsOK) + 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 listTerminators: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + PatchTerminator updates the supplied fields on a terminator + + Update the supplied fields on a terminator. Requires admin access. +*/ +func (a *Client) PatchTerminator(params *PatchTerminatorParams, opts ...ClientOption) (*PatchTerminatorOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPatchTerminatorParams() + } + op := &runtime.ClientOperation{ + ID: "patchTerminator", + Method: "PATCH", + PathPattern: "/terminators/{id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &PatchTerminatorReader{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.(*PatchTerminatorOK) + 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 patchTerminator: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* + UpdateTerminator updates all fields on a terminator + + Update all fields on a terminator by id. Requires admin access. +*/ +func (a *Client) UpdateTerminator(params *UpdateTerminatorParams, opts ...ClientOption) (*UpdateTerminatorOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewUpdateTerminatorParams() + } + op := &runtime.ClientOperation{ + ID: "updateTerminator", + Method: "PUT", + PathPattern: "/terminators/{id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &UpdateTerminatorReader{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.(*UpdateTerminatorOK) + 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 updateTerminator: 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 +} diff --git a/rest_client/terminator/update_terminator_parameters.go b/rest_client/terminator/update_terminator_parameters.go new file mode 100644 index 000000000..f424aa92b --- /dev/null +++ b/rest_client/terminator/update_terminator_parameters.go @@ -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 terminator + +// 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" +) + +// NewUpdateTerminatorParams creates a new UpdateTerminatorParams 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 NewUpdateTerminatorParams() *UpdateTerminatorParams { + return &UpdateTerminatorParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewUpdateTerminatorParamsWithTimeout creates a new UpdateTerminatorParams object +// with the ability to set a timeout on a request. +func NewUpdateTerminatorParamsWithTimeout(timeout time.Duration) *UpdateTerminatorParams { + return &UpdateTerminatorParams{ + timeout: timeout, + } +} + +// NewUpdateTerminatorParamsWithContext creates a new UpdateTerminatorParams object +// with the ability to set a context for a request. +func NewUpdateTerminatorParamsWithContext(ctx context.Context) *UpdateTerminatorParams { + return &UpdateTerminatorParams{ + Context: ctx, + } +} + +// NewUpdateTerminatorParamsWithHTTPClient creates a new UpdateTerminatorParams object +// with the ability to set a custom HTTPClient for a request. +func NewUpdateTerminatorParamsWithHTTPClient(client *http.Client) *UpdateTerminatorParams { + return &UpdateTerminatorParams{ + HTTPClient: client, + } +} + +/* UpdateTerminatorParams contains all the parameters to send to the API endpoint + for the update terminator operation. + + Typically these are written to a http.Request. +*/ +type UpdateTerminatorParams struct { + + /* ID. + + The id of the requested resource + */ + ID string + + /* Terminator. + + A terminator update object + */ + Terminator *rest_model.TerminatorUpdate + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the update terminator params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateTerminatorParams) WithDefaults() *UpdateTerminatorParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update terminator params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateTerminatorParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the update terminator params +func (o *UpdateTerminatorParams) WithTimeout(timeout time.Duration) *UpdateTerminatorParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the update terminator params +func (o *UpdateTerminatorParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the update terminator params +func (o *UpdateTerminatorParams) WithContext(ctx context.Context) *UpdateTerminatorParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the update terminator params +func (o *UpdateTerminatorParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the update terminator params +func (o *UpdateTerminatorParams) WithHTTPClient(client *http.Client) *UpdateTerminatorParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the update terminator params +func (o *UpdateTerminatorParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithID adds the id to the update terminator params +func (o *UpdateTerminatorParams) WithID(id string) *UpdateTerminatorParams { + o.SetID(id) + return o +} + +// SetID adds the id to the update terminator params +func (o *UpdateTerminatorParams) SetID(id string) { + o.ID = id +} + +// WithTerminator adds the terminator to the update terminator params +func (o *UpdateTerminatorParams) WithTerminator(terminator *rest_model.TerminatorUpdate) *UpdateTerminatorParams { + o.SetTerminator(terminator) + return o +} + +// SetTerminator adds the terminator to the update terminator params +func (o *UpdateTerminatorParams) SetTerminator(terminator *rest_model.TerminatorUpdate) { + o.Terminator = terminator +} + +// WriteToRequest writes these params to a swagger request +func (o *UpdateTerminatorParams) 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.Terminator != nil { + if err := r.SetBodyParam(o.Terminator); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client/terminator/update_terminator_responses.go b/rest_client/terminator/update_terminator_responses.go new file mode 100644 index 000000000..99b836a96 --- /dev/null +++ b/rest_client/terminator/update_terminator_responses.go @@ -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 terminator + +// 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" +) + +// UpdateTerminatorReader is a Reader for the UpdateTerminator structure. +type UpdateTerminatorReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UpdateTerminatorReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewUpdateTerminatorOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewUpdateTerminatorBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewUpdateTerminatorUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewUpdateTerminatorNotFound() + 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()) + } +} + +// NewUpdateTerminatorOK creates a UpdateTerminatorOK with default headers values +func NewUpdateTerminatorOK() *UpdateTerminatorOK { + return &UpdateTerminatorOK{} +} + +/* UpdateTerminatorOK describes a response with status code 200, with default header values. + +The update request was successful and the resource has been altered +*/ +type UpdateTerminatorOK struct { + Payload *rest_model.Empty +} + +func (o *UpdateTerminatorOK) Error() string { + return fmt.Sprintf("[PUT /terminators/{id}][%d] updateTerminatorOK %+v", 200, o.Payload) +} +func (o *UpdateTerminatorOK) GetPayload() *rest_model.Empty { + return o.Payload +} + +func (o *UpdateTerminatorOK) 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 +} + +// NewUpdateTerminatorBadRequest creates a UpdateTerminatorBadRequest with default headers values +func NewUpdateTerminatorBadRequest() *UpdateTerminatorBadRequest { + return &UpdateTerminatorBadRequest{} +} + +/* UpdateTerminatorBadRequest 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 UpdateTerminatorBadRequest struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *UpdateTerminatorBadRequest) Error() string { + return fmt.Sprintf("[PUT /terminators/{id}][%d] updateTerminatorBadRequest %+v", 400, o.Payload) +} +func (o *UpdateTerminatorBadRequest) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *UpdateTerminatorBadRequest) 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 +} + +// NewUpdateTerminatorUnauthorized creates a UpdateTerminatorUnauthorized with default headers values +func NewUpdateTerminatorUnauthorized() *UpdateTerminatorUnauthorized { + return &UpdateTerminatorUnauthorized{} +} + +/* UpdateTerminatorUnauthorized 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 UpdateTerminatorUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *UpdateTerminatorUnauthorized) Error() string { + return fmt.Sprintf("[PUT /terminators/{id}][%d] updateTerminatorUnauthorized %+v", 401, o.Payload) +} +func (o *UpdateTerminatorUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *UpdateTerminatorUnauthorized) 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 +} + +// NewUpdateTerminatorNotFound creates a UpdateTerminatorNotFound with default headers values +func NewUpdateTerminatorNotFound() *UpdateTerminatorNotFound { + return &UpdateTerminatorNotFound{} +} + +/* UpdateTerminatorNotFound describes a response with status code 404, with default header values. + +The requested resource does not exist +*/ +type UpdateTerminatorNotFound struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *UpdateTerminatorNotFound) Error() string { + return fmt.Sprintf("[PUT /terminators/{id}][%d] updateTerminatorNotFound %+v", 404, o.Payload) +} +func (o *UpdateTerminatorNotFound) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *UpdateTerminatorNotFound) 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 +} diff --git a/rest_client/ziti_fabric_client.go b/rest_client/ziti_fabric_client.go new file mode 100644 index 000000000..e5428885a --- /dev/null +++ b/rest_client/ziti_fabric_client.go @@ -0,0 +1,146 @@ +// 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 rest_client + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/openziti/fabric/rest_client/router" + "github.com/openziti/fabric/rest_client/service" + "github.com/openziti/fabric/rest_client/terminator" +) + +// Default ziti fabric HTTP client. +var Default = NewHTTPClient(nil) + +const ( + // DefaultHost is the default Host + // found in Meta (info) section of spec file + DefaultHost string = "demo.ziti.dev" + // DefaultBasePath is the default BasePath + // found in Meta (info) section of spec file + DefaultBasePath string = "/fabric/v1" +) + +// DefaultSchemes are the default schemes found in Meta (info) section of spec file +var DefaultSchemes = []string{"https"} + +// NewHTTPClient creates a new ziti fabric HTTP client. +func NewHTTPClient(formats strfmt.Registry) *ZitiFabric { + return NewHTTPClientWithConfig(formats, nil) +} + +// NewHTTPClientWithConfig creates a new ziti fabric HTTP client, +// using a customizable transport config. +func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *ZitiFabric { + // ensure nullable parameters have default + if cfg == nil { + cfg = DefaultTransportConfig() + } + + // create transport and client + transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) + return New(transport, formats) +} + +// New creates a new ziti fabric client +func New(transport runtime.ClientTransport, formats strfmt.Registry) *ZitiFabric { + // ensure nullable parameters have default + if formats == nil { + formats = strfmt.Default + } + + cli := new(ZitiFabric) + cli.Transport = transport + cli.Router = router.New(transport, formats) + cli.Service = service.New(transport, formats) + cli.Terminator = terminator.New(transport, formats) + return cli +} + +// DefaultTransportConfig creates a TransportConfig with the +// default settings taken from the meta section of the spec file. +func DefaultTransportConfig() *TransportConfig { + return &TransportConfig{ + Host: DefaultHost, + BasePath: DefaultBasePath, + Schemes: DefaultSchemes, + } +} + +// TransportConfig contains the transport related info, +// found in the meta section of the spec file. +type TransportConfig struct { + Host string + BasePath string + Schemes []string +} + +// WithHost overrides the default host, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithHost(host string) *TransportConfig { + cfg.Host = host + return cfg +} + +// WithBasePath overrides the default basePath, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { + cfg.BasePath = basePath + return cfg +} + +// WithSchemes overrides the default schemes, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { + cfg.Schemes = schemes + return cfg +} + +// ZitiFabric is a client for ziti fabric +type ZitiFabric struct { + Router router.ClientService + + Service service.ClientService + + Terminator terminator.ClientService + + Transport runtime.ClientTransport +} + +// SetTransport changes the transport on the client and all its subresources +func (c *ZitiFabric) SetTransport(transport runtime.ClientTransport) { + c.Transport = transport + c.Router.SetTransport(transport) + c.Service.SetTransport(transport) + c.Terminator.SetTransport(transport) +} diff --git a/rest_model/api_error.go b/rest_model/api_error.go new file mode 100644 index 000000000..22dfd48e5 --- /dev/null +++ b/rest_model/api_error.go @@ -0,0 +1,189 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// APIError api error +// +// swagger:model apiError +type APIError struct { + + // args + Args *APIErrorArgs `json:"args,omitempty"` + + // cause + Cause *APIErrorCause `json:"cause,omitempty"` + + // cause message + CauseMessage string `json:"causeMessage,omitempty"` + + // code + Code string `json:"code,omitempty"` + + // data + Data interface{} `json:"data,omitempty"` + + // message + Message string `json:"message,omitempty"` + + // request Id + RequestID string `json:"requestId,omitempty"` +} + +// Validate validates this api error +func (m *APIError) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateArgs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCause(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *APIError) validateArgs(formats strfmt.Registry) error { + if swag.IsZero(m.Args) { // not required + return nil + } + + if m.Args != nil { + if err := m.Args.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("args") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("args") + } + return err + } + } + + return nil +} + +func (m *APIError) validateCause(formats strfmt.Registry) error { + if swag.IsZero(m.Cause) { // not required + return nil + } + + if m.Cause != nil { + if err := m.Cause.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cause") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cause") + } + return err + } + } + + return nil +} + +// ContextValidate validate this api error based on the context it is used +func (m *APIError) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateArgs(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateCause(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *APIError) contextValidateArgs(ctx context.Context, formats strfmt.Registry) error { + + if m.Args != nil { + if err := m.Args.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("args") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("args") + } + return err + } + } + + return nil +} + +func (m *APIError) contextValidateCause(ctx context.Context, formats strfmt.Registry) error { + + if m.Cause != nil { + if err := m.Cause.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cause") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cause") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *APIError) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIError) UnmarshalBinary(b []byte) error { + var res APIError + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/api_error_args.go b/rest_model/api_error_args.go new file mode 100644 index 000000000..0fa1a2e98 --- /dev/null +++ b/rest_model/api_error_args.go @@ -0,0 +1,74 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// APIErrorArgs api error args +// +// swagger:model apiErrorArgs +type APIErrorArgs struct { + + // url vars + URLVars map[string]string `json:"urlVars,omitempty"` +} + +// Validate validates this api error args +func (m *APIErrorArgs) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this api error args based on context it is used +func (m *APIErrorArgs) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *APIErrorArgs) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIErrorArgs) UnmarshalBinary(b []byte) error { + var res APIErrorArgs + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/api_error_cause.go b/rest_model/api_error_cause.go new file mode 100644 index 000000000..37ed6a17e --- /dev/null +++ b/rest_model/api_error_cause.go @@ -0,0 +1,140 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// APIErrorCause api error cause +// +// swagger:model apiErrorCause +type APIErrorCause struct { + APIFieldError + + APIError +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *APIErrorCause) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 APIFieldError + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.APIFieldError = aO0 + + // AO1 + var aO1 APIError + if err := swag.ReadJSON(raw, &aO1); err != nil { + return err + } + m.APIError = aO1 + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m APIErrorCause) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 2) + + aO0, err := swag.WriteJSON(m.APIFieldError) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + + aO1, err := swag.WriteJSON(m.APIError) + if err != nil { + return nil, err + } + _parts = append(_parts, aO1) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this api error cause +func (m *APIErrorCause) Validate(formats strfmt.Registry) error { + var res []error + + // validation for a type composition with APIFieldError + if err := m.APIFieldError.Validate(formats); err != nil { + res = append(res, err) + } + // validation for a type composition with APIError + if err := m.APIError.Validate(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this api error cause based on the context it is used +func (m *APIErrorCause) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + // validation for a type composition with APIFieldError + if err := m.APIFieldError.ContextValidate(ctx, formats); err != nil { + res = append(res, err) + } + // validation for a type composition with APIError + if err := m.APIError.ContextValidate(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// MarshalBinary interface implementation +func (m *APIErrorCause) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIErrorCause) UnmarshalBinary(b []byte) error { + var res APIErrorCause + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/api_error_envelope.go b/rest_model/api_error_envelope.go new file mode 100644 index 000000000..da59358ca --- /dev/null +++ b/rest_model/api_error_envelope.go @@ -0,0 +1,179 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// APIErrorEnvelope api error envelope +// +// swagger:model apiErrorEnvelope +type APIErrorEnvelope struct { + + // error + // Required: true + Error *APIError `json:"error"` + + // meta + // Required: true + Meta *Meta `json:"meta"` +} + +// Validate validates this api error envelope +func (m *APIErrorEnvelope) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateError(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *APIErrorEnvelope) validateError(formats strfmt.Registry) error { + + if err := validate.Required("error", "body", m.Error); err != nil { + return err + } + + if m.Error != nil { + if err := m.Error.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("error") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("error") + } + return err + } + } + + return nil +} + +func (m *APIErrorEnvelope) validateMeta(formats strfmt.Registry) error { + + if err := validate.Required("meta", "body", m.Meta); err != nil { + return err + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this api error envelope based on the context it is used +func (m *APIErrorEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateError(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *APIErrorEnvelope) contextValidateError(ctx context.Context, formats strfmt.Registry) error { + + if m.Error != nil { + if err := m.Error.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("error") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("error") + } + return err + } + } + + return nil +} + +func (m *APIErrorEnvelope) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *APIErrorEnvelope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIErrorEnvelope) UnmarshalBinary(b []byte) error { + var res APIErrorEnvelope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/api_field_error.go b/rest_model/api_field_error.go new file mode 100644 index 000000000..aeeedf5c0 --- /dev/null +++ b/rest_model/api_field_error.go @@ -0,0 +1,80 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// APIFieldError api field error +// +// swagger:model apiFieldError +type APIFieldError struct { + + // field + Field string `json:"field,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // value + Value string `json:"value,omitempty"` +} + +// Validate validates this api field error +func (m *APIFieldError) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this api field error based on context it is used +func (m *APIFieldError) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *APIFieldError) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIFieldError) UnmarshalBinary(b []byte) error { + var res APIFieldError + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/base_entity.go b/rest_model/base_entity.go new file mode 100644 index 000000000..a92383f41 --- /dev/null +++ b/rest_model/base_entity.go @@ -0,0 +1,238 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// BaseEntity Fields shared by all Edge API entities +// +// swagger:model baseEntity +type BaseEntity struct { + + // links + // Required: true + Links Links `json:"_links"` + + // created at + // Required: true + // Format: date-time + CreatedAt *strfmt.DateTime `json:"createdAt"` + + // id + // Required: true + ID *string `json:"id"` + + // tags + // Required: true + Tags *Tags `json:"tags"` + + // updated at + // Required: true + // Format: date-time + UpdatedAt *strfmt.DateTime `json:"updatedAt"` +} + +// Validate validates this base entity +func (m *BaseEntity) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateLinks(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCreatedAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTags(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdatedAt(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BaseEntity) validateLinks(formats strfmt.Registry) error { + + if err := validate.Required("_links", "body", m.Links); err != nil { + return err + } + + if m.Links != nil { + if err := m.Links.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("_links") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("_links") + } + return err + } + } + + return nil +} + +func (m *BaseEntity) validateCreatedAt(formats strfmt.Registry) error { + + if err := validate.Required("createdAt", "body", m.CreatedAt); err != nil { + return err + } + + if err := validate.FormatOf("createdAt", "body", "date-time", m.CreatedAt.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *BaseEntity) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *BaseEntity) validateTags(formats strfmt.Registry) error { + + if err := validate.Required("tags", "body", m.Tags); err != nil { + return err + } + + if m.Tags != nil { + if err := m.Tags.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +func (m *BaseEntity) validateUpdatedAt(formats strfmt.Registry) error { + + if err := validate.Required("updatedAt", "body", m.UpdatedAt); err != nil { + return err + } + + if err := validate.FormatOf("updatedAt", "body", "date-time", m.UpdatedAt.String(), formats); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this base entity based on the context it is used +func (m *BaseEntity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateLinks(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTags(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BaseEntity) contextValidateLinks(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Links.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("_links") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("_links") + } + return err + } + + return nil +} + +func (m *BaseEntity) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { + + if m.Tags != nil { + if err := m.Tags.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BaseEntity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BaseEntity) UnmarshalBinary(b []byte) error { + var res BaseEntity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/create_envelope.go b/rest_model/create_envelope.go new file mode 100644 index 000000000..0a8263b7e --- /dev/null +++ b/rest_model/create_envelope.go @@ -0,0 +1,174 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CreateEnvelope create envelope +// +// swagger:model createEnvelope +type CreateEnvelope struct { + + // data + Data *CreateLocation `json:"data,omitempty"` + + // meta + Meta *Meta `json:"meta,omitempty"` +} + +// Validate validates this create envelope +func (m *CreateEnvelope) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CreateEnvelope) validateData(formats strfmt.Registry) error { + if swag.IsZero(m.Data) { // not required + return nil + } + + if m.Data != nil { + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *CreateEnvelope) validateMeta(formats strfmt.Registry) error { + if swag.IsZero(m.Meta) { // not required + return nil + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create envelope based on the context it is used +func (m *CreateEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CreateEnvelope) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if m.Data != nil { + if err := m.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *CreateEnvelope) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CreateEnvelope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CreateEnvelope) UnmarshalBinary(b []byte) error { + var res CreateEnvelope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/create_location.go b/rest_model/create_location.go new file mode 100644 index 000000000..e4a12db01 --- /dev/null +++ b/rest_model/create_location.go @@ -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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CreateLocation create location +// +// swagger:model createLocation +type CreateLocation struct { + + // links + Links Links `json:"_links"` + + // id + ID string `json:"id,omitempty"` +} + +// Validate validates this create location +func (m *CreateLocation) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateLinks(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CreateLocation) validateLinks(formats strfmt.Registry) error { + if swag.IsZero(m.Links) { // not required + return nil + } + + if m.Links != nil { + if err := m.Links.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("_links") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("_links") + } + return err + } + } + + return nil +} + +// ContextValidate validate this create location based on the context it is used +func (m *CreateLocation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateLinks(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CreateLocation) contextValidateLinks(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Links.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("_links") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("_links") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CreateLocation) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CreateLocation) UnmarshalBinary(b []byte) error { + var res CreateLocation + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/detail_router_envelope.go b/rest_model/detail_router_envelope.go new file mode 100644 index 000000000..169d3339d --- /dev/null +++ b/rest_model/detail_router_envelope.go @@ -0,0 +1,179 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// DetailRouterEnvelope detail router envelope +// +// swagger:model detailRouterEnvelope +type DetailRouterEnvelope struct { + + // data + // Required: true + Data *RouterDetail `json:"data"` + + // meta + // Required: true + Meta *Meta `json:"meta"` +} + +// Validate validates this detail router envelope +func (m *DetailRouterEnvelope) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DetailRouterEnvelope) validateData(formats strfmt.Registry) error { + + if err := validate.Required("data", "body", m.Data); err != nil { + return err + } + + if m.Data != nil { + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *DetailRouterEnvelope) validateMeta(formats strfmt.Registry) error { + + if err := validate.Required("meta", "body", m.Meta); err != nil { + return err + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this detail router envelope based on the context it is used +func (m *DetailRouterEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DetailRouterEnvelope) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if m.Data != nil { + if err := m.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *DetailRouterEnvelope) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *DetailRouterEnvelope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DetailRouterEnvelope) UnmarshalBinary(b []byte) error { + var res DetailRouterEnvelope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/detail_service_envelope.go b/rest_model/detail_service_envelope.go new file mode 100644 index 000000000..f24da21ed --- /dev/null +++ b/rest_model/detail_service_envelope.go @@ -0,0 +1,179 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// DetailServiceEnvelope detail service envelope +// +// swagger:model detailServiceEnvelope +type DetailServiceEnvelope struct { + + // data + // Required: true + Data *ServiceDetail `json:"data"` + + // meta + // Required: true + Meta *Meta `json:"meta"` +} + +// Validate validates this detail service envelope +func (m *DetailServiceEnvelope) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DetailServiceEnvelope) validateData(formats strfmt.Registry) error { + + if err := validate.Required("data", "body", m.Data); err != nil { + return err + } + + if m.Data != nil { + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *DetailServiceEnvelope) validateMeta(formats strfmt.Registry) error { + + if err := validate.Required("meta", "body", m.Meta); err != nil { + return err + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this detail service envelope based on the context it is used +func (m *DetailServiceEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DetailServiceEnvelope) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if m.Data != nil { + if err := m.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *DetailServiceEnvelope) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *DetailServiceEnvelope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DetailServiceEnvelope) UnmarshalBinary(b []byte) error { + var res DetailServiceEnvelope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/detail_terminator_envelope.go b/rest_model/detail_terminator_envelope.go new file mode 100644 index 000000000..f027b785c --- /dev/null +++ b/rest_model/detail_terminator_envelope.go @@ -0,0 +1,179 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// DetailTerminatorEnvelope detail terminator envelope +// +// swagger:model detailTerminatorEnvelope +type DetailTerminatorEnvelope struct { + + // data + // Required: true + Data *TerminatorDetail `json:"data"` + + // meta + // Required: true + Meta *Meta `json:"meta"` +} + +// Validate validates this detail terminator envelope +func (m *DetailTerminatorEnvelope) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DetailTerminatorEnvelope) validateData(formats strfmt.Registry) error { + + if err := validate.Required("data", "body", m.Data); err != nil { + return err + } + + if m.Data != nil { + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *DetailTerminatorEnvelope) validateMeta(formats strfmt.Registry) error { + + if err := validate.Required("meta", "body", m.Meta); err != nil { + return err + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this detail terminator envelope based on the context it is used +func (m *DetailTerminatorEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DetailTerminatorEnvelope) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if m.Data != nil { + if err := m.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *DetailTerminatorEnvelope) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *DetailTerminatorEnvelope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DetailTerminatorEnvelope) UnmarshalBinary(b []byte) error { + var res DetailTerminatorEnvelope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/empty.go b/rest_model/empty.go new file mode 100644 index 000000000..7bd63ef35 --- /dev/null +++ b/rest_model/empty.go @@ -0,0 +1,149 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Empty empty +// +// swagger:model empty +type Empty struct { + + // data + // Example: {} + // Required: true + Data interface{} `json:"data"` + + // meta + // Required: true + Meta *Meta `json:"meta"` +} + +// Validate validates this empty +func (m *Empty) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Empty) validateData(formats strfmt.Registry) error { + + if m.Data == nil { + return errors.Required("data", "body", nil) + } + + return nil +} + +func (m *Empty) validateMeta(formats strfmt.Registry) error { + + if err := validate.Required("meta", "body", m.Meta); err != nil { + return err + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this empty based on the context it is used +func (m *Empty) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Empty) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Empty) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Empty) UnmarshalBinary(b []byte) error { + var res Empty + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/entity_ref.go b/rest_model/entity_ref.go new file mode 100644 index 000000000..2535ead09 --- /dev/null +++ b/rest_model/entity_ref.go @@ -0,0 +1,135 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// EntityRef A reference to another resource and links to interact with it +// +// swagger:model entityRef +type EntityRef struct { + + // links + Links Links `json:"_links"` + + // entity + Entity string `json:"entity,omitempty"` + + // id + ID string `json:"id,omitempty"` + + // name + Name string `json:"name,omitempty"` +} + +// Validate validates this entity ref +func (m *EntityRef) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateLinks(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *EntityRef) validateLinks(formats strfmt.Registry) error { + if swag.IsZero(m.Links) { // not required + return nil + } + + if m.Links != nil { + if err := m.Links.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("_links") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("_links") + } + return err + } + } + + return nil +} + +// ContextValidate validate this entity ref based on the context it is used +func (m *EntityRef) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateLinks(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *EntityRef) contextValidateLinks(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Links.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("_links") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("_links") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *EntityRef) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *EntityRef) UnmarshalBinary(b []byte) error { + var res EntityRef + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/link.go b/rest_model/link.go new file mode 100644 index 000000000..582ad60a1 --- /dev/null +++ b/rest_model/link.go @@ -0,0 +1,106 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Link A link to another resource +// +// swagger:model link +type Link struct { + + // comment + Comment string `json:"comment,omitempty"` + + // href + // Required: true + // Format: uri + Href *strfmt.URI `json:"href"` + + // method + Method string `json:"method,omitempty"` +} + +// Validate validates this link +func (m *Link) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHref(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Link) validateHref(formats strfmt.Registry) error { + + if err := validate.Required("href", "body", m.Href); err != nil { + return err + } + + if err := validate.FormatOf("href", "body", "uri", m.Href.String(), formats); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this link based on context it is used +func (m *Link) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Link) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Link) UnmarshalBinary(b []byte) error { + var res Link + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/links.go b/rest_model/links.go new file mode 100644 index 000000000..84a6d2251 --- /dev/null +++ b/rest_model/links.go @@ -0,0 +1,86 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// Links A map of named links +// +// swagger:model links +type Links map[string]Link + +// Validate validates this links +func (m Links) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := validate.Required(k, "body", m[k]); err != nil { + return err + } + if val, ok := m[k]; ok { + if err := val.Validate(formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this links based on the context it is used +func (m Links) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for k := range m { + + if val, ok := m[k]; ok { + if err := val.ContextValidate(ctx, formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_model/list_routers_envelope.go b/rest_model/list_routers_envelope.go new file mode 100644 index 000000000..dce030bef --- /dev/null +++ b/rest_model/list_routers_envelope.go @@ -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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ListRoutersEnvelope list routers envelope +// +// swagger:model listRoutersEnvelope +type ListRoutersEnvelope struct { + + // data + // Required: true + Data RouterList `json:"data"` + + // meta + // Required: true + Meta *Meta `json:"meta"` +} + +// Validate validates this list routers envelope +func (m *ListRoutersEnvelope) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ListRoutersEnvelope) validateData(formats strfmt.Registry) error { + + if err := validate.Required("data", "body", m.Data); err != nil { + return err + } + + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + + return nil +} + +func (m *ListRoutersEnvelope) validateMeta(formats strfmt.Registry) error { + + if err := validate.Required("meta", "body", m.Meta); err != nil { + return err + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this list routers envelope based on the context it is used +func (m *ListRoutersEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ListRoutersEnvelope) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + + return nil +} + +func (m *ListRoutersEnvelope) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ListRoutersEnvelope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ListRoutersEnvelope) UnmarshalBinary(b []byte) error { + var res ListRoutersEnvelope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/list_services_envelope.go b/rest_model/list_services_envelope.go new file mode 100644 index 000000000..73945b63d --- /dev/null +++ b/rest_model/list_services_envelope.go @@ -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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ListServicesEnvelope list services envelope +// +// swagger:model listServicesEnvelope +type ListServicesEnvelope struct { + + // data + // Required: true + Data ServiceList `json:"data"` + + // meta + // Required: true + Meta *Meta `json:"meta"` +} + +// Validate validates this list services envelope +func (m *ListServicesEnvelope) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ListServicesEnvelope) validateData(formats strfmt.Registry) error { + + if err := validate.Required("data", "body", m.Data); err != nil { + return err + } + + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + + return nil +} + +func (m *ListServicesEnvelope) validateMeta(formats strfmt.Registry) error { + + if err := validate.Required("meta", "body", m.Meta); err != nil { + return err + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this list services envelope based on the context it is used +func (m *ListServicesEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ListServicesEnvelope) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + + return nil +} + +func (m *ListServicesEnvelope) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ListServicesEnvelope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ListServicesEnvelope) UnmarshalBinary(b []byte) error { + var res ListServicesEnvelope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/list_terminators_envelope.go b/rest_model/list_terminators_envelope.go new file mode 100644 index 000000000..27a1cdc4c --- /dev/null +++ b/rest_model/list_terminators_envelope.go @@ -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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ListTerminatorsEnvelope list terminators envelope +// +// swagger:model listTerminatorsEnvelope +type ListTerminatorsEnvelope struct { + + // data + // Required: true + Data TerminatorList `json:"data"` + + // meta + // Required: true + Meta *Meta `json:"meta"` +} + +// Validate validates this list terminators envelope +func (m *ListTerminatorsEnvelope) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ListTerminatorsEnvelope) validateData(formats strfmt.Registry) error { + + if err := validate.Required("data", "body", m.Data); err != nil { + return err + } + + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + + return nil +} + +func (m *ListTerminatorsEnvelope) validateMeta(formats strfmt.Registry) error { + + if err := validate.Required("meta", "body", m.Meta); err != nil { + return err + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this list terminators envelope based on the context it is used +func (m *ListTerminatorsEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ListTerminatorsEnvelope) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + + return nil +} + +func (m *ListTerminatorsEnvelope) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ListTerminatorsEnvelope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ListTerminatorsEnvelope) UnmarshalBinary(b []byte) error { + var res ListTerminatorsEnvelope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/meta.go b/rest_model/meta.go new file mode 100644 index 000000000..1cb9b9223 --- /dev/null +++ b/rest_model/meta.go @@ -0,0 +1,137 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Meta meta +// +// swagger:model meta +type Meta struct { + + // api enrollment version + APIEnrollmentVersion string `json:"apiEnrollmentVersion,omitempty"` + + // api version + APIVersion string `json:"apiVersion,omitempty"` + + // filterable fields + FilterableFields []string `json:"filterableFields,omitempty"` + + // pagination + Pagination *Pagination `json:"pagination,omitempty"` +} + +// Validate validates this meta +func (m *Meta) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePagination(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Meta) validatePagination(formats strfmt.Registry) error { + if swag.IsZero(m.Pagination) { // not required + return nil + } + + if m.Pagination != nil { + if err := m.Pagination.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pagination") + } + return err + } + } + + return nil +} + +// ContextValidate validate this meta based on the context it is used +func (m *Meta) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePagination(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Meta) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error { + + if m.Pagination != nil { + if err := m.Pagination.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pagination") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pagination") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Meta) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Meta) UnmarshalBinary(b []byte) error { + var res Meta + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/pagination.go b/rest_model/pagination.go new file mode 100644 index 000000000..3941fd45b --- /dev/null +++ b/rest_model/pagination.go @@ -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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Pagination pagination +// +// swagger:model pagination +type Pagination struct { + + // limit + // Required: true + Limit *int64 `json:"limit"` + + // offset + // Required: true + Offset *int64 `json:"offset"` + + // total count + // Required: true + TotalCount *int64 `json:"totalCount"` +} + +// Validate validates this pagination +func (m *Pagination) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateLimit(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOffset(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTotalCount(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Pagination) validateLimit(formats strfmt.Registry) error { + + if err := validate.Required("limit", "body", m.Limit); err != nil { + return err + } + + return nil +} + +func (m *Pagination) validateOffset(formats strfmt.Registry) error { + + if err := validate.Required("offset", "body", m.Offset); err != nil { + return err + } + + return nil +} + +func (m *Pagination) validateTotalCount(formats strfmt.Registry) error { + + if err := validate.Required("totalCount", "body", m.TotalCount); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this pagination based on context it is used +func (m *Pagination) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Pagination) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Pagination) UnmarshalBinary(b []byte) error { + var res Pagination + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/router_create.go b/rest_model/router_create.go new file mode 100644 index 000000000..81ac82564 --- /dev/null +++ b/rest_model/router_create.go @@ -0,0 +1,166 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// RouterCreate router create +// +// swagger:model routerCreate +type RouterCreate struct { + + // fingerprint + Fingerprint *string `json:"fingerprint,omitempty"` + + // id + // Required: true + ID *string `json:"id"` + + // name + // Required: true + Name *string `json:"name"` + + // tags + Tags *Tags `json:"tags,omitempty"` +} + +// Validate validates this router create +func (m *RouterCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTags(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RouterCreate) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *RouterCreate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *RouterCreate) validateTags(formats strfmt.Registry) error { + if swag.IsZero(m.Tags) { // not required + return nil + } + + if m.Tags != nil { + if err := m.Tags.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// ContextValidate validate this router create based on the context it is used +func (m *RouterCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateTags(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RouterCreate) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { + + if m.Tags != nil { + if err := m.Tags.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RouterCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RouterCreate) UnmarshalBinary(b []byte) error { + var res RouterCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/router_detail.go b/rest_model/router_detail.go new file mode 100644 index 000000000..8c87936cc --- /dev/null +++ b/rest_model/router_detail.go @@ -0,0 +1,272 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// RouterDetail router detail +// +// swagger:model routerDetail +type RouterDetail struct { + BaseEntity + + // connected + // Required: true + Connected *bool `json:"connected"` + + // fingerprint + // Required: true + Fingerprint *string `json:"fingerprint"` + + // listener address + ListenerAddress string `json:"listenerAddress,omitempty"` + + // name + // Required: true + Name *string `json:"name"` + + // version info + VersionInfo *VersionInfo `json:"versionInfo,omitempty"` +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *RouterDetail) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 BaseEntity + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.BaseEntity = aO0 + + // AO1 + var dataAO1 struct { + Connected *bool `json:"connected"` + + Fingerprint *string `json:"fingerprint"` + + ListenerAddress string `json:"listenerAddress,omitempty"` + + Name *string `json:"name"` + + VersionInfo *VersionInfo `json:"versionInfo,omitempty"` + } + if err := swag.ReadJSON(raw, &dataAO1); err != nil { + return err + } + + m.Connected = dataAO1.Connected + + m.Fingerprint = dataAO1.Fingerprint + + m.ListenerAddress = dataAO1.ListenerAddress + + m.Name = dataAO1.Name + + m.VersionInfo = dataAO1.VersionInfo + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m RouterDetail) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 2) + + aO0, err := swag.WriteJSON(m.BaseEntity) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + var dataAO1 struct { + Connected *bool `json:"connected"` + + Fingerprint *string `json:"fingerprint"` + + ListenerAddress string `json:"listenerAddress,omitempty"` + + Name *string `json:"name"` + + VersionInfo *VersionInfo `json:"versionInfo,omitempty"` + } + + dataAO1.Connected = m.Connected + + dataAO1.Fingerprint = m.Fingerprint + + dataAO1.ListenerAddress = m.ListenerAddress + + dataAO1.Name = m.Name + + dataAO1.VersionInfo = m.VersionInfo + + jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1) + if errAO1 != nil { + return nil, errAO1 + } + _parts = append(_parts, jsonDataAO1) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this router detail +func (m *RouterDetail) Validate(formats strfmt.Registry) error { + var res []error + + // validation for a type composition with BaseEntity + if err := m.BaseEntity.Validate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateConnected(formats); err != nil { + res = append(res, err) + } + + if err := m.validateFingerprint(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVersionInfo(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RouterDetail) validateConnected(formats strfmt.Registry) error { + + if err := validate.Required("connected", "body", m.Connected); err != nil { + return err + } + + return nil +} + +func (m *RouterDetail) validateFingerprint(formats strfmt.Registry) error { + + if err := validate.Required("fingerprint", "body", m.Fingerprint); err != nil { + return err + } + + return nil +} + +func (m *RouterDetail) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *RouterDetail) validateVersionInfo(formats strfmt.Registry) error { + + if swag.IsZero(m.VersionInfo) { // not required + return nil + } + + if m.VersionInfo != nil { + if err := m.VersionInfo.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("versionInfo") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("versionInfo") + } + return err + } + } + + return nil +} + +// ContextValidate validate this router detail based on the context it is used +func (m *RouterDetail) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + // validation for a type composition with BaseEntity + if err := m.BaseEntity.ContextValidate(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVersionInfo(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RouterDetail) contextValidateVersionInfo(ctx context.Context, formats strfmt.Registry) error { + + if m.VersionInfo != nil { + if err := m.VersionInfo.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("versionInfo") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("versionInfo") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RouterDetail) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RouterDetail) UnmarshalBinary(b []byte) error { + var res RouterDetail + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/router_list.go b/rest_model/router_list.go new file mode 100644 index 000000000..deaee3f1f --- /dev/null +++ b/rest_model/router_list.go @@ -0,0 +1,97 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RouterList router list +// +// swagger:model routerList +type RouterList []*RouterDetail + +// Validate validates this router list +func (m RouterList) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this router list based on the context it is used +func (m RouterList) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + if m[i] != nil { + if err := m[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_model/router_patch.go b/rest_model/router_patch.go new file mode 100644 index 000000000..43f0a205d --- /dev/null +++ b/rest_model/router_patch.go @@ -0,0 +1,134 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RouterPatch router patch +// +// swagger:model routerPatch +type RouterPatch struct { + + // fingerprint + Fingerprint *string `json:"fingerprint,omitempty"` + + // name + Name string `json:"name,omitempty"` + + // tags + Tags *Tags `json:"tags,omitempty"` +} + +// Validate validates this router patch +func (m *RouterPatch) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateTags(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RouterPatch) validateTags(formats strfmt.Registry) error { + if swag.IsZero(m.Tags) { // not required + return nil + } + + if m.Tags != nil { + if err := m.Tags.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// ContextValidate validate this router patch based on the context it is used +func (m *RouterPatch) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateTags(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RouterPatch) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { + + if m.Tags != nil { + if err := m.Tags.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RouterPatch) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RouterPatch) UnmarshalBinary(b []byte) error { + var res RouterPatch + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/router_update.go b/rest_model/router_update.go new file mode 100644 index 000000000..a38c66ffc --- /dev/null +++ b/rest_model/router_update.go @@ -0,0 +1,149 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// RouterUpdate router update +// +// swagger:model routerUpdate +type RouterUpdate struct { + + // fingerprint + Fingerprint *string `json:"fingerprint,omitempty"` + + // name + // Required: true + Name *string `json:"name"` + + // tags + Tags *Tags `json:"tags,omitempty"` +} + +// Validate validates this router update +func (m *RouterUpdate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTags(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RouterUpdate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *RouterUpdate) validateTags(formats strfmt.Registry) error { + if swag.IsZero(m.Tags) { // not required + return nil + } + + if m.Tags != nil { + if err := m.Tags.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// ContextValidate validate this router update based on the context it is used +func (m *RouterUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateTags(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RouterUpdate) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { + + if m.Tags != nil { + if err := m.Tags.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RouterUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RouterUpdate) UnmarshalBinary(b []byte) error { + var res RouterUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/service_create.go b/rest_model/service_create.go new file mode 100644 index 000000000..8896ca816 --- /dev/null +++ b/rest_model/service_create.go @@ -0,0 +1,149 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ServiceCreate service create +// +// swagger:model serviceCreate +type ServiceCreate struct { + + // name + // Required: true + Name *string `json:"name"` + + // tags + Tags *Tags `json:"tags,omitempty"` + + // terminator strategy + TerminatorStrategy string `json:"terminatorStrategy,omitempty"` +} + +// Validate validates this service create +func (m *ServiceCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTags(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceCreate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *ServiceCreate) validateTags(formats strfmt.Registry) error { + if swag.IsZero(m.Tags) { // not required + return nil + } + + if m.Tags != nil { + if err := m.Tags.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// ContextValidate validate this service create based on the context it is used +func (m *ServiceCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateTags(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceCreate) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { + + if m.Tags != nil { + if err := m.Tags.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceCreate) UnmarshalBinary(b []byte) error { + var res ServiceCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/service_detail.go b/rest_model/service_detail.go new file mode 100644 index 000000000..be3c42477 --- /dev/null +++ b/rest_model/service_detail.go @@ -0,0 +1,181 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ServiceDetail service detail +// +// swagger:model serviceDetail +type ServiceDetail struct { + BaseEntity + + // name + // Required: true + Name *string `json:"name"` + + // terminator strategy + // Required: true + TerminatorStrategy *string `json:"terminatorStrategy"` +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *ServiceDetail) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 BaseEntity + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.BaseEntity = aO0 + + // AO1 + var dataAO1 struct { + Name *string `json:"name"` + + TerminatorStrategy *string `json:"terminatorStrategy"` + } + if err := swag.ReadJSON(raw, &dataAO1); err != nil { + return err + } + + m.Name = dataAO1.Name + + m.TerminatorStrategy = dataAO1.TerminatorStrategy + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m ServiceDetail) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 2) + + aO0, err := swag.WriteJSON(m.BaseEntity) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + var dataAO1 struct { + Name *string `json:"name"` + + TerminatorStrategy *string `json:"terminatorStrategy"` + } + + dataAO1.Name = m.Name + + dataAO1.TerminatorStrategy = m.TerminatorStrategy + + jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1) + if errAO1 != nil { + return nil, errAO1 + } + _parts = append(_parts, jsonDataAO1) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this service detail +func (m *ServiceDetail) Validate(formats strfmt.Registry) error { + var res []error + + // validation for a type composition with BaseEntity + if err := m.BaseEntity.Validate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTerminatorStrategy(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceDetail) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *ServiceDetail) validateTerminatorStrategy(formats strfmt.Registry) error { + + if err := validate.Required("terminatorStrategy", "body", m.TerminatorStrategy); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this service detail based on the context it is used +func (m *ServiceDetail) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + // validation for a type composition with BaseEntity + if err := m.BaseEntity.ContextValidate(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceDetail) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceDetail) UnmarshalBinary(b []byte) error { + var res ServiceDetail + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/service_list.go b/rest_model/service_list.go new file mode 100644 index 000000000..10e411419 --- /dev/null +++ b/rest_model/service_list.go @@ -0,0 +1,97 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ServiceList service list +// +// swagger:model serviceList +type ServiceList []*ServiceDetail + +// Validate validates this service list +func (m ServiceList) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this service list based on the context it is used +func (m ServiceList) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + if m[i] != nil { + if err := m[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_model/service_patch.go b/rest_model/service_patch.go new file mode 100644 index 000000000..68fe3ccb2 --- /dev/null +++ b/rest_model/service_patch.go @@ -0,0 +1,134 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ServicePatch service patch +// +// swagger:model servicePatch +type ServicePatch struct { + + // name + Name string `json:"name,omitempty"` + + // tags + Tags *Tags `json:"tags,omitempty"` + + // terminator strategy + TerminatorStrategy string `json:"terminatorStrategy,omitempty"` +} + +// Validate validates this service patch +func (m *ServicePatch) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateTags(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServicePatch) validateTags(formats strfmt.Registry) error { + if swag.IsZero(m.Tags) { // not required + return nil + } + + if m.Tags != nil { + if err := m.Tags.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// ContextValidate validate this service patch based on the context it is used +func (m *ServicePatch) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateTags(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServicePatch) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { + + if m.Tags != nil { + if err := m.Tags.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ServicePatch) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServicePatch) UnmarshalBinary(b []byte) error { + var res ServicePatch + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/service_update.go b/rest_model/service_update.go new file mode 100644 index 000000000..ea2242bca --- /dev/null +++ b/rest_model/service_update.go @@ -0,0 +1,149 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ServiceUpdate service update +// +// swagger:model serviceUpdate +type ServiceUpdate struct { + + // name + // Required: true + Name *string `json:"name"` + + // tags + Tags *Tags `json:"tags,omitempty"` + + // terminator strategy + TerminatorStrategy string `json:"terminatorStrategy,omitempty"` +} + +// Validate validates this service update +func (m *ServiceUpdate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTags(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceUpdate) validateName(formats strfmt.Registry) error { + + if err := validate.Required("name", "body", m.Name); err != nil { + return err + } + + return nil +} + +func (m *ServiceUpdate) validateTags(formats strfmt.Registry) error { + if swag.IsZero(m.Tags) { // not required + return nil + } + + if m.Tags != nil { + if err := m.Tags.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// ContextValidate validate this service update based on the context it is used +func (m *ServiceUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateTags(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ServiceUpdate) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { + + if m.Tags != nil { + if err := m.Tags.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceUpdate) UnmarshalBinary(b []byte) error { + var res ServiceUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/sub_tags.go b/rest_model/sub_tags.go new file mode 100644 index 000000000..1c7edb059 --- /dev/null +++ b/rest_model/sub_tags.go @@ -0,0 +1,51 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" +) + +// SubTags sub tags +// +// swagger:model subTags +type SubTags map[string]interface{} + +// Validate validates this sub tags +func (m SubTags) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this sub tags based on context it is used +func (m SubTags) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/rest_model/tags.go b/rest_model/tags.go new file mode 100644 index 000000000..5ab8a1d6b --- /dev/null +++ b/rest_model/tags.go @@ -0,0 +1,117 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Tags A map of user defined fields and values. The values are limited to the following types/values: null, string, boolean +// +// swagger:model tags +type Tags struct { + SubTags +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *Tags) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 SubTags + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.SubTags = aO0 + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m Tags) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 1) + + aO0, err := swag.WriteJSON(m.SubTags) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this tags +func (m *Tags) Validate(formats strfmt.Registry) error { + var res []error + + // validation for a type composition with SubTags + if err := m.SubTags.Validate(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this tags based on the context it is used +func (m *Tags) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + // validation for a type composition with SubTags + if err := m.SubTags.ContextValidate(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// MarshalBinary interface implementation +func (m *Tags) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Tags) UnmarshalBinary(b []byte) error { + var res Tags + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/terminator_cost.go b/rest_model/terminator_cost.go new file mode 100644 index 000000000..357916440 --- /dev/null +++ b/rest_model/terminator_cost.go @@ -0,0 +1,66 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// TerminatorCost terminator cost +// +// swagger:model terminatorCost +type TerminatorCost int64 + +// Validate validates this terminator cost +func (m TerminatorCost) Validate(formats strfmt.Registry) error { + var res []error + + if err := validate.MinimumInt("", "body", int64(m), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("", "body", int64(m), 65535, false); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validates this terminator cost based on context it is used +func (m TerminatorCost) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/rest_model/terminator_cost_map.go b/rest_model/terminator_cost_map.go new file mode 100644 index 000000000..279384270 --- /dev/null +++ b/rest_model/terminator_cost_map.go @@ -0,0 +1,86 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// TerminatorCostMap terminator cost map +// +// swagger:model terminatorCostMap +type TerminatorCostMap map[string]*TerminatorCost + +// Validate validates this terminator cost map +func (m TerminatorCostMap) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if swag.IsZero(m[k]) { // not required + continue + } + if val, ok := m[k]; ok { + if err := val.Validate(formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this terminator cost map based on the context it is used +func (m TerminatorCostMap) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for k := range m { + + if val, ok := m[k]; ok { + if err := val.ContextValidate(ctx, formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_model/terminator_create.go b/rest_model/terminator_create.go new file mode 100644 index 000000000..e17bacae6 --- /dev/null +++ b/rest_model/terminator_create.go @@ -0,0 +1,292 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// TerminatorCreate terminator create +// +// swagger:model terminatorCreate +type TerminatorCreate struct { + + // address + // Required: true + Address *string `json:"address"` + + // binding + // Required: true + Binding *string `json:"binding"` + + // cost + Cost *TerminatorCost `json:"cost,omitempty"` + + // identity + Identity string `json:"identity,omitempty"` + + // identity secret + // Format: byte + IdentitySecret strfmt.Base64 `json:"identitySecret,omitempty"` + + // precedence + Precedence TerminatorPrecedence `json:"precedence,omitempty"` + + // router + // Required: true + Router *string `json:"router"` + + // service + // Required: true + Service *string `json:"service"` + + // tags + Tags *Tags `json:"tags,omitempty"` +} + +// Validate validates this terminator create +func (m *TerminatorCreate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateBinding(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCost(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePrecedence(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRouter(formats); err != nil { + res = append(res, err) + } + + if err := m.validateService(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTags(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TerminatorCreate) validateAddress(formats strfmt.Registry) error { + + if err := validate.Required("address", "body", m.Address); err != nil { + return err + } + + return nil +} + +func (m *TerminatorCreate) validateBinding(formats strfmt.Registry) error { + + if err := validate.Required("binding", "body", m.Binding); err != nil { + return err + } + + return nil +} + +func (m *TerminatorCreate) validateCost(formats strfmt.Registry) error { + if swag.IsZero(m.Cost) { // not required + return nil + } + + if m.Cost != nil { + if err := m.Cost.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cost") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cost") + } + return err + } + } + + return nil +} + +func (m *TerminatorCreate) validatePrecedence(formats strfmt.Registry) error { + if swag.IsZero(m.Precedence) { // not required + return nil + } + + if err := m.Precedence.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("precedence") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("precedence") + } + return err + } + + return nil +} + +func (m *TerminatorCreate) validateRouter(formats strfmt.Registry) error { + + if err := validate.Required("router", "body", m.Router); err != nil { + return err + } + + return nil +} + +func (m *TerminatorCreate) validateService(formats strfmt.Registry) error { + + if err := validate.Required("service", "body", m.Service); err != nil { + return err + } + + return nil +} + +func (m *TerminatorCreate) validateTags(formats strfmt.Registry) error { + if swag.IsZero(m.Tags) { // not required + return nil + } + + if m.Tags != nil { + if err := m.Tags.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// ContextValidate validate this terminator create based on the context it is used +func (m *TerminatorCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCost(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePrecedence(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTags(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TerminatorCreate) contextValidateCost(ctx context.Context, formats strfmt.Registry) error { + + if m.Cost != nil { + if err := m.Cost.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cost") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cost") + } + return err + } + } + + return nil +} + +func (m *TerminatorCreate) contextValidatePrecedence(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Precedence.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("precedence") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("precedence") + } + return err + } + + return nil +} + +func (m *TerminatorCreate) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { + + if m.Tags != nil { + if err := m.Tags.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *TerminatorCreate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TerminatorCreate) UnmarshalBinary(b []byte) error { + var res TerminatorCreate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/terminator_detail.go b/rest_model/terminator_detail.go new file mode 100644 index 000000000..6b082eb2d --- /dev/null +++ b/rest_model/terminator_detail.go @@ -0,0 +1,548 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// TerminatorDetail terminator detail +// +// swagger:model terminatorDetail +type TerminatorDetail struct { + BaseEntity + + // address + // Required: true + Address *string `json:"address"` + + // binding + // Required: true + Binding *string `json:"binding"` + + // cost + // Required: true + Cost *TerminatorCost `json:"cost"` + + // dynamic cost + // Required: true + DynamicCost *TerminatorCost `json:"dynamicCost"` + + // identity + // Required: true + Identity *string `json:"identity"` + + // precedence + // Required: true + Precedence *TerminatorPrecedence `json:"precedence"` + + // router + // Required: true + Router *EntityRef `json:"router"` + + // router Id + // Required: true + RouterID *string `json:"routerId"` + + // service + // Required: true + Service *EntityRef `json:"service"` + + // service Id + // Required: true + ServiceID *string `json:"serviceId"` +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *TerminatorDetail) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 BaseEntity + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.BaseEntity = aO0 + + // AO1 + var dataAO1 struct { + Address *string `json:"address"` + + Binding *string `json:"binding"` + + Cost *TerminatorCost `json:"cost"` + + DynamicCost *TerminatorCost `json:"dynamicCost"` + + Identity *string `json:"identity"` + + Precedence *TerminatorPrecedence `json:"precedence"` + + Router *EntityRef `json:"router"` + + RouterID *string `json:"routerId"` + + Service *EntityRef `json:"service"` + + ServiceID *string `json:"serviceId"` + } + if err := swag.ReadJSON(raw, &dataAO1); err != nil { + return err + } + + m.Address = dataAO1.Address + + m.Binding = dataAO1.Binding + + m.Cost = dataAO1.Cost + + m.DynamicCost = dataAO1.DynamicCost + + m.Identity = dataAO1.Identity + + m.Precedence = dataAO1.Precedence + + m.Router = dataAO1.Router + + m.RouterID = dataAO1.RouterID + + m.Service = dataAO1.Service + + m.ServiceID = dataAO1.ServiceID + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m TerminatorDetail) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 2) + + aO0, err := swag.WriteJSON(m.BaseEntity) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + var dataAO1 struct { + Address *string `json:"address"` + + Binding *string `json:"binding"` + + Cost *TerminatorCost `json:"cost"` + + DynamicCost *TerminatorCost `json:"dynamicCost"` + + Identity *string `json:"identity"` + + Precedence *TerminatorPrecedence `json:"precedence"` + + Router *EntityRef `json:"router"` + + RouterID *string `json:"routerId"` + + Service *EntityRef `json:"service"` + + ServiceID *string `json:"serviceId"` + } + + dataAO1.Address = m.Address + + dataAO1.Binding = m.Binding + + dataAO1.Cost = m.Cost + + dataAO1.DynamicCost = m.DynamicCost + + dataAO1.Identity = m.Identity + + dataAO1.Precedence = m.Precedence + + dataAO1.Router = m.Router + + dataAO1.RouterID = m.RouterID + + dataAO1.Service = m.Service + + dataAO1.ServiceID = m.ServiceID + + jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1) + if errAO1 != nil { + return nil, errAO1 + } + _parts = append(_parts, jsonDataAO1) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this terminator detail +func (m *TerminatorDetail) Validate(formats strfmt.Registry) error { + var res []error + + // validation for a type composition with BaseEntity + if err := m.BaseEntity.Validate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateBinding(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCost(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDynamicCost(formats); err != nil { + res = append(res, err) + } + + if err := m.validateIdentity(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePrecedence(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRouter(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRouterID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateService(formats); err != nil { + res = append(res, err) + } + + if err := m.validateServiceID(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TerminatorDetail) validateAddress(formats strfmt.Registry) error { + + if err := validate.Required("address", "body", m.Address); err != nil { + return err + } + + return nil +} + +func (m *TerminatorDetail) validateBinding(formats strfmt.Registry) error { + + if err := validate.Required("binding", "body", m.Binding); err != nil { + return err + } + + return nil +} + +func (m *TerminatorDetail) validateCost(formats strfmt.Registry) error { + + if err := validate.Required("cost", "body", m.Cost); err != nil { + return err + } + + if err := validate.Required("cost", "body", m.Cost); err != nil { + return err + } + + if m.Cost != nil { + if err := m.Cost.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cost") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cost") + } + return err + } + } + + return nil +} + +func (m *TerminatorDetail) validateDynamicCost(formats strfmt.Registry) error { + + if err := validate.Required("dynamicCost", "body", m.DynamicCost); err != nil { + return err + } + + if err := validate.Required("dynamicCost", "body", m.DynamicCost); err != nil { + return err + } + + if m.DynamicCost != nil { + if err := m.DynamicCost.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dynamicCost") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dynamicCost") + } + return err + } + } + + return nil +} + +func (m *TerminatorDetail) validateIdentity(formats strfmt.Registry) error { + + if err := validate.Required("identity", "body", m.Identity); err != nil { + return err + } + + return nil +} + +func (m *TerminatorDetail) validatePrecedence(formats strfmt.Registry) error { + + if err := validate.Required("precedence", "body", m.Precedence); err != nil { + return err + } + + if err := validate.Required("precedence", "body", m.Precedence); err != nil { + return err + } + + if m.Precedence != nil { + if err := m.Precedence.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("precedence") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("precedence") + } + return err + } + } + + return nil +} + +func (m *TerminatorDetail) validateRouter(formats strfmt.Registry) error { + + if err := validate.Required("router", "body", m.Router); err != nil { + return err + } + + if m.Router != nil { + if err := m.Router.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("router") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("router") + } + return err + } + } + + return nil +} + +func (m *TerminatorDetail) validateRouterID(formats strfmt.Registry) error { + + if err := validate.Required("routerId", "body", m.RouterID); err != nil { + return err + } + + return nil +} + +func (m *TerminatorDetail) validateService(formats strfmt.Registry) error { + + if err := validate.Required("service", "body", m.Service); err != nil { + return err + } + + if m.Service != nil { + if err := m.Service.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("service") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service") + } + return err + } + } + + return nil +} + +func (m *TerminatorDetail) validateServiceID(formats strfmt.Registry) error { + + if err := validate.Required("serviceId", "body", m.ServiceID); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this terminator detail based on the context it is used +func (m *TerminatorDetail) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + // validation for a type composition with BaseEntity + if err := m.BaseEntity.ContextValidate(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateCost(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateDynamicCost(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePrecedence(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateRouter(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateService(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TerminatorDetail) contextValidateCost(ctx context.Context, formats strfmt.Registry) error { + + if m.Cost != nil { + if err := m.Cost.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cost") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cost") + } + return err + } + } + + return nil +} + +func (m *TerminatorDetail) contextValidateDynamicCost(ctx context.Context, formats strfmt.Registry) error { + + if m.DynamicCost != nil { + if err := m.DynamicCost.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dynamicCost") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dynamicCost") + } + return err + } + } + + return nil +} + +func (m *TerminatorDetail) contextValidatePrecedence(ctx context.Context, formats strfmt.Registry) error { + + if m.Precedence != nil { + if err := m.Precedence.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("precedence") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("precedence") + } + return err + } + } + + return nil +} + +func (m *TerminatorDetail) contextValidateRouter(ctx context.Context, formats strfmt.Registry) error { + + if m.Router != nil { + if err := m.Router.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("router") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("router") + } + return err + } + } + + return nil +} + +func (m *TerminatorDetail) contextValidateService(ctx context.Context, formats strfmt.Registry) error { + + if m.Service != nil { + if err := m.Service.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("service") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *TerminatorDetail) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TerminatorDetail) UnmarshalBinary(b []byte) error { + var res TerminatorDetail + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/terminator_list.go b/rest_model/terminator_list.go new file mode 100644 index 000000000..4ead7f83e --- /dev/null +++ b/rest_model/terminator_list.go @@ -0,0 +1,97 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// TerminatorList terminator list +// +// swagger:model terminatorList +type TerminatorList []*TerminatorDetail + +// Validate validates this terminator list +func (m TerminatorList) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this terminator list based on the context it is used +func (m TerminatorList) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + if m[i] != nil { + if err := m[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_model/terminator_patch.go b/rest_model/terminator_patch.go new file mode 100644 index 000000000..b1ddc5575 --- /dev/null +++ b/rest_model/terminator_patch.go @@ -0,0 +1,228 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// TerminatorPatch terminator patch +// +// swagger:model terminatorPatch +type TerminatorPatch struct { + + // address + Address string `json:"address,omitempty"` + + // binding + Binding string `json:"binding,omitempty"` + + // cost + Cost *TerminatorCost `json:"cost,omitempty"` + + // precedence + Precedence TerminatorPrecedence `json:"precedence,omitempty"` + + // router + Router string `json:"router,omitempty"` + + // service + Service string `json:"service,omitempty"` + + // tags + Tags *Tags `json:"tags,omitempty"` +} + +// Validate validates this terminator patch +func (m *TerminatorPatch) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCost(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePrecedence(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTags(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TerminatorPatch) validateCost(formats strfmt.Registry) error { + if swag.IsZero(m.Cost) { // not required + return nil + } + + if m.Cost != nil { + if err := m.Cost.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cost") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cost") + } + return err + } + } + + return nil +} + +func (m *TerminatorPatch) validatePrecedence(formats strfmt.Registry) error { + if swag.IsZero(m.Precedence) { // not required + return nil + } + + if err := m.Precedence.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("precedence") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("precedence") + } + return err + } + + return nil +} + +func (m *TerminatorPatch) validateTags(formats strfmt.Registry) error { + if swag.IsZero(m.Tags) { // not required + return nil + } + + if m.Tags != nil { + if err := m.Tags.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// ContextValidate validate this terminator patch based on the context it is used +func (m *TerminatorPatch) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCost(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePrecedence(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTags(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TerminatorPatch) contextValidateCost(ctx context.Context, formats strfmt.Registry) error { + + if m.Cost != nil { + if err := m.Cost.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cost") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cost") + } + return err + } + } + + return nil +} + +func (m *TerminatorPatch) contextValidatePrecedence(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Precedence.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("precedence") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("precedence") + } + return err + } + + return nil +} + +func (m *TerminatorPatch) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { + + if m.Tags != nil { + if err := m.Tags.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *TerminatorPatch) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TerminatorPatch) UnmarshalBinary(b []byte) error { + var res TerminatorPatch + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/terminator_precedence.go b/rest_model/terminator_precedence.go new file mode 100644 index 000000000..37ad50267 --- /dev/null +++ b/rest_model/terminator_precedence.go @@ -0,0 +1,101 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// TerminatorPrecedence terminator precedence +// +// swagger:model terminatorPrecedence +type TerminatorPrecedence string + +func NewTerminatorPrecedence(value TerminatorPrecedence) *TerminatorPrecedence { + v := value + return &v +} + +const ( + + // TerminatorPrecedenceDefault captures enum value "default" + TerminatorPrecedenceDefault TerminatorPrecedence = "default" + + // TerminatorPrecedenceRequired captures enum value "required" + TerminatorPrecedenceRequired TerminatorPrecedence = "required" + + // TerminatorPrecedenceFailed captures enum value "failed" + TerminatorPrecedenceFailed TerminatorPrecedence = "failed" +) + +// for schema +var terminatorPrecedenceEnum []interface{} + +func init() { + var res []TerminatorPrecedence + if err := json.Unmarshal([]byte(`["default","required","failed"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + terminatorPrecedenceEnum = append(terminatorPrecedenceEnum, v) + } +} + +func (m TerminatorPrecedence) validateTerminatorPrecedenceEnum(path, location string, value TerminatorPrecedence) error { + if err := validate.EnumCase(path, location, value, terminatorPrecedenceEnum, true); err != nil { + return err + } + return nil +} + +// Validate validates this terminator precedence +func (m TerminatorPrecedence) Validate(formats strfmt.Registry) error { + var res []error + + // value enum + if err := m.validateTerminatorPrecedenceEnum("", "body", m); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validates this terminator precedence based on context it is used +func (m TerminatorPrecedence) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/rest_model/terminator_precedence_map.go b/rest_model/terminator_precedence_map.go new file mode 100644 index 000000000..4595ded07 --- /dev/null +++ b/rest_model/terminator_precedence_map.go @@ -0,0 +1,82 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" +) + +// TerminatorPrecedenceMap terminator precedence map +// +// swagger:model terminatorPrecedenceMap +type TerminatorPrecedenceMap map[string]TerminatorPrecedence + +// Validate validates this terminator precedence map +func (m TerminatorPrecedenceMap) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if val, ok := m[k]; ok { + if err := val.Validate(formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this terminator precedence map based on the context it is used +func (m TerminatorPrecedenceMap) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for k := range m { + + if val, ok := m[k]; ok { + if err := val.ContextValidate(ctx, formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_model/terminator_update.go b/rest_model/terminator_update.go new file mode 100644 index 000000000..dd275821a --- /dev/null +++ b/rest_model/terminator_update.go @@ -0,0 +1,285 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// TerminatorUpdate terminator update +// +// swagger:model terminatorUpdate +type TerminatorUpdate struct { + + // address + // Required: true + Address *string `json:"address"` + + // binding + // Required: true + Binding *string `json:"binding"` + + // cost + Cost *TerminatorCost `json:"cost,omitempty"` + + // precedence + Precedence TerminatorPrecedence `json:"precedence,omitempty"` + + // router + // Required: true + Router *string `json:"router"` + + // service + // Required: true + Service *string `json:"service"` + + // tags + Tags *Tags `json:"tags,omitempty"` +} + +// Validate validates this terminator update +func (m *TerminatorUpdate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAddress(formats); err != nil { + res = append(res, err) + } + + if err := m.validateBinding(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCost(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePrecedence(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRouter(formats); err != nil { + res = append(res, err) + } + + if err := m.validateService(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTags(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TerminatorUpdate) validateAddress(formats strfmt.Registry) error { + + if err := validate.Required("address", "body", m.Address); err != nil { + return err + } + + return nil +} + +func (m *TerminatorUpdate) validateBinding(formats strfmt.Registry) error { + + if err := validate.Required("binding", "body", m.Binding); err != nil { + return err + } + + return nil +} + +func (m *TerminatorUpdate) validateCost(formats strfmt.Registry) error { + if swag.IsZero(m.Cost) { // not required + return nil + } + + if m.Cost != nil { + if err := m.Cost.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cost") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cost") + } + return err + } + } + + return nil +} + +func (m *TerminatorUpdate) validatePrecedence(formats strfmt.Registry) error { + if swag.IsZero(m.Precedence) { // not required + return nil + } + + if err := m.Precedence.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("precedence") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("precedence") + } + return err + } + + return nil +} + +func (m *TerminatorUpdate) validateRouter(formats strfmt.Registry) error { + + if err := validate.Required("router", "body", m.Router); err != nil { + return err + } + + return nil +} + +func (m *TerminatorUpdate) validateService(formats strfmt.Registry) error { + + if err := validate.Required("service", "body", m.Service); err != nil { + return err + } + + return nil +} + +func (m *TerminatorUpdate) validateTags(formats strfmt.Registry) error { + if swag.IsZero(m.Tags) { // not required + return nil + } + + if m.Tags != nil { + if err := m.Tags.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// ContextValidate validate this terminator update based on the context it is used +func (m *TerminatorUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCost(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePrecedence(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTags(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TerminatorUpdate) contextValidateCost(ctx context.Context, formats strfmt.Registry) error { + + if m.Cost != nil { + if err := m.Cost.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("cost") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("cost") + } + return err + } + } + + return nil +} + +func (m *TerminatorUpdate) contextValidatePrecedence(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Precedence.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("precedence") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("precedence") + } + return err + } + + return nil +} + +func (m *TerminatorUpdate) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { + + if m.Tags != nil { + if err := m.Tags.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tags") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *TerminatorUpdate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TerminatorUpdate) UnmarshalBinary(b []byte) error { + var res TerminatorUpdate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/version_info.go b/rest_model/version_info.go new file mode 100644 index 000000000..ff5d9b0da --- /dev/null +++ b/rest_model/version_info.go @@ -0,0 +1,86 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// VersionInfo Application build information +// +// swagger:model versionInfo +type VersionInfo struct { + + // arch + Arch string `json:"arch,omitempty"` + + // build date + BuildDate string `json:"buildDate,omitempty"` + + // os + Os string `json:"os,omitempty"` + + // revision + Revision string `json:"revision,omitempty"` + + // version + Version string `json:"version,omitempty"` +} + +// Validate validates this version info +func (m *VersionInfo) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this version info based on context it is used +func (m *VersionInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VersionInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VersionInfo) UnmarshalBinary(b []byte) error { + var res VersionInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_server/configure_ziti_fabric.go b/rest_server/configure_ziti_fabric.go new file mode 100644 index 000000000..599eaade6 --- /dev/null +++ b/rest_server/configure_ziti_fabric.go @@ -0,0 +1,187 @@ +// This file is safe to edit. Once it exists it will not be overwritten + +// +// 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 rest_server + +import ( + "crypto/tls" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + + "github.com/openziti/fabric/rest_server/operations" + "github.com/openziti/fabric/rest_server/operations/router" + "github.com/openziti/fabric/rest_server/operations/service" + "github.com/openziti/fabric/rest_server/operations/terminator" +) + +//go:generate swagger generate server --target ../../fabric --name ZitiFabric --spec ../specs/swagger.yml --model-package rest_model --server-package rest_server --principal interface{} --exclude-main + +func configureFlags(api *operations.ZitiFabricAPI) { + // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } +} + +func configureAPI(api *operations.ZitiFabricAPI) http.Handler { + // configure the api here + api.ServeError = errors.ServeError + + // Set your custom logger if needed. Default one is log.Printf + // Expected interface func(string, ...interface{}) + // + // Example: + // api.Logger = log.Printf + + api.UseSwaggerUI() + // To continue using redoc as your UI, uncomment the following line + // api.UseRedoc() + + api.JSONConsumer = runtime.JSONConsumer() + + api.JSONProducer = runtime.JSONProducer() + + if api.RouterCreateRouterHandler == nil { + api.RouterCreateRouterHandler = router.CreateRouterHandlerFunc(func(params router.CreateRouterParams) middleware.Responder { + return middleware.NotImplemented("operation router.CreateRouter has not yet been implemented") + }) + } + if api.ServiceCreateServiceHandler == nil { + api.ServiceCreateServiceHandler = service.CreateServiceHandlerFunc(func(params service.CreateServiceParams) middleware.Responder { + return middleware.NotImplemented("operation service.CreateService has not yet been implemented") + }) + } + if api.TerminatorCreateTerminatorHandler == nil { + api.TerminatorCreateTerminatorHandler = terminator.CreateTerminatorHandlerFunc(func(params terminator.CreateTerminatorParams) middleware.Responder { + return middleware.NotImplemented("operation terminator.CreateTerminator has not yet been implemented") + }) + } + if api.RouterDeleteRouterHandler == nil { + api.RouterDeleteRouterHandler = router.DeleteRouterHandlerFunc(func(params router.DeleteRouterParams) middleware.Responder { + return middleware.NotImplemented("operation router.DeleteRouter has not yet been implemented") + }) + } + if api.ServiceDeleteServiceHandler == nil { + api.ServiceDeleteServiceHandler = service.DeleteServiceHandlerFunc(func(params service.DeleteServiceParams) middleware.Responder { + return middleware.NotImplemented("operation service.DeleteService has not yet been implemented") + }) + } + if api.TerminatorDeleteTerminatorHandler == nil { + api.TerminatorDeleteTerminatorHandler = terminator.DeleteTerminatorHandlerFunc(func(params terminator.DeleteTerminatorParams) middleware.Responder { + return middleware.NotImplemented("operation terminator.DeleteTerminator has not yet been implemented") + }) + } + if api.RouterDetailRouterHandler == nil { + api.RouterDetailRouterHandler = router.DetailRouterHandlerFunc(func(params router.DetailRouterParams) middleware.Responder { + return middleware.NotImplemented("operation router.DetailRouter has not yet been implemented") + }) + } + if api.ServiceDetailServiceHandler == nil { + api.ServiceDetailServiceHandler = service.DetailServiceHandlerFunc(func(params service.DetailServiceParams) middleware.Responder { + return middleware.NotImplemented("operation service.DetailService has not yet been implemented") + }) + } + if api.TerminatorDetailTerminatorHandler == nil { + api.TerminatorDetailTerminatorHandler = terminator.DetailTerminatorHandlerFunc(func(params terminator.DetailTerminatorParams) middleware.Responder { + return middleware.NotImplemented("operation terminator.DetailTerminator has not yet been implemented") + }) + } + if api.RouterListRouterTerminatorsHandler == nil { + api.RouterListRouterTerminatorsHandler = router.ListRouterTerminatorsHandlerFunc(func(params router.ListRouterTerminatorsParams) middleware.Responder { + return middleware.NotImplemented("operation router.ListRouterTerminators has not yet been implemented") + }) + } + if api.RouterListRoutersHandler == nil { + api.RouterListRoutersHandler = router.ListRoutersHandlerFunc(func(params router.ListRoutersParams) middleware.Responder { + return middleware.NotImplemented("operation router.ListRouters has not yet been implemented") + }) + } + if api.ServiceListServiceTerminatorsHandler == nil { + api.ServiceListServiceTerminatorsHandler = service.ListServiceTerminatorsHandlerFunc(func(params service.ListServiceTerminatorsParams) middleware.Responder { + return middleware.NotImplemented("operation service.ListServiceTerminators has not yet been implemented") + }) + } + if api.ServiceListServicesHandler == nil { + api.ServiceListServicesHandler = service.ListServicesHandlerFunc(func(params service.ListServicesParams) middleware.Responder { + return middleware.NotImplemented("operation service.ListServices has not yet been implemented") + }) + } + if api.TerminatorListTerminatorsHandler == nil { + api.TerminatorListTerminatorsHandler = terminator.ListTerminatorsHandlerFunc(func(params terminator.ListTerminatorsParams) middleware.Responder { + return middleware.NotImplemented("operation terminator.ListTerminators has not yet been implemented") + }) + } + if api.ServicePatchServiceHandler == nil { + api.ServicePatchServiceHandler = service.PatchServiceHandlerFunc(func(params service.PatchServiceParams) middleware.Responder { + return middleware.NotImplemented("operation service.PatchService has not yet been implemented") + }) + } + if api.TerminatorPatchTerminatorHandler == nil { + api.TerminatorPatchTerminatorHandler = terminator.PatchTerminatorHandlerFunc(func(params terminator.PatchTerminatorParams) middleware.Responder { + return middleware.NotImplemented("operation terminator.PatchTerminator has not yet been implemented") + }) + } + if api.ServiceUpdateServiceHandler == nil { + api.ServiceUpdateServiceHandler = service.UpdateServiceHandlerFunc(func(params service.UpdateServiceParams) middleware.Responder { + return middleware.NotImplemented("operation service.UpdateService has not yet been implemented") + }) + } + if api.TerminatorUpdateTerminatorHandler == nil { + api.TerminatorUpdateTerminatorHandler = terminator.UpdateTerminatorHandlerFunc(func(params terminator.UpdateTerminatorParams) middleware.Responder { + return middleware.NotImplemented("operation terminator.UpdateTerminator has not yet been implemented") + }) + } + + api.PreServerShutdown = func() {} + + api.ServerShutdown = func() {} + + return setupGlobalMiddleware(api.Serve(setupMiddlewares)) +} + +// The TLS configuration before HTTPS server starts. +func configureTLS(tlsConfig *tls.Config) { + // Make all necessary changes to the TLS configuration here. +} + +// As soon as server is initialized but not run yet, this function will be called. +// If you need to modify a config, store server instance to stop it individually later, this is the place. +// This function can be called multiple times, depending on the number of serving schemes. +// scheme value will be set accordingly: "http", "https" or "unix". +func configureServer(s *http.Server, scheme, addr string) { +} + +// The middleware configuration is for the handler executors. These do not apply to the swagger.json document. +// The middleware executes after routing but before authentication, binding and validation. +func setupMiddlewares(handler http.Handler) http.Handler { + return handler +} + +// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document. +// So this is a good place to plug in a panic handling middleware, logging and metrics. +func setupGlobalMiddleware(handler http.Handler) http.Handler { + return handler +} diff --git a/rest_server/doc.go b/rest_server/doc.go new file mode 100644 index 000000000..b86ba03d9 --- /dev/null +++ b/rest_server/doc.go @@ -0,0 +1,42 @@ +// 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 rest_server Ziti Fabric +// +// Schemes: +// https +// Host: demo.ziti.dev +// BasePath: /fabric/v1 +// Version: 0.16.54 +// Contact: +// +// Consumes: +// - application/json +// +// Produces: +// - application/json +// +// swagger:meta +package rest_server diff --git a/rest_server/embedded_spec.go b/rest_server/embedded_spec.go new file mode 100644 index 000000000..96835b54c --- /dev/null +++ b/rest_server/embedded_spec.go @@ -0,0 +1,4228 @@ +// 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 rest_server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" +) + +var ( + // SwaggerJSON embedded version of the swagger document used at generation time + SwaggerJSON json.RawMessage + // FlatSwaggerJSON embedded flattened version of the swagger document used at generation time + FlatSwaggerJSON json.RawMessage +) + +func init() { + SwaggerJSON = json.RawMessage([]byte(`{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "schemes": [ + "https" + ], + "swagger": "2.0", + "info": { + "title": "Ziti Fabric", + "contact": {}, + "version": "0.16.54" + }, + "host": "demo.ziti.dev", + "basePath": "/fabric/v1", + "paths": { + "/routers": { + "get": { + "description": "Retrieves a list of router resources; supports filtering, sorting, and pagination. Requires admin access.\n", + "tags": [ + "Router" + ], + "summary": "List routers", + "operationId": "listRouters", + "parameters": [ + { + "$ref": "#/parameters/limit" + }, + { + "$ref": "#/parameters/offset" + }, + { + "$ref": "#/parameters/filter" + } + ], + "responses": { + "200": { + "$ref": "#/responses/listRouters" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + } + } + }, + "post": { + "description": "Create a router resource. Requires admin access.", + "tags": [ + "Router" + ], + "summary": "Create a router resource", + "operationId": "createRouter", + "parameters": [ + { + "description": "A router to create", + "name": "router", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/routerCreate" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/createResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + } + } + } + }, + "/routers/{id}": { + "get": { + "description": "Retrieves a single router by id. Requires admin access.", + "tags": [ + "Router" + ], + "summary": "Retrieves a single router", + "operationId": "detailRouter", + "responses": { + "200": { + "$ref": "#/responses/detailRouter" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "404": { + "$ref": "#/responses/notFoundResponse" + } + } + }, + "delete": { + "description": "Delete a router by id. Requires admin access.", + "tags": [ + "Router" + ], + "summary": "Delete a router", + "operationId": "deleteRouter", + "responses": { + "200": { + "$ref": "#/responses/deleteResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "409": { + "$ref": "#/responses/cannotDeleteReferencedResourceResponse" + } + } + }, + "parameters": [ + { + "$ref": "#/parameters/id" + } + ] + }, + "/routers/{id}/terminators": { + "get": { + "description": "Retrieves a list of terminator resources that are assigned specific router; supports filtering, sorting, and pagination.\n", + "tags": [ + "Router" + ], + "summary": "List of terminators assigned to a router", + "operationId": "listRouterTerminators", + "parameters": [ + { + "$ref": "#/parameters/limit" + }, + { + "$ref": "#/parameters/offset" + }, + { + "$ref": "#/parameters/filter" + } + ], + "responses": { + "200": { + "$ref": "#/responses/listTerminators" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + } + } + }, + "parameters": [ + { + "$ref": "#/parameters/id" + } + ] + }, + "/services": { + "get": { + "description": "Retrieves a list of service resources; supports filtering, sorting, and pagination. Requires admin access.\n", + "tags": [ + "Service" + ], + "summary": "List services", + "operationId": "listServices", + "parameters": [ + { + "$ref": "#/parameters/limit" + }, + { + "$ref": "#/parameters/offset" + }, + { + "$ref": "#/parameters/filter" + } + ], + "responses": { + "200": { + "$ref": "#/responses/listServices" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + } + } + }, + "post": { + "description": "Create a service resource. Requires admin access.", + "tags": [ + "Service" + ], + "summary": "Create a service resource", + "operationId": "createService", + "parameters": [ + { + "description": "A service to create", + "name": "service", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/serviceCreate" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/createResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + } + } + } + }, + "/services/{id}": { + "get": { + "description": "Retrieves a single service by id. Requires admin access.", + "tags": [ + "Service" + ], + "summary": "Retrieves a single service", + "operationId": "detailService", + "responses": { + "200": { + "$ref": "#/responses/detailService" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "404": { + "$ref": "#/responses/notFoundResponse" + } + } + }, + "put": { + "description": "Update all fields on a service by id. Requires admin access.", + "tags": [ + "Service" + ], + "summary": "Update all fields on a service", + "operationId": "updateService", + "parameters": [ + { + "description": "A service update object", + "name": "service", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/serviceUpdate" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/updateResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "404": { + "$ref": "#/responses/notFoundResponse" + } + } + }, + "delete": { + "description": "Delete a service by id. Requires admin access.", + "tags": [ + "Service" + ], + "summary": "Delete a service", + "operationId": "deleteService", + "responses": { + "200": { + "$ref": "#/responses/deleteResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "409": { + "$ref": "#/responses/cannotDeleteReferencedResourceResponse" + } + } + }, + "patch": { + "description": "Update the supplied fields on a service. Requires admin access.", + "tags": [ + "Service" + ], + "summary": "Update the supplied fields on a service", + "operationId": "patchService", + "parameters": [ + { + "description": "A service patch object", + "name": "service", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/servicePatch" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/patchResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "404": { + "$ref": "#/responses/notFoundResponse" + } + } + }, + "parameters": [ + { + "$ref": "#/parameters/id" + } + ] + }, + "/services/{id}/terminators": { + "get": { + "description": "Retrieves a list of terminator resources that are assigned specific service; supports filtering, sorting, and pagination.\n", + "tags": [ + "Service" + ], + "summary": "List of terminators assigned to a service", + "operationId": "listServiceTerminators", + "parameters": [ + { + "$ref": "#/parameters/limit" + }, + { + "$ref": "#/parameters/offset" + }, + { + "$ref": "#/parameters/filter" + } + ], + "responses": { + "200": { + "$ref": "#/responses/listTerminators" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + } + } + }, + "parameters": [ + { + "$ref": "#/parameters/id" + } + ] + }, + "/terminators": { + "get": { + "description": "Retrieves a list of terminator resources; supports filtering, sorting, and pagination. Requires admin access.\n", + "tags": [ + "Terminator" + ], + "summary": "List terminators", + "operationId": "listTerminators", + "parameters": [ + { + "$ref": "#/parameters/limit" + }, + { + "$ref": "#/parameters/offset" + }, + { + "$ref": "#/parameters/filter" + } + ], + "responses": { + "200": { + "$ref": "#/responses/listTerminators" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + } + } + }, + "post": { + "description": "Create a terminator resource. Requires admin access.", + "tags": [ + "Terminator" + ], + "summary": "Create a terminator resource", + "operationId": "createTerminator", + "parameters": [ + { + "description": "A terminator to create", + "name": "terminator", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/terminatorCreate" + } + } + ], + "responses": { + "201": { + "$ref": "#/responses/createResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + } + } + } + }, + "/terminators/{id}": { + "get": { + "description": "Retrieves a single terminator by id. Requires admin access.", + "tags": [ + "Terminator" + ], + "summary": "Retrieves a single terminator", + "operationId": "detailTerminator", + "responses": { + "200": { + "$ref": "#/responses/detailTerminator" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "404": { + "$ref": "#/responses/notFoundResponse" + } + } + }, + "put": { + "description": "Update all fields on a terminator by id. Requires admin access.", + "tags": [ + "Terminator" + ], + "summary": "Update all fields on a terminator", + "operationId": "updateTerminator", + "parameters": [ + { + "description": "A terminator update object", + "name": "terminator", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/terminatorUpdate" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/updateResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "404": { + "$ref": "#/responses/notFoundResponse" + } + } + }, + "delete": { + "description": "Delete a terminator by id. Requires admin access.", + "tags": [ + "Terminator" + ], + "summary": "Delete a terminator", + "operationId": "deleteTerminator", + "responses": { + "200": { + "$ref": "#/responses/deleteResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "409": { + "$ref": "#/responses/cannotDeleteReferencedResourceResponse" + } + } + }, + "patch": { + "description": "Update the supplied fields on a terminator. Requires admin access.", + "tags": [ + "Terminator" + ], + "summary": "Update the supplied fields on a terminator", + "operationId": "patchTerminator", + "parameters": [ + { + "description": "A terminator patch object", + "name": "terminator", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/terminatorPatch" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/patchResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "404": { + "$ref": "#/responses/notFoundResponse" + } + } + }, + "parameters": [ + { + "$ref": "#/parameters/id" + } + ] + } + }, + "definitions": { + "apiError": { + "type": "object", + "properties": { + "args": { + "$ref": "#/definitions/apiErrorArgs" + }, + "cause": { + "$ref": "#/definitions/apiErrorCause" + }, + "causeMessage": { + "type": "string" + }, + "code": { + "type": "string" + }, + "data": { + "type": "object", + "additionalProperties": true + }, + "message": { + "type": "string" + }, + "requestId": { + "type": "string" + } + } + }, + "apiErrorArgs": { + "type": "object", + "properties": { + "urlVars": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "apiErrorCause": { + "allOf": [ + { + "$ref": "#/definitions/apiFieldError" + }, + { + "$ref": "#/definitions/apiError" + } + ] + }, + "apiErrorEnvelope": { + "type": "object", + "required": [ + "meta", + "error" + ], + "properties": { + "error": { + "$ref": "#/definitions/apiError" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "apiFieldError": { + "type": "object", + "properties": { + "field": { + "type": "string" + }, + "reason": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "baseEntity": { + "description": "Fields shared by all Edge API entities", + "type": "object", + "required": [ + "id", + "createdAt", + "updatedAt", + "_links", + "tags" + ], + "properties": { + "_links": { + "$ref": "#/definitions/links" + }, + "createdAt": { + "type": "string", + "format": "date-time" + }, + "id": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + }, + "updatedAt": { + "type": "string", + "format": "date-time" + } + } + }, + "createEnvelope": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/createLocation" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "createLocation": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/definitions/links" + }, + "id": { + "type": "string" + } + } + }, + "detailRouterEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/routerDetail" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "detailServiceEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/serviceDetail" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "detailTerminatorEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/terminatorDetail" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "empty": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "type": "object", + "example": {} + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "entityRef": { + "description": "A reference to another resource and links to interact with it", + "type": "object", + "properties": { + "_links": { + "$ref": "#/definitions/links" + }, + "entity": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "link": { + "description": "A link to another resource", + "type": "object", + "required": [ + "href" + ], + "properties": { + "comment": { + "type": "string" + }, + "href": { + "type": "string", + "format": "uri" + }, + "method": { + "type": "string" + } + } + }, + "links": { + "description": "A map of named links", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/link" + }, + "x-omitempty": false + }, + "listRoutersEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/routerList" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "listServicesEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/serviceList" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "listTerminatorsEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/terminatorList" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "meta": { + "type": "object", + "properties": { + "apiEnrollmentVersion": { + "type": "string" + }, + "apiVersion": { + "type": "string" + }, + "filterableFields": { + "type": "array", + "items": { + "type": "string" + }, + "x-omitempty": true + }, + "pagination": { + "$ref": "#/definitions/pagination" + } + } + }, + "pagination": { + "type": "object", + "required": [ + "limit", + "offset", + "totalCount" + ], + "properties": { + "limit": { + "type": "number", + "format": "int64" + }, + "offset": { + "type": "number", + "format": "int64" + }, + "totalCount": { + "type": "number", + "format": "int64" + } + } + }, + "routerCreate": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "fingerprint": { + "type": "string", + "x-nullable": true + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + } + } + }, + "routerDetail": { + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/baseEntity" + }, + { + "type": "object", + "required": [ + "name", + "fingerprint", + "connected" + ], + "properties": { + "connected": { + "type": "boolean" + }, + "fingerprint": { + "type": "string" + }, + "listenerAddress": { + "type": "string" + }, + "name": { + "type": "string" + }, + "versionInfo": { + "$ref": "#/definitions/versionInfo" + } + } + } + ] + }, + "routerList": { + "type": "array", + "items": { + "$ref": "#/definitions/routerDetail" + } + }, + "routerPatch": { + "type": "object", + "properties": { + "fingerprint": { + "type": "string", + "x-nullable": true + }, + "name": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + } + } + }, + "routerUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "fingerprint": { + "type": "string", + "x-nullable": true + }, + "name": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + } + } + }, + "serviceCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + }, + "terminatorStrategy": { + "type": "string" + } + } + }, + "serviceDetail": { + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/baseEntity" + }, + { + "type": "object", + "required": [ + "name", + "terminatorStrategy" + ], + "properties": { + "name": { + "type": "string" + }, + "terminatorStrategy": { + "type": "string" + } + } + } + ] + }, + "serviceList": { + "type": "array", + "items": { + "$ref": "#/definitions/serviceDetail" + } + }, + "servicePatch": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + }, + "terminatorStrategy": { + "type": "string" + } + } + }, + "serviceUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + }, + "terminatorStrategy": { + "type": "string" + } + } + }, + "subTags": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "tags": { + "description": "A map of user defined fields and values. The values are limited to the following types/values: null, string, boolean", + "allOf": [ + { + "$ref": "#/definitions/subTags" + } + ], + "x-nullable": true + }, + "terminatorCost": { + "type": "integer", + "maximum": 65535 + }, + "terminatorCostMap": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/terminatorCost" + } + }, + "terminatorCreate": { + "type": "object", + "required": [ + "service", + "router", + "address", + "binding" + ], + "properties": { + "address": { + "type": "string" + }, + "binding": { + "type": "string" + }, + "cost": { + "$ref": "#/definitions/terminatorCost" + }, + "identity": { + "type": "string" + }, + "identitySecret": { + "type": "string", + "format": "byte" + }, + "precedence": { + "$ref": "#/definitions/terminatorPrecedence" + }, + "router": { + "type": "string" + }, + "service": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + } + } + }, + "terminatorDetail": { + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/baseEntity" + }, + { + "type": "object", + "required": [ + "serviceId", + "service", + "routerId", + "router", + "binding", + "address", + "identity", + "cost", + "precedence", + "dynamicCost" + ], + "properties": { + "address": { + "type": "string" + }, + "binding": { + "type": "string" + }, + "cost": { + "$ref": "#/definitions/terminatorCost" + }, + "dynamicCost": { + "$ref": "#/definitions/terminatorCost" + }, + "identity": { + "type": "string" + }, + "precedence": { + "$ref": "#/definitions/terminatorPrecedence" + }, + "router": { + "$ref": "#/definitions/entityRef" + }, + "routerId": { + "type": "string" + }, + "service": { + "$ref": "#/definitions/entityRef" + }, + "serviceId": { + "type": "string" + } + } + } + ] + }, + "terminatorList": { + "type": "array", + "items": { + "$ref": "#/definitions/terminatorDetail" + } + }, + "terminatorPatch": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "binding": { + "type": "string" + }, + "cost": { + "$ref": "#/definitions/terminatorCost" + }, + "precedence": { + "$ref": "#/definitions/terminatorPrecedence" + }, + "router": { + "type": "string" + }, + "service": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + } + } + }, + "terminatorPrecedence": { + "type": "string", + "enum": [ + "default", + "required", + "failed" + ] + }, + "terminatorPrecedenceMap": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/terminatorPrecedence" + } + }, + "terminatorUpdate": { + "type": "object", + "required": [ + "service", + "router", + "address", + "binding" + ], + "properties": { + "address": { + "type": "string" + }, + "binding": { + "type": "string" + }, + "cost": { + "$ref": "#/definitions/terminatorCost" + }, + "precedence": { + "$ref": "#/definitions/terminatorPrecedence" + }, + "router": { + "type": "string" + }, + "service": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + } + } + }, + "versionInfo": { + "description": "Application build information", + "type": "object", + "properties": { + "arch": { + "type": "string" + }, + "buildDate": { + "type": "string" + }, + "os": { + "type": "string" + }, + "revision": { + "type": "string" + }, + "version": { + "type": "string" + } + } + } + }, + "parameters": { + "filter": { + "type": "string", + "name": "filter", + "in": "query" + }, + "id": { + "type": "string", + "description": "The id of the requested resource", + "name": "id", + "in": "path", + "required": true + }, + "limit": { + "type": "integer", + "name": "limit", + "in": "query" + }, + "offset": { + "type": "integer", + "name": "offset", + "in": "query" + } + }, + "responses": { + "badRequestResponse": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "cannotDeleteReferencedResourceResponse": { + "description": "The resource requested to be removed/altered cannot be as it is referenced by another object.", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "causeMessage": "referenced by /some-resource/05f4f710-c155-4a74-86d5-77558eb9cb42", + "code": "CONFLICT_CANNOT_MODIFY_REFERENCED", + "message": "The resource cannot be deleted/modified. Remove all referencing resources first.", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "createResponse": { + "description": "The create request was successful and the resource has been added at the following location", + "schema": { + "$ref": "#/definitions/createEnvelope" + } + }, + "deleteResponse": { + "description": "The delete request was successful and the resource has been removed", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "detailRouter": { + "description": "A single router", + "schema": { + "$ref": "#/definitions/detailRouterEnvelope" + } + }, + "detailService": { + "description": "A single service", + "schema": { + "$ref": "#/definitions/detailServiceEnvelope" + } + }, + "detailTerminator": { + "description": "A single terminator", + "schema": { + "$ref": "#/definitions/detailTerminatorEnvelope" + } + }, + "emptyResponse": { + "description": "Base empty response", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "invalidAuthResponse": { + "description": "The authentication request could not be processed as the credentials are invalid", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "INVALID_AUTH", + "message": "The authentication request failed", + "requestId": "5952ed10-3091-474f-a691-47ebab6990dc" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "listRouters": { + "description": "A list of routers", + "schema": { + "$ref": "#/definitions/listRoutersEnvelope" + } + }, + "listServices": { + "description": "A list of services", + "schema": { + "$ref": "#/definitions/listServicesEnvelope" + } + }, + "listTerminators": { + "description": "A list of terminators", + "schema": { + "$ref": "#/definitions/listTerminatorsEnvelope" + } + }, + "notFoundResponse": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "patchResponse": { + "description": "The patch request was successful and the resource has been altered", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "rateLimitedResponse": { + "description": "The resource requested is rate limited and the rate limit has been exceeded", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "causeMessage": "you have hit a rate limit in the requested operation", + "code": "RATE_LIMITED", + "message": "The resource is rate limited and the rate limit has been exceeded. Please try again later", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "unauthorizedResponse": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "updateResponse": { + "description": "The update request was successful and the resource has been altered", + "schema": { + "$ref": "#/definitions/empty" + } + } + } +}`)) + FlatSwaggerJSON = json.RawMessage([]byte(`{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "schemes": [ + "https" + ], + "swagger": "2.0", + "info": { + "title": "Ziti Fabric", + "contact": {}, + "version": "0.16.54" + }, + "host": "demo.ziti.dev", + "basePath": "/fabric/v1", + "paths": { + "/routers": { + "get": { + "description": "Retrieves a list of router resources; supports filtering, sorting, and pagination. Requires admin access.\n", + "tags": [ + "Router" + ], + "summary": "List routers", + "operationId": "listRouters", + "parameters": [ + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "name": "offset", + "in": "query" + }, + { + "type": "string", + "name": "filter", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of routers", + "schema": { + "$ref": "#/definitions/listRoutersEnvelope" + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "post": { + "description": "Create a router resource. Requires admin access.", + "tags": [ + "Router" + ], + "summary": "Create a router resource", + "operationId": "createRouter", + "parameters": [ + { + "description": "A router to create", + "name": "router", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/routerCreate" + } + } + ], + "responses": { + "201": { + "description": "The create request was successful and the resource has been added at the following location", + "schema": { + "$ref": "#/definitions/createEnvelope" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + } + }, + "/routers/{id}": { + "get": { + "description": "Retrieves a single router by id. Requires admin access.", + "tags": [ + "Router" + ], + "summary": "Retrieves a single router", + "operationId": "detailRouter", + "responses": { + "200": { + "description": "A single router", + "schema": { + "$ref": "#/definitions/detailRouterEnvelope" + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "404": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "delete": { + "description": "Delete a router by id. Requires admin access.", + "tags": [ + "Router" + ], + "summary": "Delete a router", + "operationId": "deleteRouter", + "responses": { + "200": { + "description": "The delete request was successful and the resource has been removed", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "409": { + "description": "The resource requested to be removed/altered cannot be as it is referenced by another object.", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "causeMessage": "referenced by /some-resource/05f4f710-c155-4a74-86d5-77558eb9cb42", + "code": "CONFLICT_CANNOT_MODIFY_REFERENCED", + "message": "The resource cannot be deleted/modified. Remove all referencing resources first.", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "parameters": [ + { + "type": "string", + "description": "The id of the requested resource", + "name": "id", + "in": "path", + "required": true + } + ] + }, + "/routers/{id}/terminators": { + "get": { + "description": "Retrieves a list of terminator resources that are assigned specific router; supports filtering, sorting, and pagination.\n", + "tags": [ + "Router" + ], + "summary": "List of terminators assigned to a router", + "operationId": "listRouterTerminators", + "parameters": [ + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "name": "offset", + "in": "query" + }, + { + "type": "string", + "name": "filter", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of terminators", + "schema": { + "$ref": "#/definitions/listTerminatorsEnvelope" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "parameters": [ + { + "type": "string", + "description": "The id of the requested resource", + "name": "id", + "in": "path", + "required": true + } + ] + }, + "/services": { + "get": { + "description": "Retrieves a list of service resources; supports filtering, sorting, and pagination. Requires admin access.\n", + "tags": [ + "Service" + ], + "summary": "List services", + "operationId": "listServices", + "parameters": [ + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "name": "offset", + "in": "query" + }, + { + "type": "string", + "name": "filter", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of services", + "schema": { + "$ref": "#/definitions/listServicesEnvelope" + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "post": { + "description": "Create a service resource. Requires admin access.", + "tags": [ + "Service" + ], + "summary": "Create a service resource", + "operationId": "createService", + "parameters": [ + { + "description": "A service to create", + "name": "service", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/serviceCreate" + } + } + ], + "responses": { + "201": { + "description": "The create request was successful and the resource has been added at the following location", + "schema": { + "$ref": "#/definitions/createEnvelope" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + } + }, + "/services/{id}": { + "get": { + "description": "Retrieves a single service by id. Requires admin access.", + "tags": [ + "Service" + ], + "summary": "Retrieves a single service", + "operationId": "detailService", + "responses": { + "200": { + "description": "A single service", + "schema": { + "$ref": "#/definitions/detailServiceEnvelope" + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "404": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "put": { + "description": "Update all fields on a service by id. Requires admin access.", + "tags": [ + "Service" + ], + "summary": "Update all fields on a service", + "operationId": "updateService", + "parameters": [ + { + "description": "A service update object", + "name": "service", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/serviceUpdate" + } + } + ], + "responses": { + "200": { + "description": "The update request was successful and the resource has been altered", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "404": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "delete": { + "description": "Delete a service by id. Requires admin access.", + "tags": [ + "Service" + ], + "summary": "Delete a service", + "operationId": "deleteService", + "responses": { + "200": { + "description": "The delete request was successful and the resource has been removed", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "409": { + "description": "The resource requested to be removed/altered cannot be as it is referenced by another object.", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "causeMessage": "referenced by /some-resource/05f4f710-c155-4a74-86d5-77558eb9cb42", + "code": "CONFLICT_CANNOT_MODIFY_REFERENCED", + "message": "The resource cannot be deleted/modified. Remove all referencing resources first.", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "patch": { + "description": "Update the supplied fields on a service. Requires admin access.", + "tags": [ + "Service" + ], + "summary": "Update the supplied fields on a service", + "operationId": "patchService", + "parameters": [ + { + "description": "A service patch object", + "name": "service", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/servicePatch" + } + } + ], + "responses": { + "200": { + "description": "The patch request was successful and the resource has been altered", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "404": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "parameters": [ + { + "type": "string", + "description": "The id of the requested resource", + "name": "id", + "in": "path", + "required": true + } + ] + }, + "/services/{id}/terminators": { + "get": { + "description": "Retrieves a list of terminator resources that are assigned specific service; supports filtering, sorting, and pagination.\n", + "tags": [ + "Service" + ], + "summary": "List of terminators assigned to a service", + "operationId": "listServiceTerminators", + "parameters": [ + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "name": "offset", + "in": "query" + }, + { + "type": "string", + "name": "filter", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of terminators", + "schema": { + "$ref": "#/definitions/listTerminatorsEnvelope" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "parameters": [ + { + "type": "string", + "description": "The id of the requested resource", + "name": "id", + "in": "path", + "required": true + } + ] + }, + "/terminators": { + "get": { + "description": "Retrieves a list of terminator resources; supports filtering, sorting, and pagination. Requires admin access.\n", + "tags": [ + "Terminator" + ], + "summary": "List terminators", + "operationId": "listTerminators", + "parameters": [ + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "name": "offset", + "in": "query" + }, + { + "type": "string", + "name": "filter", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A list of terminators", + "schema": { + "$ref": "#/definitions/listTerminatorsEnvelope" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "post": { + "description": "Create a terminator resource. Requires admin access.", + "tags": [ + "Terminator" + ], + "summary": "Create a terminator resource", + "operationId": "createTerminator", + "parameters": [ + { + "description": "A terminator to create", + "name": "terminator", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/terminatorCreate" + } + } + ], + "responses": { + "201": { + "description": "The create request was successful and the resource has been added at the following location", + "schema": { + "$ref": "#/definitions/createEnvelope" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + } + }, + "/terminators/{id}": { + "get": { + "description": "Retrieves a single terminator by id. Requires admin access.", + "tags": [ + "Terminator" + ], + "summary": "Retrieves a single terminator", + "operationId": "detailTerminator", + "responses": { + "200": { + "description": "A single terminator", + "schema": { + "$ref": "#/definitions/detailTerminatorEnvelope" + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "404": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "put": { + "description": "Update all fields on a terminator by id. Requires admin access.", + "tags": [ + "Terminator" + ], + "summary": "Update all fields on a terminator", + "operationId": "updateTerminator", + "parameters": [ + { + "description": "A terminator update object", + "name": "terminator", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/terminatorUpdate" + } + } + ], + "responses": { + "200": { + "description": "The update request was successful and the resource has been altered", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "404": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "delete": { + "description": "Delete a terminator by id. Requires admin access.", + "tags": [ + "Terminator" + ], + "summary": "Delete a terminator", + "operationId": "deleteTerminator", + "responses": { + "200": { + "description": "The delete request was successful and the resource has been removed", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "409": { + "description": "The resource requested to be removed/altered cannot be as it is referenced by another object.", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "causeMessage": "referenced by /some-resource/05f4f710-c155-4a74-86d5-77558eb9cb42", + "code": "CONFLICT_CANNOT_MODIFY_REFERENCED", + "message": "The resource cannot be deleted/modified. Remove all referencing resources first.", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "patch": { + "description": "Update the supplied fields on a terminator. Requires admin access.", + "tags": [ + "Terminator" + ], + "summary": "Update the supplied fields on a terminator", + "operationId": "patchTerminator", + "parameters": [ + { + "description": "A terminator patch object", + "name": "terminator", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/terminatorPatch" + } + } + ], + "responses": { + "200": { + "description": "The patch request was successful and the resource has been altered", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "404": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "parameters": [ + { + "type": "string", + "description": "The id of the requested resource", + "name": "id", + "in": "path", + "required": true + } + ] + } + }, + "definitions": { + "apiError": { + "type": "object", + "properties": { + "args": { + "$ref": "#/definitions/apiErrorArgs" + }, + "cause": { + "$ref": "#/definitions/apiErrorCause" + }, + "causeMessage": { + "type": "string" + }, + "code": { + "type": "string" + }, + "data": { + "type": "object", + "additionalProperties": true + }, + "message": { + "type": "string" + }, + "requestId": { + "type": "string" + } + } + }, + "apiErrorArgs": { + "type": "object", + "properties": { + "urlVars": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "apiErrorCause": { + "allOf": [ + { + "$ref": "#/definitions/apiFieldError" + }, + { + "$ref": "#/definitions/apiError" + } + ] + }, + "apiErrorEnvelope": { + "type": "object", + "required": [ + "meta", + "error" + ], + "properties": { + "error": { + "$ref": "#/definitions/apiError" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "apiFieldError": { + "type": "object", + "properties": { + "field": { + "type": "string" + }, + "reason": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "baseEntity": { + "description": "Fields shared by all Edge API entities", + "type": "object", + "required": [ + "id", + "createdAt", + "updatedAt", + "_links", + "tags" + ], + "properties": { + "_links": { + "$ref": "#/definitions/links" + }, + "createdAt": { + "type": "string", + "format": "date-time" + }, + "id": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + }, + "updatedAt": { + "type": "string", + "format": "date-time" + } + } + }, + "createEnvelope": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/createLocation" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "createLocation": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/definitions/links" + }, + "id": { + "type": "string" + } + } + }, + "detailRouterEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/routerDetail" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "detailServiceEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/serviceDetail" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "detailTerminatorEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/terminatorDetail" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "empty": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "type": "object", + "example": {} + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "entityRef": { + "description": "A reference to another resource and links to interact with it", + "type": "object", + "properties": { + "_links": { + "$ref": "#/definitions/links" + }, + "entity": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "link": { + "description": "A link to another resource", + "type": "object", + "required": [ + "href" + ], + "properties": { + "comment": { + "type": "string" + }, + "href": { + "type": "string", + "format": "uri" + }, + "method": { + "type": "string" + } + } + }, + "links": { + "description": "A map of named links", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/link" + }, + "x-omitempty": false + }, + "listRoutersEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/routerList" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "listServicesEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/serviceList" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "listTerminatorsEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/terminatorList" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "meta": { + "type": "object", + "properties": { + "apiEnrollmentVersion": { + "type": "string" + }, + "apiVersion": { + "type": "string" + }, + "filterableFields": { + "type": "array", + "items": { + "type": "string" + }, + "x-omitempty": true + }, + "pagination": { + "$ref": "#/definitions/pagination" + } + } + }, + "pagination": { + "type": "object", + "required": [ + "limit", + "offset", + "totalCount" + ], + "properties": { + "limit": { + "type": "number", + "format": "int64" + }, + "offset": { + "type": "number", + "format": "int64" + }, + "totalCount": { + "type": "number", + "format": "int64" + } + } + }, + "routerCreate": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "fingerprint": { + "type": "string", + "x-nullable": true + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + } + } + }, + "routerDetail": { + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/baseEntity" + }, + { + "type": "object", + "required": [ + "name", + "fingerprint", + "connected" + ], + "properties": { + "connected": { + "type": "boolean" + }, + "fingerprint": { + "type": "string" + }, + "listenerAddress": { + "type": "string" + }, + "name": { + "type": "string" + }, + "versionInfo": { + "$ref": "#/definitions/versionInfo" + } + } + } + ] + }, + "routerList": { + "type": "array", + "items": { + "$ref": "#/definitions/routerDetail" + } + }, + "routerPatch": { + "type": "object", + "properties": { + "fingerprint": { + "type": "string", + "x-nullable": true + }, + "name": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + } + } + }, + "routerUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "fingerprint": { + "type": "string", + "x-nullable": true + }, + "name": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + } + } + }, + "serviceCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + }, + "terminatorStrategy": { + "type": "string" + } + } + }, + "serviceDetail": { + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/baseEntity" + }, + { + "type": "object", + "required": [ + "name", + "terminatorStrategy" + ], + "properties": { + "name": { + "type": "string" + }, + "terminatorStrategy": { + "type": "string" + } + } + } + ] + }, + "serviceList": { + "type": "array", + "items": { + "$ref": "#/definitions/serviceDetail" + } + }, + "servicePatch": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + }, + "terminatorStrategy": { + "type": "string" + } + } + }, + "serviceUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + }, + "terminatorStrategy": { + "type": "string" + } + } + }, + "subTags": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "tags": { + "description": "A map of user defined fields and values. The values are limited to the following types/values: null, string, boolean", + "allOf": [ + { + "$ref": "#/definitions/subTags" + } + ], + "x-nullable": true + }, + "terminatorCost": { + "type": "integer", + "maximum": 65535, + "minimum": 0 + }, + "terminatorCostMap": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/terminatorCost" + } + }, + "terminatorCreate": { + "type": "object", + "required": [ + "service", + "router", + "address", + "binding" + ], + "properties": { + "address": { + "type": "string" + }, + "binding": { + "type": "string" + }, + "cost": { + "$ref": "#/definitions/terminatorCost" + }, + "identity": { + "type": "string" + }, + "identitySecret": { + "type": "string", + "format": "byte" + }, + "precedence": { + "$ref": "#/definitions/terminatorPrecedence" + }, + "router": { + "type": "string" + }, + "service": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + } + } + }, + "terminatorDetail": { + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/baseEntity" + }, + { + "type": "object", + "required": [ + "serviceId", + "service", + "routerId", + "router", + "binding", + "address", + "identity", + "cost", + "precedence", + "dynamicCost" + ], + "properties": { + "address": { + "type": "string" + }, + "binding": { + "type": "string" + }, + "cost": { + "$ref": "#/definitions/terminatorCost" + }, + "dynamicCost": { + "$ref": "#/definitions/terminatorCost" + }, + "identity": { + "type": "string" + }, + "precedence": { + "$ref": "#/definitions/terminatorPrecedence" + }, + "router": { + "$ref": "#/definitions/entityRef" + }, + "routerId": { + "type": "string" + }, + "service": { + "$ref": "#/definitions/entityRef" + }, + "serviceId": { + "type": "string" + } + } + } + ] + }, + "terminatorList": { + "type": "array", + "items": { + "$ref": "#/definitions/terminatorDetail" + } + }, + "terminatorPatch": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "binding": { + "type": "string" + }, + "cost": { + "$ref": "#/definitions/terminatorCost" + }, + "precedence": { + "$ref": "#/definitions/terminatorPrecedence" + }, + "router": { + "type": "string" + }, + "service": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + } + } + }, + "terminatorPrecedence": { + "type": "string", + "enum": [ + "default", + "required", + "failed" + ] + }, + "terminatorPrecedenceMap": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/terminatorPrecedence" + } + }, + "terminatorUpdate": { + "type": "object", + "required": [ + "service", + "router", + "address", + "binding" + ], + "properties": { + "address": { + "type": "string" + }, + "binding": { + "type": "string" + }, + "cost": { + "$ref": "#/definitions/terminatorCost" + }, + "precedence": { + "$ref": "#/definitions/terminatorPrecedence" + }, + "router": { + "type": "string" + }, + "service": { + "type": "string" + }, + "tags": { + "$ref": "#/definitions/tags" + } + } + }, + "versionInfo": { + "description": "Application build information", + "type": "object", + "properties": { + "arch": { + "type": "string" + }, + "buildDate": { + "type": "string" + }, + "os": { + "type": "string" + }, + "revision": { + "type": "string" + }, + "version": { + "type": "string" + } + } + } + }, + "parameters": { + "filter": { + "type": "string", + "name": "filter", + "in": "query" + }, + "id": { + "type": "string", + "description": "The id of the requested resource", + "name": "id", + "in": "path", + "required": true + }, + "limit": { + "type": "integer", + "name": "limit", + "in": "query" + }, + "offset": { + "type": "integer", + "name": "offset", + "in": "query" + } + }, + "responses": { + "badRequestResponse": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "cannotDeleteReferencedResourceResponse": { + "description": "The resource requested to be removed/altered cannot be as it is referenced by another object.", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "causeMessage": "referenced by /some-resource/05f4f710-c155-4a74-86d5-77558eb9cb42", + "code": "CONFLICT_CANNOT_MODIFY_REFERENCED", + "message": "The resource cannot be deleted/modified. Remove all referencing resources first.", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "createResponse": { + "description": "The create request was successful and the resource has been added at the following location", + "schema": { + "$ref": "#/definitions/createEnvelope" + } + }, + "deleteResponse": { + "description": "The delete request was successful and the resource has been removed", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "detailRouter": { + "description": "A single router", + "schema": { + "$ref": "#/definitions/detailRouterEnvelope" + } + }, + "detailService": { + "description": "A single service", + "schema": { + "$ref": "#/definitions/detailServiceEnvelope" + } + }, + "detailTerminator": { + "description": "A single terminator", + "schema": { + "$ref": "#/definitions/detailTerminatorEnvelope" + } + }, + "emptyResponse": { + "description": "Base empty response", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "invalidAuthResponse": { + "description": "The authentication request could not be processed as the credentials are invalid", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "INVALID_AUTH", + "message": "The authentication request failed", + "requestId": "5952ed10-3091-474f-a691-47ebab6990dc" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "listRouters": { + "description": "A list of routers", + "schema": { + "$ref": "#/definitions/listRoutersEnvelope" + } + }, + "listServices": { + "description": "A list of services", + "schema": { + "$ref": "#/definitions/listServicesEnvelope" + } + }, + "listTerminators": { + "description": "A list of terminators", + "schema": { + "$ref": "#/definitions/listTerminatorsEnvelope" + } + }, + "notFoundResponse": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "patchResponse": { + "description": "The patch request was successful and the resource has been altered", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "rateLimitedResponse": { + "description": "The resource requested is rate limited and the rate limit has been exceeded", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "causeMessage": "you have hit a rate limit in the requested operation", + "code": "RATE_LIMITED", + "message": "The resource is rate limited and the rate limit has been exceeded. Please try again later", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "unauthorizedResponse": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "updateResponse": { + "description": "The update request was successful and the resource has been altered", + "schema": { + "$ref": "#/definitions/empty" + } + } + } +}`)) +} diff --git a/rest_server/operations/router/create_router.go b/rest_server/operations/router/create_router.go new file mode 100644 index 000000000..067504a64 --- /dev/null +++ b/rest_server/operations/router/create_router.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateRouterHandlerFunc turns a function with the right signature into a create router handler +type CreateRouterHandlerFunc func(CreateRouterParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateRouterHandlerFunc) Handle(params CreateRouterParams) middleware.Responder { + return fn(params) +} + +// CreateRouterHandler interface for that can handle valid create router params +type CreateRouterHandler interface { + Handle(CreateRouterParams) middleware.Responder +} + +// NewCreateRouter creates a new http.Handler for the create router operation +func NewCreateRouter(ctx *middleware.Context, handler CreateRouterHandler) *CreateRouter { + return &CreateRouter{Context: ctx, Handler: handler} +} + +/* CreateRouter swagger:route POST /routers Router createRouter + +Create a router resource + +Create a router resource. Requires admin access. + +*/ +type CreateRouter struct { + Context *middleware.Context + Handler CreateRouterHandler +} + +func (o *CreateRouter) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateRouterParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/router/create_router_parameters.go b/rest_server/operations/router/create_router_parameters.go new file mode 100644 index 000000000..8fcb2d52f --- /dev/null +++ b/rest_server/operations/router/create_router_parameters.go @@ -0,0 +1,109 @@ +// 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" + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/validate" + + "github.com/openziti/fabric/rest_model" +) + +// NewCreateRouterParams creates a new CreateRouterParams object +// +// There are no default values defined in the spec. +func NewCreateRouterParams() CreateRouterParams { + + return CreateRouterParams{} +} + +// CreateRouterParams contains all the bound params for the create router operation +// typically these are obtained from a http.Request +// +// swagger:parameters createRouter +type CreateRouterParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*A router to create + Required: true + In: body + */ + Router *rest_model.RouterCreate +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateRouterParams() beforehand. +func (o *CreateRouterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body rest_model.RouterCreate + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("router", "body", "")) + } else { + res = append(res, errors.NewParseError("router", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(context.Background()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Router = &body + } + } + } else { + res = append(res, errors.Required("router", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_server/operations/router/create_router_responses.go b/rest_server/operations/router/create_router_responses.go new file mode 100644 index 000000000..c293ca3bb --- /dev/null +++ b/rest_server/operations/router/create_router_responses.go @@ -0,0 +1,170 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// CreateRouterCreatedCode is the HTTP code returned for type CreateRouterCreated +const CreateRouterCreatedCode int = 201 + +/*CreateRouterCreated The create request was successful and the resource has been added at the following location + +swagger:response createRouterCreated +*/ +type CreateRouterCreated struct { + + /* + In: Body + */ + Payload *rest_model.CreateEnvelope `json:"body,omitempty"` +} + +// NewCreateRouterCreated creates CreateRouterCreated with default headers values +func NewCreateRouterCreated() *CreateRouterCreated { + + return &CreateRouterCreated{} +} + +// WithPayload adds the payload to the create router created response +func (o *CreateRouterCreated) WithPayload(payload *rest_model.CreateEnvelope) *CreateRouterCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create router created response +func (o *CreateRouterCreated) SetPayload(payload *rest_model.CreateEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRouterCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRouterBadRequestCode is the HTTP code returned for type CreateRouterBadRequest +const CreateRouterBadRequestCode int = 400 + +/*CreateRouterBadRequest 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 + +swagger:response createRouterBadRequest +*/ +type CreateRouterBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewCreateRouterBadRequest creates CreateRouterBadRequest with default headers values +func NewCreateRouterBadRequest() *CreateRouterBadRequest { + + return &CreateRouterBadRequest{} +} + +// WithPayload adds the payload to the create router bad request response +func (o *CreateRouterBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *CreateRouterBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create router bad request response +func (o *CreateRouterBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRouterBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRouterUnauthorizedCode is the HTTP code returned for type CreateRouterUnauthorized +const CreateRouterUnauthorizedCode int = 401 + +/*CreateRouterUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response createRouterUnauthorized +*/ +type CreateRouterUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewCreateRouterUnauthorized creates CreateRouterUnauthorized with default headers values +func NewCreateRouterUnauthorized() *CreateRouterUnauthorized { + + return &CreateRouterUnauthorized{} +} + +// WithPayload adds the payload to the create router unauthorized response +func (o *CreateRouterUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *CreateRouterUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create router unauthorized response +func (o *CreateRouterUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRouterUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/router/create_router_urlbuilder.go b/rest_server/operations/router/create_router_urlbuilder.go new file mode 100644 index 000000000..be9126018 --- /dev/null +++ b/rest_server/operations/router/create_router_urlbuilder.go @@ -0,0 +1,111 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateRouterURL generates an URL for the create router operation +type CreateRouterURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateRouterURL) WithBasePath(bp string) *CreateRouterURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateRouterURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateRouterURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/routers" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateRouterURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateRouterURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateRouterURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateRouterURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateRouterURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateRouterURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/router/delete_router.go b/rest_server/operations/router/delete_router.go new file mode 100644 index 000000000..7d04b63ee --- /dev/null +++ b/rest_server/operations/router/delete_router.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteRouterHandlerFunc turns a function with the right signature into a delete router handler +type DeleteRouterHandlerFunc func(DeleteRouterParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteRouterHandlerFunc) Handle(params DeleteRouterParams) middleware.Responder { + return fn(params) +} + +// DeleteRouterHandler interface for that can handle valid delete router params +type DeleteRouterHandler interface { + Handle(DeleteRouterParams) middleware.Responder +} + +// NewDeleteRouter creates a new http.Handler for the delete router operation +func NewDeleteRouter(ctx *middleware.Context, handler DeleteRouterHandler) *DeleteRouter { + return &DeleteRouter{Context: ctx, Handler: handler} +} + +/* DeleteRouter swagger:route DELETE /routers/{id} Router deleteRouter + +Delete a router + +Delete a router by id. Requires admin access. + +*/ +type DeleteRouter struct { + Context *middleware.Context + Handler DeleteRouterHandler +} + +func (o *DeleteRouter) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteRouterParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/router/delete_router_parameters.go b/rest_server/operations/router/delete_router_parameters.go new file mode 100644 index 000000000..f96a3eac1 --- /dev/null +++ b/rest_server/operations/router/delete_router_parameters.go @@ -0,0 +1,95 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteRouterParams creates a new DeleteRouterParams object +// +// There are no default values defined in the spec. +func NewDeleteRouterParams() DeleteRouterParams { + + return DeleteRouterParams{} +} + +// DeleteRouterParams contains all the bound params for the delete router operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteRouter +type DeleteRouterParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteRouterParams() beforehand. +func (o *DeleteRouterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DeleteRouterParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/router/delete_router_responses.go b/rest_server/operations/router/delete_router_responses.go new file mode 100644 index 000000000..7373bcf22 --- /dev/null +++ b/rest_server/operations/router/delete_router_responses.go @@ -0,0 +1,214 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// DeleteRouterOKCode is the HTTP code returned for type DeleteRouterOK +const DeleteRouterOKCode int = 200 + +/*DeleteRouterOK The delete request was successful and the resource has been removed + +swagger:response deleteRouterOK +*/ +type DeleteRouterOK struct { + + /* + In: Body + */ + Payload *rest_model.Empty `json:"body,omitempty"` +} + +// NewDeleteRouterOK creates DeleteRouterOK with default headers values +func NewDeleteRouterOK() *DeleteRouterOK { + + return &DeleteRouterOK{} +} + +// WithPayload adds the payload to the delete router o k response +func (o *DeleteRouterOK) WithPayload(payload *rest_model.Empty) *DeleteRouterOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete router o k response +func (o *DeleteRouterOK) SetPayload(payload *rest_model.Empty) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRouterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRouterBadRequestCode is the HTTP code returned for type DeleteRouterBadRequest +const DeleteRouterBadRequestCode int = 400 + +/*DeleteRouterBadRequest 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 + +swagger:response deleteRouterBadRequest +*/ +type DeleteRouterBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDeleteRouterBadRequest creates DeleteRouterBadRequest with default headers values +func NewDeleteRouterBadRequest() *DeleteRouterBadRequest { + + return &DeleteRouterBadRequest{} +} + +// WithPayload adds the payload to the delete router bad request response +func (o *DeleteRouterBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *DeleteRouterBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete router bad request response +func (o *DeleteRouterBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRouterBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRouterUnauthorizedCode is the HTTP code returned for type DeleteRouterUnauthorized +const DeleteRouterUnauthorizedCode int = 401 + +/*DeleteRouterUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response deleteRouterUnauthorized +*/ +type DeleteRouterUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDeleteRouterUnauthorized creates DeleteRouterUnauthorized with default headers values +func NewDeleteRouterUnauthorized() *DeleteRouterUnauthorized { + + return &DeleteRouterUnauthorized{} +} + +// WithPayload adds the payload to the delete router unauthorized response +func (o *DeleteRouterUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *DeleteRouterUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete router unauthorized response +func (o *DeleteRouterUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRouterUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRouterConflictCode is the HTTP code returned for type DeleteRouterConflict +const DeleteRouterConflictCode int = 409 + +/*DeleteRouterConflict The resource requested to be removed/altered cannot be as it is referenced by another object. + +swagger:response deleteRouterConflict +*/ +type DeleteRouterConflict struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDeleteRouterConflict creates DeleteRouterConflict with default headers values +func NewDeleteRouterConflict() *DeleteRouterConflict { + + return &DeleteRouterConflict{} +} + +// WithPayload adds the payload to the delete router conflict response +func (o *DeleteRouterConflict) WithPayload(payload *rest_model.APIErrorEnvelope) *DeleteRouterConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete router conflict response +func (o *DeleteRouterConflict) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRouterConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/router/delete_router_urlbuilder.go b/rest_server/operations/router/delete_router_urlbuilder.go new file mode 100644 index 000000000..8ba331684 --- /dev/null +++ b/rest_server/operations/router/delete_router_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteRouterURL generates an URL for the delete router operation +type DeleteRouterURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRouterURL) WithBasePath(bp string) *DeleteRouterURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRouterURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteRouterURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/routers/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DeleteRouterURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteRouterURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteRouterURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteRouterURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteRouterURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteRouterURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteRouterURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/router/detail_router.go b/rest_server/operations/router/detail_router.go new file mode 100644 index 000000000..c62df96c5 --- /dev/null +++ b/rest_server/operations/router/detail_router.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DetailRouterHandlerFunc turns a function with the right signature into a detail router handler +type DetailRouterHandlerFunc func(DetailRouterParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DetailRouterHandlerFunc) Handle(params DetailRouterParams) middleware.Responder { + return fn(params) +} + +// DetailRouterHandler interface for that can handle valid detail router params +type DetailRouterHandler interface { + Handle(DetailRouterParams) middleware.Responder +} + +// NewDetailRouter creates a new http.Handler for the detail router operation +func NewDetailRouter(ctx *middleware.Context, handler DetailRouterHandler) *DetailRouter { + return &DetailRouter{Context: ctx, Handler: handler} +} + +/* DetailRouter swagger:route GET /routers/{id} Router detailRouter + +Retrieves a single router + +Retrieves a single router by id. Requires admin access. + +*/ +type DetailRouter struct { + Context *middleware.Context + Handler DetailRouterHandler +} + +func (o *DetailRouter) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDetailRouterParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/router/detail_router_parameters.go b/rest_server/operations/router/detail_router_parameters.go new file mode 100644 index 000000000..f1080bd1a --- /dev/null +++ b/rest_server/operations/router/detail_router_parameters.go @@ -0,0 +1,95 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDetailRouterParams creates a new DetailRouterParams object +// +// There are no default values defined in the spec. +func NewDetailRouterParams() DetailRouterParams { + + return DetailRouterParams{} +} + +// DetailRouterParams contains all the bound params for the detail router operation +// typically these are obtained from a http.Request +// +// swagger:parameters detailRouter +type DetailRouterParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDetailRouterParams() beforehand. +func (o *DetailRouterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DetailRouterParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/router/detail_router_responses.go b/rest_server/operations/router/detail_router_responses.go new file mode 100644 index 000000000..a29a2eed6 --- /dev/null +++ b/rest_server/operations/router/detail_router_responses.go @@ -0,0 +1,170 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// DetailRouterOKCode is the HTTP code returned for type DetailRouterOK +const DetailRouterOKCode int = 200 + +/*DetailRouterOK A single router + +swagger:response detailRouterOK +*/ +type DetailRouterOK struct { + + /* + In: Body + */ + Payload *rest_model.DetailRouterEnvelope `json:"body,omitempty"` +} + +// NewDetailRouterOK creates DetailRouterOK with default headers values +func NewDetailRouterOK() *DetailRouterOK { + + return &DetailRouterOK{} +} + +// WithPayload adds the payload to the detail router o k response +func (o *DetailRouterOK) WithPayload(payload *rest_model.DetailRouterEnvelope) *DetailRouterOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail router o k response +func (o *DetailRouterOK) SetPayload(payload *rest_model.DetailRouterEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailRouterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DetailRouterUnauthorizedCode is the HTTP code returned for type DetailRouterUnauthorized +const DetailRouterUnauthorizedCode int = 401 + +/*DetailRouterUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response detailRouterUnauthorized +*/ +type DetailRouterUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDetailRouterUnauthorized creates DetailRouterUnauthorized with default headers values +func NewDetailRouterUnauthorized() *DetailRouterUnauthorized { + + return &DetailRouterUnauthorized{} +} + +// WithPayload adds the payload to the detail router unauthorized response +func (o *DetailRouterUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *DetailRouterUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail router unauthorized response +func (o *DetailRouterUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailRouterUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DetailRouterNotFoundCode is the HTTP code returned for type DetailRouterNotFound +const DetailRouterNotFoundCode int = 404 + +/*DetailRouterNotFound The requested resource does not exist + +swagger:response detailRouterNotFound +*/ +type DetailRouterNotFound struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDetailRouterNotFound creates DetailRouterNotFound with default headers values +func NewDetailRouterNotFound() *DetailRouterNotFound { + + return &DetailRouterNotFound{} +} + +// WithPayload adds the payload to the detail router not found response +func (o *DetailRouterNotFound) WithPayload(payload *rest_model.APIErrorEnvelope) *DetailRouterNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail router not found response +func (o *DetailRouterNotFound) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailRouterNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/router/detail_router_urlbuilder.go b/rest_server/operations/router/detail_router_urlbuilder.go new file mode 100644 index 000000000..f78dd2877 --- /dev/null +++ b/rest_server/operations/router/detail_router_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DetailRouterURL generates an URL for the detail router operation +type DetailRouterURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DetailRouterURL) WithBasePath(bp string) *DetailRouterURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DetailRouterURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DetailRouterURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/routers/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DetailRouterURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DetailRouterURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DetailRouterURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DetailRouterURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DetailRouterURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DetailRouterURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DetailRouterURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/router/list_router_terminators.go b/rest_server/operations/router/list_router_terminators.go new file mode 100644 index 000000000..7361e2034 --- /dev/null +++ b/rest_server/operations/router/list_router_terminators.go @@ -0,0 +1,83 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListRouterTerminatorsHandlerFunc turns a function with the right signature into a list router terminators handler +type ListRouterTerminatorsHandlerFunc func(ListRouterTerminatorsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListRouterTerminatorsHandlerFunc) Handle(params ListRouterTerminatorsParams) middleware.Responder { + return fn(params) +} + +// ListRouterTerminatorsHandler interface for that can handle valid list router terminators params +type ListRouterTerminatorsHandler interface { + Handle(ListRouterTerminatorsParams) middleware.Responder +} + +// NewListRouterTerminators creates a new http.Handler for the list router terminators operation +func NewListRouterTerminators(ctx *middleware.Context, handler ListRouterTerminatorsHandler) *ListRouterTerminators { + return &ListRouterTerminators{Context: ctx, Handler: handler} +} + +/* ListRouterTerminators swagger:route GET /routers/{id}/terminators Router listRouterTerminators + +List of terminators assigned to a router + +Retrieves a list of terminator resources that are assigned specific router; supports filtering, sorting, and pagination. + + +*/ +type ListRouterTerminators struct { + Context *middleware.Context + Handler ListRouterTerminatorsHandler +} + +func (o *ListRouterTerminators) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewListRouterTerminatorsParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/router/list_router_terminators_parameters.go b/rest_server/operations/router/list_router_terminators_parameters.go new file mode 100644 index 000000000..0f04a1ded --- /dev/null +++ b/rest_server/operations/router/list_router_terminators_parameters.go @@ -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 router + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewListRouterTerminatorsParams creates a new ListRouterTerminatorsParams object +// +// There are no default values defined in the spec. +func NewListRouterTerminatorsParams() ListRouterTerminatorsParams { + + return ListRouterTerminatorsParams{} +} + +// ListRouterTerminatorsParams contains all the bound params for the list router terminators operation +// typically these are obtained from a http.Request +// +// swagger:parameters listRouterTerminators +type ListRouterTerminatorsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: query + */ + Filter *string + /*The id of the requested resource + Required: true + In: path + */ + ID string + /* + In: query + */ + Limit *int64 + /* + In: query + */ + Offset *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListRouterTerminatorsParams() beforehand. +func (o *ListRouterTerminatorsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFilter, qhkFilter, _ := qs.GetOK("filter") + if err := o.bindFilter(qFilter, qhkFilter, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + qLimit, qhkLimit, _ := qs.GetOK("limit") + if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil { + res = append(res, err) + } + + qOffset, qhkOffset, _ := qs.GetOK("offset") + if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFilter binds and validates parameter Filter from query. +func (o *ListRouterTerminatorsParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Filter = &raw + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *ListRouterTerminatorsParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} + +// bindLimit binds and validates parameter Limit from query. +func (o *ListRouterTerminatorsParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("limit", "query", "int64", raw) + } + o.Limit = &value + + return nil +} + +// bindOffset binds and validates parameter Offset from query. +func (o *ListRouterTerminatorsParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("offset", "query", "int64", raw) + } + o.Offset = &value + + return nil +} diff --git a/rest_server/operations/router/list_router_terminators_responses.go b/rest_server/operations/router/list_router_terminators_responses.go new file mode 100644 index 000000000..45ecb28b5 --- /dev/null +++ b/rest_server/operations/router/list_router_terminators_responses.go @@ -0,0 +1,170 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// ListRouterTerminatorsOKCode is the HTTP code returned for type ListRouterTerminatorsOK +const ListRouterTerminatorsOKCode int = 200 + +/*ListRouterTerminatorsOK A list of terminators + +swagger:response listRouterTerminatorsOK +*/ +type ListRouterTerminatorsOK struct { + + /* + In: Body + */ + Payload *rest_model.ListTerminatorsEnvelope `json:"body,omitempty"` +} + +// NewListRouterTerminatorsOK creates ListRouterTerminatorsOK with default headers values +func NewListRouterTerminatorsOK() *ListRouterTerminatorsOK { + + return &ListRouterTerminatorsOK{} +} + +// WithPayload adds the payload to the list router terminators o k response +func (o *ListRouterTerminatorsOK) WithPayload(payload *rest_model.ListTerminatorsEnvelope) *ListRouterTerminatorsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list router terminators o k response +func (o *ListRouterTerminatorsOK) SetPayload(payload *rest_model.ListTerminatorsEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRouterTerminatorsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRouterTerminatorsBadRequestCode is the HTTP code returned for type ListRouterTerminatorsBadRequest +const ListRouterTerminatorsBadRequestCode int = 400 + +/*ListRouterTerminatorsBadRequest 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 + +swagger:response listRouterTerminatorsBadRequest +*/ +type ListRouterTerminatorsBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListRouterTerminatorsBadRequest creates ListRouterTerminatorsBadRequest with default headers values +func NewListRouterTerminatorsBadRequest() *ListRouterTerminatorsBadRequest { + + return &ListRouterTerminatorsBadRequest{} +} + +// WithPayload adds the payload to the list router terminators bad request response +func (o *ListRouterTerminatorsBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *ListRouterTerminatorsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list router terminators bad request response +func (o *ListRouterTerminatorsBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRouterTerminatorsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRouterTerminatorsUnauthorizedCode is the HTTP code returned for type ListRouterTerminatorsUnauthorized +const ListRouterTerminatorsUnauthorizedCode int = 401 + +/*ListRouterTerminatorsUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listRouterTerminatorsUnauthorized +*/ +type ListRouterTerminatorsUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListRouterTerminatorsUnauthorized creates ListRouterTerminatorsUnauthorized with default headers values +func NewListRouterTerminatorsUnauthorized() *ListRouterTerminatorsUnauthorized { + + return &ListRouterTerminatorsUnauthorized{} +} + +// WithPayload adds the payload to the list router terminators unauthorized response +func (o *ListRouterTerminatorsUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListRouterTerminatorsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list router terminators unauthorized response +func (o *ListRouterTerminatorsUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRouterTerminatorsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/router/list_router_terminators_urlbuilder.go b/rest_server/operations/router/list_router_terminators_urlbuilder.go new file mode 100644 index 000000000..873fef6ec --- /dev/null +++ b/rest_server/operations/router/list_router_terminators_urlbuilder.go @@ -0,0 +1,157 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListRouterTerminatorsURL generates an URL for the list router terminators operation +type ListRouterTerminatorsURL struct { + ID string + + Filter *string + Limit *int64 + Offset *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRouterTerminatorsURL) WithBasePath(bp string) *ListRouterTerminatorsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRouterTerminatorsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListRouterTerminatorsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/routers/{id}/terminators" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on ListRouterTerminatorsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var filterQ string + if o.Filter != nil { + filterQ = *o.Filter + } + if filterQ != "" { + qs.Set("filter", filterQ) + } + + var limitQ string + if o.Limit != nil { + limitQ = swag.FormatInt64(*o.Limit) + } + if limitQ != "" { + qs.Set("limit", limitQ) + } + + var offsetQ string + if o.Offset != nil { + offsetQ = swag.FormatInt64(*o.Offset) + } + if offsetQ != "" { + qs.Set("offset", offsetQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListRouterTerminatorsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListRouterTerminatorsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListRouterTerminatorsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListRouterTerminatorsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListRouterTerminatorsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListRouterTerminatorsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/router/list_routers.go b/rest_server/operations/router/list_routers.go new file mode 100644 index 000000000..9dfb76fd8 --- /dev/null +++ b/rest_server/operations/router/list_routers.go @@ -0,0 +1,83 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListRoutersHandlerFunc turns a function with the right signature into a list routers handler +type ListRoutersHandlerFunc func(ListRoutersParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListRoutersHandlerFunc) Handle(params ListRoutersParams) middleware.Responder { + return fn(params) +} + +// ListRoutersHandler interface for that can handle valid list routers params +type ListRoutersHandler interface { + Handle(ListRoutersParams) middleware.Responder +} + +// NewListRouters creates a new http.Handler for the list routers operation +func NewListRouters(ctx *middleware.Context, handler ListRoutersHandler) *ListRouters { + return &ListRouters{Context: ctx, Handler: handler} +} + +/* ListRouters swagger:route GET /routers Router listRouters + +List routers + +Retrieves a list of router resources; supports filtering, sorting, and pagination. Requires admin access. + + +*/ +type ListRouters struct { + Context *middleware.Context + Handler ListRoutersHandler +} + +func (o *ListRouters) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewListRoutersParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/router/list_routers_parameters.go b/rest_server/operations/router/list_routers_parameters.go new file mode 100644 index 000000000..7fa1c0196 --- /dev/null +++ b/rest_server/operations/router/list_routers_parameters.go @@ -0,0 +1,166 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewListRoutersParams creates a new ListRoutersParams object +// +// There are no default values defined in the spec. +func NewListRoutersParams() ListRoutersParams { + + return ListRoutersParams{} +} + +// ListRoutersParams contains all the bound params for the list routers operation +// typically these are obtained from a http.Request +// +// swagger:parameters listRouters +type ListRoutersParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: query + */ + Filter *string + /* + In: query + */ + Limit *int64 + /* + In: query + */ + Offset *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListRoutersParams() beforehand. +func (o *ListRoutersParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFilter, qhkFilter, _ := qs.GetOK("filter") + if err := o.bindFilter(qFilter, qhkFilter, route.Formats); err != nil { + res = append(res, err) + } + + qLimit, qhkLimit, _ := qs.GetOK("limit") + if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil { + res = append(res, err) + } + + qOffset, qhkOffset, _ := qs.GetOK("offset") + if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFilter binds and validates parameter Filter from query. +func (o *ListRoutersParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Filter = &raw + + return nil +} + +// bindLimit binds and validates parameter Limit from query. +func (o *ListRoutersParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("limit", "query", "int64", raw) + } + o.Limit = &value + + return nil +} + +// bindOffset binds and validates parameter Offset from query. +func (o *ListRoutersParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("offset", "query", "int64", raw) + } + o.Offset = &value + + return nil +} diff --git a/rest_server/operations/router/list_routers_responses.go b/rest_server/operations/router/list_routers_responses.go new file mode 100644 index 000000000..e639edee9 --- /dev/null +++ b/rest_server/operations/router/list_routers_responses.go @@ -0,0 +1,126 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// ListRoutersOKCode is the HTTP code returned for type ListRoutersOK +const ListRoutersOKCode int = 200 + +/*ListRoutersOK A list of routers + +swagger:response listRoutersOK +*/ +type ListRoutersOK struct { + + /* + In: Body + */ + Payload *rest_model.ListRoutersEnvelope `json:"body,omitempty"` +} + +// NewListRoutersOK creates ListRoutersOK with default headers values +func NewListRoutersOK() *ListRoutersOK { + + return &ListRoutersOK{} +} + +// WithPayload adds the payload to the list routers o k response +func (o *ListRoutersOK) WithPayload(payload *rest_model.ListRoutersEnvelope) *ListRoutersOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list routers o k response +func (o *ListRoutersOK) SetPayload(payload *rest_model.ListRoutersEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRoutersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListRoutersUnauthorizedCode is the HTTP code returned for type ListRoutersUnauthorized +const ListRoutersUnauthorizedCode int = 401 + +/*ListRoutersUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listRoutersUnauthorized +*/ +type ListRoutersUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListRoutersUnauthorized creates ListRoutersUnauthorized with default headers values +func NewListRoutersUnauthorized() *ListRoutersUnauthorized { + + return &ListRoutersUnauthorized{} +} + +// WithPayload adds the payload to the list routers unauthorized response +func (o *ListRoutersUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListRoutersUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list routers unauthorized response +func (o *ListRoutersUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListRoutersUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/router/list_routers_urlbuilder.go b/rest_server/operations/router/list_routers_urlbuilder.go new file mode 100644 index 000000000..8b9c5ebdc --- /dev/null +++ b/rest_server/operations/router/list_routers_urlbuilder.go @@ -0,0 +1,147 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListRoutersURL generates an URL for the list routers operation +type ListRoutersURL struct { + Filter *string + Limit *int64 + Offset *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRoutersURL) WithBasePath(bp string) *ListRoutersURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListRoutersURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListRoutersURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/routers" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var filterQ string + if o.Filter != nil { + filterQ = *o.Filter + } + if filterQ != "" { + qs.Set("filter", filterQ) + } + + var limitQ string + if o.Limit != nil { + limitQ = swag.FormatInt64(*o.Limit) + } + if limitQ != "" { + qs.Set("limit", limitQ) + } + + var offsetQ string + if o.Offset != nil { + offsetQ = swag.FormatInt64(*o.Offset) + } + if offsetQ != "" { + qs.Set("offset", offsetQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListRoutersURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListRoutersURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListRoutersURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListRoutersURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListRoutersURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListRoutersURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/service/create_service.go b/rest_server/operations/service/create_service.go new file mode 100644 index 000000000..edb2daaa1 --- /dev/null +++ b/rest_server/operations/service/create_service.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateServiceHandlerFunc turns a function with the right signature into a create service handler +type CreateServiceHandlerFunc func(CreateServiceParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateServiceHandlerFunc) Handle(params CreateServiceParams) middleware.Responder { + return fn(params) +} + +// CreateServiceHandler interface for that can handle valid create service params +type CreateServiceHandler interface { + Handle(CreateServiceParams) middleware.Responder +} + +// NewCreateService creates a new http.Handler for the create service operation +func NewCreateService(ctx *middleware.Context, handler CreateServiceHandler) *CreateService { + return &CreateService{Context: ctx, Handler: handler} +} + +/* CreateService swagger:route POST /services Service createService + +Create a service resource + +Create a service resource. Requires admin access. + +*/ +type CreateService struct { + Context *middleware.Context + Handler CreateServiceHandler +} + +func (o *CreateService) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateServiceParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/service/create_service_parameters.go b/rest_server/operations/service/create_service_parameters.go new file mode 100644 index 000000000..7e343683c --- /dev/null +++ b/rest_server/operations/service/create_service_parameters.go @@ -0,0 +1,109 @@ +// 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" + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/validate" + + "github.com/openziti/fabric/rest_model" +) + +// NewCreateServiceParams creates a new CreateServiceParams object +// +// There are no default values defined in the spec. +func NewCreateServiceParams() CreateServiceParams { + + return CreateServiceParams{} +} + +// CreateServiceParams contains all the bound params for the create service operation +// typically these are obtained from a http.Request +// +// swagger:parameters createService +type CreateServiceParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*A service to create + Required: true + In: body + */ + Service *rest_model.ServiceCreate +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateServiceParams() beforehand. +func (o *CreateServiceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body rest_model.ServiceCreate + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("service", "body", "")) + } else { + res = append(res, errors.NewParseError("service", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(context.Background()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Service = &body + } + } + } else { + res = append(res, errors.Required("service", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_server/operations/service/create_service_responses.go b/rest_server/operations/service/create_service_responses.go new file mode 100644 index 000000000..06ae021ff --- /dev/null +++ b/rest_server/operations/service/create_service_responses.go @@ -0,0 +1,170 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// CreateServiceCreatedCode is the HTTP code returned for type CreateServiceCreated +const CreateServiceCreatedCode int = 201 + +/*CreateServiceCreated The create request was successful and the resource has been added at the following location + +swagger:response createServiceCreated +*/ +type CreateServiceCreated struct { + + /* + In: Body + */ + Payload *rest_model.CreateEnvelope `json:"body,omitempty"` +} + +// NewCreateServiceCreated creates CreateServiceCreated with default headers values +func NewCreateServiceCreated() *CreateServiceCreated { + + return &CreateServiceCreated{} +} + +// WithPayload adds the payload to the create service created response +func (o *CreateServiceCreated) WithPayload(payload *rest_model.CreateEnvelope) *CreateServiceCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create service created response +func (o *CreateServiceCreated) SetPayload(payload *rest_model.CreateEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServiceCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServiceBadRequestCode is the HTTP code returned for type CreateServiceBadRequest +const CreateServiceBadRequestCode int = 400 + +/*CreateServiceBadRequest 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 + +swagger:response createServiceBadRequest +*/ +type CreateServiceBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewCreateServiceBadRequest creates CreateServiceBadRequest with default headers values +func NewCreateServiceBadRequest() *CreateServiceBadRequest { + + return &CreateServiceBadRequest{} +} + +// WithPayload adds the payload to the create service bad request response +func (o *CreateServiceBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *CreateServiceBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create service bad request response +func (o *CreateServiceBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServiceBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServiceUnauthorizedCode is the HTTP code returned for type CreateServiceUnauthorized +const CreateServiceUnauthorizedCode int = 401 + +/*CreateServiceUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response createServiceUnauthorized +*/ +type CreateServiceUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewCreateServiceUnauthorized creates CreateServiceUnauthorized with default headers values +func NewCreateServiceUnauthorized() *CreateServiceUnauthorized { + + return &CreateServiceUnauthorized{} +} + +// WithPayload adds the payload to the create service unauthorized response +func (o *CreateServiceUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *CreateServiceUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create service unauthorized response +func (o *CreateServiceUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServiceUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/service/create_service_urlbuilder.go b/rest_server/operations/service/create_service_urlbuilder.go new file mode 100644 index 000000000..a9d69a75a --- /dev/null +++ b/rest_server/operations/service/create_service_urlbuilder.go @@ -0,0 +1,111 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateServiceURL generates an URL for the create service operation +type CreateServiceURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateServiceURL) WithBasePath(bp string) *CreateServiceURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateServiceURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateServiceURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateServiceURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateServiceURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateServiceURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateServiceURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateServiceURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateServiceURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/service/delete_service.go b/rest_server/operations/service/delete_service.go new file mode 100644 index 000000000..14565ca17 --- /dev/null +++ b/rest_server/operations/service/delete_service.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteServiceHandlerFunc turns a function with the right signature into a delete service handler +type DeleteServiceHandlerFunc func(DeleteServiceParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteServiceHandlerFunc) Handle(params DeleteServiceParams) middleware.Responder { + return fn(params) +} + +// DeleteServiceHandler interface for that can handle valid delete service params +type DeleteServiceHandler interface { + Handle(DeleteServiceParams) middleware.Responder +} + +// NewDeleteService creates a new http.Handler for the delete service operation +func NewDeleteService(ctx *middleware.Context, handler DeleteServiceHandler) *DeleteService { + return &DeleteService{Context: ctx, Handler: handler} +} + +/* DeleteService swagger:route DELETE /services/{id} Service deleteService + +Delete a service + +Delete a service by id. Requires admin access. + +*/ +type DeleteService struct { + Context *middleware.Context + Handler DeleteServiceHandler +} + +func (o *DeleteService) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteServiceParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/service/delete_service_parameters.go b/rest_server/operations/service/delete_service_parameters.go new file mode 100644 index 000000000..b58e95631 --- /dev/null +++ b/rest_server/operations/service/delete_service_parameters.go @@ -0,0 +1,95 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteServiceParams creates a new DeleteServiceParams object +// +// There are no default values defined in the spec. +func NewDeleteServiceParams() DeleteServiceParams { + + return DeleteServiceParams{} +} + +// DeleteServiceParams contains all the bound params for the delete service operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteService +type DeleteServiceParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteServiceParams() beforehand. +func (o *DeleteServiceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DeleteServiceParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/service/delete_service_responses.go b/rest_server/operations/service/delete_service_responses.go new file mode 100644 index 000000000..0b55dc487 --- /dev/null +++ b/rest_server/operations/service/delete_service_responses.go @@ -0,0 +1,214 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// DeleteServiceOKCode is the HTTP code returned for type DeleteServiceOK +const DeleteServiceOKCode int = 200 + +/*DeleteServiceOK The delete request was successful and the resource has been removed + +swagger:response deleteServiceOK +*/ +type DeleteServiceOK struct { + + /* + In: Body + */ + Payload *rest_model.Empty `json:"body,omitempty"` +} + +// NewDeleteServiceOK creates DeleteServiceOK with default headers values +func NewDeleteServiceOK() *DeleteServiceOK { + + return &DeleteServiceOK{} +} + +// WithPayload adds the payload to the delete service o k response +func (o *DeleteServiceOK) WithPayload(payload *rest_model.Empty) *DeleteServiceOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete service o k response +func (o *DeleteServiceOK) SetPayload(payload *rest_model.Empty) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServiceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteServiceBadRequestCode is the HTTP code returned for type DeleteServiceBadRequest +const DeleteServiceBadRequestCode int = 400 + +/*DeleteServiceBadRequest 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 + +swagger:response deleteServiceBadRequest +*/ +type DeleteServiceBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDeleteServiceBadRequest creates DeleteServiceBadRequest with default headers values +func NewDeleteServiceBadRequest() *DeleteServiceBadRequest { + + return &DeleteServiceBadRequest{} +} + +// WithPayload adds the payload to the delete service bad request response +func (o *DeleteServiceBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *DeleteServiceBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete service bad request response +func (o *DeleteServiceBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServiceBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteServiceUnauthorizedCode is the HTTP code returned for type DeleteServiceUnauthorized +const DeleteServiceUnauthorizedCode int = 401 + +/*DeleteServiceUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response deleteServiceUnauthorized +*/ +type DeleteServiceUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDeleteServiceUnauthorized creates DeleteServiceUnauthorized with default headers values +func NewDeleteServiceUnauthorized() *DeleteServiceUnauthorized { + + return &DeleteServiceUnauthorized{} +} + +// WithPayload adds the payload to the delete service unauthorized response +func (o *DeleteServiceUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *DeleteServiceUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete service unauthorized response +func (o *DeleteServiceUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServiceUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteServiceConflictCode is the HTTP code returned for type DeleteServiceConflict +const DeleteServiceConflictCode int = 409 + +/*DeleteServiceConflict The resource requested to be removed/altered cannot be as it is referenced by another object. + +swagger:response deleteServiceConflict +*/ +type DeleteServiceConflict struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDeleteServiceConflict creates DeleteServiceConflict with default headers values +func NewDeleteServiceConflict() *DeleteServiceConflict { + + return &DeleteServiceConflict{} +} + +// WithPayload adds the payload to the delete service conflict response +func (o *DeleteServiceConflict) WithPayload(payload *rest_model.APIErrorEnvelope) *DeleteServiceConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete service conflict response +func (o *DeleteServiceConflict) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServiceConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/service/delete_service_urlbuilder.go b/rest_server/operations/service/delete_service_urlbuilder.go new file mode 100644 index 000000000..aa0ed93af --- /dev/null +++ b/rest_server/operations/service/delete_service_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteServiceURL generates an URL for the delete service operation +type DeleteServiceURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteServiceURL) WithBasePath(bp string) *DeleteServiceURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteServiceURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteServiceURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DeleteServiceURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteServiceURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteServiceURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteServiceURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteServiceURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteServiceURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteServiceURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/service/detail_service.go b/rest_server/operations/service/detail_service.go new file mode 100644 index 000000000..993c8aef9 --- /dev/null +++ b/rest_server/operations/service/detail_service.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DetailServiceHandlerFunc turns a function with the right signature into a detail service handler +type DetailServiceHandlerFunc func(DetailServiceParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DetailServiceHandlerFunc) Handle(params DetailServiceParams) middleware.Responder { + return fn(params) +} + +// DetailServiceHandler interface for that can handle valid detail service params +type DetailServiceHandler interface { + Handle(DetailServiceParams) middleware.Responder +} + +// NewDetailService creates a new http.Handler for the detail service operation +func NewDetailService(ctx *middleware.Context, handler DetailServiceHandler) *DetailService { + return &DetailService{Context: ctx, Handler: handler} +} + +/* DetailService swagger:route GET /services/{id} Service detailService + +Retrieves a single service + +Retrieves a single service by id. Requires admin access. + +*/ +type DetailService struct { + Context *middleware.Context + Handler DetailServiceHandler +} + +func (o *DetailService) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDetailServiceParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/service/detail_service_parameters.go b/rest_server/operations/service/detail_service_parameters.go new file mode 100644 index 000000000..c7baaf646 --- /dev/null +++ b/rest_server/operations/service/detail_service_parameters.go @@ -0,0 +1,95 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDetailServiceParams creates a new DetailServiceParams object +// +// There are no default values defined in the spec. +func NewDetailServiceParams() DetailServiceParams { + + return DetailServiceParams{} +} + +// DetailServiceParams contains all the bound params for the detail service operation +// typically these are obtained from a http.Request +// +// swagger:parameters detailService +type DetailServiceParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDetailServiceParams() beforehand. +func (o *DetailServiceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DetailServiceParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/service/detail_service_responses.go b/rest_server/operations/service/detail_service_responses.go new file mode 100644 index 000000000..e85f3083e --- /dev/null +++ b/rest_server/operations/service/detail_service_responses.go @@ -0,0 +1,170 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// DetailServiceOKCode is the HTTP code returned for type DetailServiceOK +const DetailServiceOKCode int = 200 + +/*DetailServiceOK A single service + +swagger:response detailServiceOK +*/ +type DetailServiceOK struct { + + /* + In: Body + */ + Payload *rest_model.DetailServiceEnvelope `json:"body,omitempty"` +} + +// NewDetailServiceOK creates DetailServiceOK with default headers values +func NewDetailServiceOK() *DetailServiceOK { + + return &DetailServiceOK{} +} + +// WithPayload adds the payload to the detail service o k response +func (o *DetailServiceOK) WithPayload(payload *rest_model.DetailServiceEnvelope) *DetailServiceOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail service o k response +func (o *DetailServiceOK) SetPayload(payload *rest_model.DetailServiceEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailServiceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DetailServiceUnauthorizedCode is the HTTP code returned for type DetailServiceUnauthorized +const DetailServiceUnauthorizedCode int = 401 + +/*DetailServiceUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response detailServiceUnauthorized +*/ +type DetailServiceUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDetailServiceUnauthorized creates DetailServiceUnauthorized with default headers values +func NewDetailServiceUnauthorized() *DetailServiceUnauthorized { + + return &DetailServiceUnauthorized{} +} + +// WithPayload adds the payload to the detail service unauthorized response +func (o *DetailServiceUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *DetailServiceUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail service unauthorized response +func (o *DetailServiceUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailServiceUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DetailServiceNotFoundCode is the HTTP code returned for type DetailServiceNotFound +const DetailServiceNotFoundCode int = 404 + +/*DetailServiceNotFound The requested resource does not exist + +swagger:response detailServiceNotFound +*/ +type DetailServiceNotFound struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDetailServiceNotFound creates DetailServiceNotFound with default headers values +func NewDetailServiceNotFound() *DetailServiceNotFound { + + return &DetailServiceNotFound{} +} + +// WithPayload adds the payload to the detail service not found response +func (o *DetailServiceNotFound) WithPayload(payload *rest_model.APIErrorEnvelope) *DetailServiceNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail service not found response +func (o *DetailServiceNotFound) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailServiceNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/service/detail_service_urlbuilder.go b/rest_server/operations/service/detail_service_urlbuilder.go new file mode 100644 index 000000000..b93ea3bab --- /dev/null +++ b/rest_server/operations/service/detail_service_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DetailServiceURL generates an URL for the detail service operation +type DetailServiceURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DetailServiceURL) WithBasePath(bp string) *DetailServiceURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DetailServiceURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DetailServiceURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DetailServiceURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DetailServiceURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DetailServiceURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DetailServiceURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DetailServiceURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DetailServiceURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DetailServiceURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/service/list_service_terminators.go b/rest_server/operations/service/list_service_terminators.go new file mode 100644 index 000000000..571fd5fca --- /dev/null +++ b/rest_server/operations/service/list_service_terminators.go @@ -0,0 +1,83 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListServiceTerminatorsHandlerFunc turns a function with the right signature into a list service terminators handler +type ListServiceTerminatorsHandlerFunc func(ListServiceTerminatorsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListServiceTerminatorsHandlerFunc) Handle(params ListServiceTerminatorsParams) middleware.Responder { + return fn(params) +} + +// ListServiceTerminatorsHandler interface for that can handle valid list service terminators params +type ListServiceTerminatorsHandler interface { + Handle(ListServiceTerminatorsParams) middleware.Responder +} + +// NewListServiceTerminators creates a new http.Handler for the list service terminators operation +func NewListServiceTerminators(ctx *middleware.Context, handler ListServiceTerminatorsHandler) *ListServiceTerminators { + return &ListServiceTerminators{Context: ctx, Handler: handler} +} + +/* ListServiceTerminators swagger:route GET /services/{id}/terminators Service listServiceTerminators + +List of terminators assigned to a service + +Retrieves a list of terminator resources that are assigned specific service; supports filtering, sorting, and pagination. + + +*/ +type ListServiceTerminators struct { + Context *middleware.Context + Handler ListServiceTerminatorsHandler +} + +func (o *ListServiceTerminators) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewListServiceTerminatorsParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/service/list_service_terminators_parameters.go b/rest_server/operations/service/list_service_terminators_parameters.go new file mode 100644 index 000000000..b7d66e76b --- /dev/null +++ b/rest_server/operations/service/list_service_terminators_parameters.go @@ -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 service + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewListServiceTerminatorsParams creates a new ListServiceTerminatorsParams object +// +// There are no default values defined in the spec. +func NewListServiceTerminatorsParams() ListServiceTerminatorsParams { + + return ListServiceTerminatorsParams{} +} + +// ListServiceTerminatorsParams contains all the bound params for the list service terminators operation +// typically these are obtained from a http.Request +// +// swagger:parameters listServiceTerminators +type ListServiceTerminatorsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: query + */ + Filter *string + /*The id of the requested resource + Required: true + In: path + */ + ID string + /* + In: query + */ + Limit *int64 + /* + In: query + */ + Offset *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListServiceTerminatorsParams() beforehand. +func (o *ListServiceTerminatorsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFilter, qhkFilter, _ := qs.GetOK("filter") + if err := o.bindFilter(qFilter, qhkFilter, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + qLimit, qhkLimit, _ := qs.GetOK("limit") + if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil { + res = append(res, err) + } + + qOffset, qhkOffset, _ := qs.GetOK("offset") + if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFilter binds and validates parameter Filter from query. +func (o *ListServiceTerminatorsParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Filter = &raw + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *ListServiceTerminatorsParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} + +// bindLimit binds and validates parameter Limit from query. +func (o *ListServiceTerminatorsParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("limit", "query", "int64", raw) + } + o.Limit = &value + + return nil +} + +// bindOffset binds and validates parameter Offset from query. +func (o *ListServiceTerminatorsParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("offset", "query", "int64", raw) + } + o.Offset = &value + + return nil +} diff --git a/rest_server/operations/service/list_service_terminators_responses.go b/rest_server/operations/service/list_service_terminators_responses.go new file mode 100644 index 000000000..fd798b935 --- /dev/null +++ b/rest_server/operations/service/list_service_terminators_responses.go @@ -0,0 +1,170 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// ListServiceTerminatorsOKCode is the HTTP code returned for type ListServiceTerminatorsOK +const ListServiceTerminatorsOKCode int = 200 + +/*ListServiceTerminatorsOK A list of terminators + +swagger:response listServiceTerminatorsOK +*/ +type ListServiceTerminatorsOK struct { + + /* + In: Body + */ + Payload *rest_model.ListTerminatorsEnvelope `json:"body,omitempty"` +} + +// NewListServiceTerminatorsOK creates ListServiceTerminatorsOK with default headers values +func NewListServiceTerminatorsOK() *ListServiceTerminatorsOK { + + return &ListServiceTerminatorsOK{} +} + +// WithPayload adds the payload to the list service terminators o k response +func (o *ListServiceTerminatorsOK) WithPayload(payload *rest_model.ListTerminatorsEnvelope) *ListServiceTerminatorsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list service terminators o k response +func (o *ListServiceTerminatorsOK) SetPayload(payload *rest_model.ListTerminatorsEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListServiceTerminatorsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListServiceTerminatorsBadRequestCode is the HTTP code returned for type ListServiceTerminatorsBadRequest +const ListServiceTerminatorsBadRequestCode int = 400 + +/*ListServiceTerminatorsBadRequest 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 + +swagger:response listServiceTerminatorsBadRequest +*/ +type ListServiceTerminatorsBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListServiceTerminatorsBadRequest creates ListServiceTerminatorsBadRequest with default headers values +func NewListServiceTerminatorsBadRequest() *ListServiceTerminatorsBadRequest { + + return &ListServiceTerminatorsBadRequest{} +} + +// WithPayload adds the payload to the list service terminators bad request response +func (o *ListServiceTerminatorsBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *ListServiceTerminatorsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list service terminators bad request response +func (o *ListServiceTerminatorsBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListServiceTerminatorsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListServiceTerminatorsUnauthorizedCode is the HTTP code returned for type ListServiceTerminatorsUnauthorized +const ListServiceTerminatorsUnauthorizedCode int = 401 + +/*ListServiceTerminatorsUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listServiceTerminatorsUnauthorized +*/ +type ListServiceTerminatorsUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListServiceTerminatorsUnauthorized creates ListServiceTerminatorsUnauthorized with default headers values +func NewListServiceTerminatorsUnauthorized() *ListServiceTerminatorsUnauthorized { + + return &ListServiceTerminatorsUnauthorized{} +} + +// WithPayload adds the payload to the list service terminators unauthorized response +func (o *ListServiceTerminatorsUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListServiceTerminatorsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list service terminators unauthorized response +func (o *ListServiceTerminatorsUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListServiceTerminatorsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/service/list_service_terminators_urlbuilder.go b/rest_server/operations/service/list_service_terminators_urlbuilder.go new file mode 100644 index 000000000..904ada384 --- /dev/null +++ b/rest_server/operations/service/list_service_terminators_urlbuilder.go @@ -0,0 +1,157 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ListServiceTerminatorsURL generates an URL for the list service terminators operation +type ListServiceTerminatorsURL struct { + ID string + + Filter *string + Limit *int64 + Offset *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListServiceTerminatorsURL) WithBasePath(bp string) *ListServiceTerminatorsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListServiceTerminatorsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListServiceTerminatorsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/{id}/terminators" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on ListServiceTerminatorsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var filterQ string + if o.Filter != nil { + filterQ = *o.Filter + } + if filterQ != "" { + qs.Set("filter", filterQ) + } + + var limitQ string + if o.Limit != nil { + limitQ = swag.FormatInt64(*o.Limit) + } + if limitQ != "" { + qs.Set("limit", limitQ) + } + + var offsetQ string + if o.Offset != nil { + offsetQ = swag.FormatInt64(*o.Offset) + } + if offsetQ != "" { + qs.Set("offset", offsetQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListServiceTerminatorsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListServiceTerminatorsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListServiceTerminatorsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListServiceTerminatorsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListServiceTerminatorsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListServiceTerminatorsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/service/list_services.go b/rest_server/operations/service/list_services.go new file mode 100644 index 000000000..5bb2b9ac0 --- /dev/null +++ b/rest_server/operations/service/list_services.go @@ -0,0 +1,83 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListServicesHandlerFunc turns a function with the right signature into a list services handler +type ListServicesHandlerFunc func(ListServicesParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListServicesHandlerFunc) Handle(params ListServicesParams) middleware.Responder { + return fn(params) +} + +// ListServicesHandler interface for that can handle valid list services params +type ListServicesHandler interface { + Handle(ListServicesParams) middleware.Responder +} + +// NewListServices creates a new http.Handler for the list services operation +func NewListServices(ctx *middleware.Context, handler ListServicesHandler) *ListServices { + return &ListServices{Context: ctx, Handler: handler} +} + +/* ListServices swagger:route GET /services Service listServices + +List services + +Retrieves a list of service resources; supports filtering, sorting, and pagination. Requires admin access. + + +*/ +type ListServices struct { + Context *middleware.Context + Handler ListServicesHandler +} + +func (o *ListServices) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewListServicesParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/service/list_services_parameters.go b/rest_server/operations/service/list_services_parameters.go new file mode 100644 index 000000000..8eb71e07b --- /dev/null +++ b/rest_server/operations/service/list_services_parameters.go @@ -0,0 +1,166 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewListServicesParams creates a new ListServicesParams object +// +// There are no default values defined in the spec. +func NewListServicesParams() ListServicesParams { + + return ListServicesParams{} +} + +// ListServicesParams contains all the bound params for the list services operation +// typically these are obtained from a http.Request +// +// swagger:parameters listServices +type ListServicesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: query + */ + Filter *string + /* + In: query + */ + Limit *int64 + /* + In: query + */ + Offset *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListServicesParams() beforehand. +func (o *ListServicesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFilter, qhkFilter, _ := qs.GetOK("filter") + if err := o.bindFilter(qFilter, qhkFilter, route.Formats); err != nil { + res = append(res, err) + } + + qLimit, qhkLimit, _ := qs.GetOK("limit") + if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil { + res = append(res, err) + } + + qOffset, qhkOffset, _ := qs.GetOK("offset") + if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFilter binds and validates parameter Filter from query. +func (o *ListServicesParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Filter = &raw + + return nil +} + +// bindLimit binds and validates parameter Limit from query. +func (o *ListServicesParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("limit", "query", "int64", raw) + } + o.Limit = &value + + return nil +} + +// bindOffset binds and validates parameter Offset from query. +func (o *ListServicesParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("offset", "query", "int64", raw) + } + o.Offset = &value + + return nil +} diff --git a/rest_server/operations/service/list_services_responses.go b/rest_server/operations/service/list_services_responses.go new file mode 100644 index 000000000..21c2da540 --- /dev/null +++ b/rest_server/operations/service/list_services_responses.go @@ -0,0 +1,126 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// ListServicesOKCode is the HTTP code returned for type ListServicesOK +const ListServicesOKCode int = 200 + +/*ListServicesOK A list of services + +swagger:response listServicesOK +*/ +type ListServicesOK struct { + + /* + In: Body + */ + Payload *rest_model.ListServicesEnvelope `json:"body,omitempty"` +} + +// NewListServicesOK creates ListServicesOK with default headers values +func NewListServicesOK() *ListServicesOK { + + return &ListServicesOK{} +} + +// WithPayload adds the payload to the list services o k response +func (o *ListServicesOK) WithPayload(payload *rest_model.ListServicesEnvelope) *ListServicesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list services o k response +func (o *ListServicesOK) SetPayload(payload *rest_model.ListServicesEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListServicesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListServicesUnauthorizedCode is the HTTP code returned for type ListServicesUnauthorized +const ListServicesUnauthorizedCode int = 401 + +/*ListServicesUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listServicesUnauthorized +*/ +type ListServicesUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListServicesUnauthorized creates ListServicesUnauthorized with default headers values +func NewListServicesUnauthorized() *ListServicesUnauthorized { + + return &ListServicesUnauthorized{} +} + +// WithPayload adds the payload to the list services unauthorized response +func (o *ListServicesUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListServicesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list services unauthorized response +func (o *ListServicesUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListServicesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/service/list_services_urlbuilder.go b/rest_server/operations/service/list_services_urlbuilder.go new file mode 100644 index 000000000..70d04852a --- /dev/null +++ b/rest_server/operations/service/list_services_urlbuilder.go @@ -0,0 +1,147 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListServicesURL generates an URL for the list services operation +type ListServicesURL struct { + Filter *string + Limit *int64 + Offset *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListServicesURL) WithBasePath(bp string) *ListServicesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListServicesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListServicesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var filterQ string + if o.Filter != nil { + filterQ = *o.Filter + } + if filterQ != "" { + qs.Set("filter", filterQ) + } + + var limitQ string + if o.Limit != nil { + limitQ = swag.FormatInt64(*o.Limit) + } + if limitQ != "" { + qs.Set("limit", limitQ) + } + + var offsetQ string + if o.Offset != nil { + offsetQ = swag.FormatInt64(*o.Offset) + } + if offsetQ != "" { + qs.Set("offset", offsetQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListServicesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListServicesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListServicesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListServicesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListServicesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListServicesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/service/patch_service.go b/rest_server/operations/service/patch_service.go new file mode 100644 index 000000000..fdcb4c88d --- /dev/null +++ b/rest_server/operations/service/patch_service.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PatchServiceHandlerFunc turns a function with the right signature into a patch service handler +type PatchServiceHandlerFunc func(PatchServiceParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PatchServiceHandlerFunc) Handle(params PatchServiceParams) middleware.Responder { + return fn(params) +} + +// PatchServiceHandler interface for that can handle valid patch service params +type PatchServiceHandler interface { + Handle(PatchServiceParams) middleware.Responder +} + +// NewPatchService creates a new http.Handler for the patch service operation +func NewPatchService(ctx *middleware.Context, handler PatchServiceHandler) *PatchService { + return &PatchService{Context: ctx, Handler: handler} +} + +/* PatchService swagger:route PATCH /services/{id} Service patchService + +Update the supplied fields on a service + +Update the supplied fields on a service. Requires admin access. + +*/ +type PatchService struct { + Context *middleware.Context + Handler PatchServiceHandler +} + +func (o *PatchService) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPatchServiceParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/service/patch_service_parameters.go b/rest_server/operations/service/patch_service_parameters.go new file mode 100644 index 000000000..cb3e7b33a --- /dev/null +++ b/rest_server/operations/service/patch_service_parameters.go @@ -0,0 +1,134 @@ +// 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" + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/openziti/fabric/rest_model" +) + +// NewPatchServiceParams creates a new PatchServiceParams object +// +// There are no default values defined in the spec. +func NewPatchServiceParams() PatchServiceParams { + + return PatchServiceParams{} +} + +// PatchServiceParams contains all the bound params for the patch service operation +// typically these are obtained from a http.Request +// +// swagger:parameters patchService +type PatchServiceParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string + /*A service patch object + Required: true + In: body + */ + Service *rest_model.ServicePatch +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPatchServiceParams() beforehand. +func (o *PatchServiceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body rest_model.ServicePatch + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("service", "body", "")) + } else { + res = append(res, errors.NewParseError("service", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(context.Background()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Service = &body + } + } + } else { + res = append(res, errors.Required("service", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *PatchServiceParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/service/patch_service_responses.go b/rest_server/operations/service/patch_service_responses.go new file mode 100644 index 000000000..56759ef56 --- /dev/null +++ b/rest_server/operations/service/patch_service_responses.go @@ -0,0 +1,214 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// PatchServiceOKCode is the HTTP code returned for type PatchServiceOK +const PatchServiceOKCode int = 200 + +/*PatchServiceOK The patch request was successful and the resource has been altered + +swagger:response patchServiceOK +*/ +type PatchServiceOK struct { + + /* + In: Body + */ + Payload *rest_model.Empty `json:"body,omitempty"` +} + +// NewPatchServiceOK creates PatchServiceOK with default headers values +func NewPatchServiceOK() *PatchServiceOK { + + return &PatchServiceOK{} +} + +// WithPayload adds the payload to the patch service o k response +func (o *PatchServiceOK) WithPayload(payload *rest_model.Empty) *PatchServiceOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch service o k response +func (o *PatchServiceOK) SetPayload(payload *rest_model.Empty) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchServiceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PatchServiceBadRequestCode is the HTTP code returned for type PatchServiceBadRequest +const PatchServiceBadRequestCode int = 400 + +/*PatchServiceBadRequest 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 + +swagger:response patchServiceBadRequest +*/ +type PatchServiceBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewPatchServiceBadRequest creates PatchServiceBadRequest with default headers values +func NewPatchServiceBadRequest() *PatchServiceBadRequest { + + return &PatchServiceBadRequest{} +} + +// WithPayload adds the payload to the patch service bad request response +func (o *PatchServiceBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *PatchServiceBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch service bad request response +func (o *PatchServiceBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchServiceBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PatchServiceUnauthorizedCode is the HTTP code returned for type PatchServiceUnauthorized +const PatchServiceUnauthorizedCode int = 401 + +/*PatchServiceUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response patchServiceUnauthorized +*/ +type PatchServiceUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewPatchServiceUnauthorized creates PatchServiceUnauthorized with default headers values +func NewPatchServiceUnauthorized() *PatchServiceUnauthorized { + + return &PatchServiceUnauthorized{} +} + +// WithPayload adds the payload to the patch service unauthorized response +func (o *PatchServiceUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *PatchServiceUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch service unauthorized response +func (o *PatchServiceUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchServiceUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PatchServiceNotFoundCode is the HTTP code returned for type PatchServiceNotFound +const PatchServiceNotFoundCode int = 404 + +/*PatchServiceNotFound The requested resource does not exist + +swagger:response patchServiceNotFound +*/ +type PatchServiceNotFound struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewPatchServiceNotFound creates PatchServiceNotFound with default headers values +func NewPatchServiceNotFound() *PatchServiceNotFound { + + return &PatchServiceNotFound{} +} + +// WithPayload adds the payload to the patch service not found response +func (o *PatchServiceNotFound) WithPayload(payload *rest_model.APIErrorEnvelope) *PatchServiceNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch service not found response +func (o *PatchServiceNotFound) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchServiceNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/service/patch_service_urlbuilder.go b/rest_server/operations/service/patch_service_urlbuilder.go new file mode 100644 index 000000000..ac6586018 --- /dev/null +++ b/rest_server/operations/service/patch_service_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// PatchServiceURL generates an URL for the patch service operation +type PatchServiceURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PatchServiceURL) WithBasePath(bp string) *PatchServiceURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PatchServiceURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PatchServiceURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on PatchServiceURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PatchServiceURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PatchServiceURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PatchServiceURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PatchServiceURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PatchServiceURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PatchServiceURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/service/update_service.go b/rest_server/operations/service/update_service.go new file mode 100644 index 000000000..69b6af3cd --- /dev/null +++ b/rest_server/operations/service/update_service.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateServiceHandlerFunc turns a function with the right signature into a update service handler +type UpdateServiceHandlerFunc func(UpdateServiceParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateServiceHandlerFunc) Handle(params UpdateServiceParams) middleware.Responder { + return fn(params) +} + +// UpdateServiceHandler interface for that can handle valid update service params +type UpdateServiceHandler interface { + Handle(UpdateServiceParams) middleware.Responder +} + +// NewUpdateService creates a new http.Handler for the update service operation +func NewUpdateService(ctx *middleware.Context, handler UpdateServiceHandler) *UpdateService { + return &UpdateService{Context: ctx, Handler: handler} +} + +/* UpdateService swagger:route PUT /services/{id} Service updateService + +Update all fields on a service + +Update all fields on a service by id. Requires admin access. + +*/ +type UpdateService struct { + Context *middleware.Context + Handler UpdateServiceHandler +} + +func (o *UpdateService) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewUpdateServiceParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/service/update_service_parameters.go b/rest_server/operations/service/update_service_parameters.go new file mode 100644 index 000000000..3e7eb4f4d --- /dev/null +++ b/rest_server/operations/service/update_service_parameters.go @@ -0,0 +1,134 @@ +// 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" + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/openziti/fabric/rest_model" +) + +// NewUpdateServiceParams creates a new UpdateServiceParams object +// +// There are no default values defined in the spec. +func NewUpdateServiceParams() UpdateServiceParams { + + return UpdateServiceParams{} +} + +// UpdateServiceParams contains all the bound params for the update service operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateService +type UpdateServiceParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string + /*A service update object + Required: true + In: body + */ + Service *rest_model.ServiceUpdate +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateServiceParams() beforehand. +func (o *UpdateServiceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body rest_model.ServiceUpdate + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("service", "body", "")) + } else { + res = append(res, errors.NewParseError("service", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(context.Background()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Service = &body + } + } + } else { + res = append(res, errors.Required("service", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *UpdateServiceParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/service/update_service_responses.go b/rest_server/operations/service/update_service_responses.go new file mode 100644 index 000000000..5e08d7ad5 --- /dev/null +++ b/rest_server/operations/service/update_service_responses.go @@ -0,0 +1,214 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// UpdateServiceOKCode is the HTTP code returned for type UpdateServiceOK +const UpdateServiceOKCode int = 200 + +/*UpdateServiceOK The update request was successful and the resource has been altered + +swagger:response updateServiceOK +*/ +type UpdateServiceOK struct { + + /* + In: Body + */ + Payload *rest_model.Empty `json:"body,omitempty"` +} + +// NewUpdateServiceOK creates UpdateServiceOK with default headers values +func NewUpdateServiceOK() *UpdateServiceOK { + + return &UpdateServiceOK{} +} + +// WithPayload adds the payload to the update service o k response +func (o *UpdateServiceOK) WithPayload(payload *rest_model.Empty) *UpdateServiceOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update service o k response +func (o *UpdateServiceOK) SetPayload(payload *rest_model.Empty) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateServiceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateServiceBadRequestCode is the HTTP code returned for type UpdateServiceBadRequest +const UpdateServiceBadRequestCode int = 400 + +/*UpdateServiceBadRequest 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 + +swagger:response updateServiceBadRequest +*/ +type UpdateServiceBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewUpdateServiceBadRequest creates UpdateServiceBadRequest with default headers values +func NewUpdateServiceBadRequest() *UpdateServiceBadRequest { + + return &UpdateServiceBadRequest{} +} + +// WithPayload adds the payload to the update service bad request response +func (o *UpdateServiceBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *UpdateServiceBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update service bad request response +func (o *UpdateServiceBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateServiceBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateServiceUnauthorizedCode is the HTTP code returned for type UpdateServiceUnauthorized +const UpdateServiceUnauthorizedCode int = 401 + +/*UpdateServiceUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response updateServiceUnauthorized +*/ +type UpdateServiceUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewUpdateServiceUnauthorized creates UpdateServiceUnauthorized with default headers values +func NewUpdateServiceUnauthorized() *UpdateServiceUnauthorized { + + return &UpdateServiceUnauthorized{} +} + +// WithPayload adds the payload to the update service unauthorized response +func (o *UpdateServiceUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *UpdateServiceUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update service unauthorized response +func (o *UpdateServiceUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateServiceUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateServiceNotFoundCode is the HTTP code returned for type UpdateServiceNotFound +const UpdateServiceNotFoundCode int = 404 + +/*UpdateServiceNotFound The requested resource does not exist + +swagger:response updateServiceNotFound +*/ +type UpdateServiceNotFound struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewUpdateServiceNotFound creates UpdateServiceNotFound with default headers values +func NewUpdateServiceNotFound() *UpdateServiceNotFound { + + return &UpdateServiceNotFound{} +} + +// WithPayload adds the payload to the update service not found response +func (o *UpdateServiceNotFound) WithPayload(payload *rest_model.APIErrorEnvelope) *UpdateServiceNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update service not found response +func (o *UpdateServiceNotFound) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateServiceNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/service/update_service_urlbuilder.go b/rest_server/operations/service/update_service_urlbuilder.go new file mode 100644 index 000000000..5e513bcc3 --- /dev/null +++ b/rest_server/operations/service/update_service_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// UpdateServiceURL generates an URL for the update service operation +type UpdateServiceURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateServiceURL) WithBasePath(bp string) *UpdateServiceURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateServiceURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateServiceURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on UpdateServiceURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateServiceURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateServiceURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateServiceURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateServiceURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateServiceURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateServiceURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/terminator/create_terminator.go b/rest_server/operations/terminator/create_terminator.go new file mode 100644 index 000000000..a1be0b073 --- /dev/null +++ b/rest_server/operations/terminator/create_terminator.go @@ -0,0 +1,82 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateTerminatorHandlerFunc turns a function with the right signature into a create terminator handler +type CreateTerminatorHandlerFunc func(CreateTerminatorParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateTerminatorHandlerFunc) Handle(params CreateTerminatorParams) middleware.Responder { + return fn(params) +} + +// CreateTerminatorHandler interface for that can handle valid create terminator params +type CreateTerminatorHandler interface { + Handle(CreateTerminatorParams) middleware.Responder +} + +// NewCreateTerminator creates a new http.Handler for the create terminator operation +func NewCreateTerminator(ctx *middleware.Context, handler CreateTerminatorHandler) *CreateTerminator { + return &CreateTerminator{Context: ctx, Handler: handler} +} + +/* CreateTerminator swagger:route POST /terminators Terminator createTerminator + +Create a terminator resource + +Create a terminator resource. Requires admin access. + +*/ +type CreateTerminator struct { + Context *middleware.Context + Handler CreateTerminatorHandler +} + +func (o *CreateTerminator) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateTerminatorParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/terminator/create_terminator_parameters.go b/rest_server/operations/terminator/create_terminator_parameters.go new file mode 100644 index 000000000..a7afde3de --- /dev/null +++ b/rest_server/operations/terminator/create_terminator_parameters.go @@ -0,0 +1,109 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/validate" + + "github.com/openziti/fabric/rest_model" +) + +// NewCreateTerminatorParams creates a new CreateTerminatorParams object +// +// There are no default values defined in the spec. +func NewCreateTerminatorParams() CreateTerminatorParams { + + return CreateTerminatorParams{} +} + +// CreateTerminatorParams contains all the bound params for the create terminator operation +// typically these are obtained from a http.Request +// +// swagger:parameters createTerminator +type CreateTerminatorParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*A terminator to create + Required: true + In: body + */ + Terminator *rest_model.TerminatorCreate +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateTerminatorParams() beforehand. +func (o *CreateTerminatorParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body rest_model.TerminatorCreate + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("terminator", "body", "")) + } else { + res = append(res, errors.NewParseError("terminator", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(context.Background()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Terminator = &body + } + } + } else { + res = append(res, errors.Required("terminator", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_server/operations/terminator/create_terminator_responses.go b/rest_server/operations/terminator/create_terminator_responses.go new file mode 100644 index 000000000..098b45738 --- /dev/null +++ b/rest_server/operations/terminator/create_terminator_responses.go @@ -0,0 +1,170 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// CreateTerminatorCreatedCode is the HTTP code returned for type CreateTerminatorCreated +const CreateTerminatorCreatedCode int = 201 + +/*CreateTerminatorCreated The create request was successful and the resource has been added at the following location + +swagger:response createTerminatorCreated +*/ +type CreateTerminatorCreated struct { + + /* + In: Body + */ + Payload *rest_model.CreateEnvelope `json:"body,omitempty"` +} + +// NewCreateTerminatorCreated creates CreateTerminatorCreated with default headers values +func NewCreateTerminatorCreated() *CreateTerminatorCreated { + + return &CreateTerminatorCreated{} +} + +// WithPayload adds the payload to the create terminator created response +func (o *CreateTerminatorCreated) WithPayload(payload *rest_model.CreateEnvelope) *CreateTerminatorCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create terminator created response +func (o *CreateTerminatorCreated) SetPayload(payload *rest_model.CreateEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTerminatorCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTerminatorBadRequestCode is the HTTP code returned for type CreateTerminatorBadRequest +const CreateTerminatorBadRequestCode int = 400 + +/*CreateTerminatorBadRequest 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 + +swagger:response createTerminatorBadRequest +*/ +type CreateTerminatorBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewCreateTerminatorBadRequest creates CreateTerminatorBadRequest with default headers values +func NewCreateTerminatorBadRequest() *CreateTerminatorBadRequest { + + return &CreateTerminatorBadRequest{} +} + +// WithPayload adds the payload to the create terminator bad request response +func (o *CreateTerminatorBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *CreateTerminatorBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create terminator bad request response +func (o *CreateTerminatorBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTerminatorBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTerminatorUnauthorizedCode is the HTTP code returned for type CreateTerminatorUnauthorized +const CreateTerminatorUnauthorizedCode int = 401 + +/*CreateTerminatorUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response createTerminatorUnauthorized +*/ +type CreateTerminatorUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewCreateTerminatorUnauthorized creates CreateTerminatorUnauthorized with default headers values +func NewCreateTerminatorUnauthorized() *CreateTerminatorUnauthorized { + + return &CreateTerminatorUnauthorized{} +} + +// WithPayload adds the payload to the create terminator unauthorized response +func (o *CreateTerminatorUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *CreateTerminatorUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create terminator unauthorized response +func (o *CreateTerminatorUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTerminatorUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/terminator/create_terminator_urlbuilder.go b/rest_server/operations/terminator/create_terminator_urlbuilder.go new file mode 100644 index 000000000..6fe29e9ba --- /dev/null +++ b/rest_server/operations/terminator/create_terminator_urlbuilder.go @@ -0,0 +1,111 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateTerminatorURL generates an URL for the create terminator operation +type CreateTerminatorURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTerminatorURL) WithBasePath(bp string) *CreateTerminatorURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTerminatorURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateTerminatorURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/terminators" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateTerminatorURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateTerminatorURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateTerminatorURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateTerminatorURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateTerminatorURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateTerminatorURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/terminator/delete_terminator.go b/rest_server/operations/terminator/delete_terminator.go new file mode 100644 index 000000000..bfed0acf6 --- /dev/null +++ b/rest_server/operations/terminator/delete_terminator.go @@ -0,0 +1,82 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteTerminatorHandlerFunc turns a function with the right signature into a delete terminator handler +type DeleteTerminatorHandlerFunc func(DeleteTerminatorParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteTerminatorHandlerFunc) Handle(params DeleteTerminatorParams) middleware.Responder { + return fn(params) +} + +// DeleteTerminatorHandler interface for that can handle valid delete terminator params +type DeleteTerminatorHandler interface { + Handle(DeleteTerminatorParams) middleware.Responder +} + +// NewDeleteTerminator creates a new http.Handler for the delete terminator operation +func NewDeleteTerminator(ctx *middleware.Context, handler DeleteTerminatorHandler) *DeleteTerminator { + return &DeleteTerminator{Context: ctx, Handler: handler} +} + +/* DeleteTerminator swagger:route DELETE /terminators/{id} Terminator deleteTerminator + +Delete a terminator + +Delete a terminator by id. Requires admin access. + +*/ +type DeleteTerminator struct { + Context *middleware.Context + Handler DeleteTerminatorHandler +} + +func (o *DeleteTerminator) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteTerminatorParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/terminator/delete_terminator_parameters.go b/rest_server/operations/terminator/delete_terminator_parameters.go new file mode 100644 index 000000000..65ffbdcb0 --- /dev/null +++ b/rest_server/operations/terminator/delete_terminator_parameters.go @@ -0,0 +1,95 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteTerminatorParams creates a new DeleteTerminatorParams object +// +// There are no default values defined in the spec. +func NewDeleteTerminatorParams() DeleteTerminatorParams { + + return DeleteTerminatorParams{} +} + +// DeleteTerminatorParams contains all the bound params for the delete terminator operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteTerminator +type DeleteTerminatorParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteTerminatorParams() beforehand. +func (o *DeleteTerminatorParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DeleteTerminatorParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/terminator/delete_terminator_responses.go b/rest_server/operations/terminator/delete_terminator_responses.go new file mode 100644 index 000000000..10689ef2f --- /dev/null +++ b/rest_server/operations/terminator/delete_terminator_responses.go @@ -0,0 +1,214 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// DeleteTerminatorOKCode is the HTTP code returned for type DeleteTerminatorOK +const DeleteTerminatorOKCode int = 200 + +/*DeleteTerminatorOK The delete request was successful and the resource has been removed + +swagger:response deleteTerminatorOK +*/ +type DeleteTerminatorOK struct { + + /* + In: Body + */ + Payload *rest_model.Empty `json:"body,omitempty"` +} + +// NewDeleteTerminatorOK creates DeleteTerminatorOK with default headers values +func NewDeleteTerminatorOK() *DeleteTerminatorOK { + + return &DeleteTerminatorOK{} +} + +// WithPayload adds the payload to the delete terminator o k response +func (o *DeleteTerminatorOK) WithPayload(payload *rest_model.Empty) *DeleteTerminatorOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete terminator o k response +func (o *DeleteTerminatorOK) SetPayload(payload *rest_model.Empty) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTerminatorOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteTerminatorBadRequestCode is the HTTP code returned for type DeleteTerminatorBadRequest +const DeleteTerminatorBadRequestCode int = 400 + +/*DeleteTerminatorBadRequest 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 + +swagger:response deleteTerminatorBadRequest +*/ +type DeleteTerminatorBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDeleteTerminatorBadRequest creates DeleteTerminatorBadRequest with default headers values +func NewDeleteTerminatorBadRequest() *DeleteTerminatorBadRequest { + + return &DeleteTerminatorBadRequest{} +} + +// WithPayload adds the payload to the delete terminator bad request response +func (o *DeleteTerminatorBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *DeleteTerminatorBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete terminator bad request response +func (o *DeleteTerminatorBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTerminatorBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteTerminatorUnauthorizedCode is the HTTP code returned for type DeleteTerminatorUnauthorized +const DeleteTerminatorUnauthorizedCode int = 401 + +/*DeleteTerminatorUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response deleteTerminatorUnauthorized +*/ +type DeleteTerminatorUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDeleteTerminatorUnauthorized creates DeleteTerminatorUnauthorized with default headers values +func NewDeleteTerminatorUnauthorized() *DeleteTerminatorUnauthorized { + + return &DeleteTerminatorUnauthorized{} +} + +// WithPayload adds the payload to the delete terminator unauthorized response +func (o *DeleteTerminatorUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *DeleteTerminatorUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete terminator unauthorized response +func (o *DeleteTerminatorUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTerminatorUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteTerminatorConflictCode is the HTTP code returned for type DeleteTerminatorConflict +const DeleteTerminatorConflictCode int = 409 + +/*DeleteTerminatorConflict The resource requested to be removed/altered cannot be as it is referenced by another object. + +swagger:response deleteTerminatorConflict +*/ +type DeleteTerminatorConflict struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDeleteTerminatorConflict creates DeleteTerminatorConflict with default headers values +func NewDeleteTerminatorConflict() *DeleteTerminatorConflict { + + return &DeleteTerminatorConflict{} +} + +// WithPayload adds the payload to the delete terminator conflict response +func (o *DeleteTerminatorConflict) WithPayload(payload *rest_model.APIErrorEnvelope) *DeleteTerminatorConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete terminator conflict response +func (o *DeleteTerminatorConflict) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTerminatorConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/terminator/delete_terminator_urlbuilder.go b/rest_server/operations/terminator/delete_terminator_urlbuilder.go new file mode 100644 index 000000000..65fc16828 --- /dev/null +++ b/rest_server/operations/terminator/delete_terminator_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteTerminatorURL generates an URL for the delete terminator operation +type DeleteTerminatorURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTerminatorURL) WithBasePath(bp string) *DeleteTerminatorURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTerminatorURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteTerminatorURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/terminators/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DeleteTerminatorURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteTerminatorURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteTerminatorURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteTerminatorURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteTerminatorURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteTerminatorURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteTerminatorURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/terminator/detail_terminator.go b/rest_server/operations/terminator/detail_terminator.go new file mode 100644 index 000000000..b86c89774 --- /dev/null +++ b/rest_server/operations/terminator/detail_terminator.go @@ -0,0 +1,82 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DetailTerminatorHandlerFunc turns a function with the right signature into a detail terminator handler +type DetailTerminatorHandlerFunc func(DetailTerminatorParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DetailTerminatorHandlerFunc) Handle(params DetailTerminatorParams) middleware.Responder { + return fn(params) +} + +// DetailTerminatorHandler interface for that can handle valid detail terminator params +type DetailTerminatorHandler interface { + Handle(DetailTerminatorParams) middleware.Responder +} + +// NewDetailTerminator creates a new http.Handler for the detail terminator operation +func NewDetailTerminator(ctx *middleware.Context, handler DetailTerminatorHandler) *DetailTerminator { + return &DetailTerminator{Context: ctx, Handler: handler} +} + +/* DetailTerminator swagger:route GET /terminators/{id} Terminator detailTerminator + +Retrieves a single terminator + +Retrieves a single terminator by id. Requires admin access. + +*/ +type DetailTerminator struct { + Context *middleware.Context + Handler DetailTerminatorHandler +} + +func (o *DetailTerminator) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDetailTerminatorParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/terminator/detail_terminator_parameters.go b/rest_server/operations/terminator/detail_terminator_parameters.go new file mode 100644 index 000000000..cff8a8de4 --- /dev/null +++ b/rest_server/operations/terminator/detail_terminator_parameters.go @@ -0,0 +1,95 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDetailTerminatorParams creates a new DetailTerminatorParams object +// +// There are no default values defined in the spec. +func NewDetailTerminatorParams() DetailTerminatorParams { + + return DetailTerminatorParams{} +} + +// DetailTerminatorParams contains all the bound params for the detail terminator operation +// typically these are obtained from a http.Request +// +// swagger:parameters detailTerminator +type DetailTerminatorParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDetailTerminatorParams() beforehand. +func (o *DetailTerminatorParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DetailTerminatorParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/terminator/detail_terminator_responses.go b/rest_server/operations/terminator/detail_terminator_responses.go new file mode 100644 index 000000000..b4a78d9e1 --- /dev/null +++ b/rest_server/operations/terminator/detail_terminator_responses.go @@ -0,0 +1,170 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// DetailTerminatorOKCode is the HTTP code returned for type DetailTerminatorOK +const DetailTerminatorOKCode int = 200 + +/*DetailTerminatorOK A single terminator + +swagger:response detailTerminatorOK +*/ +type DetailTerminatorOK struct { + + /* + In: Body + */ + Payload *rest_model.DetailTerminatorEnvelope `json:"body,omitempty"` +} + +// NewDetailTerminatorOK creates DetailTerminatorOK with default headers values +func NewDetailTerminatorOK() *DetailTerminatorOK { + + return &DetailTerminatorOK{} +} + +// WithPayload adds the payload to the detail terminator o k response +func (o *DetailTerminatorOK) WithPayload(payload *rest_model.DetailTerminatorEnvelope) *DetailTerminatorOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail terminator o k response +func (o *DetailTerminatorOK) SetPayload(payload *rest_model.DetailTerminatorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailTerminatorOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DetailTerminatorUnauthorizedCode is the HTTP code returned for type DetailTerminatorUnauthorized +const DetailTerminatorUnauthorizedCode int = 401 + +/*DetailTerminatorUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response detailTerminatorUnauthorized +*/ +type DetailTerminatorUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDetailTerminatorUnauthorized creates DetailTerminatorUnauthorized with default headers values +func NewDetailTerminatorUnauthorized() *DetailTerminatorUnauthorized { + + return &DetailTerminatorUnauthorized{} +} + +// WithPayload adds the payload to the detail terminator unauthorized response +func (o *DetailTerminatorUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *DetailTerminatorUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail terminator unauthorized response +func (o *DetailTerminatorUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailTerminatorUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DetailTerminatorNotFoundCode is the HTTP code returned for type DetailTerminatorNotFound +const DetailTerminatorNotFoundCode int = 404 + +/*DetailTerminatorNotFound The requested resource does not exist + +swagger:response detailTerminatorNotFound +*/ +type DetailTerminatorNotFound struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDetailTerminatorNotFound creates DetailTerminatorNotFound with default headers values +func NewDetailTerminatorNotFound() *DetailTerminatorNotFound { + + return &DetailTerminatorNotFound{} +} + +// WithPayload adds the payload to the detail terminator not found response +func (o *DetailTerminatorNotFound) WithPayload(payload *rest_model.APIErrorEnvelope) *DetailTerminatorNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail terminator not found response +func (o *DetailTerminatorNotFound) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailTerminatorNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/terminator/detail_terminator_urlbuilder.go b/rest_server/operations/terminator/detail_terminator_urlbuilder.go new file mode 100644 index 000000000..aab5e6902 --- /dev/null +++ b/rest_server/operations/terminator/detail_terminator_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DetailTerminatorURL generates an URL for the detail terminator operation +type DetailTerminatorURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DetailTerminatorURL) WithBasePath(bp string) *DetailTerminatorURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DetailTerminatorURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DetailTerminatorURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/terminators/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DetailTerminatorURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DetailTerminatorURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DetailTerminatorURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DetailTerminatorURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DetailTerminatorURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DetailTerminatorURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DetailTerminatorURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/terminator/list_terminators.go b/rest_server/operations/terminator/list_terminators.go new file mode 100644 index 000000000..17b3037c8 --- /dev/null +++ b/rest_server/operations/terminator/list_terminators.go @@ -0,0 +1,83 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListTerminatorsHandlerFunc turns a function with the right signature into a list terminators handler +type ListTerminatorsHandlerFunc func(ListTerminatorsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListTerminatorsHandlerFunc) Handle(params ListTerminatorsParams) middleware.Responder { + return fn(params) +} + +// ListTerminatorsHandler interface for that can handle valid list terminators params +type ListTerminatorsHandler interface { + Handle(ListTerminatorsParams) middleware.Responder +} + +// NewListTerminators creates a new http.Handler for the list terminators operation +func NewListTerminators(ctx *middleware.Context, handler ListTerminatorsHandler) *ListTerminators { + return &ListTerminators{Context: ctx, Handler: handler} +} + +/* ListTerminators swagger:route GET /terminators Terminator listTerminators + +List terminators + +Retrieves a list of terminator resources; supports filtering, sorting, and pagination. Requires admin access. + + +*/ +type ListTerminators struct { + Context *middleware.Context + Handler ListTerminatorsHandler +} + +func (o *ListTerminators) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewListTerminatorsParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/terminator/list_terminators_parameters.go b/rest_server/operations/terminator/list_terminators_parameters.go new file mode 100644 index 000000000..84fc1e620 --- /dev/null +++ b/rest_server/operations/terminator/list_terminators_parameters.go @@ -0,0 +1,166 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewListTerminatorsParams creates a new ListTerminatorsParams object +// +// There are no default values defined in the spec. +func NewListTerminatorsParams() ListTerminatorsParams { + + return ListTerminatorsParams{} +} + +// ListTerminatorsParams contains all the bound params for the list terminators operation +// typically these are obtained from a http.Request +// +// swagger:parameters listTerminators +type ListTerminatorsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: query + */ + Filter *string + /* + In: query + */ + Limit *int64 + /* + In: query + */ + Offset *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListTerminatorsParams() beforehand. +func (o *ListTerminatorsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFilter, qhkFilter, _ := qs.GetOK("filter") + if err := o.bindFilter(qFilter, qhkFilter, route.Formats); err != nil { + res = append(res, err) + } + + qLimit, qhkLimit, _ := qs.GetOK("limit") + if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil { + res = append(res, err) + } + + qOffset, qhkOffset, _ := qs.GetOK("offset") + if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFilter binds and validates parameter Filter from query. +func (o *ListTerminatorsParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Filter = &raw + + return nil +} + +// bindLimit binds and validates parameter Limit from query. +func (o *ListTerminatorsParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("limit", "query", "int64", raw) + } + o.Limit = &value + + return nil +} + +// bindOffset binds and validates parameter Offset from query. +func (o *ListTerminatorsParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("offset", "query", "int64", raw) + } + o.Offset = &value + + return nil +} diff --git a/rest_server/operations/terminator/list_terminators_responses.go b/rest_server/operations/terminator/list_terminators_responses.go new file mode 100644 index 000000000..3946ea27c --- /dev/null +++ b/rest_server/operations/terminator/list_terminators_responses.go @@ -0,0 +1,170 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// ListTerminatorsOKCode is the HTTP code returned for type ListTerminatorsOK +const ListTerminatorsOKCode int = 200 + +/*ListTerminatorsOK A list of terminators + +swagger:response listTerminatorsOK +*/ +type ListTerminatorsOK struct { + + /* + In: Body + */ + Payload *rest_model.ListTerminatorsEnvelope `json:"body,omitempty"` +} + +// NewListTerminatorsOK creates ListTerminatorsOK with default headers values +func NewListTerminatorsOK() *ListTerminatorsOK { + + return &ListTerminatorsOK{} +} + +// WithPayload adds the payload to the list terminators o k response +func (o *ListTerminatorsOK) WithPayload(payload *rest_model.ListTerminatorsEnvelope) *ListTerminatorsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list terminators o k response +func (o *ListTerminatorsOK) SetPayload(payload *rest_model.ListTerminatorsEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTerminatorsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListTerminatorsBadRequestCode is the HTTP code returned for type ListTerminatorsBadRequest +const ListTerminatorsBadRequestCode int = 400 + +/*ListTerminatorsBadRequest 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 + +swagger:response listTerminatorsBadRequest +*/ +type ListTerminatorsBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListTerminatorsBadRequest creates ListTerminatorsBadRequest with default headers values +func NewListTerminatorsBadRequest() *ListTerminatorsBadRequest { + + return &ListTerminatorsBadRequest{} +} + +// WithPayload adds the payload to the list terminators bad request response +func (o *ListTerminatorsBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *ListTerminatorsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list terminators bad request response +func (o *ListTerminatorsBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTerminatorsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListTerminatorsUnauthorizedCode is the HTTP code returned for type ListTerminatorsUnauthorized +const ListTerminatorsUnauthorizedCode int = 401 + +/*ListTerminatorsUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listTerminatorsUnauthorized +*/ +type ListTerminatorsUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListTerminatorsUnauthorized creates ListTerminatorsUnauthorized with default headers values +func NewListTerminatorsUnauthorized() *ListTerminatorsUnauthorized { + + return &ListTerminatorsUnauthorized{} +} + +// WithPayload adds the payload to the list terminators unauthorized response +func (o *ListTerminatorsUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListTerminatorsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list terminators unauthorized response +func (o *ListTerminatorsUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListTerminatorsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/terminator/list_terminators_urlbuilder.go b/rest_server/operations/terminator/list_terminators_urlbuilder.go new file mode 100644 index 000000000..80b7ee58f --- /dev/null +++ b/rest_server/operations/terminator/list_terminators_urlbuilder.go @@ -0,0 +1,147 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ListTerminatorsURL generates an URL for the list terminators operation +type ListTerminatorsURL struct { + Filter *string + Limit *int64 + Offset *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListTerminatorsURL) WithBasePath(bp string) *ListTerminatorsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListTerminatorsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListTerminatorsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/terminators" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var filterQ string + if o.Filter != nil { + filterQ = *o.Filter + } + if filterQ != "" { + qs.Set("filter", filterQ) + } + + var limitQ string + if o.Limit != nil { + limitQ = swag.FormatInt64(*o.Limit) + } + if limitQ != "" { + qs.Set("limit", limitQ) + } + + var offsetQ string + if o.Offset != nil { + offsetQ = swag.FormatInt64(*o.Offset) + } + if offsetQ != "" { + qs.Set("offset", offsetQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListTerminatorsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListTerminatorsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListTerminatorsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListTerminatorsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListTerminatorsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListTerminatorsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/terminator/patch_terminator.go b/rest_server/operations/terminator/patch_terminator.go new file mode 100644 index 000000000..c10c2b744 --- /dev/null +++ b/rest_server/operations/terminator/patch_terminator.go @@ -0,0 +1,82 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PatchTerminatorHandlerFunc turns a function with the right signature into a patch terminator handler +type PatchTerminatorHandlerFunc func(PatchTerminatorParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PatchTerminatorHandlerFunc) Handle(params PatchTerminatorParams) middleware.Responder { + return fn(params) +} + +// PatchTerminatorHandler interface for that can handle valid patch terminator params +type PatchTerminatorHandler interface { + Handle(PatchTerminatorParams) middleware.Responder +} + +// NewPatchTerminator creates a new http.Handler for the patch terminator operation +func NewPatchTerminator(ctx *middleware.Context, handler PatchTerminatorHandler) *PatchTerminator { + return &PatchTerminator{Context: ctx, Handler: handler} +} + +/* PatchTerminator swagger:route PATCH /terminators/{id} Terminator patchTerminator + +Update the supplied fields on a terminator + +Update the supplied fields on a terminator. Requires admin access. + +*/ +type PatchTerminator struct { + Context *middleware.Context + Handler PatchTerminatorHandler +} + +func (o *PatchTerminator) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPatchTerminatorParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/terminator/patch_terminator_parameters.go b/rest_server/operations/terminator/patch_terminator_parameters.go new file mode 100644 index 000000000..dd0f85ce8 --- /dev/null +++ b/rest_server/operations/terminator/patch_terminator_parameters.go @@ -0,0 +1,134 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/openziti/fabric/rest_model" +) + +// NewPatchTerminatorParams creates a new PatchTerminatorParams object +// +// There are no default values defined in the spec. +func NewPatchTerminatorParams() PatchTerminatorParams { + + return PatchTerminatorParams{} +} + +// PatchTerminatorParams contains all the bound params for the patch terminator operation +// typically these are obtained from a http.Request +// +// swagger:parameters patchTerminator +type PatchTerminatorParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string + /*A terminator patch object + Required: true + In: body + */ + Terminator *rest_model.TerminatorPatch +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPatchTerminatorParams() beforehand. +func (o *PatchTerminatorParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body rest_model.TerminatorPatch + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("terminator", "body", "")) + } else { + res = append(res, errors.NewParseError("terminator", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(context.Background()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Terminator = &body + } + } + } else { + res = append(res, errors.Required("terminator", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *PatchTerminatorParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/terminator/patch_terminator_responses.go b/rest_server/operations/terminator/patch_terminator_responses.go new file mode 100644 index 000000000..d9f840bd1 --- /dev/null +++ b/rest_server/operations/terminator/patch_terminator_responses.go @@ -0,0 +1,214 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// PatchTerminatorOKCode is the HTTP code returned for type PatchTerminatorOK +const PatchTerminatorOKCode int = 200 + +/*PatchTerminatorOK The patch request was successful and the resource has been altered + +swagger:response patchTerminatorOK +*/ +type PatchTerminatorOK struct { + + /* + In: Body + */ + Payload *rest_model.Empty `json:"body,omitempty"` +} + +// NewPatchTerminatorOK creates PatchTerminatorOK with default headers values +func NewPatchTerminatorOK() *PatchTerminatorOK { + + return &PatchTerminatorOK{} +} + +// WithPayload adds the payload to the patch terminator o k response +func (o *PatchTerminatorOK) WithPayload(payload *rest_model.Empty) *PatchTerminatorOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch terminator o k response +func (o *PatchTerminatorOK) SetPayload(payload *rest_model.Empty) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchTerminatorOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PatchTerminatorBadRequestCode is the HTTP code returned for type PatchTerminatorBadRequest +const PatchTerminatorBadRequestCode int = 400 + +/*PatchTerminatorBadRequest 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 + +swagger:response patchTerminatorBadRequest +*/ +type PatchTerminatorBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewPatchTerminatorBadRequest creates PatchTerminatorBadRequest with default headers values +func NewPatchTerminatorBadRequest() *PatchTerminatorBadRequest { + + return &PatchTerminatorBadRequest{} +} + +// WithPayload adds the payload to the patch terminator bad request response +func (o *PatchTerminatorBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *PatchTerminatorBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch terminator bad request response +func (o *PatchTerminatorBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchTerminatorBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PatchTerminatorUnauthorizedCode is the HTTP code returned for type PatchTerminatorUnauthorized +const PatchTerminatorUnauthorizedCode int = 401 + +/*PatchTerminatorUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response patchTerminatorUnauthorized +*/ +type PatchTerminatorUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewPatchTerminatorUnauthorized creates PatchTerminatorUnauthorized with default headers values +func NewPatchTerminatorUnauthorized() *PatchTerminatorUnauthorized { + + return &PatchTerminatorUnauthorized{} +} + +// WithPayload adds the payload to the patch terminator unauthorized response +func (o *PatchTerminatorUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *PatchTerminatorUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch terminator unauthorized response +func (o *PatchTerminatorUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchTerminatorUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PatchTerminatorNotFoundCode is the HTTP code returned for type PatchTerminatorNotFound +const PatchTerminatorNotFoundCode int = 404 + +/*PatchTerminatorNotFound The requested resource does not exist + +swagger:response patchTerminatorNotFound +*/ +type PatchTerminatorNotFound struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewPatchTerminatorNotFound creates PatchTerminatorNotFound with default headers values +func NewPatchTerminatorNotFound() *PatchTerminatorNotFound { + + return &PatchTerminatorNotFound{} +} + +// WithPayload adds the payload to the patch terminator not found response +func (o *PatchTerminatorNotFound) WithPayload(payload *rest_model.APIErrorEnvelope) *PatchTerminatorNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch terminator not found response +func (o *PatchTerminatorNotFound) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchTerminatorNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/terminator/patch_terminator_urlbuilder.go b/rest_server/operations/terminator/patch_terminator_urlbuilder.go new file mode 100644 index 000000000..bc1733f98 --- /dev/null +++ b/rest_server/operations/terminator/patch_terminator_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// PatchTerminatorURL generates an URL for the patch terminator operation +type PatchTerminatorURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PatchTerminatorURL) WithBasePath(bp string) *PatchTerminatorURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PatchTerminatorURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PatchTerminatorURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/terminators/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on PatchTerminatorURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PatchTerminatorURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PatchTerminatorURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PatchTerminatorURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PatchTerminatorURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PatchTerminatorURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PatchTerminatorURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/terminator/update_terminator.go b/rest_server/operations/terminator/update_terminator.go new file mode 100644 index 000000000..815265780 --- /dev/null +++ b/rest_server/operations/terminator/update_terminator.go @@ -0,0 +1,82 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateTerminatorHandlerFunc turns a function with the right signature into a update terminator handler +type UpdateTerminatorHandlerFunc func(UpdateTerminatorParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateTerminatorHandlerFunc) Handle(params UpdateTerminatorParams) middleware.Responder { + return fn(params) +} + +// UpdateTerminatorHandler interface for that can handle valid update terminator params +type UpdateTerminatorHandler interface { + Handle(UpdateTerminatorParams) middleware.Responder +} + +// NewUpdateTerminator creates a new http.Handler for the update terminator operation +func NewUpdateTerminator(ctx *middleware.Context, handler UpdateTerminatorHandler) *UpdateTerminator { + return &UpdateTerminator{Context: ctx, Handler: handler} +} + +/* UpdateTerminator swagger:route PUT /terminators/{id} Terminator updateTerminator + +Update all fields on a terminator + +Update all fields on a terminator by id. Requires admin access. + +*/ +type UpdateTerminator struct { + Context *middleware.Context + Handler UpdateTerminatorHandler +} + +func (o *UpdateTerminator) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewUpdateTerminatorParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/terminator/update_terminator_parameters.go b/rest_server/operations/terminator/update_terminator_parameters.go new file mode 100644 index 000000000..86a6f815f --- /dev/null +++ b/rest_server/operations/terminator/update_terminator_parameters.go @@ -0,0 +1,134 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/openziti/fabric/rest_model" +) + +// NewUpdateTerminatorParams creates a new UpdateTerminatorParams object +// +// There are no default values defined in the spec. +func NewUpdateTerminatorParams() UpdateTerminatorParams { + + return UpdateTerminatorParams{} +} + +// UpdateTerminatorParams contains all the bound params for the update terminator operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateTerminator +type UpdateTerminatorParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string + /*A terminator update object + Required: true + In: body + */ + Terminator *rest_model.TerminatorUpdate +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateTerminatorParams() beforehand. +func (o *UpdateTerminatorParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body rest_model.TerminatorUpdate + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("terminator", "body", "")) + } else { + res = append(res, errors.NewParseError("terminator", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(context.Background()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Terminator = &body + } + } + } else { + res = append(res, errors.Required("terminator", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *UpdateTerminatorParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/terminator/update_terminator_responses.go b/rest_server/operations/terminator/update_terminator_responses.go new file mode 100644 index 000000000..e96f43ab6 --- /dev/null +++ b/rest_server/operations/terminator/update_terminator_responses.go @@ -0,0 +1,214 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// UpdateTerminatorOKCode is the HTTP code returned for type UpdateTerminatorOK +const UpdateTerminatorOKCode int = 200 + +/*UpdateTerminatorOK The update request was successful and the resource has been altered + +swagger:response updateTerminatorOK +*/ +type UpdateTerminatorOK struct { + + /* + In: Body + */ + Payload *rest_model.Empty `json:"body,omitempty"` +} + +// NewUpdateTerminatorOK creates UpdateTerminatorOK with default headers values +func NewUpdateTerminatorOK() *UpdateTerminatorOK { + + return &UpdateTerminatorOK{} +} + +// WithPayload adds the payload to the update terminator o k response +func (o *UpdateTerminatorOK) WithPayload(payload *rest_model.Empty) *UpdateTerminatorOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update terminator o k response +func (o *UpdateTerminatorOK) SetPayload(payload *rest_model.Empty) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateTerminatorOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateTerminatorBadRequestCode is the HTTP code returned for type UpdateTerminatorBadRequest +const UpdateTerminatorBadRequestCode int = 400 + +/*UpdateTerminatorBadRequest 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 + +swagger:response updateTerminatorBadRequest +*/ +type UpdateTerminatorBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewUpdateTerminatorBadRequest creates UpdateTerminatorBadRequest with default headers values +func NewUpdateTerminatorBadRequest() *UpdateTerminatorBadRequest { + + return &UpdateTerminatorBadRequest{} +} + +// WithPayload adds the payload to the update terminator bad request response +func (o *UpdateTerminatorBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *UpdateTerminatorBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update terminator bad request response +func (o *UpdateTerminatorBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateTerminatorBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateTerminatorUnauthorizedCode is the HTTP code returned for type UpdateTerminatorUnauthorized +const UpdateTerminatorUnauthorizedCode int = 401 + +/*UpdateTerminatorUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response updateTerminatorUnauthorized +*/ +type UpdateTerminatorUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewUpdateTerminatorUnauthorized creates UpdateTerminatorUnauthorized with default headers values +func NewUpdateTerminatorUnauthorized() *UpdateTerminatorUnauthorized { + + return &UpdateTerminatorUnauthorized{} +} + +// WithPayload adds the payload to the update terminator unauthorized response +func (o *UpdateTerminatorUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *UpdateTerminatorUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update terminator unauthorized response +func (o *UpdateTerminatorUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateTerminatorUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateTerminatorNotFoundCode is the HTTP code returned for type UpdateTerminatorNotFound +const UpdateTerminatorNotFoundCode int = 404 + +/*UpdateTerminatorNotFound The requested resource does not exist + +swagger:response updateTerminatorNotFound +*/ +type UpdateTerminatorNotFound struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewUpdateTerminatorNotFound creates UpdateTerminatorNotFound with default headers values +func NewUpdateTerminatorNotFound() *UpdateTerminatorNotFound { + + return &UpdateTerminatorNotFound{} +} + +// WithPayload adds the payload to the update terminator not found response +func (o *UpdateTerminatorNotFound) WithPayload(payload *rest_model.APIErrorEnvelope) *UpdateTerminatorNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update terminator not found response +func (o *UpdateTerminatorNotFound) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateTerminatorNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/terminator/update_terminator_urlbuilder.go b/rest_server/operations/terminator/update_terminator_urlbuilder.go new file mode 100644 index 000000000..557510f1f --- /dev/null +++ b/rest_server/operations/terminator/update_terminator_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 terminator + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// UpdateTerminatorURL generates an URL for the update terminator operation +type UpdateTerminatorURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateTerminatorURL) WithBasePath(bp string) *UpdateTerminatorURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateTerminatorURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateTerminatorURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/terminators/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on UpdateTerminatorURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateTerminatorURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateTerminatorURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateTerminatorURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateTerminatorURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateTerminatorURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateTerminatorURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/ziti_fabric_api.go b/rest_server/operations/ziti_fabric_api.go new file mode 100644 index 000000000..6bc77c120 --- /dev/null +++ b/rest_server/operations/ziti_fabric_api.go @@ -0,0 +1,533 @@ +// 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 operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "net/http" + "strings" + + "github.com/go-openapi/errors" + "github.com/go-openapi/loads" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/security" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/openziti/fabric/rest_server/operations/router" + "github.com/openziti/fabric/rest_server/operations/service" + "github.com/openziti/fabric/rest_server/operations/terminator" +) + +// NewZitiFabricAPI creates a new ZitiFabric instance +func NewZitiFabricAPI(spec *loads.Document) *ZitiFabricAPI { + return &ZitiFabricAPI{ + handlers: make(map[string]map[string]http.Handler), + formats: strfmt.Default, + defaultConsumes: "application/json", + defaultProduces: "application/json", + customConsumers: make(map[string]runtime.Consumer), + customProducers: make(map[string]runtime.Producer), + PreServerShutdown: func() {}, + ServerShutdown: func() {}, + spec: spec, + useSwaggerUI: false, + ServeError: errors.ServeError, + BasicAuthenticator: security.BasicAuth, + APIKeyAuthenticator: security.APIKeyAuth, + BearerAuthenticator: security.BearerAuth, + + JSONConsumer: runtime.JSONConsumer(), + + JSONProducer: runtime.JSONProducer(), + + RouterCreateRouterHandler: router.CreateRouterHandlerFunc(func(params router.CreateRouterParams) middleware.Responder { + return middleware.NotImplemented("operation router.CreateRouter has not yet been implemented") + }), + ServiceCreateServiceHandler: service.CreateServiceHandlerFunc(func(params service.CreateServiceParams) middleware.Responder { + return middleware.NotImplemented("operation service.CreateService has not yet been implemented") + }), + TerminatorCreateTerminatorHandler: terminator.CreateTerminatorHandlerFunc(func(params terminator.CreateTerminatorParams) middleware.Responder { + return middleware.NotImplemented("operation terminator.CreateTerminator has not yet been implemented") + }), + RouterDeleteRouterHandler: router.DeleteRouterHandlerFunc(func(params router.DeleteRouterParams) middleware.Responder { + return middleware.NotImplemented("operation router.DeleteRouter has not yet been implemented") + }), + ServiceDeleteServiceHandler: service.DeleteServiceHandlerFunc(func(params service.DeleteServiceParams) middleware.Responder { + return middleware.NotImplemented("operation service.DeleteService has not yet been implemented") + }), + TerminatorDeleteTerminatorHandler: terminator.DeleteTerminatorHandlerFunc(func(params terminator.DeleteTerminatorParams) middleware.Responder { + return middleware.NotImplemented("operation terminator.DeleteTerminator has not yet been implemented") + }), + RouterDetailRouterHandler: router.DetailRouterHandlerFunc(func(params router.DetailRouterParams) middleware.Responder { + return middleware.NotImplemented("operation router.DetailRouter has not yet been implemented") + }), + ServiceDetailServiceHandler: service.DetailServiceHandlerFunc(func(params service.DetailServiceParams) middleware.Responder { + return middleware.NotImplemented("operation service.DetailService has not yet been implemented") + }), + TerminatorDetailTerminatorHandler: terminator.DetailTerminatorHandlerFunc(func(params terminator.DetailTerminatorParams) middleware.Responder { + return middleware.NotImplemented("operation terminator.DetailTerminator has not yet been implemented") + }), + RouterListRouterTerminatorsHandler: router.ListRouterTerminatorsHandlerFunc(func(params router.ListRouterTerminatorsParams) middleware.Responder { + return middleware.NotImplemented("operation router.ListRouterTerminators has not yet been implemented") + }), + RouterListRoutersHandler: router.ListRoutersHandlerFunc(func(params router.ListRoutersParams) middleware.Responder { + return middleware.NotImplemented("operation router.ListRouters has not yet been implemented") + }), + ServiceListServiceTerminatorsHandler: service.ListServiceTerminatorsHandlerFunc(func(params service.ListServiceTerminatorsParams) middleware.Responder { + return middleware.NotImplemented("operation service.ListServiceTerminators has not yet been implemented") + }), + ServiceListServicesHandler: service.ListServicesHandlerFunc(func(params service.ListServicesParams) middleware.Responder { + return middleware.NotImplemented("operation service.ListServices has not yet been implemented") + }), + TerminatorListTerminatorsHandler: terminator.ListTerminatorsHandlerFunc(func(params terminator.ListTerminatorsParams) middleware.Responder { + return middleware.NotImplemented("operation terminator.ListTerminators has not yet been implemented") + }), + ServicePatchServiceHandler: service.PatchServiceHandlerFunc(func(params service.PatchServiceParams) middleware.Responder { + return middleware.NotImplemented("operation service.PatchService has not yet been implemented") + }), + TerminatorPatchTerminatorHandler: terminator.PatchTerminatorHandlerFunc(func(params terminator.PatchTerminatorParams) middleware.Responder { + return middleware.NotImplemented("operation terminator.PatchTerminator has not yet been implemented") + }), + ServiceUpdateServiceHandler: service.UpdateServiceHandlerFunc(func(params service.UpdateServiceParams) middleware.Responder { + return middleware.NotImplemented("operation service.UpdateService has not yet been implemented") + }), + TerminatorUpdateTerminatorHandler: terminator.UpdateTerminatorHandlerFunc(func(params terminator.UpdateTerminatorParams) middleware.Responder { + return middleware.NotImplemented("operation terminator.UpdateTerminator has not yet been implemented") + }), + } +} + +/*ZitiFabricAPI the ziti fabric API */ +type ZitiFabricAPI struct { + spec *loads.Document + context *middleware.Context + handlers map[string]map[string]http.Handler + formats strfmt.Registry + customConsumers map[string]runtime.Consumer + customProducers map[string]runtime.Producer + defaultConsumes string + defaultProduces string + Middleware func(middleware.Builder) http.Handler + useSwaggerUI bool + + // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator + + // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator + + // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator + + // JSONConsumer registers a consumer for the following mime types: + // - application/json + JSONConsumer runtime.Consumer + + // JSONProducer registers a producer for the following mime types: + // - application/json + JSONProducer runtime.Producer + + // RouterCreateRouterHandler sets the operation handler for the create router operation + RouterCreateRouterHandler router.CreateRouterHandler + // ServiceCreateServiceHandler sets the operation handler for the create service operation + ServiceCreateServiceHandler service.CreateServiceHandler + // TerminatorCreateTerminatorHandler sets the operation handler for the create terminator operation + TerminatorCreateTerminatorHandler terminator.CreateTerminatorHandler + // RouterDeleteRouterHandler sets the operation handler for the delete router operation + RouterDeleteRouterHandler router.DeleteRouterHandler + // ServiceDeleteServiceHandler sets the operation handler for the delete service operation + ServiceDeleteServiceHandler service.DeleteServiceHandler + // TerminatorDeleteTerminatorHandler sets the operation handler for the delete terminator operation + TerminatorDeleteTerminatorHandler terminator.DeleteTerminatorHandler + // RouterDetailRouterHandler sets the operation handler for the detail router operation + RouterDetailRouterHandler router.DetailRouterHandler + // ServiceDetailServiceHandler sets the operation handler for the detail service operation + ServiceDetailServiceHandler service.DetailServiceHandler + // TerminatorDetailTerminatorHandler sets the operation handler for the detail terminator operation + TerminatorDetailTerminatorHandler terminator.DetailTerminatorHandler + // RouterListRouterTerminatorsHandler sets the operation handler for the list router terminators operation + RouterListRouterTerminatorsHandler router.ListRouterTerminatorsHandler + // RouterListRoutersHandler sets the operation handler for the list routers operation + RouterListRoutersHandler router.ListRoutersHandler + // ServiceListServiceTerminatorsHandler sets the operation handler for the list service terminators operation + ServiceListServiceTerminatorsHandler service.ListServiceTerminatorsHandler + // ServiceListServicesHandler sets the operation handler for the list services operation + ServiceListServicesHandler service.ListServicesHandler + // TerminatorListTerminatorsHandler sets the operation handler for the list terminators operation + TerminatorListTerminatorsHandler terminator.ListTerminatorsHandler + // ServicePatchServiceHandler sets the operation handler for the patch service operation + ServicePatchServiceHandler service.PatchServiceHandler + // TerminatorPatchTerminatorHandler sets the operation handler for the patch terminator operation + TerminatorPatchTerminatorHandler terminator.PatchTerminatorHandler + // ServiceUpdateServiceHandler sets the operation handler for the update service operation + ServiceUpdateServiceHandler service.UpdateServiceHandler + // TerminatorUpdateTerminatorHandler sets the operation handler for the update terminator operation + TerminatorUpdateTerminatorHandler terminator.UpdateTerminatorHandler + + // ServeError is called when an error is received, there is a default handler + // but you can set your own with this + ServeError func(http.ResponseWriter, *http.Request, error) + + // PreServerShutdown is called before the HTTP(S) server is shutdown + // This allows for custom functions to get executed before the HTTP(S) server stops accepting traffic + PreServerShutdown func() + + // ServerShutdown is called when the HTTP(S) server is shut down and done + // handling all active connections and does not accept connections any more + ServerShutdown func() + + // Custom command line argument groups with their descriptions + CommandLineOptionsGroups []swag.CommandLineOptionsGroup + + // User defined logger function. + Logger func(string, ...interface{}) +} + +// UseRedoc for documentation at /docs +func (o *ZitiFabricAPI) UseRedoc() { + o.useSwaggerUI = false +} + +// UseSwaggerUI for documentation at /docs +func (o *ZitiFabricAPI) UseSwaggerUI() { + o.useSwaggerUI = true +} + +// SetDefaultProduces sets the default produces media type +func (o *ZitiFabricAPI) SetDefaultProduces(mediaType string) { + o.defaultProduces = mediaType +} + +// SetDefaultConsumes returns the default consumes media type +func (o *ZitiFabricAPI) SetDefaultConsumes(mediaType string) { + o.defaultConsumes = mediaType +} + +// SetSpec sets a spec that will be served for the clients. +func (o *ZitiFabricAPI) SetSpec(spec *loads.Document) { + o.spec = spec +} + +// DefaultProduces returns the default produces media type +func (o *ZitiFabricAPI) DefaultProduces() string { + return o.defaultProduces +} + +// DefaultConsumes returns the default consumes media type +func (o *ZitiFabricAPI) DefaultConsumes() string { + return o.defaultConsumes +} + +// Formats returns the registered string formats +func (o *ZitiFabricAPI) Formats() strfmt.Registry { + return o.formats +} + +// RegisterFormat registers a custom format validator +func (o *ZitiFabricAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) { + o.formats.Add(name, format, validator) +} + +// Validate validates the registrations in the ZitiFabricAPI +func (o *ZitiFabricAPI) Validate() error { + var unregistered []string + + if o.JSONConsumer == nil { + unregistered = append(unregistered, "JSONConsumer") + } + + if o.JSONProducer == nil { + unregistered = append(unregistered, "JSONProducer") + } + + if o.RouterCreateRouterHandler == nil { + unregistered = append(unregistered, "router.CreateRouterHandler") + } + if o.ServiceCreateServiceHandler == nil { + unregistered = append(unregistered, "service.CreateServiceHandler") + } + if o.TerminatorCreateTerminatorHandler == nil { + unregistered = append(unregistered, "terminator.CreateTerminatorHandler") + } + if o.RouterDeleteRouterHandler == nil { + unregistered = append(unregistered, "router.DeleteRouterHandler") + } + if o.ServiceDeleteServiceHandler == nil { + unregistered = append(unregistered, "service.DeleteServiceHandler") + } + if o.TerminatorDeleteTerminatorHandler == nil { + unregistered = append(unregistered, "terminator.DeleteTerminatorHandler") + } + if o.RouterDetailRouterHandler == nil { + unregistered = append(unregistered, "router.DetailRouterHandler") + } + if o.ServiceDetailServiceHandler == nil { + unregistered = append(unregistered, "service.DetailServiceHandler") + } + if o.TerminatorDetailTerminatorHandler == nil { + unregistered = append(unregistered, "terminator.DetailTerminatorHandler") + } + if o.RouterListRouterTerminatorsHandler == nil { + unregistered = append(unregistered, "router.ListRouterTerminatorsHandler") + } + if o.RouterListRoutersHandler == nil { + unregistered = append(unregistered, "router.ListRoutersHandler") + } + if o.ServiceListServiceTerminatorsHandler == nil { + unregistered = append(unregistered, "service.ListServiceTerminatorsHandler") + } + if o.ServiceListServicesHandler == nil { + unregistered = append(unregistered, "service.ListServicesHandler") + } + if o.TerminatorListTerminatorsHandler == nil { + unregistered = append(unregistered, "terminator.ListTerminatorsHandler") + } + if o.ServicePatchServiceHandler == nil { + unregistered = append(unregistered, "service.PatchServiceHandler") + } + if o.TerminatorPatchTerminatorHandler == nil { + unregistered = append(unregistered, "terminator.PatchTerminatorHandler") + } + if o.ServiceUpdateServiceHandler == nil { + unregistered = append(unregistered, "service.UpdateServiceHandler") + } + if o.TerminatorUpdateTerminatorHandler == nil { + unregistered = append(unregistered, "terminator.UpdateTerminatorHandler") + } + + if len(unregistered) > 0 { + return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", ")) + } + + return nil +} + +// ServeErrorFor gets a error handler for a given operation id +func (o *ZitiFabricAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) { + return o.ServeError +} + +// AuthenticatorsFor gets the authenticators for the specified security schemes +func (o *ZitiFabricAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator { + return nil +} + +// Authorizer returns the registered authorizer +func (o *ZitiFabricAPI) Authorizer() runtime.Authorizer { + return nil +} + +// ConsumersFor gets the consumers for the specified media types. +// MIME type parameters are ignored here. +func (o *ZitiFabricAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer { + result := make(map[string]runtime.Consumer, len(mediaTypes)) + for _, mt := range mediaTypes { + switch mt { + case "application/json": + result["application/json"] = o.JSONConsumer + } + + if c, ok := o.customConsumers[mt]; ok { + result[mt] = c + } + } + return result +} + +// ProducersFor gets the producers for the specified media types. +// MIME type parameters are ignored here. +func (o *ZitiFabricAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer { + result := make(map[string]runtime.Producer, len(mediaTypes)) + for _, mt := range mediaTypes { + switch mt { + case "application/json": + result["application/json"] = o.JSONProducer + } + + if p, ok := o.customProducers[mt]; ok { + result[mt] = p + } + } + return result +} + +// HandlerFor gets a http.Handler for the provided operation method and path +func (o *ZitiFabricAPI) HandlerFor(method, path string) (http.Handler, bool) { + if o.handlers == nil { + return nil, false + } + um := strings.ToUpper(method) + if _, ok := o.handlers[um]; !ok { + return nil, false + } + if path == "/" { + path = "" + } + h, ok := o.handlers[um][path] + return h, ok +} + +// Context returns the middleware context for the ziti fabric API +func (o *ZitiFabricAPI) Context() *middleware.Context { + if o.context == nil { + o.context = middleware.NewRoutableContext(o.spec, o, nil) + } + + return o.context +} + +func (o *ZitiFabricAPI) initHandlerCache() { + o.Context() // don't care about the result, just that the initialization happened + if o.handlers == nil { + o.handlers = make(map[string]map[string]http.Handler) + } + + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/routers"] = router.NewCreateRouter(o.context, o.RouterCreateRouterHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services"] = service.NewCreateService(o.context, o.ServiceCreateServiceHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/terminators"] = terminator.NewCreateTerminator(o.context, o.TerminatorCreateTerminatorHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/routers/{id}"] = router.NewDeleteRouter(o.context, o.RouterDeleteRouterHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/{id}"] = service.NewDeleteService(o.context, o.ServiceDeleteServiceHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/terminators/{id}"] = terminator.NewDeleteTerminator(o.context, o.TerminatorDeleteTerminatorHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/routers/{id}"] = router.NewDetailRouter(o.context, o.RouterDetailRouterHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/{id}"] = service.NewDetailService(o.context, o.ServiceDetailServiceHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/terminators/{id}"] = terminator.NewDetailTerminator(o.context, o.TerminatorDetailTerminatorHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/routers/{id}/terminators"] = router.NewListRouterTerminators(o.context, o.RouterListRouterTerminatorsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/routers"] = router.NewListRouters(o.context, o.RouterListRoutersHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/{id}/terminators"] = service.NewListServiceTerminators(o.context, o.ServiceListServiceTerminatorsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services"] = service.NewListServices(o.context, o.ServiceListServicesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/terminators"] = terminator.NewListTerminators(o.context, o.TerminatorListTerminatorsHandler) + if o.handlers["PATCH"] == nil { + o.handlers["PATCH"] = make(map[string]http.Handler) + } + o.handlers["PATCH"]["/services/{id}"] = service.NewPatchService(o.context, o.ServicePatchServiceHandler) + if o.handlers["PATCH"] == nil { + o.handlers["PATCH"] = make(map[string]http.Handler) + } + o.handlers["PATCH"]["/terminators/{id}"] = terminator.NewPatchTerminator(o.context, o.TerminatorPatchTerminatorHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/services/{id}"] = service.NewUpdateService(o.context, o.ServiceUpdateServiceHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/terminators/{id}"] = terminator.NewUpdateTerminator(o.context, o.TerminatorUpdateTerminatorHandler) +} + +// Serve creates a http handler to serve the API over HTTP +// can be used directly in http.ListenAndServe(":8000", api.Serve(nil)) +func (o *ZitiFabricAPI) Serve(builder middleware.Builder) http.Handler { + o.Init() + + if o.Middleware != nil { + return o.Middleware(builder) + } + if o.useSwaggerUI { + return o.context.APIHandlerSwaggerUI(builder) + } + return o.context.APIHandler(builder) +} + +// Init allows you to just initialize the handler cache, you can then recompose the middleware as you see fit +func (o *ZitiFabricAPI) Init() { + if len(o.handlers) == 0 { + o.initHandlerCache() + } +} + +// RegisterConsumer allows you to add (or override) a consumer for a media type. +func (o *ZitiFabricAPI) RegisterConsumer(mediaType string, consumer runtime.Consumer) { + o.customConsumers[mediaType] = consumer +} + +// RegisterProducer allows you to add (or override) a producer for a media type. +func (o *ZitiFabricAPI) RegisterProducer(mediaType string, producer runtime.Producer) { + o.customProducers[mediaType] = producer +} + +// AddMiddlewareFor adds a http middleware to existing handler +func (o *ZitiFabricAPI) AddMiddlewareFor(method, path string, builder middleware.Builder) { + um := strings.ToUpper(method) + if path == "/" { + path = "" + } + o.Init() + if h, ok := o.handlers[um][path]; ok { + o.handlers[method][path] = builder(h) + } +} diff --git a/rest_server/server.go b/rest_server/server.go new file mode 100644 index 000000000..a92a0c9b8 --- /dev/null +++ b/rest_server/server.go @@ -0,0 +1,532 @@ +// 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 rest_server + +import ( + "context" + "crypto/tls" + "crypto/x509" + "errors" + "fmt" + "io/ioutil" + "log" + "net" + "net/http" + "os" + "os/signal" + "strconv" + "sync" + "sync/atomic" + "syscall" + "time" + + "github.com/go-openapi/runtime/flagext" + "github.com/go-openapi/swag" + flags "github.com/jessevdk/go-flags" + "golang.org/x/net/netutil" + + "github.com/openziti/fabric/rest_server/operations" +) + +const ( + schemeHTTP = "http" + schemeHTTPS = "https" + schemeUnix = "unix" +) + +var defaultSchemes []string + +func init() { + defaultSchemes = []string{ + schemeHTTPS, + } +} + +// NewServer creates a new api ziti fabric server but does not configure it +func NewServer(api *operations.ZitiFabricAPI) *Server { + s := new(Server) + + s.shutdown = make(chan struct{}) + s.api = api + s.interrupt = make(chan os.Signal, 1) + return s +} + +// ConfigureAPI configures the API and handlers. +func (s *Server) ConfigureAPI() { + if s.api != nil { + s.handler = configureAPI(s.api) + } +} + +// ConfigureFlags configures the additional flags defined by the handlers. Needs to be called before the parser.Parse +func (s *Server) ConfigureFlags() { + if s.api != nil { + configureFlags(s.api) + } +} + +// Server for the ziti fabric API +type Server struct { + EnabledListeners []string `long:"scheme" description:"the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec"` + CleanupTimeout time.Duration `long:"cleanup-timeout" description:"grace period for which to wait before killing idle connections" default:"10s"` + GracefulTimeout time.Duration `long:"graceful-timeout" description:"grace period for which to wait before shutting down the server" default:"15s"` + MaxHeaderSize flagext.ByteSize `long:"max-header-size" description:"controls the maximum number of bytes the server will read parsing the request header's keys and values, including the request line. It does not limit the size of the request body." default:"1MiB"` + + SocketPath flags.Filename `long:"socket-path" description:"the unix socket to listen on" default:"/var/run/ziti-fabric.sock"` + domainSocketL net.Listener + + Host string `long:"host" description:"the IP to listen on" default:"localhost" env:"HOST"` + Port int `long:"port" description:"the port to listen on for insecure connections, defaults to a random value" env:"PORT"` + ListenLimit int `long:"listen-limit" description:"limit the number of outstanding requests"` + KeepAlive time.Duration `long:"keep-alive" description:"sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)" default:"3m"` + ReadTimeout time.Duration `long:"read-timeout" description:"maximum duration before timing out read of the request" default:"30s"` + WriteTimeout time.Duration `long:"write-timeout" description:"maximum duration before timing out write of the response" default:"60s"` + httpServerL net.Listener + + TLSHost string `long:"tls-host" description:"the IP to listen on for tls, when not specified it's the same as --host" env:"TLS_HOST"` + TLSPort int `long:"tls-port" description:"the port to listen on for secure connections, defaults to a random value" env:"TLS_PORT"` + TLSCertificate flags.Filename `long:"tls-certificate" description:"the certificate to use for secure connections" env:"TLS_CERTIFICATE"` + TLSCertificateKey flags.Filename `long:"tls-key" description:"the private key to use for secure connections" env:"TLS_PRIVATE_KEY"` + TLSCACertificate flags.Filename `long:"tls-ca" description:"the certificate authority file to be used with mutual tls auth" env:"TLS_CA_CERTIFICATE"` + TLSListenLimit int `long:"tls-listen-limit" description:"limit the number of outstanding requests"` + TLSKeepAlive time.Duration `long:"tls-keep-alive" description:"sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)"` + TLSReadTimeout time.Duration `long:"tls-read-timeout" description:"maximum duration before timing out read of the request"` + TLSWriteTimeout time.Duration `long:"tls-write-timeout" description:"maximum duration before timing out write of the response"` + httpsServerL net.Listener + + api *operations.ZitiFabricAPI + handler http.Handler + hasListeners bool + shutdown chan struct{} + shuttingDown int32 + interrupted bool + interrupt chan os.Signal +} + +// Logf logs message either via defined user logger or via system one if no user logger is defined. +func (s *Server) Logf(f string, args ...interface{}) { + if s.api != nil && s.api.Logger != nil { + s.api.Logger(f, args...) + } else { + log.Printf(f, args...) + } +} + +// Fatalf logs message either via defined user logger or via system one if no user logger is defined. +// Exits with non-zero status after printing +func (s *Server) Fatalf(f string, args ...interface{}) { + if s.api != nil && s.api.Logger != nil { + s.api.Logger(f, args...) + os.Exit(1) + } else { + log.Fatalf(f, args...) + } +} + +// SetAPI configures the server with the specified API. Needs to be called before Serve +func (s *Server) SetAPI(api *operations.ZitiFabricAPI) { + if api == nil { + s.api = nil + s.handler = nil + return + } + + s.api = api + s.handler = configureAPI(api) +} + +func (s *Server) hasScheme(scheme string) bool { + schemes := s.EnabledListeners + if len(schemes) == 0 { + schemes = defaultSchemes + } + + for _, v := range schemes { + if v == scheme { + return true + } + } + return false +} + +// Serve the api +func (s *Server) Serve() (err error) { + if !s.hasListeners { + if err = s.Listen(); err != nil { + return err + } + } + + // set default handler, if none is set + if s.handler == nil { + if s.api == nil { + return errors.New("can't create the default handler, as no api is set") + } + + s.SetHandler(s.api.Serve(nil)) + } + + wg := new(sync.WaitGroup) + once := new(sync.Once) + signalNotify(s.interrupt) + go handleInterrupt(once, s) + + servers := []*http.Server{} + + if s.hasScheme(schemeUnix) { + domainSocket := new(http.Server) + domainSocket.MaxHeaderBytes = int(s.MaxHeaderSize) + domainSocket.Handler = s.handler + if int64(s.CleanupTimeout) > 0 { + domainSocket.IdleTimeout = s.CleanupTimeout + } + + configureServer(domainSocket, "unix", string(s.SocketPath)) + + servers = append(servers, domainSocket) + wg.Add(1) + s.Logf("Serving ziti fabric at unix://%s", s.SocketPath) + go func(l net.Listener) { + defer wg.Done() + if err := domainSocket.Serve(l); err != nil && err != http.ErrServerClosed { + s.Fatalf("%v", err) + } + s.Logf("Stopped serving ziti fabric at unix://%s", s.SocketPath) + }(s.domainSocketL) + } + + if s.hasScheme(schemeHTTP) { + httpServer := new(http.Server) + httpServer.MaxHeaderBytes = int(s.MaxHeaderSize) + httpServer.ReadTimeout = s.ReadTimeout + httpServer.WriteTimeout = s.WriteTimeout + httpServer.SetKeepAlivesEnabled(int64(s.KeepAlive) > 0) + if s.ListenLimit > 0 { + s.httpServerL = netutil.LimitListener(s.httpServerL, s.ListenLimit) + } + + if int64(s.CleanupTimeout) > 0 { + httpServer.IdleTimeout = s.CleanupTimeout + } + + httpServer.Handler = s.handler + + configureServer(httpServer, "http", s.httpServerL.Addr().String()) + + servers = append(servers, httpServer) + wg.Add(1) + s.Logf("Serving ziti fabric at http://%s", s.httpServerL.Addr()) + go func(l net.Listener) { + defer wg.Done() + if err := httpServer.Serve(l); err != nil && err != http.ErrServerClosed { + s.Fatalf("%v", err) + } + s.Logf("Stopped serving ziti fabric at http://%s", l.Addr()) + }(s.httpServerL) + } + + if s.hasScheme(schemeHTTPS) { + httpsServer := new(http.Server) + httpsServer.MaxHeaderBytes = int(s.MaxHeaderSize) + httpsServer.ReadTimeout = s.TLSReadTimeout + httpsServer.WriteTimeout = s.TLSWriteTimeout + httpsServer.SetKeepAlivesEnabled(int64(s.TLSKeepAlive) > 0) + if s.TLSListenLimit > 0 { + s.httpsServerL = netutil.LimitListener(s.httpsServerL, s.TLSListenLimit) + } + if int64(s.CleanupTimeout) > 0 { + httpsServer.IdleTimeout = s.CleanupTimeout + } + httpsServer.Handler = s.handler + + // Inspired by https://blog.bracebin.com/achieving-perfect-ssl-labs-score-with-go + httpsServer.TLSConfig = &tls.Config{ + // Causes servers to use Go's default ciphersuite preferences, + // which are tuned to avoid attacks. Does nothing on clients. + PreferServerCipherSuites: true, + // Only use curves which have assembly implementations + // https://github.com/golang/go/tree/master/src/crypto/elliptic + CurvePreferences: []tls.CurveID{tls.CurveP256}, + // Use modern tls mode https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility + NextProtos: []string{"h2", "http/1.1"}, + // https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet#Rule_-_Only_Support_Strong_Protocols + MinVersion: tls.VersionTLS12, + // These ciphersuites support Forward Secrecy: https://en.wikipedia.org/wiki/Forward_secrecy + CipherSuites: []uint16{ + tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, + tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, + }, + } + + // build standard config from server options + if s.TLSCertificate != "" && s.TLSCertificateKey != "" { + httpsServer.TLSConfig.Certificates = make([]tls.Certificate, 1) + httpsServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(string(s.TLSCertificate), string(s.TLSCertificateKey)) + if err != nil { + return err + } + } + + if s.TLSCACertificate != "" { + // include specified CA certificate + caCert, caCertErr := ioutil.ReadFile(string(s.TLSCACertificate)) + if caCertErr != nil { + return caCertErr + } + caCertPool := x509.NewCertPool() + ok := caCertPool.AppendCertsFromPEM(caCert) + if !ok { + return fmt.Errorf("cannot parse CA certificate") + } + httpsServer.TLSConfig.ClientCAs = caCertPool + httpsServer.TLSConfig.ClientAuth = tls.RequireAndVerifyClientCert + } + + // call custom TLS configurator + configureTLS(httpsServer.TLSConfig) + + if len(httpsServer.TLSConfig.Certificates) == 0 && httpsServer.TLSConfig.GetCertificate == nil { + // after standard and custom config are passed, this ends up with no certificate + if s.TLSCertificate == "" { + if s.TLSCertificateKey == "" { + s.Fatalf("the required flags `--tls-certificate` and `--tls-key` were not specified") + } + s.Fatalf("the required flag `--tls-certificate` was not specified") + } + if s.TLSCertificateKey == "" { + s.Fatalf("the required flag `--tls-key` was not specified") + } + // this happens with a wrong custom TLS configurator + s.Fatalf("no certificate was configured for TLS") + } + + configureServer(httpsServer, "https", s.httpsServerL.Addr().String()) + + servers = append(servers, httpsServer) + wg.Add(1) + s.Logf("Serving ziti fabric at https://%s", s.httpsServerL.Addr()) + go func(l net.Listener) { + defer wg.Done() + if err := httpsServer.Serve(l); err != nil && err != http.ErrServerClosed { + s.Fatalf("%v", err) + } + s.Logf("Stopped serving ziti fabric at https://%s", l.Addr()) + }(tls.NewListener(s.httpsServerL, httpsServer.TLSConfig)) + } + + wg.Add(1) + go s.handleShutdown(wg, &servers) + + wg.Wait() + return nil +} + +// Listen creates the listeners for the server +func (s *Server) Listen() error { + if s.hasListeners { // already done this + return nil + } + + if s.hasScheme(schemeHTTPS) { + // Use http host if https host wasn't defined + if s.TLSHost == "" { + s.TLSHost = s.Host + } + // Use http listen limit if https listen limit wasn't defined + if s.TLSListenLimit == 0 { + s.TLSListenLimit = s.ListenLimit + } + // Use http tcp keep alive if https tcp keep alive wasn't defined + if int64(s.TLSKeepAlive) == 0 { + s.TLSKeepAlive = s.KeepAlive + } + // Use http read timeout if https read timeout wasn't defined + if int64(s.TLSReadTimeout) == 0 { + s.TLSReadTimeout = s.ReadTimeout + } + // Use http write timeout if https write timeout wasn't defined + if int64(s.TLSWriteTimeout) == 0 { + s.TLSWriteTimeout = s.WriteTimeout + } + } + + if s.hasScheme(schemeUnix) { + domSockListener, err := net.Listen("unix", string(s.SocketPath)) + if err != nil { + return err + } + s.domainSocketL = domSockListener + } + + if s.hasScheme(schemeHTTP) { + listener, err := net.Listen("tcp", net.JoinHostPort(s.Host, strconv.Itoa(s.Port))) + if err != nil { + return err + } + + h, p, err := swag.SplitHostPort(listener.Addr().String()) + if err != nil { + return err + } + s.Host = h + s.Port = p + s.httpServerL = listener + } + + if s.hasScheme(schemeHTTPS) { + tlsListener, err := net.Listen("tcp", net.JoinHostPort(s.TLSHost, strconv.Itoa(s.TLSPort))) + if err != nil { + return err + } + + sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + if err != nil { + return err + } + s.TLSHost = sh + s.TLSPort = sp + s.httpsServerL = tlsListener + } + + s.hasListeners = true + return nil +} + +// Shutdown server and clean up resources +func (s *Server) Shutdown() error { + if atomic.CompareAndSwapInt32(&s.shuttingDown, 0, 1) { + close(s.shutdown) + } + return nil +} + +func (s *Server) handleShutdown(wg *sync.WaitGroup, serversPtr *[]*http.Server) { + // wg.Done must occur last, after s.api.ServerShutdown() + // (to preserve old behaviour) + defer wg.Done() + + <-s.shutdown + + servers := *serversPtr + + ctx, cancel := context.WithTimeout(context.TODO(), s.GracefulTimeout) + defer cancel() + + // first execute the pre-shutdown hook + s.api.PreServerShutdown() + + shutdownChan := make(chan bool) + for i := range servers { + server := servers[i] + go func() { + var success bool + defer func() { + shutdownChan <- success + }() + if err := server.Shutdown(ctx); err != nil { + // Error from closing listeners, or context timeout: + s.Logf("HTTP server Shutdown: %v", err) + } else { + success = true + } + }() + } + + // Wait until all listeners have successfully shut down before calling ServerShutdown + success := true + for range servers { + success = success && <-shutdownChan + } + if success { + s.api.ServerShutdown() + } +} + +// GetHandler returns a handler useful for testing +func (s *Server) GetHandler() http.Handler { + return s.handler +} + +// SetHandler allows for setting a http handler on this server +func (s *Server) SetHandler(handler http.Handler) { + s.handler = handler +} + +// UnixListener returns the domain socket listener +func (s *Server) UnixListener() (net.Listener, error) { + if !s.hasListeners { + if err := s.Listen(); err != nil { + return nil, err + } + } + return s.domainSocketL, nil +} + +// HTTPListener returns the http listener +func (s *Server) HTTPListener() (net.Listener, error) { + if !s.hasListeners { + if err := s.Listen(); err != nil { + return nil, err + } + } + return s.httpServerL, nil +} + +// TLSListener returns the https listener +func (s *Server) TLSListener() (net.Listener, error) { + if !s.hasListeners { + if err := s.Listen(); err != nil { + return nil, err + } + } + return s.httpsServerL, nil +} + +func handleInterrupt(once *sync.Once, s *Server) { + once.Do(func() { + for range s.interrupt { + if s.interrupted { + s.Logf("Server already shutting down") + continue + } + s.interrupted = true + s.Logf("Shutting down... ") + if err := s.Shutdown(); err != nil { + s.Logf("HTTP server Shutdown: %v", err) + } + } + }) +} + +func signalNotify(interrupt chan<- os.Signal) { + signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM) +} diff --git a/scripts/generate_rest.ps1 b/scripts/generate_rest.ps1 new file mode 100644 index 000000000..05b742ca0 --- /dev/null +++ b/scripts/generate_rest.ps1 @@ -0,0 +1,71 @@ +$PSDefaultParameterValues += @{ 'New-RegKey:ErrorAction' = 'Stop' } +try +{ + Get-Command swagger -ErrorAction "SilentlyContinue" | Out-Null + if (-not$?) + { + throw "Command 'swagger' not installed. See: https://github.com/go-swagger/go-swagger for installation" + } + + $zitiEdgeDir = Join-Path $PSScriptRoot "../" -Resolve + + $copyrightFile = Join-Path $PSScriptRoot "template.copyright.txt" -Resolve + + $swagSpec = Join-Path $zitiEdgeDir "/specs/swagger.yml" -Resolve + "...reading spec from $swagSpec" + + $serverPath = Join-Path $zitiEdgeDir "/rest_server" + "...removing any existing server from $serverPath" + Remove-Item $serverPath -Recurse -Force -ErrorAction "SilentlyContinue" | Out-Null + New-Item -ItemType "directory" -Path $serverPath -ErrorAction "SilentlyContinue" | Out-Null + + $clientPath = Join-Path $zitiEdgeDir "/rest_client" + "...removing any existing client from $clientPath" + Remove-Item $clientPath -Recurse -Force -ErrorAction "SilentlyContinue" | Out-Null + New-Item -ItemType "directory" -Path $clientPath -ErrorAction "SilentlyContinue" | Out-Null + + $modelPath = Join-Path $zitiEdgeDir "/rest_model" + "...removing any existing model from $modelPath" + Remove-Item $modelPath -Recurse -Force -ErrorAction "SilentlyContinue" | Out-Null + New-Item -ItemType "directory" -Path $modelPath -ErrorAction "SilentlyContinue" | Out-Null + + + "...generating server" + swagger generate server --exclude-main -f $swagSpec -s rest_server -t $zitiEdgeDir -q -r $copyrightFile -m "rest_model" + if (-not$?) + { + throw "Failed to generate server. See above." + } + "...generating client" + swagger generate client -f $swagSpec -c rest_client -t $zitiEdgeDir -q -r $copyrightFile -m "rest_model" + if (-not$?) + { + throw "Failed to generate client. See above." + } + + "...fixing up windows slashes" + # This one file has the command used to generate the server in it w/ paths. The path sep is OS specific. + # On Windows this causes this one file to show changes depending on the OS that generated it. This + # works around those changes from showing up in commits by switching to forward slashes. + # + # There appears to be no option to suppress this line in the `swagger` executable. + $configureFile = Join-Path $serverPath "/configure_ziti_edge.go" -Resolve + + $content = "" + foreach ($line in Get-Content $configureFile) + { + if ($line -match "^//go:generate swagger generate server") + { + $line = $line -replace "\\", "/" + } + + $content = $content + $line + "`n" + } + + $content | Set-Content $configureFile -nonewline + +} +catch +{ + [Console]::Error.WriteLine($Error[0]) +} \ No newline at end of file diff --git a/scripts/generate_rest.sh b/scripts/generate_rest.sh new file mode 100755 index 000000000..e01f3c4af --- /dev/null +++ b/scripts/generate_rest.sh @@ -0,0 +1,44 @@ +#!/bin/bash -e + +command -v swagger >/dev/null 2>&1 || { + echo >&2 "Command 'swagger' not installed. See: https://github.com/go-swagger/go-swagger for installation" + exit 1 +} + +scriptPath=$(realpath $0) +scriptDir=$(dirname "$scriptPath") + +zitiEdgeDir=$(realpath "$scriptDir/..") +swagSpec=$(realpath "$zitiEdgeDir/specs/swagger.yml") +copyrightFile=$(realpath "$scriptDir/template.copyright.txt") + +serverPath=$(realpath "$zitiEdgeDir/rest_server") +echo "...removing any existing server from $serverPath" +rm -rf "$serverPath" +mkdir -p "$serverPath" + +clientPath=$(realpath "$zitiEdgeDir/rest_client") +echo "...removing any existing client from $clientPath" +rm -rf "$clientPath" +mkdir -p "$clientPath" + +modelPath=$(realpath "$zitiEdgeDir/rest_model") +echo "...removing any existing model from $modelPath" +rm -rf "$modelPath" +mkdir -p "$modelPath" + +echo "...generating server" +swagger generate server --exclude-main -f "$swagSpec" -s rest_server -t "$zitiEdgeDir" -q -r "$copyrightFile" -m "rest_model" +exit_status=$? +if [ ${exit_status} -ne 0 ]; then + echo "Failed to generate server. See above." + exit "${exit_status}" +fi + +echo "...generating client" +swagger generate client -f "$swagSpec" -c rest_client -t "$zitiEdgeDir" -q -r "$copyrightFile" -m "rest_model" +exit_status=$? +if [ ${exit_status} -ne 0 ]; then + echo "Failed to generate client. See above." + exit "${exit_status}" +fi diff --git a/scripts/template.copyright.txt b/scripts/template.copyright.txt new file mode 100644 index 000000000..c5e1321c6 --- /dev/null +++ b/scripts/template.copyright.txt @@ -0,0 +1,23 @@ + +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. + \/ \/ \__,_|_| |_| |_|_|_| |_|\__, | + __/ | + |___/ \ No newline at end of file diff --git a/specs/swagger.yml b/specs/swagger.yml new file mode 100644 index 000000000..da7ff723c --- /dev/null +++ b/specs/swagger.yml @@ -0,0 +1,1130 @@ +--- +swagger: '2.0' +info: + version: 0.16.54 + title: Ziti Fabric + contact: {} +host: demo.ziti.dev +basePath: /fabric/v1 +schemes: + - https +consumes: + - application/json +produces: + - application/json + +####################################################################################################################### +# +# Paths - Endpoints and their associated HTTP methods +# +####################################################################################################################### +paths: + ################################################################### + # Services + ################################################################## + '/services': + get: + summary: List services + description: | + Retrieves a list of service resources; supports filtering, sorting, and pagination. Requires admin access. + tags: + - Service + operationId: listServices + parameters: + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/filter' + responses: + '200': + $ref: '#/responses/listServices' + '401': + $ref: '#/responses/unauthorizedResponse' + post: + summary: Create a service resource + description: Create a service resource. Requires admin access. + tags: + - Service + operationId: createService + parameters: + - name: service + in: body + required: true + description: A service to create + schema: + $ref: '#/definitions/serviceCreate' + responses: + '201': + $ref: '#/responses/createResponse' + '400': + $ref: '#/responses/badRequestResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + '/services/{id}': + parameters: + - $ref: '#/parameters/id' + get: + summary: Retrieves a single service + description: Retrieves a single service by id. Requires admin access. + tags: + - Service + operationId: detailService + responses: + '200': + $ref: '#/responses/detailService' + '404': + $ref: '#/responses/notFoundResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + put: + summary: Update all fields on a service + description: Update all fields on a service by id. Requires admin access. + tags: + - Service + operationId: updateService + parameters: + - name: service + in: body + required: true + description: A service update object + schema: + $ref: '#/definitions/serviceUpdate' + responses: + '200': + $ref: '#/responses/updateResponse' + '400': + $ref: '#/responses/badRequestResponse' + '404': + $ref: '#/responses/notFoundResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + patch: + summary: Update the supplied fields on a service + description: Update the supplied fields on a service. Requires admin access. + tags: + - Service + operationId: patchService + parameters: + - name: service + in: body + required: true + description: A service patch object + schema: + $ref: '#/definitions/servicePatch' + responses: + '200': + $ref: '#/responses/patchResponse' + '400': + $ref: '#/responses/badRequestResponse' + '404': + $ref: '#/responses/notFoundResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + delete: + summary: Delete a service + description: Delete a service by id. Requires admin access. + tags: + - Service + operationId: deleteService + responses: + '200': + $ref: '#/responses/deleteResponse' + '400': + $ref: '#/responses/badRequestResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + '409': + $ref: '#/responses/cannotDeleteReferencedResourceResponse' + + '/services/{id}/terminators': + parameters: + - $ref: '#/parameters/id' + get: + summary: List of terminators assigned to a service + description: | + Retrieves a list of terminator resources that are assigned specific service; supports filtering, sorting, and pagination. + tags: + - Service + operationId: listServiceTerminators + parameters: + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/filter' + responses: + '200': + $ref: '#/responses/listTerminators' + '401': + $ref: '#/responses/unauthorizedResponse' + '400': + $ref: '#/responses/badRequestResponse' + + ################################################################### + # Routers + ################################################################## + '/routers': + get: + summary: List routers + description: | + Retrieves a list of router resources; supports filtering, sorting, and pagination. Requires admin access. + tags: + - Router + operationId: listRouters + parameters: + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/filter' + responses: + '200': + $ref: '#/responses/listRouters' + '401': + $ref: '#/responses/unauthorizedResponse' + post: + summary: Create a router resource + description: Create a router resource. Requires admin access. + tags: + - Router + operationId: createRouter + parameters: + - name: router + in: body + required: true + description: A router to create + schema: + $ref: '#/definitions/routerCreate' + responses: + '201': + $ref: '#/responses/createResponse' + '400': + $ref: '#/responses/badRequestResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + '/routers/{id}': + parameters: + - $ref: '#/parameters/id' + get: + summary: Retrieves a single router + description: Retrieves a single router by id. Requires admin access. + tags: + - Router + operationId: detailRouter + responses: + '200': + $ref: '#/responses/detailRouter' + '404': + $ref: '#/responses/notFoundResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + # put: + # summary: Update all fields on a router + # description: Update all fields on a router by id. Requires admin access. + # tags: + # - Router + # operationId: updateRouter + # parameters: + # - name: router + # in: body + # required: true + # description: A router update object + # schema: + # $ref: '#/definitions/routerUpdate' + # responses: + # '200': + # $ref: '#/responses/updateResponse' + # '400': + # $ref: '#/responses/badRequestResponse' + # '404': + # $ref: '#/responses/notFoundResponse' + # '401': + # $ref: '#/responses/unauthorizedResponse' + # patch: + # summary: Update the supplied fields on a router + # description: Update the supplied fields on a router. Requires admin access. + # tags: + # - Router + # operationId: patchRouter + # parameters: + # - name: router + # in: body + # required: true + # description: A router patch object + # schema: + # $ref: '#/definitions/routerPatch' + # responses: + # '200': + # $ref: '#/responses/patchResponse' + # '400': + # $ref: '#/responses/badRequestResponse' + # '404': + # $ref: '#/responses/notFoundResponse' + # '401': + # $ref: '#/responses/unauthorizedResponse' + delete: + summary: Delete a router + description: Delete a router by id. Requires admin access. + tags: + - Router + operationId: deleteRouter + responses: + '200': + $ref: '#/responses/deleteResponse' + '400': + $ref: '#/responses/badRequestResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + '409': + $ref: '#/responses/cannotDeleteReferencedResourceResponse' + + '/routers/{id}/terminators': + parameters: + - $ref: '#/parameters/id' + get: + summary: List of terminators assigned to a router + description: | + Retrieves a list of terminator resources that are assigned specific router; supports filtering, sorting, and pagination. + tags: + - Router + operationId: listRouterTerminators + parameters: + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/filter' + responses: + '200': + $ref: '#/responses/listTerminators' + '401': + $ref: '#/responses/unauthorizedResponse' + '400': + $ref: '#/responses/badRequestResponse' + + ################################################################### + # Terminators + ################################################################## + '/terminators': + get: + summary: List terminators + description: | + Retrieves a list of terminator resources; supports filtering, sorting, and pagination. Requires admin access. + tags: + - Terminator + operationId: listTerminators + parameters: + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/filter' + responses: + '200': + $ref: '#/responses/listTerminators' + '401': + $ref: '#/responses/unauthorizedResponse' + '400': + $ref: '#/responses/badRequestResponse' + post: + summary: Create a terminator resource + description: Create a terminator resource. Requires admin access. + tags: + - Terminator + operationId: createTerminator + parameters: + - name: terminator + in: body + required: true + description: A terminator to create + schema: + $ref: '#/definitions/terminatorCreate' + responses: + '201': + $ref: '#/responses/createResponse' + '400': + $ref: '#/responses/badRequestResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + '/terminators/{id}': + parameters: + - $ref: '#/parameters/id' + get: + summary: Retrieves a single terminator + description: Retrieves a single terminator by id. Requires admin access. + tags: + - Terminator + operationId: detailTerminator + responses: + '200': + $ref: '#/responses/detailTerminator' + '404': + $ref: '#/responses/notFoundResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + put: + summary: Update all fields on a terminator + description: Update all fields on a terminator by id. Requires admin access. + tags: + - Terminator + operationId: updateTerminator + parameters: + - name: terminator + in: body + required: true + description: A terminator update object + schema: + $ref: '#/definitions/terminatorUpdate' + responses: + '200': + $ref: '#/responses/updateResponse' + '400': + $ref: '#/responses/badRequestResponse' + '404': + $ref: '#/responses/notFoundResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + patch: + summary: Update the supplied fields on a terminator + description: Update the supplied fields on a terminator. Requires admin access. + tags: + - Terminator + operationId: patchTerminator + parameters: + - name: terminator + in: body + required: true + description: A terminator patch object + schema: + $ref: '#/definitions/terminatorPatch' + responses: + '200': + $ref: '#/responses/patchResponse' + '400': + $ref: '#/responses/badRequestResponse' + '404': + $ref: '#/responses/notFoundResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + delete: + summary: Delete a terminator + description: Delete a terminator by id. Requires admin access. + tags: + - Terminator + operationId: deleteTerminator + responses: + '200': + $ref: '#/responses/deleteResponse' + '400': + $ref: '#/responses/badRequestResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + '409': + $ref: '#/responses/cannotDeleteReferencedResourceResponse' + +####################################################################################################################### +# +# Parameters - Reusable parameters +# +####################################################################################################################### +parameters: + id: + name: id + required: true + type: string + in: path + description: The id of the requested resource + limit: + name: limit + type: integer + in: query + offset: + name: offset + type: integer + in: query + filter: + name: filter + type: string + in: query + +####################################################################################################################### +# +# Responses - Envelope Wrapped Definitions +# +####################################################################################################################### +responses: + ################################################################### + # Errors + ################################################################## + badRequestResponse: + description: 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 + schema: + $ref: '#/definitions/apiErrorEnvelope' + examples: + 'application/json': + error: + args: + urlVars: {} + cause: + field: '(root)' + type: required + value: + fooField: abc + fooField2: def + message: '(root): fooField3 is required' + details: + context: '(root)' + field: '(root)' + property: fooField3 + causeMessage: schema validation failed + code: COULD_NOT_VALIDATE + message: The supplied request contains an invalid document + requestId: ac6766d6-3a09-44b3-8d8a-1b541d97fdd9 + meta: + apiEnrollmentVersion: 0.0.1 + apiVersion: 0.0.1 + unauthorizedResponse: + description: The currently supplied session does not have the correct access rights to request this resource + schema: + $ref: '#/definitions/apiErrorEnvelope' + examples: + 'application/json': + error: + args: + urlVars: {} + cause: '' + causeMessage: '' + code: UNAUTHORIZED + message: The request could not be completed. The session is not authorized or the + credentials are invalid + requestId: 0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f + meta: + apiEnrollmentVersion: 0.0.1 + apiVersion: 0.0.1 + invalidAuthResponse: + description: The authentication request could not be processed as the credentials are invalid + schema: + $ref: '#/definitions/apiErrorEnvelope' + examples: + 'application/json': + error: + args: + urlVars: {} + cause: '' + causeMessage: '' + code: INVALID_AUTH + message: The authentication request failed + requestId: 5952ed10-3091-474f-a691-47ebab6990dc + meta: + apiEnrollmentVersion: 0.0.1 + apiVersion: 0.0.1 + notFoundResponse: + description: The requested resource does not exist + schema: + $ref: '#/definitions/apiErrorEnvelope' + examples: + 'application/json': + error: + args: + urlVars: + id: 71a3000f-7dda-491a-9b90-a19f4ee6c406 + cause: + causeMessage: '' + code: NOT_FOUND + message: The resource requested was not found or is no longer available + requestId: 270908d6-f2ef-4577-b973-67bec18ae376 + meta: + apiEnrollmentVersion: 0.0.1 + apiVersion: 0.0.1 + cannotDeleteReferencedResourceResponse: + description: The resource requested to be removed/altered cannot be as it is referenced by another object. + schema: + $ref: '#/definitions/apiErrorEnvelope' + examples: + 'application/json': + error: + args: + urlVars: + id: 71a3000f-7dda-491a-9b90-a19f4ee6c406 + causeMessage: 'referenced by /some-resource/05f4f710-c155-4a74-86d5-77558eb9cb42' + code: CONFLICT_CANNOT_MODIFY_REFERENCED + message: The resource cannot be deleted/modified. Remove all referencing resources first. + requestId: 270908d6-f2ef-4577-b973-67bec18ae376 + meta: + apiEnrollmentVersion: 0.0.1 + apiVersion: 0.0.1 + rateLimitedResponse: + description: The resource requested is rate limited and the rate limit has been exceeded + schema: + $ref: '#/definitions/apiErrorEnvelope' + examples: + 'application/json': + error: + args: + urlVars: {} + causeMessage: 'you have hit a rate limit in the requested operation' + code: RATE_LIMITED + message: The resource is rate limited and the rate limit has been exceeded. Please try again later + requestId: 270908d6-f2ef-4577-b973-67bec18ae376 + meta: + apiEnrollmentVersion: 0.0.1 + apiVersion: 0.0.1 + + ################################################################### + # Standard Responses + ################################################################## + emptyResponse: + description: Base empty response + schema: + $ref: '#/definitions/empty' + deleteResponse: + description: The delete request was successful and the resource has been removed + schema: + $ref: '#/definitions/empty' + updateResponse: + description: The update request was successful and the resource has been altered + schema: + $ref: '#/definitions/empty' + patchResponse: + description: The patch request was successful and the resource has been altered + schema: + $ref: '#/definitions/empty' + createResponse: + description: The create request was successful and the resource has been added at the following location + schema: + $ref: '#/definitions/createEnvelope' + + ################################################################### + # Services + ################################################################## + listServices: + description: A list of services + schema: + $ref: '#/definitions/listServicesEnvelope' + detailService: + description: A single service + schema: + $ref: '#/definitions/detailServiceEnvelope' + + ################################################################### + # Routers + ################################################################## + listRouters: + description: A list of routers + schema: + $ref: '#/definitions/listRoutersEnvelope' + detailRouter: + description: A single router + schema: + $ref: '#/definitions/detailRouterEnvelope' + + ################################################################### + # Terminators + ################################################################## + listTerminators: + description: A list of terminators + schema: + $ref: '#/definitions/listTerminatorsEnvelope' + detailTerminator: + description: A single terminator + schema: + $ref: '#/definitions/detailTerminatorEnvelope' + + +####################################################################################################################### +# +# Definitions - In & Out Models Only +# +####################################################################################################################### +definitions: + ################################################################### + # Standard + ################################################################## + pagination: + type: object + required: + - limit + - offset + - totalCount + properties: + limit: + type: number + format: int64 + offset: + type: number + format: int64 + totalCount: + type: number + format: int64 + + empty: + type: object + required: + - meta + - data + properties: + meta: + $ref: '#/definitions/meta' + data: + type: object + example: {} + meta: + type: object + properties: + filterableFields: + type: array + items: + type: string + x-omitempty: true + pagination: + $ref: '#/definitions/pagination' + apiEnrollmentVersion: + type: string + apiVersion: + type: string + createEnvelope: + type: object + properties: + meta: + $ref: '#/definitions/meta' + data: + $ref: '#/definitions/createLocation' + createLocation: + type: object + properties: + _links: + $ref: '#/definitions/links' + id: + type: string + + baseEntity: + description: Fields shared by all Edge API entities + type: object + required: + - id + - createdAt + - updatedAt + - _links + - tags + properties: + id: + type: string + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + _links: + $ref: '#/definitions/links' + tags: + $ref: '#/definitions/tags' + link: + description: A link to another resource + type: object + required: + - href + properties: + href: + type: string + format: uri + method: + type: string + comment: + type: string + links: + description: A map of named links + type: object + x-omitempty: false + additionalProperties: + $ref: '#/definitions/link' + entityRef: + description: A reference to another resource and links to interact with it + type: object + properties: + entity: + type: string + id: + type: string + name: + type: string + _links: + $ref: '#/definitions/links' + tags: + description: 'A map of user defined fields and values. The values are limited to the following types/values: null, string, boolean' + allOf: + - $ref: '#/definitions/subTags' + x-nullable: true + subTags: + type: object + additionalProperties: { + type: object + } + + versionInfo: + description: 'Application build information' + type: object + properties: + version: + type: string + revision: + type: string + buildDate: + type: string + os: + type: string + arch: + type: string + + ################################################################### + # Errors + ################################################################## + apiErrorEnvelope: + type: object + required: + - meta + - error + properties: + meta: + $ref: '#/definitions/meta' + error: + $ref: '#/definitions/apiError' + apiError: + type: object + properties: + args: + $ref: '#/definitions/apiErrorArgs' + data: + type: object + additionalProperties: true + causeMessage: + type: string + code: + type: string + message: + type: string + requestId: + type: string + cause: + $ref: '#/definitions/apiErrorCause' + apiFieldError: + type: object + properties: + reason: + type: string + field: + type: string + value: + type: string + apiErrorCause: + allOf: + - $ref: '#/definitions/apiFieldError' + - $ref: '#/definitions/apiError' + apiErrorArgs: + type: object + properties: + urlVars: + properties: {} + additionalProperties: + type: string + type: object + + ################################################################### + # Services + ################################################################## + listServicesEnvelope: + type: object + required: + - meta + - data + properties: + meta: + $ref: '#/definitions/meta' + data: + $ref: '#/definitions/serviceList' + detailServiceEnvelope: + type: object + required: + - meta + - data + properties: + meta: + $ref: '#/definitions/meta' + data: + $ref: '#/definitions/serviceDetail' + + serviceList: + type: array + items: + $ref: '#/definitions/serviceDetail' + serviceDetail: + type: object + allOf: + - $ref: '#/definitions/baseEntity' + - type: object + required: + - name + - terminatorStrategy + properties: + name: + type: string + terminatorStrategy: + type: string + serviceCreate: + type: object + required: + - name + properties: + name: + type: string + terminatorStrategy: + type: string + tags: + $ref: '#/definitions/tags' + serviceUpdate: + type: object + required: + - name + properties: + name: + type: string + terminatorStrategy: + type: string + tags: + $ref: '#/definitions/tags' + servicePatch: + type: object + properties: + name: + type: string + terminatorStrategy: + type: string + tags: + $ref: '#/definitions/tags' + + ################################################################### + # Routers + ################################################################## + listRoutersEnvelope: + type: object + required: + - meta + - data + properties: + meta: + $ref: '#/definitions/meta' + data: + $ref: '#/definitions/routerList' + detailRouterEnvelope: + type: object + required: + - meta + - data + properties: + meta: + $ref: '#/definitions/meta' + data: + $ref: '#/definitions/routerDetail' + + routerList: + type: array + items: + $ref: '#/definitions/routerDetail' + routerDetail: + type: object + allOf: + - $ref: '#/definitions/baseEntity' + - type: object + required: + - name + - fingerprint + - connected + properties: + name: + type: string + fingerprint: + type: string + connected: + type: boolean + listenerAddress: + type: string + versionInfo: + $ref: '#/definitions/versionInfo' + routerCreate: + type: object + required: + - id + - name + properties: + id: + type: string + name: + type: string + fingerprint: + type: string + x-nullable: true + tags: + $ref: '#/definitions/tags' + routerUpdate: + type: object + required: + - name + properties: + name: + type: string + fingerprint: + type: string + x-nullable: true + tags: + $ref: '#/definitions/tags' + routerPatch: + type: object + properties: + name: + type: string + fingerprint: + type: string + x-nullable: true + tags: + $ref: '#/definitions/tags' + + ################################################################### + # Terminators + ################################################################## + listTerminatorsEnvelope: + type: object + required: + - meta + - data + properties: + meta: + $ref: '#/definitions/meta' + data: + $ref: '#/definitions/terminatorList' + detailTerminatorEnvelope: + type: object + required: + - meta + - data + properties: + meta: + $ref: '#/definitions/meta' + data: + $ref: '#/definitions/terminatorDetail' + terminatorList: + type: array + items: + $ref: '#/definitions/terminatorDetail' + terminatorDetail: + type: object + allOf: + - $ref: '#/definitions/baseEntity' + - type: object + required: + - serviceId + - service + - routerId + - router + - binding + - address + - identity + - cost + - precedence + - dynamicCost + properties: + serviceId: + type: string + service: + $ref: '#/definitions/entityRef' + routerId: + type: string + router: + $ref: '#/definitions/entityRef' + binding: + type: string + address: + type: string + identity: + type: string + cost: + $ref: '#/definitions/terminatorCost' + precedence: + $ref: '#/definitions/terminatorPrecedence' + dynamicCost: + $ref: '#/definitions/terminatorCost' + terminatorCreate: + type: object + required: + - service + - router + - address + - binding + properties: + service: + type: string + router: + type: string + binding: + type: string + address: + type: string + identity: + type: string + identitySecret: + type: string + format: byte + cost: + $ref: '#/definitions/terminatorCost' + precedence: + $ref: '#/definitions/terminatorPrecedence' + tags: + $ref: '#/definitions/tags' + terminatorUpdate: + type: object + required: + - service + - router + - address + - binding + properties: + service: + type: string + router: + type: string + binding: + type: string + address: + type: string + cost: + $ref: '#/definitions/terminatorCost' + precedence: + $ref: '#/definitions/terminatorPrecedence' + tags: + $ref: '#/definitions/tags' + terminatorPatch: + type: object + properties: + service: + type: string + router: + type: string + binding: + type: string + address: + type: string + cost: + $ref: '#/definitions/terminatorCost' + precedence: + $ref: '#/definitions/terminatorPrecedence' + tags: + $ref: '#/definitions/tags' + + terminatorCost: + type: integer + minimum: 0 + maximum: 65535 + terminatorPrecedence: + type: string + enum: + - default + - required + - failed + terminatorPrecedenceMap: + type: object + additionalProperties: + $ref: '#/definitions/terminatorPrecedence' + terminatorCostMap: + type: object + additionalProperties: + $ref: '#/definitions/terminatorCost' \ No newline at end of file diff --git a/version b/version index 8eac30c38..50653ad0a 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.16 +0.17 diff --git a/xweb/server.go b/xweb/server.go index 5763155d0..ea8add3e4 100644 --- a/xweb/server.go +++ b/xweb/server.go @@ -31,7 +31,7 @@ import ( type ContextKey string const ( - WebHandlerContextKey = ContextKey("XWebHandlerContextKey") + WebHandlerContextKey = ContextKey("XWebHandlerContextKey") WebContextKey = ContextKey("XWebContext") ) @@ -79,7 +79,6 @@ func NewServer(webListener *WebListener, demuxFactory DemuxFactory, handlerFacto tlsConfig := webListener.Identity.ServerTLSConfig() tlsConfig.ClientAuth = tls.RequestClientCert - tlsConfig.MinVersion = uint16(webListener.Options.MinTLSVersion) tlsConfig.MaxVersion = uint16(webListener.Options.MaxTLSVersion) @@ -138,7 +137,7 @@ func NewServer(webListener *WebListener, demuxFactory DemuxFactory, handlerFacto } // wrapPanicRecovery wraps a http.Handler with another http.Handler that provides recovery. -func (server *Server) wrapPanicRecovery(handler http.Handler, ) http.Handler { +func (server *Server) wrapPanicRecovery(handler http.Handler) http.Handler { wrappedHandler := http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) { defer func() { From d4f2d48545eeb49fd4674433af2aabb671e3c6bd Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Wed, 17 Nov 2021 09:19:43 -0500 Subject: [PATCH 2/7] Use 64 bit ids instead of 32 ids for links and circuits --- controller/api_impl/context.go | 4 +- controller/api_impl/service_api_model.go | 4 +- controller/eid/id.go | 23 ---------- controller/idgen/id.go | 54 ++++++++++++++++++++++++ controller/network/circuit.go | 11 ++++- controller/network/link_controller.go | 10 ++--- controller/network/network.go | 12 +++--- 7 files changed, 78 insertions(+), 40 deletions(-) delete mode 100644 controller/eid/id.go create mode 100644 controller/idgen/id.go diff --git a/controller/api_impl/context.go b/controller/api_impl/context.go index 253e34c58..0aab3bda4 100644 --- a/controller/api_impl/context.go +++ b/controller/api_impl/context.go @@ -19,13 +19,13 @@ package api_impl import ( "bytes" "github.com/openziti/fabric/controller/api" - "github.com/openziti/fabric/controller/eid" + "github.com/openziti/fabric/controller/idgen" "io/ioutil" "net/http" ) func NewRequestContext(rw http.ResponseWriter, r *http.Request) api.RequestContext { - rid := eid.New() + rid := idgen.New() body, _ := ioutil.ReadAll(r.Body) r.Body = ioutil.NopCloser(bytes.NewReader(body)) diff --git a/controller/api_impl/service_api_model.go b/controller/api_impl/service_api_model.go index 8a782024b..3d67e8b59 100644 --- a/controller/api_impl/service_api_model.go +++ b/controller/api_impl/service_api_model.go @@ -20,7 +20,7 @@ import ( "fmt" "github.com/michaelquigley/pfxlog" "github.com/openziti/fabric/controller/api" - "github.com/openziti/fabric/controller/eid" + "github.com/openziti/fabric/controller/idgen" "github.com/openziti/fabric/controller/network" "github.com/openziti/fabric/rest_model" @@ -59,7 +59,7 @@ func MapCreateServiceToModel(service *rest_model.ServiceCreate) *network.Service } if ret.Id == "" { - ret.Id = eid.New() + ret.Id = idgen.New() } if ret.Id != "" && ret.Name == "" { diff --git a/controller/eid/id.go b/controller/eid/id.go deleted file mode 100644 index 5b17c39f8..000000000 --- a/controller/eid/id.go +++ /dev/null @@ -1,23 +0,0 @@ -package eid - -import ( - "crypto/rand" - "encoding/binary" - "github.com/teris-io/shortid" -) - -const Alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-" - -var idGenerator *shortid.Shortid - -func init() { - buf := make([]byte, 8) - _, _ = rand.Read(buf) - seed := binary.LittleEndian.Uint64(buf) - idGenerator = shortid.MustNew(0, Alphabet, seed) -} - -func New() string { - id, _ := idGenerator.Generate() - return id -} diff --git a/controller/idgen/id.go b/controller/idgen/id.go new file mode 100644 index 000000000..71ac29127 --- /dev/null +++ b/controller/idgen/id.go @@ -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 + } + } +} diff --git a/controller/network/circuit.go b/controller/network/circuit.go index bc8f08707..ab76dd947 100644 --- a/controller/network/circuit.go +++ b/controller/network/circuit.go @@ -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) } diff --git a/controller/network/link_controller.go b/controller/network/link_controller.go index dc879e5c8..739641397 100644 --- a/controller/network/link_controller.go +++ b/controller/network/link_controller.go @@ -17,23 +17,23 @@ package network import ( + "github.com/openziti/fabric/controller/idgen" "github.com/openziti/foundation/identity/identity" "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(), + idGenerator: idgen.NewGenerator(), } } @@ -126,7 +126,7 @@ 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 } diff --git a/controller/network/network.go b/controller/network/network.go index 288416c11..32c5e4250 100644 --- a/controller/network/network.go +++ b/controller/network/network.go @@ -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 } } From ee15d29be5b5f2e57517a75c4ac80dcd0072adba Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Thu, 18 Nov 2021 00:15:03 -0500 Subject: [PATCH 3/7] Add initial rest interfaces for links and circuits --- controller/api_impl/link_api_model.go | 77 ++ controller/api_impl/link_router.go | 103 ++ controller/network/link_controller.go | 2 +- rest_client/circuit/circuit_client.go | 190 ++++ .../circuit/delete_circuit_parameters.go | 173 ++++ .../circuit/delete_circuit_responses.go | 205 ++++ .../circuit/detail_circuit_parameters.go | 173 ++++ .../circuit/detail_circuit_responses.go | 167 +++ .../circuit/list_circuits_parameters.go | 150 +++ .../circuit/list_circuits_responses.go | 129 +++ rest_client/link/detail_link_parameters.go | 173 ++++ rest_client/link/detail_link_responses.go | 167 +++ rest_client/link/link_client.go | 190 ++++ rest_client/link/list_links_parameters.go | 150 +++ rest_client/link/list_links_responses.go | 129 +++ rest_client/link/patch_link_parameters.go | 197 ++++ rest_client/link/patch_link_responses.go | 205 ++++ rest_client/router/create_router_responses.go | 2 +- rest_client/ziti_fabric_client.go | 10 + rest_model/circuit_detail.go | 259 +++++ rest_model/circuit_list.go | 97 ++ rest_model/detail_circuit_envelope.go | 179 ++++ rest_model/detail_link_envelope.go | 179 ++++ rest_model/link_detail.go | 284 ++++++ rest_model/link_list.go | 97 ++ rest_model/link_patch.go | 77 ++ rest_model/list_circuits_envelope.go | 175 ++++ rest_model/list_links_envelope.go | 175 ++++ rest_server/configure_ziti_fabric.go | 32 + rest_server/embedded_spec.go | 953 ++++++++++++++++++ .../operations/circuit/delete_circuit.go | 82 ++ .../circuit/delete_circuit_parameters.go | 95 ++ .../circuit/delete_circuit_responses.go | 214 ++++ .../circuit/delete_circuit_urlbuilder.go | 123 +++ .../operations/circuit/detail_circuit.go | 82 ++ .../circuit/detail_circuit_parameters.go | 95 ++ .../circuit/detail_circuit_responses.go | 170 ++++ .../circuit/detail_circuit_urlbuilder.go | 123 +++ .../operations/circuit/list_circuits.go | 83 ++ .../circuit/list_circuits_parameters.go | 70 ++ .../circuit/list_circuits_responses.go | 126 +++ .../circuit/list_circuits_urlbuilder.go | 111 ++ rest_server/operations/link/detail_link.go | 82 ++ .../operations/link/detail_link_parameters.go | 95 ++ .../operations/link/detail_link_responses.go | 170 ++++ .../operations/link/detail_link_urlbuilder.go | 123 +++ rest_server/operations/link/list_links.go | 83 ++ .../operations/link/list_links_parameters.go | 70 ++ .../operations/link/list_links_responses.go | 126 +++ .../operations/link/list_links_urlbuilder.go | 111 ++ rest_server/operations/link/patch_link.go | 82 ++ .../operations/link/patch_link_parameters.go | 134 +++ .../operations/link/patch_link_responses.go | 214 ++++ .../operations/link/patch_link_urlbuilder.go | 123 +++ rest_server/operations/ziti_fabric_api.go | 74 ++ specs/swagger.yml | 249 ++++- 56 files changed, 8206 insertions(+), 3 deletions(-) create mode 100644 controller/api_impl/link_api_model.go create mode 100644 controller/api_impl/link_router.go create mode 100644 rest_client/circuit/circuit_client.go create mode 100644 rest_client/circuit/delete_circuit_parameters.go create mode 100644 rest_client/circuit/delete_circuit_responses.go create mode 100644 rest_client/circuit/detail_circuit_parameters.go create mode 100644 rest_client/circuit/detail_circuit_responses.go create mode 100644 rest_client/circuit/list_circuits_parameters.go create mode 100644 rest_client/circuit/list_circuits_responses.go create mode 100644 rest_client/link/detail_link_parameters.go create mode 100644 rest_client/link/detail_link_responses.go create mode 100644 rest_client/link/link_client.go create mode 100644 rest_client/link/list_links_parameters.go create mode 100644 rest_client/link/list_links_responses.go create mode 100644 rest_client/link/patch_link_parameters.go create mode 100644 rest_client/link/patch_link_responses.go create mode 100644 rest_model/circuit_detail.go create mode 100644 rest_model/circuit_list.go create mode 100644 rest_model/detail_circuit_envelope.go create mode 100644 rest_model/detail_link_envelope.go create mode 100644 rest_model/link_detail.go create mode 100644 rest_model/link_list.go create mode 100644 rest_model/link_patch.go create mode 100644 rest_model/list_circuits_envelope.go create mode 100644 rest_model/list_links_envelope.go create mode 100644 rest_server/operations/circuit/delete_circuit.go create mode 100644 rest_server/operations/circuit/delete_circuit_parameters.go create mode 100644 rest_server/operations/circuit/delete_circuit_responses.go create mode 100644 rest_server/operations/circuit/delete_circuit_urlbuilder.go create mode 100644 rest_server/operations/circuit/detail_circuit.go create mode 100644 rest_server/operations/circuit/detail_circuit_parameters.go create mode 100644 rest_server/operations/circuit/detail_circuit_responses.go create mode 100644 rest_server/operations/circuit/detail_circuit_urlbuilder.go create mode 100644 rest_server/operations/circuit/list_circuits.go create mode 100644 rest_server/operations/circuit/list_circuits_parameters.go create mode 100644 rest_server/operations/circuit/list_circuits_responses.go create mode 100644 rest_server/operations/circuit/list_circuits_urlbuilder.go create mode 100644 rest_server/operations/link/detail_link.go create mode 100644 rest_server/operations/link/detail_link_parameters.go create mode 100644 rest_server/operations/link/detail_link_responses.go create mode 100644 rest_server/operations/link/detail_link_urlbuilder.go create mode 100644 rest_server/operations/link/list_links.go create mode 100644 rest_server/operations/link/list_links_parameters.go create mode 100644 rest_server/operations/link/list_links_responses.go create mode 100644 rest_server/operations/link/list_links_urlbuilder.go create mode 100644 rest_server/operations/link/patch_link.go create mode 100644 rest_server/operations/link/patch_link_parameters.go create mode 100644 rest_server/operations/link/patch_link_responses.go create mode 100644 rest_server/operations/link/patch_link_urlbuilder.go diff --git a/controller/api_impl/link_api_model.go b/controller/api_impl/link_api_model.go new file mode 100644 index 000000000..de9816cd3 --- /dev/null +++ b/controller/api_impl/link_api_model.go @@ -0,0 +1,77 @@ +/* + 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/foundation/identity/identity" + + "github.com/openziti/fabric/rest_model" + + "github.com/openziti/fabric/controller/models" +) + +const EntityNameLink = "links" + +var LinkLinkFactory = NewLinkLinkFactory() + +type LinkLinkFactoryIml struct { + BasicLinkFactory +} + +func NewLinkLinkFactory() *LinkLinkFactoryIml { + return &LinkLinkFactoryIml{ + BasicLinkFactory: *NewBasicLinkFactory(EntityNameLink), + } +} + +func (factory *LinkLinkFactoryIml) Links(entity models.Entity) rest_model.Links { + links := factory.BasicLinkFactory.Links(entity) + return links +} + +func MapPatchLinkToModel(id string, link *rest_model.LinkPatch) *network.Link { + ret := &network.Link{ + Id: &identity.TokenId{Token: id}, + Down: link.Down, + StaticCost: int32(link.StaticCost), + } + + return ret +} + +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() + } + ret := &rest_model.LinkDetail{ + Cost: &link.Cost, + DestLatency: &link.DstLatency, + DestRouter: ToEntityRef(link.Dst.Name, link.Dst, RouterLinkFactory), + Down: link.Down, + ID: &link.Id.Token, + SourceLatency: &link.SrcLatency, + SourceRouter: ToEntityRef(link.Src.Name, link.Src, RouterLinkFactory), + State: &linkStateStr, + StaticCost: &staticCost, + } + return ret, nil +} diff --git a/controller/api_impl/link_router.go b/controller/api_impl/link_router.go new file mode 100644 index 000000000..df2720d64 --- /dev/null +++ b/controller/api_impl/link_router.go @@ -0,0 +1,103 @@ +/* + 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/identity/identity" + "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.Token < links[j].Id.Token + }) + 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(&identity.TokenId{Token: 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 { + // return n.Controllers.Links.Patch(MapPatchLinkToModel(params.ID, params.Link), fields.ConcatNestedNames().FilterMaps("tags")) + //}) +} diff --git a/controller/network/link_controller.go b/controller/network/link_controller.go index 739641397..0143e2280 100644 --- a/controller/network/link_controller.go +++ b/controller/network/link_controller.go @@ -197,7 +197,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)) } diff --git a/rest_client/circuit/circuit_client.go b/rest_client/circuit/circuit_client.go new file mode 100644 index 000000000..60596e53c --- /dev/null +++ b/rest_client/circuit/circuit_client.go @@ -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; doesn 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 +} diff --git a/rest_client/circuit/delete_circuit_parameters.go b/rest_client/circuit/delete_circuit_parameters.go new file mode 100644 index 000000000..eee5e7090 --- /dev/null +++ b/rest_client/circuit/delete_circuit_parameters.go @@ -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" +) + +// 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 + + 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 +} + +// 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 len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client/circuit/delete_circuit_responses.go b/rest_client/circuit/delete_circuit_responses.go new file mode 100644 index 000000000..513d814b4 --- /dev/null +++ b/rest_client/circuit/delete_circuit_responses.go @@ -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 +} diff --git a/rest_client/circuit/detail_circuit_parameters.go b/rest_client/circuit/detail_circuit_parameters.go new file mode 100644 index 000000000..65e61b3d4 --- /dev/null +++ b/rest_client/circuit/detail_circuit_parameters.go @@ -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 +} diff --git a/rest_client/circuit/detail_circuit_responses.go b/rest_client/circuit/detail_circuit_responses.go new file mode 100644 index 000000000..13e660cbc --- /dev/null +++ b/rest_client/circuit/detail_circuit_responses.go @@ -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 +} diff --git a/rest_client/circuit/list_circuits_parameters.go b/rest_client/circuit/list_circuits_parameters.go new file mode 100644 index 000000000..9c689f799 --- /dev/null +++ b/rest_client/circuit/list_circuits_parameters.go @@ -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 +} diff --git a/rest_client/circuit/list_circuits_responses.go b/rest_client/circuit/list_circuits_responses.go new file mode 100644 index 000000000..e1a607524 --- /dev/null +++ b/rest_client/circuit/list_circuits_responses.go @@ -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 +} diff --git a/rest_client/link/detail_link_parameters.go b/rest_client/link/detail_link_parameters.go new file mode 100644 index 000000000..37dc4d0fd --- /dev/null +++ b/rest_client/link/detail_link_parameters.go @@ -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 +} diff --git a/rest_client/link/detail_link_responses.go b/rest_client/link/detail_link_responses.go new file mode 100644 index 000000000..34635aa7e --- /dev/null +++ b/rest_client/link/detail_link_responses.go @@ -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 +} diff --git a/rest_client/link/link_client.go b/rest_client/link/link_client.go new file mode 100644 index 000000000..8e2807420 --- /dev/null +++ b/rest_client/link/link_client.go @@ -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; doesn 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 +} diff --git a/rest_client/link/list_links_parameters.go b/rest_client/link/list_links_parameters.go new file mode 100644 index 000000000..4e66ebb9c --- /dev/null +++ b/rest_client/link/list_links_parameters.go @@ -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 +} diff --git a/rest_client/link/list_links_responses.go b/rest_client/link/list_links_responses.go new file mode 100644 index 000000000..32ad218f2 --- /dev/null +++ b/rest_client/link/list_links_responses.go @@ -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 +} diff --git a/rest_client/link/patch_link_parameters.go b/rest_client/link/patch_link_parameters.go new file mode 100644 index 000000000..888366dba --- /dev/null +++ b/rest_client/link/patch_link_parameters.go @@ -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 +} diff --git a/rest_client/link/patch_link_responses.go b/rest_client/link/patch_link_responses.go new file mode 100644 index 000000000..e24b609dd --- /dev/null +++ b/rest_client/link/patch_link_responses.go @@ -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 +} diff --git a/rest_client/router/create_router_responses.go b/rest_client/router/create_router_responses.go index 8073756e9..ffd9c0d75 100644 --- a/rest_client/router/create_router_responses.go +++ b/rest_client/router/create_router_responses.go @@ -39,7 +39,7 @@ import ( "github.com/openziti/fabric/rest_model" ) -// CreateRouterReader is a Reader for the createRouter structure. +// CreateRouterReader is a Reader for the CreateRouter structure. type CreateRouterReader struct { formats strfmt.Registry } diff --git a/rest_client/ziti_fabric_client.go b/rest_client/ziti_fabric_client.go index e5428885a..f1ff140b8 100644 --- a/rest_client/ziti_fabric_client.go +++ b/rest_client/ziti_fabric_client.go @@ -34,6 +34,8 @@ import ( httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" + "github.com/openziti/fabric/rest_client/circuit" + "github.com/openziti/fabric/rest_client/link" "github.com/openziti/fabric/rest_client/router" "github.com/openziti/fabric/rest_client/service" "github.com/openziti/fabric/rest_client/terminator" @@ -81,6 +83,8 @@ func New(transport runtime.ClientTransport, formats strfmt.Registry) *ZitiFabric cli := new(ZitiFabric) cli.Transport = transport + cli.Circuit = circuit.New(transport, formats) + cli.Link = link.New(transport, formats) cli.Router = router.New(transport, formats) cli.Service = service.New(transport, formats) cli.Terminator = terminator.New(transport, formats) @@ -128,6 +132,10 @@ func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { // ZitiFabric is a client for ziti fabric type ZitiFabric struct { + Circuit circuit.ClientService + + Link link.ClientService + Router router.ClientService Service service.ClientService @@ -140,6 +148,8 @@ type ZitiFabric struct { // SetTransport changes the transport on the client and all its subresources func (c *ZitiFabric) SetTransport(transport runtime.ClientTransport) { c.Transport = transport + c.Circuit.SetTransport(transport) + c.Link.SetTransport(transport) c.Router.SetTransport(transport) c.Service.SetTransport(transport) c.Terminator.SetTransport(transport) diff --git a/rest_model/circuit_detail.go b/rest_model/circuit_detail.go new file mode 100644 index 000000000..379760fc9 --- /dev/null +++ b/rest_model/circuit_detail.go @@ -0,0 +1,259 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CircuitDetail circuit detail +// +// swagger:model circuitDetail +type CircuitDetail struct { + + // client Id + ClientID string `json:"clientId,omitempty"` + + // id + // Required: true + ID *string `json:"id"` + + // path + // Required: true + Path []*EntityRef `json:"path"` + + // service + // Required: true + Service *EntityRef `json:"service"` + + // terminator + // Required: true + Terminator *EntityRef `json:"terminator"` +} + +// Validate validates this circuit detail +func (m *CircuitDetail) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePath(formats); err != nil { + res = append(res, err) + } + + if err := m.validateService(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTerminator(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CircuitDetail) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *CircuitDetail) validatePath(formats strfmt.Registry) error { + + if err := validate.Required("path", "body", m.Path); err != nil { + return err + } + + for i := 0; i < len(m.Path); i++ { + if swag.IsZero(m.Path[i]) { // not required + continue + } + + if m.Path[i] != nil { + if err := m.Path[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("path" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("path" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CircuitDetail) validateService(formats strfmt.Registry) error { + + if err := validate.Required("service", "body", m.Service); err != nil { + return err + } + + if m.Service != nil { + if err := m.Service.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("service") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service") + } + return err + } + } + + return nil +} + +func (m *CircuitDetail) validateTerminator(formats strfmt.Registry) error { + + if err := validate.Required("terminator", "body", m.Terminator); err != nil { + return err + } + + if m.Terminator != nil { + if err := m.Terminator.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("terminator") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("terminator") + } + return err + } + } + + return nil +} + +// ContextValidate validate this circuit detail based on the context it is used +func (m *CircuitDetail) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidatePath(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateService(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTerminator(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CircuitDetail) contextValidatePath(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Path); i++ { + + if m.Path[i] != nil { + if err := m.Path[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("path" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("path" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CircuitDetail) contextValidateService(ctx context.Context, formats strfmt.Registry) error { + + if m.Service != nil { + if err := m.Service.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("service") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("service") + } + return err + } + } + + return nil +} + +func (m *CircuitDetail) contextValidateTerminator(ctx context.Context, formats strfmt.Registry) error { + + if m.Terminator != nil { + if err := m.Terminator.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("terminator") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("terminator") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CircuitDetail) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CircuitDetail) UnmarshalBinary(b []byte) error { + var res CircuitDetail + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/circuit_list.go b/rest_model/circuit_list.go new file mode 100644 index 000000000..17c6f3a3e --- /dev/null +++ b/rest_model/circuit_list.go @@ -0,0 +1,97 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CircuitList circuit list +// +// swagger:model circuitList +type CircuitList []*CircuitDetail + +// Validate validates this circuit list +func (m CircuitList) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this circuit list based on the context it is used +func (m CircuitList) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + if m[i] != nil { + if err := m[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_model/detail_circuit_envelope.go b/rest_model/detail_circuit_envelope.go new file mode 100644 index 000000000..4aba0fec4 --- /dev/null +++ b/rest_model/detail_circuit_envelope.go @@ -0,0 +1,179 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// DetailCircuitEnvelope detail circuit envelope +// +// swagger:model detailCircuitEnvelope +type DetailCircuitEnvelope struct { + + // data + // Required: true + Data *CircuitDetail `json:"data"` + + // meta + // Required: true + Meta *Meta `json:"meta"` +} + +// Validate validates this detail circuit envelope +func (m *DetailCircuitEnvelope) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DetailCircuitEnvelope) validateData(formats strfmt.Registry) error { + + if err := validate.Required("data", "body", m.Data); err != nil { + return err + } + + if m.Data != nil { + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *DetailCircuitEnvelope) validateMeta(formats strfmt.Registry) error { + + if err := validate.Required("meta", "body", m.Meta); err != nil { + return err + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this detail circuit envelope based on the context it is used +func (m *DetailCircuitEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DetailCircuitEnvelope) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if m.Data != nil { + if err := m.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *DetailCircuitEnvelope) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *DetailCircuitEnvelope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DetailCircuitEnvelope) UnmarshalBinary(b []byte) error { + var res DetailCircuitEnvelope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/detail_link_envelope.go b/rest_model/detail_link_envelope.go new file mode 100644 index 000000000..801e71a2c --- /dev/null +++ b/rest_model/detail_link_envelope.go @@ -0,0 +1,179 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// DetailLinkEnvelope detail link envelope +// +// swagger:model detailLinkEnvelope +type DetailLinkEnvelope struct { + + // data + // Required: true + Data *LinkDetail `json:"data"` + + // meta + // Required: true + Meta *Meta `json:"meta"` +} + +// Validate validates this detail link envelope +func (m *DetailLinkEnvelope) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DetailLinkEnvelope) validateData(formats strfmt.Registry) error { + + if err := validate.Required("data", "body", m.Data); err != nil { + return err + } + + if m.Data != nil { + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *DetailLinkEnvelope) validateMeta(formats strfmt.Registry) error { + + if err := validate.Required("meta", "body", m.Meta); err != nil { + return err + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this detail link envelope based on the context it is used +func (m *DetailLinkEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DetailLinkEnvelope) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if m.Data != nil { + if err := m.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *DetailLinkEnvelope) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *DetailLinkEnvelope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DetailLinkEnvelope) UnmarshalBinary(b []byte) error { + var res DetailLinkEnvelope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/link_detail.go b/rest_model/link_detail.go new file mode 100644 index 000000000..0a237654e --- /dev/null +++ b/rest_model/link_detail.go @@ -0,0 +1,284 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// LinkDetail link detail +// +// swagger:model linkDetail +type LinkDetail struct { + + // cost + // Required: true + Cost *int64 `json:"cost"` + + // dest latency + // Required: true + DestLatency *int64 `json:"destLatency"` + + // dest router + // Required: true + DestRouter *EntityRef `json:"destRouter"` + + // down + Down bool `json:"down,omitempty"` + + // id + // Required: true + ID *string `json:"id"` + + // source latency + // Required: true + SourceLatency *int64 `json:"sourceLatency"` + + // source router + // Required: true + SourceRouter *EntityRef `json:"sourceRouter"` + + // state + // Required: true + State *string `json:"state"` + + // static cost + // Required: true + StaticCost *int64 `json:"staticCost"` +} + +// Validate validates this link detail +func (m *LinkDetail) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCost(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDestLatency(formats); err != nil { + res = append(res, err) + } + + if err := m.validateDestRouter(formats); err != nil { + res = append(res, err) + } + + if err := m.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSourceLatency(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSourceRouter(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStaticCost(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *LinkDetail) validateCost(formats strfmt.Registry) error { + + if err := validate.Required("cost", "body", m.Cost); err != nil { + return err + } + + return nil +} + +func (m *LinkDetail) validateDestLatency(formats strfmt.Registry) error { + + if err := validate.Required("destLatency", "body", m.DestLatency); err != nil { + return err + } + + return nil +} + +func (m *LinkDetail) validateDestRouter(formats strfmt.Registry) error { + + if err := validate.Required("destRouter", "body", m.DestRouter); err != nil { + return err + } + + if m.DestRouter != nil { + if err := m.DestRouter.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("destRouter") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("destRouter") + } + return err + } + } + + return nil +} + +func (m *LinkDetail) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *LinkDetail) validateSourceLatency(formats strfmt.Registry) error { + + if err := validate.Required("sourceLatency", "body", m.SourceLatency); err != nil { + return err + } + + return nil +} + +func (m *LinkDetail) validateSourceRouter(formats strfmt.Registry) error { + + if err := validate.Required("sourceRouter", "body", m.SourceRouter); err != nil { + return err + } + + if m.SourceRouter != nil { + if err := m.SourceRouter.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sourceRouter") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sourceRouter") + } + return err + } + } + + return nil +} + +func (m *LinkDetail) validateState(formats strfmt.Registry) error { + + if err := validate.Required("state", "body", m.State); err != nil { + return err + } + + return nil +} + +func (m *LinkDetail) validateStaticCost(formats strfmt.Registry) error { + + if err := validate.Required("staticCost", "body", m.StaticCost); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this link detail based on the context it is used +func (m *LinkDetail) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateDestRouter(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSourceRouter(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *LinkDetail) contextValidateDestRouter(ctx context.Context, formats strfmt.Registry) error { + + if m.DestRouter != nil { + if err := m.DestRouter.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("destRouter") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("destRouter") + } + return err + } + } + + return nil +} + +func (m *LinkDetail) contextValidateSourceRouter(ctx context.Context, formats strfmt.Registry) error { + + if m.SourceRouter != nil { + if err := m.SourceRouter.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sourceRouter") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sourceRouter") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *LinkDetail) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *LinkDetail) UnmarshalBinary(b []byte) error { + var res LinkDetail + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/link_list.go b/rest_model/link_list.go new file mode 100644 index 000000000..a9862508c --- /dev/null +++ b/rest_model/link_list.go @@ -0,0 +1,97 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// LinkList link list +// +// swagger:model linkList +type LinkList []*LinkDetail + +// Validate validates this link list +func (m LinkList) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this link list based on the context it is used +func (m LinkList) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + if m[i] != nil { + if err := m[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_model/link_patch.go b/rest_model/link_patch.go new file mode 100644 index 000000000..89efb3258 --- /dev/null +++ b/rest_model/link_patch.go @@ -0,0 +1,77 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// LinkPatch link patch +// +// swagger:model linkPatch +type LinkPatch struct { + + // down + Down bool `json:"down,omitempty"` + + // static cost + StaticCost int64 `json:"staticCost,omitempty"` +} + +// Validate validates this link patch +func (m *LinkPatch) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this link patch based on context it is used +func (m *LinkPatch) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *LinkPatch) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *LinkPatch) UnmarshalBinary(b []byte) error { + var res LinkPatch + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/list_circuits_envelope.go b/rest_model/list_circuits_envelope.go new file mode 100644 index 000000000..bb7a2ec2e --- /dev/null +++ b/rest_model/list_circuits_envelope.go @@ -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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ListCircuitsEnvelope list circuits envelope +// +// swagger:model listCircuitsEnvelope +type ListCircuitsEnvelope struct { + + // data + // Required: true + Data LinkList `json:"data"` + + // meta + // Required: true + Meta *Meta `json:"meta"` +} + +// Validate validates this list circuits envelope +func (m *ListCircuitsEnvelope) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ListCircuitsEnvelope) validateData(formats strfmt.Registry) error { + + if err := validate.Required("data", "body", m.Data); err != nil { + return err + } + + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + + return nil +} + +func (m *ListCircuitsEnvelope) validateMeta(formats strfmt.Registry) error { + + if err := validate.Required("meta", "body", m.Meta); err != nil { + return err + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this list circuits envelope based on the context it is used +func (m *ListCircuitsEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ListCircuitsEnvelope) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + + return nil +} + +func (m *ListCircuitsEnvelope) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ListCircuitsEnvelope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ListCircuitsEnvelope) UnmarshalBinary(b []byte) error { + var res ListCircuitsEnvelope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/list_links_envelope.go b/rest_model/list_links_envelope.go new file mode 100644 index 000000000..2e213ab48 --- /dev/null +++ b/rest_model/list_links_envelope.go @@ -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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ListLinksEnvelope list links envelope +// +// swagger:model listLinksEnvelope +type ListLinksEnvelope struct { + + // data + // Required: true + Data LinkList `json:"data"` + + // meta + // Required: true + Meta *Meta `json:"meta"` +} + +// Validate validates this list links envelope +func (m *ListLinksEnvelope) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeta(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ListLinksEnvelope) validateData(formats strfmt.Registry) error { + + if err := validate.Required("data", "body", m.Data); err != nil { + return err + } + + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + + return nil +} + +func (m *ListLinksEnvelope) validateMeta(formats strfmt.Registry) error { + + if err := validate.Required("meta", "body", m.Meta); err != nil { + return err + } + + if m.Meta != nil { + if err := m.Meta.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// ContextValidate validate this list links envelope based on the context it is used +func (m *ListLinksEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateData(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMeta(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ListLinksEnvelope) contextValidateData(ctx context.Context, formats strfmt.Registry) error { + + if err := m.Data.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("data") + } + return err + } + + return nil +} + +func (m *ListLinksEnvelope) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { + + if m.Meta != nil { + if err := m.Meta.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("meta") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("meta") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ListLinksEnvelope) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ListLinksEnvelope) UnmarshalBinary(b []byte) error { + var res ListLinksEnvelope + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_server/configure_ziti_fabric.go b/rest_server/configure_ziti_fabric.go index 599eaade6..ca73ffd98 100644 --- a/rest_server/configure_ziti_fabric.go +++ b/rest_server/configure_ziti_fabric.go @@ -35,6 +35,8 @@ import ( "github.com/go-openapi/runtime/middleware" "github.com/openziti/fabric/rest_server/operations" + "github.com/openziti/fabric/rest_server/operations/circuit" + "github.com/openziti/fabric/rest_server/operations/link" "github.com/openziti/fabric/rest_server/operations/router" "github.com/openziti/fabric/rest_server/operations/service" "github.com/openziti/fabric/rest_server/operations/terminator" @@ -79,6 +81,11 @@ func configureAPI(api *operations.ZitiFabricAPI) http.Handler { return middleware.NotImplemented("operation terminator.CreateTerminator has not yet been implemented") }) } + if api.CircuitDeleteCircuitHandler == nil { + api.CircuitDeleteCircuitHandler = circuit.DeleteCircuitHandlerFunc(func(params circuit.DeleteCircuitParams) middleware.Responder { + return middleware.NotImplemented("operation circuit.DeleteCircuit has not yet been implemented") + }) + } if api.RouterDeleteRouterHandler == nil { api.RouterDeleteRouterHandler = router.DeleteRouterHandlerFunc(func(params router.DeleteRouterParams) middleware.Responder { return middleware.NotImplemented("operation router.DeleteRouter has not yet been implemented") @@ -94,6 +101,16 @@ func configureAPI(api *operations.ZitiFabricAPI) http.Handler { return middleware.NotImplemented("operation terminator.DeleteTerminator has not yet been implemented") }) } + if api.CircuitDetailCircuitHandler == nil { + api.CircuitDetailCircuitHandler = circuit.DetailCircuitHandlerFunc(func(params circuit.DetailCircuitParams) middleware.Responder { + return middleware.NotImplemented("operation circuit.DetailCircuit has not yet been implemented") + }) + } + if api.LinkDetailLinkHandler == nil { + api.LinkDetailLinkHandler = link.DetailLinkHandlerFunc(func(params link.DetailLinkParams) middleware.Responder { + return middleware.NotImplemented("operation link.DetailLink has not yet been implemented") + }) + } if api.RouterDetailRouterHandler == nil { api.RouterDetailRouterHandler = router.DetailRouterHandlerFunc(func(params router.DetailRouterParams) middleware.Responder { return middleware.NotImplemented("operation router.DetailRouter has not yet been implemented") @@ -109,6 +126,16 @@ func configureAPI(api *operations.ZitiFabricAPI) http.Handler { return middleware.NotImplemented("operation terminator.DetailTerminator has not yet been implemented") }) } + if api.CircuitListCircuitsHandler == nil { + api.CircuitListCircuitsHandler = circuit.ListCircuitsHandlerFunc(func(params circuit.ListCircuitsParams) middleware.Responder { + return middleware.NotImplemented("operation circuit.ListCircuits has not yet been implemented") + }) + } + if api.LinkListLinksHandler == nil { + api.LinkListLinksHandler = link.ListLinksHandlerFunc(func(params link.ListLinksParams) middleware.Responder { + return middleware.NotImplemented("operation link.ListLinks has not yet been implemented") + }) + } if api.RouterListRouterTerminatorsHandler == nil { api.RouterListRouterTerminatorsHandler = router.ListRouterTerminatorsHandlerFunc(func(params router.ListRouterTerminatorsParams) middleware.Responder { return middleware.NotImplemented("operation router.ListRouterTerminators has not yet been implemented") @@ -134,6 +161,11 @@ func configureAPI(api *operations.ZitiFabricAPI) http.Handler { return middleware.NotImplemented("operation terminator.ListTerminators has not yet been implemented") }) } + if api.LinkPatchLinkHandler == nil { + api.LinkPatchLinkHandler = link.PatchLinkHandlerFunc(func(params link.PatchLinkParams) middleware.Responder { + return middleware.NotImplemented("operation link.PatchLink has not yet been implemented") + }) + } if api.ServicePatchServiceHandler == nil { api.ServicePatchServiceHandler = service.PatchServiceHandlerFunc(func(params service.PatchServiceParams) middleware.Responder { return middleware.NotImplemented("operation service.PatchService has not yet been implemented") diff --git a/rest_server/embedded_spec.go b/rest_server/embedded_spec.go index 96835b54c..fe3cbc6be 100644 --- a/rest_server/embedded_spec.go +++ b/rest_server/embedded_spec.go @@ -60,6 +60,149 @@ func init() { "host": "demo.ziti.dev", "basePath": "/fabric/v1", "paths": { + "/circuits": { + "get": { + "description": "Retrieves a list of circuit resources; doesn not supports filtering, sorting, or pagination. Requires admin access.\n", + "tags": [ + "Circuit" + ], + "summary": "List circuits", + "operationId": "listCircuits", + "responses": { + "200": { + "$ref": "#/responses/listCircuits" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + } + } + } + }, + "/circuits/{id}": { + "get": { + "description": "Retrieves a single circuit by id. Requires admin access.", + "tags": [ + "Circuit" + ], + "summary": "Retrieves a single circuit", + "operationId": "detailCircuit", + "responses": { + "200": { + "$ref": "#/responses/detailCircuit" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "404": { + "$ref": "#/responses/notFoundResponse" + } + } + }, + "delete": { + "description": "Delete a circuit by id. Requires admin access.", + "tags": [ + "Circuit" + ], + "summary": "Delete a circuit", + "operationId": "deleteCircuit", + "responses": { + "200": { + "$ref": "#/responses/deleteResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "409": { + "$ref": "#/responses/cannotDeleteReferencedResourceResponse" + } + } + }, + "parameters": [ + { + "$ref": "#/parameters/id" + } + ] + }, + "/links": { + "get": { + "description": "Retrieves a list of link resources; doesn not supports filtering, sorting, or pagination. Requires admin access.\n", + "tags": [ + "Link" + ], + "summary": "List links", + "operationId": "listLinks", + "responses": { + "200": { + "$ref": "#/responses/listLinks" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + } + } + } + }, + "/links/{id}": { + "get": { + "description": "Retrieves a single link by id. Requires admin access.", + "tags": [ + "Link" + ], + "summary": "Retrieves a single link", + "operationId": "detailLink", + "responses": { + "200": { + "$ref": "#/responses/detailLink" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "404": { + "$ref": "#/responses/notFoundResponse" + } + } + }, + "patch": { + "description": "Update the supplied fields on a link. Requires admin access.", + "tags": [ + "Link" + ], + "summary": "Update the supplied fields on a link", + "operationId": "patchLink", + "parameters": [ + { + "description": "A link patch object", + "name": "link", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/linkPatch" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/patchResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "404": { + "$ref": "#/responses/notFoundResponse" + } + } + }, + "parameters": [ + { + "$ref": "#/parameters/id" + } + ] + }, "/routers": { "get": { "description": "Retrieves a list of router resources; supports filtering, sorting, and pagination. Requires admin access.\n", @@ -699,6 +842,41 @@ func init() { } } }, + "circuitDetail": { + "type": "object", + "required": [ + "id", + "service", + "terminator", + "path" + ], + "properties": { + "clientId": { + "type": "string" + }, + "id": { + "type": "string" + }, + "path": { + "type": "array", + "items": { + "$ref": "#/definitions/entityRef" + } + }, + "service": { + "$ref": "#/definitions/entityRef" + }, + "terminator": { + "$ref": "#/definitions/entityRef" + } + } + }, + "circuitList": { + "type": "array", + "items": { + "$ref": "#/definitions/circuitDetail" + } + }, "createEnvelope": { "type": "object", "properties": { @@ -721,6 +899,36 @@ func init() { } } }, + "detailCircuitEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/circuitDetail" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "detailLinkEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/linkDetail" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, "detailRouterEnvelope": { "type": "object", "required": [ @@ -819,6 +1027,65 @@ func init() { } } }, + "linkDetail": { + "type": "object", + "required": [ + "id", + "sourceRouter", + "destRouter", + "state", + "staticCost", + "sourceLatency", + "destLatency", + "cost" + ], + "properties": { + "cost": { + "type": "integer" + }, + "destLatency": { + "type": "integer" + }, + "destRouter": { + "$ref": "#/definitions/entityRef" + }, + "down": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "sourceLatency": { + "type": "integer" + }, + "sourceRouter": { + "$ref": "#/definitions/entityRef" + }, + "state": { + "type": "string" + }, + "staticCost": { + "type": "integer" + } + } + }, + "linkList": { + "type": "array", + "items": { + "$ref": "#/definitions/linkDetail" + } + }, + "linkPatch": { + "type": "object", + "properties": { + "down": { + "type": "boolean" + }, + "staticCost": { + "type": "integer" + } + } + }, "links": { "description": "A map of named links", "type": "object", @@ -827,6 +1094,36 @@ func init() { }, "x-omitempty": false }, + "listCircuitsEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/linkList" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "listLinksEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/linkList" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, "listRoutersEnvelope": { "type": "object", "required": [ @@ -1404,6 +1701,18 @@ func init() { "$ref": "#/definitions/empty" } }, + "detailCircuit": { + "description": "A single circuit", + "schema": { + "$ref": "#/definitions/detailCircuitEnvelope" + } + }, + "detailLink": { + "description": "A single link", + "schema": { + "$ref": "#/definitions/detailLinkEnvelope" + } + }, "detailRouter": { "description": "A single router", "schema": { @@ -1452,6 +1761,18 @@ func init() { } } }, + "listCircuits": { + "description": "A list of circuits", + "schema": { + "$ref": "#/definitions/listCircuitsEnvelope" + } + }, + "listLinks": { + "description": "A list of links", + "schema": { + "$ref": "#/definitions/listLinksEnvelope" + } + }, "listRouters": { "description": "A list of routers", "schema": { @@ -1576,6 +1897,460 @@ func init() { "host": "demo.ziti.dev", "basePath": "/fabric/v1", "paths": { + "/circuits": { + "get": { + "description": "Retrieves a list of circuit resources; doesn not supports filtering, sorting, or pagination. Requires admin access.\n", + "tags": [ + "Circuit" + ], + "summary": "List circuits", + "operationId": "listCircuits", + "responses": { + "200": { + "description": "A list of circuits", + "schema": { + "$ref": "#/definitions/listCircuitsEnvelope" + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + } + }, + "/circuits/{id}": { + "get": { + "description": "Retrieves a single circuit by id. Requires admin access.", + "tags": [ + "Circuit" + ], + "summary": "Retrieves a single circuit", + "operationId": "detailCircuit", + "responses": { + "200": { + "description": "A single circuit", + "schema": { + "$ref": "#/definitions/detailCircuitEnvelope" + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "404": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "delete": { + "description": "Delete a circuit by id. Requires admin access.", + "tags": [ + "Circuit" + ], + "summary": "Delete a circuit", + "operationId": "deleteCircuit", + "responses": { + "200": { + "description": "The delete request was successful and the resource has been removed", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "409": { + "description": "The resource requested to be removed/altered cannot be as it is referenced by another object.", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "causeMessage": "referenced by /some-resource/05f4f710-c155-4a74-86d5-77558eb9cb42", + "code": "CONFLICT_CANNOT_MODIFY_REFERENCED", + "message": "The resource cannot be deleted/modified. Remove all referencing resources first.", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "parameters": [ + { + "type": "string", + "description": "The id of the requested resource", + "name": "id", + "in": "path", + "required": true + } + ] + }, + "/links": { + "get": { + "description": "Retrieves a list of link resources; doesn not supports filtering, sorting, or pagination. Requires admin access.\n", + "tags": [ + "Link" + ], + "summary": "List links", + "operationId": "listLinks", + "responses": { + "200": { + "description": "A list of links", + "schema": { + "$ref": "#/definitions/listLinksEnvelope" + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + } + }, + "/links/{id}": { + "get": { + "description": "Retrieves a single link by id. Requires admin access.", + "tags": [ + "Link" + ], + "summary": "Retrieves a single link", + "operationId": "detailLink", + "responses": { + "200": { + "description": "A single link", + "schema": { + "$ref": "#/definitions/detailLinkEnvelope" + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "404": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "patch": { + "description": "Update the supplied fields on a link. Requires admin access.", + "tags": [ + "Link" + ], + "summary": "Update the supplied fields on a link", + "operationId": "patchLink", + "parameters": [ + { + "description": "A link patch object", + "name": "link", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/linkPatch" + } + } + ], + "responses": { + "200": { + "description": "The patch request was successful and the resource has been altered", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "404": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, + "parameters": [ + { + "type": "string", + "description": "The id of the requested resource", + "name": "id", + "in": "path", + "required": true + } + ] + }, "/routers": { "get": { "description": "Retrieves a list of router resources; supports filtering, sorting, and pagination. Requires admin access.\n", @@ -3366,6 +4141,41 @@ func init() { } } }, + "circuitDetail": { + "type": "object", + "required": [ + "id", + "service", + "terminator", + "path" + ], + "properties": { + "clientId": { + "type": "string" + }, + "id": { + "type": "string" + }, + "path": { + "type": "array", + "items": { + "$ref": "#/definitions/entityRef" + } + }, + "service": { + "$ref": "#/definitions/entityRef" + }, + "terminator": { + "$ref": "#/definitions/entityRef" + } + } + }, + "circuitList": { + "type": "array", + "items": { + "$ref": "#/definitions/circuitDetail" + } + }, "createEnvelope": { "type": "object", "properties": { @@ -3388,6 +4198,36 @@ func init() { } } }, + "detailCircuitEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/circuitDetail" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "detailLinkEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/linkDetail" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, "detailRouterEnvelope": { "type": "object", "required": [ @@ -3486,6 +4326,65 @@ func init() { } } }, + "linkDetail": { + "type": "object", + "required": [ + "id", + "sourceRouter", + "destRouter", + "state", + "staticCost", + "sourceLatency", + "destLatency", + "cost" + ], + "properties": { + "cost": { + "type": "integer" + }, + "destLatency": { + "type": "integer" + }, + "destRouter": { + "$ref": "#/definitions/entityRef" + }, + "down": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "sourceLatency": { + "type": "integer" + }, + "sourceRouter": { + "$ref": "#/definitions/entityRef" + }, + "state": { + "type": "string" + }, + "staticCost": { + "type": "integer" + } + } + }, + "linkList": { + "type": "array", + "items": { + "$ref": "#/definitions/linkDetail" + } + }, + "linkPatch": { + "type": "object", + "properties": { + "down": { + "type": "boolean" + }, + "staticCost": { + "type": "integer" + } + } + }, "links": { "description": "A map of named links", "type": "object", @@ -3494,6 +4393,36 @@ func init() { }, "x-omitempty": false }, + "listCircuitsEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/linkList" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, + "listLinksEnvelope": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/linkList" + }, + "meta": { + "$ref": "#/definitions/meta" + } + } + }, "listRoutersEnvelope": { "type": "object", "required": [ @@ -4072,6 +5001,18 @@ func init() { "$ref": "#/definitions/empty" } }, + "detailCircuit": { + "description": "A single circuit", + "schema": { + "$ref": "#/definitions/detailCircuitEnvelope" + } + }, + "detailLink": { + "description": "A single link", + "schema": { + "$ref": "#/definitions/detailLinkEnvelope" + } + }, "detailRouter": { "description": "A single router", "schema": { @@ -4120,6 +5061,18 @@ func init() { } } }, + "listCircuits": { + "description": "A list of circuits", + "schema": { + "$ref": "#/definitions/listCircuitsEnvelope" + } + }, + "listLinks": { + "description": "A list of links", + "schema": { + "$ref": "#/definitions/listLinksEnvelope" + } + }, "listRouters": { "description": "A list of routers", "schema": { diff --git a/rest_server/operations/circuit/delete_circuit.go b/rest_server/operations/circuit/delete_circuit.go new file mode 100644 index 000000000..ccd458c55 --- /dev/null +++ b/rest_server/operations/circuit/delete_circuit.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteCircuitHandlerFunc turns a function with the right signature into a delete circuit handler +type DeleteCircuitHandlerFunc func(DeleteCircuitParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteCircuitHandlerFunc) Handle(params DeleteCircuitParams) middleware.Responder { + return fn(params) +} + +// DeleteCircuitHandler interface for that can handle valid delete circuit params +type DeleteCircuitHandler interface { + Handle(DeleteCircuitParams) middleware.Responder +} + +// NewDeleteCircuit creates a new http.Handler for the delete circuit operation +func NewDeleteCircuit(ctx *middleware.Context, handler DeleteCircuitHandler) *DeleteCircuit { + return &DeleteCircuit{Context: ctx, Handler: handler} +} + +/* DeleteCircuit swagger:route DELETE /circuits/{id} Circuit deleteCircuit + +Delete a circuit + +Delete a circuit by id. Requires admin access. + +*/ +type DeleteCircuit struct { + Context *middleware.Context + Handler DeleteCircuitHandler +} + +func (o *DeleteCircuit) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteCircuitParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/circuit/delete_circuit_parameters.go b/rest_server/operations/circuit/delete_circuit_parameters.go new file mode 100644 index 000000000..c0954d402 --- /dev/null +++ b/rest_server/operations/circuit/delete_circuit_parameters.go @@ -0,0 +1,95 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteCircuitParams creates a new DeleteCircuitParams object +// +// There are no default values defined in the spec. +func NewDeleteCircuitParams() DeleteCircuitParams { + + return DeleteCircuitParams{} +} + +// DeleteCircuitParams contains all the bound params for the delete circuit operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteCircuit +type DeleteCircuitParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteCircuitParams() beforehand. +func (o *DeleteCircuitParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DeleteCircuitParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/circuit/delete_circuit_responses.go b/rest_server/operations/circuit/delete_circuit_responses.go new file mode 100644 index 000000000..83fbe1df7 --- /dev/null +++ b/rest_server/operations/circuit/delete_circuit_responses.go @@ -0,0 +1,214 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// DeleteCircuitOKCode is the HTTP code returned for type DeleteCircuitOK +const DeleteCircuitOKCode int = 200 + +/*DeleteCircuitOK The delete request was successful and the resource has been removed + +swagger:response deleteCircuitOK +*/ +type DeleteCircuitOK struct { + + /* + In: Body + */ + Payload *rest_model.Empty `json:"body,omitempty"` +} + +// NewDeleteCircuitOK creates DeleteCircuitOK with default headers values +func NewDeleteCircuitOK() *DeleteCircuitOK { + + return &DeleteCircuitOK{} +} + +// WithPayload adds the payload to the delete circuit o k response +func (o *DeleteCircuitOK) WithPayload(payload *rest_model.Empty) *DeleteCircuitOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete circuit o k response +func (o *DeleteCircuitOK) SetPayload(payload *rest_model.Empty) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCircuitOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteCircuitBadRequestCode is the HTTP code returned for type DeleteCircuitBadRequest +const DeleteCircuitBadRequestCode int = 400 + +/*DeleteCircuitBadRequest 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 + +swagger:response deleteCircuitBadRequest +*/ +type DeleteCircuitBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDeleteCircuitBadRequest creates DeleteCircuitBadRequest with default headers values +func NewDeleteCircuitBadRequest() *DeleteCircuitBadRequest { + + return &DeleteCircuitBadRequest{} +} + +// WithPayload adds the payload to the delete circuit bad request response +func (o *DeleteCircuitBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *DeleteCircuitBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete circuit bad request response +func (o *DeleteCircuitBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCircuitBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteCircuitUnauthorizedCode is the HTTP code returned for type DeleteCircuitUnauthorized +const DeleteCircuitUnauthorizedCode int = 401 + +/*DeleteCircuitUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response deleteCircuitUnauthorized +*/ +type DeleteCircuitUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDeleteCircuitUnauthorized creates DeleteCircuitUnauthorized with default headers values +func NewDeleteCircuitUnauthorized() *DeleteCircuitUnauthorized { + + return &DeleteCircuitUnauthorized{} +} + +// WithPayload adds the payload to the delete circuit unauthorized response +func (o *DeleteCircuitUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *DeleteCircuitUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete circuit unauthorized response +func (o *DeleteCircuitUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCircuitUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteCircuitConflictCode is the HTTP code returned for type DeleteCircuitConflict +const DeleteCircuitConflictCode int = 409 + +/*DeleteCircuitConflict The resource requested to be removed/altered cannot be as it is referenced by another object. + +swagger:response deleteCircuitConflict +*/ +type DeleteCircuitConflict struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDeleteCircuitConflict creates DeleteCircuitConflict with default headers values +func NewDeleteCircuitConflict() *DeleteCircuitConflict { + + return &DeleteCircuitConflict{} +} + +// WithPayload adds the payload to the delete circuit conflict response +func (o *DeleteCircuitConflict) WithPayload(payload *rest_model.APIErrorEnvelope) *DeleteCircuitConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete circuit conflict response +func (o *DeleteCircuitConflict) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCircuitConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/circuit/delete_circuit_urlbuilder.go b/rest_server/operations/circuit/delete_circuit_urlbuilder.go new file mode 100644 index 000000000..b58fb465c --- /dev/null +++ b/rest_server/operations/circuit/delete_circuit_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteCircuitURL generates an URL for the delete circuit operation +type DeleteCircuitURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCircuitURL) WithBasePath(bp string) *DeleteCircuitURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCircuitURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteCircuitURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/circuits/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DeleteCircuitURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteCircuitURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteCircuitURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteCircuitURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteCircuitURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteCircuitURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteCircuitURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/circuit/detail_circuit.go b/rest_server/operations/circuit/detail_circuit.go new file mode 100644 index 000000000..b10badfe4 --- /dev/null +++ b/rest_server/operations/circuit/detail_circuit.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DetailCircuitHandlerFunc turns a function with the right signature into a detail circuit handler +type DetailCircuitHandlerFunc func(DetailCircuitParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DetailCircuitHandlerFunc) Handle(params DetailCircuitParams) middleware.Responder { + return fn(params) +} + +// DetailCircuitHandler interface for that can handle valid detail circuit params +type DetailCircuitHandler interface { + Handle(DetailCircuitParams) middleware.Responder +} + +// NewDetailCircuit creates a new http.Handler for the detail circuit operation +func NewDetailCircuit(ctx *middleware.Context, handler DetailCircuitHandler) *DetailCircuit { + return &DetailCircuit{Context: ctx, Handler: handler} +} + +/* DetailCircuit swagger:route GET /circuits/{id} Circuit detailCircuit + +Retrieves a single circuit + +Retrieves a single circuit by id. Requires admin access. + +*/ +type DetailCircuit struct { + Context *middleware.Context + Handler DetailCircuitHandler +} + +func (o *DetailCircuit) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDetailCircuitParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/circuit/detail_circuit_parameters.go b/rest_server/operations/circuit/detail_circuit_parameters.go new file mode 100644 index 000000000..b589c423b --- /dev/null +++ b/rest_server/operations/circuit/detail_circuit_parameters.go @@ -0,0 +1,95 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDetailCircuitParams creates a new DetailCircuitParams object +// +// There are no default values defined in the spec. +func NewDetailCircuitParams() DetailCircuitParams { + + return DetailCircuitParams{} +} + +// DetailCircuitParams contains all the bound params for the detail circuit operation +// typically these are obtained from a http.Request +// +// swagger:parameters detailCircuit +type DetailCircuitParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDetailCircuitParams() beforehand. +func (o *DetailCircuitParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DetailCircuitParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/circuit/detail_circuit_responses.go b/rest_server/operations/circuit/detail_circuit_responses.go new file mode 100644 index 000000000..17c2d54fc --- /dev/null +++ b/rest_server/operations/circuit/detail_circuit_responses.go @@ -0,0 +1,170 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// DetailCircuitOKCode is the HTTP code returned for type DetailCircuitOK +const DetailCircuitOKCode int = 200 + +/*DetailCircuitOK A single circuit + +swagger:response detailCircuitOK +*/ +type DetailCircuitOK struct { + + /* + In: Body + */ + Payload *rest_model.DetailCircuitEnvelope `json:"body,omitempty"` +} + +// NewDetailCircuitOK creates DetailCircuitOK with default headers values +func NewDetailCircuitOK() *DetailCircuitOK { + + return &DetailCircuitOK{} +} + +// WithPayload adds the payload to the detail circuit o k response +func (o *DetailCircuitOK) WithPayload(payload *rest_model.DetailCircuitEnvelope) *DetailCircuitOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail circuit o k response +func (o *DetailCircuitOK) SetPayload(payload *rest_model.DetailCircuitEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailCircuitOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DetailCircuitUnauthorizedCode is the HTTP code returned for type DetailCircuitUnauthorized +const DetailCircuitUnauthorizedCode int = 401 + +/*DetailCircuitUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response detailCircuitUnauthorized +*/ +type DetailCircuitUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDetailCircuitUnauthorized creates DetailCircuitUnauthorized with default headers values +func NewDetailCircuitUnauthorized() *DetailCircuitUnauthorized { + + return &DetailCircuitUnauthorized{} +} + +// WithPayload adds the payload to the detail circuit unauthorized response +func (o *DetailCircuitUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *DetailCircuitUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail circuit unauthorized response +func (o *DetailCircuitUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailCircuitUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DetailCircuitNotFoundCode is the HTTP code returned for type DetailCircuitNotFound +const DetailCircuitNotFoundCode int = 404 + +/*DetailCircuitNotFound The requested resource does not exist + +swagger:response detailCircuitNotFound +*/ +type DetailCircuitNotFound struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDetailCircuitNotFound creates DetailCircuitNotFound with default headers values +func NewDetailCircuitNotFound() *DetailCircuitNotFound { + + return &DetailCircuitNotFound{} +} + +// WithPayload adds the payload to the detail circuit not found response +func (o *DetailCircuitNotFound) WithPayload(payload *rest_model.APIErrorEnvelope) *DetailCircuitNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail circuit not found response +func (o *DetailCircuitNotFound) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailCircuitNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/circuit/detail_circuit_urlbuilder.go b/rest_server/operations/circuit/detail_circuit_urlbuilder.go new file mode 100644 index 000000000..74eb73139 --- /dev/null +++ b/rest_server/operations/circuit/detail_circuit_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DetailCircuitURL generates an URL for the detail circuit operation +type DetailCircuitURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DetailCircuitURL) WithBasePath(bp string) *DetailCircuitURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DetailCircuitURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DetailCircuitURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/circuits/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DetailCircuitURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DetailCircuitURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DetailCircuitURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DetailCircuitURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DetailCircuitURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DetailCircuitURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DetailCircuitURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/circuit/list_circuits.go b/rest_server/operations/circuit/list_circuits.go new file mode 100644 index 000000000..34e8b1fb2 --- /dev/null +++ b/rest_server/operations/circuit/list_circuits.go @@ -0,0 +1,83 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListCircuitsHandlerFunc turns a function with the right signature into a list circuits handler +type ListCircuitsHandlerFunc func(ListCircuitsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListCircuitsHandlerFunc) Handle(params ListCircuitsParams) middleware.Responder { + return fn(params) +} + +// ListCircuitsHandler interface for that can handle valid list circuits params +type ListCircuitsHandler interface { + Handle(ListCircuitsParams) middleware.Responder +} + +// NewListCircuits creates a new http.Handler for the list circuits operation +func NewListCircuits(ctx *middleware.Context, handler ListCircuitsHandler) *ListCircuits { + return &ListCircuits{Context: ctx, Handler: handler} +} + +/* ListCircuits swagger:route GET /circuits Circuit listCircuits + +List circuits + +Retrieves a list of circuit resources; doesn not supports filtering, sorting, or pagination. Requires admin access. + + +*/ +type ListCircuits struct { + Context *middleware.Context + Handler ListCircuitsHandler +} + +func (o *ListCircuits) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewListCircuitsParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/circuit/list_circuits_parameters.go b/rest_server/operations/circuit/list_circuits_parameters.go new file mode 100644 index 000000000..7b59aa5db --- /dev/null +++ b/rest_server/operations/circuit/list_circuits_parameters.go @@ -0,0 +1,70 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewListCircuitsParams creates a new ListCircuitsParams object +// +// There are no default values defined in the spec. +func NewListCircuitsParams() ListCircuitsParams { + + return ListCircuitsParams{} +} + +// ListCircuitsParams contains all the bound params for the list circuits operation +// typically these are obtained from a http.Request +// +// swagger:parameters listCircuits +type ListCircuitsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListCircuitsParams() beforehand. +func (o *ListCircuitsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_server/operations/circuit/list_circuits_responses.go b/rest_server/operations/circuit/list_circuits_responses.go new file mode 100644 index 000000000..0c59912fe --- /dev/null +++ b/rest_server/operations/circuit/list_circuits_responses.go @@ -0,0 +1,126 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// ListCircuitsOKCode is the HTTP code returned for type ListCircuitsOK +const ListCircuitsOKCode int = 200 + +/*ListCircuitsOK A list of circuits + +swagger:response listCircuitsOK +*/ +type ListCircuitsOK struct { + + /* + In: Body + */ + Payload *rest_model.ListCircuitsEnvelope `json:"body,omitempty"` +} + +// NewListCircuitsOK creates ListCircuitsOK with default headers values +func NewListCircuitsOK() *ListCircuitsOK { + + return &ListCircuitsOK{} +} + +// WithPayload adds the payload to the list circuits o k response +func (o *ListCircuitsOK) WithPayload(payload *rest_model.ListCircuitsEnvelope) *ListCircuitsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list circuits o k response +func (o *ListCircuitsOK) SetPayload(payload *rest_model.ListCircuitsEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListCircuitsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListCircuitsUnauthorizedCode is the HTTP code returned for type ListCircuitsUnauthorized +const ListCircuitsUnauthorizedCode int = 401 + +/*ListCircuitsUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listCircuitsUnauthorized +*/ +type ListCircuitsUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListCircuitsUnauthorized creates ListCircuitsUnauthorized with default headers values +func NewListCircuitsUnauthorized() *ListCircuitsUnauthorized { + + return &ListCircuitsUnauthorized{} +} + +// WithPayload adds the payload to the list circuits unauthorized response +func (o *ListCircuitsUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListCircuitsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list circuits unauthorized response +func (o *ListCircuitsUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListCircuitsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/circuit/list_circuits_urlbuilder.go b/rest_server/operations/circuit/list_circuits_urlbuilder.go new file mode 100644 index 000000000..38e1fbd39 --- /dev/null +++ b/rest_server/operations/circuit/list_circuits_urlbuilder.go @@ -0,0 +1,111 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// ListCircuitsURL generates an URL for the list circuits operation +type ListCircuitsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListCircuitsURL) WithBasePath(bp string) *ListCircuitsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListCircuitsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListCircuitsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/circuits" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListCircuitsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListCircuitsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListCircuitsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListCircuitsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListCircuitsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListCircuitsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/link/detail_link.go b/rest_server/operations/link/detail_link.go new file mode 100644 index 000000000..e4f77ca01 --- /dev/null +++ b/rest_server/operations/link/detail_link.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DetailLinkHandlerFunc turns a function with the right signature into a detail link handler +type DetailLinkHandlerFunc func(DetailLinkParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DetailLinkHandlerFunc) Handle(params DetailLinkParams) middleware.Responder { + return fn(params) +} + +// DetailLinkHandler interface for that can handle valid detail link params +type DetailLinkHandler interface { + Handle(DetailLinkParams) middleware.Responder +} + +// NewDetailLink creates a new http.Handler for the detail link operation +func NewDetailLink(ctx *middleware.Context, handler DetailLinkHandler) *DetailLink { + return &DetailLink{Context: ctx, Handler: handler} +} + +/* DetailLink swagger:route GET /links/{id} Link detailLink + +Retrieves a single link + +Retrieves a single link by id. Requires admin access. + +*/ +type DetailLink struct { + Context *middleware.Context + Handler DetailLinkHandler +} + +func (o *DetailLink) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDetailLinkParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/link/detail_link_parameters.go b/rest_server/operations/link/detail_link_parameters.go new file mode 100644 index 000000000..4b1b682a2 --- /dev/null +++ b/rest_server/operations/link/detail_link_parameters.go @@ -0,0 +1,95 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDetailLinkParams creates a new DetailLinkParams object +// +// There are no default values defined in the spec. +func NewDetailLinkParams() DetailLinkParams { + + return DetailLinkParams{} +} + +// DetailLinkParams contains all the bound params for the detail link operation +// typically these are obtained from a http.Request +// +// swagger:parameters detailLink +type DetailLinkParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDetailLinkParams() beforehand. +func (o *DetailLinkParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DetailLinkParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/link/detail_link_responses.go b/rest_server/operations/link/detail_link_responses.go new file mode 100644 index 000000000..1581b941a --- /dev/null +++ b/rest_server/operations/link/detail_link_responses.go @@ -0,0 +1,170 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// DetailLinkOKCode is the HTTP code returned for type DetailLinkOK +const DetailLinkOKCode int = 200 + +/*DetailLinkOK A single link + +swagger:response detailLinkOK +*/ +type DetailLinkOK struct { + + /* + In: Body + */ + Payload *rest_model.DetailLinkEnvelope `json:"body,omitempty"` +} + +// NewDetailLinkOK creates DetailLinkOK with default headers values +func NewDetailLinkOK() *DetailLinkOK { + + return &DetailLinkOK{} +} + +// WithPayload adds the payload to the detail link o k response +func (o *DetailLinkOK) WithPayload(payload *rest_model.DetailLinkEnvelope) *DetailLinkOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail link o k response +func (o *DetailLinkOK) SetPayload(payload *rest_model.DetailLinkEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailLinkOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DetailLinkUnauthorizedCode is the HTTP code returned for type DetailLinkUnauthorized +const DetailLinkUnauthorizedCode int = 401 + +/*DetailLinkUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response detailLinkUnauthorized +*/ +type DetailLinkUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDetailLinkUnauthorized creates DetailLinkUnauthorized with default headers values +func NewDetailLinkUnauthorized() *DetailLinkUnauthorized { + + return &DetailLinkUnauthorized{} +} + +// WithPayload adds the payload to the detail link unauthorized response +func (o *DetailLinkUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *DetailLinkUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail link unauthorized response +func (o *DetailLinkUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailLinkUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DetailLinkNotFoundCode is the HTTP code returned for type DetailLinkNotFound +const DetailLinkNotFoundCode int = 404 + +/*DetailLinkNotFound The requested resource does not exist + +swagger:response detailLinkNotFound +*/ +type DetailLinkNotFound struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewDetailLinkNotFound creates DetailLinkNotFound with default headers values +func NewDetailLinkNotFound() *DetailLinkNotFound { + + return &DetailLinkNotFound{} +} + +// WithPayload adds the payload to the detail link not found response +func (o *DetailLinkNotFound) WithPayload(payload *rest_model.APIErrorEnvelope) *DetailLinkNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the detail link not found response +func (o *DetailLinkNotFound) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DetailLinkNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/link/detail_link_urlbuilder.go b/rest_server/operations/link/detail_link_urlbuilder.go new file mode 100644 index 000000000..2453aa4d1 --- /dev/null +++ b/rest_server/operations/link/detail_link_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DetailLinkURL generates an URL for the detail link operation +type DetailLinkURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DetailLinkURL) WithBasePath(bp string) *DetailLinkURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DetailLinkURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DetailLinkURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/links/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DetailLinkURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DetailLinkURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DetailLinkURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DetailLinkURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DetailLinkURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DetailLinkURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DetailLinkURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/link/list_links.go b/rest_server/operations/link/list_links.go new file mode 100644 index 000000000..ce0a3b51a --- /dev/null +++ b/rest_server/operations/link/list_links.go @@ -0,0 +1,83 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ListLinksHandlerFunc turns a function with the right signature into a list links handler +type ListLinksHandlerFunc func(ListLinksParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListLinksHandlerFunc) Handle(params ListLinksParams) middleware.Responder { + return fn(params) +} + +// ListLinksHandler interface for that can handle valid list links params +type ListLinksHandler interface { + Handle(ListLinksParams) middleware.Responder +} + +// NewListLinks creates a new http.Handler for the list links operation +func NewListLinks(ctx *middleware.Context, handler ListLinksHandler) *ListLinks { + return &ListLinks{Context: ctx, Handler: handler} +} + +/* ListLinks swagger:route GET /links Link listLinks + +List links + +Retrieves a list of link resources; doesn not supports filtering, sorting, or pagination. Requires admin access. + + +*/ +type ListLinks struct { + Context *middleware.Context + Handler ListLinksHandler +} + +func (o *ListLinks) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewListLinksParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/link/list_links_parameters.go b/rest_server/operations/link/list_links_parameters.go new file mode 100644 index 000000000..3238d957d --- /dev/null +++ b/rest_server/operations/link/list_links_parameters.go @@ -0,0 +1,70 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewListLinksParams creates a new ListLinksParams object +// +// There are no default values defined in the spec. +func NewListLinksParams() ListLinksParams { + + return ListLinksParams{} +} + +// ListLinksParams contains all the bound params for the list links operation +// typically these are obtained from a http.Request +// +// swagger:parameters listLinks +type ListLinksParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewListLinksParams() beforehand. +func (o *ListLinksParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_server/operations/link/list_links_responses.go b/rest_server/operations/link/list_links_responses.go new file mode 100644 index 000000000..1cee1e679 --- /dev/null +++ b/rest_server/operations/link/list_links_responses.go @@ -0,0 +1,126 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// ListLinksOKCode is the HTTP code returned for type ListLinksOK +const ListLinksOKCode int = 200 + +/*ListLinksOK A list of links + +swagger:response listLinksOK +*/ +type ListLinksOK struct { + + /* + In: Body + */ + Payload *rest_model.ListLinksEnvelope `json:"body,omitempty"` +} + +// NewListLinksOK creates ListLinksOK with default headers values +func NewListLinksOK() *ListLinksOK { + + return &ListLinksOK{} +} + +// WithPayload adds the payload to the list links o k response +func (o *ListLinksOK) WithPayload(payload *rest_model.ListLinksEnvelope) *ListLinksOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list links o k response +func (o *ListLinksOK) SetPayload(payload *rest_model.ListLinksEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListLinksOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ListLinksUnauthorizedCode is the HTTP code returned for type ListLinksUnauthorized +const ListLinksUnauthorizedCode int = 401 + +/*ListLinksUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listLinksUnauthorized +*/ +type ListLinksUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListLinksUnauthorized creates ListLinksUnauthorized with default headers values +func NewListLinksUnauthorized() *ListLinksUnauthorized { + + return &ListLinksUnauthorized{} +} + +// WithPayload adds the payload to the list links unauthorized response +func (o *ListLinksUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListLinksUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list links unauthorized response +func (o *ListLinksUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListLinksUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/link/list_links_urlbuilder.go b/rest_server/operations/link/list_links_urlbuilder.go new file mode 100644 index 000000000..8bcef41c8 --- /dev/null +++ b/rest_server/operations/link/list_links_urlbuilder.go @@ -0,0 +1,111 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// ListLinksURL generates an URL for the list links operation +type ListLinksURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListLinksURL) WithBasePath(bp string) *ListLinksURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ListLinksURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListLinksURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/links" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ListLinksURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ListLinksURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListLinksURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListLinksURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListLinksURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ListLinksURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/link/patch_link.go b/rest_server/operations/link/patch_link.go new file mode 100644 index 000000000..05a514797 --- /dev/null +++ b/rest_server/operations/link/patch_link.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PatchLinkHandlerFunc turns a function with the right signature into a patch link handler +type PatchLinkHandlerFunc func(PatchLinkParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PatchLinkHandlerFunc) Handle(params PatchLinkParams) middleware.Responder { + return fn(params) +} + +// PatchLinkHandler interface for that can handle valid patch link params +type PatchLinkHandler interface { + Handle(PatchLinkParams) middleware.Responder +} + +// NewPatchLink creates a new http.Handler for the patch link operation +func NewPatchLink(ctx *middleware.Context, handler PatchLinkHandler) *PatchLink { + return &PatchLink{Context: ctx, Handler: handler} +} + +/* PatchLink swagger:route PATCH /links/{id} Link patchLink + +Update the supplied fields on a link + +Update the supplied fields on a link. Requires admin access. + +*/ +type PatchLink struct { + Context *middleware.Context + Handler PatchLinkHandler +} + +func (o *PatchLink) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPatchLinkParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/link/patch_link_parameters.go b/rest_server/operations/link/patch_link_parameters.go new file mode 100644 index 000000000..25cce14b0 --- /dev/null +++ b/rest_server/operations/link/patch_link_parameters.go @@ -0,0 +1,134 @@ +// 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" + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/openziti/fabric/rest_model" +) + +// NewPatchLinkParams creates a new PatchLinkParams object +// +// There are no default values defined in the spec. +func NewPatchLinkParams() PatchLinkParams { + + return PatchLinkParams{} +} + +// PatchLinkParams contains all the bound params for the patch link operation +// typically these are obtained from a http.Request +// +// swagger:parameters patchLink +type PatchLinkParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string + /*A link patch object + Required: true + In: body + */ + Link *rest_model.LinkPatch +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPatchLinkParams() beforehand. +func (o *PatchLinkParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body rest_model.LinkPatch + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("link", "body", "")) + } else { + res = append(res, errors.NewParseError("link", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(context.Background()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Link = &body + } + } + } else { + res = append(res, errors.Required("link", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *PatchLinkParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/link/patch_link_responses.go b/rest_server/operations/link/patch_link_responses.go new file mode 100644 index 000000000..a9da81ba0 --- /dev/null +++ b/rest_server/operations/link/patch_link_responses.go @@ -0,0 +1,214 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// PatchLinkOKCode is the HTTP code returned for type PatchLinkOK +const PatchLinkOKCode int = 200 + +/*PatchLinkOK The patch request was successful and the resource has been altered + +swagger:response patchLinkOK +*/ +type PatchLinkOK struct { + + /* + In: Body + */ + Payload *rest_model.Empty `json:"body,omitempty"` +} + +// NewPatchLinkOK creates PatchLinkOK with default headers values +func NewPatchLinkOK() *PatchLinkOK { + + return &PatchLinkOK{} +} + +// WithPayload adds the payload to the patch link o k response +func (o *PatchLinkOK) WithPayload(payload *rest_model.Empty) *PatchLinkOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch link o k response +func (o *PatchLinkOK) SetPayload(payload *rest_model.Empty) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchLinkOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PatchLinkBadRequestCode is the HTTP code returned for type PatchLinkBadRequest +const PatchLinkBadRequestCode int = 400 + +/*PatchLinkBadRequest 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 + +swagger:response patchLinkBadRequest +*/ +type PatchLinkBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewPatchLinkBadRequest creates PatchLinkBadRequest with default headers values +func NewPatchLinkBadRequest() *PatchLinkBadRequest { + + return &PatchLinkBadRequest{} +} + +// WithPayload adds the payload to the patch link bad request response +func (o *PatchLinkBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *PatchLinkBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch link bad request response +func (o *PatchLinkBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchLinkBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PatchLinkUnauthorizedCode is the HTTP code returned for type PatchLinkUnauthorized +const PatchLinkUnauthorizedCode int = 401 + +/*PatchLinkUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response patchLinkUnauthorized +*/ +type PatchLinkUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewPatchLinkUnauthorized creates PatchLinkUnauthorized with default headers values +func NewPatchLinkUnauthorized() *PatchLinkUnauthorized { + + return &PatchLinkUnauthorized{} +} + +// WithPayload adds the payload to the patch link unauthorized response +func (o *PatchLinkUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *PatchLinkUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch link unauthorized response +func (o *PatchLinkUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchLinkUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PatchLinkNotFoundCode is the HTTP code returned for type PatchLinkNotFound +const PatchLinkNotFoundCode int = 404 + +/*PatchLinkNotFound The requested resource does not exist + +swagger:response patchLinkNotFound +*/ +type PatchLinkNotFound struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewPatchLinkNotFound creates PatchLinkNotFound with default headers values +func NewPatchLinkNotFound() *PatchLinkNotFound { + + return &PatchLinkNotFound{} +} + +// WithPayload adds the payload to the patch link not found response +func (o *PatchLinkNotFound) WithPayload(payload *rest_model.APIErrorEnvelope) *PatchLinkNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch link not found response +func (o *PatchLinkNotFound) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchLinkNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/link/patch_link_urlbuilder.go b/rest_server/operations/link/patch_link_urlbuilder.go new file mode 100644 index 000000000..573476c46 --- /dev/null +++ b/rest_server/operations/link/patch_link_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// PatchLinkURL generates an URL for the patch link operation +type PatchLinkURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PatchLinkURL) WithBasePath(bp string) *PatchLinkURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PatchLinkURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PatchLinkURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/links/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on PatchLinkURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PatchLinkURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PatchLinkURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PatchLinkURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PatchLinkURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PatchLinkURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PatchLinkURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/ziti_fabric_api.go b/rest_server/operations/ziti_fabric_api.go index 6bc77c120..4ae5bddf2 100644 --- a/rest_server/operations/ziti_fabric_api.go +++ b/rest_server/operations/ziti_fabric_api.go @@ -43,6 +43,8 @@ import ( "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/openziti/fabric/rest_server/operations/circuit" + "github.com/openziti/fabric/rest_server/operations/link" "github.com/openziti/fabric/rest_server/operations/router" "github.com/openziti/fabric/rest_server/operations/service" "github.com/openziti/fabric/rest_server/operations/terminator" @@ -79,6 +81,9 @@ func NewZitiFabricAPI(spec *loads.Document) *ZitiFabricAPI { TerminatorCreateTerminatorHandler: terminator.CreateTerminatorHandlerFunc(func(params terminator.CreateTerminatorParams) middleware.Responder { return middleware.NotImplemented("operation terminator.CreateTerminator has not yet been implemented") }), + CircuitDeleteCircuitHandler: circuit.DeleteCircuitHandlerFunc(func(params circuit.DeleteCircuitParams) middleware.Responder { + return middleware.NotImplemented("operation circuit.DeleteCircuit has not yet been implemented") + }), RouterDeleteRouterHandler: router.DeleteRouterHandlerFunc(func(params router.DeleteRouterParams) middleware.Responder { return middleware.NotImplemented("operation router.DeleteRouter has not yet been implemented") }), @@ -88,6 +93,12 @@ func NewZitiFabricAPI(spec *loads.Document) *ZitiFabricAPI { TerminatorDeleteTerminatorHandler: terminator.DeleteTerminatorHandlerFunc(func(params terminator.DeleteTerminatorParams) middleware.Responder { return middleware.NotImplemented("operation terminator.DeleteTerminator has not yet been implemented") }), + CircuitDetailCircuitHandler: circuit.DetailCircuitHandlerFunc(func(params circuit.DetailCircuitParams) middleware.Responder { + return middleware.NotImplemented("operation circuit.DetailCircuit has not yet been implemented") + }), + LinkDetailLinkHandler: link.DetailLinkHandlerFunc(func(params link.DetailLinkParams) middleware.Responder { + return middleware.NotImplemented("operation link.DetailLink has not yet been implemented") + }), RouterDetailRouterHandler: router.DetailRouterHandlerFunc(func(params router.DetailRouterParams) middleware.Responder { return middleware.NotImplemented("operation router.DetailRouter has not yet been implemented") }), @@ -97,6 +108,12 @@ func NewZitiFabricAPI(spec *loads.Document) *ZitiFabricAPI { TerminatorDetailTerminatorHandler: terminator.DetailTerminatorHandlerFunc(func(params terminator.DetailTerminatorParams) middleware.Responder { return middleware.NotImplemented("operation terminator.DetailTerminator has not yet been implemented") }), + CircuitListCircuitsHandler: circuit.ListCircuitsHandlerFunc(func(params circuit.ListCircuitsParams) middleware.Responder { + return middleware.NotImplemented("operation circuit.ListCircuits has not yet been implemented") + }), + LinkListLinksHandler: link.ListLinksHandlerFunc(func(params link.ListLinksParams) middleware.Responder { + return middleware.NotImplemented("operation link.ListLinks has not yet been implemented") + }), RouterListRouterTerminatorsHandler: router.ListRouterTerminatorsHandlerFunc(func(params router.ListRouterTerminatorsParams) middleware.Responder { return middleware.NotImplemented("operation router.ListRouterTerminators has not yet been implemented") }), @@ -112,6 +129,9 @@ func NewZitiFabricAPI(spec *loads.Document) *ZitiFabricAPI { TerminatorListTerminatorsHandler: terminator.ListTerminatorsHandlerFunc(func(params terminator.ListTerminatorsParams) middleware.Responder { return middleware.NotImplemented("operation terminator.ListTerminators has not yet been implemented") }), + LinkPatchLinkHandler: link.PatchLinkHandlerFunc(func(params link.PatchLinkParams) middleware.Responder { + return middleware.NotImplemented("operation link.PatchLink has not yet been implemented") + }), ServicePatchServiceHandler: service.PatchServiceHandlerFunc(func(params service.PatchServiceParams) middleware.Responder { return middleware.NotImplemented("operation service.PatchService has not yet been implemented") }), @@ -166,18 +186,28 @@ type ZitiFabricAPI struct { ServiceCreateServiceHandler service.CreateServiceHandler // TerminatorCreateTerminatorHandler sets the operation handler for the create terminator operation TerminatorCreateTerminatorHandler terminator.CreateTerminatorHandler + // CircuitDeleteCircuitHandler sets the operation handler for the delete circuit operation + CircuitDeleteCircuitHandler circuit.DeleteCircuitHandler // RouterDeleteRouterHandler sets the operation handler for the delete router operation RouterDeleteRouterHandler router.DeleteRouterHandler // ServiceDeleteServiceHandler sets the operation handler for the delete service operation ServiceDeleteServiceHandler service.DeleteServiceHandler // TerminatorDeleteTerminatorHandler sets the operation handler for the delete terminator operation TerminatorDeleteTerminatorHandler terminator.DeleteTerminatorHandler + // CircuitDetailCircuitHandler sets the operation handler for the detail circuit operation + CircuitDetailCircuitHandler circuit.DetailCircuitHandler + // LinkDetailLinkHandler sets the operation handler for the detail link operation + LinkDetailLinkHandler link.DetailLinkHandler // RouterDetailRouterHandler sets the operation handler for the detail router operation RouterDetailRouterHandler router.DetailRouterHandler // ServiceDetailServiceHandler sets the operation handler for the detail service operation ServiceDetailServiceHandler service.DetailServiceHandler // TerminatorDetailTerminatorHandler sets the operation handler for the detail terminator operation TerminatorDetailTerminatorHandler terminator.DetailTerminatorHandler + // CircuitListCircuitsHandler sets the operation handler for the list circuits operation + CircuitListCircuitsHandler circuit.ListCircuitsHandler + // LinkListLinksHandler sets the operation handler for the list links operation + LinkListLinksHandler link.ListLinksHandler // RouterListRouterTerminatorsHandler sets the operation handler for the list router terminators operation RouterListRouterTerminatorsHandler router.ListRouterTerminatorsHandler // RouterListRoutersHandler sets the operation handler for the list routers operation @@ -188,6 +218,8 @@ type ZitiFabricAPI struct { ServiceListServicesHandler service.ListServicesHandler // TerminatorListTerminatorsHandler sets the operation handler for the list terminators operation TerminatorListTerminatorsHandler terminator.ListTerminatorsHandler + // LinkPatchLinkHandler sets the operation handler for the patch link operation + LinkPatchLinkHandler link.PatchLinkHandler // ServicePatchServiceHandler sets the operation handler for the patch service operation ServicePatchServiceHandler service.PatchServiceHandler // TerminatorPatchTerminatorHandler sets the operation handler for the patch terminator operation @@ -282,6 +314,9 @@ func (o *ZitiFabricAPI) Validate() error { if o.TerminatorCreateTerminatorHandler == nil { unregistered = append(unregistered, "terminator.CreateTerminatorHandler") } + if o.CircuitDeleteCircuitHandler == nil { + unregistered = append(unregistered, "circuit.DeleteCircuitHandler") + } if o.RouterDeleteRouterHandler == nil { unregistered = append(unregistered, "router.DeleteRouterHandler") } @@ -291,6 +326,12 @@ func (o *ZitiFabricAPI) Validate() error { if o.TerminatorDeleteTerminatorHandler == nil { unregistered = append(unregistered, "terminator.DeleteTerminatorHandler") } + if o.CircuitDetailCircuitHandler == nil { + unregistered = append(unregistered, "circuit.DetailCircuitHandler") + } + if o.LinkDetailLinkHandler == nil { + unregistered = append(unregistered, "link.DetailLinkHandler") + } if o.RouterDetailRouterHandler == nil { unregistered = append(unregistered, "router.DetailRouterHandler") } @@ -300,6 +341,12 @@ func (o *ZitiFabricAPI) Validate() error { if o.TerminatorDetailTerminatorHandler == nil { unregistered = append(unregistered, "terminator.DetailTerminatorHandler") } + if o.CircuitListCircuitsHandler == nil { + unregistered = append(unregistered, "circuit.ListCircuitsHandler") + } + if o.LinkListLinksHandler == nil { + unregistered = append(unregistered, "link.ListLinksHandler") + } if o.RouterListRouterTerminatorsHandler == nil { unregistered = append(unregistered, "router.ListRouterTerminatorsHandler") } @@ -315,6 +362,9 @@ func (o *ZitiFabricAPI) Validate() error { if o.TerminatorListTerminatorsHandler == nil { unregistered = append(unregistered, "terminator.ListTerminatorsHandler") } + if o.LinkPatchLinkHandler == nil { + unregistered = append(unregistered, "link.PatchLinkHandler") + } if o.ServicePatchServiceHandler == nil { unregistered = append(unregistered, "service.PatchServiceHandler") } @@ -430,6 +480,10 @@ func (o *ZitiFabricAPI) initHandlerCache() { if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) } + o.handlers["DELETE"]["/circuits/{id}"] = circuit.NewDeleteCircuit(o.context, o.CircuitDeleteCircuitHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } o.handlers["DELETE"]["/routers/{id}"] = router.NewDeleteRouter(o.context, o.RouterDeleteRouterHandler) if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) @@ -442,6 +496,14 @@ func (o *ZitiFabricAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } + o.handlers["GET"]["/circuits/{id}"] = circuit.NewDetailCircuit(o.context, o.CircuitDetailCircuitHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/links/{id}"] = link.NewDetailLink(o.context, o.LinkDetailLinkHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } o.handlers["GET"]["/routers/{id}"] = router.NewDetailRouter(o.context, o.RouterDetailRouterHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) @@ -454,6 +516,14 @@ func (o *ZitiFabricAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } + o.handlers["GET"]["/circuits"] = circuit.NewListCircuits(o.context, o.CircuitListCircuitsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/links"] = link.NewListLinks(o.context, o.LinkListLinksHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } o.handlers["GET"]["/routers/{id}/terminators"] = router.NewListRouterTerminators(o.context, o.RouterListRouterTerminatorsHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) @@ -474,6 +544,10 @@ func (o *ZitiFabricAPI) initHandlerCache() { if o.handlers["PATCH"] == nil { o.handlers["PATCH"] = make(map[string]http.Handler) } + o.handlers["PATCH"]["/links/{id}"] = link.NewPatchLink(o.context, o.LinkPatchLinkHandler) + if o.handlers["PATCH"] == nil { + o.handlers["PATCH"] = make(map[string]http.Handler) + } o.handlers["PATCH"]["/services/{id}"] = service.NewPatchService(o.context, o.ServicePatchServiceHandler) if o.handlers["PATCH"] == nil { o.handlers["PATCH"] = make(map[string]http.Handler) diff --git a/specs/swagger.yml b/specs/swagger.yml index da7ff723c..1544dcf2f 100644 --- a/specs/swagger.yml +++ b/specs/swagger.yml @@ -413,6 +413,117 @@ paths: '409': $ref: '#/responses/cannotDeleteReferencedResourceResponse' + ################################################################### + # Links + ################################################################## + '/links': + get: + summary: List links + description: | + Retrieves a list of link resources; doesn not supports filtering, sorting, or pagination. Requires admin access. + tags: + - Link + operationId: listLinks + # parameters: + # - $ref: '#/parameters/limit' + # - $ref: '#/parameters/offset' + # - $ref: '#/parameters/filter' + responses: + '200': + $ref: '#/responses/listLinks' + '401': + $ref: '#/responses/unauthorizedResponse' + '/links/{id}': + parameters: + - $ref: '#/parameters/id' + get: + summary: Retrieves a single link + description: Retrieves a single link by id. Requires admin access. + tags: + - Link + operationId: detailLink + responses: + '200': + $ref: '#/responses/detailLink' + '404': + $ref: '#/responses/notFoundResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + patch: + summary: Update the supplied fields on a link + description: Update the supplied fields on a link. Requires admin access. + tags: + - Link + operationId: patchLink + parameters: + - name: link + in: body + required: true + description: A link patch object + schema: + $ref: '#/definitions/linkPatch' + responses: + '200': + $ref: '#/responses/patchResponse' + '400': + $ref: '#/responses/badRequestResponse' + '404': + $ref: '#/responses/notFoundResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + + ################################################################### + # Circuits + ################################################################## + '/circuits': + get: + summary: List circuits + description: | + Retrieves a list of circuit resources; doesn not supports filtering, sorting, or pagination. Requires admin access. + tags: + - Circuit + operationId: listCircuits + # parameters: + # - $ref: '#/parameters/limit' + # - $ref: '#/parameters/offset' + # - $ref: '#/parameters/filter' + responses: + '200': + $ref: '#/responses/listCircuits' + '401': + $ref: '#/responses/unauthorizedResponse' + '/circuits/{id}': + parameters: + - $ref: '#/parameters/id' + get: + summary: Retrieves a single circuit + description: Retrieves a single circuit by id. Requires admin access. + tags: + - Circuit + operationId: detailCircuit + responses: + '200': + $ref: '#/responses/detailCircuit' + '404': + $ref: '#/responses/notFoundResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + delete: + summary: Delete a circuit + description: Delete a circuit by id. Requires admin access. + tags: + - Circuit + operationId: deleteCircuit + responses: + '200': + $ref: '#/responses/deleteResponse' + '400': + $ref: '#/responses/badRequestResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + '409': + $ref: '#/responses/cannotDeleteReferencedResourceResponse' + ####################################################################################################################### # # Parameters - Reusable parameters @@ -621,6 +732,29 @@ responses: schema: $ref: '#/definitions/detailTerminatorEnvelope' + ################################################################### + # Links + ################################################################## + listLinks: + description: A list of links + schema: + $ref: '#/definitions/listLinksEnvelope' + detailLink: + description: A single link + schema: + $ref: '#/definitions/detailLinkEnvelope' + + ################################################################### + # Circuits + ################################################################## + listCircuits: + description: A list of circuits + schema: + $ref: '#/definitions/listCircuitsEnvelope' + detailCircuit: + description: A single circuit + schema: + $ref: '#/definitions/detailCircuitEnvelope' ####################################################################################################################### # @@ -1127,4 +1261,117 @@ definitions: terminatorCostMap: type: object additionalProperties: - $ref: '#/definitions/terminatorCost' \ No newline at end of file + $ref: '#/definitions/terminatorCost' + + ################################################################### + # Links + ################################################################## + listLinksEnvelope: + type: object + required: + - meta + - data + properties: + meta: + $ref: '#/definitions/meta' + data: + $ref: '#/definitions/linkList' + detailLinkEnvelope: + type: object + required: + - meta + - data + properties: + meta: + $ref: '#/definitions/meta' + data: + $ref: '#/definitions/linkDetail' + linkList: + type: array + items: + $ref: '#/definitions/linkDetail' + linkDetail: + type: object + required: + - id + - sourceRouter + - destRouter + - state + - staticCost + - sourceLatency + - destLatency + - cost + properties: + id: + type: string + sourceRouter: + $ref: '#/definitions/entityRef' + destRouter: + $ref: '#/definitions/entityRef' + state: + type: string + down: + type: boolean + staticCost: + type: integer + sourceLatency: + type: integer + destLatency: + type: integer + cost: + type: integer + linkPatch: + type: object + properties: + down: + type: boolean + staticCost: + type: integer + + ################################################################### + # Circuits + ################################################################## + listCircuitsEnvelope: + type: object + required: + - meta + - data + properties: + meta: + $ref: '#/definitions/meta' + data: + $ref: '#/definitions/linkList' + detailCircuitEnvelope: + type: object + required: + - meta + - data + properties: + meta: + $ref: '#/definitions/meta' + data: + $ref: '#/definitions/circuitDetail' + circuitList: + type: array + items: + $ref: '#/definitions/circuitDetail' + circuitDetail: + type: object + required: + - id + - service + - terminator + - path + properties: + id: + type: string + clientId: + type: string + service: + $ref: '#/definitions/entityRef' + terminator: + $ref: '#/definitions/entityRef' + path: + type: array + items: + $ref: '#/definitions/entityRef' From ea1bac0b17c892adbfe8849da09da1f1cb57ec13 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Sat, 20 Nov 2021 23:51:03 -0500 Subject: [PATCH 4/7] Add link implementation. Convert link to string from identity.TokenId --- controller/api_impl/link_api_model.go | 19 +++-------- controller/api_impl/link_router.go | 22 ++++++++---- controller/handler_ctrl/fault.go | 5 ++- controller/handler_ctrl/link.go | 3 +- controller/handler_ctrl/verify_link.go | 3 +- controller/handler_mgmt/list_circuits.go | 2 +- controller/handler_mgmt/list_links.go | 2 +- controller/handler_mgmt/set_link_cost.go | 3 +- controller/handler_mgmt/set_link_down.go | 3 +- controller/network/assembly.go | 6 ++-- controller/network/link.go | 5 ++- controller/network/link_controller.go | 23 ++++++------- controller/network/link_controller_test.go | 5 ++- controller/network/network.go | 30 ++++++++--------- controller/network/path.go | 18 +++++----- controller/network/path_test.go | 39 +++++++++++----------- controller/network/route_perf_test.go | 9 +++-- events/metrics.go | 3 +- rest_model/link_detail.go | 16 ++++++++- rest_server/embedded_spec.go | 6 ++-- specs/swagger.yml | 1 + 21 files changed, 115 insertions(+), 108 deletions(-) diff --git a/controller/api_impl/link_api_model.go b/controller/api_impl/link_api_model.go index de9816cd3..1ff665a44 100644 --- a/controller/api_impl/link_api_model.go +++ b/controller/api_impl/link_api_model.go @@ -19,8 +19,6 @@ package api_impl import ( "github.com/openziti/fabric/controller/api" "github.com/openziti/fabric/controller/network" - "github.com/openziti/foundation/identity/identity" - "github.com/openziti/fabric/rest_model" "github.com/openziti/fabric/controller/models" @@ -45,16 +43,6 @@ func (factory *LinkLinkFactoryIml) Links(entity models.Entity) rest_model.Links return links } -func MapPatchLinkToModel(id string, link *rest_model.LinkPatch) *network.Link { - ret := &network.Link{ - Id: &identity.TokenId{Token: id}, - Down: link.Down, - StaticCost: int32(link.StaticCost), - } - - return ret -} - func MapLinkToRestModel(_ *network.Network, _ api.RequestContext, link *network.Link) (*rest_model.LinkDetail, error) { staticCost := int64(link.StaticCost) linkState := link.CurrentState() @@ -62,12 +50,15 @@ func MapLinkToRestModel(_ *network.Network, _ api.RequestContext, link *network. 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: link.Down, - ID: &link.Id.Token, + Down: &down, + ID: &link.Id, SourceLatency: &link.SrcLatency, SourceRouter: ToEntityRef(link.Src.Name, link.Src, RouterLinkFactory), State: &linkStateStr, diff --git a/controller/api_impl/link_router.go b/controller/api_impl/link_router.go index df2720d64..99a93a617 100644 --- a/controller/api_impl/link_router.go +++ b/controller/api_impl/link_router.go @@ -23,7 +23,6 @@ import ( "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/identity/identity" "github.com/openziti/foundation/storage/boltz" "sort" ) @@ -61,7 +60,7 @@ 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.Token < links[j].Id.Token + return links[i].Id < links[j].Id }) apiLinks := make([]*rest_model.LinkDetail, 0, len(links)) for _, modelLink := range links { @@ -84,7 +83,7 @@ func (r *LinkRouter) ListLinks(n *network.Network, rc api.RequestContext) { func (r *LinkRouter) Detail(n *network.Network, rc api.RequestContext) { Detail(rc, func(rc api.RequestContext, id string) (interface{}, error) { - l, found := n.GetLink(&identity.TokenId{Token: id}) + l, found := n.GetLink(id) if !found { return nil, boltz.NewNotFoundError("link", "id", id) } @@ -97,7 +96,18 @@ func (r *LinkRouter) Detail(n *network.Network, rc api.RequestContext) { } func (r *LinkRouter) Patch(n *network.Network, rc api.RequestContext, params link.PatchLinkParams) { - //Patch(rc, func(id string, fields api.JsonFields) error { - // return n.Controllers.Links.Patch(MapPatchLinkToModel(params.ID, params.Link), fields.ConcatNestedNames().FilterMaps("tags")) - //}) + 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 + }) } diff --git a/controller/handler_ctrl/fault.go b/controller/handler_ctrl/fault.go index a53118ce6..beae2f29c 100644 --- a/controller/handler_ctrl/fault.go +++ b/controller/handler_ctrl/fault.go @@ -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: diff --git a/controller/handler_ctrl/link.go b/controller/handler_ctrl/link.go index daf09f623..7fe0f4ec6 100644 --- a/controller/handler_ctrl/link.go +++ b/controller/handler_ctrl/link.go @@ -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") diff --git a/controller/handler_ctrl/verify_link.go b/controller/handler_ctrl/verify_link.go index 3e7a73b8f..8f5b3302e 100644 --- a/controller/handler_ctrl/verify_link.go +++ b/controller/handler_ctrl/verify_link.go @@ -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 { diff --git a/controller/handler_mgmt/list_circuits.go b/controller/handler_mgmt/list_circuits.go index 056ae8e6a..1c403f156 100644 --- a/controller/handler_mgmt/list_circuits.go +++ b/controller/handler_mgmt/list_circuits.go @@ -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 } diff --git a/controller/handler_mgmt/list_links.go b/controller/handler_mgmt/list_links.go index efc341cd3..8c309bf30 100644 --- a/controller/handler_mgmt/list_links.go +++ b/controller/handler_mgmt/list_links.go @@ -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(), diff --git a/controller/handler_mgmt/set_link_cost.go b/controller/handler_mgmt/set_link_cost.go index fe80afa82..20c7bc597 100644 --- a/controller/handler_mgmt/set_link_cost.go +++ b/controller/handler_mgmt/set_link_cost.go @@ -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) diff --git a/controller/handler_mgmt/set_link_down.go b/controller/handler_mgmt/set_link_down.go index 1fcd166f3..1c6a8791f 100644 --- a/controller/handler_mgmt/set_link_down.go +++ b/controller/handler_mgmt/set_link_down.go @@ -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) diff --git a/controller/network/assembly.go b/controller/network/assembly.go index d5cba2dd2..c4a0cdda8 100644 --- a/controller/network/assembly.go +++ b/controller/network/assembly.go @@ -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) } } diff --git a/controller/network/link.go b/controller/network/link.go index f7a1e5e67..25d311f9d 100644 --- a/controller/network/link.go +++ b/controller/network/link.go @@ -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), diff --git a/controller/network/link_controller.go b/controller/network/link_controller.go index 0143e2280..3e75e0a6f 100644 --- a/controller/network/link_controller.go +++ b/controller/network/link_controller.go @@ -18,7 +18,6 @@ package network import ( "github.com/openziti/fabric/controller/idgen" - "github.com/openziti/foundation/identity/identity" "github.com/openziti/foundation/util/info" "github.com/orcaman/concurrent-map" "math" @@ -26,14 +25,14 @@ import ( ) type linkController struct { - linkTable *linkTable - idGenerator idgen.Generator + linkTable *linkTable + idGenerator idgen.Generator } func newLinkController() *linkController { return &linkController{ - linkTable: newLinkTable(), - idGenerator: idgen.NewGenerator(), + 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 } @@ -130,7 +129,7 @@ func (linkController *linkController) missingLinks(routers []*Router, pendingTim 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 } @@ -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) } /* diff --git a/controller/network/link_controller_test.go b/controller/network/link_controller_test.go index 97cb3773c..47b0e42d4 100644 --- a/controller/network/link_controller_test.go +++ b/controller/network/link_controller_test.go @@ -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, } diff --git a/controller/network/network.go b/controller/network/network.go index 32c5e4250..13d0ab352 100644 --- a/controller/network/network.go +++ b/controller/network/network.go @@ -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) { @@ -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 diff --git a/controller/network/path.go b/controller/network/path.go index a21d7bd83..d52b8a5d4 100644 --- a/controller/network/path.go +++ b/controller/network/path.go @@ -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) diff --git a/controller/network/path_test.go b/controller/network/path_test.go index 585e698a7..7901fd358 100644 --- a/controller/network/path_test.go +++ b/controller/network/path_test.go @@ -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) diff --git a/controller/network/route_perf_test.go b/controller/network/route_perf_test.go index d80b298a5..4904b3f9e 100644 --- a/controller/network/route_perf_test.go +++ b/controller/network/route_perf_test.go @@ -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) diff --git a/events/metrics.go b/events/metrics.go index de9f0cde9..024d0c628 100644 --- a/events/metrics.go +++ b/events/metrics.go @@ -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 { diff --git a/rest_model/link_detail.go b/rest_model/link_detail.go index 0a237654e..555cabc0d 100644 --- a/rest_model/link_detail.go +++ b/rest_model/link_detail.go @@ -56,7 +56,8 @@ type LinkDetail struct { DestRouter *EntityRef `json:"destRouter"` // down - Down bool `json:"down,omitempty"` + // Required: true + Down *bool `json:"down"` // id // Required: true @@ -95,6 +96,10 @@ func (m *LinkDetail) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateDown(formats); err != nil { + res = append(res, err) + } + if err := m.validateID(formats); err != nil { res = append(res, err) } @@ -159,6 +164,15 @@ func (m *LinkDetail) validateDestRouter(formats strfmt.Registry) error { return nil } +func (m *LinkDetail) validateDown(formats strfmt.Registry) error { + + if err := validate.Required("down", "body", m.Down); err != nil { + return err + } + + return nil +} + func (m *LinkDetail) validateID(formats strfmt.Registry) error { if err := validate.Required("id", "body", m.ID); err != nil { diff --git a/rest_server/embedded_spec.go b/rest_server/embedded_spec.go index fe3cbc6be..dfeca3fd8 100644 --- a/rest_server/embedded_spec.go +++ b/rest_server/embedded_spec.go @@ -1037,7 +1037,8 @@ func init() { "staticCost", "sourceLatency", "destLatency", - "cost" + "cost", + "down" ], "properties": { "cost": { @@ -4336,7 +4337,8 @@ func init() { "staticCost", "sourceLatency", "destLatency", - "cost" + "cost", + "down" ], "properties": { "cost": { diff --git a/specs/swagger.yml b/specs/swagger.yml index 1544dcf2f..34751c45b 100644 --- a/specs/swagger.yml +++ b/specs/swagger.yml @@ -1301,6 +1301,7 @@ definitions: - sourceLatency - destLatency - cost + - down properties: id: type: string From 5a54c9b041c1d651be692ba7b4d958629f036474 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Sun, 21 Nov 2021 00:42:07 -0500 Subject: [PATCH 5/7] Add circuit router implementation --- controller/api_impl/base_entity_api_model.go | 14 +- controller/api_impl/base_router.go | 6 + controller/api_impl/circuit_api_model.go | 64 ++++++ controller/api_impl/circuit_router.go | 102 +++++++++ controller/api_impl/link_api_model.go | 4 +- controller/api_impl/router_api_model.go | 2 +- controller/api_impl/service_api_model.go | 2 +- controller/db/terminator_store.go | 4 + controller/network/link.go | 4 + controller/network/util_test.go | 6 +- controller/xt/xt.go | 2 +- .../circuit/delete_circuit_parameters.go | 24 +++ rest_model/circuit_delete.go | 74 +++++++ rest_model/circuit_detail.go | 199 +++++++++++++++--- rest_server/embedded_spec.go | 87 +++++++- .../circuit/delete_circuit_parameters.go | 31 +++ specs/swagger.yml | 25 ++- 17 files changed, 601 insertions(+), 49 deletions(-) create mode 100644 controller/api_impl/circuit_api_model.go create mode 100644 controller/api_impl/circuit_router.go create mode 100644 rest_model/circuit_delete.go diff --git a/controller/api_impl/base_entity_api_model.go b/controller/api_impl/base_entity_api_model.go index b9407d80c..1f7cd2b60 100644 --- a/controller/api_impl/base_entity_api_model.go +++ b/controller/api_impl/base_entity_api_model.go @@ -52,7 +52,7 @@ type FullLinkFactory interface { } type LinksFactory interface { - Links(entity models.Entity) rest_model.Links + Links(entity LinkEntity) rest_model.Links EntityName() string } @@ -81,17 +81,17 @@ func (factory *BasicLinkFactory) SelfUrlString(id string) string { return "./" + path.Join(factory.entityName, id) } -func (factory *BasicLinkFactory) SelfLink(entity models.Entity) rest_model.Link { +func (factory *BasicLinkFactory) SelfLink(entity LinkEntity) rest_model.Link { return NewLink(factory.SelfUrlString(entity.GetId())) } -func (factory *BasicLinkFactory) Links(entity models.Entity) rest_model.Links { +func (factory *BasicLinkFactory) Links(entity LinkEntity) rest_model.Links { return rest_model.Links{ EntityNameSelf: factory.SelfLink(entity), } } -func (factory BasicLinkFactory) NewNestedLink(entity models.Entity, elem ...string) rest_model.Link { +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...)) @@ -101,7 +101,11 @@ func (factory *BasicLinkFactory) EntityName() string { return factory.entityName } -func ToEntityRef(name string, entity models.Entity, factory LinksFactory) *rest_model.EntityRef { +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(), diff --git a/controller/api_impl/base_router.go b/controller/api_impl/base_router.go index 53b7d4154..3b9fc2d96 100644 --- a/controller/api_impl/base_router.go +++ b/controller/api_impl/base_router.go @@ -225,6 +225,12 @@ 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) diff --git a/controller/api_impl/circuit_api_model.go b/controller/api_impl/circuit_api_model.go new file mode 100644 index 000000000..0684c2d9e --- /dev/null +++ b/controller/api_impl/circuit_api_model.go @@ -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 +} diff --git a/controller/api_impl/circuit_router.go b/controller/api_impl/circuit_router.go new file mode 100644 index 000000000..b12e9fc3e --- /dev/null +++ b/controller/api_impl/circuit_router.go @@ -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) + })) +} diff --git a/controller/api_impl/link_api_model.go b/controller/api_impl/link_api_model.go index 1ff665a44..54086ab4c 100644 --- a/controller/api_impl/link_api_model.go +++ b/controller/api_impl/link_api_model.go @@ -20,8 +20,6 @@ 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" ) const EntityNameLink = "links" @@ -38,7 +36,7 @@ func NewLinkLinkFactory() *LinkLinkFactoryIml { } } -func (factory *LinkLinkFactoryIml) Links(entity models.Entity) rest_model.Links { +func (factory *LinkLinkFactoryIml) Links(entity LinkEntity) rest_model.Links { links := factory.BasicLinkFactory.Links(entity) return links } diff --git a/controller/api_impl/router_api_model.go b/controller/api_impl/router_api_model.go index 21f98ed3e..2462c6da1 100644 --- a/controller/api_impl/router_api_model.go +++ b/controller/api_impl/router_api_model.go @@ -42,7 +42,7 @@ func NewRouterLinkFactory() *RouterLinkFactoryIml { } } -func (factory *RouterLinkFactoryIml) Links(entity models.Entity) rest_model.Links { +func (factory *RouterLinkFactoryIml) Links(entity LinkEntity) rest_model.Links { links := factory.BasicLinkFactory.Links(entity) links[EntityNameTerminator] = factory.NewNestedLink(entity, EntityNameTerminator) return links diff --git a/controller/api_impl/service_api_model.go b/controller/api_impl/service_api_model.go index 3d67e8b59..f55dae488 100644 --- a/controller/api_impl/service_api_model.go +++ b/controller/api_impl/service_api_model.go @@ -43,7 +43,7 @@ func NewServiceLinkFactory() *ServiceLinkFactoryIml { } } -func (factory *ServiceLinkFactoryIml) Links(entity models.Entity) rest_model.Links { +func (factory *ServiceLinkFactoryIml) Links(entity LinkEntity) rest_model.Links { links := factory.BasicLinkFactory.Links(entity) links[EntityNameTerminator] = factory.NewNestedLink(entity, EntityNameTerminator) return links diff --git a/controller/db/terminator_store.go b/controller/db/terminator_store.go index 1749298ca..262b6b9d5 100644 --- a/controller/db/terminator_store.go +++ b/controller/db/terminator_store.go @@ -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 } diff --git a/controller/network/link.go b/controller/network/link.go index 25d311f9d..77cf9c153 100644 --- a/controller/network/link.go +++ b/controller/network/link.go @@ -49,6 +49,10 @@ func newLink(id string) *Link { return l } +func (link *Link) GetId() string { + return link.Id +} + func (link *Link) CurrentState() *LinkState { link.lock.Lock() defer link.lock.Unlock() diff --git a/controller/network/util_test.go b/controller/network/util_test.go index 7ada5dab5..d470ac5f3 100644 --- a/controller/network/util_test.go +++ b/controller/network/util_test.go @@ -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) } } } diff --git a/controller/xt/xt.go b/controller/xt/xt.go index a93930e67..a0c2123dd 100644 --- a/controller/xt/xt.go +++ b/controller/xt/xt.go @@ -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 { diff --git a/rest_client/circuit/delete_circuit_parameters.go b/rest_client/circuit/delete_circuit_parameters.go index eee5e7090..65b5b6821 100644 --- a/rest_client/circuit/delete_circuit_parameters.go +++ b/rest_client/circuit/delete_circuit_parameters.go @@ -38,6 +38,8 @@ import ( "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, @@ -89,6 +91,12 @@ type DeleteCircuitParams struct { */ ID string + /* Options. + + A circuit delete object + */ + Options *rest_model.CircuitDelete + timeout time.Duration Context context.Context HTTPClient *http.Client @@ -153,6 +161,17 @@ 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 { @@ -165,6 +184,11 @@ func (o *DeleteCircuitParams) WriteToRequest(r runtime.ClientRequest, reg strfmt 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...) diff --git a/rest_model/circuit_delete.go b/rest_model/circuit_delete.go new file mode 100644 index 000000000..9b8bb8bf9 --- /dev/null +++ b/rest_model/circuit_delete.go @@ -0,0 +1,74 @@ +// 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 rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CircuitDelete circuit delete +// +// swagger:model circuitDelete +type CircuitDelete struct { + + // immediate + Immediate bool `json:"immediate,omitempty"` +} + +// Validate validates this circuit delete +func (m *CircuitDelete) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this circuit delete based on context it is used +func (m *CircuitDelete) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CircuitDelete) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CircuitDelete) UnmarshalBinary(b []byte) error { + var res CircuitDelete + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_model/circuit_detail.go b/rest_model/circuit_detail.go index 379760fc9..035fc5e5f 100644 --- a/rest_model/circuit_detail.go +++ b/rest_model/circuit_detail.go @@ -53,7 +53,7 @@ type CircuitDetail struct { // path // Required: true - Path []*EntityRef `json:"path"` + Path *CircuitDetailPath `json:"path"` // service // Required: true @@ -105,22 +105,15 @@ func (m *CircuitDetail) validatePath(formats strfmt.Registry) error { return err } - for i := 0; i < len(m.Path); i++ { - if swag.IsZero(m.Path[i]) { // not required - continue - } - - if m.Path[i] != nil { - if err := m.Path[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("path" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("path" + "." + strconv.Itoa(i)) - } - return err + if m.Path != nil { + if err := m.Path.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("path") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("path") } + return err } - } return nil @@ -190,19 +183,15 @@ func (m *CircuitDetail) ContextValidate(ctx context.Context, formats strfmt.Regi func (m *CircuitDetail) contextValidatePath(ctx context.Context, formats strfmt.Registry) error { - for i := 0; i < len(m.Path); i++ { - - if m.Path[i] != nil { - if err := m.Path[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("path" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("path" + "." + strconv.Itoa(i)) - } - return err + if m.Path != nil { + if err := m.Path.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("path") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("path") } + return err } - } return nil @@ -257,3 +246,161 @@ func (m *CircuitDetail) UnmarshalBinary(b []byte) error { *m = res return nil } + +// CircuitDetailPath circuit detail path +// +// swagger:model CircuitDetailPath +type CircuitDetailPath struct { + + // links + Links []*EntityRef `json:"links"` + + // nodes + Nodes []*EntityRef `json:"nodes"` +} + +// Validate validates this circuit detail path +func (m *CircuitDetailPath) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateLinks(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNodes(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CircuitDetailPath) validateLinks(formats strfmt.Registry) error { + if swag.IsZero(m.Links) { // not required + return nil + } + + for i := 0; i < len(m.Links); i++ { + if swag.IsZero(m.Links[i]) { // not required + continue + } + + if m.Links[i] != nil { + if err := m.Links[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("path" + "." + "links" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("path" + "." + "links" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CircuitDetailPath) validateNodes(formats strfmt.Registry) error { + if swag.IsZero(m.Nodes) { // not required + return nil + } + + for i := 0; i < len(m.Nodes); i++ { + if swag.IsZero(m.Nodes[i]) { // not required + continue + } + + if m.Nodes[i] != nil { + if err := m.Nodes[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("path" + "." + "nodes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("path" + "." + "nodes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this circuit detail path based on the context it is used +func (m *CircuitDetailPath) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateLinks(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateNodes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CircuitDetailPath) contextValidateLinks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Links); i++ { + + if m.Links[i] != nil { + if err := m.Links[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("path" + "." + "links" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("path" + "." + "links" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *CircuitDetailPath) contextValidateNodes(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Nodes); i++ { + + if m.Nodes[i] != nil { + if err := m.Nodes[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("path" + "." + "nodes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("path" + "." + "nodes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CircuitDetailPath) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CircuitDetailPath) UnmarshalBinary(b []byte) error { + var res CircuitDetailPath + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_server/embedded_spec.go b/rest_server/embedded_spec.go index dfeca3fd8..1576259b0 100644 --- a/rest_server/embedded_spec.go +++ b/rest_server/embedded_spec.go @@ -105,6 +105,16 @@ func init() { ], "summary": "Delete a circuit", "operationId": "deleteCircuit", + "parameters": [ + { + "description": "A circuit delete object", + "name": "options", + "in": "body", + "schema": { + "$ref": "#/definitions/circuitDelete" + } + } + ], "responses": { "200": { "$ref": "#/responses/deleteResponse" @@ -842,6 +852,14 @@ func init() { } } }, + "circuitDelete": { + "type": "object", + "properties": { + "immediate": { + "type": "boolean" + } + } + }, "circuitDetail": { "type": "object", "required": [ @@ -858,9 +876,20 @@ func init() { "type": "string" }, "path": { - "type": "array", - "items": { - "$ref": "#/definitions/entityRef" + "type": "object", + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/entityRef" + } + }, + "nodes": { + "type": "array", + "items": { + "$ref": "#/definitions/entityRef" + } + } } }, "service": { @@ -2014,6 +2043,16 @@ func init() { ], "summary": "Delete a circuit", "operationId": "deleteCircuit", + "parameters": [ + { + "description": "A circuit delete object", + "name": "options", + "in": "body", + "schema": { + "$ref": "#/definitions/circuitDelete" + } + } + ], "responses": { "200": { "description": "The delete request was successful and the resource has been removed", @@ -4035,6 +4074,23 @@ func init() { } }, "definitions": { + "CircuitDetailPath": { + "type": "object", + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/entityRef" + } + }, + "nodes": { + "type": "array", + "items": { + "$ref": "#/definitions/entityRef" + } + } + } + }, "apiError": { "type": "object", "properties": { @@ -4142,6 +4198,14 @@ func init() { } } }, + "circuitDelete": { + "type": "object", + "properties": { + "immediate": { + "type": "boolean" + } + } + }, "circuitDetail": { "type": "object", "required": [ @@ -4158,9 +4222,20 @@ func init() { "type": "string" }, "path": { - "type": "array", - "items": { - "$ref": "#/definitions/entityRef" + "type": "object", + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/entityRef" + } + }, + "nodes": { + "type": "array", + "items": { + "$ref": "#/definitions/entityRef" + } + } } }, "service": { diff --git a/rest_server/operations/circuit/delete_circuit_parameters.go b/rest_server/operations/circuit/delete_circuit_parameters.go index c0954d402..580c47a79 100644 --- a/rest_server/operations/circuit/delete_circuit_parameters.go +++ b/rest_server/operations/circuit/delete_circuit_parameters.go @@ -30,11 +30,16 @@ package circuit // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "net/http" "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/openziti/fabric/rest_model" ) // NewDeleteCircuitParams creates a new DeleteCircuitParams object @@ -59,6 +64,10 @@ type DeleteCircuitParams struct { In: path */ ID string + /*A circuit delete object + In: body + */ + Options *rest_model.CircuitDelete } // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface @@ -74,6 +83,28 @@ func (o *DeleteCircuitParams) BindRequest(r *http.Request, route *middleware.Mat if err := o.bindID(rID, rhkID, route.Formats); err != nil { res = append(res, err) } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body rest_model.CircuitDelete + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("options", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(context.Background()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Options = &body + } + } + } if len(res) > 0 { return errors.CompositeValidationError(res...) } diff --git a/specs/swagger.yml b/specs/swagger.yml index 34751c45b..157a35a61 100644 --- a/specs/swagger.yml +++ b/specs/swagger.yml @@ -514,6 +514,13 @@ paths: tags: - Circuit operationId: deleteCircuit + parameters: + - name: options + in: body + required: false + description: A circuit delete object + schema: + $ref: '#/definitions/circuitDelete' responses: '200': $ref: '#/responses/deleteResponse' @@ -1373,6 +1380,18 @@ definitions: terminator: $ref: '#/definitions/entityRef' path: - type: array - items: - $ref: '#/definitions/entityRef' + type: object + properties: + nodes: + type: array + items: + $ref: '#/definitions/entityRef' + links: + type: array + items: + $ref: '#/definitions/entityRef' + circuitDelete: + type: object + properties: + immediate: + type: boolean \ No newline at end of file From 00957fe8e6286b1f71f793127bc4313dcb3be36f Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Tue, 30 Nov 2021 14:26:07 -0500 Subject: [PATCH 6/7] Implement router update/patch --- controller/api_impl/router_router.go | 36 +-- controller/network/router.go | 25 +- rest_client/router/patch_router_parameters.go | 197 ++++++++++++ rest_client/router/patch_router_responses.go | 205 ++++++++++++ rest_client/router/router_client.go | 84 +++++ .../router/update_router_parameters.go | 197 ++++++++++++ rest_client/router/update_router_responses.go | 205 ++++++++++++ rest_server/configure_ziti_fabric.go | 10 + rest_server/embedded_spec.go | 294 ++++++++++++++++++ rest_server/operations/router/patch_router.go | 82 +++++ .../router/patch_router_parameters.go | 134 ++++++++ .../router/patch_router_responses.go | 214 +++++++++++++ .../router/patch_router_urlbuilder.go | 123 ++++++++ .../operations/router/update_router.go | 82 +++++ .../router/update_router_parameters.go | 134 ++++++++ .../router/update_router_responses.go | 214 +++++++++++++ .../router/update_router_urlbuilder.go | 123 ++++++++ rest_server/operations/ziti_fabric_api.go | 24 ++ specs/swagger.yml | 88 +++--- 19 files changed, 2408 insertions(+), 63 deletions(-) create mode 100644 rest_client/router/patch_router_parameters.go create mode 100644 rest_client/router/patch_router_responses.go create mode 100644 rest_client/router/update_router_parameters.go create mode 100644 rest_client/router/update_router_responses.go create mode 100644 rest_server/operations/router/patch_router.go create mode 100644 rest_server/operations/router/patch_router_parameters.go create mode 100644 rest_server/operations/router/patch_router_responses.go create mode 100644 rest_server/operations/router/patch_router_urlbuilder.go create mode 100644 rest_server/operations/router/update_router.go create mode 100644 rest_server/operations/router/update_router_parameters.go create mode 100644 rest_server/operations/router/update_router_responses.go create mode 100644 rest_server/operations/router/update_router_urlbuilder.go diff --git a/controller/api_impl/router_router.go b/controller/api_impl/router_router.go index 04aeedd9f..a25e87610 100644 --- a/controller/api_impl/router_router.go +++ b/controller/api_impl/router_router.go @@ -57,13 +57,13 @@ func (r *RouterRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper Req 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.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, "") @@ -93,17 +93,17 @@ 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) 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) diff --git a/controller/network/router.go b/controller/network/router.go index 190aa00e5..8092f461b 100644 --- a/controller/network/router.go +++ b/controller/network/router.go @@ -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 diff --git a/rest_client/router/patch_router_parameters.go b/rest_client/router/patch_router_parameters.go new file mode 100644 index 000000000..3348b4a49 --- /dev/null +++ b/rest_client/router/patch_router_parameters.go @@ -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 +} diff --git a/rest_client/router/patch_router_responses.go b/rest_client/router/patch_router_responses.go new file mode 100644 index 000000000..39ee3f351 --- /dev/null +++ b/rest_client/router/patch_router_responses.go @@ -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 +} diff --git a/rest_client/router/router_client.go b/rest_client/router/router_client.go index 2aa61d63d..572149882 100644 --- a/rest_client/router/router_client.go +++ b/rest_client/router/router_client.go @@ -64,6 +64,10 @@ type ClientService interface { 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) } @@ -269,6 +273,86 @@ func (a *Client) ListRouters(params *ListRoutersParams, opts ...ClientOption) (* 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 diff --git a/rest_client/router/update_router_parameters.go b/rest_client/router/update_router_parameters.go new file mode 100644 index 000000000..09b910ce1 --- /dev/null +++ b/rest_client/router/update_router_parameters.go @@ -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 +} diff --git a/rest_client/router/update_router_responses.go b/rest_client/router/update_router_responses.go new file mode 100644 index 000000000..0d14a2cb1 --- /dev/null +++ b/rest_client/router/update_router_responses.go @@ -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 +} diff --git a/rest_server/configure_ziti_fabric.go b/rest_server/configure_ziti_fabric.go index ca73ffd98..14256ebdb 100644 --- a/rest_server/configure_ziti_fabric.go +++ b/rest_server/configure_ziti_fabric.go @@ -166,6 +166,11 @@ func configureAPI(api *operations.ZitiFabricAPI) http.Handler { return middleware.NotImplemented("operation link.PatchLink has not yet been implemented") }) } + if api.RouterPatchRouterHandler == nil { + api.RouterPatchRouterHandler = router.PatchRouterHandlerFunc(func(params router.PatchRouterParams) middleware.Responder { + return middleware.NotImplemented("operation router.PatchRouter has not yet been implemented") + }) + } if api.ServicePatchServiceHandler == nil { api.ServicePatchServiceHandler = service.PatchServiceHandlerFunc(func(params service.PatchServiceParams) middleware.Responder { return middleware.NotImplemented("operation service.PatchService has not yet been implemented") @@ -176,6 +181,11 @@ func configureAPI(api *operations.ZitiFabricAPI) http.Handler { return middleware.NotImplemented("operation terminator.PatchTerminator has not yet been implemented") }) } + if api.RouterUpdateRouterHandler == nil { + api.RouterUpdateRouterHandler = router.UpdateRouterHandlerFunc(func(params router.UpdateRouterParams) middleware.Responder { + return middleware.NotImplemented("operation router.UpdateRouter has not yet been implemented") + }) + } if api.ServiceUpdateServiceHandler == nil { api.ServiceUpdateServiceHandler = service.UpdateServiceHandlerFunc(func(params service.UpdateServiceParams) middleware.Responder { return middleware.NotImplemented("operation service.UpdateService has not yet been implemented") diff --git a/rest_server/embedded_spec.go b/rest_server/embedded_spec.go index 1576259b0..4b64905e5 100644 --- a/rest_server/embedded_spec.go +++ b/rest_server/embedded_spec.go @@ -292,6 +292,39 @@ func init() { } } }, + "put": { + "description": "Update all fields on a router by id. Requires admin access.", + "tags": [ + "Router" + ], + "summary": "Update all fields on a router", + "operationId": "updateRouter", + "parameters": [ + { + "description": "A router update object", + "name": "router", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/routerUpdate" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/updateResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "404": { + "$ref": "#/responses/notFoundResponse" + } + } + }, "delete": { "description": "Delete a router by id. Requires admin access.", "tags": [ @@ -314,6 +347,39 @@ func init() { } } }, + "patch": { + "description": "Update the supplied fields on a router. Requires admin access.", + "tags": [ + "Router" + ], + "summary": "Update the supplied fields on a router", + "operationId": "patchRouter", + "parameters": [ + { + "description": "A router patch object", + "name": "router", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/routerPatch" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/patchResponse" + }, + "400": { + "$ref": "#/responses/badRequestResponse" + }, + "401": { + "$ref": "#/responses/unauthorizedResponse" + }, + "404": { + "$ref": "#/responses/notFoundResponse" + } + } + }, "parameters": [ { "$ref": "#/parameters/id" @@ -2605,6 +2671,120 @@ func init() { } } }, + "put": { + "description": "Update all fields on a router by id. Requires admin access.", + "tags": [ + "Router" + ], + "summary": "Update all fields on a router", + "operationId": "updateRouter", + "parameters": [ + { + "description": "A router update object", + "name": "router", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/routerUpdate" + } + } + ], + "responses": { + "200": { + "description": "The update request was successful and the resource has been altered", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "404": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, "delete": { "description": "Delete a router by id. Requires admin access.", "tags": [ @@ -2707,6 +2887,120 @@ func init() { } } }, + "patch": { + "description": "Update the supplied fields on a router. Requires admin access.", + "tags": [ + "Router" + ], + "summary": "Update the supplied fields on a router", + "operationId": "patchRouter", + "parameters": [ + { + "description": "A router patch object", + "name": "router", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/routerPatch" + } + } + ], + "responses": { + "200": { + "description": "The patch request was successful and the resource has been altered", + "schema": { + "$ref": "#/definitions/empty" + } + }, + "400": { + "description": "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", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": { + "details": { + "context": "(root)", + "field": "(root)", + "property": "fooField3" + }, + "field": "(root)", + "message": "(root): fooField3 is required", + "type": "required", + "value": { + "fooField": "abc", + "fooField2": "def" + } + }, + "causeMessage": "schema validation failed", + "code": "COULD_NOT_VALIDATE", + "message": "The supplied request contains an invalid document", + "requestId": "ac6766d6-3a09-44b3-8d8a-1b541d97fdd9" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + }, + "404": { + "description": "The requested resource does not exist", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": { + "id": "71a3000f-7dda-491a-9b90-a19f4ee6c406" + } + }, + "cause": null, + "causeMessage": "", + "code": "NOT_FOUND", + "message": "The resource requested was not found or is no longer available", + "requestId": "270908d6-f2ef-4577-b973-67bec18ae376" + }, + "meta": { + "apiEnrollmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } + } + } + }, "parameters": [ { "type": "string", diff --git a/rest_server/operations/router/patch_router.go b/rest_server/operations/router/patch_router.go new file mode 100644 index 000000000..b0ea1ad3b --- /dev/null +++ b/rest_server/operations/router/patch_router.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PatchRouterHandlerFunc turns a function with the right signature into a patch router handler +type PatchRouterHandlerFunc func(PatchRouterParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PatchRouterHandlerFunc) Handle(params PatchRouterParams) middleware.Responder { + return fn(params) +} + +// PatchRouterHandler interface for that can handle valid patch router params +type PatchRouterHandler interface { + Handle(PatchRouterParams) middleware.Responder +} + +// NewPatchRouter creates a new http.Handler for the patch router operation +func NewPatchRouter(ctx *middleware.Context, handler PatchRouterHandler) *PatchRouter { + return &PatchRouter{Context: ctx, Handler: handler} +} + +/* PatchRouter swagger:route PATCH /routers/{id} Router patchRouter + +Update the supplied fields on a router + +Update the supplied fields on a router. Requires admin access. + +*/ +type PatchRouter struct { + Context *middleware.Context + Handler PatchRouterHandler +} + +func (o *PatchRouter) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPatchRouterParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/router/patch_router_parameters.go b/rest_server/operations/router/patch_router_parameters.go new file mode 100644 index 000000000..bd145d5da --- /dev/null +++ b/rest_server/operations/router/patch_router_parameters.go @@ -0,0 +1,134 @@ +// 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" + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/openziti/fabric/rest_model" +) + +// NewPatchRouterParams creates a new PatchRouterParams object +// +// There are no default values defined in the spec. +func NewPatchRouterParams() PatchRouterParams { + + return PatchRouterParams{} +} + +// PatchRouterParams contains all the bound params for the patch router operation +// typically these are obtained from a http.Request +// +// swagger:parameters patchRouter +type PatchRouterParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string + /*A router patch object + Required: true + In: body + */ + Router *rest_model.RouterPatch +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPatchRouterParams() beforehand. +func (o *PatchRouterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body rest_model.RouterPatch + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("router", "body", "")) + } else { + res = append(res, errors.NewParseError("router", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(context.Background()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Router = &body + } + } + } else { + res = append(res, errors.Required("router", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *PatchRouterParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/router/patch_router_responses.go b/rest_server/operations/router/patch_router_responses.go new file mode 100644 index 000000000..a45c38b8a --- /dev/null +++ b/rest_server/operations/router/patch_router_responses.go @@ -0,0 +1,214 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// PatchRouterOKCode is the HTTP code returned for type PatchRouterOK +const PatchRouterOKCode int = 200 + +/*PatchRouterOK The patch request was successful and the resource has been altered + +swagger:response patchRouterOK +*/ +type PatchRouterOK struct { + + /* + In: Body + */ + Payload *rest_model.Empty `json:"body,omitempty"` +} + +// NewPatchRouterOK creates PatchRouterOK with default headers values +func NewPatchRouterOK() *PatchRouterOK { + + return &PatchRouterOK{} +} + +// WithPayload adds the payload to the patch router o k response +func (o *PatchRouterOK) WithPayload(payload *rest_model.Empty) *PatchRouterOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch router o k response +func (o *PatchRouterOK) SetPayload(payload *rest_model.Empty) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchRouterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PatchRouterBadRequestCode is the HTTP code returned for type PatchRouterBadRequest +const PatchRouterBadRequestCode int = 400 + +/*PatchRouterBadRequest 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 + +swagger:response patchRouterBadRequest +*/ +type PatchRouterBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewPatchRouterBadRequest creates PatchRouterBadRequest with default headers values +func NewPatchRouterBadRequest() *PatchRouterBadRequest { + + return &PatchRouterBadRequest{} +} + +// WithPayload adds the payload to the patch router bad request response +func (o *PatchRouterBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *PatchRouterBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch router bad request response +func (o *PatchRouterBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchRouterBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PatchRouterUnauthorizedCode is the HTTP code returned for type PatchRouterUnauthorized +const PatchRouterUnauthorizedCode int = 401 + +/*PatchRouterUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response patchRouterUnauthorized +*/ +type PatchRouterUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewPatchRouterUnauthorized creates PatchRouterUnauthorized with default headers values +func NewPatchRouterUnauthorized() *PatchRouterUnauthorized { + + return &PatchRouterUnauthorized{} +} + +// WithPayload adds the payload to the patch router unauthorized response +func (o *PatchRouterUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *PatchRouterUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch router unauthorized response +func (o *PatchRouterUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchRouterUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PatchRouterNotFoundCode is the HTTP code returned for type PatchRouterNotFound +const PatchRouterNotFoundCode int = 404 + +/*PatchRouterNotFound The requested resource does not exist + +swagger:response patchRouterNotFound +*/ +type PatchRouterNotFound struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewPatchRouterNotFound creates PatchRouterNotFound with default headers values +func NewPatchRouterNotFound() *PatchRouterNotFound { + + return &PatchRouterNotFound{} +} + +// WithPayload adds the payload to the patch router not found response +func (o *PatchRouterNotFound) WithPayload(payload *rest_model.APIErrorEnvelope) *PatchRouterNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch router not found response +func (o *PatchRouterNotFound) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchRouterNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/router/patch_router_urlbuilder.go b/rest_server/operations/router/patch_router_urlbuilder.go new file mode 100644 index 000000000..dfdae10a1 --- /dev/null +++ b/rest_server/operations/router/patch_router_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// PatchRouterURL generates an URL for the patch router operation +type PatchRouterURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PatchRouterURL) WithBasePath(bp string) *PatchRouterURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PatchRouterURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PatchRouterURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/routers/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on PatchRouterURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PatchRouterURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PatchRouterURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PatchRouterURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PatchRouterURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PatchRouterURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PatchRouterURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/router/update_router.go b/rest_server/operations/router/update_router.go new file mode 100644 index 000000000..f0d2b346d --- /dev/null +++ b/rest_server/operations/router/update_router.go @@ -0,0 +1,82 @@ +// 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 generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// UpdateRouterHandlerFunc turns a function with the right signature into a update router handler +type UpdateRouterHandlerFunc func(UpdateRouterParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn UpdateRouterHandlerFunc) Handle(params UpdateRouterParams) middleware.Responder { + return fn(params) +} + +// UpdateRouterHandler interface for that can handle valid update router params +type UpdateRouterHandler interface { + Handle(UpdateRouterParams) middleware.Responder +} + +// NewUpdateRouter creates a new http.Handler for the update router operation +func NewUpdateRouter(ctx *middleware.Context, handler UpdateRouterHandler) *UpdateRouter { + return &UpdateRouter{Context: ctx, Handler: handler} +} + +/* UpdateRouter swagger:route PUT /routers/{id} Router updateRouter + +Update all fields on a router + +Update all fields on a router by id. Requires admin access. + +*/ +type UpdateRouter struct { + Context *middleware.Context + Handler UpdateRouterHandler +} + +func (o *UpdateRouter) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewUpdateRouterParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server/operations/router/update_router_parameters.go b/rest_server/operations/router/update_router_parameters.go new file mode 100644 index 000000000..8101a82fb --- /dev/null +++ b/rest_server/operations/router/update_router_parameters.go @@ -0,0 +1,134 @@ +// 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" + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/openziti/fabric/rest_model" +) + +// NewUpdateRouterParams creates a new UpdateRouterParams object +// +// There are no default values defined in the spec. +func NewUpdateRouterParams() UpdateRouterParams { + + return UpdateRouterParams{} +} + +// UpdateRouterParams contains all the bound params for the update router operation +// typically these are obtained from a http.Request +// +// swagger:parameters updateRouter +type UpdateRouterParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The id of the requested resource + Required: true + In: path + */ + ID string + /*A router update object + Required: true + In: body + */ + Router *rest_model.RouterUpdate +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewUpdateRouterParams() beforehand. +func (o *UpdateRouterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body rest_model.RouterUpdate + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("router", "body", "")) + } else { + res = append(res, errors.NewParseError("router", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(context.Background()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Router = &body + } + } + } else { + res = append(res, errors.Required("router", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *UpdateRouterParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/rest_server/operations/router/update_router_responses.go b/rest_server/operations/router/update_router_responses.go new file mode 100644 index 000000000..5cf1c6fe3 --- /dev/null +++ b/rest_server/operations/router/update_router_responses.go @@ -0,0 +1,214 @@ +// 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 ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/openziti/fabric/rest_model" +) + +// UpdateRouterOKCode is the HTTP code returned for type UpdateRouterOK +const UpdateRouterOKCode int = 200 + +/*UpdateRouterOK The update request was successful and the resource has been altered + +swagger:response updateRouterOK +*/ +type UpdateRouterOK struct { + + /* + In: Body + */ + Payload *rest_model.Empty `json:"body,omitempty"` +} + +// NewUpdateRouterOK creates UpdateRouterOK with default headers values +func NewUpdateRouterOK() *UpdateRouterOK { + + return &UpdateRouterOK{} +} + +// WithPayload adds the payload to the update router o k response +func (o *UpdateRouterOK) WithPayload(payload *rest_model.Empty) *UpdateRouterOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update router o k response +func (o *UpdateRouterOK) SetPayload(payload *rest_model.Empty) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRouterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRouterBadRequestCode is the HTTP code returned for type UpdateRouterBadRequest +const UpdateRouterBadRequestCode int = 400 + +/*UpdateRouterBadRequest 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 + +swagger:response updateRouterBadRequest +*/ +type UpdateRouterBadRequest struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewUpdateRouterBadRequest creates UpdateRouterBadRequest with default headers values +func NewUpdateRouterBadRequest() *UpdateRouterBadRequest { + + return &UpdateRouterBadRequest{} +} + +// WithPayload adds the payload to the update router bad request response +func (o *UpdateRouterBadRequest) WithPayload(payload *rest_model.APIErrorEnvelope) *UpdateRouterBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update router bad request response +func (o *UpdateRouterBadRequest) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRouterBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRouterUnauthorizedCode is the HTTP code returned for type UpdateRouterUnauthorized +const UpdateRouterUnauthorizedCode int = 401 + +/*UpdateRouterUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response updateRouterUnauthorized +*/ +type UpdateRouterUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewUpdateRouterUnauthorized creates UpdateRouterUnauthorized with default headers values +func NewUpdateRouterUnauthorized() *UpdateRouterUnauthorized { + + return &UpdateRouterUnauthorized{} +} + +// WithPayload adds the payload to the update router unauthorized response +func (o *UpdateRouterUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *UpdateRouterUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update router unauthorized response +func (o *UpdateRouterUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRouterUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// UpdateRouterNotFoundCode is the HTTP code returned for type UpdateRouterNotFound +const UpdateRouterNotFoundCode int = 404 + +/*UpdateRouterNotFound The requested resource does not exist + +swagger:response updateRouterNotFound +*/ +type UpdateRouterNotFound struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewUpdateRouterNotFound creates UpdateRouterNotFound with default headers values +func NewUpdateRouterNotFound() *UpdateRouterNotFound { + + return &UpdateRouterNotFound{} +} + +// WithPayload adds the payload to the update router not found response +func (o *UpdateRouterNotFound) WithPayload(payload *rest_model.APIErrorEnvelope) *UpdateRouterNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the update router not found response +func (o *UpdateRouterNotFound) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UpdateRouterNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_server/operations/router/update_router_urlbuilder.go b/rest_server/operations/router/update_router_urlbuilder.go new file mode 100644 index 000000000..d7043d7f6 --- /dev/null +++ b/rest_server/operations/router/update_router_urlbuilder.go @@ -0,0 +1,123 @@ +// 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 generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// UpdateRouterURL generates an URL for the update router operation +type UpdateRouterURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateRouterURL) WithBasePath(bp string) *UpdateRouterURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *UpdateRouterURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *UpdateRouterURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/routers/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on UpdateRouterURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/fabric/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *UpdateRouterURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *UpdateRouterURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *UpdateRouterURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on UpdateRouterURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on UpdateRouterURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *UpdateRouterURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server/operations/ziti_fabric_api.go b/rest_server/operations/ziti_fabric_api.go index 4ae5bddf2..91317b802 100644 --- a/rest_server/operations/ziti_fabric_api.go +++ b/rest_server/operations/ziti_fabric_api.go @@ -132,12 +132,18 @@ func NewZitiFabricAPI(spec *loads.Document) *ZitiFabricAPI { LinkPatchLinkHandler: link.PatchLinkHandlerFunc(func(params link.PatchLinkParams) middleware.Responder { return middleware.NotImplemented("operation link.PatchLink has not yet been implemented") }), + RouterPatchRouterHandler: router.PatchRouterHandlerFunc(func(params router.PatchRouterParams) middleware.Responder { + return middleware.NotImplemented("operation router.PatchRouter has not yet been implemented") + }), ServicePatchServiceHandler: service.PatchServiceHandlerFunc(func(params service.PatchServiceParams) middleware.Responder { return middleware.NotImplemented("operation service.PatchService has not yet been implemented") }), TerminatorPatchTerminatorHandler: terminator.PatchTerminatorHandlerFunc(func(params terminator.PatchTerminatorParams) middleware.Responder { return middleware.NotImplemented("operation terminator.PatchTerminator has not yet been implemented") }), + RouterUpdateRouterHandler: router.UpdateRouterHandlerFunc(func(params router.UpdateRouterParams) middleware.Responder { + return middleware.NotImplemented("operation router.UpdateRouter has not yet been implemented") + }), ServiceUpdateServiceHandler: service.UpdateServiceHandlerFunc(func(params service.UpdateServiceParams) middleware.Responder { return middleware.NotImplemented("operation service.UpdateService has not yet been implemented") }), @@ -220,10 +226,14 @@ type ZitiFabricAPI struct { TerminatorListTerminatorsHandler terminator.ListTerminatorsHandler // LinkPatchLinkHandler sets the operation handler for the patch link operation LinkPatchLinkHandler link.PatchLinkHandler + // RouterPatchRouterHandler sets the operation handler for the patch router operation + RouterPatchRouterHandler router.PatchRouterHandler // ServicePatchServiceHandler sets the operation handler for the patch service operation ServicePatchServiceHandler service.PatchServiceHandler // TerminatorPatchTerminatorHandler sets the operation handler for the patch terminator operation TerminatorPatchTerminatorHandler terminator.PatchTerminatorHandler + // RouterUpdateRouterHandler sets the operation handler for the update router operation + RouterUpdateRouterHandler router.UpdateRouterHandler // ServiceUpdateServiceHandler sets the operation handler for the update service operation ServiceUpdateServiceHandler service.UpdateServiceHandler // TerminatorUpdateTerminatorHandler sets the operation handler for the update terminator operation @@ -365,12 +375,18 @@ func (o *ZitiFabricAPI) Validate() error { if o.LinkPatchLinkHandler == nil { unregistered = append(unregistered, "link.PatchLinkHandler") } + if o.RouterPatchRouterHandler == nil { + unregistered = append(unregistered, "router.PatchRouterHandler") + } if o.ServicePatchServiceHandler == nil { unregistered = append(unregistered, "service.PatchServiceHandler") } if o.TerminatorPatchTerminatorHandler == nil { unregistered = append(unregistered, "terminator.PatchTerminatorHandler") } + if o.RouterUpdateRouterHandler == nil { + unregistered = append(unregistered, "router.UpdateRouterHandler") + } if o.ServiceUpdateServiceHandler == nil { unregistered = append(unregistered, "service.UpdateServiceHandler") } @@ -548,6 +564,10 @@ func (o *ZitiFabricAPI) initHandlerCache() { if o.handlers["PATCH"] == nil { o.handlers["PATCH"] = make(map[string]http.Handler) } + o.handlers["PATCH"]["/routers/{id}"] = router.NewPatchRouter(o.context, o.RouterPatchRouterHandler) + if o.handlers["PATCH"] == nil { + o.handlers["PATCH"] = make(map[string]http.Handler) + } o.handlers["PATCH"]["/services/{id}"] = service.NewPatchService(o.context, o.ServicePatchServiceHandler) if o.handlers["PATCH"] == nil { o.handlers["PATCH"] = make(map[string]http.Handler) @@ -556,6 +576,10 @@ func (o *ZitiFabricAPI) initHandlerCache() { if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } + o.handlers["PUT"]["/routers/{id}"] = router.NewUpdateRouter(o.context, o.RouterUpdateRouterHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } o.handlers["PUT"]["/services/{id}"] = service.NewUpdateService(o.context, o.ServiceUpdateServiceHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) diff --git a/specs/swagger.yml b/specs/swagger.yml index 157a35a61..dd8c73adb 100644 --- a/specs/swagger.yml +++ b/specs/swagger.yml @@ -213,50 +213,50 @@ paths: $ref: '#/responses/notFoundResponse' '401': $ref: '#/responses/unauthorizedResponse' - # put: - # summary: Update all fields on a router - # description: Update all fields on a router by id. Requires admin access. - # tags: - # - Router - # operationId: updateRouter - # parameters: - # - name: router - # in: body - # required: true - # description: A router update object - # schema: - # $ref: '#/definitions/routerUpdate' - # responses: - # '200': - # $ref: '#/responses/updateResponse' - # '400': - # $ref: '#/responses/badRequestResponse' - # '404': - # $ref: '#/responses/notFoundResponse' - # '401': - # $ref: '#/responses/unauthorizedResponse' - # patch: - # summary: Update the supplied fields on a router - # description: Update the supplied fields on a router. Requires admin access. - # tags: - # - Router - # operationId: patchRouter - # parameters: - # - name: router - # in: body - # required: true - # description: A router patch object - # schema: - # $ref: '#/definitions/routerPatch' - # responses: - # '200': - # $ref: '#/responses/patchResponse' - # '400': - # $ref: '#/responses/badRequestResponse' - # '404': - # $ref: '#/responses/notFoundResponse' - # '401': - # $ref: '#/responses/unauthorizedResponse' + put: + summary: Update all fields on a router + description: Update all fields on a router by id. Requires admin access. + tags: + - Router + operationId: updateRouter + parameters: + - name: router + in: body + required: true + description: A router update object + schema: + $ref: '#/definitions/routerUpdate' + responses: + '200': + $ref: '#/responses/updateResponse' + '400': + $ref: '#/responses/badRequestResponse' + '404': + $ref: '#/responses/notFoundResponse' + '401': + $ref: '#/responses/unauthorizedResponse' + patch: + summary: Update the supplied fields on a router + description: Update the supplied fields on a router. Requires admin access. + tags: + - Router + operationId: patchRouter + parameters: + - name: router + in: body + required: true + description: A router patch object + schema: + $ref: '#/definitions/routerPatch' + responses: + '200': + $ref: '#/responses/patchResponse' + '400': + $ref: '#/responses/badRequestResponse' + '404': + $ref: '#/responses/notFoundResponse' + '401': + $ref: '#/responses/unauthorizedResponse' delete: summary: Delete a router description: Delete a router by id. Requires admin access. From d63b5b407174f42e7d9ccbe09a577ea69f65e745 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Tue, 30 Nov 2021 14:31:34 -0500 Subject: [PATCH 7/7] Update link/circuit doc --- rest_client/circuit/circuit_client.go | 2 +- rest_client/link/link_client.go | 2 +- rest_server/embedded_spec.go | 8 ++++---- rest_server/operations/circuit/list_circuits.go | 2 +- rest_server/operations/link/list_links.go | 2 +- specs/swagger.yml | 12 ++---------- 6 files changed, 10 insertions(+), 18 deletions(-) diff --git a/rest_client/circuit/circuit_client.go b/rest_client/circuit/circuit_client.go index 60596e53c..2dd0d2f84 100644 --- a/rest_client/circuit/circuit_client.go +++ b/rest_client/circuit/circuit_client.go @@ -146,7 +146,7 @@ func (a *Client) DetailCircuit(params *DetailCircuitParams, opts ...ClientOption /* ListCircuits lists circuits - Retrieves a list of circuit resources; doesn not supports filtering, sorting, or pagination. Requires admin access. + 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) { diff --git a/rest_client/link/link_client.go b/rest_client/link/link_client.go index 8e2807420..132198e31 100644 --- a/rest_client/link/link_client.go +++ b/rest_client/link/link_client.go @@ -106,7 +106,7 @@ func (a *Client) DetailLink(params *DetailLinkParams, opts ...ClientOption) (*De /* ListLinks lists links - Retrieves a list of link resources; doesn not supports filtering, sorting, or pagination. Requires admin access. + 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) { diff --git a/rest_server/embedded_spec.go b/rest_server/embedded_spec.go index 4b64905e5..a029f4ce1 100644 --- a/rest_server/embedded_spec.go +++ b/rest_server/embedded_spec.go @@ -62,7 +62,7 @@ func init() { "paths": { "/circuits": { "get": { - "description": "Retrieves a list of circuit resources; doesn not supports filtering, sorting, or pagination. Requires admin access.\n", + "description": "Retrieves a list of circuit resources; does not supports filtering, sorting, or pagination. Requires admin access.\n", "tags": [ "Circuit" ], @@ -138,7 +138,7 @@ func init() { }, "/links": { "get": { - "description": "Retrieves a list of link resources; doesn not supports filtering, sorting, or pagination. Requires admin access.\n", + "description": "Retrieves a list of link resources; does not supports filtering, sorting, or pagination. Requires admin access.\n", "tags": [ "Link" ], @@ -1995,7 +1995,7 @@ func init() { "paths": { "/circuits": { "get": { - "description": "Retrieves a list of circuit resources; doesn not supports filtering, sorting, or pagination. Requires admin access.\n", + "description": "Retrieves a list of circuit resources; does not supports filtering, sorting, or pagination. Requires admin access.\n", "tags": [ "Circuit" ], @@ -2226,7 +2226,7 @@ func init() { }, "/links": { "get": { - "description": "Retrieves a list of link resources; doesn not supports filtering, sorting, or pagination. Requires admin access.\n", + "description": "Retrieves a list of link resources; does not supports filtering, sorting, or pagination. Requires admin access.\n", "tags": [ "Link" ], diff --git a/rest_server/operations/circuit/list_circuits.go b/rest_server/operations/circuit/list_circuits.go index 34e8b1fb2..b0b45f982 100644 --- a/rest_server/operations/circuit/list_circuits.go +++ b/rest_server/operations/circuit/list_circuits.go @@ -57,7 +57,7 @@ func NewListCircuits(ctx *middleware.Context, handler ListCircuitsHandler) *List List circuits -Retrieves a list of circuit resources; doesn not supports filtering, sorting, or pagination. Requires admin access. +Retrieves a list of circuit resources; does not supports filtering, sorting, or pagination. Requires admin access. */ diff --git a/rest_server/operations/link/list_links.go b/rest_server/operations/link/list_links.go index ce0a3b51a..88c51ff49 100644 --- a/rest_server/operations/link/list_links.go +++ b/rest_server/operations/link/list_links.go @@ -57,7 +57,7 @@ func NewListLinks(ctx *middleware.Context, handler ListLinksHandler) *ListLinks List links -Retrieves a list of link resources; doesn not supports filtering, sorting, or pagination. Requires admin access. +Retrieves a list of link resources; does not supports filtering, sorting, or pagination. Requires admin access. */ diff --git a/specs/swagger.yml b/specs/swagger.yml index dd8c73adb..03ab59764 100644 --- a/specs/swagger.yml +++ b/specs/swagger.yml @@ -420,14 +420,10 @@ paths: get: summary: List links description: | - Retrieves a list of link resources; doesn not supports filtering, sorting, or pagination. Requires admin access. + Retrieves a list of link resources; does not supports filtering, sorting, or pagination. Requires admin access. tags: - Link operationId: listLinks - # parameters: - # - $ref: '#/parameters/limit' - # - $ref: '#/parameters/offset' - # - $ref: '#/parameters/filter' responses: '200': $ref: '#/responses/listLinks' @@ -479,14 +475,10 @@ paths: get: summary: List circuits description: | - Retrieves a list of circuit resources; doesn not supports filtering, sorting, or pagination. Requires admin access. + Retrieves a list of circuit resources; does not supports filtering, sorting, or pagination. Requires admin access. tags: - Circuit operationId: listCircuits - # parameters: - # - $ref: '#/parameters/limit' - # - $ref: '#/parameters/offset' - # - $ref: '#/parameters/filter' responses: '200': $ref: '#/responses/listCircuits'