mirror of
https://github.com/openziti/zrok.git
synced 2025-02-16 10:19:18 +01:00
identities -> 'environments'
This commit is contained in:
parent
1a4bb269e8
commit
46b00ab9f0
@ -25,7 +25,7 @@ func Run(cfg *Config) error {
|
||||
api.IdentityCreateAccountHandler = identity.CreateAccountHandlerFunc(createAccountHandler)
|
||||
api.IdentityEnableHandler = identity.EnableHandlerFunc(enableHandler)
|
||||
api.IdentityLoginHandler = identity.LoginHandlerFunc(loginHandler)
|
||||
api.MetadataListIdentitiesHandler = metadata.ListIdentitiesHandlerFunc(listIdentitiesHandler)
|
||||
api.MetadataListEnvironmentsHandler = metadata.ListEnvironmentsHandlerFunc(listEnvironmentsHandler)
|
||||
api.MetadataVersionHandler = metadata.VersionHandlerFunc(versionHandler)
|
||||
api.TunnelTunnelHandler = tunnel.TunnelHandlerFunc(tunnelHandler)
|
||||
api.TunnelUntunnelHandler = tunnel.UntunnelHandlerFunc(untunnelHandler)
|
||||
|
@ -7,26 +7,26 @@ import (
|
||||
"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()
|
||||
if err != nil {
|
||||
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() }()
|
||||
ids, err := str.FindIdentitiesForAccount(int(principal.ID), tx)
|
||||
if err != nil {
|
||||
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 {
|
||||
out = append(out, &rest_model_zrok.Identity{
|
||||
out = append(out, &rest_model_zrok.Environment{
|
||||
Active: id.Active,
|
||||
CreatedAt: id.CreatedAt.String(),
|
||||
UpdatedAt: id.UpdatedAt.String(),
|
||||
ZitiID: id.ZitiId,
|
||||
})
|
||||
}
|
||||
return metadata.NewListIdentitiesOK().WithPayload(out)
|
||||
return metadata.NewListEnvironmentsOK().WithPayload(out)
|
||||
}
|
||||
|
126
rest_client_zrok/metadata/list_environments_parameters.go
Normal file
126
rest_client_zrok/metadata/list_environments_parameters.go
Normal 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
|
||||
}
|
101
rest_client_zrok/metadata/list_environments_responses.go
Normal file
101
rest_client_zrok/metadata/list_environments_responses.go
Normal 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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -30,7 +30,7 @@ type ClientOption func(*runtime.ClientOperation)
|
||||
|
||||
// ClientService is the interface for Client methods
|
||||
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)
|
||||
|
||||
@ -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
|
||||
if params == nil {
|
||||
params = NewListIdentitiesParams()
|
||||
params = NewListEnvironmentsParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "listIdentities",
|
||||
ID: "listEnvironments",
|
||||
Method: "GET",
|
||||
PathPattern: "/listIdentities",
|
||||
PathPattern: "/listEnvironments",
|
||||
ProducesMediaTypes: []string{"application/zrok.v1+json"},
|
||||
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &ListIdentitiesReader{formats: a.formats},
|
||||
Reader: &ListEnvironmentsReader{formats: a.formats},
|
||||
AuthInfo: authInfo,
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
@ -66,13 +66,13 @@ func (a *Client) ListIdentities(params *ListIdentitiesParams, authInfo runtime.C
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*ListIdentitiesOK)
|
||||
success, ok := result.(*ListEnvironmentsOK)
|
||||
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 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)
|
||||
}
|
||||
|
||||
|
@ -12,10 +12,10 @@ import (
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// Identity identity
|
||||
// Environment environment
|
||||
//
|
||||
// swagger:model identity
|
||||
type Identity struct {
|
||||
// swagger:model environment
|
||||
type Environment struct {
|
||||
|
||||
// active
|
||||
Active bool `json:"active,omitempty"`
|
||||
@ -30,18 +30,18 @@ type Identity struct {
|
||||
ZitiID string `json:"zitiId,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this identity
|
||||
func (m *Identity) Validate(formats strfmt.Registry) error {
|
||||
// Validate validates this environment
|
||||
func (m *Environment) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this identity based on context it is used
|
||||
func (m *Identity) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
// ContextValidate validates this environment based on context it is used
|
||||
func (m *Environment) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *Identity) MarshalBinary() ([]byte, error) {
|
||||
func (m *Environment) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@ -49,8 +49,8 @@ func (m *Identity) MarshalBinary() ([]byte, error) {
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *Identity) UnmarshalBinary(b []byte) error {
|
||||
var res Identity
|
||||
func (m *Environment) UnmarshalBinary(b []byte) error {
|
||||
var res Environment
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
@ -14,13 +14,13 @@ import (
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// Identities identities
|
||||
// Environments environments
|
||||
//
|
||||
// swagger:model identities
|
||||
type Identities []*Identity
|
||||
// swagger:model environments
|
||||
type Environments []*Environment
|
||||
|
||||
// Validate validates this identities
|
||||
func (m Identities) Validate(formats strfmt.Registry) error {
|
||||
// Validate validates this environments
|
||||
func (m Environments) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
for i := 0; i < len(m); i++ {
|
||||
@ -47,8 +47,8 @@ func (m Identities) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this identities based on the context it is used
|
||||
func (m Identities) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
// ContextValidate validate this environments based on the context it is used
|
||||
func (m Environments) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
for i := 0; i < len(m); i++ {
|
@ -4,27 +4,92 @@ package rest_server_zrok
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"github.com/openziti-test-kitchen/zrok/ui"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"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/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) {
|
||||
// api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... }
|
||||
}
|
||||
|
||||
func configureAPI(api *operations.ZrokAPI) http.Handler {
|
||||
// configure the api here
|
||||
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()
|
||||
// To continue using redoc as your UI, uncomment the following line
|
||||
// api.UseRedoc()
|
||||
|
||||
api.JSONConsumer = runtime.JSONConsumer()
|
||||
|
||||
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.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.
|
||||
// So this is a good place to plug in a panic handling middleware, logging and metrics.
|
||||
func setupGlobalMiddleware(handler http.Handler) http.Handler {
|
||||
logrus.Infof("configuring")
|
||||
return ui.StaticBuilder(handler)
|
||||
return handler
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/listIdentities": {
|
||||
"/listEnvironments": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
@ -115,12 +115,12 @@ func init() {
|
||||
"tags": [
|
||||
"metadata"
|
||||
],
|
||||
"operationId": "listIdentities",
|
||||
"operationId": "listEnvironments",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "success",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/identities"
|
||||
"$ref": "#/definitions/environments"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
@ -289,16 +289,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"type": "string"
|
||||
},
|
||||
"identities": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/identity"
|
||||
}
|
||||
},
|
||||
"identity": {
|
||||
"environment": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"active": {
|
||||
@ -315,6 +306,15 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"environments": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/environment"
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"type": "string"
|
||||
},
|
||||
"loginRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -470,7 +470,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/listIdentities": {
|
||||
"/listEnvironments": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
@ -480,12 +480,12 @@ func init() {
|
||||
"tags": [
|
||||
"metadata"
|
||||
],
|
||||
"operationId": "listIdentities",
|
||||
"operationId": "listEnvironments",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "success",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/identities"
|
||||
"$ref": "#/definitions/environments"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
@ -654,16 +654,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"type": "string"
|
||||
},
|
||||
"identities": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/identity"
|
||||
}
|
||||
},
|
||||
"identity": {
|
||||
"environment": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"active": {
|
||||
@ -680,6 +671,15 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"environments": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/environment"
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"type": "string"
|
||||
},
|
||||
"loginRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -13,40 +13,40 @@ import (
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// ListIdentitiesHandlerFunc turns a function with the right signature into a list identities handler
|
||||
type ListIdentitiesHandlerFunc func(ListIdentitiesParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
// ListEnvironmentsHandlerFunc turns a function with the right signature into a list environments handler
|
||||
type ListEnvironmentsHandlerFunc func(ListEnvironmentsParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// ListIdentitiesHandler interface for that can handle valid list identities params
|
||||
type ListIdentitiesHandler interface {
|
||||
Handle(ListIdentitiesParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
// ListEnvironmentsHandler interface for that can handle valid list environments params
|
||||
type ListEnvironmentsHandler interface {
|
||||
Handle(ListEnvironmentsParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewListIdentities creates a new http.Handler for the list identities operation
|
||||
func NewListIdentities(ctx *middleware.Context, handler ListIdentitiesHandler) *ListIdentities {
|
||||
return &ListIdentities{Context: ctx, Handler: handler}
|
||||
// NewListEnvironments creates a new http.Handler for the list environments operation
|
||||
func NewListEnvironments(ctx *middleware.Context, handler ListEnvironmentsHandler) *ListEnvironments {
|
||||
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
|
||||
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)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewListIdentitiesParams()
|
||||
var Params = NewListEnvironmentsParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
@ -12,19 +12,19 @@ import (
|
||||
"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.
|
||||
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
|
||||
//
|
||||
// swagger:parameters listIdentities
|
||||
type ListIdentitiesParams struct {
|
||||
// swagger:parameters listEnvironments
|
||||
type ListEnvironmentsParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
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
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewListIdentitiesParams() beforehand.
|
||||
func (o *ListIdentitiesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
// To ensure default values, the struct must have been initialized with NewListEnvironmentsParams() beforehand.
|
||||
func (o *ListEnvironmentsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
@ -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
|
||||
}
|
||||
}
|
@ -11,15 +11,15 @@ import (
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// ListIdentitiesURL generates an URL for the list identities operation
|
||||
type ListIdentitiesURL struct {
|
||||
// ListEnvironmentsURL generates an URL for the list environments operation
|
||||
type ListEnvironmentsURL 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 *ListIdentitiesURL) WithBasePath(bp string) *ListIdentitiesURL {
|
||||
func (o *ListEnvironmentsURL) WithBasePath(bp string) *ListEnvironmentsURL {
|
||||
o.SetBasePath(bp)
|
||||
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
|
||||
// base path specified in the swagger spec.
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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 _path = "/listIdentities"
|
||||
var _path = "/listEnvironments"
|
||||
|
||||
_basePath := o._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
|
||||
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 {
|
||||
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
|
||||
func (o *ListIdentitiesURL) String() string {
|
||||
func (o *ListEnvironmentsURL) String() string {
|
||||
return o.Must(o.Build()).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 == "" {
|
||||
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 == "" {
|
||||
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()
|
||||
@ -82,6 +82,6 @@ func (o *ListIdentitiesURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
@ -53,8 +53,8 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
|
||||
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")
|
||||
}),
|
||||
MetadataListIdentitiesHandler: metadata.ListIdentitiesHandlerFunc(func(params metadata.ListIdentitiesParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation metadata.ListIdentities has not yet been implemented")
|
||||
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")
|
||||
}),
|
||||
IdentityLoginHandler: identity.LoginHandlerFunc(func(params identity.LoginParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation identity.Login has not yet been implemented")
|
||||
@ -122,8 +122,8 @@ type ZrokAPI struct {
|
||||
IdentityCreateAccountHandler identity.CreateAccountHandler
|
||||
// IdentityEnableHandler sets the operation handler for the enable operation
|
||||
IdentityEnableHandler identity.EnableHandler
|
||||
// MetadataListIdentitiesHandler sets the operation handler for the list identities operation
|
||||
MetadataListIdentitiesHandler metadata.ListIdentitiesHandler
|
||||
// MetadataListEnvironmentsHandler sets the operation handler for the list environments operation
|
||||
MetadataListEnvironmentsHandler metadata.ListEnvironmentsHandler
|
||||
// IdentityLoginHandler sets the operation handler for the login operation
|
||||
IdentityLoginHandler identity.LoginHandler
|
||||
// TunnelTunnelHandler sets the operation handler for the tunnel operation
|
||||
@ -219,8 +219,8 @@ func (o *ZrokAPI) Validate() error {
|
||||
if o.IdentityEnableHandler == nil {
|
||||
unregistered = append(unregistered, "identity.EnableHandler")
|
||||
}
|
||||
if o.MetadataListIdentitiesHandler == nil {
|
||||
unregistered = append(unregistered, "metadata.ListIdentitiesHandler")
|
||||
if o.MetadataListEnvironmentsHandler == nil {
|
||||
unregistered = append(unregistered, "metadata.ListEnvironmentsHandler")
|
||||
}
|
||||
if o.IdentityLoginHandler == nil {
|
||||
unregistered = append(unregistered, "identity.LoginHandler")
|
||||
@ -344,7 +344,7 @@ func (o *ZrokAPI) initHandlerCache() {
|
||||
if o.handlers["GET"] == nil {
|
||||
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 {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ paths:
|
||||
description: internal server error
|
||||
schema:
|
||||
$ref: "#/definitions/errorMessage"
|
||||
|
||||
/enable:
|
||||
post:
|
||||
tags:
|
||||
@ -55,22 +56,24 @@ paths:
|
||||
description: internal server error
|
||||
schema:
|
||||
$ref: "#/definitions/errorMessage"
|
||||
/listIdentities:
|
||||
|
||||
/listEnvironments:
|
||||
get:
|
||||
tags:
|
||||
- metadata
|
||||
security:
|
||||
- key: []
|
||||
operationId: listIdentities
|
||||
operationId: listEnvironments
|
||||
responses:
|
||||
200:
|
||||
description: success
|
||||
schema:
|
||||
$ref: "#/definitions/identities"
|
||||
$ref: "#/definitions/environments"
|
||||
500:
|
||||
description: internal server error
|
||||
schema:
|
||||
$ref: "#/definitions/errorMessage"
|
||||
|
||||
/login:
|
||||
post:
|
||||
tags:
|
||||
@ -88,6 +91,7 @@ paths:
|
||||
$ref: "#/definitions/loginResponse"
|
||||
401:
|
||||
description: invalid login
|
||||
|
||||
/tunnel:
|
||||
post:
|
||||
tags:
|
||||
@ -160,6 +164,7 @@ definitions:
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
|
||||
enableResponse:
|
||||
type: object
|
||||
properties:
|
||||
@ -167,13 +172,12 @@ definitions:
|
||||
type: string
|
||||
cfg:
|
||||
type: string
|
||||
errorMessage:
|
||||
type: string
|
||||
identities:
|
||||
|
||||
environments:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/definitions/identity"
|
||||
identity:
|
||||
$ref: "#/definitions/environment"
|
||||
environment:
|
||||
type: object
|
||||
properties:
|
||||
zitiId:
|
||||
@ -184,6 +188,10 @@ definitions:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
|
||||
errorMessage:
|
||||
type: string
|
||||
|
||||
loginRequest:
|
||||
type: object
|
||||
properties:
|
||||
@ -193,6 +201,7 @@ definitions:
|
||||
type: string
|
||||
loginResponse:
|
||||
type: string
|
||||
|
||||
principal:
|
||||
type: object
|
||||
properties:
|
||||
@ -202,6 +211,7 @@ definitions:
|
||||
type: string
|
||||
token:
|
||||
type: string
|
||||
|
||||
tunnelRequest:
|
||||
type: object
|
||||
properties:
|
||||
@ -214,11 +224,13 @@ definitions:
|
||||
properties:
|
||||
service:
|
||||
type: string
|
||||
|
||||
untunnelRequest:
|
||||
type: object
|
||||
properties:
|
||||
service:
|
||||
type: string
|
||||
|
||||
version:
|
||||
type: string
|
||||
|
||||
@ -228,4 +240,4 @@ consumes:
|
||||
- application/zrok.v1+json
|
||||
schemes:
|
||||
- http
|
||||
swagger: "2.0"
|
||||
swagger: "2.0"
|
@ -2,7 +2,9 @@ import Login from './Login';
|
||||
import Logout from './Logout';
|
||||
import Version from './Version';
|
||||
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 [user, setUser] = useState();
|
||||
@ -25,22 +27,24 @@ const App = () => {
|
||||
<div className="zrok">
|
||||
<div className="container">
|
||||
<div className="header">
|
||||
<img src="ziggy.svg" width="65px"/>
|
||||
<p className="title">zrok</p>
|
||||
<div className="header-left">
|
||||
<img alt="ziggy goes to space" src="ziggy.svg" width="65px"/>
|
||||
<p className="header-title">zrok</p>
|
||||
<div className={"header-status"}>
|
||||
<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={() => {
|
||||
setUser(null);
|
||||
localStorage.clear();
|
||||
}}/>
|
||||
</div>
|
||||
<div>
|
||||
<Version/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="main">
|
||||
<Identities user={user}/>
|
||||
<Environments user={user}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -2,8 +2,8 @@ import {useEffect, useState} from "react";
|
||||
import * as metadata from './api/metadata';
|
||||
import DataTable from 'react-data-table-component';
|
||||
|
||||
const Identities = (props) => {
|
||||
const [identities, setIdentities] = useState([])
|
||||
const Environments = (props) => {
|
||||
const [environments, setEnvironments] = useState([])
|
||||
|
||||
const columns = [
|
||||
{
|
||||
@ -30,8 +30,8 @@ const Identities = (props) => {
|
||||
|
||||
useEffect(() => {
|
||||
let mounted = true;
|
||||
metadata.listIdentities().then((resp) => {
|
||||
setIdentities(resp.data)
|
||||
metadata.listEnvironments().then((resp) => {
|
||||
setEnvironments(resp.data)
|
||||
console.log(resp.data);
|
||||
})
|
||||
return () => { mounted = false; }
|
||||
@ -39,12 +39,12 @@ const Identities = (props) => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Identities</h1>
|
||||
{ identities && identities.length > 0 && (
|
||||
<h1>Environments</h1>
|
||||
{ environments && environments.length > 0 && (
|
||||
<div>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={identities}
|
||||
data={environments}
|
||||
defaultSortFieldId={1}
|
||||
/>
|
||||
</div>
|
||||
@ -53,4 +53,4 @@ const Identities = (props) => {
|
||||
)
|
||||
};
|
||||
|
||||
export default Identities;
|
||||
export default Environments;
|
@ -9,7 +9,7 @@ const Logout = (props) => {
|
||||
}
|
||||
|
||||
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>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ const Version = () => {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<h2>{v}</h2>
|
||||
<p>{v}</p>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,8 @@ import * as gateway from './gateway'
|
||||
|
||||
/**
|
||||
*/
|
||||
export function listIdentities() {
|
||||
return gateway.request(listIdentitiesOperation)
|
||||
export function listEnvironments() {
|
||||
return gateway.request(listEnvironmentsOperation)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -14,8 +14,8 @@ export function version() {
|
||||
return gateway.request(versionOperation)
|
||||
}
|
||||
|
||||
const listIdentitiesOperation = {
|
||||
path: '/listIdentities',
|
||||
const listEnvironmentsOperation = {
|
||||
path: '/listEnvironments',
|
||||
method: 'get',
|
||||
security: [
|
||||
{
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef identity
|
||||
* @typedef environment
|
||||
* @memberof module:types
|
||||
*
|
||||
* @property {string} zitiId
|
||||
|
@ -14,11 +14,6 @@ h1, h2, h3, h4, h5, h6 {
|
||||
font-family: 'Russo One', sans-serif;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-family: 'Russo One', sans-serif;
|
||||
font-size: 3em;
|
||||
margin-left: 0.53em;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: grid;
|
||||
@ -32,17 +27,46 @@ h1, h2, h3, h4, h5, h6 {
|
||||
padding-left: 2em;
|
||||
padding-right: 2em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 0 0 25px 25px;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
.header-title {
|
||||
font-family: 'Russo One', sans-serif;
|
||||
font-size: 3em;
|
||||
margin-left: 0.53em;
|
||||
}
|
||||
.header-status {
|
||||
width: 100%;
|
||||
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;
|
||||
}
|
||||
.header-left div {
|
||||
text-align: right;
|
||||
.header-controls button {
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user