update share backend (#125)

This commit is contained in:
Michael Quigley 2022-12-02 13:21:05 -05:00
parent d2cf19188a
commit 135fd483fa
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
15 changed files with 1081 additions and 9 deletions

View File

@ -44,6 +44,7 @@ func Run(inCfg *Config) error {
api.ServiceShareHandler = newShareHandler()
api.ServiceUnaccessHandler = newUnaccessHandler()
api.ServiceUnshareHandler = newUnshareHandler()
api.ServiceUpdateShareHandler = newUpdateShareHandler()
if err := controllerStartup(); err != nil {
return err

View File

@ -0,0 +1,63 @@
package controller
import (
"github.com/go-openapi/runtime/middleware"
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/service"
"github.com/sirupsen/logrus"
)
type updateShareHandler struct{}
func newUpdateShareHandler() *updateShareHandler {
return &updateShareHandler{}
}
func (h *updateShareHandler) Handle(params service.UpdateShareParams, principal *rest_model_zrok.Principal) middleware.Responder {
svcToken := params.Body.ServiceToken
backendProxyEndpoint := params.Body.BackendProxyEndpoint
tx, err := str.Begin()
if err != nil {
logrus.Errorf("error starting transaction: %v", err)
return service.NewUpdateShareInternalServerError()
}
defer func() { _ = tx.Rollback() }()
ssvc, err := str.FindServiceWithToken(svcToken, tx)
if err != nil {
logrus.Errorf("service '%v' not found: %v", svcToken, err)
return service.NewUpdateShareNotFound()
}
senvs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx)
if err != nil {
logrus.Errorf("error finding environments for account '%v': %v", principal.Email, err)
return service.NewUpdateShareInternalServerError()
}
envFound := false
for _, senv := range senvs {
if senv.Id == ssvc.Id {
envFound = true
break
}
}
if !envFound {
logrus.Errorf("environment not found for service '%v'", svcToken)
return service.NewUpdateShareNotFound()
}
ssvc.BackendProxyEndpoint = &backendProxyEndpoint
if err := str.UpdateService(ssvc, tx); err != nil {
logrus.Errorf("error updating service '%v': %v", svcToken, err)
return service.NewUpdateShareInternalServerError()
}
if err := tx.Commit(); err != nil {
logrus.Errorf("error committing transaction for service '%v' update: %v", svcToken, err)
return service.NewUpdateShareInternalServerError()
}
return service.NewUpdateShareOK()
}

View File

@ -40,6 +40,8 @@ type ClientService interface {
Unshare(params *UnshareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnshareOK, error)
UpdateShare(params *UpdateShareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateShareOK, error)
SetTransport(transport runtime.ClientTransport)
}
@ -238,6 +240,45 @@ func (a *Client) Unshare(params *UnshareParams, authInfo runtime.ClientAuthInfoW
panic(msg)
}
/*
UpdateShare update share API
*/
func (a *Client) UpdateShare(params *UpdateShareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateShareOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewUpdateShareParams()
}
op := &runtime.ClientOperation{
ID: "updateShare",
Method: "PATCH",
PathPattern: "/share",
ProducesMediaTypes: []string{"application/zrok.v1+json"},
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
Schemes: []string{"http"},
Params: params,
Reader: &UpdateShareReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*UpdateShareOK)
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 updateShare: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport

View File

@ -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"
)
// NewUpdateShareParams creates a new UpdateShareParams 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 NewUpdateShareParams() *UpdateShareParams {
return &UpdateShareParams{
timeout: cr.DefaultTimeout,
}
}
// NewUpdateShareParamsWithTimeout creates a new UpdateShareParams object
// with the ability to set a timeout on a request.
func NewUpdateShareParamsWithTimeout(timeout time.Duration) *UpdateShareParams {
return &UpdateShareParams{
timeout: timeout,
}
}
// NewUpdateShareParamsWithContext creates a new UpdateShareParams object
// with the ability to set a context for a request.
func NewUpdateShareParamsWithContext(ctx context.Context) *UpdateShareParams {
return &UpdateShareParams{
Context: ctx,
}
}
// NewUpdateShareParamsWithHTTPClient creates a new UpdateShareParams object
// with the ability to set a custom HTTPClient for a request.
func NewUpdateShareParamsWithHTTPClient(client *http.Client) *UpdateShareParams {
return &UpdateShareParams{
HTTPClient: client,
}
}
/*
UpdateShareParams contains all the parameters to send to the API endpoint
for the update share operation.
Typically these are written to a http.Request.
*/
type UpdateShareParams struct {
// Body.
Body *rest_model_zrok.UpdateShareRequest
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the update share params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateShareParams) WithDefaults() *UpdateShareParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the update share params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateShareParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the update share params
func (o *UpdateShareParams) WithTimeout(timeout time.Duration) *UpdateShareParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the update share params
func (o *UpdateShareParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the update share params
func (o *UpdateShareParams) WithContext(ctx context.Context) *UpdateShareParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the update share params
func (o *UpdateShareParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the update share params
func (o *UpdateShareParams) WithHTTPClient(client *http.Client) *UpdateShareParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the update share params
func (o *UpdateShareParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the update share params
func (o *UpdateShareParams) WithBody(body *rest_model_zrok.UpdateShareRequest) *UpdateShareParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the update share params
func (o *UpdateShareParams) SetBody(body *rest_model_zrok.UpdateShareRequest) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *UpdateShareParams) 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
}

View File

@ -0,0 +1,254 @@
// 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"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
)
// UpdateShareReader is a Reader for the UpdateShare structure.
type UpdateShareReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *UpdateShareReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewUpdateShareOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 401:
result := NewUpdateShareUnauthorized()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 404:
result := NewUpdateShareNotFound()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 500:
result := NewUpdateShareInternalServerError()
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())
}
}
// NewUpdateShareOK creates a UpdateShareOK with default headers values
func NewUpdateShareOK() *UpdateShareOK {
return &UpdateShareOK{}
}
/*
UpdateShareOK describes a response with status code 200, with default header values.
service updated
*/
type UpdateShareOK struct {
}
// IsSuccess returns true when this update share o k response has a 2xx status code
func (o *UpdateShareOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this update share o k response has a 3xx status code
func (o *UpdateShareOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this update share o k response has a 4xx status code
func (o *UpdateShareOK) IsClientError() bool {
return false
}
// IsServerError returns true when this update share o k response has a 5xx status code
func (o *UpdateShareOK) IsServerError() bool {
return false
}
// IsCode returns true when this update share o k response a status code equal to that given
func (o *UpdateShareOK) IsCode(code int) bool {
return code == 200
}
func (o *UpdateShareOK) Error() string {
return fmt.Sprintf("[PATCH /share][%d] updateShareOK ", 200)
}
func (o *UpdateShareOK) String() string {
return fmt.Sprintf("[PATCH /share][%d] updateShareOK ", 200)
}
func (o *UpdateShareOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewUpdateShareUnauthorized creates a UpdateShareUnauthorized with default headers values
func NewUpdateShareUnauthorized() *UpdateShareUnauthorized {
return &UpdateShareUnauthorized{}
}
/*
UpdateShareUnauthorized describes a response with status code 401, with default header values.
unauthorized
*/
type UpdateShareUnauthorized struct {
}
// IsSuccess returns true when this update share unauthorized response has a 2xx status code
func (o *UpdateShareUnauthorized) IsSuccess() bool {
return false
}
// IsRedirect returns true when this update share unauthorized response has a 3xx status code
func (o *UpdateShareUnauthorized) IsRedirect() bool {
return false
}
// IsClientError returns true when this update share unauthorized response has a 4xx status code
func (o *UpdateShareUnauthorized) IsClientError() bool {
return true
}
// IsServerError returns true when this update share unauthorized response has a 5xx status code
func (o *UpdateShareUnauthorized) IsServerError() bool {
return false
}
// IsCode returns true when this update share unauthorized response a status code equal to that given
func (o *UpdateShareUnauthorized) IsCode(code int) bool {
return code == 401
}
func (o *UpdateShareUnauthorized) Error() string {
return fmt.Sprintf("[PATCH /share][%d] updateShareUnauthorized ", 401)
}
func (o *UpdateShareUnauthorized) String() string {
return fmt.Sprintf("[PATCH /share][%d] updateShareUnauthorized ", 401)
}
func (o *UpdateShareUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewUpdateShareNotFound creates a UpdateShareNotFound with default headers values
func NewUpdateShareNotFound() *UpdateShareNotFound {
return &UpdateShareNotFound{}
}
/*
UpdateShareNotFound describes a response with status code 404, with default header values.
not found
*/
type UpdateShareNotFound struct {
}
// IsSuccess returns true when this update share not found response has a 2xx status code
func (o *UpdateShareNotFound) IsSuccess() bool {
return false
}
// IsRedirect returns true when this update share not found response has a 3xx status code
func (o *UpdateShareNotFound) IsRedirect() bool {
return false
}
// IsClientError returns true when this update share not found response has a 4xx status code
func (o *UpdateShareNotFound) IsClientError() bool {
return true
}
// IsServerError returns true when this update share not found response has a 5xx status code
func (o *UpdateShareNotFound) IsServerError() bool {
return false
}
// IsCode returns true when this update share not found response a status code equal to that given
func (o *UpdateShareNotFound) IsCode(code int) bool {
return code == 404
}
func (o *UpdateShareNotFound) Error() string {
return fmt.Sprintf("[PATCH /share][%d] updateShareNotFound ", 404)
}
func (o *UpdateShareNotFound) String() string {
return fmt.Sprintf("[PATCH /share][%d] updateShareNotFound ", 404)
}
func (o *UpdateShareNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewUpdateShareInternalServerError creates a UpdateShareInternalServerError with default headers values
func NewUpdateShareInternalServerError() *UpdateShareInternalServerError {
return &UpdateShareInternalServerError{}
}
/*
UpdateShareInternalServerError describes a response with status code 500, with default header values.
internal server error
*/
type UpdateShareInternalServerError struct {
}
// IsSuccess returns true when this update share internal server error response has a 2xx status code
func (o *UpdateShareInternalServerError) IsSuccess() bool {
return false
}
// IsRedirect returns true when this update share internal server error response has a 3xx status code
func (o *UpdateShareInternalServerError) IsRedirect() bool {
return false
}
// IsClientError returns true when this update share internal server error response has a 4xx status code
func (o *UpdateShareInternalServerError) IsClientError() bool {
return false
}
// IsServerError returns true when this update share internal server error response has a 5xx status code
func (o *UpdateShareInternalServerError) IsServerError() bool {
return true
}
// IsCode returns true when this update share internal server error response a status code equal to that given
func (o *UpdateShareInternalServerError) IsCode(code int) bool {
return code == 500
}
func (o *UpdateShareInternalServerError) Error() string {
return fmt.Sprintf("[PATCH /share][%d] updateShareInternalServerError ", 500)
}
func (o *UpdateShareInternalServerError) String() string {
return fmt.Sprintf("[PATCH /share][%d] updateShareInternalServerError ", 500)
}
func (o *UpdateShareInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}

View File

@ -0,0 +1,53 @@
// Code generated by go-swagger; DO NOT EDIT.
package rest_model_zrok
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// UpdateShareRequest update share request
//
// swagger:model updateShareRequest
type UpdateShareRequest struct {
// backend proxy endpoint
BackendProxyEndpoint string `json:"backendProxyEndpoint,omitempty"`
// service token
ServiceToken string `json:"serviceToken,omitempty"`
}
// Validate validates this update share request
func (m *UpdateShareRequest) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this update share request based on context it is used
func (m *UpdateShareRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *UpdateShareRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *UpdateShareRequest) UnmarshalBinary(b []byte) error {
var res UpdateShareRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -470,6 +470,40 @@ func init() {
}
}
}
},
"patch": {
"security": [
{
"key": []
}
],
"tags": [
"service"
],
"operationId": "updateShare",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/updateShareRequest"
}
}
],
"responses": {
"200": {
"description": "service updated"
},
"401": {
"description": "unauthorized"
},
"404": {
"description": "not found"
},
"500": {
"description": "internal server error"
}
}
}
},
"/unaccess": {
@ -983,6 +1017,17 @@ func init() {
}
}
},
"updateShareRequest": {
"type": "object",
"properties": {
"backendProxyEndpoint": {
"type": "string"
},
"serviceToken": {
"type": "string"
}
}
},
"verifyRequest": {
"type": "object",
"properties": {
@ -1464,6 +1509,40 @@ func init() {
}
}
}
},
"patch": {
"security": [
{
"key": []
}
],
"tags": [
"service"
],
"operationId": "updateShare",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/updateShareRequest"
}
}
],
"responses": {
"200": {
"description": "service updated"
},
"401": {
"description": "unauthorized"
},
"404": {
"description": "not found"
},
"500": {
"description": "internal server error"
}
}
}
},
"/unaccess": {
@ -1977,6 +2056,17 @@ func init() {
}
}
},
"updateShareRequest": {
"type": "object",
"properties": {
"backendProxyEndpoint": {
"type": "string"
},
"serviceToken": {
"type": "string"
}
}
},
"verifyRequest": {
"type": "object",
"properties": {

View File

@ -0,0 +1,71 @@
// 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 generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
)
// UpdateShareHandlerFunc turns a function with the right signature into a update share handler
type UpdateShareHandlerFunc func(UpdateShareParams, *rest_model_zrok.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn UpdateShareHandlerFunc) Handle(params UpdateShareParams, principal *rest_model_zrok.Principal) middleware.Responder {
return fn(params, principal)
}
// UpdateShareHandler interface for that can handle valid update share params
type UpdateShareHandler interface {
Handle(UpdateShareParams, *rest_model_zrok.Principal) middleware.Responder
}
// NewUpdateShare creates a new http.Handler for the update share operation
func NewUpdateShare(ctx *middleware.Context, handler UpdateShareHandler) *UpdateShare {
return &UpdateShare{Context: ctx, Handler: handler}
}
/*
UpdateShare swagger:route PATCH /share service updateShare
UpdateShare update share API
*/
type UpdateShare struct {
Context *middleware.Context
Handler UpdateShareHandler
}
func (o *UpdateShare) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewUpdateShareParams()
uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
if aCtx != nil {
*r = *aCtx
}
var principal *rest_model_zrok.Principal
if uprinc != nil {
principal = uprinc.(*rest_model_zrok.Principal) // this is really a rest_model_zrok.Principal, I promise
}
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params, principal) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@ -0,0 +1,76 @@
// 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/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/validate"
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
)
// NewUpdateShareParams creates a new UpdateShareParams object
//
// There are no default values defined in the spec.
func NewUpdateShareParams() UpdateShareParams {
return UpdateShareParams{}
}
// UpdateShareParams contains all the bound params for the update share operation
// typically these are obtained from a http.Request
//
// swagger:parameters updateShare
type UpdateShareParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
In: body
*/
Body *rest_model_zrok.UpdateShareRequest
}
// 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 NewUpdateShareParams() beforehand.
func (o *UpdateShareParams) 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.UpdateShareRequest
if err := route.Consumer.Consume(r.Body, &body); err != nil {
res = append(res, errors.NewParseError("body", "body", "", err))
} else {
// validate body object
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
ctx := validate.WithOperationRequest(r.Context())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Body = &body
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,112 @@
// 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"
)
// UpdateShareOKCode is the HTTP code returned for type UpdateShareOK
const UpdateShareOKCode int = 200
/*
UpdateShareOK service updated
swagger:response updateShareOK
*/
type UpdateShareOK struct {
}
// NewUpdateShareOK creates UpdateShareOK with default headers values
func NewUpdateShareOK() *UpdateShareOK {
return &UpdateShareOK{}
}
// WriteResponse to the client
func (o *UpdateShareOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(200)
}
// UpdateShareUnauthorizedCode is the HTTP code returned for type UpdateShareUnauthorized
const UpdateShareUnauthorizedCode int = 401
/*
UpdateShareUnauthorized unauthorized
swagger:response updateShareUnauthorized
*/
type UpdateShareUnauthorized struct {
}
// NewUpdateShareUnauthorized creates UpdateShareUnauthorized with default headers values
func NewUpdateShareUnauthorized() *UpdateShareUnauthorized {
return &UpdateShareUnauthorized{}
}
// WriteResponse to the client
func (o *UpdateShareUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(401)
}
// UpdateShareNotFoundCode is the HTTP code returned for type UpdateShareNotFound
const UpdateShareNotFoundCode int = 404
/*
UpdateShareNotFound not found
swagger:response updateShareNotFound
*/
type UpdateShareNotFound struct {
}
// NewUpdateShareNotFound creates UpdateShareNotFound with default headers values
func NewUpdateShareNotFound() *UpdateShareNotFound {
return &UpdateShareNotFound{}
}
// WriteResponse to the client
func (o *UpdateShareNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(404)
}
// UpdateShareInternalServerErrorCode is the HTTP code returned for type UpdateShareInternalServerError
const UpdateShareInternalServerErrorCode int = 500
/*
UpdateShareInternalServerError internal server error
swagger:response updateShareInternalServerError
*/
type UpdateShareInternalServerError struct {
}
// NewUpdateShareInternalServerError creates UpdateShareInternalServerError with default headers values
func NewUpdateShareInternalServerError() *UpdateShareInternalServerError {
return &UpdateShareInternalServerError{}
}
// WriteResponse to the client
func (o *UpdateShareInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(500)
}

