identities -> 'environments'

This commit is contained in:
Michael Quigley 2022-08-03 11:54:11 -04:00
parent 1a4bb269e8
commit 46b00ab9f0
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
25 changed files with 583 additions and 479 deletions

View File

@ -25,7 +25,7 @@ func Run(cfg *Config) error {
api.IdentityCreateAccountHandler = identity.CreateAccountHandlerFunc(createAccountHandler) api.IdentityCreateAccountHandler = identity.CreateAccountHandlerFunc(createAccountHandler)
api.IdentityEnableHandler = identity.EnableHandlerFunc(enableHandler) api.IdentityEnableHandler = identity.EnableHandlerFunc(enableHandler)
api.IdentityLoginHandler = identity.LoginHandlerFunc(loginHandler) api.IdentityLoginHandler = identity.LoginHandlerFunc(loginHandler)
api.MetadataListIdentitiesHandler = metadata.ListIdentitiesHandlerFunc(listIdentitiesHandler) api.MetadataListEnvironmentsHandler = metadata.ListEnvironmentsHandlerFunc(listEnvironmentsHandler)
api.MetadataVersionHandler = metadata.VersionHandlerFunc(versionHandler) api.MetadataVersionHandler = metadata.VersionHandlerFunc(versionHandler)
api.TunnelTunnelHandler = tunnel.TunnelHandlerFunc(tunnelHandler) api.TunnelTunnelHandler = tunnel.TunnelHandlerFunc(tunnelHandler)
api.TunnelUntunnelHandler = tunnel.UntunnelHandlerFunc(untunnelHandler) api.TunnelUntunnelHandler = tunnel.UntunnelHandlerFunc(untunnelHandler)

View File

@ -7,26 +7,26 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
func listIdentitiesHandler(_ metadata.ListIdentitiesParams, principal *rest_model_zrok.Principal) middleware.Responder { func listEnvironmentsHandler(_ metadata.ListEnvironmentsParams, principal *rest_model_zrok.Principal) middleware.Responder {
tx, err := str.Begin() tx, err := str.Begin()
if err != nil { if err != nil {
logrus.Errorf("error starting transaction: %v", err) logrus.Errorf("error starting transaction: %v", err)
return metadata.NewListIdentitiesInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error())) return metadata.NewListEnvironmentsInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
} }
defer func() { _ = tx.Rollback() }() defer func() { _ = tx.Rollback() }()
ids, err := str.FindIdentitiesForAccount(int(principal.ID), tx) ids, err := str.FindIdentitiesForAccount(int(principal.ID), tx)
if err != nil { if err != nil {
logrus.Errorf("error finding identities for '%v': %v", principal.Username, err) logrus.Errorf("error finding identities for '%v': %v", principal.Username, err)
return metadata.NewListIdentitiesInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error())) return metadata.NewListEnvironmentsInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
} }
var out rest_model_zrok.Identities var out rest_model_zrok.Environments
for _, id := range ids { for _, id := range ids {
out = append(out, &rest_model_zrok.Identity{ out = append(out, &rest_model_zrok.Environment{
Active: id.Active, Active: id.Active,
CreatedAt: id.CreatedAt.String(), CreatedAt: id.CreatedAt.String(),
UpdatedAt: id.UpdatedAt.String(), UpdatedAt: id.UpdatedAt.String(),
ZitiID: id.ZitiId, ZitiID: id.ZitiId,
}) })
} }
return metadata.NewListIdentitiesOK().WithPayload(out) return metadata.NewListEnvironmentsOK().WithPayload(out)
} }

View File

