initial access/unaccess api (#111)

This commit is contained in:
Michael Quigley 2022-11-23 12:12:11 -05:00
parent 4ec0004285
commit f47d97d103
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
20 changed files with 1939 additions and 0 deletions

View File

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

View File

@ -0,0 +1,197 @@
// Code generated by go-swagger; DO NOT EDIT.
package service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
)
// AccessReader is a Reader for the Access structure.
type AccessReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *AccessReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 201:
result := NewAccessCreated()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 401:
result := NewAccessUnauthorized()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 500:
result := NewAccessInternalServerError()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
}
}
// NewAccessCreated creates a AccessCreated with default headers values
func NewAccessCreated() *AccessCreated {
return &AccessCreated{}
}
/*
AccessCreated describes a response with status code 201, with default header values.
access created
*/
type AccessCreated struct {
}
// IsSuccess returns true when this access created response has a 2xx status code
func (o *AccessCreated) IsSuccess() bool {
return true
}
// IsRedirect returns true when this access created response has a 3xx status code
func (o *AccessCreated) IsRedirect() bool {
return false
}
// IsClientError returns true when this access created response has a 4xx status code
func (o *AccessCreated) IsClientError() bool {
return false
}
// IsServerError returns true when this access created response has a 5xx status code
func (o *AccessCreated) IsServerError() bool {
return false
}
// IsCode returns true when this access created response a status code equal to that given
func (o *AccessCreated) IsCode(code int) bool {
return code == 201
}
func (o *AccessCreated) Error() string {
return fmt.Sprintf("[POST /access][%d] accessCreated ", 201)
}
func (o *AccessCreated) String() string {
return fmt.Sprintf("[POST /access][%d] accessCreated ", 201)
}
func (o *AccessCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewAccessUnauthorized creates a AccessUnauthorized with default headers values
func NewAccessUnauthorized() *AccessUnauthorized {
return &AccessUnauthorized{}
}
/*
AccessUnauthorized describes a response with status code 401, with default header values.
unauthorized
*/
type AccessUnauthorized struct {
}
// IsSuccess returns true when this access unauthorized response has a 2xx status code
func (o *AccessUnauthorized) IsSuccess() bool {
return false
}
// IsRedirect returns true when this access unauthorized response has a 3xx status code
func (o *AccessUnauthorized) IsRedirect() bool {
return false
}
// IsClientError returns true when this access unauthorized response has a 4xx status code
func (o *AccessUnauthorized) IsClientError() bool {
return true
}
// IsServerError returns true when this access unauthorized response has a 5xx status code
func (o *AccessUnauthorized) IsServerError() bool {
return false
}
// IsCode returns true when this access unauthorized response a status code equal to that given
func (o *AccessUnauthorized) IsCode(code int) bool {
return code == 401
}
func (o *AccessUnauthorized) Error() string {
return fmt.Sprintf("[POST /access][%d] accessUnauthorized ", 401)
}
func (o *AccessUnauthorized) String() string {
return fmt.Sprintf("[POST /access][%d] accessUnauthorized ", 401)
}
func (o *AccessUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewAccessInternalServerError creates a AccessInternalServerError with default headers values
func NewAccessInternalServerError() *AccessInternalServerError {
return &AccessInternalServerError{}
}
/*
AccessInternalServerError describes a response with status code 500, with default header values.
internal server error
*/
type AccessInternalServerError struct {
}
// IsSuccess returns true when this access internal server error response has a 2xx status code
func (o *AccessInternalServerError) IsSuccess() bool {
return false
}
// IsRedirect returns true when this access internal server error response has a 3xx status code
func (o *AccessInternalServerError) IsRedirect() bool {
return false
}
// IsClientError returns true when this access internal server error response has a 4xx status code
func (o *AccessInternalServerError) IsClientError() bool {
return false
}
// IsServerError returns true when this access internal server error response has a 5xx status code
func (o *AccessInternalServerError) IsServerError() bool {
return true
}
// IsCode returns true when this access internal server error response a status code equal to that given
func (o *AccessInternalServerError) IsCode(code int) bool {
return code == 500
}
func (o *AccessInternalServerError) Error() string {
return fmt.Sprintf("[POST /access][%d] accessInternalServerError ", 500)
}
func (o *AccessInternalServerError) String() string {
return fmt.Sprintf("[POST /access][%d] accessInternalServerError ", 500)
}
func (o *AccessInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}

View File

@ -30,13 +30,56 @@ type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods
type ClientService interface {
Access(params *AccessParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AccessCreated, error)
Share(params *ShareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ShareCreated, error)
Unaccess(params *UnaccessParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnaccessOK, error)
Unshare(params *UnshareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnshareOK, error)
SetTransport(transport runtime.ClientTransport)
}
/*
Access access API
*/
func (a *Client) Access(params *AccessParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AccessCreated, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewAccessParams()
}
op := &runtime.ClientOperation{
ID: "access",
Method: "POST",
PathPattern: "/access",
ProducesMediaTypes: []string{"application/zrok.v1+json"},
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
Schemes: []string{"http"},
Params: params,
Reader: &AccessReader{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.(*AccessCreated)
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 access: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
Share share API
*/
@ -76,6 +119,45 @@ func (a *Client) Share(params *ShareParams, authInfo runtime.ClientAuthInfoWrite
panic(msg)
}
/*
Unaccess unaccess API
*/
func (a *Client) Unaccess(params *UnaccessParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnaccessOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewUnaccessParams()
}
op := &runtime.ClientOperation{
ID: "unaccess",
Method: "DELETE",
PathPattern: "/unaccess",
ProducesMediaTypes: []string{"application/zrok.v1+json"},
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
Schemes: []string{"http"},
Params: params,
Reader: &UnaccessReader{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.(*UnaccessOK)
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 unaccess: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
Unshare unshare API
*/

View File

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

View File

@ -0,0 +1,254 @@
// Code generated by go-swagger; DO NOT EDIT.
package service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
)
// UnaccessReader is a Reader for the Unaccess structure.
type UnaccessReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *UnaccessReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewUnaccessOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 401:
result := NewUnaccessUnauthorized()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 404:
result := NewUnaccessNotFound()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 500:
result := NewUnaccessInternalServerError()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
}
}
// NewUnaccessOK creates a UnaccessOK with default headers values
func NewUnaccessOK() *UnaccessOK {
return &UnaccessOK{}
}
/*
UnaccessOK describes a response with status code 200, with default header values.
access removed
*/
type UnaccessOK struct {
}
// IsSuccess returns true when this unaccess o k response has a 2xx status code
func (o *UnaccessOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this unaccess o k response has a 3xx status code
func (o *UnaccessOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this unaccess o k response has a 4xx status code
func (o *UnaccessOK) IsClientError() bool {
return false
}
// IsServerError returns true when this unaccess o k response has a 5xx status code
func (o *UnaccessOK) IsServerError() bool {
return false
}
// IsCode returns true when this unaccess o k response a status code equal to that given
func (o *UnaccessOK) IsCode(code int) bool {
return code == 200
}
func (o *UnaccessOK) Error() string {
return fmt.Sprintf("[DELETE /unaccess][%d] unaccessOK ", 200)
}
func (o *UnaccessOK) String() string {
return fmt.Sprintf("[DELETE /unaccess][%d] unaccessOK ", 200)
}
func (o *UnaccessOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewUnaccessUnauthorized creates a UnaccessUnauthorized with default headers values
func NewUnaccessUnauthorized() *UnaccessUnauthorized {
return &UnaccessUnauthorized{}
}
/*
UnaccessUnauthorized describes a response with status code 401, with default header values.
unauthorized
*/
type UnaccessUnauthorized struct {
}
// IsSuccess returns true when this unaccess unauthorized response has a 2xx status code
func (o *UnaccessUnauthorized) IsSuccess() bool {
return false
}
// IsRedirect returns true when this unaccess unauthorized response has a 3xx status code
func (o *UnaccessUnauthorized) IsRedirect() bool {
return false
}
// IsClientError returns true when this unaccess unauthorized response has a 4xx status code
func (o *UnaccessUnauthorized) IsClientError() bool {
return true
}
// IsServerError returns true when this unaccess unauthorized response has a 5xx status code
func (o *UnaccessUnauthorized) IsServerError() bool {
return false
}
// IsCode returns true when this unaccess unauthorized response a status code equal to that given
func (o *UnaccessUnauthorized) IsCode(code int) bool {
return code == 401
}
func (o *UnaccessUnauthorized) Error() string {
return fmt.Sprintf("[DELETE /unaccess][%d] unaccessUnauthorized ", 401)
}
func (o *UnaccessUnauthorized) String() string {
return fmt.Sprintf("[DELETE /unaccess][%d] unaccessUnauthorized ", 401)
}
func (o *UnaccessUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewUnaccessNotFound creates a UnaccessNotFound with default headers values
func NewUnaccessNotFound() *UnaccessNotFound {
return &UnaccessNotFound{}
}
/*
UnaccessNotFound describes a response with status code 404, with default header values.
not found
*/
type UnaccessNotFound struct {
}
// IsSuccess returns true when this unaccess not found response has a 2xx status code
func (o *UnaccessNotFound) IsSuccess() bool {
return false
}
// IsRedirect returns true when this unaccess not found response has a 3xx status code
func (o *UnaccessNotFound) IsRedirect() bool {
return false
}
// IsClientError returns true when this unaccess not found response has a 4xx status code
func (o *UnaccessNotFound) IsClientError() bool {
return true
}
// IsServerError returns true when this unaccess not found response has a 5xx status code
func (o *UnaccessNotFound) IsServerError() bool {
return false
}
// IsCode returns true when this unaccess not found response a status code equal to that given
func (o *UnaccessNotFound) IsCode(code int) bool {
return code == 404
}
func (o *UnaccessNotFound) Error() string {
return fmt.Sprintf("[DELETE /unaccess][%d] unaccessNotFound ", 404)
}
func (o *UnaccessNotFound) String() string {
return fmt.Sprintf("[DELETE /unaccess][%d] unaccessNotFound ", 404)
}
func (o *UnaccessNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewUnaccessInternalServerError creates a UnaccessInternalServerError with default headers values
func NewUnaccessInternalServerError() *UnaccessInternalServerError {
return &UnaccessInternalServerError{}
}
/*
UnaccessInternalServerError describes a response with status code 500, with default header values.
internal server error
*/
type UnaccessInternalServerError struct {
}
// IsSuccess returns true when this unaccess internal server error response has a 2xx status code
func (o *UnaccessInternalServerError) IsSuccess() bool {
return false
}
// IsRedirect returns true when this unaccess internal server error response has a 3xx status code
func (o *UnaccessInternalServerError) IsRedirect() bool {
return false
}
// IsClientError returns true when this unaccess internal server error response has a 4xx status code
func (o *UnaccessInternalServerError) IsClientError() bool {
return false
}
// IsServerError returns true when this unaccess internal server error response has a 5xx status code
func (o *UnaccessInternalServerError) IsServerError() bool {
return true
}
// IsCode returns true when this unaccess internal server error response a status code equal to that given
func (o *UnaccessInternalServerError) IsCode(code int) bool {
return code == 500
}
func (o *UnaccessInternalServerError) Error() string {
return fmt.Sprintf("[DELETE /unaccess][%d] unaccessInternalServerError ", 500)
}
func (o *UnaccessInternalServerError) String() string {
return fmt.Sprintf("[DELETE /unaccess][%d] unaccessInternalServerError ", 500)
}
func (o *UnaccessInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}

View File

@ -0,0 +1,53 @@
// Code generated by go-swagger; DO NOT EDIT.
package rest_model_zrok
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// AccessRequest access request
//
// swagger:model accessRequest
type AccessRequest struct {
// svc name
SvcName string `json:"svcName,omitempty"`
// z Id
ZID string `json:"zId,omitempty"`
}
// Validate validates this access request
func (m *AccessRequest) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this access request based on context it is used
func (m *AccessRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *AccessRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *AccessRequest) UnmarshalBinary(b []byte) error {
var res AccessRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -0,0 +1,53 @@
// Code generated by go-swagger; DO NOT EDIT.
package rest_model_zrok
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// UnaccessRequest unaccess request
//
// swagger:model unaccessRequest
type UnaccessRequest struct {
// svc name
SvcName string `json:"svcName,omitempty"`
// z Id
ZID string `json:"zId,omitempty"`
}
// Validate validates this unaccess request
func (m *UnaccessRequest) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this unaccess request based on context it is used
func (m *UnaccessRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *UnaccessRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *UnaccessRequest) UnmarshalBinary(b []byte) error {
var res UnaccessRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -35,6 +35,39 @@ func init() {
},
"basePath": "/api/v1",
"paths": {
"/access": {
"post": {
"security": [
{
"key": []
}
],
"tags": [
"service"
],
"operationId": "access",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/accessRequest"
}
}
],
"responses": {
"201": {
"description": "access created"
},
"401": {
"description": "unauthorized"
},
"500": {
"description": "internal server error"
}
}
}
},
"/account": {
"post": {
"tags": [
@ -275,6 +308,42 @@ func init() {
}
}
},
"/unaccess": {
"delete": {
"security": [
{
"key": []
}
],
"tags": [
"service"
],
"operationId": "unaccess",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/unaccessRequest"
}
}
],
"responses": {
"200": {
"description": "access removed"
},
"401": {
"description": "unauthorized"
},
"404": {
"description": "not found"
},
"500": {
"description": "internal server error"
}
}
}
},
"/unshare": {
"delete": {
"security": [
@ -366,6 +435,17 @@ func init() {
}
},
"definitions": {
"accessRequest": {
"type": "object",
"properties": {
"svcName": {
"type": "string"
},
"zId": {
"type": "string"
}
}
},
"accountRequest": {
"type": "object",
"properties": {
@ -604,6 +684,17 @@ func init() {
}
}
},
"unaccessRequest": {
"type": "object",
"properties": {
"svcName": {
"type": "string"
},
"zId": {
"type": "string"
}
}
},
"unshareRequest": {
"type": "object",
"properties": {
@ -661,6 +752,39 @@ func init() {
},
"basePath": "/api/v1",
"paths": {
"/access": {
"post": {
"security": [
{
"key": []
}
],
"tags": [
"service"
],
"operationId": "access",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/accessRequest"
}
}
],
"responses": {
"201": {
"description": "access created"
},
"401": {
"description": "unauthorized"
},
"500": {
"description": "internal server error"
}
}
}
},
"/account": {
"post": {
"tags": [
@ -901,6 +1025,42 @@ func init() {
}
}
},
"/unaccess": {
"delete": {
"security": [
{
"key": []
}
],
"tags": [
"service"
],
"operationId": "unaccess",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/unaccessRequest"
}
}
],
"responses": {
"200": {
"description": "access removed"
},
"401": {
"description": "unauthorized"
},
"404": {
"description": "not found"
},
"500": {
"description": "internal server error"
}
}
}
},
"/unshare": {
"delete": {
"security": [
@ -992,6 +1152,17 @@ func init() {
}
},
"definitions": {
"accessRequest": {
"type": "object",
"properties": {
"svcName": {
"type": "string"
},
"zId": {
"type": "string"
}
}
},
"accountRequest": {
"type": "object",
"properties": {
@ -1230,6 +1401,17 @@ func init() {
}
}
},
"unaccessRequest": {
"type": "object",
"properties": {
"svcName": {
"type": "string"
},
"zId": {
"type": "string"
}
}
},
"unshareRequest": {
"type": "object",
"properties": {

View File

@ -0,0 +1,71 @@
// Code generated by go-swagger; DO NOT EDIT.
package service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
)
// AccessHandlerFunc turns a function with the right signature into a access handler
type AccessHandlerFunc func(AccessParams, *rest_model_zrok.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn AccessHandlerFunc) Handle(params AccessParams, principal *rest_model_zrok.Principal) middleware.Responder {
return fn(params, principal)
}
// AccessHandler interface for that can handle valid access params
type AccessHandler interface {
Handle(AccessParams, *rest_model_zrok.Principal) middleware.Responder
}
// NewAccess creates a new http.Handler for the access operation
func NewAccess(ctx *middleware.Context, handler AccessHandler) *Access {
return &Access{Context: ctx, Handler: handler}
}
/*
Access swagger:route POST /access service access
Access access API
*/
type Access struct {
Context *middleware.Context
Handler AccessHandler
}
func (o *Access) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewAccessParams()
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)
}

View File

@ -0,0 +1,76 @@
// Code generated by go-swagger; DO NOT EDIT.
package service
// 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"
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
)
// NewAccessParams creates a new AccessParams object
//
// There are no default values defined in the spec.
func NewAccessParams() AccessParams {
return AccessParams{}
}
// AccessParams contains all the bound params for the access operation
// typically these are obtained from a http.Request
//
// swagger:parameters access
type AccessParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
In: body
*/
Body *rest_model_zrok.AccessRequest
}
// 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 NewAccessParams() beforehand.
func (o *AccessParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if runtime.HasBody(r) {
defer r.Body.Close()
var body rest_model_zrok.AccessRequest
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
}

View File

@ -0,0 +1,87 @@
// Code generated by go-swagger; DO NOT EDIT.
package service
// 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"
)
// AccessCreatedCode is the HTTP code returned for type AccessCreated
const AccessCreatedCode int = 201
/*
AccessCreated access created
swagger:response accessCreated
*/
type AccessCreated struct {
}
// NewAccessCreated creates AccessCreated with default headers values
func NewAccessCreated() *AccessCreated {
return &AccessCreated{}
}
// WriteResponse to the client
func (o *AccessCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(201)
}
// AccessUnauthorizedCode is the HTTP code returned for type AccessUnauthorized
const AccessUnauthorizedCode int = 401
/*
AccessUnauthorized unauthorized
swagger:response accessUnauthorized
*/
type AccessUnauthorized struct {
}
// NewAccessUnauthorized creates AccessUnauthorized with default headers values
func NewAccessUnauthorized() *AccessUnauthorized {
return &AccessUnauthorized{}
}
// WriteResponse to the client
func (o *AccessUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(401)
}
// AccessInternalServerErrorCode is the HTTP code returned for type AccessInternalServerError
const AccessInternalServerErrorCode int = 500
/*
AccessInternalServerError internal server error
swagger:response accessInternalServerError
*/
type AccessInternalServerError struct {
}
// NewAccessInternalServerError creates AccessInternalServerError with default headers values
func NewAccessInternalServerError() *AccessInternalServerError {
return &AccessInternalServerError{}
}
// WriteResponse to the client
func (o *AccessInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(500)
}

View File

@ -0,0 +1,87 @@
// Code generated by go-swagger; DO NOT EDIT.
package service
// 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"
)
// AccessURL generates an URL for the access operation
type AccessURL 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 *AccessURL) WithBasePath(bp string) *AccessURL {
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 *AccessURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *AccessURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/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 *AccessURL) 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 *AccessURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *AccessURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on AccessURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on AccessURL")
}
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 *AccessURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@ -0,0 +1,71 @@
// Code generated by go-swagger; DO NOT EDIT.
package service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
)
// UnaccessHandlerFunc turns a function with the right signature into a unaccess handler
type UnaccessHandlerFunc func(UnaccessParams, *rest_model_zrok.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn UnaccessHandlerFunc) Handle(params UnaccessParams, principal *rest_model_zrok.Principal) middleware.Responder {
return fn(params, principal)
}
// UnaccessHandler interface for that can handle valid unaccess params
type UnaccessHandler interface {
Handle(UnaccessParams, *rest_model_zrok.Principal) middleware.Responder
}
// NewUnaccess creates a new http.Handler for the unaccess operation
func NewUnaccess(ctx *middleware.Context, handler UnaccessHandler) *Unaccess {
return &Unaccess{Context: ctx, Handler: handler}
}
/*
Unaccess swagger:route DELETE /unaccess service unaccess
Unaccess unaccess API
*/
type Unaccess struct {
Context *middleware.Context
Handler UnaccessHandler
}
func (o *Unaccess) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewUnaccessParams()
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)
}

View File

@ -0,0 +1,76 @@
// Code generated by go-swagger; DO NOT EDIT.
package service
// 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"
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
)
// NewUnaccessParams creates a new UnaccessParams object
//
// There are no default values defined in the spec.
func NewUnaccessParams() UnaccessParams {
return UnaccessParams{}
}
// UnaccessParams contains all the bound params for the unaccess operation
// typically these are obtained from a http.Request
//
// swagger:parameters unaccess
type UnaccessParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
In: body
*/
Body *rest_model_zrok.UnaccessRequest
}
// 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 NewUnaccessParams() beforehand.
func (o *UnaccessParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if runtime.HasBody(r) {
defer r.Body.Close()
var body rest_model_zrok.UnaccessRequest
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
}

View File

@ -0,0 +1,112 @@
// Code generated by go-swagger; DO NOT EDIT.
package service
// 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"
)
// UnaccessOKCode is the HTTP code returned for type UnaccessOK
const UnaccessOKCode int = 200
/*
UnaccessOK access removed
swagger:response unaccessOK
*/
type UnaccessOK struct {
}
// NewUnaccessOK creates UnaccessOK with default headers values
func NewUnaccessOK() *UnaccessOK {
return &UnaccessOK{}
}
// WriteResponse to the client
func (o *UnaccessOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(200)
}
// UnaccessUnauthorizedCode is the HTTP code returned for type UnaccessUnauthorized
const UnaccessUnauthorizedCode int = 401
/*
UnaccessUnauthorized unauthorized
swagger:response unaccessUnauthorized
*/
type UnaccessUnauthorized struct {
}
// NewUnaccessUnauthorized creates UnaccessUnauthorized with default headers values
func NewUnaccessUnauthorized() *UnaccessUnauthorized {
return &UnaccessUnauthorized{}
}
// WriteResponse to the client
func (o *UnaccessUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(401)
}
// UnaccessNotFoundCode is the HTTP code returned for type UnaccessNotFound
const UnaccessNotFoundCode int = 404
/*
UnaccessNotFound not found
swagger:response unaccessNotFound
*/
type UnaccessNotFound struct {
}
// NewUnaccessNotFound creates UnaccessNotFound with default headers values
func NewUnaccessNotFound() *UnaccessNotFound {
return &UnaccessNotFound{}
}
// WriteResponse to the client
func (o *UnaccessNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(404)
}
// UnaccessInternalServerErrorCode is the HTTP code returned for type UnaccessInternalServerError
const UnaccessInternalServerErrorCode int = 500
/*
UnaccessInternalServerError internal server error
swagger:response unaccessInternalServerError
*/
type UnaccessInternalServerError struct {
}
// NewUnaccessInternalServerError creates UnaccessInternalServerError with default headers values
func NewUnaccessInternalServerError() *UnaccessInternalServerError {
return &UnaccessInternalServerError{}
}
// WriteResponse to the client
func (o *UnaccessInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(500)
}

View File

@ -0,0 +1,87 @@
// Code generated by go-swagger; DO NOT EDIT.
package service
// 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"
)
// UnaccessURL generates an URL for the unaccess operation
type UnaccessURL 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 *UnaccessURL) WithBasePath(bp string) *UnaccessURL {
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 *UnaccessURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *UnaccessURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/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 *UnaccessURL) 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 *UnaccessURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *UnaccessURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on UnaccessURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on UnaccessURL")
}
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 *UnaccessURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@ -47,6 +47,9 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
JSONProducer: runtime.JSONProducer(),
ServiceAccessHandler: service.AccessHandlerFunc(func(params service.AccessParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation service.Access has not yet been implemented")
}),
IdentityCreateAccountHandler: identity.CreateAccountHandlerFunc(func(params identity.CreateAccountParams) middleware.Responder {
return middleware.NotImplemented("operation identity.CreateAccount has not yet been implemented")
}),
@ -68,6 +71,9 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
ServiceShareHandler: service.ShareHandlerFunc(func(params service.ShareParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation service.Share has not yet been implemented")
}),
ServiceUnaccessHandler: service.UnaccessHandlerFunc(func(params service.UnaccessParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation service.Unaccess has not yet been implemented")
}),
ServiceUnshareHandler: service.UnshareHandlerFunc(func(params service.UnshareParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation service.Unshare has not yet been implemented")
}),
@ -127,6 +133,8 @@ type ZrokAPI struct {
// APIAuthorizer provides access control (ACL/RBAC/ABAC) by providing access to the request and authenticated principal
APIAuthorizer runtime.Authorizer
// ServiceAccessHandler sets the operation handler for the access operation
ServiceAccessHandler service.AccessHandler
// IdentityCreateAccountHandler sets the operation handler for the create account operation
IdentityCreateAccountHandler identity.CreateAccountHandler
// IdentityDisableHandler sets the operation handler for the disable operation
@ -141,6 +149,8 @@ type ZrokAPI struct {
IdentityRegisterHandler identity.RegisterHandler
// ServiceShareHandler sets the operation handler for the share operation
ServiceShareHandler service.ShareHandler
// ServiceUnaccessHandler sets the operation handler for the unaccess operation
ServiceUnaccessHandler service.UnaccessHandler
// ServiceUnshareHandler sets the operation handler for the unshare operation
ServiceUnshareHandler service.UnshareHandler
// IdentityVerifyHandler sets the operation handler for the verify operation
@ -228,6 +238,9 @@ func (o *ZrokAPI) Validate() error {
unregistered = append(unregistered, "XTokenAuth")
}
if o.ServiceAccessHandler == nil {
unregistered = append(unregistered, "service.AccessHandler")
}
if o.IdentityCreateAccountHandler == nil {
unregistered = append(unregistered, "identity.CreateAccountHandler")
}
@ -249,6 +262,9 @@ func (o *ZrokAPI) Validate() error {
if o.ServiceShareHandler == nil {
unregistered = append(unregistered, "service.ShareHandler")
}
if o.ServiceUnaccessHandler == nil {
unregistered = append(unregistered, "service.UnaccessHandler")
}
if o.ServiceUnshareHandler == nil {
unregistered = append(unregistered, "service.UnshareHandler")
}
@ -357,6 +373,10 @@ func (o *ZrokAPI) initHandlerCache() {
o.handlers = make(map[string]map[string]http.Handler)
}
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/access"] = service.NewAccess(o.context, o.ServiceAccessHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
@ -388,6 +408,10 @@ func (o *ZrokAPI) initHandlerCache() {
if o.handlers["DELETE"] == nil {
o.handlers["DELETE"] = make(map[string]http.Handler)
}
o.handlers["DELETE"]["/unaccess"] = service.NewUnaccess(o.context, o.ServiceUnaccessHandler)
if o.handlers["DELETE"] == nil {
o.handlers["DELETE"] = make(map[string]http.Handler)
}
o.handlers["DELETE"]["/unshare"] = service.NewUnshare(o.context, o.ServiceUnshareHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)

View File

@ -179,6 +179,48 @@ paths:
#
# service
#
/access:
post:
tags:
- service
security:
- key: []
operationId: access
parameters:
- name: body
in: body
schema:
$ref: "#/definitions/accessRequest"
responses:
201:
description: access created
401:
description: unauthorized
500:
description: internal server error
/unaccess:
delete:
tags:
- service
security:
- key: []
operationId: unaccess
parameters:
- name: body
in: body
schema:
$ref: "#/definitions/unaccessRequest"
responses:
200:
description: access removed
401:
description: unauthorized
404:
description: not found
500:
description: internal server error
/share:
post:
tags:
@ -202,6 +244,7 @@ paths:
description: internal server error
schema:
$ref: "#/definitions/errorMessage"
/unshare:
delete:
tags:
@ -227,6 +270,14 @@ paths:
$ref: "#/definitions/errorMessage"
definitions:
accessRequest:
type: object
properties:
zId:
type: string
svcName:
type: string
accountRequest:
type: object
properties:
@ -390,6 +441,14 @@ definitions:
svcName:
type: string
unaccessRequest:
type: object
properties:
zId:
type: string
svcName:
type: string
unshareRequest:
type: object
properties:

View File

@ -2,6 +2,36 @@
// Auto-generated, edits will be overwritten
import * as gateway from './gateway'
/**
* @param {object} options Optional options
* @param {module:types.accessRequest} [options.body]
* @return {Promise<object>} access created
*/
export function access(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(accessOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.unaccessRequest} [options.body]
* @return {Promise<object>} access removed
*/
export function unaccess(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(unaccessOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.shareRequest} [options.body]
@ -32,6 +62,28 @@ export function unshare(options) {
return gateway.request(unshareOperation, parameters)
}
const accessOperation = {
path: '/access',
contentTypes: ['application/zrok.v1+json'],
method: 'post',
security: [
{
id: 'key'
}
]
}
const unaccessOperation = {
path: '/unaccess',
contentTypes: ['application/zrok.v1+json'],
method: 'delete',
security: [
{
id: 'key'
}
]
}
const shareOperation = {
path: '/share',
contentTypes: ['application/zrok.v1+json'],

View File

@ -1,6 +1,14 @@
/** @module types */
// Auto-generated, edits will be overwritten
/**
* @typedef accessRequest
* @memberof module:types
*
* @property {string} zId
* @property {string} svcName
*/
/**
* @typedef accountRequest
* @memberof module:types
@ -126,6 +134,14 @@
* @property {string} svcName
*/
/**
* @typedef unaccessRequest
* @memberof module:types
*
* @property {string} zId
* @property {string} svcName
*/
/**
* @typedef unshareRequest
* @memberof module:types