View File

@ -0,0 +1,87 @@
// 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 generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
)
// UpdateShareURL generates an URL for the update share operation
type UpdateShareURL 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 *UpdateShareURL) WithBasePath(bp string) *UpdateShareURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *UpdateShareURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *UpdateShareURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/share"
_basePath := o._basePath
if _basePath == "" {
_basePath = "/api/v1"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *UpdateShareURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *UpdateShareURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *UpdateShareURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on UpdateShareURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on UpdateShareURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *UpdateShareURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@ -94,6 +94,9 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
AdminUpdateFrontendHandler: admin.UpdateFrontendHandlerFunc(func(params admin.UpdateFrontendParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation admin.UpdateFrontend has not yet been implemented")
}),
ServiceUpdateShareHandler: service.UpdateShareHandlerFunc(func(params service.UpdateShareParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation service.UpdateShare has not yet been implemented")
}),
AccountVerifyHandler: account.VerifyHandlerFunc(func(params account.VerifyParams) middleware.Responder {
return middleware.NotImplemented("operation account.Verify has not yet been implemented")
}),
@ -180,6 +183,8 @@ type ZrokAPI struct {
ServiceUnshareHandler service.UnshareHandler
// AdminUpdateFrontendHandler sets the operation handler for the update frontend operation
AdminUpdateFrontendHandler admin.UpdateFrontendHandler
// ServiceUpdateShareHandler sets the operation handler for the update share operation
ServiceUpdateShareHandler service.UpdateShareHandler
// AccountVerifyHandler sets the operation handler for the verify operation
AccountVerifyHandler account.VerifyHandler
// MetadataVersionHandler sets the operation handler for the version operation
@ -310,6 +315,9 @@ func (o *ZrokAPI) Validate() error {
if o.AdminUpdateFrontendHandler == nil {
unregistered = append(unregistered, "admin.UpdateFrontendHandler")
}
if o.ServiceUpdateShareHandler == nil {
unregistered = append(unregistered, "service.UpdateShareHandler")
}
if o.AccountVerifyHandler == nil {
unregistered = append(unregistered, "account.VerifyHandler")
}
@ -475,6 +483,10 @@ func (o *ZrokAPI) initHandlerCache() {
o.handlers["PATCH"] = make(map[string]http.Handler)
}
o.handlers["PATCH"]["/frontend"] = admin.NewUpdateFrontend(o.context, o.AdminUpdateFrontendHandler)
if o.handlers["PATCH"] == nil {
o.handlers["PATCH"] = make(map[string]http.Handler)
}
o.handlers["PATCH"]["/share"] = service.NewUpdateShare(o.context, o.ServiceUpdateShareHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}

View File

@ -325,6 +325,26 @@ paths:
description: internal server error
schema:
$ref: "#/definitions/errorMessage"
patch:
tags:
- service
security:
- key: []
operationId: updateShare
parameters:
- name: body
in: body
schema:
$ref: "#/definitions/updateShareRequest"
responses:
200:
description: service updated
401:
description: unauthorized
404:
description: not found
500:
description: internal server error
/unaccess:
delete:
@ -630,6 +650,16 @@ definitions:
svcToken:
type: string
unshareRequest:
type: object
properties:
envZId:
type: string
svcToken:
type: string
reserved:
type: boolean
updateFrontendRequest:
type: object
properties:
@ -640,15 +670,13 @@ definitions:
urlTemplate:
type: string
unshareRequest:
updateShareRequest:
type: object
properties:
envZId:
serviceToken:
type: string
svcToken:
backendProxyEndpoint:
type: string
reserved:
type: boolean
verifyRequest:
type: object

View File

@ -47,6 +47,21 @@ export function share(options) {
return gateway.request(shareOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.updateShareRequest} [options.body]
* @return {Promise<object>} service updated
*/
export function updateShare(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(updateShareOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.unaccessRequest} [options.body]
@ -110,6 +125,17 @@ const shareOperation = {
]
}
const updateShareOperation = {
path: '/share',
contentTypes: ['application/zrok.v1+json'],
method: 'patch',
security: [
{
id: 'key'
}
]
}
const unaccessOperation = {
path: '/unaccess',
contentTypes: ['application/zrok.v1+json'],

View File

@ -199,6 +199,15 @@
* @property {string} svcToken
*/
/**
* @typedef unshareRequest
* @memberof module:types
*
* @property {string} envZId
* @property {string} svcToken
* @property {boolean} reserved
*/
/**
* @typedef updateFrontendRequest
* @memberof module:types
@ -209,12 +218,11 @@
*/
/**
* @typedef unshareRequest
* @typedef updateShareRequest
* @memberof module:types
*
* @property {string} envZId
* @property {string} svcToken
* @property {boolean} reserved
* @property {string} serviceToken
* @property {string} backendProxyEndpoint
*/
/**