@ -0,0 +1,126 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// 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"
)
// NewListEnvironmentsParams creates a new ListEnvironmentsParams 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 NewListEnvironmentsParams() *ListEnvironmentsParams {
return &ListEnvironmentsParams{
timeout: cr.DefaultTimeout,
}
}
// NewListEnvironmentsParamsWithTimeout creates a new ListEnvironmentsParams object
// with the ability to set a timeout on a request.
func NewListEnvironmentsParamsWithTimeout(timeout time.Duration) *ListEnvironmentsParams {
return &ListEnvironmentsParams{
timeout: timeout,
}
}
// NewListEnvironmentsParamsWithContext creates a new ListEnvironmentsParams object
// with the ability to set a context for a request.
func NewListEnvironmentsParamsWithContext(ctx context.Context) *ListEnvironmentsParams {
return &ListEnvironmentsParams{
Context: ctx,
}
}
// NewListEnvironmentsParamsWithHTTPClient creates a new ListEnvironmentsParams object
// with the ability to set a custom HTTPClient for a request.
func NewListEnvironmentsParamsWithHTTPClient(client *http.Client) *ListEnvironmentsParams {
return &ListEnvironmentsParams{
HTTPClient: client,
}
}
/* ListEnvironmentsParams contains all the parameters to send to the API endpoint
for the list environments operation.
Typically these are written to a http.Request.
*/
type ListEnvironmentsParams struct {
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list environments params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListEnvironmentsParams) WithDefaults() *ListEnvironmentsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list environments params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListEnvironmentsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list environments params
func (o *ListEnvironmentsParams) WithTimeout(timeout time.Duration) *ListEnvironmentsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list environments params
func (o *ListEnvironmentsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list environments params
func (o *ListEnvironmentsParams) WithContext(ctx context.Context) *ListEnvironmentsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list environments params
func (o *ListEnvironmentsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list environments params
func (o *ListEnvironmentsParams) WithHTTPClient(client *http.Client) *ListEnvironmentsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list environments params
func (o *ListEnvironmentsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WriteToRequest writes these params to a swagger request
func (o *ListEnvironmentsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,101 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// 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"
)
// ListEnvironmentsReader is a Reader for the ListEnvironments structure.
type ListEnvironmentsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListEnvironmentsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListEnvironmentsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 500:
result := NewListEnvironmentsInternalServerError()
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())
}
}
// NewListEnvironmentsOK creates a ListEnvironmentsOK with default headers values
func NewListEnvironmentsOK() *ListEnvironmentsOK {
return &ListEnvironmentsOK{}
}
/* ListEnvironmentsOK describes a response with status code 200, with default header values.
success
*/
type ListEnvironmentsOK struct {
Payload rest_model_zrok.Environments
}
func (o *ListEnvironmentsOK) Error() string {
return fmt.Sprintf("[GET /listEnvironments][%d] listEnvironmentsOK %+v", 200, o.Payload)
}
func (o *ListEnvironmentsOK) GetPayload() rest_model_zrok.Environments {
return o.Payload
}
func (o *ListEnvironmentsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListEnvironmentsInternalServerError creates a ListEnvironmentsInternalServerError with default headers values
func NewListEnvironmentsInternalServerError() *ListEnvironmentsInternalServerError {
return &ListEnvironmentsInternalServerError{}
}
/* ListEnvironmentsInternalServerError describes a response with status code 500, with default header values.
internal server error
*/
type ListEnvironmentsInternalServerError struct {
Payload rest_model_zrok.ErrorMessage
}
func (o *ListEnvironmentsInternalServerError) Error() string {
return fmt.Sprintf("[GET /listEnvironments][%d] listEnvironmentsInternalServerError %+v", 500, o.Payload)
}
func (o *ListEnvironmentsInternalServerError) GetPayload() rest_model_zrok.ErrorMessage {
return o.Payload
}
func (o *ListEnvironmentsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -1,126 +0,0 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// 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"
)
// NewListIdentitiesParams creates a new ListIdentitiesParams 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 NewListIdentitiesParams() *ListIdentitiesParams {
return &ListIdentitiesParams{
timeout: cr.DefaultTimeout,
}
}
// NewListIdentitiesParamsWithTimeout creates a new ListIdentitiesParams object
// with the ability to set a timeout on a request.
func NewListIdentitiesParamsWithTimeout(timeout time.Duration) *ListIdentitiesParams {
return &ListIdentitiesParams{
timeout: timeout,
}
}
// NewListIdentitiesParamsWithContext creates a new ListIdentitiesParams object
// with the ability to set a context for a request.
func NewListIdentitiesParamsWithContext(ctx context.Context) *ListIdentitiesParams {
return &ListIdentitiesParams{
Context: ctx,
}
}
// NewListIdentitiesParamsWithHTTPClient creates a new ListIdentitiesParams object
// with the ability to set a custom HTTPClient for a request.
func NewListIdentitiesParamsWithHTTPClient(client *http.Client) *ListIdentitiesParams {
return &ListIdentitiesParams{
HTTPClient: client,
}
}
/* ListIdentitiesParams contains all the parameters to send to the API endpoint
for the list identities operation.
Typically these are written to a http.Request.
*/
type ListIdentitiesParams struct {
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list identities params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListIdentitiesParams) WithDefaults() *ListIdentitiesParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list identities params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListIdentitiesParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list identities params
func (o *ListIdentitiesParams) WithTimeout(timeout time.Duration) *ListIdentitiesParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list identities params
func (o *ListIdentitiesParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list identities params
func (o *ListIdentitiesParams) WithContext(ctx context.Context) *ListIdentitiesParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list identities params
func (o *ListIdentitiesParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list identities params
func (o *ListIdentitiesParams) WithHTTPClient(client *http.Client) *ListIdentitiesParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list identities params
func (o *ListIdentitiesParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WriteToRequest writes these params to a swagger request
func (o *ListIdentitiesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -1,101 +0,0 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// 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"
)
// ListIdentitiesReader is a Reader for the ListIdentities structure.
type ListIdentitiesReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListIdentitiesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListIdentitiesOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 500:
result := NewListIdentitiesInternalServerError()
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())
}
}
// NewListIdentitiesOK creates a ListIdentitiesOK with default headers values
func NewListIdentitiesOK() *ListIdentitiesOK {
return &ListIdentitiesOK{}
}
/* ListIdentitiesOK describes a response with status code 200, with default header values.
success
*/
type ListIdentitiesOK struct {
Payload rest_model_zrok.Identities
}
func (o *ListIdentitiesOK) Error() string {
return fmt.Sprintf("[GET /listIdentities][%d] listIdentitiesOK %+v", 200, o.Payload)
}
func (o *ListIdentitiesOK) GetPayload() rest_model_zrok.Identities {
return o.Payload
}
func (o *ListIdentitiesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListIdentitiesInternalServerError creates a ListIdentitiesInternalServerError with default headers values
func NewListIdentitiesInternalServerError() *ListIdentitiesInternalServerError {
return &ListIdentitiesInternalServerError{}
}
/* ListIdentitiesInternalServerError describes a response with status code 500, with default header values.
internal server error
*/
type ListIdentitiesInternalServerError struct {
Payload rest_model_zrok.ErrorMessage
}
func (o *ListIdentitiesInternalServerError) Error() string {
return fmt.Sprintf("[GET /listIdentities][%d] listIdentitiesInternalServerError %+v", 500, o.Payload)
}
func (o *ListIdentitiesInternalServerError) GetPayload() rest_model_zrok.ErrorMessage {
return o.Payload
}
func (o *ListIdentitiesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -30,7 +30,7 @@ type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods // ClientService is the interface for Client methods
type ClientService interface { type ClientService interface {
ListIdentities(params *ListIdentitiesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListIdentitiesOK, error) ListEnvironments(params *ListEnvironmentsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListEnvironmentsOK, error)
Version(params *VersionParams, opts ...ClientOption) (*VersionOK, error) Version(params *VersionParams, opts ...ClientOption) (*VersionOK, error)
@ -38,22 +38,22 @@ type ClientService interface {
} }
/* /*
ListIdentities list identities API ListEnvironments list environments API
*/ */
func (a *Client) ListIdentities(params *ListIdentitiesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListIdentitiesOK, error) { func (a *Client) ListEnvironments(params *ListEnvironmentsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListEnvironmentsOK, error) {
// TODO: Validate the params before sending // TODO: Validate the params before sending
if params == nil { if params == nil {
params = NewListIdentitiesParams() params = NewListEnvironmentsParams()
} }
op := &runtime.ClientOperation{ op := &runtime.ClientOperation{
ID: "listIdentities", ID: "listEnvironments",
Method: "GET", Method: "GET",
PathPattern: "/listIdentities", PathPattern: "/listEnvironments",
ProducesMediaTypes: []string{"application/zrok.v1+json"}, ProducesMediaTypes: []string{"application/zrok.v1+json"},
ConsumesMediaTypes: []string{"application/zrok.v1+json"}, ConsumesMediaTypes: []string{"application/zrok.v1+json"},
Schemes: []string{"http"}, Schemes: []string{"http"},
Params: params, Params: params,
Reader: &ListIdentitiesReader{formats: a.formats}, Reader: &ListEnvironmentsReader{formats: a.formats},
AuthInfo: authInfo, AuthInfo: authInfo,
Context: params.Context, Context: params.Context,
Client: params.HTTPClient, Client: params.HTTPClient,
@ -66,13 +66,13 @@ func (a *Client) ListIdentities(params *ListIdentitiesParams, authInfo runtime.C
if err != nil { if err != nil {
return nil, err return nil, err
} }
success, ok := result.(*ListIdentitiesOK) success, ok := result.(*ListEnvironmentsOK)
if ok { if ok {
return success, nil return success, nil
} }
// unexpected success response // unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue // 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 listIdentities: API contract not enforced by server. Client expected to get an error, but got: %T", result) msg := fmt.Sprintf("unexpected success response for listEnvironments: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg) panic(msg)
} }

View File

@ -12,10 +12,10 @@ import (
"github.com/go-openapi/swag" "github.com/go-openapi/swag"
) )
// Identity identity // Environment environment
// //
// swagger:model identity // swagger:model environment
type Identity struct { type Environment struct {
// active // active
Active bool `json:"active,omitempty"` Active bool `json:"active,omitempty"`
@ -30,18 +30,18 @@ type Identity struct {
ZitiID string `json:"zitiId,omitempty"` ZitiID string `json:"zitiId,omitempty"`
} }
// Validate validates this identity // Validate validates this environment
func (m *Identity) Validate(formats strfmt.Registry) error { func (m *Environment) Validate(formats strfmt.Registry) error {
return nil return nil
} }
// ContextValidate validates this identity based on context it is used // ContextValidate validates this environment based on context it is used
func (m *Identity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { func (m *Environment) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil return nil
} }
// MarshalBinary interface implementation // MarshalBinary interface implementation
func (m *Identity) MarshalBinary() ([]byte, error) { func (m *Environment) MarshalBinary() ([]byte, error) {
if m == nil { if m == nil {
return nil, nil return nil, nil
} }
@ -49,8 +49,8 @@ func (m *Identity) MarshalBinary() ([]byte, error) {
} }
// UnmarshalBinary interface implementation // UnmarshalBinary interface implementation
func (m *Identity) UnmarshalBinary(b []byte) error { func (m *Environment) UnmarshalBinary(b []byte) error {
var res Identity var res Environment
if err := swag.ReadJSON(b, &res); err != nil { if err := swag.ReadJSON(b, &res); err != nil {
return err return err
} }

View File

@ -14,13 +14,13 @@ import (
"github.com/go-openapi/swag" "github.com/go-openapi/swag"
) )
// Identities identities // Environments environments
// //
// swagger:model identities // swagger:model environments
type Identities []*Identity type Environments []*Environment
// Validate validates this identities // Validate validates this environments
func (m Identities) Validate(formats strfmt.Registry) error { func (m Environments) Validate(formats strfmt.Registry) error {
var res []error var res []error
for i := 0; i < len(m); i++ { for i := 0; i < len(m); i++ {
@ -47,8 +47,8 @@ func (m Identities) Validate(formats strfmt.Registry) error {
return nil return nil
} }
// ContextValidate validate this identities based on the context it is used // ContextValidate validate this environments based on the context it is used
func (m Identities) ContextValidate(ctx context.Context, formats strfmt.Registry) error { func (m Environments) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error var res []error
for i := 0; i < len(m); i++ { for i := 0; i < len(m); i++ {

View File

@ -4,27 +4,92 @@ package rest_server_zrok
import ( import (
"crypto/tls" "crypto/tls"
"github.com/openziti-test-kitchen/zrok/ui"
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/go-openapi/errors" "github.com/go-openapi/errors"
"github.com/go-openapi/runtime" "github.com/go-openapi/runtime"
"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" "github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations"
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/identity"
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/metadata"
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/tunnel"
) )
//go:generate swagger generate server --target ../../zrok --name Zrok --spec ../specs/zrok.yml --model-package rest_model_zrok --server-package rest_server_zrok --principal interface{} --exclude-main //go:generate swagger generate server --target ../../zrok --name Zrok --spec ../specs/zrok.yml --model-package rest_model_zrok --server-package rest_server_zrok --principal rest_model_zrok.Principal --exclude-main
func configureFlags(api *operations.ZrokAPI) { func configureFlags(api *operations.ZrokAPI) {
// api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... }
} }
func configureAPI(api *operations.ZrokAPI) http.Handler { func configureAPI(api *operations.ZrokAPI) http.Handler {
// configure the api here
api.ServeError = errors.ServeError api.ServeError = errors.ServeError
api.Logger = logrus.Printf
// Set your custom logger if needed. Default one is log.Printf
// Expected interface func(string, ...interface{})
//
// Example:
// api.Logger = log.Printf
api.UseSwaggerUI() api.UseSwaggerUI()
// To continue using redoc as your UI, uncomment the following line
// api.UseRedoc()
api.JSONConsumer = runtime.JSONConsumer() api.JSONConsumer = runtime.JSONConsumer()
api.JSONProducer = runtime.JSONProducer() api.JSONProducer = runtime.JSONProducer()
// Applies when the "x-token" header is set
if api.KeyAuth == nil {
api.KeyAuth = func(token string) (*rest_model_zrok.Principal, error) {
return nil, errors.NotImplemented("api key auth (key) x-token from header param [x-token] has not yet been implemented")
}
}
// Set your custom authorizer if needed. Default one is security.Authorized()
// Expected interface runtime.Authorizer
//
// Example:
// api.APIAuthorizer = security.Authorized()
if api.IdentityCreateAccountHandler == nil {
api.IdentityCreateAccountHandler = identity.CreateAccountHandlerFunc(func(params identity.CreateAccountParams) middleware.Responder {
return middleware.NotImplemented("operation identity.CreateAccount has not yet been implemented")
})
}
if api.IdentityEnableHandler == nil {
api.IdentityEnableHandler = identity.EnableHandlerFunc(func(params identity.EnableParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation identity.Enable has not yet been implemented")
})
}
if api.MetadataListEnvironmentsHandler == nil {
api.MetadataListEnvironmentsHandler = metadata.ListEnvironmentsHandlerFunc(func(params metadata.ListEnvironmentsParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation metadata.ListEnvironments has not yet been implemented")
})
}
if api.IdentityLoginHandler == nil {
api.IdentityLoginHandler = identity.LoginHandlerFunc(func(params identity.LoginParams) middleware.Responder {
return middleware.NotImplemented("operation identity.Login has not yet been implemented")
})
}
if api.TunnelTunnelHandler == nil {
api.TunnelTunnelHandler = tunnel.TunnelHandlerFunc(func(params tunnel.TunnelParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation tunnel.Tunnel has not yet been implemented")
})
}
if api.TunnelUntunnelHandler == nil {
api.TunnelUntunnelHandler = tunnel.UntunnelHandlerFunc(func(params tunnel.UntunnelParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation tunnel.Untunnel has not yet been implemented")
})
}
if api.MetadataVersionHandler == nil {
api.MetadataVersionHandler = metadata.VersionHandlerFunc(func(params metadata.VersionParams) middleware.Responder {
return middleware.NotImplemented("operation metadata.Version has not yet been implemented")
})
}
api.PreServerShutdown = func() {} api.PreServerShutdown = func() {}
api.ServerShutdown = func() {} api.ServerShutdown = func() {}
@ -53,6 +118,5 @@ func setupMiddlewares(handler http.Handler) http.Handler {
// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document. // The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document.
// So this is a good place to plug in a panic handling middleware, logging and metrics. // So this is a good place to plug in a panic handling middleware, logging and metrics.
func setupGlobalMiddleware(handler http.Handler) http.Handler { func setupGlobalMiddleware(handler http.Handler) http.Handler {
logrus.Infof("configuring") return handler
return ui.StaticBuilder(handler)
} }

View File

@ -105,7 +105,7 @@ func init() {
} }
} }
}, },
"/listIdentities": { "/listEnvironments": {
"get": { "get": {
"security": [ "security": [
{ {
@ -115,12 +115,12 @@ func init() {
"tags": [ "tags": [
"metadata" "metadata"
], ],
"operationId": "listIdentities", "operationId": "listEnvironments",
"responses": { "responses": {
"200": { "200": {
"description": "success", "description": "success",
"schema": { "schema": {
"$ref": "#/definitions/identities" "$ref": "#/definitions/environments"
} }
}, },
"500": { "500": {
@ -289,16 +289,7 @@ func init() {
} }
} }
}, },
"errorMessage": { "environment": {
"type": "string"
},
"identities": {
"type": "array",
"items": {
"$ref": "#/definitions/identity"
}
},
"identity": {
"type": "object", "type": "object",
"properties": { "properties": {
"active": { "active": {
@ -315,6 +306,15 @@ func init() {
} }
} }
}, },
"environments": {
"type": "array",
"items": {
"$ref": "#/definitions/environment"
}
},
"errorMessage": {
"type": "string"
},
"loginRequest": { "loginRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -470,7 +470,7 @@ func init() {
} }
} }
}, },
"/listIdentities": { "/listEnvironments": {
"get": { "get": {
"security": [ "security": [
{ {
@ -480,12 +480,12 @@ func init() {
"tags": [ "tags": [
"metadata" "metadata"
], ],
"operationId": "listIdentities", "operationId": "listEnvironments",
"responses": { "responses": {
"200": { "200": {
"description": "success", "description": "success",
"schema": { "schema": {
"$ref": "#/definitions/identities" "$ref": "#/definitions/environments"
} }
}, },
"500": { "500": {
@ -654,16 +654,7 @@ func init() {
} }
} }
}, },
"errorMessage": { "environment": {
"type": "string"
},
"identities": {
"type": "array",
"items": {
"$ref": "#/definitions/identity"
}
},
"identity": {
"type": "object", "type": "object",
"properties": { "properties": {
"active": { "active": {
@ -680,6 +671,15 @@ func init() {
} }
} }
}, },
"environments": {
"type": "array",
"items": {
"$ref": "#/definitions/environment"
}
},
"errorMessage": {
"type": "string"
},
"loginRequest": { "loginRequest": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -13,40 +13,40 @@ import (
"github.com/openziti-test-kitchen/zrok/rest_model_zrok" "github.com/openziti-test-kitchen/zrok/rest_model_zrok"
) )
// ListIdentitiesHandlerFunc turns a function with the right signature into a list identities handler // ListEnvironmentsHandlerFunc turns a function with the right signature into a list environments handler
type ListIdentitiesHandlerFunc func(ListIdentitiesParams, *rest_model_zrok.Principal) middleware.Responder type ListEnvironmentsHandlerFunc func(ListEnvironmentsParams, *rest_model_zrok.Principal) middleware.Responder
// Handle executing the request and returning a response // Handle executing the request and returning a response
func (fn ListIdentitiesHandlerFunc) Handle(params ListIdentitiesParams, principal *rest_model_zrok.Principal) middleware.Responder { func (fn ListEnvironmentsHandlerFunc) Handle(params ListEnvironmentsParams, principal *rest_model_zrok.Principal) middleware.Responder {
return fn(params, principal) return fn(params, principal)
} }
// ListIdentitiesHandler interface for that can handle valid list identities params // ListEnvironmentsHandler interface for that can handle valid list environments params
type ListIdentitiesHandler interface { type ListEnvironmentsHandler interface {
Handle(ListIdentitiesParams, *rest_model_zrok.Principal) middleware.Responder Handle(ListEnvironmentsParams, *rest_model_zrok.Principal) middleware.Responder
} }
// NewListIdentities creates a new http.Handler for the list identities operation // NewListEnvironments creates a new http.Handler for the list environments operation
func NewListIdentities(ctx *middleware.Context, handler ListIdentitiesHandler) *ListIdentities { func NewListEnvironments(ctx *middleware.Context, handler ListEnvironmentsHandler) *ListEnvironments {
return &ListIdentities{Context: ctx, Handler: handler} return &ListEnvironments{Context: ctx, Handler: handler}
} }
/* ListIdentities swagger:route GET /listIdentities metadata listIdentities /* ListEnvironments swagger:route GET /listEnvironments metadata listEnvironments
ListIdentities list identities API ListEnvironments list environments API
*/ */
type ListIdentities struct { type ListEnvironments struct {
Context *middleware.Context Context *middleware.Context
Handler ListIdentitiesHandler Handler ListEnvironmentsHandler
} }
func (o *ListIdentities) ServeHTTP(rw http.ResponseWriter, r *http.Request) { func (o *ListEnvironments) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r) route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil { if rCtx != nil {
*r = *rCtx *r = *rCtx
} }
var Params = NewListIdentitiesParams() var Params = NewListEnvironmentsParams()
uprinc, aCtx, err := o.Context.Authorize(r, route) uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil { if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err) o.Context.Respond(rw, r, route.Produces, route, err)

View File

@ -12,19 +12,19 @@ import (
"github.com/go-openapi/runtime/middleware" "github.com/go-openapi/runtime/middleware"
) )
// NewListIdentitiesParams creates a new ListIdentitiesParams object // NewListEnvironmentsParams creates a new ListEnvironmentsParams object
// //
// There are no default values defined in the spec. // There are no default values defined in the spec.
func NewListIdentitiesParams() ListIdentitiesParams { func NewListEnvironmentsParams() ListEnvironmentsParams {
return ListIdentitiesParams{} return ListEnvironmentsParams{}
} }
// ListIdentitiesParams contains all the bound params for the list identities operation // ListEnvironmentsParams contains all the bound params for the list environments operation
// typically these are obtained from a http.Request // typically these are obtained from a http.Request
// //
// swagger:parameters listIdentities // swagger:parameters listEnvironments
type ListIdentitiesParams struct { type ListEnvironmentsParams struct {
// HTTP Request Object // HTTP Request Object
HTTPRequest *http.Request `json:"-"` HTTPRequest *http.Request `json:"-"`
@ -33,8 +33,8 @@ type ListIdentitiesParams struct {
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface // 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. // for simple values it will use straight method calls.
// //
// To ensure default values, the struct must have been initialized with NewListIdentitiesParams() beforehand. // To ensure default values, the struct must have been initialized with NewListEnvironmentsParams() beforehand.
func (o *ListIdentitiesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { func (o *ListEnvironmentsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error var res []error
o.HTTPRequest = r o.HTTPRequest = r

View File

@ -0,0 +1,103 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// 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"
)
// ListEnvironmentsOKCode is the HTTP code returned for type ListEnvironmentsOK
const ListEnvironmentsOKCode int = 200
/*ListEnvironmentsOK success
swagger:response listEnvironmentsOK
*/
type ListEnvironmentsOK struct {
/*
In: Body
*/
Payload rest_model_zrok.Environments `json:"body,omitempty"`
}
// NewListEnvironmentsOK creates ListEnvironmentsOK with default headers values
func NewListEnvironmentsOK() *ListEnvironmentsOK {
return &ListEnvironmentsOK{}
}
// WithPayload adds the payload to the list environments o k response
func (o *ListEnvironmentsOK) WithPayload(payload rest_model_zrok.Environments) *ListEnvironmentsOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the list environments o k response
func (o *ListEnvironmentsOK) SetPayload(payload rest_model_zrok.Environments) {
o.Payload = payload
}
// WriteResponse to the client
func (o *ListEnvironmentsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
payload := o.Payload
if payload == nil {
// return empty array
payload = rest_model_zrok.Environments{}
}
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
// ListEnvironmentsInternalServerErrorCode is the HTTP code returned for type ListEnvironmentsInternalServerError
const ListEnvironmentsInternalServerErrorCode int = 500
/*ListEnvironmentsInternalServerError internal server error
swagger:response listEnvironmentsInternalServerError
*/
type ListEnvironmentsInternalServerError struct {
/*
In: Body
*/
Payload rest_model_zrok.ErrorMessage `json:"body,omitempty"`
}
// NewListEnvironmentsInternalServerError creates ListEnvironmentsInternalServerError with default headers values
func NewListEnvironmentsInternalServerError() *ListEnvironmentsInternalServerError {
return &ListEnvironmentsInternalServerError{}
}
// WithPayload adds the payload to the list environments internal server error response
func (o *ListEnvironmentsInternalServerError) WithPayload(payload rest_model_zrok.ErrorMessage) *ListEnvironmentsInternalServerError {
o.Payload = payload
return o
}
// SetPayload sets the payload to the list environments internal server error response
func (o *ListEnvironmentsInternalServerError) SetPayload(payload rest_model_zrok.ErrorMessage) {
o.Payload = payload
}
// WriteResponse to the client
func (o *ListEnvironmentsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(500)
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}

View File

@ -11,15 +11,15 @@ import (
golangswaggerpaths "path" golangswaggerpaths "path"
) )
// ListIdentitiesURL generates an URL for the list identities operation // ListEnvironmentsURL generates an URL for the list environments operation
type ListIdentitiesURL struct { type ListEnvironmentsURL struct {
_basePath string _basePath string
} }
// WithBasePath sets the base path for this url builder, only required when it's different from the // WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec. // base path specified in the swagger spec.
// When the value of the base path is an empty string // When the value of the base path is an empty string
func (o *ListIdentitiesURL) WithBasePath(bp string) *ListIdentitiesURL { func (o *ListEnvironmentsURL) WithBasePath(bp string) *ListEnvironmentsURL {
o.SetBasePath(bp) o.SetBasePath(bp)
return o return o
} }
@ -27,15 +27,15 @@ func (o *ListIdentitiesURL) WithBasePath(bp string) *ListIdentitiesURL {
// SetBasePath sets the base path for this url builder, only required when it's different from the // SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec. // base path specified in the swagger spec.
// When the value of the base path is an empty string // When the value of the base path is an empty string
func (o *ListIdentitiesURL) SetBasePath(bp string) { func (o *ListEnvironmentsURL) SetBasePath(bp string) {
o._basePath = bp o._basePath = bp
} }
// Build a url path and query string // Build a url path and query string
func (o *ListIdentitiesURL) Build() (*url.URL, error) { func (o *ListEnvironmentsURL) Build() (*url.URL, error) {
var _result url.URL var _result url.URL
var _path = "/listIdentities" var _path = "/listEnvironments"
_basePath := o._basePath _basePath := o._basePath
if _basePath == "" { if _basePath == "" {
@ -47,7 +47,7 @@ func (o *ListIdentitiesURL) Build() (*url.URL, error) {
} }
// Must is a helper function to panic when the url builder returns an error // Must is a helper function to panic when the url builder returns an error
func (o *ListIdentitiesURL) Must(u *url.URL, err error) *url.URL { func (o *ListEnvironmentsURL) Must(u *url.URL, err error) *url.URL {
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -58,17 +58,17 @@ func (o *ListIdentitiesURL) Must(u *url.URL, err error) *url.URL {
} }
// String returns the string representation of the path with query string // String returns the string representation of the path with query string
func (o *ListIdentitiesURL) String() string { func (o *ListEnvironmentsURL) String() string {
return o.Must(o.Build()).String() return o.Must(o.Build()).String()
} }
// BuildFull builds a full url with scheme, host, path and query string // BuildFull builds a full url with scheme, host, path and query string
func (o *ListIdentitiesURL) BuildFull(scheme, host string) (*url.URL, error) { func (o *ListEnvironmentsURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" { if scheme == "" {
return nil, errors.New("scheme is required for a full url on ListIdentitiesURL") return nil, errors.New("scheme is required for a full url on ListEnvironmentsURL")
} }
if host == "" { if host == "" {
return nil, errors.New("host is required for a full url on ListIdentitiesURL") return nil, errors.New("host is required for a full url on ListEnvironmentsURL")
} }
base, err := o.Build() base, err := o.Build()
@ -82,6 +82,6 @@ func (o *ListIdentitiesURL) BuildFull(scheme, host string) (*url.URL, error) {
} }
// StringFull returns the string representation of a complete url // StringFull returns the string representation of a complete url
func (o *ListIdentitiesURL) StringFull(scheme, host string) string { func (o *ListEnvironmentsURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String() return o.Must(o.BuildFull(scheme, host)).String()
} }

View File

@ -1,103 +0,0 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// 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"
)
// ListIdentitiesOKCode is the HTTP code returned for type ListIdentitiesOK
const ListIdentitiesOKCode int = 200
/*ListIdentitiesOK success
swagger:response listIdentitiesOK
*/
type ListIdentitiesOK struct {
/*
In: Body
*/
Payload rest_model_zrok.Identities `json:"body,omitempty"`
}
// NewListIdentitiesOK creates ListIdentitiesOK with default headers values
func NewListIdentitiesOK() *ListIdentitiesOK {
return &ListIdentitiesOK{}
}
// WithPayload adds the payload to the list identities o k response
func (o *ListIdentitiesOK) WithPayload(payload rest_model_zrok.Identities) *ListIdentitiesOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the list identities o k response
func (o *ListIdentitiesOK) SetPayload(payload rest_model_zrok.Identities) {
o.Payload = payload
}
// WriteResponse to the client
func (o *ListIdentitiesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
payload := o.Payload
if payload == nil {
// return empty array
payload = rest_model_zrok.Identities{}
}
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
// ListIdentitiesInternalServerErrorCode is the HTTP code returned for type ListIdentitiesInternalServerError
const ListIdentitiesInternalServerErrorCode int = 500
/*ListIdentitiesInternalServerError internal server error
swagger:response listIdentitiesInternalServerError
*/
type ListIdentitiesInternalServerError struct {
/*
In: Body
*/
Payload rest_model_zrok.ErrorMessage `json:"body,omitempty"`
}
// NewListIdentitiesInternalServerError creates ListIdentitiesInternalServerError with default headers values
func NewListIdentitiesInternalServerError() *ListIdentitiesInternalServerError {
return &ListIdentitiesInternalServerError{}
}
// WithPayload adds the payload to the list identities internal server error response
func (o *ListIdentitiesInternalServerError) WithPayload(payload rest_model_zrok.ErrorMessage) *ListIdentitiesInternalServerError {
o.Payload = payload
return o
}
// SetPayload sets the payload to the list identities internal server error response
func (o *ListIdentitiesInternalServerError) SetPayload(payload rest_model_zrok.ErrorMessage) {
o.Payload = payload
}
// WriteResponse to the client
func (o *ListIdentitiesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(500)
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}

View File

@ -53,8 +53,8 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
IdentityEnableHandler: identity.EnableHandlerFunc(func(params identity.EnableParams, principal *rest_model_zrok.Principal) middleware.Responder { IdentityEnableHandler: identity.EnableHandlerFunc(func(params identity.EnableParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation identity.Enable has not yet been implemented") return middleware.NotImplemented("operation identity.Enable has not yet been implemented")
}), }),
MetadataListIdentitiesHandler: metadata.ListIdentitiesHandlerFunc(func(params metadata.ListIdentitiesParams, principal *rest_model_zrok.Principal) middleware.Responder { MetadataListEnvironmentsHandler: metadata.ListEnvironmentsHandlerFunc(func(params metadata.ListEnvironmentsParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation metadata.ListIdentities has not yet been implemented") return middleware.NotImplemented("operation metadata.ListEnvironments has not yet been implemented")
}), }),
IdentityLoginHandler: identity.LoginHandlerFunc(func(params identity.LoginParams) middleware.Responder { IdentityLoginHandler: identity.LoginHandlerFunc(func(params identity.LoginParams) middleware.Responder {
return middleware.NotImplemented("operation identity.Login has not yet been implemented") return middleware.NotImplemented("operation identity.Login has not yet been implemented")
@ -122,8 +122,8 @@ type ZrokAPI struct {
IdentityCreateAccountHandler identity.CreateAccountHandler IdentityCreateAccountHandler identity.CreateAccountHandler
// IdentityEnableHandler sets the operation handler for the enable operation // IdentityEnableHandler sets the operation handler for the enable operation
IdentityEnableHandler identity.EnableHandler IdentityEnableHandler identity.EnableHandler
// MetadataListIdentitiesHandler sets the operation handler for the list identities operation // MetadataListEnvironmentsHandler sets the operation handler for the list environments operation
MetadataListIdentitiesHandler metadata.ListIdentitiesHandler MetadataListEnvironmentsHandler metadata.ListEnvironmentsHandler
// IdentityLoginHandler sets the operation handler for the login operation // IdentityLoginHandler sets the operation handler for the login operation
IdentityLoginHandler identity.LoginHandler IdentityLoginHandler identity.LoginHandler
// TunnelTunnelHandler sets the operation handler for the tunnel operation // TunnelTunnelHandler sets the operation handler for the tunnel operation
@ -219,8 +219,8 @@ func (o *ZrokAPI) Validate() error {
if o.IdentityEnableHandler == nil { if o.IdentityEnableHandler == nil {
unregistered = append(unregistered, "identity.EnableHandler") unregistered = append(unregistered, "identity.EnableHandler")
} }
if o.MetadataListIdentitiesHandler == nil { if o.MetadataListEnvironmentsHandler == nil {
unregistered = append(unregistered, "metadata.ListIdentitiesHandler") unregistered = append(unregistered, "metadata.ListEnvironmentsHandler")
} }
if o.IdentityLoginHandler == nil { if o.IdentityLoginHandler == nil {
unregistered = append(unregistered, "identity.LoginHandler") unregistered = append(unregistered, "identity.LoginHandler")
@ -344,7 +344,7 @@ func (o *ZrokAPI) initHandlerCache() {
if o.handlers["GET"] == nil { if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler) o.handlers["GET"] = make(map[string]http.Handler)
} }
o.handlers["GET"]["/listIdentities"] = metadata.NewListIdentities(o.context, o.MetadataListIdentitiesHandler) o.handlers["GET"]["/listEnvironments"] = metadata.NewListEnvironments(o.context, o.MetadataListEnvironmentsHandler)
if o.handlers["POST"] == nil { if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler) o.handlers["POST"] = make(map[string]http.Handler)
} }

View File

@ -35,6 +35,7 @@ paths:
description: internal server error description: internal server error
schema: schema:
$ref: "#/definitions/errorMessage" $ref: "#/definitions/errorMessage"
/enable: /enable:
post: post:
tags: tags:
@ -55,22 +56,24 @@ paths:
description: internal server error description: internal server error
schema: schema:
$ref: "#/definitions/errorMessage" $ref: "#/definitions/errorMessage"
/listIdentities:
/listEnvironments:
get: get:
tags: tags:
- metadata - metadata
security: security:
- key: [] - key: []
operationId: listIdentities operationId: listEnvironments
responses: responses:
200: 200:
description: success description: success
schema: schema:
$ref: "#/definitions/identities" $ref: "#/definitions/environments"
500: 500:
description: internal server error description: internal server error
schema: schema:
$ref: "#/definitions/errorMessage" $ref: "#/definitions/errorMessage"
/login: /login:
post: post:
tags: tags:
@ -88,6 +91,7 @@ paths:
$ref: "#/definitions/loginResponse" $ref: "#/definitions/loginResponse"
401: 401:
description: invalid login description: invalid login
/tunnel: /tunnel:
post: post:
tags: tags:
@ -160,6 +164,7 @@ definitions:
properties: properties:
token: token:
type: string type: string
enableResponse: enableResponse:
type: object type: object
properties: properties:
@ -167,13 +172,12 @@ definitions:
type: string type: string
cfg: cfg:
type: string type: string
errorMessage:
type: string environments:
identities:
type: array type: array
items: items:
$ref: "#/definitions/identity" $ref: "#/definitions/environment"
identity: environment:
type: object type: object
properties: properties:
zitiId: zitiId:
@ -184,6 +188,10 @@ definitions:
type: string type: string
updatedAt: updatedAt:
type: string type: string
errorMessage:
type: string
loginRequest: loginRequest:
type: object type: object
properties: properties:
@ -193,6 +201,7 @@ definitions:
type: string type: string
loginResponse: loginResponse:
type: string type: string
principal: principal:
type: object type: object
properties: properties:
@ -202,6 +211,7 @@ definitions:
type: string type: string
token: token:
type: string type: string
tunnelRequest: tunnelRequest:
type: object type: object
properties: properties:
@ -214,11 +224,13 @@ definitions:
properties: properties:
service: service:
type: string type: string
untunnelRequest: untunnelRequest:
type: object type: object
properties: properties:
service: service:
type: string type: string
version: version:
type: string type: string

View File

@ -2,7 +2,9 @@ import Login from './Login';
import Logout from './Logout'; import Logout from './Logout';
import Version from './Version'; import Version from './Version';
import {useEffect, useState} from "react"; import {useEffect, useState} from "react";
import Identities from "./Identities"; import Environments from "./Environments";
import Icon from '@mdi/react';
import { mdiCloud } from '@mdi/js';
const App = () => { const App = () => {
const [user, setUser] = useState(); const [user, setUser] = useState();
@ -25,22 +27,24 @@ const App = () => {
<div className="zrok"> <div className="zrok">
<div className="container"> <div className="container">
<div className="header"> <div className="header">
<img src="ziggy.svg" width="65px"/> <img alt="ziggy goes to space" src="ziggy.svg" width="65px"/>
<p className="title">zrok</p> <p className="header-title">zrok</p>
<div className="header-left"> <div className={"header-status"}>
<div> <div>
<p>{user.email}</p>
<Version/>
</div>
<div className={"header-controls"}>
<button className={"logoutButton"}><Icon path={mdiCloud} size={0.7}/></button>
<Logout user={user} logout={() => { <Logout user={user} logout={() => {
setUser(null); setUser(null);
localStorage.clear(); localStorage.clear();
}}/> }}/>
</div> </div>
<div>
<Version/>
</div>
</div> </div>
</div> </div>
<div className="main"> <div className="main">
<Identities user={user}/> <Environments user={user}/>
</div> </div>
</div> </div>
</div> </div>

View File

@ -2,8 +2,8 @@ import {useEffect, useState} from "react";
import * as metadata from './api/metadata'; import * as metadata from './api/metadata';
import DataTable from 'react-data-table-component'; import DataTable from 'react-data-table-component';
const Identities = (props) => { const Environments = (props) => {
const [identities, setIdentities] = useState([]) const [environments, setEnvironments] = useState([])
const columns = [ const columns = [
{ {
@ -30,8 +30,8 @@ const Identities = (props) => {
useEffect(() => { useEffect(() => {
let mounted = true; let mounted = true;
metadata.listIdentities().then((resp) => { metadata.listEnvironments().then((resp) => {
setIdentities(resp.data) setEnvironments(resp.data)
console.log(resp.data); console.log(resp.data);
}) })
return () => { mounted = false; } return () => { mounted = false; }
@ -39,12 +39,12 @@ const Identities = (props) => {
return ( return (
<div> <div>
<h1>Identities</h1> <h1>Environments</h1>
{ identities && identities.length > 0 && ( { environments && environments.length > 0 && (
<div> <div>
<DataTable <DataTable
columns={columns} columns={columns}
data={identities} data={environments}
defaultSortFieldId={1} defaultSortFieldId={1}
/> />
</div> </div>
@ -53,4 +53,4 @@ const Identities = (props) => {
) )
}; };
export default Identities; export default Environments;

View File

@ -9,7 +9,7 @@ const Logout = (props) => {
} }
return ( return (
<a onClick={onClick}><Icon path={logoutIcon} size={1}/> {props.user.email}</a> <button className="logoutButton" onClick={onClick} aria-label={"log out"}><Icon path={logoutIcon} size={.7}/></button>
); );
} }

View File

@ -17,7 +17,7 @@ const Version = () => {
}, []); }, []);
return ( return (
<h2>{v}</h2> <p>{v}</p>
); );
} }

View File

@ -4,8 +4,8 @@ import * as gateway from './gateway'
/** /**
*/ */
export function listIdentities() { export function listEnvironments() {
return gateway.request(listIdentitiesOperation) return gateway.request(listEnvironmentsOperation)
} }
/** /**
@ -14,8 +14,8 @@ export function version() {
return gateway.request(versionOperation) return gateway.request(versionOperation)
} }
const listIdentitiesOperation = { const listEnvironmentsOperation = {
path: '/listIdentities', path: '/listEnvironments',
method: 'get', method: 'get',
security: [ security: [
{ {

View File

@ -25,7 +25,7 @@
*/ */
/** /**
* @typedef identity * @typedef environment
* @memberof module:types * @memberof module:types
* *
* @property {string} zitiId * @property {string} zitiId

View File

@ -14,11 +14,6 @@ h1, h2, h3, h4, h5, h6 {
font-family: 'Russo One', sans-serif; font-family: 'Russo One', sans-serif;
} }
.title {
font-family: 'Russo One', sans-serif;
font-size: 3em;
margin-left: 0.53em;
}
.container { .container {
display: grid; display: grid;
@ -32,17 +27,46 @@ h1, h2, h3, h4, h5, h6 {
padding-left: 2em; padding-left: 2em;
padding-right: 2em; padding-right: 2em;
display: flex; display: flex;
align-items: center;
border-radius: 0 0 25px 25px; border-radius: 0 0 25px 25px;
} }
.header-title {
.header-left { font-family: 'Russo One', sans-serif;
font-size: 3em;
margin-left: 0.53em;
}
.header-status {
width: 100%; width: 100%;
display: grid; display: grid;
align-items: center; padding-bottom: 1em;
grid-row-start: 2;
}
.header-status div p {
font-size: 75%;
}
.header-status div {
text-align: right;
}
.header-controls {
display: flex;
grid-row-start: 2;
justify-content: right; justify-content: right;
} }
.header-left div { .header-controls button {
text-align: right; margin-left: 30px;
display: flex;
align-items: center;
background-color: #5241a8;
border-radius: 5px 5px 5px 5px;
border: 1px solid #846fec;
color: lightgray;
padding: 5px;
width: 60px;
justify-content: center;
}
.header-controls button:hover {
color: white;
border-color: white;
} }
.main { .main {