mirror of
https://github.com/openziti/zrok.git
synced 2024-12-22 06:40:50 +01:00
pr comments
This commit is contained in:
parent
049ef6c9e9
commit
ee078a9e10
@ -11,21 +11,21 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
adminCmd.AddCommand(newGenerateCommand().cmd)
|
||||
adminCmd.AddCommand(newAdminGenerateCommand().cmd)
|
||||
}
|
||||
|
||||
type generateCommand struct {
|
||||
type adminGenerateCommand struct {
|
||||
cmd *cobra.Command
|
||||
amount int
|
||||
}
|
||||
|
||||
func newGenerateCommand() *generateCommand {
|
||||
func newAdminGenerateCommand() *adminGenerateCommand {
|
||||
cmd := &cobra.Command{
|
||||
Use: "generate",
|
||||
Short: "Generate invite tokens (default: 5)",
|
||||
Args: cobra.ExactArgs(0),
|
||||
}
|
||||
command := &generateCommand{cmd: cmd}
|
||||
command := &adminGenerateCommand{cmd: cmd}
|
||||
cmd.Run = command.run
|
||||
|
||||
cmd.Flags().IntVar(&command.amount, "amount", 5, "Amount of tokens to generate")
|
||||
@ -33,7 +33,7 @@ func newGenerateCommand() *generateCommand {
|
||||
return command
|
||||
}
|
||||
|
||||
func (cmd *generateCommand) run(_ *cobra.Command, args []string) {
|
||||
func (cmd *adminGenerateCommand) run(_ *cobra.Command, args []string) {
|
||||
var err error
|
||||
tokens := make([]string, cmd.amount)
|
||||
for i := 0; i < int(cmd.amount); i++ {
|
||||
@ -49,11 +49,11 @@ func (cmd *generateCommand) run(_ *cobra.Command, args []string) {
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
req := admin.NewInviteGenerateParams()
|
||||
req.Body = &rest_model_zrok.InviteGenerateRequest{
|
||||
req := admin.NewInviteTokenGenerateParams()
|
||||
req.Body = &rest_model_zrok.InviteTokenGenerateRequest{
|
||||
Tokens: tokens,
|
||||
}
|
||||
_, err = zrok.Admin.InviteGenerate(req, mustGetAdminAuth())
|
||||
_, err = zrok.Admin.InviteTokenGenerate(req, mustGetAdminAuth())
|
||||
if err != nil {
|
||||
if !panicInstead {
|
||||
showError("error creating invite tokens", err)
|
@ -17,7 +17,7 @@ func init() {
|
||||
|
||||
type inviteCommand struct {
|
||||
cmd *cobra.Command
|
||||
Token string
|
||||
token string
|
||||
}
|
||||
|
||||
func newInviteCommand() *inviteCommand {
|
||||
@ -30,7 +30,7 @@ func newInviteCommand() *inviteCommand {
|
||||
command := &inviteCommand{cmd: cmd}
|
||||
cmd.Run = command.run
|
||||
|
||||
cmd.Flags().StringVar(&command.Token, "token", "", "Invite token required when Zrok running in token store mode")
|
||||
cmd.Flags().StringVar(&command.token, "token", "", "Invite token required when zrok running in token store mode")
|
||||
|
||||
return command
|
||||
}
|
||||
@ -61,7 +61,7 @@ func (cmd *inviteCommand) run(_ *cobra.Command, _ []string) {
|
||||
req := account.NewInviteParams()
|
||||
req.Body = &rest_model_zrok.InviteRequest{
|
||||
Email: email,
|
||||
Token: cmd.Token,
|
||||
Token: cmd.token,
|
||||
}
|
||||
_, err = zrok.Account.Invite(req)
|
||||
if err != nil {
|
||||
|
@ -33,7 +33,7 @@ func Run(inCfg *Config) error {
|
||||
api.AdminCreateFrontendHandler = newCreateFrontendHandler()
|
||||
api.AdminCreateIdentityHandler = newCreateIdentityHandler()
|
||||
api.AdminDeleteFrontendHandler = newDeleteFrontendHandler()
|
||||
api.AdminInviteGenerateHandler = newInviteGenerateHandler()
|
||||
api.AdminInviteTokenGenerateHandler = newInviteTokenGenerateHandler()
|
||||
api.AdminListFrontendsHandler = newListFrontendsHandler()
|
||||
api.AdminUpdateFrontendHandler = newUpdateFrontendHandler()
|
||||
api.EnvironmentEnableHandler = newEnableHandler()
|
||||
|
@ -3,9 +3,7 @@ package controller
|
||||
import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti-test-kitchen/zrok/controller/store"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/account"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/admin"
|
||||
"github.com/openziti-test-kitchen/zrok/util"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -40,12 +38,12 @@ func (self *inviteHandler) Handle(params account.InviteParams) middleware.Respon
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
if self.cfg.Registration.TokenStrategy == "store" {
|
||||
invite, err := str.GetInviteByToken(params.Body.Token, tx)
|
||||
invite, err := str.GetInviteTokenByToken(params.Body.Token, tx)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return account.NewInviteBadRequest()
|
||||
}
|
||||
if err := str.DeleteInvite(invite.Id, tx); err != nil {
|
||||
if err := str.DeleteInviteToken(invite.Id, tx); err != nil {
|
||||
logrus.Error(err)
|
||||
return account.NewInviteInternalServerError()
|
||||
}
|
||||
@ -101,48 +99,3 @@ func (self *inviteHandler) Handle(params account.InviteParams) middleware.Respon
|
||||
|
||||
return account.NewInviteCreated()
|
||||
}
|
||||
|
||||
type inviteGenerateHandler struct {
|
||||
}
|
||||
|
||||
func newInviteGenerateHandler() *inviteGenerateHandler {
|
||||
return &inviteGenerateHandler{}
|
||||
}
|
||||
|
||||
func (handler *inviteGenerateHandler) Handle(params admin.InviteGenerateParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
if !principal.Admin {
|
||||
logrus.Errorf("invalid admin principal")
|
||||
return admin.NewInviteGenerateUnauthorized()
|
||||
}
|
||||
|
||||
if params.Body == nil || len(params.Body.Tokens) == 0 {
|
||||
logrus.Error("missing tokens")
|
||||
return admin.NewInviteGenerateBadRequest()
|
||||
}
|
||||
logrus.Infof("received invite generate request with %d tokens", len(params.Body.Tokens))
|
||||
|
||||
invites := make([]*store.Invite, len(params.Body.Tokens))
|
||||
for i, token := range params.Body.Tokens {
|
||||
invites[i] = &store.Invite{
|
||||
Token: token,
|
||||
}
|
||||
}
|
||||
tx, err := str.Begin()
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return admin.NewInviteGenerateInternalServerError()
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
if err := str.CreateInvites(invites, tx); err != nil {
|
||||
logrus.Error(err)
|
||||
return admin.NewInviteGenerateInternalServerError()
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
logrus.Errorf("error committing inviteGenerate request: %v", err)
|
||||
return account.NewInviteInternalServerError()
|
||||
}
|
||||
|
||||
return admin.NewInviteGenerateCreated()
|
||||
}
|
||||
|
55
controller/inviteTokenGenerate.go
Normal file
55
controller/inviteTokenGenerate.go
Normal file
@ -0,0 +1,55 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti-test-kitchen/zrok/controller/store"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/account"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/admin"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type inviteTokenGenerateHandler struct {
|
||||
}
|
||||
|
||||
func newInviteTokenGenerateHandler() *inviteTokenGenerateHandler {
|
||||
return &inviteTokenGenerateHandler{}
|
||||
}
|
||||
|
||||
func (handler *inviteTokenGenerateHandler) Handle(params admin.InviteTokenGenerateParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
if !principal.Admin {
|
||||
logrus.Errorf("invalid admin principal")
|
||||
return admin.NewInviteTokenGenerateUnauthorized()
|
||||
}
|
||||
|
||||
if params.Body == nil || len(params.Body.Tokens) == 0 {
|
||||
logrus.Error("missing tokens")
|
||||
return admin.NewInviteTokenGenerateBadRequest()
|
||||
}
|
||||
logrus.Infof("received invite generate request with %d tokens", len(params.Body.Tokens))
|
||||
|
||||
invites := make([]*store.InviteToken, len(params.Body.Tokens))
|
||||
for i, token := range params.Body.Tokens {
|
||||
invites[i] = &store.InviteToken{
|
||||
Token: token,
|
||||
}
|
||||
}
|
||||
tx, err := str.Begin()
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return admin.NewInviteTokenGenerateInternalServerError()
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
if err := str.CreateInviteTokens(invites, tx); err != nil {
|
||||
logrus.Error(err)
|
||||
return admin.NewInviteTokenGenerateInternalServerError()
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
logrus.Errorf("error committing inviteGenerate request: %v", err)
|
||||
return account.NewInviteInternalServerError()
|
||||
}
|
||||
|
||||
return admin.NewInviteTokenGenerateCreated()
|
||||
}
|
52
controller/store/invite_tokens.go
Normal file
52
controller/store/invite_tokens.go
Normal file
@ -0,0 +1,52 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type InviteToken struct {
|
||||
Model
|
||||
Token string
|
||||
}
|
||||
|
||||
func (str *Store) CreateInviteTokens(inviteTokens []*InviteToken, tx *sqlx.Tx) error {
|
||||
sql := "insert into invite_tokens (token) values %s"
|
||||
invs := make([]any, len(inviteTokens))
|
||||
queries := make([]string, len(inviteTokens))
|
||||
for i, inv := range inviteTokens {
|
||||
invs[i] = inv.Token
|
||||
queries[i] = fmt.Sprintf("($%d)", i+1)
|
||||
}
|
||||
stmt, err := tx.Prepare(fmt.Sprintf(sql, strings.Join(queries, ",")))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error preparing invite_tokenss insert statement")
|
||||
}
|
||||
if _, err := stmt.Exec(invs...); err != nil {
|
||||
return errors.Wrap(err, "error executing invites_tokens insert statement")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (str *Store) GetInviteTokenByToken(token string, tx *sqlx.Tx) (*InviteToken, error) {
|
||||
inviteToken := &InviteToken{}
|
||||
if err := tx.QueryRowx("select * from invite_tokens where token = $1", token).StructScan(inviteToken); err != nil {
|
||||
return nil, errors.Wrap(err, "error getting unused invite_token")
|
||||
}
|
||||
return inviteToken, nil
|
||||
}
|
||||
|
||||
func (str *Store) DeleteInviteToken(id int, tx *sqlx.Tx) error {
|
||||
stmt, err := tx.Prepare("delete from invite_tokens where id = $1")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error preparing invite_tokens delete statement")
|
||||
}
|
||||
_, err = stmt.Exec(id)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error executing invite_tokens delete statement")
|
||||
}
|
||||
return nil
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Invite struct {
|
||||
Model
|
||||
Token string
|
||||
}
|
||||
|
||||
func (str *Store) CreateInvites(invites []*Invite, tx *sqlx.Tx) error {
|
||||
sql := "insert into invites (token) values %s"
|
||||
invs := make([]any, len(invites))
|
||||
queries := make([]string, len(invites))
|
||||
for i, inv := range invites {
|
||||
invs[i] = inv.Token
|
||||
queries[i] = fmt.Sprintf("($%d)", i+1)
|
||||
}
|
||||
stmt, err := tx.Prepare(fmt.Sprintf(sql, strings.Join(queries, ",")))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error preparing invites insert statement")
|
||||
}
|
||||
if _, err := stmt.Exec(invs...); err != nil {
|
||||
return errors.Wrap(err, "error executing invites insert statement")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (str *Store) GetInviteByToken(token string, tx *sqlx.Tx) (*Invite, error) {
|
||||
invite := &Invite{}
|
||||
if err := tx.QueryRowx("select * from invites where token = $1", token).StructScan(invite); err != nil {
|
||||
return nil, errors.Wrap(err, "error getting unused invite")
|
||||
}
|
||||
return invite, nil
|
||||
}
|
||||
|
||||
func (str *Store) UpdateInvite(invite *Invite, tx *sqlx.Tx) error {
|
||||
stmt, err := tx.Prepare("update invites set token = $1")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error perparing invites update statement")
|
||||
}
|
||||
_, err = stmt.Exec(invite.Token)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error executing invites update statement")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (str *Store) DeleteInvite(id int, tx *sqlx.Tx) error {
|
||||
stmt, err := tx.Prepare("delete from invites where id = $1")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error preparing invites delete statement")
|
||||
}
|
||||
_, err = stmt.Exec(id)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error executing invites delete statement")
|
||||
}
|
||||
return nil
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
-- +migrate Up
|
||||
|
||||
--
|
||||
-- invites
|
||||
-- invite_tokens
|
||||
---
|
||||
|
||||
create table invites (
|
||||
create table invite_tokens (
|
||||
id serial primary key,
|
||||
token varchar(32) not null unique,
|
||||
created_at timestamptz not null default(current_timestamp),
|
||||
|
@ -1,10 +1,10 @@
|
||||
-- +migrate Up
|
||||
|
||||
--
|
||||
-- invites
|
||||
-- invite_tokens
|
||||
---
|
||||
|
||||
create table invites (
|
||||
create table invite_tokens (
|
||||
id integer primary key,
|
||||
token string not null unique,
|
||||
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
|
||||
|
@ -36,7 +36,7 @@ type ClientService interface {
|
||||
|
||||
DeleteFrontend(params *DeleteFrontendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteFrontendOK, error)
|
||||
|
||||
InviteGenerate(params *InviteGenerateParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InviteGenerateCreated, error)
|
||||
InviteTokenGenerate(params *InviteTokenGenerateParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InviteTokenGenerateCreated, error)
|
||||
|
||||
ListFrontends(params *ListFrontendsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListFrontendsOK, error)
|
||||
|
||||
@ -163,22 +163,22 @@ func (a *Client) DeleteFrontend(params *DeleteFrontendParams, authInfo runtime.C
|
||||
}
|
||||
|
||||
/*
|
||||
InviteGenerate invite generate API
|
||||
InviteTokenGenerate invite token generate API
|
||||
*/
|
||||
func (a *Client) InviteGenerate(params *InviteGenerateParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InviteGenerateCreated, error) {
|
||||
func (a *Client) InviteTokenGenerate(params *InviteTokenGenerateParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InviteTokenGenerateCreated, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewInviteGenerateParams()
|
||||
params = NewInviteTokenGenerateParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "inviteGenerate",
|
||||
ID: "inviteTokenGenerate",
|
||||
Method: "POST",
|
||||
PathPattern: "/invite/generate",
|
||||
PathPattern: "/invite/token/generate",
|
||||
ProducesMediaTypes: []string{"application/zrok.v1+json"},
|
||||
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &InviteGenerateReader{formats: a.formats},
|
||||
Reader: &InviteTokenGenerateReader{formats: a.formats},
|
||||
AuthInfo: authInfo,
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
@ -191,13 +191,13 @@ func (a *Client) InviteGenerate(params *InviteGenerateParams, authInfo runtime.C
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*InviteGenerateCreated)
|
||||
success, ok := result.(*InviteTokenGenerateCreated)
|
||||
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 inviteGenerate: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
msg := fmt.Sprintf("unexpected success response for inviteTokenGenerate: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
|
@ -1,150 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// NewInviteGenerateParams creates a new InviteGenerateParams 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 NewInviteGenerateParams() *InviteGenerateParams {
|
||||
return &InviteGenerateParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewInviteGenerateParamsWithTimeout creates a new InviteGenerateParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewInviteGenerateParamsWithTimeout(timeout time.Duration) *InviteGenerateParams {
|
||||
return &InviteGenerateParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewInviteGenerateParamsWithContext creates a new InviteGenerateParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewInviteGenerateParamsWithContext(ctx context.Context) *InviteGenerateParams {
|
||||
return &InviteGenerateParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewInviteGenerateParamsWithHTTPClient creates a new InviteGenerateParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewInviteGenerateParamsWithHTTPClient(client *http.Client) *InviteGenerateParams {
|
||||
return &InviteGenerateParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
InviteGenerateParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the invite generate operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type InviteGenerateParams struct {
|
||||
|
||||
// Body.
|
||||
Body *rest_model_zrok.InviteGenerateRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the invite generate params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *InviteGenerateParams) WithDefaults() *InviteGenerateParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the invite generate params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *InviteGenerateParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the invite generate params
|
||||
func (o *InviteGenerateParams) WithTimeout(timeout time.Duration) *InviteGenerateParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the invite generate params
|
||||
func (o *InviteGenerateParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the invite generate params
|
||||
func (o *InviteGenerateParams) WithContext(ctx context.Context) *InviteGenerateParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the invite generate params
|
||||
func (o *InviteGenerateParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the invite generate params
|
||||
func (o *InviteGenerateParams) WithHTTPClient(client *http.Client) *InviteGenerateParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the invite generate params
|
||||
func (o *InviteGenerateParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the invite generate params
|
||||
func (o *InviteGenerateParams) WithBody(body *rest_model_zrok.InviteGenerateRequest) *InviteGenerateParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the invite generate params
|
||||
func (o *InviteGenerateParams) SetBody(body *rest_model_zrok.InviteGenerateRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *InviteGenerateParams) 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
|
||||
}
|
@ -1,254 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// InviteGenerateReader is a Reader for the InviteGenerate structure.
|
||||
type InviteGenerateReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *InviteGenerateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 201:
|
||||
result := NewInviteGenerateCreated()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 400:
|
||||
result := NewInviteGenerateBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 401:
|
||||
result := NewInviteGenerateUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 500:
|
||||
result := NewInviteGenerateInternalServerError()
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
// NewInviteGenerateCreated creates a InviteGenerateCreated with default headers values
|
||||
func NewInviteGenerateCreated() *InviteGenerateCreated {
|
||||
return &InviteGenerateCreated{}
|
||||
}
|
||||
|
||||
/*
|
||||
InviteGenerateCreated describes a response with status code 201, with default header values.
|
||||
|
||||
invitation tokens created
|
||||
*/
|
||||
type InviteGenerateCreated struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this invite generate created response has a 2xx status code
|
||||
func (o *InviteGenerateCreated) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this invite generate created response has a 3xx status code
|
||||
func (o *InviteGenerateCreated) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this invite generate created response has a 4xx status code
|
||||
func (o *InviteGenerateCreated) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this invite generate created response has a 5xx status code
|
||||
func (o *InviteGenerateCreated) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this invite generate created response a status code equal to that given
|
||||
func (o *InviteGenerateCreated) IsCode(code int) bool {
|
||||
return code == 201
|
||||
}
|
||||
|
||||
func (o *InviteGenerateCreated) Error() string {
|
||||
return fmt.Sprintf("[POST /invite/generate][%d] inviteGenerateCreated ", 201)
|
||||
}
|
||||
|
||||
func (o *InviteGenerateCreated) String() string {
|
||||
return fmt.Sprintf("[POST /invite/generate][%d] inviteGenerateCreated ", 201)
|
||||
}
|
||||
|
||||
func (o *InviteGenerateCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewInviteGenerateBadRequest creates a InviteGenerateBadRequest with default headers values
|
||||
func NewInviteGenerateBadRequest() *InviteGenerateBadRequest {
|
||||
return &InviteGenerateBadRequest{}
|
||||
}
|
||||
|
||||
/*
|
||||
InviteGenerateBadRequest describes a response with status code 400, with default header values.
|
||||
|
||||
invitation tokens not created
|
||||
*/
|
||||
type InviteGenerateBadRequest struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this invite generate bad request response has a 2xx status code
|
||||
func (o *InviteGenerateBadRequest) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this invite generate bad request response has a 3xx status code
|
||||
func (o *InviteGenerateBadRequest) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this invite generate bad request response has a 4xx status code
|
||||
func (o *InviteGenerateBadRequest) IsClientError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsServerError returns true when this invite generate bad request response has a 5xx status code
|
||||
func (o *InviteGenerateBadRequest) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this invite generate bad request response a status code equal to that given
|
||||
func (o *InviteGenerateBadRequest) IsCode(code int) bool {
|
||||
return code == 400
|
||||
}
|
||||
|
||||
func (o *InviteGenerateBadRequest) Error() string {
|
||||
return fmt.Sprintf("[POST /invite/generate][%d] inviteGenerateBadRequest ", 400)
|
||||
}
|
||||
|
||||
func (o *InviteGenerateBadRequest) String() string {
|
||||
return fmt.Sprintf("[POST /invite/generate][%d] inviteGenerateBadRequest ", 400)
|
||||
}
|
||||
|
||||
func (o *InviteGenerateBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewInviteGenerateUnauthorized creates a InviteGenerateUnauthorized with default headers values
|
||||
func NewInviteGenerateUnauthorized() *InviteGenerateUnauthorized {
|
||||
return &InviteGenerateUnauthorized{}
|
||||
}
|
||||
|
||||
/*
|
||||
InviteGenerateUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
unauthorized
|
||||
*/
|
||||
type InviteGenerateUnauthorized struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this invite generate unauthorized response has a 2xx status code
|
||||
func (o *InviteGenerateUnauthorized) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this invite generate unauthorized response has a 3xx status code
|
||||
func (o *InviteGenerateUnauthorized) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this invite generate unauthorized response has a 4xx status code
|
||||
func (o *InviteGenerateUnauthorized) IsClientError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsServerError returns true when this invite generate unauthorized response has a 5xx status code
|
||||
func (o *InviteGenerateUnauthorized) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this invite generate unauthorized response a status code equal to that given
|
||||
func (o *InviteGenerateUnauthorized) IsCode(code int) bool {
|
||||
return code == 401
|
||||
}
|
||||
|
||||
func (o *InviteGenerateUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[POST /invite/generate][%d] inviteGenerateUnauthorized ", 401)
|
||||
}
|
||||
|
||||
func (o *InviteGenerateUnauthorized) String() string {
|
||||
return fmt.Sprintf("[POST /invite/generate][%d] inviteGenerateUnauthorized ", 401)
|
||||
}
|
||||
|
||||
func (o *InviteGenerateUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewInviteGenerateInternalServerError creates a InviteGenerateInternalServerError with default headers values
|
||||
func NewInviteGenerateInternalServerError() *InviteGenerateInternalServerError {
|
||||
return &InviteGenerateInternalServerError{}
|
||||
}
|
||||
|
||||
/*
|
||||
InviteGenerateInternalServerError describes a response with status code 500, with default header values.
|
||||
|
||||
internal server error
|
||||
*/
|
||||
type InviteGenerateInternalServerError struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this invite generate internal server error response has a 2xx status code
|
||||
func (o *InviteGenerateInternalServerError) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this invite generate internal server error response has a 3xx status code
|
||||
func (o *InviteGenerateInternalServerError) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this invite generate internal server error response has a 4xx status code
|
||||
func (o *InviteGenerateInternalServerError) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this invite generate internal server error response has a 5xx status code
|
||||
func (o *InviteGenerateInternalServerError) IsServerError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsCode returns true when this invite generate internal server error response a status code equal to that given
|
||||
func (o *InviteGenerateInternalServerError) IsCode(code int) bool {
|
||||
return code == 500
|
||||
}
|
||||
|
||||
func (o *InviteGenerateInternalServerError) Error() string {
|
||||
return fmt.Sprintf("[POST /invite/generate][%d] inviteGenerateInternalServerError ", 500)
|
||||
}
|
||||
|
||||
func (o *InviteGenerateInternalServerError) String() string {
|
||||
return fmt.Sprintf("[POST /invite/generate][%d] inviteGenerateInternalServerError ", 500)
|
||||
}
|
||||
|
||||
func (o *InviteGenerateInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
150
rest_client_zrok/admin/invite_token_generate_parameters.go
Normal file
150
rest_client_zrok/admin/invite_token_generate_parameters.go
Normal file
@ -0,0 +1,150 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// NewInviteTokenGenerateParams creates a new InviteTokenGenerateParams 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 NewInviteTokenGenerateParams() *InviteTokenGenerateParams {
|
||||
return &InviteTokenGenerateParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewInviteTokenGenerateParamsWithTimeout creates a new InviteTokenGenerateParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewInviteTokenGenerateParamsWithTimeout(timeout time.Duration) *InviteTokenGenerateParams {
|
||||
return &InviteTokenGenerateParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewInviteTokenGenerateParamsWithContext creates a new InviteTokenGenerateParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewInviteTokenGenerateParamsWithContext(ctx context.Context) *InviteTokenGenerateParams {
|
||||
return &InviteTokenGenerateParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewInviteTokenGenerateParamsWithHTTPClient creates a new InviteTokenGenerateParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewInviteTokenGenerateParamsWithHTTPClient(client *http.Client) *InviteTokenGenerateParams {
|
||||
return &InviteTokenGenerateParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
InviteTokenGenerateParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the invite token generate operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type InviteTokenGenerateParams struct {
|
||||
|
||||
// Body.
|
||||
Body *rest_model_zrok.InviteTokenGenerateRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the invite token generate params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *InviteTokenGenerateParams) WithDefaults() *InviteTokenGenerateParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the invite token generate params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *InviteTokenGenerateParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the invite token generate params
|
||||
func (o *InviteTokenGenerateParams) WithTimeout(timeout time.Duration) *InviteTokenGenerateParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the invite token generate params
|
||||
func (o *InviteTokenGenerateParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the invite token generate params
|
||||
func (o *InviteTokenGenerateParams) WithContext(ctx context.Context) *InviteTokenGenerateParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the invite token generate params
|
||||
func (o *InviteTokenGenerateParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the invite token generate params
|
||||
func (o *InviteTokenGenerateParams) WithHTTPClient(client *http.Client) *InviteTokenGenerateParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the invite token generate params
|
||||
func (o *InviteTokenGenerateParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the invite token generate params
|
||||
func (o *InviteTokenGenerateParams) WithBody(body *rest_model_zrok.InviteTokenGenerateRequest) *InviteTokenGenerateParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the invite token generate params
|
||||
func (o *InviteTokenGenerateParams) SetBody(body *rest_model_zrok.InviteTokenGenerateRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *InviteTokenGenerateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
254
rest_client_zrok/admin/invite_token_generate_responses.go
Normal file
254
rest_client_zrok/admin/invite_token_generate_responses.go
Normal file
@ -0,0 +1,254 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// InviteTokenGenerateReader is a Reader for the InviteTokenGenerate structure.
|
||||
type InviteTokenGenerateReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *InviteTokenGenerateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 201:
|
||||
result := NewInviteTokenGenerateCreated()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 400:
|
||||
result := NewInviteTokenGenerateBadRequest()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 401:
|
||||
result := NewInviteTokenGenerateUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 500:
|
||||
result := NewInviteTokenGenerateInternalServerError()
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
// NewInviteTokenGenerateCreated creates a InviteTokenGenerateCreated with default headers values
|
||||
func NewInviteTokenGenerateCreated() *InviteTokenGenerateCreated {
|
||||
return &InviteTokenGenerateCreated{}
|
||||
}
|
||||
|
||||
/*
|
||||
InviteTokenGenerateCreated describes a response with status code 201, with default header values.
|
||||
|
||||
invitation tokens created
|
||||
*/
|
||||
type InviteTokenGenerateCreated struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this invite token generate created response has a 2xx status code
|
||||
func (o *InviteTokenGenerateCreated) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this invite token generate created response has a 3xx status code
|
||||
func (o *InviteTokenGenerateCreated) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this invite token generate created response has a 4xx status code
|
||||
func (o *InviteTokenGenerateCreated) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this invite token generate created response has a 5xx status code
|
||||
func (o *InviteTokenGenerateCreated) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this invite token generate created response a status code equal to that given
|
||||
func (o *InviteTokenGenerateCreated) IsCode(code int) bool {
|
||||
return code == 201
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerateCreated) Error() string {
|
||||
return fmt.Sprintf("[POST /invite/token/generate][%d] inviteTokenGenerateCreated ", 201)
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerateCreated) String() string {
|
||||
return fmt.Sprintf("[POST /invite/token/generate][%d] inviteTokenGenerateCreated ", 201)
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerateCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewInviteTokenGenerateBadRequest creates a InviteTokenGenerateBadRequest with default headers values
|
||||
func NewInviteTokenGenerateBadRequest() *InviteTokenGenerateBadRequest {
|
||||
return &InviteTokenGenerateBadRequest{}
|
||||
}
|
||||
|
||||
/*
|
||||
InviteTokenGenerateBadRequest describes a response with status code 400, with default header values.
|
||||
|
||||
invitation tokens not created
|
||||
*/
|
||||
type InviteTokenGenerateBadRequest struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this invite token generate bad request response has a 2xx status code
|
||||
func (o *InviteTokenGenerateBadRequest) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this invite token generate bad request response has a 3xx status code
|
||||
func (o *InviteTokenGenerateBadRequest) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this invite token generate bad request response has a 4xx status code
|
||||
func (o *InviteTokenGenerateBadRequest) IsClientError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsServerError returns true when this invite token generate bad request response has a 5xx status code
|
||||
func (o *InviteTokenGenerateBadRequest) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this invite token generate bad request response a status code equal to that given
|
||||
func (o *InviteTokenGenerateBadRequest) IsCode(code int) bool {
|
||||
return code == 400
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerateBadRequest) Error() string {
|
||||
return fmt.Sprintf("[POST /invite/token/generate][%d] inviteTokenGenerateBadRequest ", 400)
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerateBadRequest) String() string {
|
||||
return fmt.Sprintf("[POST /invite/token/generate][%d] inviteTokenGenerateBadRequest ", 400)
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerateBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewInviteTokenGenerateUnauthorized creates a InviteTokenGenerateUnauthorized with default headers values
|
||||
func NewInviteTokenGenerateUnauthorized() *InviteTokenGenerateUnauthorized {
|
||||
return &InviteTokenGenerateUnauthorized{}
|
||||
}
|
||||
|
||||
/*
|
||||
InviteTokenGenerateUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
unauthorized
|
||||
*/
|
||||
type InviteTokenGenerateUnauthorized struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this invite token generate unauthorized response has a 2xx status code
|
||||
func (o *InviteTokenGenerateUnauthorized) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this invite token generate unauthorized response has a 3xx status code
|
||||
func (o *InviteTokenGenerateUnauthorized) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this invite token generate unauthorized response has a 4xx status code
|
||||
func (o *InviteTokenGenerateUnauthorized) IsClientError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsServerError returns true when this invite token generate unauthorized response has a 5xx status code
|
||||
func (o *InviteTokenGenerateUnauthorized) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this invite token generate unauthorized response a status code equal to that given
|
||||
func (o *InviteTokenGenerateUnauthorized) IsCode(code int) bool {
|
||||
return code == 401
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerateUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[POST /invite/token/generate][%d] inviteTokenGenerateUnauthorized ", 401)
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerateUnauthorized) String() string {
|
||||
return fmt.Sprintf("[POST /invite/token/generate][%d] inviteTokenGenerateUnauthorized ", 401)
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerateUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewInviteTokenGenerateInternalServerError creates a InviteTokenGenerateInternalServerError with default headers values
|
||||
func NewInviteTokenGenerateInternalServerError() *InviteTokenGenerateInternalServerError {
|
||||
return &InviteTokenGenerateInternalServerError{}
|
||||
}
|
||||
|
||||
/*
|
||||
InviteTokenGenerateInternalServerError describes a response with status code 500, with default header values.
|
||||
|
||||
internal server error
|
||||
*/
|
||||
type InviteTokenGenerateInternalServerError struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this invite token generate internal server error response has a 2xx status code
|
||||
func (o *InviteTokenGenerateInternalServerError) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this invite token generate internal server error response has a 3xx status code
|
||||
func (o *InviteTokenGenerateInternalServerError) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this invite token generate internal server error response has a 4xx status code
|
||||
func (o *InviteTokenGenerateInternalServerError) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this invite token generate internal server error response has a 5xx status code
|
||||
func (o *InviteTokenGenerateInternalServerError) IsServerError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsCode returns true when this invite token generate internal server error response a status code equal to that given
|
||||
func (o *InviteTokenGenerateInternalServerError) IsCode(code int) bool {
|
||||
return code == 500
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerateInternalServerError) Error() string {
|
||||
return fmt.Sprintf("[POST /invite/token/generate][%d] inviteTokenGenerateInternalServerError ", 500)
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerateInternalServerError) String() string {
|
||||
return fmt.Sprintf("[POST /invite/token/generate][%d] inviteTokenGenerateInternalServerError ", 500)
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerateInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package rest_model_zrok
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// InviteGenerateRequest invite generate request
|
||||
//
|
||||
// swagger:model inviteGenerateRequest
|
||||
type InviteGenerateRequest struct {
|
||||
|
||||
// tokens
|
||||
Tokens []string `json:"tokens"`
|
||||
}
|
||||
|
||||
// Validate validates this invite generate request
|
||||
func (m *InviteGenerateRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this invite generate request based on context it is used
|
||||
func (m *InviteGenerateRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *InviteGenerateRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *InviteGenerateRequest) UnmarshalBinary(b []byte) error {
|
||||
var res InviteGenerateRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
50
rest_model_zrok/invite_token_generate_request.go
Normal file
50
rest_model_zrok/invite_token_generate_request.go
Normal file
@ -0,0 +1,50 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package rest_model_zrok
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// InviteTokenGenerateRequest invite token generate request
|
||||
//
|
||||
// swagger:model inviteTokenGenerateRequest
|
||||
type InviteTokenGenerateRequest struct {
|
||||
|
||||
// tokens
|
||||
Tokens []string `json:"tokens"`
|
||||
}
|
||||
|
||||
// Validate validates this invite token generate request
|
||||
func (m *InviteTokenGenerateRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this invite token generate request based on context it is used
|
||||
func (m *InviteTokenGenerateRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *InviteTokenGenerateRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *InviteTokenGenerateRequest) UnmarshalBinary(b []byte) error {
|
||||
var res InviteTokenGenerateRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
@ -431,7 +431,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/invite/generate": {
|
||||
"/invite/token/generate": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
@ -441,13 +441,13 @@ func init() {
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"operationId": "inviteGenerate",
|
||||
"operationId": "inviteTokenGenerate",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/inviteGenerateRequest"
|
||||
"$ref": "#/definitions/inviteTokenGenerateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -895,17 +895,6 @@ func init() {
|
||||
"errorMessage": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviteGenerateRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tokens": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"inviteRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -917,6 +906,17 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"inviteTokenGenerateRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tokens": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"loginRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -1599,7 +1599,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/invite/generate": {
|
||||
"/invite/token/generate": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
@ -1609,13 +1609,13 @@ func init() {
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"operationId": "inviteGenerate",
|
||||
"operationId": "inviteTokenGenerate",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/inviteGenerateRequest"
|
||||
"$ref": "#/definitions/inviteTokenGenerateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -2063,17 +2063,6 @@ func init() {
|
||||
"errorMessage": {
|
||||
"type": "string"
|
||||
},
|
||||
"inviteGenerateRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tokens": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"inviteRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -2085,6 +2074,17 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"inviteTokenGenerateRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tokens": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"loginRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -1,71 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// InviteGenerateHandlerFunc turns a function with the right signature into a invite generate handler
|
||||
type InviteGenerateHandlerFunc func(InviteGenerateParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn InviteGenerateHandlerFunc) Handle(params InviteGenerateParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// InviteGenerateHandler interface for that can handle valid invite generate params
|
||||
type InviteGenerateHandler interface {
|
||||
Handle(InviteGenerateParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewInviteGenerate creates a new http.Handler for the invite generate operation
|
||||
func NewInviteGenerate(ctx *middleware.Context, handler InviteGenerateHandler) *InviteGenerate {
|
||||
return &InviteGenerate{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
InviteGenerate swagger:route POST /invite/generate admin inviteGenerate
|
||||
|
||||
InviteGenerate invite generate API
|
||||
*/
|
||||
type InviteGenerate struct {
|
||||
Context *middleware.Context
|
||||
Handler InviteGenerateHandler
|
||||
}
|
||||
|
||||
func (o *InviteGenerate) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewInviteGenerateParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *rest_model_zrok.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*rest_model_zrok.Principal) // this is really a rest_model_zrok.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
)
|
||||
|
||||
// InviteGenerateCreatedCode is the HTTP code returned for type InviteGenerateCreated
|
||||
const InviteGenerateCreatedCode int = 201
|
||||
|
||||
/*
|
||||
InviteGenerateCreated invitation tokens created
|
||||
|
||||
swagger:response inviteGenerateCreated
|
||||
*/
|
||||
type InviteGenerateCreated struct {
|
||||
}
|
||||
|
||||
// NewInviteGenerateCreated creates InviteGenerateCreated with default headers values
|
||||
func NewInviteGenerateCreated() *InviteGenerateCreated {
|
||||
|
||||
return &InviteGenerateCreated{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *InviteGenerateCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(201)
|
||||
}
|
||||
|
||||
// InviteGenerateBadRequestCode is the HTTP code returned for type InviteGenerateBadRequest
|
||||
const InviteGenerateBadRequestCode int = 400
|
||||
|
||||
/*
|
||||
InviteGenerateBadRequest invitation tokens not created
|
||||
|
||||
swagger:response inviteGenerateBadRequest
|
||||
*/
|
||||
type InviteGenerateBadRequest struct {
|
||||
}
|
||||
|
||||
// NewInviteGenerateBadRequest creates InviteGenerateBadRequest with default headers values
|
||||
func NewInviteGenerateBadRequest() *InviteGenerateBadRequest {
|
||||
|
||||
return &InviteGenerateBadRequest{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *InviteGenerateBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(400)
|
||||
}
|
||||
|
||||
// InviteGenerateUnauthorizedCode is the HTTP code returned for type InviteGenerateUnauthorized
|
||||
const InviteGenerateUnauthorizedCode int = 401
|
||||
|
||||
/*
|
||||
InviteGenerateUnauthorized unauthorized
|
||||
|
||||
swagger:response inviteGenerateUnauthorized
|
||||
*/
|
||||
type InviteGenerateUnauthorized struct {
|
||||
}
|
||||
|
||||
// NewInviteGenerateUnauthorized creates InviteGenerateUnauthorized with default headers values
|
||||
func NewInviteGenerateUnauthorized() *InviteGenerateUnauthorized {
|
||||
|
||||
return &InviteGenerateUnauthorized{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *InviteGenerateUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(401)
|
||||
}
|
||||
|
||||
// InviteGenerateInternalServerErrorCode is the HTTP code returned for type InviteGenerateInternalServerError
|
||||
const InviteGenerateInternalServerErrorCode int = 500
|
||||
|
||||
/*
|
||||
InviteGenerateInternalServerError internal server error
|
||||
|
||||
swagger:response inviteGenerateInternalServerError
|
||||
*/
|
||||
type InviteGenerateInternalServerError struct {
|
||||
}
|
||||
|
||||
// NewInviteGenerateInternalServerError creates InviteGenerateInternalServerError with default headers values
|
||||
func NewInviteGenerateInternalServerError() *InviteGenerateInternalServerError {
|
||||
|
||||
return &InviteGenerateInternalServerError{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *InviteGenerateInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(500)
|
||||
}
|
71
rest_server_zrok/operations/admin/invite_token_generate.go
Normal file
71
rest_server_zrok/operations/admin/invite_token_generate.go
Normal file
@ -0,0 +1,71 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// InviteTokenGenerateHandlerFunc turns a function with the right signature into a invite token generate handler
|
||||
type InviteTokenGenerateHandlerFunc func(InviteTokenGenerateParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn InviteTokenGenerateHandlerFunc) Handle(params InviteTokenGenerateParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// InviteTokenGenerateHandler interface for that can handle valid invite token generate params
|
||||
type InviteTokenGenerateHandler interface {
|
||||
Handle(InviteTokenGenerateParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewInviteTokenGenerate creates a new http.Handler for the invite token generate operation
|
||||
func NewInviteTokenGenerate(ctx *middleware.Context, handler InviteTokenGenerateHandler) *InviteTokenGenerate {
|
||||
return &InviteTokenGenerate{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
InviteTokenGenerate swagger:route POST /invite/token/generate admin inviteTokenGenerate
|
||||
|
||||
InviteTokenGenerate invite token generate API
|
||||
*/
|
||||
type InviteTokenGenerate struct {
|
||||
Context *middleware.Context
|
||||
Handler InviteTokenGenerateHandler
|
||||
}
|
||||
|
||||
func (o *InviteTokenGenerate) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewInviteTokenGenerateParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *rest_model_zrok.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*rest_model_zrok.Principal) // this is really a rest_model_zrok.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
@ -16,19 +16,19 @@ import (
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// NewInviteGenerateParams creates a new InviteGenerateParams object
|
||||
// NewInviteTokenGenerateParams creates a new InviteTokenGenerateParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewInviteGenerateParams() InviteGenerateParams {
|
||||
func NewInviteTokenGenerateParams() InviteTokenGenerateParams {
|
||||
|
||||
return InviteGenerateParams{}
|
||||
return InviteTokenGenerateParams{}
|
||||
}
|
||||
|
||||
// InviteGenerateParams contains all the bound params for the invite generate operation
|
||||
// InviteTokenGenerateParams contains all the bound params for the invite token generate operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters inviteGenerate
|
||||
type InviteGenerateParams struct {
|
||||
// swagger:parameters inviteTokenGenerate
|
||||
type InviteTokenGenerateParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
@ -36,21 +36,21 @@ type InviteGenerateParams struct {
|
||||
/*
|
||||
In: body
|
||||
*/
|
||||
Body *rest_model_zrok.InviteGenerateRequest
|
||||
Body *rest_model_zrok.InviteTokenGenerateRequest
|
||||
}
|
||||
|
||||
// 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 NewInviteGenerateParams() beforehand.
|
||||
func (o *InviteGenerateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
// To ensure default values, the struct must have been initialized with NewInviteTokenGenerateParams() beforehand.
|
||||
func (o *InviteTokenGenerateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body rest_model_zrok.InviteGenerateRequest
|
||||
var body rest_model_zrok.InviteTokenGenerateRequest
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
} else {
|
@ -0,0 +1,112 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
)
|
||||
|
||||
// InviteTokenGenerateCreatedCode is the HTTP code returned for type InviteTokenGenerateCreated
|
||||
const InviteTokenGenerateCreatedCode int = 201
|
||||
|
||||
/*
|
||||
InviteTokenGenerateCreated invitation tokens created
|
||||
|
||||
swagger:response inviteTokenGenerateCreated
|
||||
*/
|
||||
type InviteTokenGenerateCreated struct {
|
||||
}
|
||||
|
||||
// NewInviteTokenGenerateCreated creates InviteTokenGenerateCreated with default headers values
|
||||
func NewInviteTokenGenerateCreated() *InviteTokenGenerateCreated {
|
||||
|
||||
return &InviteTokenGenerateCreated{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *InviteTokenGenerateCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(201)
|
||||
}
|
||||
|
||||
// InviteTokenGenerateBadRequestCode is the HTTP code returned for type InviteTokenGenerateBadRequest
|
||||
const InviteTokenGenerateBadRequestCode int = 400
|
||||
|
||||
/*
|
||||
InviteTokenGenerateBadRequest invitation tokens not created
|
||||
|
||||
swagger:response inviteTokenGenerateBadRequest
|
||||
*/
|
||||
type InviteTokenGenerateBadRequest struct {
|
||||
}
|
||||
|
||||
// NewInviteTokenGenerateBadRequest creates InviteTokenGenerateBadRequest with default headers values
|
||||
func NewInviteTokenGenerateBadRequest() *InviteTokenGenerateBadRequest {
|
||||
|
||||
return &InviteTokenGenerateBadRequest{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *InviteTokenGenerateBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(400)
|
||||
}
|
||||
|
||||
// InviteTokenGenerateUnauthorizedCode is the HTTP code returned for type InviteTokenGenerateUnauthorized
|
||||
const InviteTokenGenerateUnauthorizedCode int = 401
|
||||
|
||||
/*
|
||||
InviteTokenGenerateUnauthorized unauthorized
|
||||
|
||||
swagger:response inviteTokenGenerateUnauthorized
|
||||
*/
|
||||
type InviteTokenGenerateUnauthorized struct {
|
||||
}
|
||||
|
||||
// NewInviteTokenGenerateUnauthorized creates InviteTokenGenerateUnauthorized with default headers values
|
||||
func NewInviteTokenGenerateUnauthorized() *InviteTokenGenerateUnauthorized {
|
||||
|
||||
return &InviteTokenGenerateUnauthorized{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *InviteTokenGenerateUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(401)
|
||||
}
|
||||
|
||||
// InviteTokenGenerateInternalServerErrorCode is the HTTP code returned for type InviteTokenGenerateInternalServerError
|
||||
const InviteTokenGenerateInternalServerErrorCode int = 500
|
||||
|
||||
/*
|
||||
InviteTokenGenerateInternalServerError internal server error
|
||||
|
||||
swagger:response inviteTokenGenerateInternalServerError
|
||||
*/
|
||||
type InviteTokenGenerateInternalServerError struct {
|
||||
}
|
||||
|
||||
// NewInviteTokenGenerateInternalServerError creates InviteTokenGenerateInternalServerError with default headers values
|
||||
func NewInviteTokenGenerateInternalServerError() *InviteTokenGenerateInternalServerError {
|
||||
|
||||
return &InviteTokenGenerateInternalServerError{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *InviteTokenGenerateInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(500)
|
||||
}
|
@ -11,15 +11,15 @@ import (
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// InviteGenerateURL generates an URL for the invite generate operation
|
||||
type InviteGenerateURL struct {
|
||||
// InviteTokenGenerateURL generates an URL for the invite token generate operation
|
||||
type InviteTokenGenerateURL 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 *InviteGenerateURL) WithBasePath(bp string) *InviteGenerateURL {
|
||||
func (o *InviteTokenGenerateURL) WithBasePath(bp string) *InviteTokenGenerateURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
@ -27,15 +27,15 @@ func (o *InviteGenerateURL) WithBasePath(bp string) *InviteGenerateURL {
|
||||
// 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 *InviteGenerateURL) SetBasePath(bp string) {
|
||||
func (o *InviteTokenGenerateURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *InviteGenerateURL) Build() (*url.URL, error) {
|
||||
func (o *InviteTokenGenerateURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/invite/generate"
|
||||
var _path = "/invite/token/generate"
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
@ -47,7 +47,7 @@ func (o *InviteGenerateURL) Build() (*url.URL, error) {
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *InviteGenerateURL) Must(u *url.URL, err error) *url.URL {
|
||||
func (o *InviteTokenGenerateURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -58,17 +58,17 @@ func (o *InviteGenerateURL) Must(u *url.URL, err error) *url.URL {
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *InviteGenerateURL) String() string {
|
||||
func (o *InviteTokenGenerateURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *InviteGenerateURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
func (o *InviteTokenGenerateURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on InviteGenerateURL")
|
||||
return nil, errors.New("scheme is required for a full url on InviteTokenGenerateURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on InviteGenerateURL")
|
||||
return nil, errors.New("host is required for a full url on InviteTokenGenerateURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
@ -82,6 +82,6 @@ func (o *InviteGenerateURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *InviteGenerateURL) StringFull(scheme, host string) string {
|
||||
func (o *InviteTokenGenerateURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
@ -76,8 +76,8 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
|
||||
AccountInviteHandler: account.InviteHandlerFunc(func(params account.InviteParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation account.Invite has not yet been implemented")
|
||||
}),
|
||||
AdminInviteGenerateHandler: admin.InviteGenerateHandlerFunc(func(params admin.InviteGenerateParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin.InviteGenerate has not yet been implemented")
|
||||
AdminInviteTokenGenerateHandler: admin.InviteTokenGenerateHandlerFunc(func(params admin.InviteTokenGenerateParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin.InviteTokenGenerate has not yet been implemented")
|
||||
}),
|
||||
AdminListFrontendsHandler: admin.ListFrontendsHandlerFunc(func(params admin.ListFrontendsParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin.ListFrontends has not yet been implemented")
|
||||
@ -180,8 +180,8 @@ type ZrokAPI struct {
|
||||
MetadataGetShareDetailHandler metadata.GetShareDetailHandler
|
||||
// AccountInviteHandler sets the operation handler for the invite operation
|
||||
AccountInviteHandler account.InviteHandler
|
||||
// AdminInviteGenerateHandler sets the operation handler for the invite generate operation
|
||||
AdminInviteGenerateHandler admin.InviteGenerateHandler
|
||||
// AdminInviteTokenGenerateHandler sets the operation handler for the invite token generate operation
|
||||
AdminInviteTokenGenerateHandler admin.InviteTokenGenerateHandler
|
||||
// AdminListFrontendsHandler sets the operation handler for the list frontends operation
|
||||
AdminListFrontendsHandler admin.ListFrontendsHandler
|
||||
// AccountLoginHandler sets the operation handler for the login operation
|
||||
@ -312,8 +312,8 @@ func (o *ZrokAPI) Validate() error {
|
||||
if o.AccountInviteHandler == nil {
|
||||
unregistered = append(unregistered, "account.InviteHandler")
|
||||
}
|
||||
if o.AdminInviteGenerateHandler == nil {
|
||||
unregistered = append(unregistered, "admin.InviteGenerateHandler")
|
||||
if o.AdminInviteTokenGenerateHandler == nil {
|
||||
unregistered = append(unregistered, "admin.InviteTokenGenerateHandler")
|
||||
}
|
||||
if o.AdminListFrontendsHandler == nil {
|
||||
unregistered = append(unregistered, "admin.ListFrontendsHandler")
|
||||
@ -486,7 +486,7 @@ func (o *ZrokAPI) initHandlerCache() {
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/invite/generate"] = admin.NewInviteGenerate(o.context, o.AdminInviteGenerateHandler)
|
||||
o.handlers["POST"]["/invite/token/generate"] = admin.NewInviteTokenGenerate(o.context, o.AdminInviteTokenGenerateHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
@ -203,18 +203,18 @@ paths:
|
||||
500:
|
||||
description: internal server error
|
||||
|
||||
/invite/generate:
|
||||
/invite/token/generate:
|
||||
post:
|
||||
tags:
|
||||
- admin
|
||||
security:
|
||||
- key: []
|
||||
operationId: inviteGenerate
|
||||
operationId: inviteTokenGenerate
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
schema:
|
||||
$ref: "#/definitions/inviteGenerateRequest"
|
||||
$ref: "#/definitions/inviteTokenGenerateRequest"
|
||||
responses:
|
||||
201:
|
||||
description: invitation tokens created
|
||||
@ -574,6 +574,14 @@ definitions:
|
||||
errorMessage:
|
||||
type: string
|
||||
|
||||
inviteTokenGenerateRequest:
|
||||
type: object
|
||||
properties:
|
||||
tokens:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
|
||||
inviteRequest:
|
||||
type: object
|
||||
properties:
|
||||
@ -764,14 +772,6 @@ definitions:
|
||||
version:
|
||||
type: string
|
||||
|
||||
inviteGenerateRequest:
|
||||
type: object
|
||||
properties:
|
||||
tokens:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
|
||||
produces:
|
||||
- application/zrok.v1+json
|
||||
consumes:
|
||||
|
@ -70,17 +70,17 @@ export function createIdentity(options) {
|
||||
|
||||
/**
|
||||
* @param {object} options Optional options
|
||||
* @param {module:types.inviteGenerateRequest} [options.body]
|
||||
* @param {module:types.inviteTokenGenerateRequest} [options.body]
|
||||
* @return {Promise<object>} invitation tokens created
|
||||
*/
|
||||
export function inviteGenerate(options) {
|
||||
export function inviteTokenGenerate(options) {
|
||||
if (!options) options = {}
|
||||
const parameters = {
|
||||
body: {
|
||||
body: options.body
|
||||
}
|
||||
}
|
||||
return gateway.request(inviteGenerateOperation, parameters)
|
||||
return gateway.request(inviteTokenGenerateOperation, parameters)
|
||||
}
|
||||
|
||||
const createFrontendOperation = {
|
||||
@ -137,8 +137,8 @@ const createIdentityOperation = {
|
||||
]
|
||||
}
|
||||
|
||||
const inviteGenerateOperation = {
|
||||
path: '/invite/generate',
|
||||
const inviteTokenGenerateOperation = {
|
||||
path: '/invite/token/generate',
|
||||
contentTypes: ['application/zrok.v1+json'],
|
||||
method: 'post',
|
||||
security: [
|
||||
|
@ -91,6 +91,13 @@
|
||||
* @property {module:types.shares} shares
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef inviteTokenGenerateRequest
|
||||
* @memberof module:types
|
||||
*
|
||||
* @property {string[]} tokens
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef inviteRequest
|
||||
* @memberof module:types
|
||||
@ -231,10 +238,3 @@
|
||||
*
|
||||
* @property {string} email
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef inviteGenerateRequest
|
||||
* @memberof module:types
|
||||
*
|
||||
* @property {string[]} tokens
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user