diff --git a/controller/agentRemoteAccess.go b/controller/agentRemoteAccess.go new file mode 100644 index 00000000..b748d8cc --- /dev/null +++ b/controller/agentRemoteAccess.go @@ -0,0 +1,63 @@ +package controller + +import ( + "context" + "github.com/go-openapi/runtime/middleware" + "github.com/openziti/zrok/agent/agentGrpc" + "github.com/openziti/zrok/controller/agentController" + "github.com/openziti/zrok/rest_model_zrok" + "github.com/openziti/zrok/rest_server_zrok/operations/agent" + "github.com/sirupsen/logrus" +) + +type agentRemoteAccessHandler struct{} + +func newAgentRemoteAccessHandler() *agentRemoteAccessHandler { + return &agentRemoteAccessHandler{} +} + +func (h *agentRemoteAccessHandler) Handle(params agent.RemoteAccessParams, principal *rest_model_zrok.Principal) middleware.Responder { + trx, err := str.Begin() + if err != nil { + logrus.Errorf("error starting transaction for '%v': %v", principal.Email, err) + return agent.NewRemoteAccessInternalServerError() + } + defer trx.Rollback() + + env, err := str.FindEnvironmentForAccount(params.Body.EnvZID, int(principal.ID), trx) + if err != nil { + logrus.Errorf("error finding environment for '%v' (%v): %v", params.Body.EnvZID, principal.ID, err) + return agent.NewRemoteAccessUnauthorized() + } + + ae, err := str.FindAgentEnrollmentForEnvironment(env.Id, trx) + if err != nil { + logrus.Errorf("error finding agent enrollment for environment '%v' (%v): %v", params.Body.EnvZID, principal.Email, err) + return agent.NewRemoteAccessBadGateway() + } + _ = trx.Rollback() // ...or will block the access trx on sqlite + + acli, aconn, err := agentController.NewAgentClient(ae.Token, cfg.AgentController) + if err != nil { + logrus.Errorf("error creating agent client for '%v' (%v): %v", params.Body.EnvZID, principal.Email, err) + return agent.NewRemoteAccessInternalServerError() + } + defer aconn.Close() + + req := &agentGrpc.AccessPrivateRequest{ + Token: params.Body.Token, + BindAddress: params.Body.BindAddress, + AutoMode: params.Body.AutoMode, + AutoAddress: params.Body.AutoAddress, + AutoStartPort: uint32(params.Body.AutoStartPort), + AutoEndPort: uint32(params.Body.AutoEndPort), + ResponseHeaders: params.Body.ResponseHeaders, + } + resp, err := acli.AccessPrivate(context.Background(), req) + if err != nil { + logrus.Errorf("error creating remote agent private access for '%v' (%v): %v", params.Body.EnvZID, principal.Email, err) + return agent.NewRemoteAccessBadGateway() + } + + return agent.NewRemoteAccessOK().WithPayload(&agent.RemoteAccessOKBody{FrontendToken: resp.FrontendToken}) +} diff --git a/controller/controller.go b/controller/controller.go index 6f2c7cba..7a17c6f4 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -68,6 +68,7 @@ func Run(inCfg *config.Config) error { if cfg.AgentController != nil { api.AgentEnrollHandler = newAgentEnrollHandler() api.AgentPingHandler = newAgentPingHandler() + api.AgentRemoteAccessHandler = newAgentRemoteAccessHandler() api.AgentRemoteShareHandler = newAgentRemoteShareHandler() api.AgentRemoteStatusHandler = newAgentRemoteStatusHandler() api.AgentRemoteUnshareHandler = newAgentRemoteUnshareHandler() diff --git a/rest_client_zrok/agent/agent_client.go b/rest_client_zrok/agent/agent_client.go index ea83391f..16be5eb7 100644 --- a/rest_client_zrok/agent/agent_client.go +++ b/rest_client_zrok/agent/agent_client.go @@ -104,10 +104,14 @@ type ClientService interface { Ping(params *PingParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PingOK, error) + RemoteAccess(params *RemoteAccessParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RemoteAccessOK, error) + RemoteShare(params *RemoteShareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RemoteShareOK, error) RemoteStatus(params *RemoteStatusParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RemoteStatusOK, error) + RemoteUnaccess(params *RemoteUnaccessParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RemoteUnaccessOK, error) + RemoteUnshare(params *RemoteUnshareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RemoteUnshareOK, error) Unenroll(params *UnenrollParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnenrollOK, error) @@ -193,6 +197,45 @@ func (a *Client) Ping(params *PingParams, authInfo runtime.ClientAuthInfoWriter, panic(msg) } +/* +RemoteAccess remote access API +*/ +func (a *Client) RemoteAccess(params *RemoteAccessParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RemoteAccessOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewRemoteAccessParams() + } + op := &runtime.ClientOperation{ + ID: "remoteAccess", + Method: "POST", + PathPattern: "/agent/access", + ProducesMediaTypes: []string{"application/zrok.v1+json"}, + ConsumesMediaTypes: []string{"application/zrok.v1+json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &RemoteAccessReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*RemoteAccessOK) + 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 remoteAccess: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* RemoteShare remote share API */ @@ -271,6 +314,45 @@ func (a *Client) RemoteStatus(params *RemoteStatusParams, authInfo runtime.Clien panic(msg) } +/* +RemoteUnaccess remote unaccess API +*/ +func (a *Client) RemoteUnaccess(params *RemoteUnaccessParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RemoteUnaccessOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewRemoteUnaccessParams() + } + op := &runtime.ClientOperation{ + ID: "remoteUnaccess", + Method: "POST", + PathPattern: "/agent/unaccess", + ProducesMediaTypes: []string{"application/zrok.v1+json"}, + ConsumesMediaTypes: []string{"application/zrok.v1+json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &RemoteUnaccessReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*RemoteUnaccessOK) + 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 remoteUnaccess: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* RemoteUnshare remote unshare API */ diff --git a/rest_client_zrok/agent/remote_access_parameters.go b/rest_client_zrok/agent/remote_access_parameters.go new file mode 100644 index 00000000..f5b6e32a --- /dev/null +++ b/rest_client_zrok/agent/remote_access_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package agent + +// 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" +) + +// NewRemoteAccessParams creates a new RemoteAccessParams 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 NewRemoteAccessParams() *RemoteAccessParams { + return &RemoteAccessParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewRemoteAccessParamsWithTimeout creates a new RemoteAccessParams object +// with the ability to set a timeout on a request. +func NewRemoteAccessParamsWithTimeout(timeout time.Duration) *RemoteAccessParams { + return &RemoteAccessParams{ + timeout: timeout, + } +} + +// NewRemoteAccessParamsWithContext creates a new RemoteAccessParams object +// with the ability to set a context for a request. +func NewRemoteAccessParamsWithContext(ctx context.Context) *RemoteAccessParams { + return &RemoteAccessParams{ + Context: ctx, + } +} + +// NewRemoteAccessParamsWithHTTPClient creates a new RemoteAccessParams object +// with the ability to set a custom HTTPClient for a request. +func NewRemoteAccessParamsWithHTTPClient(client *http.Client) *RemoteAccessParams { + return &RemoteAccessParams{ + HTTPClient: client, + } +} + +/* +RemoteAccessParams contains all the parameters to send to the API endpoint + + for the remote access operation. + + Typically these are written to a http.Request. +*/ +type RemoteAccessParams struct { + + // Body. + Body RemoteAccessBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the remote access params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RemoteAccessParams) WithDefaults() *RemoteAccessParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the remote access params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RemoteAccessParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the remote access params +func (o *RemoteAccessParams) WithTimeout(timeout time.Duration) *RemoteAccessParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the remote access params +func (o *RemoteAccessParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the remote access params +func (o *RemoteAccessParams) WithContext(ctx context.Context) *RemoteAccessParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the remote access params +func (o *RemoteAccessParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the remote access params +func (o *RemoteAccessParams) WithHTTPClient(client *http.Client) *RemoteAccessParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the remote access params +func (o *RemoteAccessParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the remote access params +func (o *RemoteAccessParams) WithBody(body RemoteAccessBody) *RemoteAccessParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the remote access params +func (o *RemoteAccessParams) SetBody(body RemoteAccessBody) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *RemoteAccessParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client_zrok/agent/remote_access_responses.go b/rest_client_zrok/agent/remote_access_responses.go new file mode 100644 index 00000000..decc7569 --- /dev/null +++ b/rest_client_zrok/agent/remote_access_responses.go @@ -0,0 +1,389 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package agent + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RemoteAccessReader is a Reader for the RemoteAccess structure. +type RemoteAccessReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *RemoteAccessReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewRemoteAccessOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewRemoteAccessUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewRemoteAccessInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 502: + result := NewRemoteAccessBadGateway() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[POST /agent/access] remoteAccess", response, response.Code()) + } +} + +// NewRemoteAccessOK creates a RemoteAccessOK with default headers values +func NewRemoteAccessOK() *RemoteAccessOK { + return &RemoteAccessOK{} +} + +/* +RemoteAccessOK describes a response with status code 200, with default header values. + +ok +*/ +type RemoteAccessOK struct { + Payload *RemoteAccessOKBody +} + +// IsSuccess returns true when this remote access o k response has a 2xx status code +func (o *RemoteAccessOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this remote access o k response has a 3xx status code +func (o *RemoteAccessOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this remote access o k response has a 4xx status code +func (o *RemoteAccessOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this remote access o k response has a 5xx status code +func (o *RemoteAccessOK) IsServerError() bool { + return false +} + +// IsCode returns true when this remote access o k response a status code equal to that given +func (o *RemoteAccessOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the remote access o k response +func (o *RemoteAccessOK) Code() int { + return 200 +} + +func (o *RemoteAccessOK) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /agent/access][%d] remoteAccessOK %s", 200, payload) +} + +func (o *RemoteAccessOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[POST /agent/access][%d] remoteAccessOK %s", 200, payload) +} + +func (o *RemoteAccessOK) GetPayload() *RemoteAccessOKBody { + return o.Payload +} + +func (o *RemoteAccessOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(RemoteAccessOKBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewRemoteAccessUnauthorized creates a RemoteAccessUnauthorized with default headers values +func NewRemoteAccessUnauthorized() *RemoteAccessUnauthorized { + return &RemoteAccessUnauthorized{} +} + +/* +RemoteAccessUnauthorized describes a response with status code 401, with default header values. + +unauthorized +*/ +type RemoteAccessUnauthorized struct { +} + +// IsSuccess returns true when this remote access unauthorized response has a 2xx status code +func (o *RemoteAccessUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this remote access unauthorized response has a 3xx status code +func (o *RemoteAccessUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this remote access unauthorized response has a 4xx status code +func (o *RemoteAccessUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this remote access unauthorized response has a 5xx status code +func (o *RemoteAccessUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this remote access unauthorized response a status code equal to that given +func (o *RemoteAccessUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the remote access unauthorized response +func (o *RemoteAccessUnauthorized) Code() int { + return 401 +} + +func (o *RemoteAccessUnauthorized) Error() string { + return fmt.Sprintf("[POST /agent/access][%d] remoteAccessUnauthorized", 401) +} + +func (o *RemoteAccessUnauthorized) String() string { + return fmt.Sprintf("[POST /agent/access][%d] remoteAccessUnauthorized", 401) +} + +func (o *RemoteAccessUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewRemoteAccessInternalServerError creates a RemoteAccessInternalServerError with default headers values +func NewRemoteAccessInternalServerError() *RemoteAccessInternalServerError { + return &RemoteAccessInternalServerError{} +} + +/* +RemoteAccessInternalServerError describes a response with status code 500, with default header values. + +internal server error +*/ +type RemoteAccessInternalServerError struct { +} + +// IsSuccess returns true when this remote access internal server error response has a 2xx status code +func (o *RemoteAccessInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this remote access internal server error response has a 3xx status code +func (o *RemoteAccessInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this remote access internal server error response has a 4xx status code +func (o *RemoteAccessInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this remote access internal server error response has a 5xx status code +func (o *RemoteAccessInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this remote access internal server error response a status code equal to that given +func (o *RemoteAccessInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the remote access internal server error response +func (o *RemoteAccessInternalServerError) Code() int { + return 500 +} + +func (o *RemoteAccessInternalServerError) Error() string { + return fmt.Sprintf("[POST /agent/access][%d] remoteAccessInternalServerError", 500) +} + +func (o *RemoteAccessInternalServerError) String() string { + return fmt.Sprintf("[POST /agent/access][%d] remoteAccessInternalServerError", 500) +} + +func (o *RemoteAccessInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewRemoteAccessBadGateway creates a RemoteAccessBadGateway with default headers values +func NewRemoteAccessBadGateway() *RemoteAccessBadGateway { + return &RemoteAccessBadGateway{} +} + +/* +RemoteAccessBadGateway describes a response with status code 502, with default header values. + +bad gateway; agent not reachable +*/ +type RemoteAccessBadGateway struct { +} + +// IsSuccess returns true when this remote access bad gateway response has a 2xx status code +func (o *RemoteAccessBadGateway) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this remote access bad gateway response has a 3xx status code +func (o *RemoteAccessBadGateway) IsRedirect() bool { + return false +} + +// IsClientError returns true when this remote access bad gateway response has a 4xx status code +func (o *RemoteAccessBadGateway) IsClientError() bool { + return false +} + +// IsServerError returns true when this remote access bad gateway response has a 5xx status code +func (o *RemoteAccessBadGateway) IsServerError() bool { + return true +} + +// IsCode returns true when this remote access bad gateway response a status code equal to that given +func (o *RemoteAccessBadGateway) IsCode(code int) bool { + return code == 502 +} + +// Code gets the status code for the remote access bad gateway response +func (o *RemoteAccessBadGateway) Code() int { + return 502 +} + +func (o *RemoteAccessBadGateway) Error() string { + return fmt.Sprintf("[POST /agent/access][%d] remoteAccessBadGateway", 502) +} + +func (o *RemoteAccessBadGateway) String() string { + return fmt.Sprintf("[POST /agent/access][%d] remoteAccessBadGateway", 502) +} + +func (o *RemoteAccessBadGateway) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +/* +RemoteAccessBody remote access body +swagger:model RemoteAccessBody +*/ +type RemoteAccessBody struct { + + // auto address + AutoAddress string `json:"autoAddress,omitempty"` + + // auto end port + AutoEndPort int64 `json:"autoEndPort,omitempty"` + + // auto mode + AutoMode bool `json:"autoMode,omitempty"` + + // auto start port + AutoStartPort int64 `json:"autoStartPort,omitempty"` + + // bind address + BindAddress string `json:"bindAddress,omitempty"` + + // env z Id + EnvZID string `json:"envZId,omitempty"` + + // response headers + ResponseHeaders []string `json:"responseHeaders"` + + // token + Token string `json:"token,omitempty"` +} + +// Validate validates this remote access body +func (o *RemoteAccessBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this remote access body based on context it is used +func (o *RemoteAccessBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *RemoteAccessBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *RemoteAccessBody) UnmarshalBinary(b []byte) error { + var res RemoteAccessBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +RemoteAccessOKBody remote access o k body +swagger:model RemoteAccessOKBody +*/ +type RemoteAccessOKBody struct { + + // frontend token + FrontendToken string `json:"frontendToken,omitempty"` +} + +// Validate validates this remote access o k body +func (o *RemoteAccessOKBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this remote access o k body based on context it is used +func (o *RemoteAccessOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *RemoteAccessOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *RemoteAccessOKBody) UnmarshalBinary(b []byte) error { + var res RemoteAccessOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/rest_client_zrok/agent/remote_unaccess_parameters.go b/rest_client_zrok/agent/remote_unaccess_parameters.go new file mode 100644 index 00000000..578958bc --- /dev/null +++ b/rest_client_zrok/agent/remote_unaccess_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package agent + +// 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" +) + +// NewRemoteUnaccessParams creates a new RemoteUnaccessParams 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 NewRemoteUnaccessParams() *RemoteUnaccessParams { + return &RemoteUnaccessParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewRemoteUnaccessParamsWithTimeout creates a new RemoteUnaccessParams object +// with the ability to set a timeout on a request. +func NewRemoteUnaccessParamsWithTimeout(timeout time.Duration) *RemoteUnaccessParams { + return &RemoteUnaccessParams{ + timeout: timeout, + } +} + +// NewRemoteUnaccessParamsWithContext creates a new RemoteUnaccessParams object +// with the ability to set a context for a request. +func NewRemoteUnaccessParamsWithContext(ctx context.Context) *RemoteUnaccessParams { + return &RemoteUnaccessParams{ + Context: ctx, + } +} + +// NewRemoteUnaccessParamsWithHTTPClient creates a new RemoteUnaccessParams object +// with the ability to set a custom HTTPClient for a request. +func NewRemoteUnaccessParamsWithHTTPClient(client *http.Client) *RemoteUnaccessParams { + return &RemoteUnaccessParams{ + HTTPClient: client, + } +} + +/* +RemoteUnaccessParams contains all the parameters to send to the API endpoint + + for the remote unaccess operation. + + Typically these are written to a http.Request. +*/ +type RemoteUnaccessParams struct { + + // Body. + Body RemoteUnaccessBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the remote unaccess params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RemoteUnaccessParams) WithDefaults() *RemoteUnaccessParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the remote unaccess params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RemoteUnaccessParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the remote unaccess params +func (o *RemoteUnaccessParams) WithTimeout(timeout time.Duration) *RemoteUnaccessParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the remote unaccess params +func (o *RemoteUnaccessParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the remote unaccess params +func (o *RemoteUnaccessParams) WithContext(ctx context.Context) *RemoteUnaccessParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the remote unaccess params +func (o *RemoteUnaccessParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the remote unaccess params +func (o *RemoteUnaccessParams) WithHTTPClient(client *http.Client) *RemoteUnaccessParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the remote unaccess params +func (o *RemoteUnaccessParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the remote unaccess params +func (o *RemoteUnaccessParams) WithBody(body RemoteUnaccessBody) *RemoteUnaccessParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the remote unaccess params +func (o *RemoteUnaccessParams) SetBody(body RemoteUnaccessBody) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *RemoteUnaccessParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client_zrok/agent/remote_unaccess_responses.go b/rest_client_zrok/agent/remote_unaccess_responses.go new file mode 100644 index 00000000..2a73b5a2 --- /dev/null +++ b/rest_client_zrok/agent/remote_unaccess_responses.go @@ -0,0 +1,317 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package agent + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RemoteUnaccessReader is a Reader for the RemoteUnaccess structure. +type RemoteUnaccessReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *RemoteUnaccessReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewRemoteUnaccessOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewRemoteUnaccessUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewRemoteUnaccessInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 502: + result := NewRemoteUnaccessBadGateway() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[POST /agent/unaccess] remoteUnaccess", response, response.Code()) + } +} + +// NewRemoteUnaccessOK creates a RemoteUnaccessOK with default headers values +func NewRemoteUnaccessOK() *RemoteUnaccessOK { + return &RemoteUnaccessOK{} +} + +/* +RemoteUnaccessOK describes a response with status code 200, with default header values. + +ok +*/ +type RemoteUnaccessOK struct { +} + +// IsSuccess returns true when this remote unaccess o k response has a 2xx status code +func (o *RemoteUnaccessOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this remote unaccess o k response has a 3xx status code +func (o *RemoteUnaccessOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this remote unaccess o k response has a 4xx status code +func (o *RemoteUnaccessOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this remote unaccess o k response has a 5xx status code +func (o *RemoteUnaccessOK) IsServerError() bool { + return false +} + +// IsCode returns true when this remote unaccess o k response a status code equal to that given +func (o *RemoteUnaccessOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the remote unaccess o k response +func (o *RemoteUnaccessOK) Code() int { + return 200 +} + +func (o *RemoteUnaccessOK) Error() string { + return fmt.Sprintf("[POST /agent/unaccess][%d] remoteUnaccessOK", 200) +} + +func (o *RemoteUnaccessOK) String() string { + return fmt.Sprintf("[POST /agent/unaccess][%d] remoteUnaccessOK", 200) +} + +func (o *RemoteUnaccessOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewRemoteUnaccessUnauthorized creates a RemoteUnaccessUnauthorized with default headers values +func NewRemoteUnaccessUnauthorized() *RemoteUnaccessUnauthorized { + return &RemoteUnaccessUnauthorized{} +} + +/* +RemoteUnaccessUnauthorized describes a response with status code 401, with default header values. + +unauthorized +*/ +type RemoteUnaccessUnauthorized struct { +} + +// IsSuccess returns true when this remote unaccess unauthorized response has a 2xx status code +func (o *RemoteUnaccessUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this remote unaccess unauthorized response has a 3xx status code +func (o *RemoteUnaccessUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this remote unaccess unauthorized response has a 4xx status code +func (o *RemoteUnaccessUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this remote unaccess unauthorized response has a 5xx status code +func (o *RemoteUnaccessUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this remote unaccess unauthorized response a status code equal to that given +func (o *RemoteUnaccessUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the remote unaccess unauthorized response +func (o *RemoteUnaccessUnauthorized) Code() int { + return 401 +} + +func (o *RemoteUnaccessUnauthorized) Error() string { + return fmt.Sprintf("[POST /agent/unaccess][%d] remoteUnaccessUnauthorized", 401) +} + +func (o *RemoteUnaccessUnauthorized) String() string { + return fmt.Sprintf("[POST /agent/unaccess][%d] remoteUnaccessUnauthorized", 401) +} + +func (o *RemoteUnaccessUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewRemoteUnaccessInternalServerError creates a RemoteUnaccessInternalServerError with default headers values +func NewRemoteUnaccessInternalServerError() *RemoteUnaccessInternalServerError { + return &RemoteUnaccessInternalServerError{} +} + +/* +RemoteUnaccessInternalServerError describes a response with status code 500, with default header values. + +internal server error +*/ +type RemoteUnaccessInternalServerError struct { +} + +// IsSuccess returns true when this remote unaccess internal server error response has a 2xx status code +func (o *RemoteUnaccessInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this remote unaccess internal server error response has a 3xx status code +func (o *RemoteUnaccessInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this remote unaccess internal server error response has a 4xx status code +func (o *RemoteUnaccessInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this remote unaccess internal server error response has a 5xx status code +func (o *RemoteUnaccessInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this remote unaccess internal server error response a status code equal to that given +func (o *RemoteUnaccessInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the remote unaccess internal server error response +func (o *RemoteUnaccessInternalServerError) Code() int { + return 500 +} + +func (o *RemoteUnaccessInternalServerError) Error() string { + return fmt.Sprintf("[POST /agent/unaccess][%d] remoteUnaccessInternalServerError", 500) +} + +func (o *RemoteUnaccessInternalServerError) String() string { + return fmt.Sprintf("[POST /agent/unaccess][%d] remoteUnaccessInternalServerError", 500) +} + +func (o *RemoteUnaccessInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewRemoteUnaccessBadGateway creates a RemoteUnaccessBadGateway with default headers values +func NewRemoteUnaccessBadGateway() *RemoteUnaccessBadGateway { + return &RemoteUnaccessBadGateway{} +} + +/* +RemoteUnaccessBadGateway describes a response with status code 502, with default header values. + +bad gateway; agent not reachable +*/ +type RemoteUnaccessBadGateway struct { +} + +// IsSuccess returns true when this remote unaccess bad gateway response has a 2xx status code +func (o *RemoteUnaccessBadGateway) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this remote unaccess bad gateway response has a 3xx status code +func (o *RemoteUnaccessBadGateway) IsRedirect() bool { + return false +} + +// IsClientError returns true when this remote unaccess bad gateway response has a 4xx status code +func (o *RemoteUnaccessBadGateway) IsClientError() bool { + return false +} + +// IsServerError returns true when this remote unaccess bad gateway response has a 5xx status code +func (o *RemoteUnaccessBadGateway) IsServerError() bool { + return true +} + +// IsCode returns true when this remote unaccess bad gateway response a status code equal to that given +func (o *RemoteUnaccessBadGateway) IsCode(code int) bool { + return code == 502 +} + +// Code gets the status code for the remote unaccess bad gateway response +func (o *RemoteUnaccessBadGateway) Code() int { + return 502 +} + +func (o *RemoteUnaccessBadGateway) Error() string { + return fmt.Sprintf("[POST /agent/unaccess][%d] remoteUnaccessBadGateway", 502) +} + +func (o *RemoteUnaccessBadGateway) String() string { + return fmt.Sprintf("[POST /agent/unaccess][%d] remoteUnaccessBadGateway", 502) +} + +func (o *RemoteUnaccessBadGateway) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +/* +RemoteUnaccessBody remote unaccess body +swagger:model RemoteUnaccessBody +*/ +type RemoteUnaccessBody struct { + + // env z Id + EnvZID string `json:"envZId,omitempty"` + + // frontend token + FrontendToken string `json:"frontendToken,omitempty"` +} + +// Validate validates this remote unaccess body +func (o *RemoteUnaccessBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this remote unaccess body based on context it is used +func (o *RemoteUnaccessBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *RemoteUnaccessBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *RemoteUnaccessBody) UnmarshalBinary(b []byte) error { + var res RemoteUnaccessBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/rest_server_zrok/embedded_spec.go b/rest_server_zrok/embedded_spec.go index 40a349ee..378e6315 100644 --- a/rest_server_zrok/embedded_spec.go +++ b/rest_server_zrok/embedded_spec.go @@ -185,6 +185,77 @@ func init() { } } }, + "/agent/access": { + "post": { + "security": [ + { + "key": [] + } + ], + "tags": [ + "agent" + ], + "operationId": "remoteAccess", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "properties": { + "autoAddress": { + "type": "string" + }, + "autoEndPort": { + "type": "integer" + }, + "autoMode": { + "type": "boolean" + }, + "autoStartPort": { + "type": "integer" + }, + "bindAddress": { + "type": "string" + }, + "envZId": { + "type": "string" + }, + "responseHeaders": { + "type": "array", + "items": { + "type": "string" + } + }, + "token": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "ok", + "schema": { + "properties": { + "frontendToken": { + "type": "string" + } + } + } + }, + "401": { + "description": "unauthorized" + }, + "500": { + "description": "internal server error" + }, + "502": { + "description": "bad gateway; agent not reachable" + } + } + } + }, "/agent/enroll": { "post": { "security": [ @@ -497,6 +568,49 @@ func init() { } } }, + "/agent/unaccess": { + "post": { + "security": [ + { + "key": [] + } + ], + "tags": [ + "agent" + ], + "operationId": "remoteUnaccess", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "properties": { + "envZId": { + "type": "string" + }, + "frontendToken": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "ok" + }, + "401": { + "description": "unauthorized" + }, + "500": { + "description": "internal server error" + }, + "502": { + "description": "bad gateway; agent not reachable" + } + } + } + }, "/agent/unenroll": { "post": { "security": [ @@ -2891,6 +3005,77 @@ func init() { } } }, + "/agent/access": { + "post": { + "security": [ + { + "key": [] + } + ], + "tags": [ + "agent" + ], + "operationId": "remoteAccess", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "properties": { + "autoAddress": { + "type": "string" + }, + "autoEndPort": { + "type": "integer" + }, + "autoMode": { + "type": "boolean" + }, + "autoStartPort": { + "type": "integer" + }, + "bindAddress": { + "type": "string" + }, + "envZId": { + "type": "string" + }, + "responseHeaders": { + "type": "array", + "items": { + "type": "string" + } + }, + "token": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "ok", + "schema": { + "properties": { + "frontendToken": { + "type": "string" + } + } + } + }, + "401": { + "description": "unauthorized" + }, + "500": { + "description": "internal server error" + }, + "502": { + "description": "bad gateway; agent not reachable" + } + } + } + }, "/agent/enroll": { "post": { "security": [ @@ -3157,6 +3342,49 @@ func init() { } } }, + "/agent/unaccess": { + "post": { + "security": [ + { + "key": [] + } + ], + "tags": [ + "agent" + ], + "operationId": "remoteUnaccess", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "properties": { + "envZId": { + "type": "string" + }, + "frontendToken": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "ok" + }, + "401": { + "description": "unauthorized" + }, + "500": { + "description": "internal server error" + }, + "502": { + "description": "bad gateway; agent not reachable" + } + } + } + }, "/agent/unenroll": { "post": { "security": [ diff --git a/rest_server_zrok/operations/agent/remote_access.go b/rest_server_zrok/operations/agent/remote_access.go new file mode 100644 index 00000000..11c9afe4 --- /dev/null +++ b/rest_server_zrok/operations/agent/remote_access.go @@ -0,0 +1,169 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package agent + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "context" + "net/http" + + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/openziti/zrok/rest_model_zrok" +) + +// RemoteAccessHandlerFunc turns a function with the right signature into a remote access handler +type RemoteAccessHandlerFunc func(RemoteAccessParams, *rest_model_zrok.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn RemoteAccessHandlerFunc) Handle(params RemoteAccessParams, principal *rest_model_zrok.Principal) middleware.Responder { + return fn(params, principal) +} + +// RemoteAccessHandler interface for that can handle valid remote access params +type RemoteAccessHandler interface { + Handle(RemoteAccessParams, *rest_model_zrok.Principal) middleware.Responder +} + +// NewRemoteAccess creates a new http.Handler for the remote access operation +func NewRemoteAccess(ctx *middleware.Context, handler RemoteAccessHandler) *RemoteAccess { + return &RemoteAccess{Context: ctx, Handler: handler} +} + +/* + RemoteAccess swagger:route POST /agent/access agent remoteAccess + +RemoteAccess remote access API +*/ +type RemoteAccess struct { + Context *middleware.Context + Handler RemoteAccessHandler +} + +func (o *RemoteAccess) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewRemoteAccessParams() + 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) + +} + +// RemoteAccessBody remote access body +// +// swagger:model RemoteAccessBody +type RemoteAccessBody struct { + + // auto address + AutoAddress string `json:"autoAddress,omitempty"` + + // auto end port + AutoEndPort int64 `json:"autoEndPort,omitempty"` + + // auto mode + AutoMode bool `json:"autoMode,omitempty"` + + // auto start port + AutoStartPort int64 `json:"autoStartPort,omitempty"` + + // bind address + BindAddress string `json:"bindAddress,omitempty"` + + // env z Id + EnvZID string `json:"envZId,omitempty"` + + // response headers + ResponseHeaders []string `json:"responseHeaders"` + + // token + Token string `json:"token,omitempty"` +} + +// Validate validates this remote access body +func (o *RemoteAccessBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this remote access body based on context it is used +func (o *RemoteAccessBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *RemoteAccessBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *RemoteAccessBody) UnmarshalBinary(b []byte) error { + var res RemoteAccessBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +// RemoteAccessOKBody remote access o k body +// +// swagger:model RemoteAccessOKBody +type RemoteAccessOKBody struct { + + // frontend token + FrontendToken string `json:"frontendToken,omitempty"` +} + +// Validate validates this remote access o k body +func (o *RemoteAccessOKBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this remote access o k body based on context it is used +func (o *RemoteAccessOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *RemoteAccessOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *RemoteAccessOKBody) UnmarshalBinary(b []byte) error { + var res RemoteAccessOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/rest_server_zrok/operations/agent/remote_access_parameters.go b/rest_server_zrok/operations/agent/remote_access_parameters.go new file mode 100644 index 00000000..ba6f805d --- /dev/null +++ b/rest_server_zrok/operations/agent/remote_access_parameters.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package agent + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/validate" +) + +// NewRemoteAccessParams creates a new RemoteAccessParams object +// +// There are no default values defined in the spec. +func NewRemoteAccessParams() RemoteAccessParams { + + return RemoteAccessParams{} +} + +// RemoteAccessParams contains all the bound params for the remote access operation +// typically these are obtained from a http.Request +// +// swagger:parameters remoteAccess +type RemoteAccessParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: body + */ + Body RemoteAccessBody +} + +// 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 NewRemoteAccessParams() beforehand. +func (o *RemoteAccessParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body RemoteAccessBody + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("body", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(r.Context()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Body = body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_server_zrok/operations/agent/remote_access_responses.go b/rest_server_zrok/operations/agent/remote_access_responses.go new file mode 100644 index 00000000..d9b0dfd3 --- /dev/null +++ b/rest_server_zrok/operations/agent/remote_access_responses.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package agent + +// 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" +) + +// RemoteAccessOKCode is the HTTP code returned for type RemoteAccessOK +const RemoteAccessOKCode int = 200 + +/* +RemoteAccessOK ok + +swagger:response remoteAccessOK +*/ +type RemoteAccessOK struct { + + /* + In: Body + */ + Payload *RemoteAccessOKBody `json:"body,omitempty"` +} + +// NewRemoteAccessOK creates RemoteAccessOK with default headers values +func NewRemoteAccessOK() *RemoteAccessOK { + + return &RemoteAccessOK{} +} + +// WithPayload adds the payload to the remote access o k response +func (o *RemoteAccessOK) WithPayload(payload *RemoteAccessOKBody) *RemoteAccessOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the remote access o k response +func (o *RemoteAccessOK) SetPayload(payload *RemoteAccessOKBody) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RemoteAccessOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RemoteAccessUnauthorizedCode is the HTTP code returned for type RemoteAccessUnauthorized +const RemoteAccessUnauthorizedCode int = 401 + +/* +RemoteAccessUnauthorized unauthorized + +swagger:response remoteAccessUnauthorized +*/ +type RemoteAccessUnauthorized struct { +} + +// NewRemoteAccessUnauthorized creates RemoteAccessUnauthorized with default headers values +func NewRemoteAccessUnauthorized() *RemoteAccessUnauthorized { + + return &RemoteAccessUnauthorized{} +} + +// WriteResponse to the client +func (o *RemoteAccessUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(401) +} + +// RemoteAccessInternalServerErrorCode is the HTTP code returned for type RemoteAccessInternalServerError +const RemoteAccessInternalServerErrorCode int = 500 + +/* +RemoteAccessInternalServerError internal server error + +swagger:response remoteAccessInternalServerError +*/ +type RemoteAccessInternalServerError struct { +} + +// NewRemoteAccessInternalServerError creates RemoteAccessInternalServerError with default headers values +func NewRemoteAccessInternalServerError() *RemoteAccessInternalServerError { + + return &RemoteAccessInternalServerError{} +} + +// WriteResponse to the client +func (o *RemoteAccessInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(500) +} + +// RemoteAccessBadGatewayCode is the HTTP code returned for type RemoteAccessBadGateway +const RemoteAccessBadGatewayCode int = 502 + +/* +RemoteAccessBadGateway bad gateway; agent not reachable + +swagger:response remoteAccessBadGateway +*/ +type RemoteAccessBadGateway struct { +} + +// NewRemoteAccessBadGateway creates RemoteAccessBadGateway with default headers values +func NewRemoteAccessBadGateway() *RemoteAccessBadGateway { + + return &RemoteAccessBadGateway{} +} + +// WriteResponse to the client +func (o *RemoteAccessBadGateway) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(502) +} diff --git a/rest_server_zrok/operations/agent/remote_access_urlbuilder.go b/rest_server_zrok/operations/agent/remote_access_urlbuilder.go new file mode 100644 index 00000000..3d7152f7 --- /dev/null +++ b/rest_server_zrok/operations/agent/remote_access_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package agent + +// 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" +) + +// RemoteAccessURL generates an URL for the remote access operation +type RemoteAccessURL 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 *RemoteAccessURL) WithBasePath(bp string) *RemoteAccessURL { + 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 *RemoteAccessURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RemoteAccessURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/agent/access" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RemoteAccessURL) 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 *RemoteAccessURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RemoteAccessURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RemoteAccessURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RemoteAccessURL") + } + + 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 *RemoteAccessURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server_zrok/operations/agent/remote_unaccess.go b/rest_server_zrok/operations/agent/remote_unaccess.go new file mode 100644 index 00000000..8a7a7eea --- /dev/null +++ b/rest_server_zrok/operations/agent/remote_unaccess.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package agent + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "context" + "net/http" + + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/openziti/zrok/rest_model_zrok" +) + +// RemoteUnaccessHandlerFunc turns a function with the right signature into a remote unaccess handler +type RemoteUnaccessHandlerFunc func(RemoteUnaccessParams, *rest_model_zrok.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn RemoteUnaccessHandlerFunc) Handle(params RemoteUnaccessParams, principal *rest_model_zrok.Principal) middleware.Responder { + return fn(params, principal) +} + +// RemoteUnaccessHandler interface for that can handle valid remote unaccess params +type RemoteUnaccessHandler interface { + Handle(RemoteUnaccessParams, *rest_model_zrok.Principal) middleware.Responder +} + +// NewRemoteUnaccess creates a new http.Handler for the remote unaccess operation +func NewRemoteUnaccess(ctx *middleware.Context, handler RemoteUnaccessHandler) *RemoteUnaccess { + return &RemoteUnaccess{Context: ctx, Handler: handler} +} + +/* + RemoteUnaccess swagger:route POST /agent/unaccess agent remoteUnaccess + +RemoteUnaccess remote unaccess API +*/ +type RemoteUnaccess struct { + Context *middleware.Context + Handler RemoteUnaccessHandler +} + +func (o *RemoteUnaccess) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewRemoteUnaccessParams() + 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) + +} + +// RemoteUnaccessBody remote unaccess body +// +// swagger:model RemoteUnaccessBody +type RemoteUnaccessBody struct { + + // env z Id + EnvZID string `json:"envZId,omitempty"` + + // frontend token + FrontendToken string `json:"frontendToken,omitempty"` +} + +// Validate validates this remote unaccess body +func (o *RemoteUnaccessBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this remote unaccess body based on context it is used +func (o *RemoteUnaccessBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *RemoteUnaccessBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *RemoteUnaccessBody) UnmarshalBinary(b []byte) error { + var res RemoteUnaccessBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/rest_server_zrok/operations/agent/remote_unaccess_parameters.go b/rest_server_zrok/operations/agent/remote_unaccess_parameters.go new file mode 100644 index 00000000..52a2f8de --- /dev/null +++ b/rest_server_zrok/operations/agent/remote_unaccess_parameters.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package agent + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/validate" +) + +// NewRemoteUnaccessParams creates a new RemoteUnaccessParams object +// +// There are no default values defined in the spec. +func NewRemoteUnaccessParams() RemoteUnaccessParams { + + return RemoteUnaccessParams{} +} + +// RemoteUnaccessParams contains all the bound params for the remote unaccess operation +// typically these are obtained from a http.Request +// +// swagger:parameters remoteUnaccess +type RemoteUnaccessParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: body + */ + Body RemoteUnaccessBody +} + +// 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 NewRemoteUnaccessParams() beforehand. +func (o *RemoteUnaccessParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body RemoteUnaccessBody + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("body", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(r.Context()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Body = body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_server_zrok/operations/agent/remote_unaccess_responses.go b/rest_server_zrok/operations/agent/remote_unaccess_responses.go new file mode 100644 index 00000000..0cfa4933 --- /dev/null +++ b/rest_server_zrok/operations/agent/remote_unaccess_responses.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package agent + +// 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" +) + +// RemoteUnaccessOKCode is the HTTP code returned for type RemoteUnaccessOK +const RemoteUnaccessOKCode int = 200 + +/* +RemoteUnaccessOK ok + +swagger:response remoteUnaccessOK +*/ +type RemoteUnaccessOK struct { +} + +// NewRemoteUnaccessOK creates RemoteUnaccessOK with default headers values +func NewRemoteUnaccessOK() *RemoteUnaccessOK { + + return &RemoteUnaccessOK{} +} + +// WriteResponse to the client +func (o *RemoteUnaccessOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// RemoteUnaccessUnauthorizedCode is the HTTP code returned for type RemoteUnaccessUnauthorized +const RemoteUnaccessUnauthorizedCode int = 401 + +/* +RemoteUnaccessUnauthorized unauthorized + +swagger:response remoteUnaccessUnauthorized +*/ +type RemoteUnaccessUnauthorized struct { +} + +// NewRemoteUnaccessUnauthorized creates RemoteUnaccessUnauthorized with default headers values +func NewRemoteUnaccessUnauthorized() *RemoteUnaccessUnauthorized { + + return &RemoteUnaccessUnauthorized{} +} + +// WriteResponse to the client +func (o *RemoteUnaccessUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(401) +} + +// RemoteUnaccessInternalServerErrorCode is the HTTP code returned for type RemoteUnaccessInternalServerError +const RemoteUnaccessInternalServerErrorCode int = 500 + +/* +RemoteUnaccessInternalServerError internal server error + +swagger:response remoteUnaccessInternalServerError +*/ +type RemoteUnaccessInternalServerError struct { +} + +// NewRemoteUnaccessInternalServerError creates RemoteUnaccessInternalServerError with default headers values +func NewRemoteUnaccessInternalServerError() *RemoteUnaccessInternalServerError { + + return &RemoteUnaccessInternalServerError{} +} + +// WriteResponse to the client +func (o *RemoteUnaccessInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(500) +} + +// RemoteUnaccessBadGatewayCode is the HTTP code returned for type RemoteUnaccessBadGateway +const RemoteUnaccessBadGatewayCode int = 502 + +/* +RemoteUnaccessBadGateway bad gateway; agent not reachable + +swagger:response remoteUnaccessBadGateway +*/ +type RemoteUnaccessBadGateway struct { +} + +// NewRemoteUnaccessBadGateway creates RemoteUnaccessBadGateway with default headers values +func NewRemoteUnaccessBadGateway() *RemoteUnaccessBadGateway { + + return &RemoteUnaccessBadGateway{} +} + +// WriteResponse to the client +func (o *RemoteUnaccessBadGateway) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(502) +} diff --git a/rest_server_zrok/operations/agent/remote_unaccess_urlbuilder.go b/rest_server_zrok/operations/agent/remote_unaccess_urlbuilder.go new file mode 100644 index 00000000..9cae9bba --- /dev/null +++ b/rest_server_zrok/operations/agent/remote_unaccess_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package agent + +// 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" +) + +// RemoteUnaccessURL generates an URL for the remote unaccess operation +type RemoteUnaccessURL 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 *RemoteUnaccessURL) WithBasePath(bp string) *RemoteUnaccessURL { + 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 *RemoteUnaccessURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RemoteUnaccessURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/agent/unaccess" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RemoteUnaccessURL) 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 *RemoteUnaccessURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RemoteUnaccessURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RemoteUnaccessURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RemoteUnaccessURL") + } + + 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 *RemoteUnaccessURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server_zrok/operations/zrok_api.go b/rest_server_zrok/operations/zrok_api.go index 4c015ed2..0f2a6a9c 100644 --- a/rest_server_zrok/operations/zrok_api.go +++ b/rest_server_zrok/operations/zrok_api.go @@ -158,12 +158,18 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI { AccountRegisterHandler: account.RegisterHandlerFunc(func(params account.RegisterParams) middleware.Responder { return middleware.NotImplemented("operation account.Register has not yet been implemented") }), + AgentRemoteAccessHandler: agent.RemoteAccessHandlerFunc(func(params agent.RemoteAccessParams, principal *rest_model_zrok.Principal) middleware.Responder { + return middleware.NotImplemented("operation agent.RemoteAccess has not yet been implemented") + }), AgentRemoteShareHandler: agent.RemoteShareHandlerFunc(func(params agent.RemoteShareParams, principal *rest_model_zrok.Principal) middleware.Responder { return middleware.NotImplemented("operation agent.RemoteShare has not yet been implemented") }), AgentRemoteStatusHandler: agent.RemoteStatusHandlerFunc(func(params agent.RemoteStatusParams, principal *rest_model_zrok.Principal) middleware.Responder { return middleware.NotImplemented("operation agent.RemoteStatus has not yet been implemented") }), + AgentRemoteUnaccessHandler: agent.RemoteUnaccessHandlerFunc(func(params agent.RemoteUnaccessParams, principal *rest_model_zrok.Principal) middleware.Responder { + return middleware.NotImplemented("operation agent.RemoteUnaccess has not yet been implemented") + }), AgentRemoteUnshareHandler: agent.RemoteUnshareHandlerFunc(func(params agent.RemoteUnshareParams, principal *rest_model_zrok.Principal) middleware.Responder { return middleware.NotImplemented("operation agent.RemoteUnshare has not yet been implemented") }), @@ -328,10 +334,14 @@ type ZrokAPI struct { AccountRegenerateAccountTokenHandler account.RegenerateAccountTokenHandler // AccountRegisterHandler sets the operation handler for the register operation AccountRegisterHandler account.RegisterHandler + // AgentRemoteAccessHandler sets the operation handler for the remote access operation + AgentRemoteAccessHandler agent.RemoteAccessHandler // AgentRemoteShareHandler sets the operation handler for the remote share operation AgentRemoteShareHandler agent.RemoteShareHandler // AgentRemoteStatusHandler sets the operation handler for the remote status operation AgentRemoteStatusHandler agent.RemoteStatusHandler + // AgentRemoteUnaccessHandler sets the operation handler for the remote unaccess operation + AgentRemoteUnaccessHandler agent.RemoteUnaccessHandler // AgentRemoteUnshareHandler sets the operation handler for the remote unshare operation AgentRemoteUnshareHandler agent.RemoteUnshareHandler // AdminRemoveOrganizationMemberHandler sets the operation handler for the remove organization member operation @@ -549,12 +559,18 @@ func (o *ZrokAPI) Validate() error { if o.AccountRegisterHandler == nil { unregistered = append(unregistered, "account.RegisterHandler") } + if o.AgentRemoteAccessHandler == nil { + unregistered = append(unregistered, "agent.RemoteAccessHandler") + } if o.AgentRemoteShareHandler == nil { unregistered = append(unregistered, "agent.RemoteShareHandler") } if o.AgentRemoteStatusHandler == nil { unregistered = append(unregistered, "agent.RemoteStatusHandler") } + if o.AgentRemoteUnaccessHandler == nil { + unregistered = append(unregistered, "agent.RemoteUnaccessHandler") + } if o.AgentRemoteUnshareHandler == nil { unregistered = append(unregistered, "agent.RemoteUnshareHandler") } @@ -843,6 +859,10 @@ func (o *ZrokAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } + o.handlers["POST"]["/agent/access"] = agent.NewRemoteAccess(o.context, o.AgentRemoteAccessHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } o.handlers["POST"]["/agent/share"] = agent.NewRemoteShare(o.context, o.AgentRemoteShareHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) @@ -851,6 +871,10 @@ func (o *ZrokAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } + o.handlers["POST"]["/agent/unaccess"] = agent.NewRemoteUnaccess(o.context, o.AgentRemoteUnaccessHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } o.handlers["POST"]["/agent/unshare"] = agent.NewRemoteUnshare(o.context, o.AgentRemoteUnshareHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) diff --git a/sdk/nodejs/sdk/src/api/.openapi-generator/FILES b/sdk/nodejs/sdk/src/api/.openapi-generator/FILES index 383bbb26..a2ecc8ad 100644 --- a/sdk/nodejs/sdk/src/api/.openapi-generator/FILES +++ b/sdk/nodejs/sdk/src/api/.openapi-generator/FILES @@ -47,11 +47,13 @@ models/Principal.ts models/RegenerateAccountToken200Response.ts models/RegenerateAccountTokenRequest.ts models/RegisterRequest.ts +models/RemoteAccessRequest.ts models/RemoteShare200Response.ts models/RemoteShareRequest.ts models/RemoteStatus200Response.ts models/RemoteStatus200ResponseAccessesInner.ts models/RemoteStatus200ResponseSharesInner.ts +models/RemoteUnaccessRequest.ts models/RemoteUnshareRequest.ts models/RemoveOrganizationMemberRequest.ts models/ResetPasswordRequest.ts diff --git a/sdk/nodejs/sdk/src/api/apis/AgentApi.ts b/sdk/nodejs/sdk/src/api/apis/AgentApi.ts index 7ccb6f92..ee24c3c6 100644 --- a/sdk/nodejs/sdk/src/api/apis/AgentApi.ts +++ b/sdk/nodejs/sdk/src/api/apis/AgentApi.ts @@ -15,27 +15,36 @@ import * as runtime from '../runtime'; import type { + CreateFrontend201Response, Enroll200Response, EnrollRequest, Ping200Response, + RemoteAccessRequest, RemoteShare200Response, RemoteShareRequest, RemoteStatus200Response, + RemoteUnaccessRequest, RemoteUnshareRequest, } from '../models/index'; import { + CreateFrontend201ResponseFromJSON, + CreateFrontend201ResponseToJSON, Enroll200ResponseFromJSON, Enroll200ResponseToJSON, EnrollRequestFromJSON, EnrollRequestToJSON, Ping200ResponseFromJSON, Ping200ResponseToJSON, + RemoteAccessRequestFromJSON, + RemoteAccessRequestToJSON, RemoteShare200ResponseFromJSON, RemoteShare200ResponseToJSON, RemoteShareRequestFromJSON, RemoteShareRequestToJSON, RemoteStatus200ResponseFromJSON, RemoteStatus200ResponseToJSON, + RemoteUnaccessRequestFromJSON, + RemoteUnaccessRequestToJSON, RemoteUnshareRequestFromJSON, RemoteUnshareRequestToJSON, } from '../models/index'; @@ -48,6 +57,10 @@ export interface PingRequest { body?: EnrollRequest; } +export interface RemoteAccessOperationRequest { + body?: RemoteAccessRequest; +} + export interface RemoteShareOperationRequest { body?: RemoteShareRequest; } @@ -56,6 +69,10 @@ export interface RemoteStatusRequest { body?: EnrollRequest; } +export interface RemoteUnaccessOperationRequest { + body?: RemoteUnaccessRequest; +} + export interface RemoteUnshareOperationRequest { body?: RemoteUnshareRequest; } @@ -131,6 +148,37 @@ export class AgentApi extends runtime.BaseAPI { return await response.value(); } + /** + */ + async remoteAccessRaw(requestParameters: RemoteAccessOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/zrok.v1+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["x-token"] = await this.configuration.apiKey("x-token"); // key authentication + } + + const response = await this.request({ + path: `/agent/access`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: RemoteAccessRequestToJSON(requestParameters['body']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CreateFrontend201ResponseFromJSON(jsonValue)); + } + + /** + */ + async remoteAccess(requestParameters: RemoteAccessOperationRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.remoteAccessRaw(requestParameters, initOverrides); + return await response.value(); + } + /** */ async remoteShareRaw(requestParameters: RemoteShareOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -193,6 +241,36 @@ export class AgentApi extends runtime.BaseAPI { return await response.value(); } + /** + */ + async remoteUnaccessRaw(requestParameters: RemoteUnaccessOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/zrok.v1+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["x-token"] = await this.configuration.apiKey("x-token"); // key authentication + } + + const response = await this.request({ + path: `/agent/unaccess`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: RemoteUnaccessRequestToJSON(requestParameters['body']), + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + */ + async remoteUnaccess(requestParameters: RemoteUnaccessOperationRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.remoteUnaccessRaw(requestParameters, initOverrides); + } + /** */ async remoteUnshareRaw(requestParameters: RemoteUnshareOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { diff --git a/sdk/nodejs/sdk/src/api/models/RemoteAccessRequest.ts b/sdk/nodejs/sdk/src/api/models/RemoteAccessRequest.ts new file mode 100644 index 00000000..575b80e5 --- /dev/null +++ b/sdk/nodejs/sdk/src/api/models/RemoteAccessRequest.ts @@ -0,0 +1,121 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * zrok + * zrok client access + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface RemoteAccessRequest + */ +export interface RemoteAccessRequest { + /** + * + * @type {string} + * @memberof RemoteAccessRequest + */ + envZId?: string; + /** + * + * @type {string} + * @memberof RemoteAccessRequest + */ + token?: string; + /** + * + * @type {string} + * @memberof RemoteAccessRequest + */ + bindAddress?: string; + /** + * + * @type {boolean} + * @memberof RemoteAccessRequest + */ + autoMode?: boolean; + /** + * + * @type {string} + * @memberof RemoteAccessRequest + */ + autoAddress?: string; + /** + * + * @type {number} + * @memberof RemoteAccessRequest + */ + autoStartPort?: number; + /** + * + * @type {number} + * @memberof RemoteAccessRequest + */ + autoEndPort?: number; + /** + * + * @type {Array} + * @memberof RemoteAccessRequest + */ + responseHeaders?: Array; +} + +/** + * Check if a given object implements the RemoteAccessRequest interface. + */ +export function instanceOfRemoteAccessRequest(value: object): value is RemoteAccessRequest { + return true; +} + +export function RemoteAccessRequestFromJSON(json: any): RemoteAccessRequest { + return RemoteAccessRequestFromJSONTyped(json, false); +} + +export function RemoteAccessRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): RemoteAccessRequest { + if (json == null) { + return json; + } + return { + + 'envZId': json['envZId'] == null ? undefined : json['envZId'], + 'token': json['token'] == null ? undefined : json['token'], + 'bindAddress': json['bindAddress'] == null ? undefined : json['bindAddress'], + 'autoMode': json['autoMode'] == null ? undefined : json['autoMode'], + 'autoAddress': json['autoAddress'] == null ? undefined : json['autoAddress'], + 'autoStartPort': json['autoStartPort'] == null ? undefined : json['autoStartPort'], + 'autoEndPort': json['autoEndPort'] == null ? undefined : json['autoEndPort'], + 'responseHeaders': json['responseHeaders'] == null ? undefined : json['responseHeaders'], + }; +} + +export function RemoteAccessRequestToJSON(json: any): RemoteAccessRequest { + return RemoteAccessRequestToJSONTyped(json, false); +} + +export function RemoteAccessRequestToJSONTyped(value?: RemoteAccessRequest | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'envZId': value['envZId'], + 'token': value['token'], + 'bindAddress': value['bindAddress'], + 'autoMode': value['autoMode'], + 'autoAddress': value['autoAddress'], + 'autoStartPort': value['autoStartPort'], + 'autoEndPort': value['autoEndPort'], + 'responseHeaders': value['responseHeaders'], + }; +} + diff --git a/sdk/nodejs/sdk/src/api/models/RemoteUnaccessRequest.ts b/sdk/nodejs/sdk/src/api/models/RemoteUnaccessRequest.ts new file mode 100644 index 00000000..f5062c5a --- /dev/null +++ b/sdk/nodejs/sdk/src/api/models/RemoteUnaccessRequest.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * zrok + * zrok client access + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface RemoteUnaccessRequest + */ +export interface RemoteUnaccessRequest { + /** + * + * @type {string} + * @memberof RemoteUnaccessRequest + */ + envZId?: string; + /** + * + * @type {string} + * @memberof RemoteUnaccessRequest + */ + frontendToken?: string; +} + +/** + * Check if a given object implements the RemoteUnaccessRequest interface. + */ +export function instanceOfRemoteUnaccessRequest(value: object): value is RemoteUnaccessRequest { + return true; +} + +export function RemoteUnaccessRequestFromJSON(json: any): RemoteUnaccessRequest { + return RemoteUnaccessRequestFromJSONTyped(json, false); +} + +export function RemoteUnaccessRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): RemoteUnaccessRequest { + if (json == null) { + return json; + } + return { + + 'envZId': json['envZId'] == null ? undefined : json['envZId'], + 'frontendToken': json['frontendToken'] == null ? undefined : json['frontendToken'], + }; +} + +export function RemoteUnaccessRequestToJSON(json: any): RemoteUnaccessRequest { + return RemoteUnaccessRequestToJSONTyped(json, false); +} + +export function RemoteUnaccessRequestToJSONTyped(value?: RemoteUnaccessRequest | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'envZId': value['envZId'], + 'frontendToken': value['frontendToken'], + }; +} + diff --git a/sdk/nodejs/sdk/src/api/models/index.ts b/sdk/nodejs/sdk/src/api/models/index.ts index f380a124..f9b94bca 100644 --- a/sdk/nodejs/sdk/src/api/models/index.ts +++ b/sdk/nodejs/sdk/src/api/models/index.ts @@ -40,11 +40,13 @@ export * from './Principal'; export * from './RegenerateAccountToken200Response'; export * from './RegenerateAccountTokenRequest'; export * from './RegisterRequest'; +export * from './RemoteAccessRequest'; export * from './RemoteShare200Response'; export * from './RemoteShareRequest'; export * from './RemoteStatus200Response'; export * from './RemoteStatus200ResponseAccessesInner'; export * from './RemoteStatus200ResponseSharesInner'; +export * from './RemoteUnaccessRequest'; export * from './RemoteUnshareRequest'; export * from './RemoveOrganizationMemberRequest'; export * from './ResetPasswordRequest'; diff --git a/sdk/python/src/.openapi-generator/FILES b/sdk/python/src/.openapi-generator/FILES index 289074a6..a379cf57 100644 --- a/sdk/python/src/.openapi-generator/FILES +++ b/sdk/python/src/.openapi-generator/FILES @@ -45,11 +45,13 @@ docs/Principal.md docs/RegenerateAccountToken200Response.md docs/RegenerateAccountTokenRequest.md docs/RegisterRequest.md +docs/RemoteAccessRequest.md docs/RemoteShare200Response.md docs/RemoteShareRequest.md docs/RemoteStatus200Response.md docs/RemoteStatus200ResponseAccessesInner.md docs/RemoteStatus200ResponseSharesInner.md +docs/RemoteUnaccessRequest.md docs/RemoteUnshareRequest.md docs/RemoveOrganizationMemberRequest.md docs/ResetPasswordRequest.md @@ -114,11 +116,13 @@ test/test_principal.py test/test_regenerate_account_token200_response.py test/test_regenerate_account_token_request.py test/test_register_request.py +test/test_remote_access_request.py test/test_remote_share200_response.py test/test_remote_share_request.py test/test_remote_status200_response.py test/test_remote_status200_response_accesses_inner.py test/test_remote_status200_response_shares_inner.py +test/test_remote_unaccess_request.py test/test_remote_unshare_request.py test/test_remove_organization_member_request.py test/test_reset_password_request.py @@ -188,11 +192,13 @@ zrok_api/models/principal.py zrok_api/models/regenerate_account_token200_response.py zrok_api/models/regenerate_account_token_request.py zrok_api/models/register_request.py +zrok_api/models/remote_access_request.py zrok_api/models/remote_share200_response.py zrok_api/models/remote_share_request.py zrok_api/models/remote_status200_response.py zrok_api/models/remote_status200_response_accesses_inner.py zrok_api/models/remote_status200_response_shares_inner.py +zrok_api/models/remote_unaccess_request.py zrok_api/models/remote_unshare_request.py zrok_api/models/remove_organization_member_request.py zrok_api/models/reset_password_request.py diff --git a/sdk/python/src/README.md b/sdk/python/src/README.md index a7c66b95..9fd04d80 100644 --- a/sdk/python/src/README.md +++ b/sdk/python/src/README.md @@ -116,8 +116,10 @@ Class | Method | HTTP request | Description *AdminApi* | [**update_frontend**](docs/AdminApi.md#update_frontend) | **PATCH** /frontend | *AgentApi* | [**enroll**](docs/AgentApi.md#enroll) | **POST** /agent/enroll | *AgentApi* | [**ping**](docs/AgentApi.md#ping) | **POST** /agent/ping | +*AgentApi* | [**remote_access**](docs/AgentApi.md#remote_access) | **POST** /agent/access | *AgentApi* | [**remote_share**](docs/AgentApi.md#remote_share) | **POST** /agent/share | *AgentApi* | [**remote_status**](docs/AgentApi.md#remote_status) | **POST** /agent/status | +*AgentApi* | [**remote_unaccess**](docs/AgentApi.md#remote_unaccess) | **POST** /agent/unaccess | *AgentApi* | [**remote_unshare**](docs/AgentApi.md#remote_unshare) | **POST** /agent/unshare | *AgentApi* | [**unenroll**](docs/AgentApi.md#unenroll) | **POST** /agent/unenroll | *EnvironmentApi* | [**disable**](docs/EnvironmentApi.md#disable) | **POST** /disable | @@ -188,11 +190,13 @@ Class | Method | HTTP request | Description - [RegenerateAccountToken200Response](docs/RegenerateAccountToken200Response.md) - [RegenerateAccountTokenRequest](docs/RegenerateAccountTokenRequest.md) - [RegisterRequest](docs/RegisterRequest.md) + - [RemoteAccessRequest](docs/RemoteAccessRequest.md) - [RemoteShare200Response](docs/RemoteShare200Response.md) - [RemoteShareRequest](docs/RemoteShareRequest.md) - [RemoteStatus200Response](docs/RemoteStatus200Response.md) - [RemoteStatus200ResponseAccessesInner](docs/RemoteStatus200ResponseAccessesInner.md) - [RemoteStatus200ResponseSharesInner](docs/RemoteStatus200ResponseSharesInner.md) + - [RemoteUnaccessRequest](docs/RemoteUnaccessRequest.md) - [RemoteUnshareRequest](docs/RemoteUnshareRequest.md) - [RemoveOrganizationMemberRequest](docs/RemoveOrganizationMemberRequest.md) - [ResetPasswordRequest](docs/ResetPasswordRequest.md) diff --git a/sdk/python/src/docs/AgentApi.md b/sdk/python/src/docs/AgentApi.md index 5a8abe5c..a43049c1 100644 --- a/sdk/python/src/docs/AgentApi.md +++ b/sdk/python/src/docs/AgentApi.md @@ -6,8 +6,10 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**enroll**](AgentApi.md#enroll) | **POST** /agent/enroll | [**ping**](AgentApi.md#ping) | **POST** /agent/ping | +[**remote_access**](AgentApi.md#remote_access) | **POST** /agent/access | [**remote_share**](AgentApi.md#remote_share) | **POST** /agent/share | [**remote_status**](AgentApi.md#remote_status) | **POST** /agent/status | +[**remote_unaccess**](AgentApi.md#remote_unaccess) | **POST** /agent/unaccess | [**remote_unshare**](AgentApi.md#remote_unshare) | **POST** /agent/unshare | [**unenroll**](AgentApi.md#unenroll) | **POST** /agent/unenroll | @@ -168,6 +170,84 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **remote_access** +> CreateFrontend201Response remote_access(body=body) + +### Example + +* Api Key Authentication (key): + +```python +import zrok_api +from zrok_api.models.create_frontend201_response import CreateFrontend201Response +from zrok_api.models.remote_access_request import RemoteAccessRequest +from zrok_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to /api/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = zrok_api.Configuration( + host = "/api/v1" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: key +configuration.api_key['key'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['key'] = 'Bearer' + +# Enter a context with an instance of the API client +with zrok_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = zrok_api.AgentApi(api_client) + body = zrok_api.RemoteAccessRequest() # RemoteAccessRequest | (optional) + + try: + api_response = api_instance.remote_access(body=body) + print("The response of AgentApi->remote_access:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling AgentApi->remote_access: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**RemoteAccessRequest**](RemoteAccessRequest.md)| | [optional] + +### Return type + +[**CreateFrontend201Response**](CreateFrontend201Response.md) + +### Authorization + +[key](../README.md#key) + +### HTTP request headers + + - **Content-Type**: application/zrok.v1+json + - **Accept**: application/zrok.v1+json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | ok | - | +**401** | unauthorized | - | +**500** | internal server error | - | +**502** | bad gateway; agent not reachable | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **remote_share** > RemoteShare200Response remote_share(body=body) @@ -324,6 +404,81 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **remote_unaccess** +> remote_unaccess(body=body) + +### Example + +* Api Key Authentication (key): + +```python +import zrok_api +from zrok_api.models.remote_unaccess_request import RemoteUnaccessRequest +from zrok_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to /api/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = zrok_api.Configuration( + host = "/api/v1" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: key +configuration.api_key['key'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['key'] = 'Bearer' + +# Enter a context with an instance of the API client +with zrok_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = zrok_api.AgentApi(api_client) + body = zrok_api.RemoteUnaccessRequest() # RemoteUnaccessRequest | (optional) + + try: + api_instance.remote_unaccess(body=body) + except Exception as e: + print("Exception when calling AgentApi->remote_unaccess: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**RemoteUnaccessRequest**](RemoteUnaccessRequest.md)| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[key](../README.md#key) + +### HTTP request headers + + - **Content-Type**: application/zrok.v1+json + - **Accept**: Not defined + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | ok | - | +**401** | unauthorized | - | +**500** | internal server error | - | +**502** | bad gateway; agent not reachable | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **remote_unshare** > remote_unshare(body=body) diff --git a/sdk/python/src/docs/RemoteAccessRequest.md b/sdk/python/src/docs/RemoteAccessRequest.md new file mode 100644 index 00000000..d383958d --- /dev/null +++ b/sdk/python/src/docs/RemoteAccessRequest.md @@ -0,0 +1,36 @@ +# RemoteAccessRequest + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**env_zid** | **str** | | [optional] +**token** | **str** | | [optional] +**bind_address** | **str** | | [optional] +**auto_mode** | **bool** | | [optional] +**auto_address** | **str** | | [optional] +**auto_start_port** | **int** | | [optional] +**auto_end_port** | **int** | | [optional] +**response_headers** | **List[str]** | | [optional] + +## Example + +```python +from zrok_api.models.remote_access_request import RemoteAccessRequest + +# TODO update the JSON string below +json = "{}" +# create an instance of RemoteAccessRequest from a JSON string +remote_access_request_instance = RemoteAccessRequest.from_json(json) +# print the JSON string representation of the object +print(RemoteAccessRequest.to_json()) + +# convert the object into a dict +remote_access_request_dict = remote_access_request_instance.to_dict() +# create an instance of RemoteAccessRequest from a dict +remote_access_request_from_dict = RemoteAccessRequest.from_dict(remote_access_request_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/sdk/python/src/docs/RemoteUnaccessRequest.md b/sdk/python/src/docs/RemoteUnaccessRequest.md new file mode 100644 index 00000000..b3caeaed --- /dev/null +++ b/sdk/python/src/docs/RemoteUnaccessRequest.md @@ -0,0 +1,30 @@ +# RemoteUnaccessRequest + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**env_zid** | **str** | | [optional] +**frontend_token** | **str** | | [optional] + +## Example + +```python +from zrok_api.models.remote_unaccess_request import RemoteUnaccessRequest + +# TODO update the JSON string below +json = "{}" +# create an instance of RemoteUnaccessRequest from a JSON string +remote_unaccess_request_instance = RemoteUnaccessRequest.from_json(json) +# print the JSON string representation of the object +print(RemoteUnaccessRequest.to_json()) + +# convert the object into a dict +remote_unaccess_request_dict = remote_unaccess_request_instance.to_dict() +# create an instance of RemoteUnaccessRequest from a dict +remote_unaccess_request_from_dict = RemoteUnaccessRequest.from_dict(remote_unaccess_request_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/sdk/python/src/test/test_agent_api.py b/sdk/python/src/test/test_agent_api.py index 32e0fec3..428cf927 100644 --- a/sdk/python/src/test/test_agent_api.py +++ b/sdk/python/src/test/test_agent_api.py @@ -38,6 +38,12 @@ class TestAgentApi(unittest.TestCase): """ pass + def test_remote_access(self) -> None: + """Test case for remote_access + + """ + pass + def test_remote_share(self) -> None: """Test case for remote_share @@ -50,6 +56,12 @@ class TestAgentApi(unittest.TestCase): """ pass + def test_remote_unaccess(self) -> None: + """Test case for remote_unaccess + + """ + pass + def test_remote_unshare(self) -> None: """Test case for remote_unshare diff --git a/sdk/python/src/test/test_remote_access_request.py b/sdk/python/src/test/test_remote_access_request.py new file mode 100644 index 00000000..4af86217 --- /dev/null +++ b/sdk/python/src/test/test_remote_access_request.py @@ -0,0 +1,60 @@ +# coding: utf-8 + +""" + zrok + + zrok client access + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from zrok_api.models.remote_access_request import RemoteAccessRequest + +class TestRemoteAccessRequest(unittest.TestCase): + """RemoteAccessRequest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> RemoteAccessRequest: + """Test RemoteAccessRequest + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `RemoteAccessRequest` + """ + model = RemoteAccessRequest() + if include_optional: + return RemoteAccessRequest( + env_zid = '', + token = '', + bind_address = '', + auto_mode = True, + auto_address = '', + auto_start_port = 56, + auto_end_port = 56, + response_headers = [ + '' + ] + ) + else: + return RemoteAccessRequest( + ) + """ + + def testRemoteAccessRequest(self): + """Test RemoteAccessRequest""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/sdk/python/src/test/test_remote_unaccess_request.py b/sdk/python/src/test/test_remote_unaccess_request.py new file mode 100644 index 00000000..b8c1f346 --- /dev/null +++ b/sdk/python/src/test/test_remote_unaccess_request.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + zrok + + zrok client access + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from zrok_api.models.remote_unaccess_request import RemoteUnaccessRequest + +class TestRemoteUnaccessRequest(unittest.TestCase): + """RemoteUnaccessRequest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> RemoteUnaccessRequest: + """Test RemoteUnaccessRequest + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `RemoteUnaccessRequest` + """ + model = RemoteUnaccessRequest() + if include_optional: + return RemoteUnaccessRequest( + env_zid = '', + frontend_token = '' + ) + else: + return RemoteUnaccessRequest( + ) + """ + + def testRemoteUnaccessRequest(self): + """Test RemoteUnaccessRequest""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/sdk/python/src/zrok_api/__init__.py b/sdk/python/src/zrok_api/__init__.py index 6150272a..ab4323ad 100644 --- a/sdk/python/src/zrok_api/__init__.py +++ b/sdk/python/src/zrok_api/__init__.py @@ -76,11 +76,13 @@ from zrok_api.models.principal import Principal from zrok_api.models.regenerate_account_token200_response import RegenerateAccountToken200Response from zrok_api.models.regenerate_account_token_request import RegenerateAccountTokenRequest from zrok_api.models.register_request import RegisterRequest +from zrok_api.models.remote_access_request import RemoteAccessRequest from zrok_api.models.remote_share200_response import RemoteShare200Response from zrok_api.models.remote_share_request import RemoteShareRequest from zrok_api.models.remote_status200_response import RemoteStatus200Response from zrok_api.models.remote_status200_response_accesses_inner import RemoteStatus200ResponseAccessesInner from zrok_api.models.remote_status200_response_shares_inner import RemoteStatus200ResponseSharesInner +from zrok_api.models.remote_unaccess_request import RemoteUnaccessRequest from zrok_api.models.remote_unshare_request import RemoteUnshareRequest from zrok_api.models.remove_organization_member_request import RemoveOrganizationMemberRequest from zrok_api.models.reset_password_request import ResetPasswordRequest diff --git a/sdk/python/src/zrok_api/api/agent_api.py b/sdk/python/src/zrok_api/api/agent_api.py index 72bd32c3..56544755 100644 --- a/sdk/python/src/zrok_api/api/agent_api.py +++ b/sdk/python/src/zrok_api/api/agent_api.py @@ -17,12 +17,15 @@ from typing import Any, Dict, List, Optional, Tuple, Union from typing_extensions import Annotated from typing import Optional +from zrok_api.models.create_frontend201_response import CreateFrontend201Response from zrok_api.models.enroll200_response import Enroll200Response from zrok_api.models.enroll_request import EnrollRequest from zrok_api.models.ping200_response import Ping200Response +from zrok_api.models.remote_access_request import RemoteAccessRequest from zrok_api.models.remote_share200_response import RemoteShare200Response from zrok_api.models.remote_share_request import RemoteShareRequest from zrok_api.models.remote_status200_response import RemoteStatus200Response +from zrok_api.models.remote_unaccess_request import RemoteUnaccessRequest from zrok_api.models.remote_unshare_request import RemoteUnshareRequest from zrok_api.api_client import ApiClient, RequestSerialized @@ -603,6 +606,286 @@ class AgentApi: + @validate_call + def remote_access( + self, + body: Optional[RemoteAccessRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> CreateFrontend201Response: + """remote_access + + + :param body: + :type body: RemoteAccessRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._remote_access_serialize( + body=body, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CreateFrontend201Response", + '401': None, + '500': None, + '502': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def remote_access_with_http_info( + self, + body: Optional[RemoteAccessRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[CreateFrontend201Response]: + """remote_access + + + :param body: + :type body: RemoteAccessRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._remote_access_serialize( + body=body, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CreateFrontend201Response", + '401': None, + '500': None, + '502': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def remote_access_without_preload_content( + self, + body: Optional[RemoteAccessRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """remote_access + + + :param body: + :type body: RemoteAccessRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._remote_access_serialize( + body=body, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CreateFrontend201Response", + '401': None, + '500': None, + '502': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _remote_access_serialize( + self, + body, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if body is not None: + _body_params = body + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/zrok.v1+json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/zrok.v1+json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'key' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/agent/access', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def remote_share( self, @@ -1163,6 +1446,279 @@ class AgentApi: + @validate_call + def remote_unaccess( + self, + body: Optional[RemoteUnaccessRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """remote_unaccess + + + :param body: + :type body: RemoteUnaccessRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._remote_unaccess_serialize( + body=body, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': None, + '401': None, + '500': None, + '502': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def remote_unaccess_with_http_info( + self, + body: Optional[RemoteUnaccessRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """remote_unaccess + + + :param body: + :type body: RemoteUnaccessRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._remote_unaccess_serialize( + body=body, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': None, + '401': None, + '500': None, + '502': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def remote_unaccess_without_preload_content( + self, + body: Optional[RemoteUnaccessRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """remote_unaccess + + + :param body: + :type body: RemoteUnaccessRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._remote_unaccess_serialize( + body=body, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': None, + '401': None, + '500': None, + '502': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _remote_unaccess_serialize( + self, + body, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if body is not None: + _body_params = body + + + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/zrok.v1+json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'key' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/agent/unaccess', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def remote_unshare( self, diff --git a/sdk/python/src/zrok_api/models/__init__.py b/sdk/python/src/zrok_api/models/__init__.py index 6a8005ad..3a034b7a 100644 --- a/sdk/python/src/zrok_api/models/__init__.py +++ b/sdk/python/src/zrok_api/models/__init__.py @@ -54,11 +54,13 @@ from zrok_api.models.principal import Principal from zrok_api.models.regenerate_account_token200_response import RegenerateAccountToken200Response from zrok_api.models.regenerate_account_token_request import RegenerateAccountTokenRequest from zrok_api.models.register_request import RegisterRequest +from zrok_api.models.remote_access_request import RemoteAccessRequest from zrok_api.models.remote_share200_response import RemoteShare200Response from zrok_api.models.remote_share_request import RemoteShareRequest from zrok_api.models.remote_status200_response import RemoteStatus200Response from zrok_api.models.remote_status200_response_accesses_inner import RemoteStatus200ResponseAccessesInner from zrok_api.models.remote_status200_response_shares_inner import RemoteStatus200ResponseSharesInner +from zrok_api.models.remote_unaccess_request import RemoteUnaccessRequest from zrok_api.models.remote_unshare_request import RemoteUnshareRequest from zrok_api.models.remove_organization_member_request import RemoveOrganizationMemberRequest from zrok_api.models.reset_password_request import ResetPasswordRequest diff --git a/sdk/python/src/zrok_api/models/remote_access_request.py b/sdk/python/src/zrok_api/models/remote_access_request.py new file mode 100644 index 00000000..137b0d87 --- /dev/null +++ b/sdk/python/src/zrok_api/models/remote_access_request.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + zrok + + zrok client access + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class RemoteAccessRequest(BaseModel): + """ + RemoteAccessRequest + """ # noqa: E501 + env_zid: Optional[StrictStr] = Field(default=None, alias="envZId") + token: Optional[StrictStr] = None + bind_address: Optional[StrictStr] = Field(default=None, alias="bindAddress") + auto_mode: Optional[StrictBool] = Field(default=None, alias="autoMode") + auto_address: Optional[StrictStr] = Field(default=None, alias="autoAddress") + auto_start_port: Optional[StrictInt] = Field(default=None, alias="autoStartPort") + auto_end_port: Optional[StrictInt] = Field(default=None, alias="autoEndPort") + response_headers: Optional[List[StrictStr]] = Field(default=None, alias="responseHeaders") + __properties: ClassVar[List[str]] = ["envZId", "token", "bindAddress", "autoMode", "autoAddress", "autoStartPort", "autoEndPort", "responseHeaders"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RemoteAccessRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RemoteAccessRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "envZId": obj.get("envZId"), + "token": obj.get("token"), + "bindAddress": obj.get("bindAddress"), + "autoMode": obj.get("autoMode"), + "autoAddress": obj.get("autoAddress"), + "autoStartPort": obj.get("autoStartPort"), + "autoEndPort": obj.get("autoEndPort"), + "responseHeaders": obj.get("responseHeaders") + }) + return _obj + + diff --git a/sdk/python/src/zrok_api/models/remote_unaccess_request.py b/sdk/python/src/zrok_api/models/remote_unaccess_request.py new file mode 100644 index 00000000..2716a0ce --- /dev/null +++ b/sdk/python/src/zrok_api/models/remote_unaccess_request.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + zrok + + zrok client access + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class RemoteUnaccessRequest(BaseModel): + """ + RemoteUnaccessRequest + """ # noqa: E501 + env_zid: Optional[StrictStr] = Field(default=None, alias="envZId") + frontend_token: Optional[StrictStr] = Field(default=None, alias="frontendToken") + __properties: ClassVar[List[str]] = ["envZId", "frontendToken"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RemoteUnaccessRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RemoteUnaccessRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "envZId": obj.get("envZId"), + "frontendToken": obj.get("frontendToken") + }) + return _obj + + diff --git a/specs/zrok.yml b/specs/zrok.yml index b156351f..ad1ab71d 100644 --- a/specs/zrok.yml +++ b/specs/zrok.yml @@ -616,6 +616,50 @@ paths: # # agent # + /agent/access: + post: + tags: + - agent + security: + - key: [] + operationId: remoteAccess + parameters: + - name: body + in: body + schema: + properties: + envZId: + type: string + token: + type: string + bindAddress: + type: string + autoMode: + type: boolean + autoAddress: + type: string + autoStartPort: + type: integer + autoEndPort: + type: integer + responseHeaders: + type: array + items: + type: string + responses: + 200: + description: ok + schema: + properties: + frontendToken: + type: string + 401: + description: unauthorized + 500: + description: internal server error + 502: + description: bad gateway; agent not reachable + /agent/enroll: post: tags: @@ -802,6 +846,32 @@ paths: 502: description: bad gateway; agent not reachable + /agent/unaccess: + post: + tags: + - agent + security: + - key: [] + operationId: remoteUnaccess + parameters: + - name: body + in: body + schema: + properties: + envZId: + type: string + frontendToken: + type: string + responses: + 200: + description: ok + 401: + description: unauthorized + 500: + description: internal server error + 502: + description: bad gateway; agent not reachable + /agent/unenroll: post: tags: diff --git a/ui/src/api/.openapi-generator/FILES b/ui/src/api/.openapi-generator/FILES index 383bbb26..a2ecc8ad 100644 --- a/ui/src/api/.openapi-generator/FILES +++ b/ui/src/api/.openapi-generator/FILES @@ -47,11 +47,13 @@ models/Principal.ts models/RegenerateAccountToken200Response.ts models/RegenerateAccountTokenRequest.ts models/RegisterRequest.ts +models/RemoteAccessRequest.ts models/RemoteShare200Response.ts models/RemoteShareRequest.ts models/RemoteStatus200Response.ts models/RemoteStatus200ResponseAccessesInner.ts models/RemoteStatus200ResponseSharesInner.ts +models/RemoteUnaccessRequest.ts models/RemoteUnshareRequest.ts models/RemoveOrganizationMemberRequest.ts models/ResetPasswordRequest.ts diff --git a/ui/src/api/apis/AgentApi.ts b/ui/src/api/apis/AgentApi.ts index 7ccb6f92..ee24c3c6 100644 --- a/ui/src/api/apis/AgentApi.ts +++ b/ui/src/api/apis/AgentApi.ts @@ -15,27 +15,36 @@ import * as runtime from '../runtime'; import type { + CreateFrontend201Response, Enroll200Response, EnrollRequest, Ping200Response, + RemoteAccessRequest, RemoteShare200Response, RemoteShareRequest, RemoteStatus200Response, + RemoteUnaccessRequest, RemoteUnshareRequest, } from '../models/index'; import { + CreateFrontend201ResponseFromJSON, + CreateFrontend201ResponseToJSON, Enroll200ResponseFromJSON, Enroll200ResponseToJSON, EnrollRequestFromJSON, EnrollRequestToJSON, Ping200ResponseFromJSON, Ping200ResponseToJSON, + RemoteAccessRequestFromJSON, + RemoteAccessRequestToJSON, RemoteShare200ResponseFromJSON, RemoteShare200ResponseToJSON, RemoteShareRequestFromJSON, RemoteShareRequestToJSON, RemoteStatus200ResponseFromJSON, RemoteStatus200ResponseToJSON, + RemoteUnaccessRequestFromJSON, + RemoteUnaccessRequestToJSON, RemoteUnshareRequestFromJSON, RemoteUnshareRequestToJSON, } from '../models/index'; @@ -48,6 +57,10 @@ export interface PingRequest { body?: EnrollRequest; } +export interface RemoteAccessOperationRequest { + body?: RemoteAccessRequest; +} + export interface RemoteShareOperationRequest { body?: RemoteShareRequest; } @@ -56,6 +69,10 @@ export interface RemoteStatusRequest { body?: EnrollRequest; } +export interface RemoteUnaccessOperationRequest { + body?: RemoteUnaccessRequest; +} + export interface RemoteUnshareOperationRequest { body?: RemoteUnshareRequest; } @@ -131,6 +148,37 @@ export class AgentApi extends runtime.BaseAPI { return await response.value(); } + /** + */ + async remoteAccessRaw(requestParameters: RemoteAccessOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/zrok.v1+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["x-token"] = await this.configuration.apiKey("x-token"); // key authentication + } + + const response = await this.request({ + path: `/agent/access`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: RemoteAccessRequestToJSON(requestParameters['body']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => CreateFrontend201ResponseFromJSON(jsonValue)); + } + + /** + */ + async remoteAccess(requestParameters: RemoteAccessOperationRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.remoteAccessRaw(requestParameters, initOverrides); + return await response.value(); + } + /** */ async remoteShareRaw(requestParameters: RemoteShareOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -193,6 +241,36 @@ export class AgentApi extends runtime.BaseAPI { return await response.value(); } + /** + */ + async remoteUnaccessRaw(requestParameters: RemoteUnaccessOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/zrok.v1+json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["x-token"] = await this.configuration.apiKey("x-token"); // key authentication + } + + const response = await this.request({ + path: `/agent/unaccess`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: RemoteUnaccessRequestToJSON(requestParameters['body']), + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + */ + async remoteUnaccess(requestParameters: RemoteUnaccessOperationRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.remoteUnaccessRaw(requestParameters, initOverrides); + } + /** */ async remoteUnshareRaw(requestParameters: RemoteUnshareOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { diff --git a/ui/src/api/models/RemoteAccessRequest.ts b/ui/src/api/models/RemoteAccessRequest.ts new file mode 100644 index 00000000..575b80e5 --- /dev/null +++ b/ui/src/api/models/RemoteAccessRequest.ts @@ -0,0 +1,121 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * zrok + * zrok client access + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface RemoteAccessRequest + */ +export interface RemoteAccessRequest { + /** + * + * @type {string} + * @memberof RemoteAccessRequest + */ + envZId?: string; + /** + * + * @type {string} + * @memberof RemoteAccessRequest + */ + token?: string; + /** + * + * @type {string} + * @memberof RemoteAccessRequest + */ + bindAddress?: string; + /** + * + * @type {boolean} + * @memberof RemoteAccessRequest + */ + autoMode?: boolean; + /** + * + * @type {string} + * @memberof RemoteAccessRequest + */ + autoAddress?: string; + /** + * + * @type {number} + * @memberof RemoteAccessRequest + */ + autoStartPort?: number; + /** + * + * @type {number} + * @memberof RemoteAccessRequest + */ + autoEndPort?: number; + /** + * + * @type {Array} + * @memberof RemoteAccessRequest + */ + responseHeaders?: Array; +} + +/** + * Check if a given object implements the RemoteAccessRequest interface. + */ +export function instanceOfRemoteAccessRequest(value: object): value is RemoteAccessRequest { + return true; +} + +export function RemoteAccessRequestFromJSON(json: any): RemoteAccessRequest { + return RemoteAccessRequestFromJSONTyped(json, false); +} + +export function RemoteAccessRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): RemoteAccessRequest { + if (json == null) { + return json; + } + return { + + 'envZId': json['envZId'] == null ? undefined : json['envZId'], + 'token': json['token'] == null ? undefined : json['token'], + 'bindAddress': json['bindAddress'] == null ? undefined : json['bindAddress'], + 'autoMode': json['autoMode'] == null ? undefined : json['autoMode'], + 'autoAddress': json['autoAddress'] == null ? undefined : json['autoAddress'], + 'autoStartPort': json['autoStartPort'] == null ? undefined : json['autoStartPort'], + 'autoEndPort': json['autoEndPort'] == null ? undefined : json['autoEndPort'], + 'responseHeaders': json['responseHeaders'] == null ? undefined : json['responseHeaders'], + }; +} + +export function RemoteAccessRequestToJSON(json: any): RemoteAccessRequest { + return RemoteAccessRequestToJSONTyped(json, false); +} + +export function RemoteAccessRequestToJSONTyped(value?: RemoteAccessRequest | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'envZId': value['envZId'], + 'token': value['token'], + 'bindAddress': value['bindAddress'], + 'autoMode': value['autoMode'], + 'autoAddress': value['autoAddress'], + 'autoStartPort': value['autoStartPort'], + 'autoEndPort': value['autoEndPort'], + 'responseHeaders': value['responseHeaders'], + }; +} + diff --git a/ui/src/api/models/RemoteUnaccessRequest.ts b/ui/src/api/models/RemoteUnaccessRequest.ts new file mode 100644 index 00000000..f5062c5a --- /dev/null +++ b/ui/src/api/models/RemoteUnaccessRequest.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * zrok + * zrok client access + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface RemoteUnaccessRequest + */ +export interface RemoteUnaccessRequest { + /** + * + * @type {string} + * @memberof RemoteUnaccessRequest + */ + envZId?: string; + /** + * + * @type {string} + * @memberof RemoteUnaccessRequest + */ + frontendToken?: string; +} + +/** + * Check if a given object implements the RemoteUnaccessRequest interface. + */ +export function instanceOfRemoteUnaccessRequest(value: object): value is RemoteUnaccessRequest { + return true; +} + +export function RemoteUnaccessRequestFromJSON(json: any): RemoteUnaccessRequest { + return RemoteUnaccessRequestFromJSONTyped(json, false); +} + +export function RemoteUnaccessRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): RemoteUnaccessRequest { + if (json == null) { + return json; + } + return { + + 'envZId': json['envZId'] == null ? undefined : json['envZId'], + 'frontendToken': json['frontendToken'] == null ? undefined : json['frontendToken'], + }; +} + +export function RemoteUnaccessRequestToJSON(json: any): RemoteUnaccessRequest { + return RemoteUnaccessRequestToJSONTyped(json, false); +} + +export function RemoteUnaccessRequestToJSONTyped(value?: RemoteUnaccessRequest | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'envZId': value['envZId'], + 'frontendToken': value['frontendToken'], + }; +} + diff --git a/ui/src/api/models/index.ts b/ui/src/api/models/index.ts index f380a124..f9b94bca 100644 --- a/ui/src/api/models/index.ts +++ b/ui/src/api/models/index.ts @@ -40,11 +40,13 @@ export * from './Principal'; export * from './RegenerateAccountToken200Response'; export * from './RegenerateAccountTokenRequest'; export * from './RegisterRequest'; +export * from './RemoteAccessRequest'; export * from './RemoteShare200Response'; export * from './RemoteShareRequest'; export * from './RemoteStatus200Response'; export * from './RemoteStatus200ResponseAccessesInner'; export * from './RemoteStatus200ResponseSharesInner'; +export * from './RemoteUnaccessRequest'; export * from './RemoteUnshareRequest'; export * from './RemoveOrganizationMemberRequest'; export * from './ResetPasswordRequest';