From 11068394b83b0fb5884f66f342a5ca5b7c99d576 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Fri, 18 Nov 2022 15:36:55 -0500 Subject: [PATCH] tunnel -> service; tunnel.Tunnel -> service.Share; tunnel.Untunnel -> service.Unshare (#102) --- cmd/zrok/http_backend.go | 14 +- cmd/zrok/loop.go | 14 +- controller/controller.go | 4 +- controller/{tunnel.go => share.go} | 54 ++-- controller/{untunnel.go => unshare.go} | 46 +-- .../service_client.go} | 42 +-- rest_client_zrok/service/share_parameters.go | 150 ++++++++++ rest_client_zrok/service/share_responses.go | 222 +++++++++++++++ .../service/unshare_parameters.go | 150 ++++++++++ rest_client_zrok/service/unshare_responses.go | 267 ++++++++++++++++++ rest_client_zrok/tunnel/tunnel_parameters.go | 150 ---------- rest_client_zrok/tunnel/tunnel_responses.go | 232 --------------- .../tunnel/untunnel_parameters.go | 150 ---------- rest_client_zrok/tunnel/untunnel_responses.go | 220 --------------- rest_client_zrok/zrok_client.go | 8 +- .../{tunnel_request.go => share_request.go} | 24 +- .../{tunnel_response.go => share_response.go} | 20 +- ...untunnel_request.go => unshare_request.go} | 20 +- rest_server_zrok/embedded_spec.go | 82 +++--- .../{tunnel/tunnel.go => service/share.go} | 32 +-- .../share_parameters.go} | 22 +- .../operations/service/share_responses.go | 127 +++++++++ .../share_urlbuilder.go} | 26 +- .../untunnel.go => service/unshare.go} | 32 +-- .../unshare_parameters.go} | 22 +- .../operations/service/unshare_responses.go | 132 +++++++++ .../unshare_urlbuilder.go} | 26 +- .../operations/tunnel/tunnel_responses.go | 145 ---------- .../operations/tunnel/untunnel_responses.go | 125 -------- rest_server_zrok/operations/zrok_api.go | 30 +- specs/zrok.yml | 38 ++- ui/src/api/{tunnel.js => service.js} | 26 +- ui/src/api/types.js | 6 +- 33 files changed, 1338 insertions(+), 1320 deletions(-) rename controller/{tunnel.go => share.go} (79%) rename controller/{untunnel.go => unshare.go} (70%) rename rest_client_zrok/{tunnel/tunnel_client.go => service/service_client.go} (64%) create mode 100644 rest_client_zrok/service/share_parameters.go create mode 100644 rest_client_zrok/service/share_responses.go create mode 100644 rest_client_zrok/service/unshare_parameters.go create mode 100644 rest_client_zrok/service/unshare_responses.go delete mode 100644 rest_client_zrok/tunnel/tunnel_parameters.go delete mode 100644 rest_client_zrok/tunnel/tunnel_responses.go delete mode 100644 rest_client_zrok/tunnel/untunnel_parameters.go delete mode 100644 rest_client_zrok/tunnel/untunnel_responses.go rename rest_model_zrok/{tunnel_request.go => share_request.go} (75%) rename rest_model_zrok/{tunnel_response.go => share_response.go} (57%) rename rest_model_zrok/{untunnel_request.go => unshare_request.go} (55%) rename rest_server_zrok/operations/{tunnel/tunnel.go => service/share.go} (56%) rename rest_server_zrok/operations/{tunnel/tunnel_parameters.go => service/share_parameters.go} (76%) create mode 100644 rest_server_zrok/operations/service/share_responses.go rename rest_server_zrok/operations/{tunnel/tunnel_urlbuilder.go => service/share_urlbuilder.go} (70%) rename rest_server_zrok/operations/{tunnel/untunnel.go => service/unshare.go} (55%) rename rest_server_zrok/operations/{tunnel/untunnel_parameters.go => service/unshare_parameters.go} (75%) create mode 100644 rest_server_zrok/operations/service/unshare_responses.go rename rest_server_zrok/operations/{tunnel/untunnel_urlbuilder.go => service/unshare_urlbuilder.go} (72%) delete mode 100644 rest_server_zrok/operations/tunnel/tunnel_responses.go delete mode 100644 rest_server_zrok/operations/tunnel/untunnel_responses.go rename ui/src/api/{tunnel.js => service.js} (54%) diff --git a/cmd/zrok/http_backend.go b/cmd/zrok/http_backend.go index e613b814..af4cb9d8 100644 --- a/cmd/zrok/http_backend.go +++ b/cmd/zrok/http_backend.go @@ -10,7 +10,7 @@ import ( "github.com/openziti-test-kitchen/zrok/endpoints/backend" "github.com/openziti-test-kitchen/zrok/model" "github.com/openziti-test-kitchen/zrok/rest_client_zrok" - "github.com/openziti-test-kitchen/zrok/rest_client_zrok/tunnel" + "github.com/openziti-test-kitchen/zrok/rest_client_zrok/service" "github.com/openziti-test-kitchen/zrok/rest_model_zrok" "github.com/openziti-test-kitchen/zrok/zrokdir" "github.com/pkg/errors" @@ -101,8 +101,8 @@ func (self *httpBackendCommand) run(_ *cobra.Command, args []string) { panic(err) } auth := httptransport.APIKeyAuth("X-TOKEN", "header", env.Token) - req := tunnel.NewTunnelParams() - req.Body = &rest_model_zrok.TunnelRequest{ + req := service.NewShareParams() + req.Body = &rest_model_zrok.ShareRequest{ ZID: env.ZId, Endpoint: cfg.EndpointAddress, AuthScheme: string(model.None), @@ -119,7 +119,7 @@ func (self *httpBackendCommand) run(_ *cobra.Command, args []string) { } } } - resp, err := zrok.Tunnel.Tunnel(req, auth) + resp, err := zrok.Service.Share(req, auth) if err != nil { ui.Close() if !panicInstead { @@ -225,12 +225,12 @@ func (self *httpBackendCommand) run(_ *cobra.Command, args []string) { func (self *httpBackendCommand) destroy(id string, cfg *backend.Config, zrok *rest_client_zrok.Zrok, auth runtime.ClientAuthInfoWriter) { logrus.Debugf("shutting down '%v'", cfg.Service) - req := tunnel.NewUntunnelParams() - req.Body = &rest_model_zrok.UntunnelRequest{ + req := service.NewUnshareParams() + req.Body = &rest_model_zrok.UnshareRequest{ ZID: id, SvcName: cfg.Service, } - if _, err := zrok.Tunnel.Untunnel(req, auth); err == nil { + if _, err := zrok.Service.Unshare(req, auth); err == nil { logrus.Debugf("shutdown complete") } else { logrus.Errorf("error shutting down: %v", err) diff --git a/cmd/zrok/loop.go b/cmd/zrok/loop.go index 36b1d06e..c843ae5a 100644 --- a/cmd/zrok/loop.go +++ b/cmd/zrok/loop.go @@ -8,7 +8,7 @@ import ( httptransport "github.com/go-openapi/runtime/client" "github.com/openziti-test-kitchen/zrok/model" "github.com/openziti-test-kitchen/zrok/rest_client_zrok" - "github.com/openziti-test-kitchen/zrok/rest_client_zrok/tunnel" + "github.com/openziti-test-kitchen/zrok/rest_client_zrok/service" "github.com/openziti-test-kitchen/zrok/rest_model_zrok" "github.com/openziti-test-kitchen/zrok/util" "github.com/openziti-test-kitchen/zrok/zrokdir" @@ -182,14 +182,14 @@ func (l *looper) startup() { panic(err) } l.auth = httptransport.APIKeyAuth("x-token", "header", l.env.Token) - tunnelReq := tunnel.NewTunnelParams() - tunnelReq.Body = &rest_model_zrok.TunnelRequest{ + tunnelReq := service.NewShareParams() + tunnelReq.Body = &rest_model_zrok.ShareRequest{ ZID: l.env.ZId, Endpoint: fmt.Sprintf("looper#%d", l.id), AuthScheme: string(model.None), } tunnelReq.SetTimeout(60 * time.Second) - tunnelResp, err := l.zrok.Tunnel.Tunnel(tunnelReq, l.auth) + tunnelResp, err := l.zrok.Service.Share(tunnelReq, l.auth) if err != nil { panic(err) } @@ -255,12 +255,12 @@ func (l *looper) shutdown() { } } - untunnelReq := tunnel.NewUntunnelParams() - untunnelReq.Body = &rest_model_zrok.UntunnelRequest{ + untunnelReq := service.NewUnshareParams() + untunnelReq.Body = &rest_model_zrok.UnshareRequest{ ZID: l.env.ZId, SvcName: l.service, } - if _, err := l.zrok.Tunnel.Untunnel(untunnelReq, l.auth); err != nil { + if _, err := l.zrok.Service.Unshare(untunnelReq, l.auth); err != nil { logrus.Errorf("error shutting down looper #%d: %v", l.id, err) } } diff --git a/controller/controller.go b/controller/controller.go index 77c16b96..5b8de49b 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -34,8 +34,8 @@ func Run(inCfg *Config) error { api.IdentityVerifyHandler = newVerifyHandler() api.MetadataOverviewHandler = metadata.OverviewHandlerFunc(overviewHandler) api.MetadataVersionHandler = metadata.VersionHandlerFunc(versionHandler) - api.TunnelTunnelHandler = newTunnelHandler() - api.TunnelUntunnelHandler = newUntunnelHandler() + api.ServiceShareHandler = newShareHandler() + api.ServiceUnshareHandler = newUnshareHandler() if err := controllerStartup(); err != nil { return err diff --git a/controller/tunnel.go b/controller/share.go similarity index 79% rename from controller/tunnel.go rename to controller/share.go index cd9dfd30..fe28530b 100644 --- a/controller/tunnel.go +++ b/controller/share.go @@ -8,10 +8,10 @@ import ( "github.com/openziti-test-kitchen/zrok/controller/store" "github.com/openziti-test-kitchen/zrok/model" "github.com/openziti-test-kitchen/zrok/rest_model_zrok" - "github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/tunnel" + "github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/service" "github.com/openziti/edge/rest_management_api_client" "github.com/openziti/edge/rest_management_api_client/config" - "github.com/openziti/edge/rest_management_api_client/service" + edge_service "github.com/openziti/edge/rest_management_api_client/service" "github.com/openziti/edge/rest_management_api_client/service_edge_router_policy" "github.com/openziti/edge/rest_management_api_client/service_policy" "github.com/openziti/edge/rest_model" @@ -20,18 +20,18 @@ import ( "time" ) -type tunnelHandler struct { +type shareHandler struct { } -func newTunnelHandler() *tunnelHandler { - return &tunnelHandler{} +func newShareHandler() *shareHandler { + return &shareHandler{} } -func (h *tunnelHandler) Handle(params tunnel.TunnelParams, principal *rest_model_zrok.Principal) middleware.Responder { +func (h *shareHandler) Handle(params service.ShareParams, principal *rest_model_zrok.Principal) middleware.Responder { tx, err := str.Begin() if err != nil { logrus.Errorf("error starting transaction: %v", err) - return tunnel.NewTunnelInternalServerError() + return service.NewShareInternalServerError() } defer func() { _ = tx.Rollback() }() @@ -49,44 +49,44 @@ func (h *tunnelHandler) Handle(params tunnel.TunnelParams, principal *rest_model } if !found { logrus.Errorf("environment '%v' not found for user '%v'", envZId, principal.Email) - return tunnel.NewTunnelUnauthorized().WithPayload("bad environment identity") + return service.NewShareUnauthorized() } } else { logrus.Errorf("error finding environments for account '%v'", principal.Email) - return tunnel.NewTunnelInternalServerError() + return service.NewShareInternalServerError() } edge, err := edgeClient() if err != nil { logrus.Error(err) - return tunnel.NewTunnelInternalServerError() + return service.NewShareInternalServerError() } svcName, err := createServiceName() if err != nil { logrus.Error(err) - return tunnel.NewTunnelInternalServerError() + return service.NewShareInternalServerError() } cfgId, err := h.createConfig(envZId, svcName, params, edge) if err != nil { logrus.Error(err) - return tunnel.NewTunnelInternalServerError() + return service.NewShareInternalServerError() } svcZId, err := h.createService(envZId, svcName, cfgId, edge) if err != nil { logrus.Error(err) - return tunnel.NewTunnelInternalServerError() + return service.NewShareInternalServerError() } if err := h.createServicePolicyBind(envZId, svcName, svcZId, envZId, edge); err != nil { logrus.Error(err) - return tunnel.NewTunnelInternalServerError() + return service.NewShareInternalServerError() } if err := h.createServicePolicyDial(envZId, svcName, svcZId, edge); err != nil { logrus.Error(err) - return tunnel.NewTunnelInternalServerError() + return service.NewShareInternalServerError() } if err := h.createServiceEdgeRouterPolicy(envZId, svcName, svcZId, edge); err != nil { logrus.Error(err) - return tunnel.NewTunnelInternalServerError() + return service.NewShareInternalServerError() } logrus.Debugf("allocated service '%v'", svcName) @@ -101,21 +101,21 @@ func (h *tunnelHandler) Handle(params tunnel.TunnelParams, principal *rest_model if err != nil { logrus.Errorf("error creating service record: %v", err) _ = tx.Rollback() - return tunnel.NewUntunnelInternalServerError() + return service.NewShareInternalServerError() } if err := tx.Commit(); err != nil { logrus.Errorf("error committing service record: %v", err) - return tunnel.NewTunnelInternalServerError() + return service.NewShareInternalServerError() } logrus.Infof("recorded service '%v' with id '%v' for '%v'", svcName, sid, principal.Email) - return tunnel.NewTunnelCreated().WithPayload(&rest_model_zrok.TunnelResponse{ + return service.NewShareCreated().WithPayload(&rest_model_zrok.ShareResponse{ ProxyEndpoint: frontendUrl, SvcName: svcName, }) } -func (h *tunnelHandler) createConfig(envZId, svcName string, params tunnel.TunnelParams, edge *rest_management_api_client.ZitiEdgeManagement) (cfgID string, err error) { +func (h *shareHandler) createConfig(envZId, svcName string, params service.ShareParams, edge *rest_management_api_client.ZitiEdgeManagement) (cfgID string, err error) { authScheme, err := model.ParseAuthScheme(params.Body.AuthScheme) if err != nil { return "", err @@ -148,7 +148,7 @@ func (h *tunnelHandler) createConfig(envZId, svcName string, params tunnel.Tunne return cfgResp.Payload.Data.ID, nil } -func (h *tunnelHandler) createService(envZId, svcName, cfgId string, edge *rest_management_api_client.ZitiEdgeManagement) (serviceId string, err error) { +func (h *shareHandler) createService(envZId, svcName, cfgId string, edge *rest_management_api_client.ZitiEdgeManagement) (serviceId string, err error) { configs := []string{cfgId} encryptionRequired := true svc := &rest_model.ServiceCreate{ @@ -157,7 +157,7 @@ func (h *tunnelHandler) createService(envZId, svcName, cfgId string, edge *rest_ Name: &svcName, Tags: h.zrokTags(svcName), } - req := &service.CreateServiceParams{ + req := &edge_service.CreateServiceParams{ Service: svc, Context: context.Background(), } @@ -170,7 +170,7 @@ func (h *tunnelHandler) createService(envZId, svcName, cfgId string, edge *rest_ return resp.Payload.Data.ID, nil } -func (h *tunnelHandler) createServicePolicyBind(envZId, svcName, svcZId, envId string, edge *rest_management_api_client.ZitiEdgeManagement) error { +func (h *shareHandler) createServicePolicyBind(envZId, svcName, svcZId, envId string, edge *rest_management_api_client.ZitiEdgeManagement) error { semantic := rest_model.SemanticAllOf identityRoles := []string{fmt.Sprintf("@%v", envId)} name := fmt.Sprintf("%v-backend", svcName) @@ -199,7 +199,7 @@ func (h *tunnelHandler) createServicePolicyBind(envZId, svcName, svcZId, envId s return nil } -func (h *tunnelHandler) createServicePolicyDial(envZId, svcName, svcZId string, edge *rest_management_api_client.ZitiEdgeManagement) error { +func (h *shareHandler) createServicePolicyDial(envZId, svcName, svcZId string, edge *rest_management_api_client.ZitiEdgeManagement) error { var identityRoles []string for _, proxyIdentity := range cfg.Proxy.Identities { identityRoles = append(identityRoles, "@"+proxyIdentity) @@ -232,7 +232,7 @@ func (h *tunnelHandler) createServicePolicyDial(envZId, svcName, svcZId string, return nil } -func (h *tunnelHandler) createServiceEdgeRouterPolicy(envZId, svcName, svcZId string, edge *rest_management_api_client.ZitiEdgeManagement) error { +func (h *shareHandler) createServiceEdgeRouterPolicy(envZId, svcName, svcZId string, edge *rest_management_api_client.ZitiEdgeManagement) error { edgeRouterRoles := []string{"#all"} semantic := rest_model.SemanticAllOf serviceRoles := []string{fmt.Sprintf("@%v", svcZId)} @@ -256,11 +256,11 @@ func (h *tunnelHandler) createServiceEdgeRouterPolicy(envZId, svcName, svcZId st return nil } -func (h *tunnelHandler) proxyUrl(svcName string) string { +func (h *shareHandler) proxyUrl(svcName string) string { return strings.Replace(cfg.Proxy.UrlTemplate, "{svcName}", svcName, -1) } -func (h *tunnelHandler) zrokTags(svcName string) *rest_model.Tags { +func (h *shareHandler) zrokTags(svcName string) *rest_model.Tags { return &rest_model.Tags{ SubTags: map[string]interface{}{ "zrok": build.String(), diff --git a/controller/untunnel.go b/controller/unshare.go similarity index 70% rename from controller/untunnel.go rename to controller/unshare.go index d8fee2ec..1712d98b 100644 --- a/controller/untunnel.go +++ b/controller/unshare.go @@ -6,39 +6,39 @@ import ( "github.com/go-openapi/runtime/middleware" "github.com/openziti-test-kitchen/zrok/controller/store" "github.com/openziti-test-kitchen/zrok/rest_model_zrok" - "github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/tunnel" + "github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/service" "github.com/openziti/edge/rest_management_api_client" - "github.com/openziti/edge/rest_management_api_client/service" + edge_service "github.com/openziti/edge/rest_management_api_client/service" "github.com/pkg/errors" "github.com/sirupsen/logrus" "time" ) -type untunnelHandler struct { +type unshareHandler struct { } -func newUntunnelHandler() *untunnelHandler { - return &untunnelHandler{} +func newUnshareHandler() *unshareHandler { + return &unshareHandler{} } -func (h *untunnelHandler) Handle(params tunnel.UntunnelParams, principal *rest_model_zrok.Principal) middleware.Responder { +func (h *unshareHandler) Handle(params service.UnshareParams, principal *rest_model_zrok.Principal) middleware.Responder { tx, err := str.Begin() if err != nil { logrus.Errorf("error starting transaction: %v", err) - return tunnel.NewUntunnelInternalServerError() + return service.NewUnshareInternalServerError() } defer func() { _ = tx.Rollback() }() edge, err := edgeClient() if err != nil { logrus.Error(err) - return tunnel.NewUntunnelInternalServerError() + return service.NewUnshareInternalServerError() } svcName := params.Body.SvcName svcZId, err := h.findServiceZId(svcName, edge) if err != nil { logrus.Error(err) - return tunnel.NewUntunnelInternalServerError() + return service.NewUnshareInternalServerError() } var senv *store.Environment if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil { @@ -51,11 +51,11 @@ func (h *untunnelHandler) Handle(params tunnel.UntunnelParams, principal *rest_m if senv == nil { err := errors.Errorf("environment with id '%v' not found for '%v", params.Body.ZID, principal.Email) logrus.Error(err) - return tunnel.NewUntunnelNotFound() + return service.NewUnshareNotFound() } } else { logrus.Errorf("error finding environments for account '%v': %v", principal.Email, err) - return tunnel.NewUntunnelInternalServerError() + return service.NewUnshareInternalServerError() } var ssvc *store.Service @@ -69,53 +69,53 @@ func (h *untunnelHandler) Handle(params tunnel.UntunnelParams, principal *rest_m if ssvc == nil { err := errors.Errorf("service with id '%v' not found for '%v'", svcZId, principal.Email) logrus.Error(err) - return tunnel.NewUntunnelNotFound() + return service.NewUnshareNotFound() } } else { logrus.Errorf("error finding services for account '%v': %v", principal.Email, err) - return tunnel.NewUntunnelInternalServerError() + return service.NewUnshareInternalServerError() } if err := deleteServiceEdgeRouterPolicy(senv.ZId, svcName, edge); err != nil { logrus.Error(err) - return tunnel.NewUntunnelInternalServerError() + return service.NewUnshareInternalServerError() } if err := deleteServicePolicyDial(senv.ZId, svcName, edge); err != nil { logrus.Error(err) - return tunnel.NewUntunnelInternalServerError() + return service.NewUnshareInternalServerError() } if err := deleteServicePolicyBind(senv.ZId, svcName, edge); err != nil { logrus.Error(err) - return tunnel.NewUntunnelInternalServerError() + return service.NewUnshareInternalServerError() } if err := deleteConfig(senv.ZId, svcName, edge); err != nil { logrus.Error(err) - return tunnel.NewTunnelInternalServerError() + return service.NewUnshareInternalServerError() } if err := deleteService(senv.ZId, svcZId, edge); err != nil { logrus.Error(err) - return tunnel.NewUntunnelInternalServerError() + return service.NewUnshareInternalServerError() } logrus.Debugf("deallocated service '%v'", svcName) if err := str.DeleteService(ssvc.Id, tx); err != nil { logrus.Errorf("error deactivating service '%v': %v", svcZId, err) - return tunnel.NewUntunnelInternalServerError() + return service.NewUnshareInternalServerError() } if err := tx.Commit(); err != nil { logrus.Errorf("error committing: %v", err) - return tunnel.NewUntunnelInternalServerError() + return service.NewUnshareInternalServerError() } - return tunnel.NewUntunnelOK() + return service.NewUnshareOK() } -func (h *untunnelHandler) findServiceZId(svcName string, edge *rest_management_api_client.ZitiEdgeManagement) (string, error) { +func (h *unshareHandler) findServiceZId(svcName string, edge *rest_management_api_client.ZitiEdgeManagement) (string, error) { filter := fmt.Sprintf("name=\"%v\"", svcName) limit := int64(1) offset := int64(0) - listReq := &service.ListServicesParams{ + listReq := &edge_service.ListServicesParams{ Filter: &filter, Limit: &limit, Offset: &offset, diff --git a/rest_client_zrok/tunnel/tunnel_client.go b/rest_client_zrok/service/service_client.go similarity index 64% rename from rest_client_zrok/tunnel/tunnel_client.go rename to rest_client_zrok/service/service_client.go index 680262db..2fb894d2 100644 --- a/rest_client_zrok/tunnel/tunnel_client.go +++ b/rest_client_zrok/service/service_client.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package tunnel +package service // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command @@ -12,13 +12,13 @@ import ( "github.com/go-openapi/strfmt" ) -// New creates a new tunnel API client. +// New creates a new service API client. func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } /* -Client for tunnel API +Client for service API */ type Client struct { transport runtime.ClientTransport @@ -30,30 +30,30 @@ type ClientOption func(*runtime.ClientOperation) // ClientService is the interface for Client methods type ClientService interface { - Tunnel(params *TunnelParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*TunnelCreated, error) + Share(params *ShareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ShareCreated, error) - Untunnel(params *UntunnelParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UntunnelOK, error) + Unshare(params *UnshareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnshareOK, error) SetTransport(transport runtime.ClientTransport) } /* -Tunnel tunnel API +Share share API */ -func (a *Client) Tunnel(params *TunnelParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*TunnelCreated, error) { +func (a *Client) Share(params *ShareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ShareCreated, error) { // TODO: Validate the params before sending if params == nil { - params = NewTunnelParams() + params = NewShareParams() } op := &runtime.ClientOperation{ - ID: "tunnel", + ID: "share", Method: "POST", - PathPattern: "/tunnel", + PathPattern: "/share", ProducesMediaTypes: []string{"application/zrok.v1+json"}, ConsumesMediaTypes: []string{"application/zrok.v1+json"}, Schemes: []string{"http"}, Params: params, - Reader: &TunnelReader{formats: a.formats}, + Reader: &ShareReader{formats: a.formats}, AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, @@ -66,33 +66,33 @@ func (a *Client) Tunnel(params *TunnelParams, authInfo runtime.ClientAuthInfoWri if err != nil { return nil, err } - success, ok := result.(*TunnelCreated) + success, ok := result.(*ShareCreated) 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 tunnel: API contract not enforced by server. Client expected to get an error, but got: %T", result) + msg := fmt.Sprintf("unexpected success response for share: API contract not enforced by server. Client expected to get an error, but got: %T", result) panic(msg) } /* -Untunnel untunnel API +Unshare unshare API */ -func (a *Client) Untunnel(params *UntunnelParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UntunnelOK, error) { +func (a *Client) Unshare(params *UnshareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnshareOK, error) { // TODO: Validate the params before sending if params == nil { - params = NewUntunnelParams() + params = NewUnshareParams() } op := &runtime.ClientOperation{ - ID: "untunnel", + ID: "unshare", Method: "DELETE", - PathPattern: "/untunnel", + PathPattern: "/unshare", ProducesMediaTypes: []string{"application/zrok.v1+json"}, ConsumesMediaTypes: []string{"application/zrok.v1+json"}, Schemes: []string{"http"}, Params: params, - Reader: &UntunnelReader{formats: a.formats}, + Reader: &UnshareReader{formats: a.formats}, AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, @@ -105,13 +105,13 @@ func (a *Client) Untunnel(params *UntunnelParams, authInfo runtime.ClientAuthInf if err != nil { return nil, err } - success, ok := result.(*UntunnelOK) + success, ok := result.(*UnshareOK) 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 untunnel: API contract not enforced by server. Client expected to get an error, but got: %T", result) + msg := fmt.Sprintf("unexpected success response for unshare: API contract not enforced by server. Client expected to get an error, but got: %T", result) panic(msg) } diff --git a/rest_client_zrok/service/share_parameters.go b/rest_client_zrok/service/share_parameters.go new file mode 100644 index 00000000..fd9ab5cf --- /dev/null +++ b/rest_client_zrok/service/share_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +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-test-kitchen/zrok/rest_model_zrok" +) + +// NewShareParams creates a new ShareParams 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 NewShareParams() *ShareParams { + return &ShareParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewShareParamsWithTimeout creates a new ShareParams object +// with the ability to set a timeout on a request. +func NewShareParamsWithTimeout(timeout time.Duration) *ShareParams { + return &ShareParams{ + timeout: timeout, + } +} + +// NewShareParamsWithContext creates a new ShareParams object +// with the ability to set a context for a request. +func NewShareParamsWithContext(ctx context.Context) *ShareParams { + return &ShareParams{ + Context: ctx, + } +} + +// NewShareParamsWithHTTPClient creates a new ShareParams object +// with the ability to set a custom HTTPClient for a request. +func NewShareParamsWithHTTPClient(client *http.Client) *ShareParams { + return &ShareParams{ + HTTPClient: client, + } +} + +/* +ShareParams contains all the parameters to send to the API endpoint + + for the share operation. + + Typically these are written to a http.Request. +*/ +type ShareParams struct { + + // Body. + Body *rest_model_zrok.ShareRequest + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the share params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ShareParams) WithDefaults() *ShareParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the share params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ShareParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the share params +func (o *ShareParams) WithTimeout(timeout time.Duration) *ShareParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the share params +func (o *ShareParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the share params +func (o *ShareParams) WithContext(ctx context.Context) *ShareParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the share params +func (o *ShareParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the share params +func (o *ShareParams) WithHTTPClient(client *http.Client) *ShareParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the share params +func (o *ShareParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the share params +func (o *ShareParams) WithBody(body *rest_model_zrok.ShareRequest) *ShareParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the share params +func (o *ShareParams) SetBody(body *rest_model_zrok.ShareRequest) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *ShareParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client_zrok/service/share_responses.go b/rest_client_zrok/service/share_responses.go new file mode 100644 index 00000000..8aee1416 --- /dev/null +++ b/rest_client_zrok/service/share_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +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-test-kitchen/zrok/rest_model_zrok" +) + +// ShareReader is a Reader for the Share structure. +type ShareReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ShareReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 201: + result := NewShareCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewShareUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewShareInternalServerError() + 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()) + } +} + +// NewShareCreated creates a ShareCreated with default headers values +func NewShareCreated() *ShareCreated { + return &ShareCreated{} +} + +/* +ShareCreated describes a response with status code 201, with default header values. + +service created +*/ +type ShareCreated struct { + Payload *rest_model_zrok.ShareResponse +} + +// IsSuccess returns true when this share created response has a 2xx status code +func (o *ShareCreated) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this share created response has a 3xx status code +func (o *ShareCreated) IsRedirect() bool { + return false +} + +// IsClientError returns true when this share created response has a 4xx status code +func (o *ShareCreated) IsClientError() bool { + return false +} + +// IsServerError returns true when this share created response has a 5xx status code +func (o *ShareCreated) IsServerError() bool { + return false +} + +// IsCode returns true when this share created response a status code equal to that given +func (o *ShareCreated) IsCode(code int) bool { + return code == 201 +} + +func (o *ShareCreated) Error() string { + return fmt.Sprintf("[POST /share][%d] shareCreated %+v", 201, o.Payload) +} + +func (o *ShareCreated) String() string { + return fmt.Sprintf("[POST /share][%d] shareCreated %+v", 201, o.Payload) +} + +func (o *ShareCreated) GetPayload() *rest_model_zrok.ShareResponse { + return o.Payload +} + +func (o *ShareCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(rest_model_zrok.ShareResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewShareUnauthorized creates a ShareUnauthorized with default headers values +func NewShareUnauthorized() *ShareUnauthorized { + return &ShareUnauthorized{} +} + +/* +ShareUnauthorized describes a response with status code 401, with default header values. + +unauthorized +*/ +type ShareUnauthorized struct { +} + +// IsSuccess returns true when this share unauthorized response has a 2xx status code +func (o *ShareUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this share unauthorized response has a 3xx status code +func (o *ShareUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this share unauthorized response has a 4xx status code +func (o *ShareUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this share unauthorized response has a 5xx status code +func (o *ShareUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this share unauthorized response a status code equal to that given +func (o *ShareUnauthorized) IsCode(code int) bool { + return code == 401 +} + +func (o *ShareUnauthorized) Error() string { + return fmt.Sprintf("[POST /share][%d] shareUnauthorized ", 401) +} + +func (o *ShareUnauthorized) String() string { + return fmt.Sprintf("[POST /share][%d] shareUnauthorized ", 401) +} + +func (o *ShareUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewShareInternalServerError creates a ShareInternalServerError with default headers values +func NewShareInternalServerError() *ShareInternalServerError { + return &ShareInternalServerError{} +} + +/* +ShareInternalServerError describes a response with status code 500, with default header values. + +internal server error +*/ +type ShareInternalServerError struct { + Payload rest_model_zrok.ErrorMessage +} + +// IsSuccess returns true when this share internal server error response has a 2xx status code +func (o *ShareInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this share internal server error response has a 3xx status code +func (o *ShareInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this share internal server error response has a 4xx status code +func (o *ShareInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this share internal server error response has a 5xx status code +func (o *ShareInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this share internal server error response a status code equal to that given +func (o *ShareInternalServerError) IsCode(code int) bool { + return code == 500 +} + +func (o *ShareInternalServerError) Error() string { + return fmt.Sprintf("[POST /share][%d] shareInternalServerError %+v", 500, o.Payload) +} + +func (o *ShareInternalServerError) String() string { + return fmt.Sprintf("[POST /share][%d] shareInternalServerError %+v", 500, o.Payload) +} + +func (o *ShareInternalServerError) GetPayload() rest_model_zrok.ErrorMessage { + return o.Payload +} + +func (o *ShareInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/rest_client_zrok/service/unshare_parameters.go b/rest_client_zrok/service/unshare_parameters.go new file mode 100644 index 00000000..1857604a --- /dev/null +++ b/rest_client_zrok/service/unshare_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +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-test-kitchen/zrok/rest_model_zrok" +) + +// NewUnshareParams creates a new UnshareParams 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 NewUnshareParams() *UnshareParams { + return &UnshareParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewUnshareParamsWithTimeout creates a new UnshareParams object +// with the ability to set a timeout on a request. +func NewUnshareParamsWithTimeout(timeout time.Duration) *UnshareParams { + return &UnshareParams{ + timeout: timeout, + } +} + +// NewUnshareParamsWithContext creates a new UnshareParams object +// with the ability to set a context for a request. +func NewUnshareParamsWithContext(ctx context.Context) *UnshareParams { + return &UnshareParams{ + Context: ctx, + } +} + +// NewUnshareParamsWithHTTPClient creates a new UnshareParams object +// with the ability to set a custom HTTPClient for a request. +func NewUnshareParamsWithHTTPClient(client *http.Client) *UnshareParams { + return &UnshareParams{ + HTTPClient: client, + } +} + +/* +UnshareParams contains all the parameters to send to the API endpoint + + for the unshare operation. + + Typically these are written to a http.Request. +*/ +type UnshareParams struct { + + // Body. + Body *rest_model_zrok.UnshareRequest + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the unshare params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UnshareParams) WithDefaults() *UnshareParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the unshare params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UnshareParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the unshare params +func (o *UnshareParams) WithTimeout(timeout time.Duration) *UnshareParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the unshare params +func (o *UnshareParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the unshare params +func (o *UnshareParams) WithContext(ctx context.Context) *UnshareParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the unshare params +func (o *UnshareParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the unshare params +func (o *UnshareParams) WithHTTPClient(client *http.Client) *UnshareParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the unshare params +func (o *UnshareParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the unshare params +func (o *UnshareParams) WithBody(body *rest_model_zrok.UnshareRequest) *UnshareParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the unshare params +func (o *UnshareParams) SetBody(body *rest_model_zrok.UnshareRequest) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *UnshareParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client_zrok/service/unshare_responses.go b/rest_client_zrok/service/unshare_responses.go new file mode 100644 index 00000000..36bdac47 --- /dev/null +++ b/rest_client_zrok/service/unshare_responses.go @@ -0,0 +1,267 @@ +// Code generated by go-swagger; DO NOT EDIT. + +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-test-kitchen/zrok/rest_model_zrok" +) + +// UnshareReader is a Reader for the Unshare structure. +type UnshareReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UnshareReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewUnshareOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewUnshareUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewUnshareNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewUnshareInternalServerError() + 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()) + } +} + +// NewUnshareOK creates a UnshareOK with default headers values +func NewUnshareOK() *UnshareOK { + return &UnshareOK{} +} + +/* +UnshareOK describes a response with status code 200, with default header values. + +service removed +*/ +type UnshareOK struct { +} + +// IsSuccess returns true when this unshare o k response has a 2xx status code +func (o *UnshareOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this unshare o k response has a 3xx status code +func (o *UnshareOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this unshare o k response has a 4xx status code +func (o *UnshareOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this unshare o k response has a 5xx status code +func (o *UnshareOK) IsServerError() bool { + return false +} + +// IsCode returns true when this unshare o k response a status code equal to that given +func (o *UnshareOK) IsCode(code int) bool { + return code == 200 +} + +func (o *UnshareOK) Error() string { + return fmt.Sprintf("[DELETE /unshare][%d] unshareOK ", 200) +} + +func (o *UnshareOK) String() string { + return fmt.Sprintf("[DELETE /unshare][%d] unshareOK ", 200) +} + +func (o *UnshareOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUnshareUnauthorized creates a UnshareUnauthorized with default headers values +func NewUnshareUnauthorized() *UnshareUnauthorized { + return &UnshareUnauthorized{} +} + +/* +UnshareUnauthorized describes a response with status code 401, with default header values. + +unauthorized +*/ +type UnshareUnauthorized struct { +} + +// IsSuccess returns true when this unshare unauthorized response has a 2xx status code +func (o *UnshareUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this unshare unauthorized response has a 3xx status code +func (o *UnshareUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this unshare unauthorized response has a 4xx status code +func (o *UnshareUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this unshare unauthorized response has a 5xx status code +func (o *UnshareUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this unshare unauthorized response a status code equal to that given +func (o *UnshareUnauthorized) IsCode(code int) bool { + return code == 401 +} + +func (o *UnshareUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /unshare][%d] unshareUnauthorized ", 401) +} + +func (o *UnshareUnauthorized) String() string { + return fmt.Sprintf("[DELETE /unshare][%d] unshareUnauthorized ", 401) +} + +func (o *UnshareUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUnshareNotFound creates a UnshareNotFound with default headers values +func NewUnshareNotFound() *UnshareNotFound { + return &UnshareNotFound{} +} + +/* +UnshareNotFound describes a response with status code 404, with default header values. + +not found +*/ +type UnshareNotFound struct { +} + +// IsSuccess returns true when this unshare not found response has a 2xx status code +func (o *UnshareNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this unshare not found response has a 3xx status code +func (o *UnshareNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this unshare not found response has a 4xx status code +func (o *UnshareNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this unshare not found response has a 5xx status code +func (o *UnshareNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this unshare not found response a status code equal to that given +func (o *UnshareNotFound) IsCode(code int) bool { + return code == 404 +} + +func (o *UnshareNotFound) Error() string { + return fmt.Sprintf("[DELETE /unshare][%d] unshareNotFound ", 404) +} + +func (o *UnshareNotFound) String() string { + return fmt.Sprintf("[DELETE /unshare][%d] unshareNotFound ", 404) +} + +func (o *UnshareNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUnshareInternalServerError creates a UnshareInternalServerError with default headers values +func NewUnshareInternalServerError() *UnshareInternalServerError { + return &UnshareInternalServerError{} +} + +/* +UnshareInternalServerError describes a response with status code 500, with default header values. + +internal server error +*/ +type UnshareInternalServerError struct { + Payload rest_model_zrok.ErrorMessage +} + +// IsSuccess returns true when this unshare internal server error response has a 2xx status code +func (o *UnshareInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this unshare internal server error response has a 3xx status code +func (o *UnshareInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this unshare internal server error response has a 4xx status code +func (o *UnshareInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this unshare internal server error response has a 5xx status code +func (o *UnshareInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this unshare internal server error response a status code equal to that given +func (o *UnshareInternalServerError) IsCode(code int) bool { + return code == 500 +} + +func (o *UnshareInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /unshare][%d] unshareInternalServerError %+v", 500, o.Payload) +} + +func (o *UnshareInternalServerError) String() string { + return fmt.Sprintf("[DELETE /unshare][%d] unshareInternalServerError %+v", 500, o.Payload) +} + +func (o *UnshareInternalServerError) GetPayload() rest_model_zrok.ErrorMessage { + return o.Payload +} + +func (o *UnshareInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/rest_client_zrok/tunnel/tunnel_parameters.go b/rest_client_zrok/tunnel/tunnel_parameters.go deleted file mode 100644 index 7e2c34e7..00000000 --- a/rest_client_zrok/tunnel/tunnel_parameters.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package tunnel - -// 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-test-kitchen/zrok/rest_model_zrok" -) - -// NewTunnelParams creates a new TunnelParams 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 NewTunnelParams() *TunnelParams { - return &TunnelParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewTunnelParamsWithTimeout creates a new TunnelParams object -// with the ability to set a timeout on a request. -func NewTunnelParamsWithTimeout(timeout time.Duration) *TunnelParams { - return &TunnelParams{ - timeout: timeout, - } -} - -// NewTunnelParamsWithContext creates a new TunnelParams object -// with the ability to set a context for a request. -func NewTunnelParamsWithContext(ctx context.Context) *TunnelParams { - return &TunnelParams{ - Context: ctx, - } -} - -// NewTunnelParamsWithHTTPClient creates a new TunnelParams object -// with the ability to set a custom HTTPClient for a request. -func NewTunnelParamsWithHTTPClient(client *http.Client) *TunnelParams { - return &TunnelParams{ - HTTPClient: client, - } -} - -/* -TunnelParams contains all the parameters to send to the API endpoint - - for the tunnel operation. - - Typically these are written to a http.Request. -*/ -type TunnelParams struct { - - // Body. - Body *rest_model_zrok.TunnelRequest - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the tunnel params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *TunnelParams) WithDefaults() *TunnelParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the tunnel params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *TunnelParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the tunnel params -func (o *TunnelParams) WithTimeout(timeout time.Duration) *TunnelParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the tunnel params -func (o *TunnelParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the tunnel params -func (o *TunnelParams) WithContext(ctx context.Context) *TunnelParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the tunnel params -func (o *TunnelParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the tunnel params -func (o *TunnelParams) WithHTTPClient(client *http.Client) *TunnelParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the tunnel params -func (o *TunnelParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithBody adds the body to the tunnel params -func (o *TunnelParams) WithBody(body *rest_model_zrok.TunnelRequest) *TunnelParams { - o.SetBody(body) - return o -} - -// SetBody adds the body to the tunnel params -func (o *TunnelParams) SetBody(body *rest_model_zrok.TunnelRequest) { - o.Body = body -} - -// WriteToRequest writes these params to a swagger request -func (o *TunnelParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - if o.Body != nil { - if err := r.SetBodyParam(o.Body); err != nil { - return err - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/rest_client_zrok/tunnel/tunnel_responses.go b/rest_client_zrok/tunnel/tunnel_responses.go deleted file mode 100644 index 22123f03..00000000 --- a/rest_client_zrok/tunnel/tunnel_responses.go +++ /dev/null @@ -1,232 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package tunnel - -// 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-test-kitchen/zrok/rest_model_zrok" -) - -// TunnelReader is a Reader for the Tunnel structure. -type TunnelReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *TunnelReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 201: - result := NewTunnelCreated() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 401: - result := NewTunnelUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewTunnelInternalServerError() - 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()) - } -} - -// NewTunnelCreated creates a TunnelCreated with default headers values -func NewTunnelCreated() *TunnelCreated { - return &TunnelCreated{} -} - -/* -TunnelCreated describes a response with status code 201, with default header values. - -tunnel created -*/ -type TunnelCreated struct { - Payload *rest_model_zrok.TunnelResponse -} - -// IsSuccess returns true when this tunnel created response has a 2xx status code -func (o *TunnelCreated) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this tunnel created response has a 3xx status code -func (o *TunnelCreated) IsRedirect() bool { - return false -} - -// IsClientError returns true when this tunnel created response has a 4xx status code -func (o *TunnelCreated) IsClientError() bool { - return false -} - -// IsServerError returns true when this tunnel created response has a 5xx status code -func (o *TunnelCreated) IsServerError() bool { - return false -} - -// IsCode returns true when this tunnel created response a status code equal to that given -func (o *TunnelCreated) IsCode(code int) bool { - return code == 201 -} - -func (o *TunnelCreated) Error() string { - return fmt.Sprintf("[POST /tunnel][%d] tunnelCreated %+v", 201, o.Payload) -} - -func (o *TunnelCreated) String() string { - return fmt.Sprintf("[POST /tunnel][%d] tunnelCreated %+v", 201, o.Payload) -} - -func (o *TunnelCreated) GetPayload() *rest_model_zrok.TunnelResponse { - return o.Payload -} - -func (o *TunnelCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(rest_model_zrok.TunnelResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewTunnelUnauthorized creates a TunnelUnauthorized with default headers values -func NewTunnelUnauthorized() *TunnelUnauthorized { - return &TunnelUnauthorized{} -} - -/* -TunnelUnauthorized describes a response with status code 401, with default header values. - -invalid environment identity -*/ -type TunnelUnauthorized struct { - Payload rest_model_zrok.ErrorMessage -} - -// IsSuccess returns true when this tunnel unauthorized response has a 2xx status code -func (o *TunnelUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this tunnel unauthorized response has a 3xx status code -func (o *TunnelUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this tunnel unauthorized response has a 4xx status code -func (o *TunnelUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this tunnel unauthorized response has a 5xx status code -func (o *TunnelUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this tunnel unauthorized response a status code equal to that given -func (o *TunnelUnauthorized) IsCode(code int) bool { - return code == 401 -} - -func (o *TunnelUnauthorized) Error() string { - return fmt.Sprintf("[POST /tunnel][%d] tunnelUnauthorized %+v", 401, o.Payload) -} - -func (o *TunnelUnauthorized) String() string { - return fmt.Sprintf("[POST /tunnel][%d] tunnelUnauthorized %+v", 401, o.Payload) -} - -func (o *TunnelUnauthorized) GetPayload() rest_model_zrok.ErrorMessage { - return o.Payload -} - -func (o *TunnelUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewTunnelInternalServerError creates a TunnelInternalServerError with default headers values -func NewTunnelInternalServerError() *TunnelInternalServerError { - return &TunnelInternalServerError{} -} - -/* -TunnelInternalServerError describes a response with status code 500, with default header values. - -internal server error -*/ -type TunnelInternalServerError struct { - Payload rest_model_zrok.ErrorMessage -} - -// IsSuccess returns true when this tunnel internal server error response has a 2xx status code -func (o *TunnelInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this tunnel internal server error response has a 3xx status code -func (o *TunnelInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this tunnel internal server error response has a 4xx status code -func (o *TunnelInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this tunnel internal server error response has a 5xx status code -func (o *TunnelInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this tunnel internal server error response a status code equal to that given -func (o *TunnelInternalServerError) IsCode(code int) bool { - return code == 500 -} - -func (o *TunnelInternalServerError) Error() string { - return fmt.Sprintf("[POST /tunnel][%d] tunnelInternalServerError %+v", 500, o.Payload) -} - -func (o *TunnelInternalServerError) String() string { - return fmt.Sprintf("[POST /tunnel][%d] tunnelInternalServerError %+v", 500, o.Payload) -} - -func (o *TunnelInternalServerError) GetPayload() rest_model_zrok.ErrorMessage { - return o.Payload -} - -func (o *TunnelInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/rest_client_zrok/tunnel/untunnel_parameters.go b/rest_client_zrok/tunnel/untunnel_parameters.go deleted file mode 100644 index 6e7fa750..00000000 --- a/rest_client_zrok/tunnel/untunnel_parameters.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package tunnel - -// 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-test-kitchen/zrok/rest_model_zrok" -) - -// NewUntunnelParams creates a new UntunnelParams 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 NewUntunnelParams() *UntunnelParams { - return &UntunnelParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewUntunnelParamsWithTimeout creates a new UntunnelParams object -// with the ability to set a timeout on a request. -func NewUntunnelParamsWithTimeout(timeout time.Duration) *UntunnelParams { - return &UntunnelParams{ - timeout: timeout, - } -} - -// NewUntunnelParamsWithContext creates a new UntunnelParams object -// with the ability to set a context for a request. -func NewUntunnelParamsWithContext(ctx context.Context) *UntunnelParams { - return &UntunnelParams{ - Context: ctx, - } -} - -// NewUntunnelParamsWithHTTPClient creates a new UntunnelParams object -// with the ability to set a custom HTTPClient for a request. -func NewUntunnelParamsWithHTTPClient(client *http.Client) *UntunnelParams { - return &UntunnelParams{ - HTTPClient: client, - } -} - -/* -UntunnelParams contains all the parameters to send to the API endpoint - - for the untunnel operation. - - Typically these are written to a http.Request. -*/ -type UntunnelParams struct { - - // Body. - Body *rest_model_zrok.UntunnelRequest - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the untunnel params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *UntunnelParams) WithDefaults() *UntunnelParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the untunnel params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *UntunnelParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the untunnel params -func (o *UntunnelParams) WithTimeout(timeout time.Duration) *UntunnelParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the untunnel params -func (o *UntunnelParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the untunnel params -func (o *UntunnelParams) WithContext(ctx context.Context) *UntunnelParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the untunnel params -func (o *UntunnelParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the untunnel params -func (o *UntunnelParams) WithHTTPClient(client *http.Client) *UntunnelParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the untunnel params -func (o *UntunnelParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithBody adds the body to the untunnel params -func (o *UntunnelParams) WithBody(body *rest_model_zrok.UntunnelRequest) *UntunnelParams { - o.SetBody(body) - return o -} - -// SetBody adds the body to the untunnel params -func (o *UntunnelParams) SetBody(body *rest_model_zrok.UntunnelRequest) { - o.Body = body -} - -// WriteToRequest writes these params to a swagger request -func (o *UntunnelParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - if o.Body != nil { - if err := r.SetBodyParam(o.Body); err != nil { - return err - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/rest_client_zrok/tunnel/untunnel_responses.go b/rest_client_zrok/tunnel/untunnel_responses.go deleted file mode 100644 index 1d527570..00000000 --- a/rest_client_zrok/tunnel/untunnel_responses.go +++ /dev/null @@ -1,220 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package tunnel - -// 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-test-kitchen/zrok/rest_model_zrok" -) - -// UntunnelReader is a Reader for the Untunnel structure. -type UntunnelReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *UntunnelReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewUntunnelOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 404: - result := NewUntunnelNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewUntunnelInternalServerError() - 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()) - } -} - -// NewUntunnelOK creates a UntunnelOK with default headers values -func NewUntunnelOK() *UntunnelOK { - return &UntunnelOK{} -} - -/* -UntunnelOK describes a response with status code 200, with default header values. - -tunnel removed -*/ -type UntunnelOK struct { -} - -// IsSuccess returns true when this untunnel o k response has a 2xx status code -func (o *UntunnelOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this untunnel o k response has a 3xx status code -func (o *UntunnelOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this untunnel o k response has a 4xx status code -func (o *UntunnelOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this untunnel o k response has a 5xx status code -func (o *UntunnelOK) IsServerError() bool { - return false -} - -// IsCode returns true when this untunnel o k response a status code equal to that given -func (o *UntunnelOK) IsCode(code int) bool { - return code == 200 -} - -func (o *UntunnelOK) Error() string { - return fmt.Sprintf("[DELETE /untunnel][%d] untunnelOK ", 200) -} - -func (o *UntunnelOK) String() string { - return fmt.Sprintf("[DELETE /untunnel][%d] untunnelOK ", 200) -} - -func (o *UntunnelOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - return nil -} - -// NewUntunnelNotFound creates a UntunnelNotFound with default headers values -func NewUntunnelNotFound() *UntunnelNotFound { - return &UntunnelNotFound{} -} - -/* -UntunnelNotFound describes a response with status code 404, with default header values. - -not found -*/ -type UntunnelNotFound struct { - Payload rest_model_zrok.ErrorMessage -} - -// IsSuccess returns true when this untunnel not found response has a 2xx status code -func (o *UntunnelNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this untunnel not found response has a 3xx status code -func (o *UntunnelNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this untunnel not found response has a 4xx status code -func (o *UntunnelNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this untunnel not found response has a 5xx status code -func (o *UntunnelNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this untunnel not found response a status code equal to that given -func (o *UntunnelNotFound) IsCode(code int) bool { - return code == 404 -} - -func (o *UntunnelNotFound) Error() string { - return fmt.Sprintf("[DELETE /untunnel][%d] untunnelNotFound %+v", 404, o.Payload) -} - -func (o *UntunnelNotFound) String() string { - return fmt.Sprintf("[DELETE /untunnel][%d] untunnelNotFound %+v", 404, o.Payload) -} - -func (o *UntunnelNotFound) GetPayload() rest_model_zrok.ErrorMessage { - return o.Payload -} - -func (o *UntunnelNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewUntunnelInternalServerError creates a UntunnelInternalServerError with default headers values -func NewUntunnelInternalServerError() *UntunnelInternalServerError { - return &UntunnelInternalServerError{} -} - -/* -UntunnelInternalServerError describes a response with status code 500, with default header values. - -internal server error -*/ -type UntunnelInternalServerError struct { - Payload rest_model_zrok.ErrorMessage -} - -// IsSuccess returns true when this untunnel internal server error response has a 2xx status code -func (o *UntunnelInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this untunnel internal server error response has a 3xx status code -func (o *UntunnelInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this untunnel internal server error response has a 4xx status code -func (o *UntunnelInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this untunnel internal server error response has a 5xx status code -func (o *UntunnelInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this untunnel internal server error response a status code equal to that given -func (o *UntunnelInternalServerError) IsCode(code int) bool { - return code == 500 -} - -func (o *UntunnelInternalServerError) Error() string { - return fmt.Sprintf("[DELETE /untunnel][%d] untunnelInternalServerError %+v", 500, o.Payload) -} - -func (o *UntunnelInternalServerError) String() string { - return fmt.Sprintf("[DELETE /untunnel][%d] untunnelInternalServerError %+v", 500, o.Payload) -} - -func (o *UntunnelInternalServerError) GetPayload() rest_model_zrok.ErrorMessage { - return o.Payload -} - -func (o *UntunnelInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/rest_client_zrok/zrok_client.go b/rest_client_zrok/zrok_client.go index 8e2109ff..e360029e 100644 --- a/rest_client_zrok/zrok_client.go +++ b/rest_client_zrok/zrok_client.go @@ -12,7 +12,7 @@ import ( "github.com/openziti-test-kitchen/zrok/rest_client_zrok/identity" "github.com/openziti-test-kitchen/zrok/rest_client_zrok/metadata" - "github.com/openziti-test-kitchen/zrok/rest_client_zrok/tunnel" + "github.com/openziti-test-kitchen/zrok/rest_client_zrok/service" ) // Default zrok HTTP client. @@ -59,7 +59,7 @@ func New(transport runtime.ClientTransport, formats strfmt.Registry) *Zrok { cli.Transport = transport cli.Identity = identity.New(transport, formats) cli.Metadata = metadata.New(transport, formats) - cli.Tunnel = tunnel.New(transport, formats) + cli.Service = service.New(transport, formats) return cli } @@ -108,7 +108,7 @@ type Zrok struct { Metadata metadata.ClientService - Tunnel tunnel.ClientService + Service service.ClientService Transport runtime.ClientTransport } @@ -118,5 +118,5 @@ func (c *Zrok) SetTransport(transport runtime.ClientTransport) { c.Transport = transport c.Identity.SetTransport(transport) c.Metadata.SetTransport(transport) - c.Tunnel.SetTransport(transport) + c.Service.SetTransport(transport) } diff --git a/rest_model_zrok/tunnel_request.go b/rest_model_zrok/share_request.go similarity index 75% rename from rest_model_zrok/tunnel_request.go rename to rest_model_zrok/share_request.go index 8c6baad5..fbb6f36c 100644 --- a/rest_model_zrok/tunnel_request.go +++ b/rest_model_zrok/share_request.go @@ -14,10 +14,10 @@ import ( "github.com/go-openapi/swag" ) -// TunnelRequest tunnel request +// ShareRequest share request // -// swagger:model tunnelRequest -type TunnelRequest struct { +// swagger:model shareRequest +type ShareRequest struct { // auth scheme AuthScheme string `json:"authScheme,omitempty"` @@ -32,8 +32,8 @@ type TunnelRequest struct { ZID string `json:"zId,omitempty"` } -// Validate validates this tunnel request -func (m *TunnelRequest) Validate(formats strfmt.Registry) error { +// Validate validates this share request +func (m *ShareRequest) Validate(formats strfmt.Registry) error { var res []error if err := m.validateAuthUsers(formats); err != nil { @@ -46,7 +46,7 @@ func (m *TunnelRequest) Validate(formats strfmt.Registry) error { return nil } -func (m *TunnelRequest) validateAuthUsers(formats strfmt.Registry) error { +func (m *ShareRequest) validateAuthUsers(formats strfmt.Registry) error { if swag.IsZero(m.AuthUsers) { // not required return nil } @@ -72,8 +72,8 @@ func (m *TunnelRequest) validateAuthUsers(formats strfmt.Registry) error { return nil } -// ContextValidate validate this tunnel request based on the context it is used -func (m *TunnelRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { +// ContextValidate validate this share request based on the context it is used +func (m *ShareRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error if err := m.contextValidateAuthUsers(ctx, formats); err != nil { @@ -86,7 +86,7 @@ func (m *TunnelRequest) ContextValidate(ctx context.Context, formats strfmt.Regi return nil } -func (m *TunnelRequest) contextValidateAuthUsers(ctx context.Context, formats strfmt.Registry) error { +func (m *ShareRequest) contextValidateAuthUsers(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.AuthUsers); i++ { @@ -107,7 +107,7 @@ func (m *TunnelRequest) contextValidateAuthUsers(ctx context.Context, formats st } // MarshalBinary interface implementation -func (m *TunnelRequest) MarshalBinary() ([]byte, error) { +func (m *ShareRequest) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } @@ -115,8 +115,8 @@ func (m *TunnelRequest) MarshalBinary() ([]byte, error) { } // UnmarshalBinary interface implementation -func (m *TunnelRequest) UnmarshalBinary(b []byte) error { - var res TunnelRequest +func (m *ShareRequest) UnmarshalBinary(b []byte) error { + var res ShareRequest if err := swag.ReadJSON(b, &res); err != nil { return err } diff --git a/rest_model_zrok/tunnel_response.go b/rest_model_zrok/share_response.go similarity index 57% rename from rest_model_zrok/tunnel_response.go rename to rest_model_zrok/share_response.go index 53cc2fdd..f4140ce7 100644 --- a/rest_model_zrok/tunnel_response.go +++ b/rest_model_zrok/share_response.go @@ -12,10 +12,10 @@ import ( "github.com/go-openapi/swag" ) -// TunnelResponse tunnel response +// ShareResponse share response // -// swagger:model tunnelResponse -type TunnelResponse struct { +// swagger:model shareResponse +type ShareResponse struct { // proxy endpoint ProxyEndpoint string `json:"proxyEndpoint,omitempty"` @@ -24,18 +24,18 @@ type TunnelResponse struct { SvcName string `json:"svcName,omitempty"` } -// Validate validates this tunnel response -func (m *TunnelResponse) Validate(formats strfmt.Registry) error { +// Validate validates this share response +func (m *ShareResponse) Validate(formats strfmt.Registry) error { return nil } -// ContextValidate validates this tunnel response based on context it is used -func (m *TunnelResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { +// ContextValidate validates this share response based on context it is used +func (m *ShareResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil } // MarshalBinary interface implementation -func (m *TunnelResponse) MarshalBinary() ([]byte, error) { +func (m *ShareResponse) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } @@ -43,8 +43,8 @@ func (m *TunnelResponse) MarshalBinary() ([]byte, error) { } // UnmarshalBinary interface implementation -func (m *TunnelResponse) UnmarshalBinary(b []byte) error { - var res TunnelResponse +func (m *ShareResponse) UnmarshalBinary(b []byte) error { + var res ShareResponse if err := swag.ReadJSON(b, &res); err != nil { return err } diff --git a/rest_model_zrok/untunnel_request.go b/rest_model_zrok/unshare_request.go similarity index 55% rename from rest_model_zrok/untunnel_request.go rename to rest_model_zrok/unshare_request.go index a5c6bffd..779743da 100644 --- a/rest_model_zrok/untunnel_request.go +++ b/rest_model_zrok/unshare_request.go @@ -12,10 +12,10 @@ import ( "github.com/go-openapi/swag" ) -// UntunnelRequest untunnel request +// UnshareRequest unshare request // -// swagger:model untunnelRequest -type UntunnelRequest struct { +// swagger:model unshareRequest +type UnshareRequest struct { // svc name SvcName string `json:"svcName,omitempty"` @@ -24,18 +24,18 @@ type UntunnelRequest struct { ZID string `json:"zId,omitempty"` } -// Validate validates this untunnel request -func (m *UntunnelRequest) Validate(formats strfmt.Registry) error { +// Validate validates this unshare request +func (m *UnshareRequest) Validate(formats strfmt.Registry) error { return nil } -// ContextValidate validates this untunnel request based on context it is used -func (m *UntunnelRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { +// ContextValidate validates this unshare request based on context it is used +func (m *UnshareRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil } // MarshalBinary interface implementation -func (m *UntunnelRequest) MarshalBinary() ([]byte, error) { +func (m *UnshareRequest) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } @@ -43,8 +43,8 @@ func (m *UntunnelRequest) MarshalBinary() ([]byte, error) { } // UnmarshalBinary interface implementation -func (m *UntunnelRequest) UnmarshalBinary(b []byte) error { - var res UntunnelRequest +func (m *UnshareRequest) UnmarshalBinary(b []byte) error { + var res UnshareRequest if err := swag.ReadJSON(b, &res); err != nil { return err } diff --git a/rest_server_zrok/embedded_spec.go b/rest_server_zrok/embedded_spec.go index c69fc027..28fc89ac 100644 --- a/rest_server_zrok/embedded_spec.go +++ b/rest_server_zrok/embedded_spec.go @@ -236,7 +236,7 @@ func init() { } } }, - "/tunnel": { + "/share": { "post": { "security": [ { @@ -244,30 +244,27 @@ func init() { } ], "tags": [ - "tunnel" + "service" ], - "operationId": "tunnel", + "operationId": "share", "parameters": [ { "name": "body", "in": "body", "schema": { - "$ref": "#/definitions/tunnelRequest" + "$ref": "#/definitions/shareRequest" } } ], "responses": { "201": { - "description": "tunnel created", + "description": "service created", "schema": { - "$ref": "#/definitions/tunnelResponse" + "$ref": "#/definitions/shareResponse" } }, "401": { - "description": "invalid environment identity", - "schema": { - "$ref": "#/definitions/errorMessage" - } + "description": "unauthorized" }, "500": { "description": "internal server error", @@ -278,7 +275,7 @@ func init() { } } }, - "/untunnel": { + "/unshare": { "delete": { "security": [ { @@ -286,27 +283,27 @@ func init() { } ], "tags": [ - "tunnel" + "service" ], - "operationId": "untunnel", + "operationId": "unshare", "parameters": [ { "name": "body", "in": "body", "schema": { - "$ref": "#/definitions/untunnelRequest" + "$ref": "#/definitions/unshareRequest" } } ], "responses": { "200": { - "description": "tunnel removed" + "description": "service removed" + }, + "401": { + "description": "unauthorized" }, "404": { - "description": "not found", - "schema": { - "$ref": "#/definitions/errorMessage" - } + "description": "not found" }, "500": { "description": "internal server error", @@ -555,7 +552,7 @@ func init() { "$ref": "#/definitions/service" } }, - "tunnelRequest": { + "shareRequest": { "type": "object", "properties": { "authScheme": { @@ -575,7 +572,7 @@ func init() { } } }, - "tunnelResponse": { + "shareResponse": { "type": "object", "properties": { "proxyEndpoint": { @@ -586,7 +583,7 @@ func init() { } } }, - "untunnelRequest": { + "unshareRequest": { "type": "object", "properties": { "svcName": { @@ -844,7 +841,7 @@ func init() { } } }, - "/tunnel": { + "/share": { "post": { "security": [ { @@ -852,30 +849,27 @@ func init() { } ], "tags": [ - "tunnel" + "service" ], - "operationId": "tunnel", + "operationId": "share", "parameters": [ { "name": "body", "in": "body", "schema": { - "$ref": "#/definitions/tunnelRequest" + "$ref": "#/definitions/shareRequest" } } ], "responses": { "201": { - "description": "tunnel created", + "description": "service created", "schema": { - "$ref": "#/definitions/tunnelResponse" + "$ref": "#/definitions/shareResponse" } }, "401": { - "description": "invalid environment identity", - "schema": { - "$ref": "#/definitions/errorMessage" - } + "description": "unauthorized" }, "500": { "description": "internal server error", @@ -886,7 +880,7 @@ func init() { } } }, - "/untunnel": { + "/unshare": { "delete": { "security": [ { @@ -894,27 +888,27 @@ func init() { } ], "tags": [ - "tunnel" + "service" ], - "operationId": "untunnel", + "operationId": "unshare", "parameters": [ { "name": "body", "in": "body", "schema": { - "$ref": "#/definitions/untunnelRequest" + "$ref": "#/definitions/unshareRequest" } } ], "responses": { "200": { - "description": "tunnel removed" + "description": "service removed" + }, + "401": { + "description": "unauthorized" }, "404": { - "description": "not found", - "schema": { - "$ref": "#/definitions/errorMessage" - } + "description": "not found" }, "500": { "description": "internal server error", @@ -1163,7 +1157,7 @@ func init() { "$ref": "#/definitions/service" } }, - "tunnelRequest": { + "shareRequest": { "type": "object", "properties": { "authScheme": { @@ -1183,7 +1177,7 @@ func init() { } } }, - "tunnelResponse": { + "shareResponse": { "type": "object", "properties": { "proxyEndpoint": { @@ -1194,7 +1188,7 @@ func init() { } } }, - "untunnelRequest": { + "unshareRequest": { "type": "object", "properties": { "svcName": { diff --git a/rest_server_zrok/operations/tunnel/tunnel.go b/rest_server_zrok/operations/service/share.go similarity index 56% rename from rest_server_zrok/operations/tunnel/tunnel.go rename to rest_server_zrok/operations/service/share.go index 85b54bf1..480f4187 100644 --- a/rest_server_zrok/operations/tunnel/tunnel.go +++ b/rest_server_zrok/operations/service/share.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package tunnel +package service // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the generate command @@ -13,40 +13,40 @@ import ( "github.com/openziti-test-kitchen/zrok/rest_model_zrok" ) -// TunnelHandlerFunc turns a function with the right signature into a tunnel handler -type TunnelHandlerFunc func(TunnelParams, *rest_model_zrok.Principal) middleware.Responder +// ShareHandlerFunc turns a function with the right signature into a share handler +type ShareHandlerFunc func(ShareParams, *rest_model_zrok.Principal) middleware.Responder // Handle executing the request and returning a response -func (fn TunnelHandlerFunc) Handle(params TunnelParams, principal *rest_model_zrok.Principal) middleware.Responder { +func (fn ShareHandlerFunc) Handle(params ShareParams, principal *rest_model_zrok.Principal) middleware.Responder { return fn(params, principal) } -// TunnelHandler interface for that can handle valid tunnel params -type TunnelHandler interface { - Handle(TunnelParams, *rest_model_zrok.Principal) middleware.Responder +// ShareHandler interface for that can handle valid share params +type ShareHandler interface { + Handle(ShareParams, *rest_model_zrok.Principal) middleware.Responder } -// NewTunnel creates a new http.Handler for the tunnel operation -func NewTunnel(ctx *middleware.Context, handler TunnelHandler) *Tunnel { - return &Tunnel{Context: ctx, Handler: handler} +// NewShare creates a new http.Handler for the share operation +func NewShare(ctx *middleware.Context, handler ShareHandler) *Share { + return &Share{Context: ctx, Handler: handler} } /* - Tunnel swagger:route POST /tunnel tunnel tunnel + Share swagger:route POST /share service share -Tunnel tunnel API +Share share API */ -type Tunnel struct { +type Share struct { Context *middleware.Context - Handler TunnelHandler + Handler ShareHandler } -func (o *Tunnel) ServeHTTP(rw http.ResponseWriter, r *http.Request) { +func (o *Share) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { *r = *rCtx } - var Params = NewTunnelParams() + var Params = NewShareParams() uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) diff --git a/rest_server_zrok/operations/tunnel/tunnel_parameters.go b/rest_server_zrok/operations/service/share_parameters.go similarity index 76% rename from rest_server_zrok/operations/tunnel/tunnel_parameters.go rename to rest_server_zrok/operations/service/share_parameters.go index a294752a..b4cc3285 100644 --- a/rest_server_zrok/operations/tunnel/tunnel_parameters.go +++ b/rest_server_zrok/operations/service/share_parameters.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package tunnel +package service // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command @@ -16,19 +16,19 @@ import ( "github.com/openziti-test-kitchen/zrok/rest_model_zrok" ) -// NewTunnelParams creates a new TunnelParams object +// NewShareParams creates a new ShareParams object // // There are no default values defined in the spec. -func NewTunnelParams() TunnelParams { +func NewShareParams() ShareParams { - return TunnelParams{} + return ShareParams{} } -// TunnelParams contains all the bound params for the tunnel operation +// ShareParams contains all the bound params for the share operation // typically these are obtained from a http.Request // -// swagger:parameters tunnel -type TunnelParams struct { +// swagger:parameters share +type ShareParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` @@ -36,21 +36,21 @@ type TunnelParams struct { /* In: body */ - Body *rest_model_zrok.TunnelRequest + Body *rest_model_zrok.ShareRequest } // 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 NewTunnelParams() beforehand. -func (o *TunnelParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { +// To ensure default values, the struct must have been initialized with NewShareParams() beforehand. +func (o *ShareParams) 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_zrok.TunnelRequest + var body rest_model_zrok.ShareRequest if err := route.Consumer.Consume(r.Body, &body); err != nil { res = append(res, errors.NewParseError("body", "body", "", err)) } else { diff --git a/rest_server_zrok/operations/service/share_responses.go b/rest_server_zrok/operations/service/share_responses.go new file mode 100644 index 00000000..cbb46a14 --- /dev/null +++ b/rest_server_zrok/operations/service/share_responses.go @@ -0,0 +1,127 @@ +// Code generated by go-swagger; DO NOT EDIT. + +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-test-kitchen/zrok/rest_model_zrok" +) + +// ShareCreatedCode is the HTTP code returned for type ShareCreated +const ShareCreatedCode int = 201 + +/* +ShareCreated service created + +swagger:response shareCreated +*/ +type ShareCreated struct { + + /* + In: Body + */ + Payload *rest_model_zrok.ShareResponse `json:"body,omitempty"` +} + +// NewShareCreated creates ShareCreated with default headers values +func NewShareCreated() *ShareCreated { + + return &ShareCreated{} +} + +// WithPayload adds the payload to the share created response +func (o *ShareCreated) WithPayload(payload *rest_model_zrok.ShareResponse) *ShareCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the share created response +func (o *ShareCreated) SetPayload(payload *rest_model_zrok.ShareResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ShareCreated) 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 + } + } +} + +// ShareUnauthorizedCode is the HTTP code returned for type ShareUnauthorized +const ShareUnauthorizedCode int = 401 + +/* +ShareUnauthorized unauthorized + +swagger:response shareUnauthorized +*/ +type ShareUnauthorized struct { +} + +// NewShareUnauthorized creates ShareUnauthorized with default headers values +func NewShareUnauthorized() *ShareUnauthorized { + + return &ShareUnauthorized{} +} + +// WriteResponse to the client +func (o *ShareUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(401) +} + +// ShareInternalServerErrorCode is the HTTP code returned for type ShareInternalServerError +const ShareInternalServerErrorCode int = 500 + +/* +ShareInternalServerError internal server error + +swagger:response shareInternalServerError +*/ +type ShareInternalServerError struct { + + /* + In: Body + */ + Payload rest_model_zrok.ErrorMessage `json:"body,omitempty"` +} + +// NewShareInternalServerError creates ShareInternalServerError with default headers values +func NewShareInternalServerError() *ShareInternalServerError { + + return &ShareInternalServerError{} +} + +// WithPayload adds the payload to the share internal server error response +func (o *ShareInternalServerError) WithPayload(payload rest_model_zrok.ErrorMessage) *ShareInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the share internal server error response +func (o *ShareInternalServerError) SetPayload(payload rest_model_zrok.ErrorMessage) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ShareInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + 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_zrok/operations/tunnel/tunnel_urlbuilder.go b/rest_server_zrok/operations/service/share_urlbuilder.go similarity index 70% rename from rest_server_zrok/operations/tunnel/tunnel_urlbuilder.go rename to rest_server_zrok/operations/service/share_urlbuilder.go index dc086639..78d14d28 100644 --- a/rest_server_zrok/operations/tunnel/tunnel_urlbuilder.go +++ b/rest_server_zrok/operations/service/share_urlbuilder.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package tunnel +package service // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the generate command @@ -11,15 +11,15 @@ import ( golangswaggerpaths "path" ) -// TunnelURL generates an URL for the tunnel operation -type TunnelURL struct { +// ShareURL generates an URL for the share operation +type ShareURL 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 *TunnelURL) WithBasePath(bp string) *TunnelURL { +func (o *ShareURL) WithBasePath(bp string) *ShareURL { o.SetBasePath(bp) return o } @@ -27,15 +27,15 @@ func (o *TunnelURL) WithBasePath(bp string) *TunnelURL { // 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 *TunnelURL) SetBasePath(bp string) { +func (o *ShareURL) SetBasePath(bp string) { o._basePath = bp } // Build a url path and query string -func (o *TunnelURL) Build() (*url.URL, error) { +func (o *ShareURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/tunnel" + var _path = "/share" _basePath := o._basePath if _basePath == "" { @@ -47,7 +47,7 @@ func (o *TunnelURL) Build() (*url.URL, error) { } // Must is a helper function to panic when the url builder returns an error -func (o *TunnelURL) Must(u *url.URL, err error) *url.URL { +func (o *ShareURL) Must(u *url.URL, err error) *url.URL { if err != nil { panic(err) } @@ -58,17 +58,17 @@ func (o *TunnelURL) Must(u *url.URL, err error) *url.URL { } // String returns the string representation of the path with query string -func (o *TunnelURL) String() string { +func (o *ShareURL) String() string { return o.Must(o.Build()).String() } // BuildFull builds a full url with scheme, host, path and query string -func (o *TunnelURL) BuildFull(scheme, host string) (*url.URL, error) { +func (o *ShareURL) BuildFull(scheme, host string) (*url.URL, error) { if scheme == "" { - return nil, errors.New("scheme is required for a full url on TunnelURL") + return nil, errors.New("scheme is required for a full url on ShareURL") } if host == "" { - return nil, errors.New("host is required for a full url on TunnelURL") + return nil, errors.New("host is required for a full url on ShareURL") } base, err := o.Build() @@ -82,6 +82,6 @@ func (o *TunnelURL) BuildFull(scheme, host string) (*url.URL, error) { } // StringFull returns the string representation of a complete url -func (o *TunnelURL) StringFull(scheme, host string) string { +func (o *ShareURL) StringFull(scheme, host string) string { return o.Must(o.BuildFull(scheme, host)).String() } diff --git a/rest_server_zrok/operations/tunnel/untunnel.go b/rest_server_zrok/operations/service/unshare.go similarity index 55% rename from rest_server_zrok/operations/tunnel/untunnel.go rename to rest_server_zrok/operations/service/unshare.go index dbda2eca..a7784ad8 100644 --- a/rest_server_zrok/operations/tunnel/untunnel.go +++ b/rest_server_zrok/operations/service/unshare.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package tunnel +package service // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the generate command @@ -13,40 +13,40 @@ import ( "github.com/openziti-test-kitchen/zrok/rest_model_zrok" ) -// UntunnelHandlerFunc turns a function with the right signature into a untunnel handler -type UntunnelHandlerFunc func(UntunnelParams, *rest_model_zrok.Principal) middleware.Responder +// UnshareHandlerFunc turns a function with the right signature into a unshare handler +type UnshareHandlerFunc func(UnshareParams, *rest_model_zrok.Principal) middleware.Responder // Handle executing the request and returning a response -func (fn UntunnelHandlerFunc) Handle(params UntunnelParams, principal *rest_model_zrok.Principal) middleware.Responder { +func (fn UnshareHandlerFunc) Handle(params UnshareParams, principal *rest_model_zrok.Principal) middleware.Responder { return fn(params, principal) } -// UntunnelHandler interface for that can handle valid untunnel params -type UntunnelHandler interface { - Handle(UntunnelParams, *rest_model_zrok.Principal) middleware.Responder +// UnshareHandler interface for that can handle valid unshare params +type UnshareHandler interface { + Handle(UnshareParams, *rest_model_zrok.Principal) middleware.Responder } -// NewUntunnel creates a new http.Handler for the untunnel operation -func NewUntunnel(ctx *middleware.Context, handler UntunnelHandler) *Untunnel { - return &Untunnel{Context: ctx, Handler: handler} +// NewUnshare creates a new http.Handler for the unshare operation +func NewUnshare(ctx *middleware.Context, handler UnshareHandler) *Unshare { + return &Unshare{Context: ctx, Handler: handler} } /* - Untunnel swagger:route DELETE /untunnel tunnel untunnel + Unshare swagger:route DELETE /unshare service unshare -Untunnel untunnel API +Unshare unshare API */ -type Untunnel struct { +type Unshare struct { Context *middleware.Context - Handler UntunnelHandler + Handler UnshareHandler } -func (o *Untunnel) ServeHTTP(rw http.ResponseWriter, r *http.Request) { +func (o *Unshare) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { *r = *rCtx } - var Params = NewUntunnelParams() + var Params = NewUnshareParams() uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) diff --git a/rest_server_zrok/operations/tunnel/untunnel_parameters.go b/rest_server_zrok/operations/service/unshare_parameters.go similarity index 75% rename from rest_server_zrok/operations/tunnel/untunnel_parameters.go rename to rest_server_zrok/operations/service/unshare_parameters.go index 55cd49d4..af46d005 100644 --- a/rest_server_zrok/operations/tunnel/untunnel_parameters.go +++ b/rest_server_zrok/operations/service/unshare_parameters.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package tunnel +package service // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command @@ -16,19 +16,19 @@ import ( "github.com/openziti-test-kitchen/zrok/rest_model_zrok" ) -// NewUntunnelParams creates a new UntunnelParams object +// NewUnshareParams creates a new UnshareParams object // // There are no default values defined in the spec. -func NewUntunnelParams() UntunnelParams { +func NewUnshareParams() UnshareParams { - return UntunnelParams{} + return UnshareParams{} } -// UntunnelParams contains all the bound params for the untunnel operation +// UnshareParams contains all the bound params for the unshare operation // typically these are obtained from a http.Request // -// swagger:parameters untunnel -type UntunnelParams struct { +// swagger:parameters unshare +type UnshareParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` @@ -36,21 +36,21 @@ type UntunnelParams struct { /* In: body */ - Body *rest_model_zrok.UntunnelRequest + Body *rest_model_zrok.UnshareRequest } // 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 NewUntunnelParams() beforehand. -func (o *UntunnelParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { +// To ensure default values, the struct must have been initialized with NewUnshareParams() beforehand. +func (o *UnshareParams) 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_zrok.UntunnelRequest + var body rest_model_zrok.UnshareRequest if err := route.Consumer.Consume(r.Body, &body); err != nil { res = append(res, errors.NewParseError("body", "body", "", err)) } else { diff --git a/rest_server_zrok/operations/service/unshare_responses.go b/rest_server_zrok/operations/service/unshare_responses.go new file mode 100644 index 00000000..348abb92 --- /dev/null +++ b/rest_server_zrok/operations/service/unshare_responses.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +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-test-kitchen/zrok/rest_model_zrok" +) + +// UnshareOKCode is the HTTP code returned for type UnshareOK +const UnshareOKCode int = 200 + +/* +UnshareOK service removed + +swagger:response unshareOK +*/ +type UnshareOK struct { +} + +// NewUnshareOK creates UnshareOK with default headers values +func NewUnshareOK() *UnshareOK { + + return &UnshareOK{} +} + +// WriteResponse to the client +func (o *UnshareOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// UnshareUnauthorizedCode is the HTTP code returned for type UnshareUnauthorized +const UnshareUnauthorizedCode int = 401 + +/* +UnshareUnauthorized unauthorized + +swagger:response unshareUnauthorized +*/ +type UnshareUnauthorized struct { +} + +// NewUnshareUnauthorized creates UnshareUnauthorized with default headers values +func NewUnshareUnauthorized() *UnshareUnauthorized { + + return &UnshareUnauthorized{} +} + +// WriteResponse to the client +func (o *UnshareUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(401) +} + +// UnshareNotFoundCode is the HTTP code returned for type UnshareNotFound +const UnshareNotFoundCode int = 404 + +/* +UnshareNotFound not found + +swagger:response unshareNotFound +*/ +type UnshareNotFound struct { +} + +// NewUnshareNotFound creates UnshareNotFound with default headers values +func NewUnshareNotFound() *UnshareNotFound { + + return &UnshareNotFound{} +} + +// WriteResponse to the client +func (o *UnshareNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(404) +} + +// UnshareInternalServerErrorCode is the HTTP code returned for type UnshareInternalServerError +const UnshareInternalServerErrorCode int = 500 + +/* +UnshareInternalServerError internal server error + +swagger:response unshareInternalServerError +*/ +type UnshareInternalServerError struct { + + /* + In: Body + */ + Payload rest_model_zrok.ErrorMessage `json:"body,omitempty"` +} + +// NewUnshareInternalServerError creates UnshareInternalServerError with default headers values +func NewUnshareInternalServerError() *UnshareInternalServerError { + + return &UnshareInternalServerError{} +} + +// WithPayload adds the payload to the unshare internal server error response +func (o *UnshareInternalServerError) WithPayload(payload rest_model_zrok.ErrorMessage) *UnshareInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the unshare internal server error response +func (o *UnshareInternalServerError) SetPayload(payload rest_model_zrok.ErrorMessage) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *UnshareInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + 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_zrok/operations/tunnel/untunnel_urlbuilder.go b/rest_server_zrok/operations/service/unshare_urlbuilder.go similarity index 72% rename from rest_server_zrok/operations/tunnel/untunnel_urlbuilder.go rename to rest_server_zrok/operations/service/unshare_urlbuilder.go index 997b4e7a..9567b35e 100644 --- a/rest_server_zrok/operations/tunnel/untunnel_urlbuilder.go +++ b/rest_server_zrok/operations/service/unshare_urlbuilder.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package tunnel +package service // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the generate command @@ -11,15 +11,15 @@ import ( golangswaggerpaths "path" ) -// UntunnelURL generates an URL for the untunnel operation -type UntunnelURL struct { +// UnshareURL generates an URL for the unshare operation +type UnshareURL 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 *UntunnelURL) WithBasePath(bp string) *UntunnelURL { +func (o *UnshareURL) WithBasePath(bp string) *UnshareURL { o.SetBasePath(bp) return o } @@ -27,15 +27,15 @@ func (o *UntunnelURL) WithBasePath(bp string) *UntunnelURL { // 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 *UntunnelURL) SetBasePath(bp string) { +func (o *UnshareURL) SetBasePath(bp string) { o._basePath = bp } // Build a url path and query string -func (o *UntunnelURL) Build() (*url.URL, error) { +func (o *UnshareURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/untunnel" + var _path = "/unshare" _basePath := o._basePath if _basePath == "" { @@ -47,7 +47,7 @@ func (o *UntunnelURL) Build() (*url.URL, error) { } // Must is a helper function to panic when the url builder returns an error -func (o *UntunnelURL) Must(u *url.URL, err error) *url.URL { +func (o *UnshareURL) Must(u *url.URL, err error) *url.URL { if err != nil { panic(err) } @@ -58,17 +58,17 @@ func (o *UntunnelURL) Must(u *url.URL, err error) *url.URL { } // String returns the string representation of the path with query string -func (o *UntunnelURL) String() string { +func (o *UnshareURL) String() string { return o.Must(o.Build()).String() } // BuildFull builds a full url with scheme, host, path and query string -func (o *UntunnelURL) BuildFull(scheme, host string) (*url.URL, error) { +func (o *UnshareURL) BuildFull(scheme, host string) (*url.URL, error) { if scheme == "" { - return nil, errors.New("scheme is required for a full url on UntunnelURL") + return nil, errors.New("scheme is required for a full url on UnshareURL") } if host == "" { - return nil, errors.New("host is required for a full url on UntunnelURL") + return nil, errors.New("host is required for a full url on UnshareURL") } base, err := o.Build() @@ -82,6 +82,6 @@ func (o *UntunnelURL) BuildFull(scheme, host string) (*url.URL, error) { } // StringFull returns the string representation of a complete url -func (o *UntunnelURL) StringFull(scheme, host string) string { +func (o *UnshareURL) StringFull(scheme, host string) string { return o.Must(o.BuildFull(scheme, host)).String() } diff --git a/rest_server_zrok/operations/tunnel/tunnel_responses.go b/rest_server_zrok/operations/tunnel/tunnel_responses.go deleted file mode 100644 index b5c9fd30..00000000 --- a/rest_server_zrok/operations/tunnel/tunnel_responses.go +++ /dev/null @@ -1,145 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package tunnel - -// 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-test-kitchen/zrok/rest_model_zrok" -) - -// TunnelCreatedCode is the HTTP code returned for type TunnelCreated -const TunnelCreatedCode int = 201 - -/* -TunnelCreated tunnel created - -swagger:response tunnelCreated -*/ -type TunnelCreated struct { - - /* - In: Body - */ - Payload *rest_model_zrok.TunnelResponse `json:"body,omitempty"` -} - -// NewTunnelCreated creates TunnelCreated with default headers values -func NewTunnelCreated() *TunnelCreated { - - return &TunnelCreated{} -} - -// WithPayload adds the payload to the tunnel created response -func (o *TunnelCreated) WithPayload(payload *rest_model_zrok.TunnelResponse) *TunnelCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the tunnel created response -func (o *TunnelCreated) SetPayload(payload *rest_model_zrok.TunnelResponse) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *TunnelCreated) 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 - } - } -} - -// TunnelUnauthorizedCode is the HTTP code returned for type TunnelUnauthorized -const TunnelUnauthorizedCode int = 401 - -/* -TunnelUnauthorized invalid environment identity - -swagger:response tunnelUnauthorized -*/ -type TunnelUnauthorized struct { - - /* - In: Body - */ - Payload rest_model_zrok.ErrorMessage `json:"body,omitempty"` -} - -// NewTunnelUnauthorized creates TunnelUnauthorized with default headers values -func NewTunnelUnauthorized() *TunnelUnauthorized { - - return &TunnelUnauthorized{} -} - -// WithPayload adds the payload to the tunnel unauthorized response -func (o *TunnelUnauthorized) WithPayload(payload rest_model_zrok.ErrorMessage) *TunnelUnauthorized { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the tunnel unauthorized response -func (o *TunnelUnauthorized) SetPayload(payload rest_model_zrok.ErrorMessage) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *TunnelUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(401) - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } -} - -// TunnelInternalServerErrorCode is the HTTP code returned for type TunnelInternalServerError -const TunnelInternalServerErrorCode int = 500 - -/* -TunnelInternalServerError internal server error - -swagger:response tunnelInternalServerError -*/ -type TunnelInternalServerError struct { - - /* - In: Body - */ - Payload rest_model_zrok.ErrorMessage `json:"body,omitempty"` -} - -// NewTunnelInternalServerError creates TunnelInternalServerError with default headers values -func NewTunnelInternalServerError() *TunnelInternalServerError { - - return &TunnelInternalServerError{} -} - -// WithPayload adds the payload to the tunnel internal server error response -func (o *TunnelInternalServerError) WithPayload(payload rest_model_zrok.ErrorMessage) *TunnelInternalServerError { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the tunnel internal server error response -func (o *TunnelInternalServerError) SetPayload(payload rest_model_zrok.ErrorMessage) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *TunnelInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(500) - 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_zrok/operations/tunnel/untunnel_responses.go b/rest_server_zrok/operations/tunnel/untunnel_responses.go deleted file mode 100644 index 480ee349..00000000 --- a/rest_server_zrok/operations/tunnel/untunnel_responses.go +++ /dev/null @@ -1,125 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package tunnel - -// 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-test-kitchen/zrok/rest_model_zrok" -) - -// UntunnelOKCode is the HTTP code returned for type UntunnelOK -const UntunnelOKCode int = 200 - -/* -UntunnelOK tunnel removed - -swagger:response untunnelOK -*/ -type UntunnelOK struct { -} - -// NewUntunnelOK creates UntunnelOK with default headers values -func NewUntunnelOK() *UntunnelOK { - - return &UntunnelOK{} -} - -// WriteResponse to the client -func (o *UntunnelOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(200) -} - -// UntunnelNotFoundCode is the HTTP code returned for type UntunnelNotFound -const UntunnelNotFoundCode int = 404 - -/* -UntunnelNotFound not found - -swagger:response untunnelNotFound -*/ -type UntunnelNotFound struct { - - /* - In: Body - */ - Payload rest_model_zrok.ErrorMessage `json:"body,omitempty"` -} - -// NewUntunnelNotFound creates UntunnelNotFound with default headers values -func NewUntunnelNotFound() *UntunnelNotFound { - - return &UntunnelNotFound{} -} - -// WithPayload adds the payload to the untunnel not found response -func (o *UntunnelNotFound) WithPayload(payload rest_model_zrok.ErrorMessage) *UntunnelNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the untunnel not found response -func (o *UntunnelNotFound) SetPayload(payload rest_model_zrok.ErrorMessage) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *UntunnelNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(404) - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } -} - -// UntunnelInternalServerErrorCode is the HTTP code returned for type UntunnelInternalServerError -const UntunnelInternalServerErrorCode int = 500 - -/* -UntunnelInternalServerError internal server error - -swagger:response untunnelInternalServerError -*/ -type UntunnelInternalServerError struct { - - /* - In: Body - */ - Payload rest_model_zrok.ErrorMessage `json:"body,omitempty"` -} - -// NewUntunnelInternalServerError creates UntunnelInternalServerError with default headers values -func NewUntunnelInternalServerError() *UntunnelInternalServerError { - - return &UntunnelInternalServerError{} -} - -// WithPayload adds the payload to the untunnel internal server error response -func (o *UntunnelInternalServerError) WithPayload(payload rest_model_zrok.ErrorMessage) *UntunnelInternalServerError { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the untunnel internal server error response -func (o *UntunnelInternalServerError) SetPayload(payload rest_model_zrok.ErrorMessage) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *UntunnelInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(500) - 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_zrok/operations/zrok_api.go b/rest_server_zrok/operations/zrok_api.go index 73d65b57..acecb722 100644 --- a/rest_server_zrok/operations/zrok_api.go +++ b/rest_server_zrok/operations/zrok_api.go @@ -22,7 +22,7 @@ import ( "github.com/openziti-test-kitchen/zrok/rest_model_zrok" "github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/identity" "github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/metadata" - "github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/tunnel" + "github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/service" ) // NewZrokAPI creates a new Zrok instance @@ -65,11 +65,11 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI { IdentityRegisterHandler: identity.RegisterHandlerFunc(func(params identity.RegisterParams) middleware.Responder { return middleware.NotImplemented("operation identity.Register has not yet been implemented") }), - TunnelTunnelHandler: tunnel.TunnelHandlerFunc(func(params tunnel.TunnelParams, principal *rest_model_zrok.Principal) middleware.Responder { - return middleware.NotImplemented("operation tunnel.Tunnel has not yet been implemented") + ServiceShareHandler: service.ShareHandlerFunc(func(params service.ShareParams, principal *rest_model_zrok.Principal) middleware.Responder { + return middleware.NotImplemented("operation service.Share has not yet been implemented") }), - TunnelUntunnelHandler: tunnel.UntunnelHandlerFunc(func(params tunnel.UntunnelParams, principal *rest_model_zrok.Principal) middleware.Responder { - return middleware.NotImplemented("operation tunnel.Untunnel has not yet been implemented") + ServiceUnshareHandler: service.UnshareHandlerFunc(func(params service.UnshareParams, principal *rest_model_zrok.Principal) middleware.Responder { + return middleware.NotImplemented("operation service.Unshare has not yet been implemented") }), IdentityVerifyHandler: identity.VerifyHandlerFunc(func(params identity.VerifyParams) middleware.Responder { return middleware.NotImplemented("operation identity.Verify has not yet been implemented") @@ -139,10 +139,10 @@ type ZrokAPI struct { MetadataOverviewHandler metadata.OverviewHandler // IdentityRegisterHandler sets the operation handler for the register operation IdentityRegisterHandler identity.RegisterHandler - // TunnelTunnelHandler sets the operation handler for the tunnel operation - TunnelTunnelHandler tunnel.TunnelHandler - // TunnelUntunnelHandler sets the operation handler for the untunnel operation - TunnelUntunnelHandler tunnel.UntunnelHandler + // ServiceShareHandler sets the operation handler for the share operation + ServiceShareHandler service.ShareHandler + // ServiceUnshareHandler sets the operation handler for the unshare operation + ServiceUnshareHandler service.UnshareHandler // IdentityVerifyHandler sets the operation handler for the verify operation IdentityVerifyHandler identity.VerifyHandler // MetadataVersionHandler sets the operation handler for the version operation @@ -246,11 +246,11 @@ func (o *ZrokAPI) Validate() error { if o.IdentityRegisterHandler == nil { unregistered = append(unregistered, "identity.RegisterHandler") } - if o.TunnelTunnelHandler == nil { - unregistered = append(unregistered, "tunnel.TunnelHandler") + if o.ServiceShareHandler == nil { + unregistered = append(unregistered, "service.ShareHandler") } - if o.TunnelUntunnelHandler == nil { - unregistered = append(unregistered, "tunnel.UntunnelHandler") + if o.ServiceUnshareHandler == nil { + unregistered = append(unregistered, "service.UnshareHandler") } if o.IdentityVerifyHandler == nil { unregistered = append(unregistered, "identity.VerifyHandler") @@ -384,11 +384,11 @@ func (o *ZrokAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/tunnel"] = tunnel.NewTunnel(o.context, o.TunnelTunnelHandler) + o.handlers["POST"]["/share"] = service.NewShare(o.context, o.ServiceShareHandler) if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/untunnel"] = tunnel.NewUntunnel(o.context, o.TunnelUntunnelHandler) + o.handlers["DELETE"]["/unshare"] = service.NewUnshare(o.context, o.ServiceUnshareHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } diff --git a/specs/zrok.yml b/specs/zrok.yml index 89f9c497..ab27349c 100644 --- a/specs/zrok.yml +++ b/specs/zrok.yml @@ -177,52 +177,50 @@ paths: schema: $ref: "#/definitions/version" # - # tunnel + # service # - /tunnel: + /share: post: tags: - - tunnel + - service security: - key: [] - operationId: tunnel + operationId: share parameters: - name: body in: body schema: - $ref: "#/definitions/tunnelRequest" + $ref: "#/definitions/shareRequest" responses: 201: - description: tunnel created + description: service created schema: - $ref: "#/definitions/tunnelResponse" + $ref: "#/definitions/shareResponse" 401: - description: invalid environment identity - schema: - $ref: "#/definitions/errorMessage" + description: unauthorized 500: description: internal server error schema: $ref: "#/definitions/errorMessage" - /untunnel: + /unshare: delete: tags: - - tunnel + - service security: - key: [] - operationId: untunnel + operationId: unshare parameters: - name: body in: body schema: - $ref: "#/definitions/untunnelRequest" + $ref: "#/definitions/unshareRequest" responses: 200: - description: tunnel removed + description: service removed + 401: + description: unauthorized 404: description: not found - schema: - $ref: "#/definitions/errorMessage" 500: description: internal server error schema: @@ -361,7 +359,7 @@ definitions: items: type: integer - tunnelRequest: + shareRequest: type: object properties: zId: @@ -374,7 +372,7 @@ definitions: type: array items: $ref: "#/definitions/authUser" - tunnelResponse: + shareResponse: type: object properties: proxyEndpoint: @@ -382,7 +380,7 @@ definitions: svcName: type: string - untunnelRequest: + unshareRequest: type: object properties: zId: diff --git a/ui/src/api/tunnel.js b/ui/src/api/service.js similarity index 54% rename from ui/src/api/tunnel.js rename to ui/src/api/service.js index 3451aa6a..bde776b1 100644 --- a/ui/src/api/tunnel.js +++ b/ui/src/api/service.js @@ -1,39 +1,39 @@ -/** @module tunnel */ +/** @module service */ // Auto-generated, edits will be overwritten import * as gateway from './gateway' /** * @param {object} options Optional options - * @param {module:types.tunnelRequest} [options.body] - * @return {Promise} tunnel created + * @param {module:types.shareRequest} [options.body] + * @return {Promise} service created */ -export function tunnel(options) { +export function share(options) { if (!options) options = {} const parameters = { body: { body: options.body } } - return gateway.request(tunnelOperation, parameters) + return gateway.request(shareOperation, parameters) } /** * @param {object} options Optional options - * @param {module:types.untunnelRequest} [options.body] - * @return {Promise} tunnel removed + * @param {module:types.unshareRequest} [options.body] + * @return {Promise} service removed */ -export function untunnel(options) { +export function unshare(options) { if (!options) options = {} const parameters = { body: { body: options.body } } - return gateway.request(untunnelOperation, parameters) + return gateway.request(unshareOperation, parameters) } -const tunnelOperation = { - path: '/tunnel', +const shareOperation = { + path: '/share', contentTypes: ['application/zrok.v1+json'], method: 'post', security: [ @@ -43,8 +43,8 @@ const tunnelOperation = { ] } -const untunnelOperation = { - path: '/untunnel', +const unshareOperation = { + path: '/unshare', contentTypes: ['application/zrok.v1+json'], method: 'delete', security: [ diff --git a/ui/src/api/types.js b/ui/src/api/types.js index 3104ed5f..6bf666e1 100644 --- a/ui/src/api/types.js +++ b/ui/src/api/types.js @@ -106,7 +106,7 @@ */ /** - * @typedef tunnelRequest + * @typedef shareRequest * @memberof module:types * * @property {string} zId @@ -116,7 +116,7 @@ */ /** - * @typedef tunnelResponse + * @typedef shareResponse * @memberof module:types * * @property {string} proxyEndpoint @@ -124,7 +124,7 @@ */ /** - * @typedef untunnelRequest + * @typedef unshareRequest * @memberof module:types * * @property {string} zId