mirror of
https://github.com/openziti/zrok.git
synced 2024-11-21 23:53:19 +01:00
update frontend backend (#129)
This commit is contained in:
parent
9ab7eeebf3
commit
38c83fda92
@ -34,6 +34,7 @@ func Run(inCfg *Config) error {
|
||||
api.AdminCreateFrontendHandler = newCreateFrontendHandler()
|
||||
api.AdminDeleteFrontendHandler = newDeleteFrontendHandler()
|
||||
api.AdminListFrontendsHandler = newListFrontendsHandler()
|
||||
api.AdminUpdateFrontendHandler = newUpdateFrontendHandler()
|
||||
api.EnvironmentEnableHandler = newEnableHandler()
|
||||
api.EnvironmentDisableHandler = newDisableHandler()
|
||||
api.MetadataOverviewHandler = metadata.OverviewHandlerFunc(overviewHandler)
|
||||
|
@ -95,6 +95,19 @@ func (str *Store) FindPublicFrontends(tx *sqlx.Tx) ([]*Frontend, error) {
|
||||
return frontends, nil
|
||||
}
|
||||
|
||||
func (str *Store) UpdateFrontend(fe *Frontend, tx *sqlx.Tx) error {
|
||||
sql := "update frontends set environment_id = $1, token = $2, z_id = $3, public_name = $4, url_template = $5, reserved = $6, updated_at = current_timestamp where id = $7"
|
||||
stmt, err := tx.Prepare(sql)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error preparing frontends update statement")
|
||||
}
|
||||
_, err = stmt.Exec(fe.EnvironmentId, fe.Token, fe.ZId, fe.PublicName, fe.UrlTemplate, fe.Reserved, fe.Id)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error executing frontends update statement")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (str *Store) DeleteFrontend(id int, tx *sqlx.Tx) error {
|
||||
|
||||
stmt, err := tx.Prepare("delete from frontends where id = $1")
|
||||
|
@ -79,7 +79,7 @@ func (self *Store) FindServicesForEnvironment(envId int, tx *sqlx.Tx) ([]*Servic
|
||||
}
|
||||
|
||||
func (self *Store) UpdateService(svc *Service, tx *sqlx.Tx) error {
|
||||
sql := "update services set z_id = $1, token = $2, share_mode = $3, backend_mode = $4, frontend_selection = $5, frontend_endpoint = $6, backend_proxy_endpoint = $7, reserved = $8, updated_at = strftime('%Y-%m-%d %H:%M:%f', 'now') where id = $9"
|
||||
sql := "update services set z_id = $1, token = $2, share_mode = $3, backend_mode = $4, frontend_selection = $5, frontend_endpoint = $6, backend_proxy_endpoint = $7, reserved = $8, updated_at = current_timestamp where id = $9"
|
||||
stmt, err := tx.Prepare(sql)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error preparing services update statement")
|
||||
|
70
controller/update_frontend.go
Normal file
70
controller/update_frontend.go
Normal file
@ -0,0 +1,70 @@
|
||||
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/admin"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type updateFrontendHandler struct{}
|
||||
|
||||
func newUpdateFrontendHandler() *updateFrontendHandler {
|
||||
return &updateFrontendHandler{}
|
||||
}
|
||||
|
||||
func (h *updateFrontendHandler) Handle(params admin.UpdateFrontendParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
feToken := params.Body.FrontendToken
|
||||
publicName := params.Body.PublicName
|
||||
urlTemplate := params.Body.URLTemplate
|
||||
|
||||
if !principal.Admin {
|
||||
logrus.Errorf("invalid admin principal")
|
||||
return admin.NewUpdateFrontendUnauthorized()
|
||||
}
|
||||
|
||||
tx, err := str.Begin()
|
||||
if err != nil {
|
||||
logrus.Errorf("error starting transaction: %v", err)
|
||||
return admin.NewUpdateFrontendInternalServerError()
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
fe, err := str.FindFrontendWithToken(feToken, tx)
|
||||
if err != nil {
|
||||
logrus.Errorf("error finding frontend with token '%v': %v", feToken, err)
|
||||
return admin.NewUpdateFrontendNotFound()
|
||||
}
|
||||
|
||||
doUpdate := false
|
||||
if (fe.PublicName == nil && publicName != "") || (fe.PublicName != nil && *fe.PublicName != publicName) {
|
||||
if publicName != "" {
|
||||
fe.PublicName = &publicName
|
||||
} else {
|
||||
fe.PublicName = nil
|
||||
}
|
||||
doUpdate = true
|
||||
}
|
||||
if (fe.UrlTemplate == nil && urlTemplate != "") || (fe.UrlTemplate != nil && *fe.UrlTemplate != urlTemplate) {
|
||||
if urlTemplate != "" {
|
||||
fe.UrlTemplate = &urlTemplate
|
||||
} else {
|
||||
fe.UrlTemplate = nil
|
||||
}
|
||||
doUpdate = true
|
||||
}
|
||||
|
||||
if doUpdate {
|
||||
if err := str.UpdateFrontend(fe, tx); err != nil {
|
||||
logrus.Errorf("error updating frontend: %v", err)
|
||||
return admin.NewUpdateFrontendInternalServerError()
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
logrus.Errorf("error commiting frontend update: %v", err)
|
||||
return admin.NewUpdateFrontendInternalServerError()
|
||||
}
|
||||
}
|
||||
|
||||
return admin.NewUpdateFrontendOK()
|
||||
}
|
@ -36,6 +36,8 @@ type ClientService interface {
|
||||
|
||||
ListFrontends(params *ListFrontendsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListFrontendsOK, error)
|
||||
|
||||
UpdateFrontend(params *UpdateFrontendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateFrontendOK, error)
|
||||
|
||||
SetTransport(transport runtime.ClientTransport)
|
||||
}
|
||||
|
||||
@ -156,6 +158,45 @@ func (a *Client) ListFrontends(params *ListFrontendsParams, authInfo runtime.Cli
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
UpdateFrontend update frontend API
|
||||
*/
|
||||
func (a *Client) UpdateFrontend(params *UpdateFrontendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateFrontendOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewUpdateFrontendParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "updateFrontend",
|
||||
Method: "PATCH",
|
||||
PathPattern: "/frontend",
|
||||
ProducesMediaTypes: []string{"application/zrok.v1+json"},
|
||||
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &UpdateFrontendReader{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.(*UpdateFrontendOK)
|
||||
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 updateFrontend: 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
|
||||
|
150
rest_client_zrok/admin/update_frontend_parameters.go
Normal file
150
rest_client_zrok/admin/update_frontend_parameters.go
Normal file
@ -0,0 +1,150 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// NewUpdateFrontendParams creates a new UpdateFrontendParams 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 NewUpdateFrontendParams() *UpdateFrontendParams {
|
||||
return &UpdateFrontendParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateFrontendParamsWithTimeout creates a new UpdateFrontendParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewUpdateFrontendParamsWithTimeout(timeout time.Duration) *UpdateFrontendParams {
|
||||
return &UpdateFrontendParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateFrontendParamsWithContext creates a new UpdateFrontendParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewUpdateFrontendParamsWithContext(ctx context.Context) *UpdateFrontendParams {
|
||||
return &UpdateFrontendParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateFrontendParamsWithHTTPClient creates a new UpdateFrontendParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewUpdateFrontendParamsWithHTTPClient(client *http.Client) *UpdateFrontendParams {
|
||||
return &UpdateFrontendParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
UpdateFrontendParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the update frontend operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type UpdateFrontendParams struct {
|
||||
|
||||
// Body.
|
||||
Body *rest_model_zrok.UpdateFrontendRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the update frontend params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *UpdateFrontendParams) WithDefaults() *UpdateFrontendParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the update frontend params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *UpdateFrontendParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the update frontend params
|
||||
func (o *UpdateFrontendParams) WithTimeout(timeout time.Duration) *UpdateFrontendParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the update frontend params
|
||||
func (o *UpdateFrontendParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the update frontend params
|
||||
func (o *UpdateFrontendParams) WithContext(ctx context.Context) *UpdateFrontendParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the update frontend params
|
||||
func (o *UpdateFrontendParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the update frontend params
|
||||
func (o *UpdateFrontendParams) WithHTTPClient(client *http.Client) *UpdateFrontendParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the update frontend params
|
||||
func (o *UpdateFrontendParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the update frontend params
|
||||
func (o *UpdateFrontendParams) WithBody(body *rest_model_zrok.UpdateFrontendRequest) *UpdateFrontendParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the update frontend params
|
||||
func (o *UpdateFrontendParams) SetBody(body *rest_model_zrok.UpdateFrontendRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *UpdateFrontendParams) 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
|
||||
}
|
254
rest_client_zrok/admin/update_frontend_responses.go
Normal file
254
rest_client_zrok/admin/update_frontend_responses.go
Normal file
@ -0,0 +1,254 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// UpdateFrontendReader is a Reader for the UpdateFrontend structure.
|
||||
type UpdateFrontendReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *UpdateFrontendReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewUpdateFrontendOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 401:
|
||||
result := NewUpdateFrontendUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 404:
|
||||
result := NewUpdateFrontendNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 500:
|
||||
result := NewUpdateFrontendInternalServerError()
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateFrontendOK creates a UpdateFrontendOK with default headers values
|
||||
func NewUpdateFrontendOK() *UpdateFrontendOK {
|
||||
return &UpdateFrontendOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
UpdateFrontendOK describes a response with status code 200, with default header values.
|
||||
|
||||
frontend updated
|
||||
*/
|
||||
type UpdateFrontendOK struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this update frontend o k response has a 2xx status code
|
||||
func (o *UpdateFrontendOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this update frontend o k response has a 3xx status code
|
||||
func (o *UpdateFrontendOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this update frontend o k response has a 4xx status code
|
||||
func (o *UpdateFrontendOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this update frontend o k response has a 5xx status code
|
||||
func (o *UpdateFrontendOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this update frontend o k response a status code equal to that given
|
||||
func (o *UpdateFrontendOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
func (o *UpdateFrontendOK) Error() string {
|
||||
return fmt.Sprintf("[PATCH /frontend][%d] updateFrontendOK ", 200)
|
||||
}
|
||||
|
||||
func (o *UpdateFrontendOK) String() string {
|
||||
return fmt.Sprintf("[PATCH /frontend][%d] updateFrontendOK ", 200)
|
||||
}
|
||||
|
||||
func (o *UpdateFrontendOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewUpdateFrontendUnauthorized creates a UpdateFrontendUnauthorized with default headers values
|
||||
func NewUpdateFrontendUnauthorized() *UpdateFrontendUnauthorized {
|
||||
return &UpdateFrontendUnauthorized{}
|
||||
}
|
||||
|
||||
/*
|
||||
UpdateFrontendUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
unauthorized
|
||||
*/
|
||||
type UpdateFrontendUnauthorized struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this update frontend unauthorized response has a 2xx status code
|
||||
func (o *UpdateFrontendUnauthorized) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this update frontend unauthorized response has a 3xx status code
|
||||
func (o *UpdateFrontendUnauthorized) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this update frontend unauthorized response has a 4xx status code
|
||||
func (o *UpdateFrontendUnauthorized) IsClientError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsServerError returns true when this update frontend unauthorized response has a 5xx status code
|
||||
func (o *UpdateFrontendUnauthorized) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this update frontend unauthorized response a status code equal to that given
|
||||
func (o *UpdateFrontendUnauthorized) IsCode(code int) bool {
|
||||
return code == 401
|
||||
}
|
||||
|
||||
func (o *UpdateFrontendUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[PATCH /frontend][%d] updateFrontendUnauthorized ", 401)
|
||||
}
|
||||
|
||||
func (o *UpdateFrontendUnauthorized) String() string {
|
||||
return fmt.Sprintf("[PATCH /frontend][%d] updateFrontendUnauthorized ", 401)
|
||||
}
|
||||
|
||||
func (o *UpdateFrontendUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewUpdateFrontendNotFound creates a UpdateFrontendNotFound with default headers values
|
||||
func NewUpdateFrontendNotFound() *UpdateFrontendNotFound {
|
||||
return &UpdateFrontendNotFound{}
|
||||
}
|
||||
|
||||
/*
|
||||
UpdateFrontendNotFound describes a response with status code 404, with default header values.
|
||||
|
||||
not found
|
||||
*/
|
||||
type UpdateFrontendNotFound struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this update frontend not found response has a 2xx status code
|
||||
func (o *UpdateFrontendNotFound) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this update frontend not found response has a 3xx status code
|
||||
func (o *UpdateFrontendNotFound) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this update frontend not found response has a 4xx status code
|
||||
func (o *UpdateFrontendNotFound) IsClientError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsServerError returns true when this update frontend not found response has a 5xx status code
|
||||
func (o *UpdateFrontendNotFound) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this update frontend not found response a status code equal to that given
|
||||
func (o *UpdateFrontendNotFound) IsCode(code int) bool {
|
||||
return code == 404
|
||||
}
|
||||
|
||||
func (o *UpdateFrontendNotFound) Error() string {
|
||||
return fmt.Sprintf("[PATCH /frontend][%d] updateFrontendNotFound ", 404)
|
||||
}
|
||||
|
||||
func (o *UpdateFrontendNotFound) String() string {
|
||||
return fmt.Sprintf("[PATCH /frontend][%d] updateFrontendNotFound ", 404)
|
||||
}
|
||||
|
||||
func (o *UpdateFrontendNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewUpdateFrontendInternalServerError creates a UpdateFrontendInternalServerError with default headers values
|
||||
func NewUpdateFrontendInternalServerError() *UpdateFrontendInternalServerError {
|
||||
return &UpdateFrontendInternalServerError{}
|
||||
}
|
||||
|
||||
/*
|
||||
UpdateFrontendInternalServerError describes a response with status code 500, with default header values.
|
||||
|
||||
internal server error
|
||||
*/
|
||||
type UpdateFrontendInternalServerError struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this update frontend internal server error response has a 2xx status code
|
||||
func (o *UpdateFrontendInternalServerError) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this update frontend internal server error response has a 3xx status code
|
||||
func (o *UpdateFrontendInternalServerError) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this update frontend internal server error response has a 4xx status code
|
||||
func (o *UpdateFrontendInternalServerError) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this update frontend internal server error response has a 5xx status code
|
||||
func (o *UpdateFrontendInternalServerError) IsServerError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsCode returns true when this update frontend internal server error response a status code equal to that given
|
||||
func (o *UpdateFrontendInternalServerError) IsCode(code int) bool {
|
||||
return code == 500
|
||||
}
|
||||
|
||||
func (o *UpdateFrontendInternalServerError) Error() string {
|
||||
return fmt.Sprintf("[PATCH /frontend][%d] updateFrontendInternalServerError ", 500)
|
||||
}
|
||||
|
||||
func (o *UpdateFrontendInternalServerError) String() string {
|
||||
return fmt.Sprintf("[PATCH /frontend][%d] updateFrontendInternalServerError ", 500)
|
||||
}
|
||||
|
||||
func (o *UpdateFrontendInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
@ -18,19 +18,19 @@ import (
|
||||
type PublicFrontend struct {
|
||||
|
||||
// created at
|
||||
CreatedAt int64 `json:"created_at,omitempty"`
|
||||
CreatedAt int64 `json:"createdAt,omitempty"`
|
||||
|
||||
// public name
|
||||
PublicName string `json:"public_name,omitempty"`
|
||||
PublicName string `json:"publicName,omitempty"`
|
||||
|
||||
// token
|
||||
Token string `json:"token,omitempty"`
|
||||
|
||||
// updated at
|
||||
UpdatedAt int64 `json:"updated_at,omitempty"`
|
||||
UpdatedAt int64 `json:"updatedAt,omitempty"`
|
||||
|
||||
// url template
|
||||
URLTemplate string `json:"url_template,omitempty"`
|
||||
URLTemplate string `json:"urlTemplate,omitempty"`
|
||||
|
||||
// z Id
|
||||
ZID string `json:"zId,omitempty"`
|
||||
|
56
rest_model_zrok/update_frontend_request.go
Normal file
56
rest_model_zrok/update_frontend_request.go
Normal file
@ -0,0 +1,56 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// UpdateFrontendRequest update frontend request
|
||||
//
|
||||
// swagger:model updateFrontendRequest
|
||||
type UpdateFrontendRequest struct {
|
||||
|
||||
// frontend token
|
||||
FrontendToken string `json:"frontendToken,omitempty"`
|
||||
|
||||
// public name
|
||||
PublicName string `json:"publicName,omitempty"`
|
||||
|
||||
// url template
|
||||
URLTemplate string `json:"urlTemplate,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this update frontend request
|
||||
func (m *UpdateFrontendRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this update frontend request based on context it is used
|
||||
func (m *UpdateFrontendRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *UpdateFrontendRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *UpdateFrontendRequest) UnmarshalBinary(b []byte) error {
|
||||
var res UpdateFrontendRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
@ -217,6 +217,40 @@ func init() {
|
||||
"description": "internal server error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"patch": {
|
||||
"security": [
|
||||
{
|
||||
"key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"operationId": "updateFrontend",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/updateFrontendRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "frontend updated"
|
||||
},
|
||||
"401": {
|
||||
"description": "unauthorized"
|
||||
},
|
||||
"404": {
|
||||
"description": "not found"
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/frontends": {
|
||||
@ -746,19 +780,19 @@ func init() {
|
||||
"publicFrontend": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"createdAt": {
|
||||
"type": "integer"
|
||||
},
|
||||
"public_name": {
|
||||
"publicName": {
|
||||
"type": "string"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"updated_at": {
|
||||
"updatedAt": {
|
||||
"type": "integer"
|
||||
},
|
||||
"url_template": {
|
||||
"urlTemplate": {
|
||||
"type": "string"
|
||||
},
|
||||
"zId": {
|
||||
@ -935,6 +969,20 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateFrontendRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"frontendToken": {
|
||||
"type": "string"
|
||||
},
|
||||
"publicName": {
|
||||
"type": "string"
|
||||
},
|
||||
"urlTemplate": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"verifyRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -1163,6 +1211,40 @@ func init() {
|
||||
"description": "internal server error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"patch": {
|
||||
"security": [
|
||||
{
|
||||
"key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"operationId": "updateFrontend",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/updateFrontendRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "frontend updated"
|
||||
},
|
||||
"401": {
|
||||
"description": "unauthorized"
|
||||
},
|
||||
"404": {
|
||||
"description": "not found"
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/frontends": {
|
||||
@ -1692,19 +1774,19 @@ func init() {
|
||||
"publicFrontend": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"createdAt": {
|
||||
"type": "integer"
|
||||
},
|
||||
"public_name": {
|
||||
"publicName": {
|
||||
"type": "string"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"updated_at": {
|
||||
"updatedAt": {
|
||||
"type": "integer"
|
||||
},
|
||||
"url_template": {
|
||||
"urlTemplate": {
|
||||
"type": "string"
|
||||
},
|
||||
"zId": {
|
||||
@ -1881,6 +1963,20 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateFrontendRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"frontendToken": {
|
||||
"type": "string"
|
||||
},
|
||||
"publicName": {
|
||||
"type": "string"
|
||||
},
|
||||
"urlTemplate": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"verifyRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
71
rest_server_zrok/operations/admin/update_frontend.go
Normal file
71
rest_server_zrok/operations/admin/update_frontend.go
Normal file
@ -0,0 +1,71 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// UpdateFrontendHandlerFunc turns a function with the right signature into a update frontend handler
|
||||
type UpdateFrontendHandlerFunc func(UpdateFrontendParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn UpdateFrontendHandlerFunc) Handle(params UpdateFrontendParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// UpdateFrontendHandler interface for that can handle valid update frontend params
|
||||
type UpdateFrontendHandler interface {
|
||||
Handle(UpdateFrontendParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewUpdateFrontend creates a new http.Handler for the update frontend operation
|
||||
func NewUpdateFrontend(ctx *middleware.Context, handler UpdateFrontendHandler) *UpdateFrontend {
|
||||
return &UpdateFrontend{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
UpdateFrontend swagger:route PATCH /frontend admin updateFrontend
|
||||
|
||||
UpdateFrontend update frontend API
|
||||
*/
|
||||
type UpdateFrontend struct {
|
||||
Context *middleware.Context
|
||||
Handler UpdateFrontendHandler
|
||||
}
|
||||
|
||||
func (o *UpdateFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewUpdateFrontendParams()
|
||||
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)
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// NewUpdateFrontendParams creates a new UpdateFrontendParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewUpdateFrontendParams() UpdateFrontendParams {
|
||||
|
||||
return UpdateFrontendParams{}
|
||||
}
|
||||
|
||||
// UpdateFrontendParams contains all the bound params for the update frontend operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters updateFrontend
|
||||
type UpdateFrontendParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
In: body
|
||||
*/
|
||||
Body *rest_model_zrok.UpdateFrontendRequest
|
||||
}
|
||||
|
||||
// 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 NewUpdateFrontendParams() beforehand.
|
||||
func (o *UpdateFrontendParams) 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.UpdateFrontendRequest
|
||||
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
|
||||
}
|
112
rest_server_zrok/operations/admin/update_frontend_responses.go
Normal file
112
rest_server_zrok/operations/admin/update_frontend_responses.go
Normal file
@ -0,0 +1,112 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// UpdateFrontendOKCode is the HTTP code returned for type UpdateFrontendOK
|
||||
const UpdateFrontendOKCode int = 200
|
||||
|
||||
/*
|
||||
UpdateFrontendOK frontend updated
|
||||
|
||||
swagger:response updateFrontendOK
|
||||
*/
|
||||
type UpdateFrontendOK struct {
|
||||
}
|
||||
|
||||
// NewUpdateFrontendOK creates UpdateFrontendOK with default headers values
|
||||
func NewUpdateFrontendOK() *UpdateFrontendOK {
|
||||
|
||||
return &UpdateFrontendOK{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *UpdateFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(200)
|
||||
}
|
||||
|
||||
// UpdateFrontendUnauthorizedCode is the HTTP code returned for type UpdateFrontendUnauthorized
|
||||
const UpdateFrontendUnauthorizedCode int = 401
|
||||
|
||||
/*
|
||||
UpdateFrontendUnauthorized unauthorized
|
||||
|
||||
swagger:response updateFrontendUnauthorized
|
||||
*/
|
||||
type UpdateFrontendUnauthorized struct {
|
||||
}
|
||||
|
||||
// NewUpdateFrontendUnauthorized creates UpdateFrontendUnauthorized with default headers values
|
||||
func NewUpdateFrontendUnauthorized() *UpdateFrontendUnauthorized {
|
||||
|
||||
return &UpdateFrontendUnauthorized{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *UpdateFrontendUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(401)
|
||||
}
|
||||
|
||||
// UpdateFrontendNotFoundCode is the HTTP code returned for type UpdateFrontendNotFound
|
||||
const UpdateFrontendNotFoundCode int = 404
|
||||
|
||||
/*
|
||||
UpdateFrontendNotFound not found
|
||||
|
||||
swagger:response updateFrontendNotFound
|
||||
*/
|
||||
type UpdateFrontendNotFound struct {
|
||||
}
|
||||
|
||||
// NewUpdateFrontendNotFound creates UpdateFrontendNotFound with default headers values
|
||||
func NewUpdateFrontendNotFound() *UpdateFrontendNotFound {
|
||||
|
||||
return &UpdateFrontendNotFound{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *UpdateFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(404)
|
||||
}
|
||||
|
||||
// UpdateFrontendInternalServerErrorCode is the HTTP code returned for type UpdateFrontendInternalServerError
|
||||
const UpdateFrontendInternalServerErrorCode int = 500
|
||||
|
||||
/*
|
||||
UpdateFrontendInternalServerError internal server error
|
||||
|
||||
swagger:response updateFrontendInternalServerError
|
||||
*/
|
||||
type UpdateFrontendInternalServerError struct {
|
||||
}
|
||||
|
||||
// NewUpdateFrontendInternalServerError creates UpdateFrontendInternalServerError with default headers values
|
||||
func NewUpdateFrontendInternalServerError() *UpdateFrontendInternalServerError {
|
||||
|
||||
return &UpdateFrontendInternalServerError{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *UpdateFrontendInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(500)
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// UpdateFrontendURL generates an URL for the update frontend operation
|
||||
type UpdateFrontendURL 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 *UpdateFrontendURL) WithBasePath(bp string) *UpdateFrontendURL {
|
||||
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 *UpdateFrontendURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *UpdateFrontendURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/frontend"
|
||||
|
||||
_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 *UpdateFrontendURL) 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 *UpdateFrontendURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *UpdateFrontendURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on UpdateFrontendURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on UpdateFrontendURL")
|
||||
}
|
||||
|
||||
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 *UpdateFrontendURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
@ -91,6 +91,9 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
|
||||
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")
|
||||
}),
|
||||
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")
|
||||
}),
|
||||
AccountVerifyHandler: account.VerifyHandlerFunc(func(params account.VerifyParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation account.Verify has not yet been implemented")
|
||||
}),
|
||||
@ -175,6 +178,8 @@ type ZrokAPI struct {
|
||||
ServiceUnaccessHandler service.UnaccessHandler
|
||||
// ServiceUnshareHandler sets the operation handler for the unshare operation
|
||||
ServiceUnshareHandler service.UnshareHandler
|
||||
// AdminUpdateFrontendHandler sets the operation handler for the update frontend operation
|
||||
AdminUpdateFrontendHandler admin.UpdateFrontendHandler
|
||||
// AccountVerifyHandler sets the operation handler for the verify operation
|
||||
AccountVerifyHandler account.VerifyHandler
|
||||
// MetadataVersionHandler sets the operation handler for the version operation
|
||||
@ -302,6 +307,9 @@ func (o *ZrokAPI) Validate() error {
|
||||
if o.ServiceUnshareHandler == nil {
|
||||
unregistered = append(unregistered, "service.UnshareHandler")
|
||||
}
|
||||
if o.AdminUpdateFrontendHandler == nil {
|
||||
unregistered = append(unregistered, "admin.UpdateFrontendHandler")
|
||||
}
|
||||
if o.AccountVerifyHandler == nil {
|
||||
unregistered = append(unregistered, "account.VerifyHandler")
|
||||
}
|
||||
@ -463,6 +471,10 @@ func (o *ZrokAPI) initHandlerCache() {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/unshare"] = service.NewUnshare(o.context, o.ServiceUnshareHandler)
|
||||
if o.handlers["PATCH"] == nil {
|
||||
o.handlers["PATCH"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PATCH"]["/frontend"] = admin.NewUpdateFrontend(o.context, o.AdminUpdateFrontendHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
@ -117,6 +117,26 @@ paths:
|
||||
description: not found
|
||||
500:
|
||||
description: internal server error
|
||||
patch:
|
||||
tags:
|
||||
- admin
|
||||
security:
|
||||
- key: []
|
||||
operationId: updateFrontend
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
schema:
|
||||
$ref: "#/definitions/updateFrontendRequest"
|
||||
responses:
|
||||
200:
|
||||
description: frontend updated
|
||||
401:
|
||||
description: unauthorized
|
||||
404:
|
||||
description: not found
|
||||
500:
|
||||
description: internal server error
|
||||
delete:
|
||||
tags:
|
||||
- admin
|
||||
@ -494,13 +514,13 @@ definitions:
|
||||
type: string
|
||||
zId:
|
||||
type: string
|
||||
url_template:
|
||||
urlTemplate:
|
||||
type: string
|
||||
public_name:
|
||||
publicName:
|
||||
type: string
|
||||
created_at:
|
||||
createdAt:
|
||||
type: integer
|
||||
updated_at:
|
||||
updatedAt:
|
||||
type: integer
|
||||
|
||||
publicFrontendList:
|
||||
@ -610,6 +630,16 @@ definitions:
|
||||
svcToken:
|
||||
type: string
|
||||
|
||||
updateFrontendRequest:
|
||||
type: object
|
||||
properties:
|
||||
frontendToken:
|
||||
type: string
|
||||
publicName:
|
||||
type: string
|
||||
urlTemplate:
|
||||
type: string
|
||||
|
||||
unshareRequest:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -17,6 +17,21 @@ export function createFrontend(options) {
|
||||
return gateway.request(createFrontendOperation, parameters)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} options Optional options
|
||||
* @param {module:types.updateFrontendRequest} [options.body]
|
||||
* @return {Promise<object>} frontend updated
|
||||
*/
|
||||
export function updateFrontend(options) {
|
||||
if (!options) options = {}
|
||||
const parameters = {
|
||||
body: {
|
||||
body: options.body
|
||||
}
|
||||
}
|
||||
return gateway.request(updateFrontendOperation, parameters)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} options Optional options
|
||||
* @param {module:types.deleteFrontendRequest} [options.body]
|
||||
@ -49,6 +64,17 @@ const createFrontendOperation = {
|
||||
]
|
||||
}
|
||||
|
||||
const updateFrontendOperation = {
|
||||
path: '/frontend',
|
||||
contentTypes: ['application/zrok.v1+json'],
|
||||
method: 'patch',
|
||||
security: [
|
||||
{
|
||||
id: 'key'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const deleteFrontendOperation = {
|
||||
path: '/frontend',
|
||||
contentTypes: ['application/zrok.v1+json'],
|
||||
|
@ -122,10 +122,10 @@
|
||||
*
|
||||
* @property {string} token
|
||||
* @property {string} zId
|
||||
* @property {string} url_template
|
||||
* @property {string} public_name
|
||||
* @property {number} created_at
|
||||
* @property {number} updated_at
|
||||
* @property {string} urlTemplate
|
||||
* @property {string} publicName
|
||||
* @property {number} createdAt
|
||||
* @property {number} updatedAt
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -199,6 +199,15 @@
|
||||
* @property {string} svcToken
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef updateFrontendRequest
|
||||
* @memberof module:types
|
||||
*
|
||||
* @property {string} frontendToken
|
||||
* @property {string} publicName
|
||||
* @property {string} urlTemplate
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef unshareRequest
|
||||
* @memberof module:types
|
||||
|
Loading…
Reference in New Issue
Block a user