mirror of
https://github.com/openziti/zrok.git
synced 2024-11-21 15:43:22 +01:00
admin/createFrontend api roughed in (#129)
This commit is contained in:
parent
9db6aa1c07
commit
81e5f7e469
80
rest_client_zrok/admin/admin_client.go
Normal file
80
rest_client_zrok/admin/admin_client.go
Normal file
@ -0,0 +1,80 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// New creates a new admin API client.
|
||||
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
|
||||
return &Client{transport: transport, formats: formats}
|
||||
}
|
||||
|
||||
/*
|
||||
Client for admin API
|
||||
*/
|
||||
type Client struct {
|
||||
transport runtime.ClientTransport
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ClientOption is the option for Client methods
|
||||
type ClientOption func(*runtime.ClientOperation)
|
||||
|
||||
// ClientService is the interface for Client methods
|
||||
type ClientService interface {
|
||||
CreateFrontend(params *CreateFrontendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateFrontendCreated, error)
|
||||
|
||||
SetTransport(transport runtime.ClientTransport)
|
||||
}
|
||||
|
||||
/*
|
||||
CreateFrontend create frontend API
|
||||
*/
|
||||
func (a *Client) CreateFrontend(params *CreateFrontendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateFrontendCreated, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewCreateFrontendParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "createFrontend",
|
||||
Method: "POST",
|
||||
PathPattern: "/frontend",
|
||||
ProducesMediaTypes: []string{"application/zrok.v1+json"},
|
||||
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &CreateFrontendReader{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.(*CreateFrontendCreated)
|
||||
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 createFrontend: 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/create_frontend_parameters.go
Normal file
150
rest_client_zrok/admin/create_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"
|
||||
)
|
||||
|
||||
// NewCreateFrontendParams creates a new CreateFrontendParams 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 NewCreateFrontendParams() *CreateFrontendParams {
|
||||
return &CreateFrontendParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateFrontendParamsWithTimeout creates a new CreateFrontendParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewCreateFrontendParamsWithTimeout(timeout time.Duration) *CreateFrontendParams {
|
||||
return &CreateFrontendParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateFrontendParamsWithContext creates a new CreateFrontendParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewCreateFrontendParamsWithContext(ctx context.Context) *CreateFrontendParams {
|
||||
return &CreateFrontendParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateFrontendParamsWithHTTPClient creates a new CreateFrontendParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewCreateFrontendParamsWithHTTPClient(client *http.Client) *CreateFrontendParams {
|
||||
return &CreateFrontendParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
CreateFrontendParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the create frontend operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type CreateFrontendParams struct {
|
||||
|
||||
// Body.
|
||||
Body *rest_model_zrok.CreateFrontendRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the create frontend params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *CreateFrontendParams) WithDefaults() *CreateFrontendParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the create frontend params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *CreateFrontendParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the create frontend params
|
||||
func (o *CreateFrontendParams) WithTimeout(timeout time.Duration) *CreateFrontendParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the create frontend params
|
||||
func (o *CreateFrontendParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the create frontend params
|
||||
func (o *CreateFrontendParams) WithContext(ctx context.Context) *CreateFrontendParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the create frontend params
|
||||
func (o *CreateFrontendParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the create frontend params
|
||||
func (o *CreateFrontendParams) WithHTTPClient(client *http.Client) *CreateFrontendParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the create frontend params
|
||||
func (o *CreateFrontendParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the create frontend params
|
||||
func (o *CreateFrontendParams) WithBody(body *rest_model_zrok.CreateFrontendRequest) *CreateFrontendParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the create frontend params
|
||||
func (o *CreateFrontendParams) SetBody(body *rest_model_zrok.CreateFrontendRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *CreateFrontendParams) 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
|
||||
}
|
212
rest_client_zrok/admin/create_frontend_responses.go
Normal file
212
rest_client_zrok/admin/create_frontend_responses.go
Normal file
@ -0,0 +1,212 @@
|
||||
// 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"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// CreateFrontendReader is a Reader for the CreateFrontend structure.
|
||||
type CreateFrontendReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *CreateFrontendReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 201:
|
||||
result := NewCreateFrontendCreated()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 401:
|
||||
result := NewCreateFrontendUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 500:
|
||||
result := NewCreateFrontendInternalServerError()
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateFrontendCreated creates a CreateFrontendCreated with default headers values
|
||||
func NewCreateFrontendCreated() *CreateFrontendCreated {
|
||||
return &CreateFrontendCreated{}
|
||||
}
|
||||
|
||||
/*
|
||||
CreateFrontendCreated describes a response with status code 201, with default header values.
|
||||
|
||||
frontend created
|
||||
*/
|
||||
type CreateFrontendCreated struct {
|
||||
Payload *rest_model_zrok.CreateFrontendResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this create frontend created response has a 2xx status code
|
||||
func (o *CreateFrontendCreated) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this create frontend created response has a 3xx status code
|
||||
func (o *CreateFrontendCreated) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this create frontend created response has a 4xx status code
|
||||
func (o *CreateFrontendCreated) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this create frontend created response has a 5xx status code
|
||||
func (o *CreateFrontendCreated) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this create frontend created response a status code equal to that given
|
||||
func (o *CreateFrontendCreated) IsCode(code int) bool {
|
||||
return code == 201
|
||||
}
|
||||
|
||||
func (o *CreateFrontendCreated) Error() string {
|
||||
return fmt.Sprintf("[POST /frontend][%d] createFrontendCreated %+v", 201, o.Payload)
|
||||
}
|
||||
|
||||
func (o *CreateFrontendCreated) String() string {
|
||||
return fmt.Sprintf("[POST /frontend][%d] createFrontendCreated %+v", 201, o.Payload)
|
||||
}
|
||||
|
||||
func (o *CreateFrontendCreated) GetPayload() *rest_model_zrok.CreateFrontendResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *CreateFrontendCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model_zrok.CreateFrontendResponse)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewCreateFrontendUnauthorized creates a CreateFrontendUnauthorized with default headers values
|
||||
func NewCreateFrontendUnauthorized() *CreateFrontendUnauthorized {
|
||||
return &CreateFrontendUnauthorized{}
|
||||
}
|
||||
|
||||
/*
|
||||
CreateFrontendUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
unauthorized
|
||||
*/
|
||||
type CreateFrontendUnauthorized struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this create frontend unauthorized response has a 2xx status code
|
||||
func (o *CreateFrontendUnauthorized) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this create frontend unauthorized response has a 3xx status code
|
||||
func (o *CreateFrontendUnauthorized) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this create frontend unauthorized response has a 4xx status code
|
||||
func (o *CreateFrontendUnauthorized) IsClientError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsServerError returns true when this create frontend unauthorized response has a 5xx status code
|
||||
func (o *CreateFrontendUnauthorized) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this create frontend unauthorized response a status code equal to that given
|
||||
func (o *CreateFrontendUnauthorized) IsCode(code int) bool {
|
||||
return code == 401
|
||||
}
|
||||
|
||||
func (o *CreateFrontendUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[POST /frontend][%d] createFrontendUnauthorized ", 401)
|
||||
}
|
||||
|
||||
func (o *CreateFrontendUnauthorized) String() string {
|
||||
return fmt.Sprintf("[POST /frontend][%d] createFrontendUnauthorized ", 401)
|
||||
}
|
||||
|
||||
func (o *CreateFrontendUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewCreateFrontendInternalServerError creates a CreateFrontendInternalServerError with default headers values
|
||||
func NewCreateFrontendInternalServerError() *CreateFrontendInternalServerError {
|
||||
return &CreateFrontendInternalServerError{}
|
||||
}
|
||||
|
||||
/*
|
||||
CreateFrontendInternalServerError describes a response with status code 500, with default header values.
|
||||
|
||||
internal server error
|
||||
*/
|
||||
type CreateFrontendInternalServerError struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this create frontend internal server error response has a 2xx status code
|
||||
func (o *CreateFrontendInternalServerError) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this create frontend internal server error response has a 3xx status code
|
||||
func (o *CreateFrontendInternalServerError) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this create frontend internal server error response has a 4xx status code
|
||||
func (o *CreateFrontendInternalServerError) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this create frontend internal server error response has a 5xx status code
|
||||
func (o *CreateFrontendInternalServerError) IsServerError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsCode returns true when this create frontend internal server error response a status code equal to that given
|
||||
func (o *CreateFrontendInternalServerError) IsCode(code int) bool {
|
||||
return code == 500
|
||||
}
|
||||
|
||||
func (o *CreateFrontendInternalServerError) Error() string {
|
||||
return fmt.Sprintf("[POST /frontend][%d] createFrontendInternalServerError ", 500)
|
||||
}
|
||||
|
||||
func (o *CreateFrontendInternalServerError) String() string {
|
||||
return fmt.Sprintf("[POST /frontend][%d] createFrontendInternalServerError ", 500)
|
||||
}
|
||||
|
||||
func (o *CreateFrontendInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
@ -11,6 +11,7 @@ import (
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/account"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/admin"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/environment"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/metadata"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/service"
|
||||
@ -59,6 +60,7 @@ func New(transport runtime.ClientTransport, formats strfmt.Registry) *Zrok {
|
||||
cli := new(Zrok)
|
||||
cli.Transport = transport
|
||||
cli.Account = account.New(transport, formats)
|
||||
cli.Admin = admin.New(transport, formats)
|
||||
cli.Environment = environment.New(transport, formats)
|
||||
cli.Metadata = metadata.New(transport, formats)
|
||||
cli.Service = service.New(transport, formats)
|
||||
@ -108,6 +110,8 @@ func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
|
||||
type Zrok struct {
|
||||
Account account.ClientService
|
||||
|
||||
Admin admin.ClientService
|
||||
|
||||
Environment environment.ClientService
|
||||
|
||||
Metadata metadata.ClientService
|
||||
@ -121,6 +125,7 @@ type Zrok struct {
|
||||
func (c *Zrok) SetTransport(transport runtime.ClientTransport) {
|
||||
c.Transport = transport
|
||||
c.Account.SetTransport(transport)
|
||||
c.Admin.SetTransport(transport)
|
||||
c.Environment.SetTransport(transport)
|
||||
c.Metadata.SetTransport(transport)
|
||||
c.Service.SetTransport(transport)
|
||||
|
56
rest_model_zrok/create_frontend_request.go
Normal file
56
rest_model_zrok/create_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"
|
||||
)
|
||||
|
||||
// CreateFrontendRequest create frontend request
|
||||
//
|
||||
// swagger:model createFrontendRequest
|
||||
type CreateFrontendRequest struct {
|
||||
|
||||
// public name
|
||||
PublicName string `json:"public_name,omitempty"`
|
||||
|
||||
// url template
|
||||
URLTemplate string `json:"url_template,omitempty"`
|
||||
|
||||
// z Id
|
||||
ZID string `json:"zId,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this create frontend request
|
||||
func (m *CreateFrontendRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this create frontend request based on context it is used
|
||||
func (m *CreateFrontendRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *CreateFrontendRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *CreateFrontendRequest) UnmarshalBinary(b []byte) error {
|
||||
var res CreateFrontendRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
50
rest_model_zrok/create_frontend_response.go
Normal file
50
rest_model_zrok/create_frontend_response.go
Normal file
@ -0,0 +1,50 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// CreateFrontendResponse create frontend response
|
||||
//
|
||||
// swagger:model createFrontendResponse
|
||||
type CreateFrontendResponse struct {
|
||||
|
||||
// token
|
||||
Token string `json:"token,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this create frontend response
|
||||
func (m *CreateFrontendResponse) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this create frontend response based on context it is used
|
||||
func (m *CreateFrontendResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *CreateFrontendResponse) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *CreateFrontendResponse) UnmarshalBinary(b []byte) error {
|
||||
var res CreateFrontendResponse
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
@ -146,6 +146,42 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/frontend": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"operationId": "createFrontend",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/createFrontendRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "frontend created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/createFrontendResponse"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "unauthorized"
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/invite": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@ -492,6 +528,28 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"createFrontendRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"public_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"url_template": {
|
||||
"type": "string"
|
||||
},
|
||||
"zId": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"createFrontendResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"token": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"disableRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -933,6 +991,42 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/frontend": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"operationId": "createFrontend",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/createFrontendRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "frontend created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/createFrontendResponse"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "unauthorized"
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/invite": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@ -1279,6 +1373,28 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"createFrontendRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"public_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"url_template": {
|
||||
"type": "string"
|
||||
},
|
||||
"zId": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"createFrontendResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"token": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"disableRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
71
rest_server_zrok/operations/admin/create_frontend.go
Normal file
71
rest_server_zrok/operations/admin/create_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"
|
||||
)
|
||||
|
||||
// CreateFrontendHandlerFunc turns a function with the right signature into a create frontend handler
|
||||
type CreateFrontendHandlerFunc func(CreateFrontendParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn CreateFrontendHandlerFunc) Handle(params CreateFrontendParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// CreateFrontendHandler interface for that can handle valid create frontend params
|
||||
type CreateFrontendHandler interface {
|
||||
Handle(CreateFrontendParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewCreateFrontend creates a new http.Handler for the create frontend operation
|
||||
func NewCreateFrontend(ctx *middleware.Context, handler CreateFrontendHandler) *CreateFrontend {
|
||||
return &CreateFrontend{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
CreateFrontend swagger:route POST /frontend admin createFrontend
|
||||
|
||||
CreateFrontend create frontend API
|
||||
*/
|
||||
type CreateFrontend struct {
|
||||
Context *middleware.Context
|
||||
Handler CreateFrontendHandler
|
||||
}
|
||||
|
||||
func (o *CreateFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewCreateFrontendParams()
|
||||
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"
|
||||
)
|
||||
|
||||
// NewCreateFrontendParams creates a new CreateFrontendParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewCreateFrontendParams() CreateFrontendParams {
|
||||
|
||||
return CreateFrontendParams{}
|
||||
}
|
||||
|
||||
// CreateFrontendParams contains all the bound params for the create frontend operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters createFrontend
|
||||
type CreateFrontendParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
In: body
|
||||
*/
|
||||
Body *rest_model_zrok.CreateFrontendRequest
|
||||
}
|
||||
|
||||
// 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 NewCreateFrontendParams() beforehand.
|
||||
func (o *CreateFrontendParams) 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.CreateFrontendRequest
|
||||
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
|
||||
}
|
109
rest_server_zrok/operations/admin/create_frontend_responses.go
Normal file
109
rest_server_zrok/operations/admin/create_frontend_responses.go
Normal file
@ -0,0 +1,109 @@
|
||||
// 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"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// CreateFrontendCreatedCode is the HTTP code returned for type CreateFrontendCreated
|
||||
const CreateFrontendCreatedCode int = 201
|
||||
|
||||
/*
|
||||
CreateFrontendCreated frontend created
|
||||
|
||||
swagger:response createFrontendCreated
|
||||
*/
|
||||
type CreateFrontendCreated struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *rest_model_zrok.CreateFrontendResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewCreateFrontendCreated creates CreateFrontendCreated with default headers values
|
||||
func NewCreateFrontendCreated() *CreateFrontendCreated {
|
||||
|
||||
return &CreateFrontendCreated{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the create frontend created response
|
||||
func (o *CreateFrontendCreated) WithPayload(payload *rest_model_zrok.CreateFrontendResponse) *CreateFrontendCreated {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the create frontend created response
|
||||
func (o *CreateFrontendCreated) SetPayload(payload *rest_model_zrok.CreateFrontendResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *CreateFrontendCreated) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CreateFrontendUnauthorizedCode is the HTTP code returned for type CreateFrontendUnauthorized
|
||||
const CreateFrontendUnauthorizedCode int = 401
|
||||
|
||||
/*
|
||||
CreateFrontendUnauthorized unauthorized
|
||||
|
||||
swagger:response createFrontendUnauthorized
|
||||
*/
|
||||
type CreateFrontendUnauthorized struct {
|
||||
}
|
||||
|
||||
// NewCreateFrontendUnauthorized creates CreateFrontendUnauthorized with default headers values
|
||||
func NewCreateFrontendUnauthorized() *CreateFrontendUnauthorized {
|
||||
|
||||
return &CreateFrontendUnauthorized{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *CreateFrontendUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(401)
|
||||
}
|
||||
|
||||
// CreateFrontendInternalServerErrorCode is the HTTP code returned for type CreateFrontendInternalServerError
|
||||
const CreateFrontendInternalServerErrorCode int = 500
|
||||
|
||||
/*
|
||||
CreateFrontendInternalServerError internal server error
|
||||
|
||||
swagger:response createFrontendInternalServerError
|
||||
*/
|
||||
type CreateFrontendInternalServerError struct {
|
||||
}
|
||||
|
||||
// NewCreateFrontendInternalServerError creates CreateFrontendInternalServerError with default headers values
|
||||
func NewCreateFrontendInternalServerError() *CreateFrontendInternalServerError {
|
||||
|
||||
return &CreateFrontendInternalServerError{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *CreateFrontendInternalServerError) 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"
|
||||
)
|
||||
|
||||
// CreateFrontendURL generates an URL for the create frontend operation
|
||||
type CreateFrontendURL 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 *CreateFrontendURL) WithBasePath(bp string) *CreateFrontendURL {
|
||||
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 *CreateFrontendURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *CreateFrontendURL) 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 *CreateFrontendURL) 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 *CreateFrontendURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *CreateFrontendURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on CreateFrontendURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on CreateFrontendURL")
|
||||
}
|
||||
|
||||
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 *CreateFrontendURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
@ -21,6 +21,7 @@ import (
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/account"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/admin"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/environment"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/metadata"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/service"
|
||||
@ -51,6 +52,9 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
|
||||
ServiceAccessHandler: service.AccessHandlerFunc(func(params service.AccessParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation service.Access has not yet been implemented")
|
||||
}),
|
||||
AdminCreateFrontendHandler: admin.CreateFrontendHandlerFunc(func(params admin.CreateFrontendParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin.CreateFrontend has not yet been implemented")
|
||||
}),
|
||||
EnvironmentDisableHandler: environment.DisableHandlerFunc(func(params environment.DisableParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation environment.Disable has not yet been implemented")
|
||||
}),
|
||||
@ -139,6 +143,8 @@ type ZrokAPI struct {
|
||||
|
||||
// ServiceAccessHandler sets the operation handler for the access operation
|
||||
ServiceAccessHandler service.AccessHandler
|
||||
// AdminCreateFrontendHandler sets the operation handler for the create frontend operation
|
||||
AdminCreateFrontendHandler admin.CreateFrontendHandler
|
||||
// EnvironmentDisableHandler sets the operation handler for the disable operation
|
||||
EnvironmentDisableHandler environment.DisableHandler
|
||||
// EnvironmentEnableHandler sets the operation handler for the enable operation
|
||||
@ -247,6 +253,9 @@ func (o *ZrokAPI) Validate() error {
|
||||
if o.ServiceAccessHandler == nil {
|
||||
unregistered = append(unregistered, "service.AccessHandler")
|
||||
}
|
||||
if o.AdminCreateFrontendHandler == nil {
|
||||
unregistered = append(unregistered, "admin.CreateFrontendHandler")
|
||||
}
|
||||
if o.EnvironmentDisableHandler == nil {
|
||||
unregistered = append(unregistered, "environment.DisableHandler")
|
||||
}
|
||||
@ -389,6 +398,10 @@ func (o *ZrokAPI) initHandlerCache() {
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/frontend"] = admin.NewCreateFrontend(o.context, o.AdminCreateFrontendHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/disable"] = environment.NewDisable(o.context, o.EnvironmentDisableHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
|
@ -91,6 +91,31 @@ paths:
|
||||
500:
|
||||
description: internal server error
|
||||
|
||||
#
|
||||
# admin
|
||||
#
|
||||
/frontend:
|
||||
post:
|
||||
tags:
|
||||
- admin
|
||||
security:
|
||||
- key: []
|
||||
operationId: createFrontend
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
schema:
|
||||
$ref: "#/definitions/createFrontendRequest"
|
||||
responses:
|
||||
201:
|
||||
description: frontend created
|
||||
schema:
|
||||
$ref: "#/definitions/createFrontendResponse"
|
||||
401:
|
||||
description: unauthorized
|
||||
500:
|
||||
description: internal server error
|
||||
|
||||
#
|
||||
# environment
|
||||
#
|
||||
@ -312,6 +337,22 @@ definitions:
|
||||
password:
|
||||
type: string
|
||||
|
||||
createFrontendRequest:
|
||||
type: object
|
||||
properties:
|
||||
zId:
|
||||
type: string
|
||||
url_template:
|
||||
type: string
|
||||
public_name:
|
||||
type: string
|
||||
|
||||
createFrontendResponse:
|
||||
type: object
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
|
||||
disableRequest:
|
||||
type: object
|
||||
properties:
|
||||
|
29
ui/src/api/admin.js
Normal file
29
ui/src/api/admin.js
Normal file
@ -0,0 +1,29 @@
|
||||
/** @module admin */
|
||||
// Auto-generated, edits will be overwritten
|
||||
import * as gateway from './gateway'
|
||||
|
||||
/**
|
||||
* @param {object} options Optional options
|
||||
* @param {module:types.createFrontendRequest} [options.body]
|
||||
* @return {Promise<module:types.createFrontendResponse>} frontend created
|
||||
*/
|
||||
export function createFrontend(options) {
|
||||
if (!options) options = {}
|
||||
const parameters = {
|
||||
body: {
|
||||
body: options.body
|
||||
}
|
||||
}
|
||||
return gateway.request(createFrontendOperation, parameters)
|
||||
}
|
||||
|
||||
const createFrontendOperation = {
|
||||
path: '/frontend',
|
||||
contentTypes: ['application/zrok.v1+json'],
|
||||
method: 'post',
|
||||
security: [
|
||||
{
|
||||
id: 'key'
|
||||
}
|
||||
]
|
||||
}
|
@ -24,6 +24,22 @@
|
||||
* @property {string} password
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef createFrontendRequest
|
||||
* @memberof module:types
|
||||
*
|
||||
* @property {string} zId
|
||||
* @property {string} url_template
|
||||
* @property {string} public_name
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef createFrontendResponse
|
||||
* @memberof module:types
|
||||
*
|
||||
* @property {string} token
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef disableRequest
|
||||
* @memberof module:types
|
||||
|
Loading…
Reference in New Issue
Block a user