skeleton bits for zrok enable

This commit is contained in:
Michael Quigley 2022-07-25 17:05:44 -04:00
parent 17c75b212d
commit bb57075059
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
15 changed files with 793 additions and 48 deletions

View File

@ -15,7 +15,7 @@ func init() {
var createCmd = &cobra.Command{
Use: "create",
Short: "create objects",
Short: "Create objects",
}
var createAccountCmd = &cobra.Command{

37
cmd/zrok/enable.go Normal file
View File

@ -0,0 +1,37 @@
package main
import (
"github.com/openziti-test-kitchen/zrok/rest_model"
"github.com/openziti-test-kitchen/zrok/rest_zrok_client/identity"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(enableCmd)
}
var enableCmd = &cobra.Command{
Use: "enable <token>",
Short: "Enable an environment for zrok",
Run: enable,
}
func enable(_ *cobra.Command, args []string) {
if len(args) != 1 {
panic(errors.Errorf("provide a single zrok token"))
}
zrok := newZrokClient()
req := identity.NewEnableParams()
req.Body = &rest_model.EnableRequest{
Token: args[0],
}
resp, err := zrok.Identity.Enable(req)
if err != nil {
panic(err)
}
logrus.Infof("enabled, identity = '%v'", resp.Payload.Identity)
}

56
controller/account.go Normal file
View File

@ -0,0 +1,56 @@
package controller
import (
"crypto/sha512"
"encoding/hex"
"github.com/go-openapi/runtime/middleware"
"github.com/openziti-test-kitchen/zrok/controller/store"
"github.com/openziti-test-kitchen/zrok/rest_model"
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations/identity"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
func createAccountHandler(params identity.CreateAccountParams) middleware.Responder {
logrus.Infof("received account request for username '%v'", params.Body.Username)
if params.Body == nil || params.Body.Username == "" || params.Body.Password == "" {
return middleware.Error(500, errors.Errorf("invalid username or password"))
}
token, err := generateApiToken()
if err != nil {
logrus.Errorf("error generating api token: %v", err)
return middleware.Error(500, err.Error())
}
a := &store.Account{
Username: params.Body.Username,
Password: hashPassword(params.Body.Password),
Token: token,
}
tx, err := str.Begin()
if err != nil {
logrus.Errorf("error starting transaction: %v", err)
return middleware.Error(500, err.Error())
}
id, err := str.CreateAccount(a, tx)
if err != nil {
logrus.Errorf("error creating account: %v", err)
_ = tx.Rollback()
return middleware.Error(400, err.Error())
}
if err := tx.Commit(); err != nil {
logrus.Errorf("error comitting: %v", err)
}
logrus.Infof("account created with id = '%v'", id)
return identity.NewCreateAccountCreated().WithPayload(&rest_model.AccountResponse{
Token: token,
})
}
func hashPassword(raw string) string {
hash := sha512.New()
hash.Write([]byte(raw))
return hex.EncodeToString(hash.Sum(nil))
}

View File

@ -1,8 +1,6 @@
package controller
import (
"crypto/sha512"
"encoding/hex"
"github.com/go-openapi/loads"
"github.com/go-openapi/runtime/middleware"
"github.com/openziti-test-kitchen/zrok/controller/store"
@ -12,7 +10,6 @@ import (
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations/identity"
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations/metadata"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
var str *store.Store
@ -32,6 +29,7 @@ func Run(cfg *Config) error {
api := operations.NewZrokAPI(swaggerSpec)
api.MetadataVersionHandler = metadata.VersionHandlerFunc(versionHandler)
api.IdentityCreateAccountHandler = identity.CreateAccountHandlerFunc(createAccountHandler)
api.IdentityEnableHandler = identity.EnableHandlerFunc(enableHandler)
server := rest_zrok_server.NewServer(api)
defer func() { _ = server.Shutdown() }()
@ -47,47 +45,3 @@ func Run(cfg *Config) error {
func versionHandler(_ metadata.VersionParams) middleware.Responder {
return metadata.NewGetOK().WithPayload(&rest_model.Version{Version: "v0.0.0; sk3tch"})
}
func createAccountHandler(params identity.CreateAccountParams) middleware.Responder {
logrus.Infof("received account request for username '%v'", params.Body.Username)
if params.Body == nil || params.Body.Username == "" || params.Body.Password == "" {
return middleware.Error(500, errors.Errorf("invalid username or password"))
}
token, err := generateApiToken()
if err != nil {
logrus.Errorf("error generating api token: %v", err)
return middleware.Error(500, err.Error())
}
a := &store.Account{
Username: params.Body.Username,
Password: hashPassword(params.Body.Password),
Token: token,
}
tx, err := str.Begin()
if err != nil {
logrus.Errorf("error starting transaction: %v", err)
return middleware.Error(500, err.Error())
}
id, err := str.CreateAccount(a, tx)
if err != nil {
logrus.Errorf("error creating account: %v", err)
_ = tx.Rollback()
return middleware.Error(400, err.Error())
}
if err := tx.Commit(); err != nil {
logrus.Errorf("error comitting: %v", err)
}
logrus.Infof("account created with id = '%v'", id)
return identity.NewCreateAccountCreated().WithPayload(&rest_model.AccountResponse{
Token: token,
})
}
func hashPassword(raw string) string {
hash := sha512.New()
hash.Write([]byte(raw))
return hex.EncodeToString(hash.Sum(nil))
}

30
controller/enable.go Normal file
View File

@ -0,0 +1,30 @@
package controller
import (
"github.com/go-openapi/runtime/middleware"
"github.com/openziti-test-kitchen/zrok/rest_model"
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations/identity"
"github.com/sirupsen/logrus"
)
func enableHandler(params identity.EnableParams) middleware.Responder {
tx, err := str.Begin()
if err != nil {
logrus.Errorf("error starting transaction: %v", err)
return middleware.Error(500, err.Error())
}
a, err := str.FindAccountWithToken(params.Body.Token, tx)
if err != nil {
logrus.Errorf("error finding account: %v", err)
return middleware.Error(500, err.Error())
}
if a == nil {
logrus.Errorf("account not found: %v", err)
return middleware.Error(404, err.Error())
}
logrus.Infof("found account '%v'", a.Username)
return identity.NewEnableCreated().WithPayload(&rest_model.EnableResponse{
Identity: a.Username,
})
}

View File

@ -0,0 +1,148 @@
// Code generated by go-swagger; DO NOT EDIT.
package identity
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/openziti-test-kitchen/zrok/rest_model"
)
// NewEnableParams creates a new EnableParams 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 NewEnableParams() *EnableParams {
return &EnableParams{
timeout: cr.DefaultTimeout,
}
}
// NewEnableParamsWithTimeout creates a new EnableParams object
// with the ability to set a timeout on a request.
func NewEnableParamsWithTimeout(timeout time.Duration) *EnableParams {
return &EnableParams{
timeout: timeout,
}
}
// NewEnableParamsWithContext creates a new EnableParams object
// with the ability to set a context for a request.
func NewEnableParamsWithContext(ctx context.Context) *EnableParams {
return &EnableParams{
Context: ctx,
}
}
// NewEnableParamsWithHTTPClient creates a new EnableParams object
// with the ability to set a custom HTTPClient for a request.
func NewEnableParamsWithHTTPClient(client *http.Client) *EnableParams {
return &EnableParams{
HTTPClient: client,
}
}
/* EnableParams contains all the parameters to send to the API endpoint
for the enable operation.
Typically these are written to a http.Request.
*/
type EnableParams struct {
// Body.
Body *rest_model.EnableRequest
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the enable params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *EnableParams) WithDefaults() *EnableParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the enable params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *EnableParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the enable params
func (o *EnableParams) WithTimeout(timeout time.Duration) *EnableParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the enable params
func (o *EnableParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the enable params
func (o *EnableParams) WithContext(ctx context.Context) *EnableParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the enable params
func (o *EnableParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the enable params
func (o *EnableParams) WithHTTPClient(client *http.Client) *EnableParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the enable params
func (o *EnableParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the enable params
func (o *EnableParams) WithBody(body *rest_model.EnableRequest) *EnableParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the enable params
func (o *EnableParams) SetBody(body *rest_model.EnableRequest) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *EnableParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if o.Body != nil {
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,94 @@
// Code generated by go-swagger; DO NOT EDIT.
package identity
// 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"
)
// EnableReader is a Reader for the Enable structure.
type EnableReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *EnableReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 201:
result := NewEnableCreated()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 500:
result := NewEnableInternalServerError()
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())
}
}
// NewEnableCreated creates a EnableCreated with default headers values
func NewEnableCreated() *EnableCreated {
return &EnableCreated{}
}
/* EnableCreated describes a response with status code 201, with default header values.
environment enabled
*/
type EnableCreated struct {
Payload *rest_model.EnableResponse
}
func (o *EnableCreated) Error() string {
return fmt.Sprintf("[POST /enable][%d] enableCreated %+v", 201, o.Payload)
}
func (o *EnableCreated) GetPayload() *rest_model.EnableResponse {
return o.Payload
}
func (o *EnableCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(rest_model.EnableResponse)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewEnableInternalServerError creates a EnableInternalServerError with default headers values
func NewEnableInternalServerError() *EnableInternalServerError {
return &EnableInternalServerError{}
}
/* EnableInternalServerError describes a response with status code 500, with default header values.
internal server error
*/
type EnableInternalServerError struct {
}
func (o *EnableInternalServerError) Error() string {
return fmt.Sprintf("[POST /enable][%d] enableInternalServerError ", 500)
}
func (o *EnableInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}

View File

@ -32,6 +32,8 @@ type ClientOption func(*runtime.ClientOperation)
type ClientService interface {
CreateAccount(params *CreateAccountParams, opts ...ClientOption) (*CreateAccountCreated, error)
Enable(params *EnableParams, opts ...ClientOption) (*EnableCreated, error)
SetTransport(transport runtime.ClientTransport)
}
@ -73,6 +75,44 @@ func (a *Client) CreateAccount(params *CreateAccountParams, opts ...ClientOption
panic(msg)
}
/*
Enable enable API
*/
func (a *Client) Enable(params *EnableParams, opts ...ClientOption) (*EnableCreated, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewEnableParams()
}
op := &runtime.ClientOperation{
ID: "enable",
Method: "POST",
PathPattern: "/enable",
ProducesMediaTypes: []string{"application/zrok.v1+json"},
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
Schemes: []string{"http"},
Params: params,
Reader: &EnableReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*EnableCreated)
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 enable: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport

View File

@ -65,6 +65,34 @@ func init() {
}
}
},
"/enable": {
"post": {
"tags": [
"identity"
],
"operationId": "enable",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/enableRequest"
}
}
],
"responses": {
"201": {
"description": "environment enabled",
"schema": {
"$ref": "#/definitions/enableResponse"
}
},
"500": {
"description": "internal server error"
}
}
}
},
"/version": {
"get": {
"tags": [
@ -176,6 +204,34 @@ func init() {
}
}
},
"/enable": {
"post": {
"tags": [
"identity"
],
"operationId": "enable",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/enableRequest"
}
}
],
"responses": {
"201": {
"description": "environment enabled",
"schema": {
"$ref": "#/definitions/enableResponse"
}
},
"500": {
"description": "internal server error"
}
}
}
},
"/version": {
"get": {
"tags": [

View File

@ -0,0 +1,56 @@
// Code generated by go-swagger; DO NOT EDIT.
package identity
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
)
// EnableHandlerFunc turns a function with the right signature into a enable handler
type EnableHandlerFunc func(EnableParams) middleware.Responder
// Handle executing the request and returning a response
func (fn EnableHandlerFunc) Handle(params EnableParams) middleware.Responder {
return fn(params)
}
// EnableHandler interface for that can handle valid enable params
type EnableHandler interface {
Handle(EnableParams) middleware.Responder
}
// NewEnable creates a new http.Handler for the enable operation
func NewEnable(ctx *middleware.Context, handler EnableHandler) *Enable {
return &Enable{Context: ctx, Handler: handler}
}
/* Enable swagger:route POST /enable identity enable
Enable enable API
*/
type Enable struct {
Context *middleware.Context
Handler EnableHandler
}
func (o *Enable) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewEnableParams()
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@ -0,0 +1,77 @@
// Code generated by go-swagger; DO NOT EDIT.
package identity
// 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"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/validate"
"github.com/openziti-test-kitchen/zrok/rest_model"
)
// NewEnableParams creates a new EnableParams object
//
// There are no default values defined in the spec.
func NewEnableParams() EnableParams {
return EnableParams{}
}
// EnableParams contains all the bound params for the enable operation
// typically these are obtained from a http.Request
//
// swagger:parameters enable
type EnableParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
In: body
*/
Body *rest_model.EnableRequest
}
// 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 NewEnableParams() beforehand.
func (o *EnableParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if runtime.HasBody(r) {
defer r.Body.Close()
var body rest_model.EnableRequest
if err := route.Consumer.Consume(r.Body, &body); err != nil {
res = append(res, errors.NewParseError("body", "body", "", err))
} else {
// validate body object
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
ctx := validate.WithOperationRequest(context.Background())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Body = &body
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,82 @@
// Code generated by go-swagger; DO NOT EDIT.
package identity
// 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"
)
// EnableCreatedCode is the HTTP code returned for type EnableCreated
const EnableCreatedCode int = 201
/*EnableCreated environment enabled
swagger:response enableCreated
*/
type EnableCreated struct {
/*
In: Body
*/
Payload *rest_model.EnableResponse `json:"body,omitempty"`
}
// NewEnableCreated creates EnableCreated with default headers values
func NewEnableCreated() *EnableCreated {
return &EnableCreated{}
}
// WithPayload adds the payload to the enable created response
func (o *EnableCreated) WithPayload(payload *rest_model.EnableResponse) *EnableCreated {
o.Payload = payload
return o
}
// SetPayload sets the payload to the enable created response
func (o *EnableCreated) SetPayload(payload *rest_model.EnableResponse) {
o.Payload = payload
}
// WriteResponse to the client
func (o *EnableCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(201)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}
// EnableInternalServerErrorCode is the HTTP code returned for type EnableInternalServerError
const EnableInternalServerErrorCode int = 500
/*EnableInternalServerError internal server error
swagger:response enableInternalServerError
*/
type EnableInternalServerError struct {
}
// NewEnableInternalServerError creates EnableInternalServerError with default headers values
func NewEnableInternalServerError() *EnableInternalServerError {
return &EnableInternalServerError{}
}
// WriteResponse to the client
func (o *EnableInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(500)
}

View File

@ -0,0 +1,84 @@
// Code generated by go-swagger; DO NOT EDIT.
package identity
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
)
// EnableURL generates an URL for the enable operation
type EnableURL 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 *EnableURL) WithBasePath(bp string) *EnableURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *EnableURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *EnableURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/enable"
_basePath := o._basePath
_result.Path = golangswaggerpaths.Join(_basePath, _path)
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *EnableURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *EnableURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *EnableURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on EnableURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on EnableURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *EnableURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@ -48,6 +48,9 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
IdentityCreateAccountHandler: identity.CreateAccountHandlerFunc(func(params identity.CreateAccountParams) middleware.Responder {
return middleware.NotImplemented("operation identity.CreateAccount has not yet been implemented")
}),
IdentityEnableHandler: identity.EnableHandlerFunc(func(params identity.EnableParams) middleware.Responder {
return middleware.NotImplemented("operation identity.Enable has not yet been implemented")
}),
MetadataVersionHandler: metadata.VersionHandlerFunc(func(params metadata.VersionParams) middleware.Responder {
return middleware.NotImplemented("operation metadata.Version has not yet been implemented")
}),
@ -89,6 +92,8 @@ type ZrokAPI struct {
// IdentityCreateAccountHandler sets the operation handler for the create account operation
IdentityCreateAccountHandler identity.CreateAccountHandler
// IdentityEnableHandler sets the operation handler for the enable operation
IdentityEnableHandler identity.EnableHandler
// MetadataVersionHandler sets the operation handler for the version operation
MetadataVersionHandler metadata.VersionHandler
@ -171,6 +176,9 @@ func (o *ZrokAPI) Validate() error {
if o.IdentityCreateAccountHandler == nil {
unregistered = append(unregistered, "identity.CreateAccountHandler")
}
if o.IdentityEnableHandler == nil {
unregistered = append(unregistered, "identity.EnableHandler")
}
if o.MetadataVersionHandler == nil {
unregistered = append(unregistered, "metadata.VersionHandler")
}
@ -266,6 +274,10 @@ func (o *ZrokAPI) initHandlerCache() {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/account"] = identity.NewCreateAccount(o.context, o.IdentityCreateAccountHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/enable"] = identity.NewEnable(o.context, o.IdentityEnableHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}

View File

@ -23,6 +23,25 @@ paths:
description: account not created (already exists)
500:
description: internal server error
/enable:
post:
tags:
- identity
operationId: enable
parameters:
- name: body
in: body
schema:
$ref: "#/definitions/enableRequest"
responses:
201:
description: environment enabled
schema:
$ref: "#/definitions/enableResponse"
404:
description: account not found
500:
description: internal server error
/version:
get:
tags: