From ac95ebd2f79a024f821984ceafbad6de0f69d03a Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Fri, 27 Jun 2025 12:33:18 -0400 Subject: [PATCH 1/4] '/overview/public-frontends' and generated stubs (#996) --- ...public_frontends_for_account_parameters.go | 128 +++++++++ ..._public_frontends_for_account_responses.go | 268 ++++++++++++++++++ rest_client_zrok/metadata/metadata_client.go | 41 +++ rest_server_zrok/embedded_spec.go | 68 +++++ .../list_public_frontends_for_account.go | 114 ++++++++ ...public_frontends_for_account_parameters.go | 46 +++ ..._public_frontends_for_account_responses.go | 107 +++++++ ...public_frontends_for_account_urlbuilder.go | 87 ++++++ rest_server_zrok/operations/zrok_api.go | 12 + .../sdk/src/api/.openapi-generator/FILES | 1 + sdk/nodejs/sdk/src/api/apis/MetadataApi.ts | 31 ++ ...istPublicFrontendsForAccount200Response.ts | 73 +++++ sdk/nodejs/sdk/src/api/models/index.ts | 1 + sdk/python/src/.openapi-generator/FILES | 3 + sdk/python/src/README.md | 2 + ...istPublicFrontendsForAccount200Response.md | 30 ++ sdk/python/src/docs/MetadataApi.md | 73 +++++ ...ublic_frontends_for_account200_response.py | 52 ++++ sdk/python/src/test/test_metadata_api.py | 6 + sdk/python/src/zrok_api/__init__.py | 1 + sdk/python/src/zrok_api/api/metadata_api.py | 250 ++++++++++++++++ sdk/python/src/zrok_api/models/__init__.py | 1 + ...ublic_frontends_for_account200_response.py | 89 ++++++ specs/zrok.yml | 21 ++ ui/src/api/.openapi-generator/FILES | 1 + ui/src/api/apis/MetadataApi.ts | 31 ++ ...istPublicFrontendsForAccount200Response.ts | 73 +++++ ui/src/api/models/index.ts | 1 + 28 files changed, 1611 insertions(+) create mode 100644 rest_client_zrok/metadata/list_public_frontends_for_account_parameters.go create mode 100644 rest_client_zrok/metadata/list_public_frontends_for_account_responses.go create mode 100644 rest_server_zrok/operations/metadata/list_public_frontends_for_account.go create mode 100644 rest_server_zrok/operations/metadata/list_public_frontends_for_account_parameters.go create mode 100644 rest_server_zrok/operations/metadata/list_public_frontends_for_account_responses.go create mode 100644 rest_server_zrok/operations/metadata/list_public_frontends_for_account_urlbuilder.go create mode 100644 sdk/nodejs/sdk/src/api/models/ListPublicFrontendsForAccount200Response.ts create mode 100644 sdk/python/src/docs/ListPublicFrontendsForAccount200Response.md create mode 100644 sdk/python/src/test/test_list_public_frontends_for_account200_response.py create mode 100644 sdk/python/src/zrok_api/models/list_public_frontends_for_account200_response.py create mode 100644 ui/src/api/models/ListPublicFrontendsForAccount200Response.ts diff --git a/rest_client_zrok/metadata/list_public_frontends_for_account_parameters.go b/rest_client_zrok/metadata/list_public_frontends_for_account_parameters.go new file mode 100644 index 00000000..93d28cff --- /dev/null +++ b/rest_client_zrok/metadata/list_public_frontends_for_account_parameters.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewListPublicFrontendsForAccountParams creates a new ListPublicFrontendsForAccountParams 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 NewListPublicFrontendsForAccountParams() *ListPublicFrontendsForAccountParams { + return &ListPublicFrontendsForAccountParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListPublicFrontendsForAccountParamsWithTimeout creates a new ListPublicFrontendsForAccountParams object +// with the ability to set a timeout on a request. +func NewListPublicFrontendsForAccountParamsWithTimeout(timeout time.Duration) *ListPublicFrontendsForAccountParams { + return &ListPublicFrontendsForAccountParams{ + timeout: timeout, + } +} + +// NewListPublicFrontendsForAccountParamsWithContext creates a new ListPublicFrontendsForAccountParams object +// with the ability to set a context for a request. +func NewListPublicFrontendsForAccountParamsWithContext(ctx context.Context) *ListPublicFrontendsForAccountParams { + return &ListPublicFrontendsForAccountParams{ + Context: ctx, + } +} + +// NewListPublicFrontendsForAccountParamsWithHTTPClient creates a new ListPublicFrontendsForAccountParams object +// with the ability to set a custom HTTPClient for a request. +func NewListPublicFrontendsForAccountParamsWithHTTPClient(client *http.Client) *ListPublicFrontendsForAccountParams { + return &ListPublicFrontendsForAccountParams{ + HTTPClient: client, + } +} + +/* +ListPublicFrontendsForAccountParams contains all the parameters to send to the API endpoint + + for the list public frontends for account operation. + + Typically these are written to a http.Request. +*/ +type ListPublicFrontendsForAccountParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the list public frontends for account params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListPublicFrontendsForAccountParams) WithDefaults() *ListPublicFrontendsForAccountParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list public frontends for account params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListPublicFrontendsForAccountParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the list public frontends for account params +func (o *ListPublicFrontendsForAccountParams) WithTimeout(timeout time.Duration) *ListPublicFrontendsForAccountParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list public frontends for account params +func (o *ListPublicFrontendsForAccountParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list public frontends for account params +func (o *ListPublicFrontendsForAccountParams) WithContext(ctx context.Context) *ListPublicFrontendsForAccountParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list public frontends for account params +func (o *ListPublicFrontendsForAccountParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list public frontends for account params +func (o *ListPublicFrontendsForAccountParams) WithHTTPClient(client *http.Client) *ListPublicFrontendsForAccountParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list public frontends for account params +func (o *ListPublicFrontendsForAccountParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ListPublicFrontendsForAccountParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client_zrok/metadata/list_public_frontends_for_account_responses.go b/rest_client_zrok/metadata/list_public_frontends_for_account_responses.go new file mode 100644 index 00000000..d52c30b0 --- /dev/null +++ b/rest_client_zrok/metadata/list_public_frontends_for_account_responses.go @@ -0,0 +1,268 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ListPublicFrontendsForAccountReader is a Reader for the ListPublicFrontendsForAccount structure. +type ListPublicFrontendsForAccountReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListPublicFrontendsForAccountReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListPublicFrontendsForAccountOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewListPublicFrontendsForAccountUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewListPublicFrontendsForAccountInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /overview/public-frontends] listPublicFrontendsForAccount", response, response.Code()) + } +} + +// NewListPublicFrontendsForAccountOK creates a ListPublicFrontendsForAccountOK with default headers values +func NewListPublicFrontendsForAccountOK() *ListPublicFrontendsForAccountOK { + return &ListPublicFrontendsForAccountOK{} +} + +/* +ListPublicFrontendsForAccountOK describes a response with status code 200, with default header values. + +public frontends list returned +*/ +type ListPublicFrontendsForAccountOK struct { + Payload *ListPublicFrontendsForAccountOKBody +} + +// IsSuccess returns true when this list public frontends for account o k response has a 2xx status code +func (o *ListPublicFrontendsForAccountOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list public frontends for account o k response has a 3xx status code +func (o *ListPublicFrontendsForAccountOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list public frontends for account o k response has a 4xx status code +func (o *ListPublicFrontendsForAccountOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list public frontends for account o k response has a 5xx status code +func (o *ListPublicFrontendsForAccountOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list public frontends for account o k response a status code equal to that given +func (o *ListPublicFrontendsForAccountOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list public frontends for account o k response +func (o *ListPublicFrontendsForAccountOK) Code() int { + return 200 +} + +func (o *ListPublicFrontendsForAccountOK) Error() string { + return fmt.Sprintf("[GET /overview/public-frontends][%d] listPublicFrontendsForAccountOK %+v", 200, o.Payload) +} + +func (o *ListPublicFrontendsForAccountOK) String() string { + return fmt.Sprintf("[GET /overview/public-frontends][%d] listPublicFrontendsForAccountOK %+v", 200, o.Payload) +} + +func (o *ListPublicFrontendsForAccountOK) GetPayload() *ListPublicFrontendsForAccountOKBody { + return o.Payload +} + +func (o *ListPublicFrontendsForAccountOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(ListPublicFrontendsForAccountOKBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListPublicFrontendsForAccountUnauthorized creates a ListPublicFrontendsForAccountUnauthorized with default headers values +func NewListPublicFrontendsForAccountUnauthorized() *ListPublicFrontendsForAccountUnauthorized { + return &ListPublicFrontendsForAccountUnauthorized{} +} + +/* +ListPublicFrontendsForAccountUnauthorized describes a response with status code 401, with default header values. + +unauthorized +*/ +type ListPublicFrontendsForAccountUnauthorized struct { +} + +// IsSuccess returns true when this list public frontends for account unauthorized response has a 2xx status code +func (o *ListPublicFrontendsForAccountUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list public frontends for account unauthorized response has a 3xx status code +func (o *ListPublicFrontendsForAccountUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list public frontends for account unauthorized response has a 4xx status code +func (o *ListPublicFrontendsForAccountUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this list public frontends for account unauthorized response has a 5xx status code +func (o *ListPublicFrontendsForAccountUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this list public frontends for account unauthorized response a status code equal to that given +func (o *ListPublicFrontendsForAccountUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the list public frontends for account unauthorized response +func (o *ListPublicFrontendsForAccountUnauthorized) Code() int { + return 401 +} + +func (o *ListPublicFrontendsForAccountUnauthorized) Error() string { + return fmt.Sprintf("[GET /overview/public-frontends][%d] listPublicFrontendsForAccountUnauthorized ", 401) +} + +func (o *ListPublicFrontendsForAccountUnauthorized) String() string { + return fmt.Sprintf("[GET /overview/public-frontends][%d] listPublicFrontendsForAccountUnauthorized ", 401) +} + +func (o *ListPublicFrontendsForAccountUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewListPublicFrontendsForAccountInternalServerError creates a ListPublicFrontendsForAccountInternalServerError with default headers values +func NewListPublicFrontendsForAccountInternalServerError() *ListPublicFrontendsForAccountInternalServerError { + return &ListPublicFrontendsForAccountInternalServerError{} +} + +/* +ListPublicFrontendsForAccountInternalServerError describes a response with status code 500, with default header values. + +internal server error +*/ +type ListPublicFrontendsForAccountInternalServerError struct { +} + +// IsSuccess returns true when this list public frontends for account internal server error response has a 2xx status code +func (o *ListPublicFrontendsForAccountInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this list public frontends for account internal server error response has a 3xx status code +func (o *ListPublicFrontendsForAccountInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list public frontends for account internal server error response has a 4xx status code +func (o *ListPublicFrontendsForAccountInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this list public frontends for account internal server error response has a 5xx status code +func (o *ListPublicFrontendsForAccountInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this list public frontends for account internal server error response a status code equal to that given +func (o *ListPublicFrontendsForAccountInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the list public frontends for account internal server error response +func (o *ListPublicFrontendsForAccountInternalServerError) Code() int { + return 500 +} + +func (o *ListPublicFrontendsForAccountInternalServerError) Error() string { + return fmt.Sprintf("[GET /overview/public-frontends][%d] listPublicFrontendsForAccountInternalServerError ", 500) +} + +func (o *ListPublicFrontendsForAccountInternalServerError) String() string { + return fmt.Sprintf("[GET /overview/public-frontends][%d] listPublicFrontendsForAccountInternalServerError ", 500) +} + +func (o *ListPublicFrontendsForAccountInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +/* +ListPublicFrontendsForAccountOKBody list public frontends for account o k body +swagger:model ListPublicFrontendsForAccountOKBody +*/ +type ListPublicFrontendsForAccountOKBody struct { + + // public name + PublicName string `json:"publicName,omitempty"` + + // url template + URLTemplate string `json:"urlTemplate,omitempty"` +} + +// Validate validates this list public frontends for account o k body +func (o *ListPublicFrontendsForAccountOKBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this list public frontends for account o k body based on context it is used +func (o *ListPublicFrontendsForAccountOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *ListPublicFrontendsForAccountOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *ListPublicFrontendsForAccountOKBody) UnmarshalBinary(b []byte) error { + var res ListPublicFrontendsForAccountOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/rest_client_zrok/metadata/metadata_client.go b/rest_client_zrok/metadata/metadata_client.go index 4682edbb..974bb925 100644 --- a/rest_client_zrok/metadata/metadata_client.go +++ b/rest_client_zrok/metadata/metadata_client.go @@ -54,6 +54,8 @@ type ClientService interface { ListOrgMembers(params *ListOrgMembersParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListOrgMembersOK, error) + ListPublicFrontendsForAccount(params *ListPublicFrontendsForAccountParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListPublicFrontendsForAccountOK, error) + OrgAccountOverview(params *OrgAccountOverviewParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*OrgAccountOverviewOK, error) Overview(params *OverviewParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*OverviewOK, error) @@ -531,6 +533,45 @@ func (a *Client) ListOrgMembers(params *ListOrgMembersParams, authInfo runtime.C panic(msg) } +/* +ListPublicFrontendsForAccount list public frontends for account API +*/ +func (a *Client) ListPublicFrontendsForAccount(params *ListPublicFrontendsForAccountParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListPublicFrontendsForAccountOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListPublicFrontendsForAccountParams() + } + op := &runtime.ClientOperation{ + ID: "listPublicFrontendsForAccount", + Method: "GET", + PathPattern: "/overview/public-frontends", + ProducesMediaTypes: []string{"application/zrok.v1+json"}, + ConsumesMediaTypes: []string{"application/zrok.v1+json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ListPublicFrontendsForAccountReader{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.(*ListPublicFrontendsForAccountOK) + 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 listPublicFrontendsForAccount: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* OrgAccountOverview org account overview API */ diff --git a/rest_server_zrok/embedded_spec.go b/rest_server_zrok/embedded_spec.go index af6e8cbb..a9893e35 100644 --- a/rest_server_zrok/embedded_spec.go +++ b/rest_server_zrok/embedded_spec.go @@ -2067,6 +2067,40 @@ func init() { } } }, + "/overview/public-frontends": { + "get": { + "security": [ + { + "key": [] + } + ], + "tags": [ + "metadata" + ], + "operationId": "listPublicFrontendsForAccount", + "responses": { + "200": { + "description": "public frontends list returned", + "schema": { + "properties": { + "publicName": { + "type": "string" + }, + "urlTemplate": { + "type": "string" + } + } + } + }, + "401": { + "description": "unauthorized" + }, + "500": { + "description": "internal server error" + } + } + } + }, "/overview/{organizationToken}/{accountEmail}": { "get": { "security": [ @@ -4927,6 +4961,40 @@ func init() { } } }, + "/overview/public-frontends": { + "get": { + "security": [ + { + "key": [] + } + ], + "tags": [ + "metadata" + ], + "operationId": "listPublicFrontendsForAccount", + "responses": { + "200": { + "description": "public frontends list returned", + "schema": { + "properties": { + "publicName": { + "type": "string" + }, + "urlTemplate": { + "type": "string" + } + } + } + }, + "401": { + "description": "unauthorized" + }, + "500": { + "description": "internal server error" + } + } + } + }, "/overview/{organizationToken}/{accountEmail}": { "get": { "security": [ diff --git a/rest_server_zrok/operations/metadata/list_public_frontends_for_account.go b/rest_server_zrok/operations/metadata/list_public_frontends_for_account.go new file mode 100644 index 00000000..a70c351b --- /dev/null +++ b/rest_server_zrok/operations/metadata/list_public_frontends_for_account.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the 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" +) + +// ListPublicFrontendsForAccountHandlerFunc turns a function with the right signature into a list public frontends for account handler +type ListPublicFrontendsForAccountHandlerFunc func(ListPublicFrontendsForAccountParams, *rest_model_zrok.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn ListPublicFrontendsForAccountHandlerFunc) Handle(params ListPublicFrontendsForAccountParams, principal *rest_model_zrok.Principal) middleware.Responder { + return fn(params, principal) +} + +// ListPublicFrontendsForAccountHandler interface for that can handle valid list public frontends for account params +type ListPublicFrontendsForAccountHandler interface { + Handle(ListPublicFrontendsForAccountParams, *rest_model_zrok.Principal) middleware.Responder +} + +// NewListPublicFrontendsForAccount creates a new http.Handler for the list public frontends for account operation +func NewListPublicFrontendsForAccount(ctx *middleware.Context, handler ListPublicFrontendsForAccountHandler) *ListPublicFrontendsForAccount { + return &ListPublicFrontendsForAccount{Context: ctx, Handler: handler} +} + +/* + ListPublicFrontendsForAccount swagger:route GET /overview/public-frontends metadata listPublicFrontendsForAccount + +ListPublicFrontendsForAccount list public frontends for account API +*/ +type ListPublicFrontendsForAccount struct { + Context *middleware.Context + Handler ListPublicFrontendsForAccountHandler +} + +func (o *ListPublicFrontendsForAccount) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewListPublicFrontendsForAccountParams() + 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) + +} + +// ListPublicFrontendsForAccountOKBody list public frontends for account o k body +// +// swagger:model ListPublicFrontendsForAccountOKBody +type ListPublicFrontendsForAccountOKBody struct { + + // public name + PublicName string `json:"publicName,omitempty"` + + // url template + URLTemplate string `json:"urlTemplate,omitempty"` +} + +// Validate validates this list public frontends for account o k body +func (o *ListPublicFrontendsForAccountOKBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this list public frontends for account o k body based on context it is used +func (o *ListPublicFrontendsForAccountOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *ListPublicFrontendsForAccountOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *ListPublicFrontendsForAccountOKBody) UnmarshalBinary(b []byte) error { + var res ListPublicFrontendsForAccountOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/rest_server_zrok/operations/metadata/list_public_frontends_for_account_parameters.go b/rest_server_zrok/operations/metadata/list_public_frontends_for_account_parameters.go new file mode 100644 index 00000000..92893ee9 --- /dev/null +++ b/rest_server_zrok/operations/metadata/list_public_frontends_for_account_parameters.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewListPublicFrontendsForAccountParams creates a new ListPublicFrontendsForAccountParams object +// +// There are no default values defined in the spec. +func NewListPublicFrontendsForAccountParams() ListPublicFrontendsForAccountParams { + + return ListPublicFrontendsForAccountParams{} +} + +// ListPublicFrontendsForAccountParams contains all the bound params for the list public frontends for account operation +// typically these are obtained from a http.Request +// +// swagger:parameters listPublicFrontendsForAccount +type ListPublicFrontendsForAccountParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// 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 NewListPublicFrontendsForAccountParams() beforehand. +func (o *ListPublicFrontendsForAccountParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_server_zrok/operations/metadata/list_public_frontends_for_account_responses.go b/rest_server_zrok/operations/metadata/list_public_frontends_for_account_responses.go new file mode 100644 index 00000000..af0f147f --- /dev/null +++ b/rest_server_zrok/operations/metadata/list_public_frontends_for_account_responses.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" +) + +// ListPublicFrontendsForAccountOKCode is the HTTP code returned for type ListPublicFrontendsForAccountOK +const ListPublicFrontendsForAccountOKCode int = 200 + +/* +ListPublicFrontendsForAccountOK public frontends list returned + +swagger:response listPublicFrontendsForAccountOK +*/ +type ListPublicFrontendsForAccountOK struct { + + /* + In: Body + */ + Payload *ListPublicFrontendsForAccountOKBody `json:"body,omitempty"` +} + +// NewListPublicFrontendsForAccountOK creates ListPublicFrontendsForAccountOK with default headers values +func NewListPublicFrontendsForAccountOK() *ListPublicFrontendsForAccountOK { + + return &ListPublicFrontendsForAccountOK{} +} + +// WithPayload adds the payload to the list public frontends for account o k response +func (o *ListPublicFrontendsForAccountOK) WithPayload(payload *ListPublicFrontendsForAccountOKBody) *ListPublicFrontendsForAccountOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list public frontends for account o k response +func (o *ListPublicFrontendsForAccountOK) SetPayload(payload *ListPublicFrontendsForAccountOKBody) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListPublicFrontendsForAccountOK) 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 + } + } +} + +// ListPublicFrontendsForAccountUnauthorizedCode is the HTTP code returned for type ListPublicFrontendsForAccountUnauthorized +const ListPublicFrontendsForAccountUnauthorizedCode int = 401 + +/* +ListPublicFrontendsForAccountUnauthorized unauthorized + +swagger:response listPublicFrontendsForAccountUnauthorized +*/ +type ListPublicFrontendsForAccountUnauthorized struct { +} + +// NewListPublicFrontendsForAccountUnauthorized creates ListPublicFrontendsForAccountUnauthorized with default headers values +func NewListPublicFrontendsForAccountUnauthorized() *ListPublicFrontendsForAccountUnauthorized { + + return &ListPublicFrontendsForAccountUnauthorized{} +} + +// WriteResponse to the client +func (o *ListPublicFrontendsForAccountUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(401) +} + +// ListPublicFrontendsForAccountInternalServerErrorCode is the HTTP code returned for type ListPublicFrontendsForAccountInternalServerError +const ListPublicFrontendsForAccountInternalServerErrorCode int = 500 + +/* +ListPublicFrontendsForAccountInternalServerError internal server error + +swagger:response listPublicFrontendsForAccountInternalServerError +*/ +type ListPublicFrontendsForAccountInternalServerError struct { +} + +// NewListPublicFrontendsForAccountInternalServerError creates ListPublicFrontendsForAccountInternalServerError with default headers values +func NewListPublicFrontendsForAccountInternalServerError() *ListPublicFrontendsForAccountInternalServerError { + + return &ListPublicFrontendsForAccountInternalServerError{} +} + +// WriteResponse to the client +func (o *ListPublicFrontendsForAccountInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/rest_server_zrok/operations/metadata/list_public_frontends_for_account_urlbuilder.go b/rest_server_zrok/operations/metadata/list_public_frontends_for_account_urlbuilder.go new file mode 100644 index 00000000..2750e002 --- /dev/null +++ b/rest_server_zrok/operations/metadata/list_public_frontends_for_account_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// ListPublicFrontendsForAccountURL generates an URL for the list public frontends for account operation +type ListPublicFrontendsForAccountURL 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 *ListPublicFrontendsForAccountURL) WithBasePath(bp string) *ListPublicFrontendsForAccountURL { + 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 *ListPublicFrontendsForAccountURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ListPublicFrontendsForAccountURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/overview/public-frontends" + + _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 *ListPublicFrontendsForAccountURL) 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 *ListPublicFrontendsForAccountURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ListPublicFrontendsForAccountURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ListPublicFrontendsForAccountURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ListPublicFrontendsForAccountURL") + } + + 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 *ListPublicFrontendsForAccountURL) 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 31f6345b..a60e41ef 100644 --- a/rest_server_zrok/operations/zrok_api.go +++ b/rest_server_zrok/operations/zrok_api.go @@ -149,6 +149,9 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI { AdminListOrganizationsHandler: admin.ListOrganizationsHandlerFunc(func(params admin.ListOrganizationsParams, principal *rest_model_zrok.Principal) middleware.Responder { return middleware.NotImplemented("operation admin.ListOrganizations has not yet been implemented") }), + MetadataListPublicFrontendsForAccountHandler: metadata.ListPublicFrontendsForAccountHandlerFunc(func(params metadata.ListPublicFrontendsForAccountParams, principal *rest_model_zrok.Principal) middleware.Responder { + return middleware.NotImplemented("operation metadata.ListPublicFrontendsForAccount has not yet been implemented") + }), AccountLoginHandler: account.LoginHandlerFunc(func(params account.LoginParams) middleware.Responder { return middleware.NotImplemented("operation account.Login has not yet been implemented") }), @@ -337,6 +340,8 @@ type ZrokAPI struct { AdminListOrganizationMembersHandler admin.ListOrganizationMembersHandler // AdminListOrganizationsHandler sets the operation handler for the list organizations operation AdminListOrganizationsHandler admin.ListOrganizationsHandler + // MetadataListPublicFrontendsForAccountHandler sets the operation handler for the list public frontends for account operation + MetadataListPublicFrontendsForAccountHandler metadata.ListPublicFrontendsForAccountHandler // AccountLoginHandler sets the operation handler for the login operation AccountLoginHandler account.LoginHandler // MetadataOrgAccountOverviewHandler sets the operation handler for the org account overview operation @@ -565,6 +570,9 @@ func (o *ZrokAPI) Validate() error { if o.AdminListOrganizationsHandler == nil { unregistered = append(unregistered, "admin.ListOrganizationsHandler") } + if o.MetadataListPublicFrontendsForAccountHandler == nil { + unregistered = append(unregistered, "metadata.ListPublicFrontendsForAccountHandler") + } if o.AccountLoginHandler == nil { unregistered = append(unregistered, "account.LoginHandler") } @@ -868,6 +876,10 @@ func (o *ZrokAPI) initHandlerCache() { o.handlers["GET"] = make(map[string]http.Handler) } o.handlers["GET"]["/organizations"] = admin.NewListOrganizations(o.context, o.AdminListOrganizationsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/overview/public-frontends"] = metadata.NewListPublicFrontendsForAccount(o.context, o.MetadataListPublicFrontendsForAccountHandler) 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 ddecf8da..4507e585 100644 --- a/sdk/nodejs/sdk/src/api/.openapi-generator/FILES +++ b/sdk/nodejs/sdk/src/api/.openapi-generator/FILES @@ -38,6 +38,7 @@ models/ListOrganizationMembers200Response.ts models/ListOrganizationMembers200ResponseMembersInner.ts models/ListOrganizations200Response.ts models/ListOrganizations200ResponseOrganizationsInner.ts +models/ListPublicFrontendsForAccount200Response.ts models/LoginRequest.ts models/Metrics.ts models/MetricsSample.ts diff --git a/sdk/nodejs/sdk/src/api/apis/MetadataApi.ts b/sdk/nodejs/sdk/src/api/apis/MetadataApi.ts index a202d96a..e3c69720 100644 --- a/sdk/nodejs/sdk/src/api/apis/MetadataApi.ts +++ b/sdk/nodejs/sdk/src/api/apis/MetadataApi.ts @@ -23,6 +23,7 @@ import type { GetSparklinesRequest, ListMemberships200Response, ListOrganizationMembers200Response, + ListPublicFrontendsForAccount200Response, Metrics, ModelConfiguration, Overview, @@ -46,6 +47,8 @@ import { ListMemberships200ResponseToJSON, ListOrganizationMembers200ResponseFromJSON, ListOrganizationMembers200ResponseToJSON, + ListPublicFrontendsForAccount200ResponseFromJSON, + ListPublicFrontendsForAccount200ResponseToJSON, MetricsFromJSON, MetricsToJSON, ModelConfigurationFromJSON, @@ -493,6 +496,34 @@ export class MetadataApi extends runtime.BaseAPI { return await response.value(); } + /** + */ + async listPublicFrontendsForAccountRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["x-token"] = await this.configuration.apiKey("x-token"); // key authentication + } + + const response = await this.request({ + path: `/overview/public-frontends`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ListPublicFrontendsForAccount200ResponseFromJSON(jsonValue)); + } + + /** + */ + async listPublicFrontendsForAccount(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.listPublicFrontendsForAccountRaw(initOverrides); + return await response.value(); + } + /** */ async orgAccountOverviewRaw(requestParameters: OrgAccountOverviewRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { diff --git a/sdk/nodejs/sdk/src/api/models/ListPublicFrontendsForAccount200Response.ts b/sdk/nodejs/sdk/src/api/models/ListPublicFrontendsForAccount200Response.ts new file mode 100644 index 00000000..e87743ba --- /dev/null +++ b/sdk/nodejs/sdk/src/api/models/ListPublicFrontendsForAccount200Response.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 ListPublicFrontendsForAccount200Response + */ +export interface ListPublicFrontendsForAccount200Response { + /** + * + * @type {string} + * @memberof ListPublicFrontendsForAccount200Response + */ + publicName?: string; + /** + * + * @type {string} + * @memberof ListPublicFrontendsForAccount200Response + */ + urlTemplate?: string; +} + +/** + * Check if a given object implements the ListPublicFrontendsForAccount200Response interface. + */ +export function instanceOfListPublicFrontendsForAccount200Response(value: object): value is ListPublicFrontendsForAccount200Response { + return true; +} + +export function ListPublicFrontendsForAccount200ResponseFromJSON(json: any): ListPublicFrontendsForAccount200Response { + return ListPublicFrontendsForAccount200ResponseFromJSONTyped(json, false); +} + +export function ListPublicFrontendsForAccount200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ListPublicFrontendsForAccount200Response { + if (json == null) { + return json; + } + return { + + 'publicName': json['publicName'] == null ? undefined : json['publicName'], + 'urlTemplate': json['urlTemplate'] == null ? undefined : json['urlTemplate'], + }; +} + +export function ListPublicFrontendsForAccount200ResponseToJSON(json: any): ListPublicFrontendsForAccount200Response { + return ListPublicFrontendsForAccount200ResponseToJSONTyped(json, false); +} + +export function ListPublicFrontendsForAccount200ResponseToJSONTyped(value?: ListPublicFrontendsForAccount200Response | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'publicName': value['publicName'], + 'urlTemplate': value['urlTemplate'], + }; +} + diff --git a/sdk/nodejs/sdk/src/api/models/index.ts b/sdk/nodejs/sdk/src/api/models/index.ts index e5a788e6..026ac8bf 100644 --- a/sdk/nodejs/sdk/src/api/models/index.ts +++ b/sdk/nodejs/sdk/src/api/models/index.ts @@ -31,6 +31,7 @@ export * from './ListOrganizationMembers200Response'; export * from './ListOrganizationMembers200ResponseMembersInner'; export * from './ListOrganizations200Response'; export * from './ListOrganizations200ResponseOrganizationsInner'; +export * from './ListPublicFrontendsForAccount200Response'; export * from './LoginRequest'; export * from './Metrics'; export * from './MetricsSample'; diff --git a/sdk/python/src/.openapi-generator/FILES b/sdk/python/src/.openapi-generator/FILES index 5f0fdb83..eb90a776 100644 --- a/sdk/python/src/.openapi-generator/FILES +++ b/sdk/python/src/.openapi-generator/FILES @@ -36,6 +36,7 @@ docs/ListOrganizationMembers200Response.md docs/ListOrganizationMembers200ResponseMembersInner.md docs/ListOrganizations200Response.md docs/ListOrganizations200ResponseOrganizationsInner.md +docs/ListPublicFrontendsForAccount200Response.md docs/LoginRequest.md docs/MetadataApi.md docs/Metrics.md @@ -108,6 +109,7 @@ test/test_list_organization_members200_response.py test/test_list_organization_members200_response_members_inner.py test/test_list_organizations200_response.py test/test_list_organizations200_response_organizations_inner.py +test/test_list_public_frontends_for_account200_response.py test/test_login_request.py test/test_metadata_api.py test/test_metrics.py @@ -186,6 +188,7 @@ zrok_api/models/list_organization_members200_response.py zrok_api/models/list_organization_members200_response_members_inner.py zrok_api/models/list_organizations200_response.py zrok_api/models/list_organizations200_response_organizations_inner.py +zrok_api/models/list_public_frontends_for_account200_response.py zrok_api/models/login_request.py zrok_api/models/metrics.py zrok_api/models/metrics_sample.py diff --git a/sdk/python/src/README.md b/sdk/python/src/README.md index 6faa08b3..5667f369 100644 --- a/sdk/python/src/README.md +++ b/sdk/python/src/README.md @@ -139,6 +139,7 @@ Class | Method | HTTP request | Description *MetadataApi* | [**get_sparklines**](docs/MetadataApi.md#get_sparklines) | **POST** /sparklines | *MetadataApi* | [**list_memberships**](docs/MetadataApi.md#list_memberships) | **GET** /memberships | *MetadataApi* | [**list_org_members**](docs/MetadataApi.md#list_org_members) | **GET** /members/{organizationToken} | +*MetadataApi* | [**list_public_frontends_for_account**](docs/MetadataApi.md#list_public_frontends_for_account) | **GET** /overview/public-frontends | *MetadataApi* | [**org_account_overview**](docs/MetadataApi.md#org_account_overview) | **GET** /overview/{organizationToken}/{accountEmail} | *MetadataApi* | [**overview**](docs/MetadataApi.md#overview) | **GET** /overview | *MetadataApi* | [**version**](docs/MetadataApi.md#version) | **GET** /version | @@ -185,6 +186,7 @@ Class | Method | HTTP request | Description - [ListOrganizationMembers200ResponseMembersInner](docs/ListOrganizationMembers200ResponseMembersInner.md) - [ListOrganizations200Response](docs/ListOrganizations200Response.md) - [ListOrganizations200ResponseOrganizationsInner](docs/ListOrganizations200ResponseOrganizationsInner.md) + - [ListPublicFrontendsForAccount200Response](docs/ListPublicFrontendsForAccount200Response.md) - [LoginRequest](docs/LoginRequest.md) - [Metrics](docs/Metrics.md) - [MetricsSample](docs/MetricsSample.md) diff --git a/sdk/python/src/docs/ListPublicFrontendsForAccount200Response.md b/sdk/python/src/docs/ListPublicFrontendsForAccount200Response.md new file mode 100644 index 00000000..c3e15e7a --- /dev/null +++ b/sdk/python/src/docs/ListPublicFrontendsForAccount200Response.md @@ -0,0 +1,30 @@ +# ListPublicFrontendsForAccount200Response + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**public_name** | **str** | | [optional] +**url_template** | **str** | | [optional] + +## Example + +```python +from zrok_api.models.list_public_frontends_for_account200_response import ListPublicFrontendsForAccount200Response + +# TODO update the JSON string below +json = "{}" +# create an instance of ListPublicFrontendsForAccount200Response from a JSON string +list_public_frontends_for_account200_response_instance = ListPublicFrontendsForAccount200Response.from_json(json) +# print the JSON string representation of the object +print(ListPublicFrontendsForAccount200Response.to_json()) + +# convert the object into a dict +list_public_frontends_for_account200_response_dict = list_public_frontends_for_account200_response_instance.to_dict() +# create an instance of ListPublicFrontendsForAccount200Response from a dict +list_public_frontends_for_account200_response_from_dict = ListPublicFrontendsForAccount200Response.from_dict(list_public_frontends_for_account200_response_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/MetadataApi.md b/sdk/python/src/docs/MetadataApi.md index ecb0cf8b..c83a1a16 100644 --- a/sdk/python/src/docs/MetadataApi.md +++ b/sdk/python/src/docs/MetadataApi.md @@ -16,6 +16,7 @@ Method | HTTP request | Description [**get_sparklines**](MetadataApi.md#get_sparklines) | **POST** /sparklines | [**list_memberships**](MetadataApi.md#list_memberships) | **GET** /memberships | [**list_org_members**](MetadataApi.md#list_org_members) | **GET** /members/{organizationToken} | +[**list_public_frontends_for_account**](MetadataApi.md#list_public_frontends_for_account) | **GET** /overview/public-frontends | [**org_account_overview**](MetadataApi.md#org_account_overview) | **GET** /overview/{organizationToken}/{accountEmail} | [**overview**](MetadataApi.md#overview) | **GET** /overview | [**version**](MetadataApi.md#version) | **GET** /version | @@ -903,6 +904,78 @@ 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) +# **list_public_frontends_for_account** +> ListPublicFrontendsForAccount200Response list_public_frontends_for_account() + +### Example + +* Api Key Authentication (key): + +```python +import zrok_api +from zrok_api.models.list_public_frontends_for_account200_response import ListPublicFrontendsForAccount200Response +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.MetadataApi(api_client) + + try: + api_response = api_instance.list_public_frontends_for_account() + print("The response of MetadataApi->list_public_frontends_for_account:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling MetadataApi->list_public_frontends_for_account: %s\n" % e) +``` + + + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**ListPublicFrontendsForAccount200Response**](ListPublicFrontendsForAccount200Response.md) + +### Authorization + +[key](../README.md#key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/zrok.v1+json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | public frontends list returned | - | +**401** | unauthorized | - | +**500** | internal server error | - | + +[[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) + # **org_account_overview** > Overview org_account_overview(organization_token, account_email) diff --git a/sdk/python/src/test/test_list_public_frontends_for_account200_response.py b/sdk/python/src/test/test_list_public_frontends_for_account200_response.py new file mode 100644 index 00000000..61d4f0c9 --- /dev/null +++ b/sdk/python/src/test/test_list_public_frontends_for_account200_response.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.list_public_frontends_for_account200_response import ListPublicFrontendsForAccount200Response + +class TestListPublicFrontendsForAccount200Response(unittest.TestCase): + """ListPublicFrontendsForAccount200Response unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ListPublicFrontendsForAccount200Response: + """Test ListPublicFrontendsForAccount200Response + 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 `ListPublicFrontendsForAccount200Response` + """ + model = ListPublicFrontendsForAccount200Response() + if include_optional: + return ListPublicFrontendsForAccount200Response( + public_name = '', + url_template = '' + ) + else: + return ListPublicFrontendsForAccount200Response( + ) + """ + + def testListPublicFrontendsForAccount200Response(self): + """Test ListPublicFrontendsForAccount200Response""" + # 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_metadata_api.py b/sdk/python/src/test/test_metadata_api.py index 2424ae4c..0419570f 100644 --- a/sdk/python/src/test/test_metadata_api.py +++ b/sdk/python/src/test/test_metadata_api.py @@ -98,6 +98,12 @@ class TestMetadataApi(unittest.TestCase): """ pass + def test_list_public_frontends_for_account(self) -> None: + """Test case for list_public_frontends_for_account + + """ + pass + def test_org_account_overview(self) -> None: """Test case for org_account_overview diff --git a/sdk/python/src/zrok_api/__init__.py b/sdk/python/src/zrok_api/__init__.py index 23fc8d32..6b73a2a5 100644 --- a/sdk/python/src/zrok_api/__init__.py +++ b/sdk/python/src/zrok_api/__init__.py @@ -68,6 +68,7 @@ from zrok_api.models.list_organization_members200_response import ListOrganizati from zrok_api.models.list_organization_members200_response_members_inner import ListOrganizationMembers200ResponseMembersInner from zrok_api.models.list_organizations200_response import ListOrganizations200Response from zrok_api.models.list_organizations200_response_organizations_inner import ListOrganizations200ResponseOrganizationsInner +from zrok_api.models.list_public_frontends_for_account200_response import ListPublicFrontendsForAccount200Response from zrok_api.models.login_request import LoginRequest from zrok_api.models.metrics import Metrics from zrok_api.models.metrics_sample import MetricsSample diff --git a/sdk/python/src/zrok_api/api/metadata_api.py b/sdk/python/src/zrok_api/api/metadata_api.py index ae780e05..23632ad8 100644 --- a/sdk/python/src/zrok_api/api/metadata_api.py +++ b/sdk/python/src/zrok_api/api/metadata_api.py @@ -27,6 +27,7 @@ from zrok_api.models.get_sparklines200_response import GetSparklines200Response from zrok_api.models.get_sparklines_request import GetSparklinesRequest from zrok_api.models.list_memberships200_response import ListMemberships200Response from zrok_api.models.list_organization_members200_response import ListOrganizationMembers200Response +from zrok_api.models.list_public_frontends_for_account200_response import ListPublicFrontendsForAccount200Response from zrok_api.models.metrics import Metrics from zrok_api.models.overview import Overview from zrok_api.models.share import Share @@ -3233,6 +3234,255 @@ class MetadataApi: + @validate_call + def list_public_frontends_for_account( + self, + _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, + ) -> ListPublicFrontendsForAccount200Response: + """list_public_frontends_for_account + + + :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._list_public_frontends_for_account_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListPublicFrontendsForAccount200Response", + '401': None, + '500': 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 list_public_frontends_for_account_with_http_info( + self, + _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[ListPublicFrontendsForAccount200Response]: + """list_public_frontends_for_account + + + :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._list_public_frontends_for_account_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListPublicFrontendsForAccount200Response", + '401': None, + '500': 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 list_public_frontends_for_account_without_preload_content( + self, + _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: + """list_public_frontends_for_account + + + :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._list_public_frontends_for_account_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListPublicFrontendsForAccount200Response", + '401': None, + '500': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _list_public_frontends_for_account_serialize( + self, + _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 + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/zrok.v1+json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'key' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/overview/public-frontends', + 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 org_account_overview( self, diff --git a/sdk/python/src/zrok_api/models/__init__.py b/sdk/python/src/zrok_api/models/__init__.py index 160b4183..a07826c2 100644 --- a/sdk/python/src/zrok_api/models/__init__.py +++ b/sdk/python/src/zrok_api/models/__init__.py @@ -46,6 +46,7 @@ from zrok_api.models.list_organization_members200_response import ListOrganizati from zrok_api.models.list_organization_members200_response_members_inner import ListOrganizationMembers200ResponseMembersInner from zrok_api.models.list_organizations200_response import ListOrganizations200Response from zrok_api.models.list_organizations200_response_organizations_inner import ListOrganizations200ResponseOrganizationsInner +from zrok_api.models.list_public_frontends_for_account200_response import ListPublicFrontendsForAccount200Response from zrok_api.models.login_request import LoginRequest from zrok_api.models.metrics import Metrics from zrok_api.models.metrics_sample import MetricsSample diff --git a/sdk/python/src/zrok_api/models/list_public_frontends_for_account200_response.py b/sdk/python/src/zrok_api/models/list_public_frontends_for_account200_response.py new file mode 100644 index 00000000..e9913c1b --- /dev/null +++ b/sdk/python/src/zrok_api/models/list_public_frontends_for_account200_response.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 ListPublicFrontendsForAccount200Response(BaseModel): + """ + ListPublicFrontendsForAccount200Response + """ # noqa: E501 + public_name: Optional[StrictStr] = Field(default=None, alias="publicName") + url_template: Optional[StrictStr] = Field(default=None, alias="urlTemplate") + __properties: ClassVar[List[str]] = ["publicName", "urlTemplate"] + + 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 ListPublicFrontendsForAccount200Response 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 ListPublicFrontendsForAccount200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "publicName": obj.get("publicName"), + "urlTemplate": obj.get("urlTemplate") + }) + return _obj + + diff --git a/specs/zrok.yml b/specs/zrok.yml index cc571842..474abb64 100644 --- a/specs/zrok.yml +++ b/specs/zrok.yml @@ -1254,6 +1254,27 @@ paths: schema: $ref: "#/definitions/errorMessage" + /overview/public-frontends: + get: + tags: + - metadata + security: + - key: [] + operationId: listPublicFrontendsForAccount + responses: + 200: + description: public frontends list returned + schema: + properties: + publicName: + type: string + urlTemplate: + type: string + 401: + description: unauthorized + 500: + description: internal server error + /overview/{organizationToken}/{accountEmail}: get: tags: diff --git a/ui/src/api/.openapi-generator/FILES b/ui/src/api/.openapi-generator/FILES index ddecf8da..4507e585 100644 --- a/ui/src/api/.openapi-generator/FILES +++ b/ui/src/api/.openapi-generator/FILES @@ -38,6 +38,7 @@ models/ListOrganizationMembers200Response.ts models/ListOrganizationMembers200ResponseMembersInner.ts models/ListOrganizations200Response.ts models/ListOrganizations200ResponseOrganizationsInner.ts +models/ListPublicFrontendsForAccount200Response.ts models/LoginRequest.ts models/Metrics.ts models/MetricsSample.ts diff --git a/ui/src/api/apis/MetadataApi.ts b/ui/src/api/apis/MetadataApi.ts index a202d96a..e3c69720 100644 --- a/ui/src/api/apis/MetadataApi.ts +++ b/ui/src/api/apis/MetadataApi.ts @@ -23,6 +23,7 @@ import type { GetSparklinesRequest, ListMemberships200Response, ListOrganizationMembers200Response, + ListPublicFrontendsForAccount200Response, Metrics, ModelConfiguration, Overview, @@ -46,6 +47,8 @@ import { ListMemberships200ResponseToJSON, ListOrganizationMembers200ResponseFromJSON, ListOrganizationMembers200ResponseToJSON, + ListPublicFrontendsForAccount200ResponseFromJSON, + ListPublicFrontendsForAccount200ResponseToJSON, MetricsFromJSON, MetricsToJSON, ModelConfigurationFromJSON, @@ -493,6 +496,34 @@ export class MetadataApi extends runtime.BaseAPI { return await response.value(); } + /** + */ + async listPublicFrontendsForAccountRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["x-token"] = await this.configuration.apiKey("x-token"); // key authentication + } + + const response = await this.request({ + path: `/overview/public-frontends`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ListPublicFrontendsForAccount200ResponseFromJSON(jsonValue)); + } + + /** + */ + async listPublicFrontendsForAccount(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.listPublicFrontendsForAccountRaw(initOverrides); + return await response.value(); + } + /** */ async orgAccountOverviewRaw(requestParameters: OrgAccountOverviewRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { diff --git a/ui/src/api/models/ListPublicFrontendsForAccount200Response.ts b/ui/src/api/models/ListPublicFrontendsForAccount200Response.ts new file mode 100644 index 00000000..e87743ba --- /dev/null +++ b/ui/src/api/models/ListPublicFrontendsForAccount200Response.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 ListPublicFrontendsForAccount200Response + */ +export interface ListPublicFrontendsForAccount200Response { + /** + * + * @type {string} + * @memberof ListPublicFrontendsForAccount200Response + */ + publicName?: string; + /** + * + * @type {string} + * @memberof ListPublicFrontendsForAccount200Response + */ + urlTemplate?: string; +} + +/** + * Check if a given object implements the ListPublicFrontendsForAccount200Response interface. + */ +export function instanceOfListPublicFrontendsForAccount200Response(value: object): value is ListPublicFrontendsForAccount200Response { + return true; +} + +export function ListPublicFrontendsForAccount200ResponseFromJSON(json: any): ListPublicFrontendsForAccount200Response { + return ListPublicFrontendsForAccount200ResponseFromJSONTyped(json, false); +} + +export function ListPublicFrontendsForAccount200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ListPublicFrontendsForAccount200Response { + if (json == null) { + return json; + } + return { + + 'publicName': json['publicName'] == null ? undefined : json['publicName'], + 'urlTemplate': json['urlTemplate'] == null ? undefined : json['urlTemplate'], + }; +} + +export function ListPublicFrontendsForAccount200ResponseToJSON(json: any): ListPublicFrontendsForAccount200Response { + return ListPublicFrontendsForAccount200ResponseToJSONTyped(json, false); +} + +export function ListPublicFrontendsForAccount200ResponseToJSONTyped(value?: ListPublicFrontendsForAccount200Response | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'publicName': value['publicName'], + 'urlTemplate': value['urlTemplate'], + }; +} + diff --git a/ui/src/api/models/index.ts b/ui/src/api/models/index.ts index e5a788e6..026ac8bf 100644 --- a/ui/src/api/models/index.ts +++ b/ui/src/api/models/index.ts @@ -31,6 +31,7 @@ export * from './ListOrganizationMembers200Response'; export * from './ListOrganizationMembers200ResponseMembersInner'; export * from './ListOrganizations200Response'; export * from './ListOrganizations200ResponseOrganizationsInner'; +export * from './ListPublicFrontendsForAccount200Response'; export * from './LoginRequest'; export * from './Metrics'; export * from './MetricsSample'; From f6d1b01ef080a090419c09a0486bebef8aaaa63a Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Fri, 27 Jun 2025 13:12:10 -0400 Subject: [PATCH 2/4] list public frontends for account implementation (#996) --- controller/controller.go | 1 + controller/listMemberships.go | 2 +- controller/listPublicFrontendsForAccount.go | 52 ++++++++ controller/store/frontend.go | 40 ++++++ ..._public_frontends_for_account_responses.go | 121 +++++++++++++++++- rest_server_zrok/embedded_spec.go | 39 ++++-- .../list_public_frontends_for_account.go | 120 ++++++++++++++++- .../sdk/src/api/.openapi-generator/FILES | 1 + ...istPublicFrontendsForAccount200Response.ts | 24 ++-- ...rAccount200ResponsePublicFrontendsInner.ts | 73 +++++++++++ sdk/nodejs/sdk/src/api/models/index.ts | 1 + sdk/python/src/.openapi-generator/FILES | 3 + sdk/python/src/README.md | 1 + ...istPublicFrontendsForAccount200Response.md | 3 +- ...rAccount200ResponsePublicFrontendsInner.md | 30 +++++ ...ublic_frontends_for_account200_response.py | 7 +- ...ount200_response_public_frontends_inner.py | 52 ++++++++ sdk/python/src/zrok_api/__init__.py | 1 + sdk/python/src/zrok_api/models/__init__.py | 1 + ...ublic_frontends_for_account200_response.py | 18 ++- ...ount200_response_public_frontends_inner.py | 89 +++++++++++++ specs/zrok.yml | 13 +- ui/src/api/.openapi-generator/FILES | 1 + ...istPublicFrontendsForAccount200Response.ts | 24 ++-- ...rAccount200ResponsePublicFrontendsInner.ts | 73 +++++++++++ ui/src/api/models/index.ts | 1 + 26 files changed, 730 insertions(+), 61 deletions(-) create mode 100644 controller/listPublicFrontendsForAccount.go create mode 100644 sdk/nodejs/sdk/src/api/models/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.ts create mode 100644 sdk/python/src/docs/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.md create mode 100644 sdk/python/src/test/test_list_public_frontends_for_account200_response_public_frontends_inner.py create mode 100644 sdk/python/src/zrok_api/models/list_public_frontends_for_account200_response_public_frontends_inner.py create mode 100644 ui/src/api/models/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.ts diff --git a/controller/controller.go b/controller/controller.go index 4493374f..010b79bc 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -95,6 +95,7 @@ func Run(inCfg *config.Config) error { api.MetadataGetShareDetailHandler = newShareDetailHandler() api.MetadataListMembershipsHandler = newListMembershipsHandler() api.MetadataListOrgMembersHandler = newListOrgMembersHandler() + api.MetadataListPublicFrontendsForAccountHandler = newListPublicFrontendsForAccountHandler() api.MetadataOrgAccountOverviewHandler = newOrgAccountOverviewHandler() api.MetadataOverviewHandler = newOverviewHandler() api.MetadataVersionHandler = metadata.VersionHandlerFunc(versionHandler) diff --git a/controller/listMemberships.go b/controller/listMemberships.go index 9687372a..b5081f74 100644 --- a/controller/listMemberships.go +++ b/controller/listMemberships.go @@ -16,7 +16,7 @@ func newListMembershipsHandler() *listMembershipsHandler { func (h *listMembershipsHandler) Handle(_ metadata.ListMembershipsParams, principal *rest_model_zrok.Principal) middleware.Responder { trx, err := str.Begin() if err != nil { - logrus.Errorf("error startin transaction: %v", err) + logrus.Errorf("error starting transaction: %v", err) return metadata.NewListMembershipsInternalServerError() } defer func() { _ = trx.Rollback() }() diff --git a/controller/listPublicFrontendsForAccount.go b/controller/listPublicFrontendsForAccount.go new file mode 100644 index 00000000..32599c64 --- /dev/null +++ b/controller/listPublicFrontendsForAccount.go @@ -0,0 +1,52 @@ +package controller + +import ( + "github.com/go-openapi/runtime/middleware" + "github.com/openziti/zrok/rest_model_zrok" + "github.com/openziti/zrok/rest_server_zrok/operations/metadata" + "github.com/sirupsen/logrus" +) + +type listPublicFrontendsForAccountHandler struct{} + +func newListPublicFrontendsForAccountHandler() *listPublicFrontendsForAccountHandler { + return &listPublicFrontendsForAccountHandler{} +} + +func (h *listPublicFrontendsForAccountHandler) Handle(_ metadata.ListPublicFrontendsForAccountParams, principal *rest_model_zrok.Principal) middleware.Responder { + trx, err := str.Begin() + if err != nil { + logrus.Errorf("error starting transaction: %v", err) + return metadata.NewListPublicFrontendsForAccountInternalServerError() + } + defer trx.Rollback() + + var publicFrontends []*metadata.ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0 + + openFes, err := str.FindOpenPublicFrontends(trx) + if err != nil { + logrus.Errorf("error finding open public frontends: %v", err) + return metadata.NewListPublicFrontendsForAccountInternalServerError() + } + for _, openFe := range openFes { + publicFrontends = append(publicFrontends, &metadata.ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0{ + PublicName: *openFe.PublicName, + URLTemplate: *openFe.UrlTemplate, + }) + } + + closedFes, err := str.FindClosedPublicFrontendsGrantedToAccount(int(principal.ID), trx) + if err != nil { + logrus.Errorf("error finding closed public frontends: %v", err) + return metadata.NewListPublicFrontendsForAccountInternalServerError() + } + for _, closedFe := range closedFes { + publicFrontends = append(publicFrontends, &metadata.ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0{ + PublicName: *closedFe.PublicName, + URLTemplate: *closedFe.UrlTemplate, + }) + } + + payload := &metadata.ListPublicFrontendsForAccountOKBody{PublicFrontends: publicFrontends} + return metadata.NewListPublicFrontendsForAccountOK().WithPayload(payload) +} diff --git a/controller/store/frontend.go b/controller/store/frontend.go index d0cbf678..d0c5c463 100644 --- a/controller/store/frontend.go +++ b/controller/store/frontend.go @@ -107,6 +107,46 @@ func (str *Store) FindPublicFrontends(tx *sqlx.Tx) ([]*Frontend, error) { return frontends, nil } +func (str *Store) FindOpenPublicFrontends(tx *sqlx.Tx) ([]*Frontend, error) { + rows, err := tx.Queryx("select frontends.* from frontends where environment_id is null and permission_mode = 'open' and reserved = true and not deleted") + if err != nil { + return nil, errors.Wrap(err, "error selecting open public frontends") + } + var frontends []*Frontend + for rows.Next() { + frontend := &Frontend{} + if err := rows.StructScan(frontend); err != nil { + return nil, errors.Wrap(err, "error scanning frontend") + } + frontends = append(frontends, frontend) + } + return frontends, nil +} + +func (str *Store) FindClosedPublicFrontendsGrantedToAccount(accountId int, tx *sqlx.Tx) ([]*Frontend, error) { + rows, err := tx.Queryx(` + select frontends.* from frontends + inner join frontend_grants on frontends.id = frontend_grants.frontend_id + where frontend_grants.account_id = $1 + and frontends.environment_id is null + and frontends.permission_mode = 'closed' + and frontends.reserved = true + and not frontends.deleted + and not frontend_grants.deleted`, accountId) + if err != nil { + return nil, errors.Wrap(err, "error selecting closed public frontends granted to account") + } + var frontends []*Frontend + for rows.Next() { + frontend := &Frontend{} + if err := rows.StructScan(frontend); err != nil { + return nil, errors.Wrap(err, "error scanning frontend") + } + frontends = append(frontends, frontend) + } + return frontends, nil +} + func (str *Store) FindFrontendsForPrivateShare(shrId int, tx *sqlx.Tx) ([]*Frontend, error) { rows, err := tx.Queryx("select frontends.* from frontends where private_share_id = $1 and not deleted", shrId) if err != nil { diff --git a/rest_client_zrok/metadata/list_public_frontends_for_account_responses.go b/rest_client_zrok/metadata/list_public_frontends_for_account_responses.go index d52c30b0..967fd52f 100644 --- a/rest_client_zrok/metadata/list_public_frontends_for_account_responses.go +++ b/rest_client_zrok/metadata/list_public_frontends_for_account_responses.go @@ -9,7 +9,9 @@ import ( "context" "fmt" "io" + "strconv" + "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" @@ -232,20 +234,86 @@ swagger:model ListPublicFrontendsForAccountOKBody */ type ListPublicFrontendsForAccountOKBody struct { - // public name - PublicName string `json:"publicName,omitempty"` - - // url template - URLTemplate string `json:"urlTemplate,omitempty"` + // public frontends + PublicFrontends []*ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0 `json:"publicFrontends"` } // Validate validates this list public frontends for account o k body func (o *ListPublicFrontendsForAccountOKBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validatePublicFrontends(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } return nil } -// ContextValidate validates this list public frontends for account o k body based on context it is used +func (o *ListPublicFrontendsForAccountOKBody) validatePublicFrontends(formats strfmt.Registry) error { + if swag.IsZero(o.PublicFrontends) { // not required + return nil + } + + for i := 0; i < len(o.PublicFrontends); i++ { + if swag.IsZero(o.PublicFrontends[i]) { // not required + continue + } + + if o.PublicFrontends[i] != nil { + if err := o.PublicFrontends[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("listPublicFrontendsForAccountOK" + "." + "publicFrontends" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listPublicFrontendsForAccountOK" + "." + "publicFrontends" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this list public frontends for account o k body based on the context it is used func (o *ListPublicFrontendsForAccountOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidatePublicFrontends(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ListPublicFrontendsForAccountOKBody) contextValidatePublicFrontends(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.PublicFrontends); i++ { + + if o.PublicFrontends[i] != nil { + + if swag.IsZero(o.PublicFrontends[i]) { // not required + return nil + } + + if err := o.PublicFrontends[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("listPublicFrontendsForAccountOK" + "." + "publicFrontends" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listPublicFrontendsForAccountOK" + "." + "publicFrontends" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + return nil } @@ -266,3 +334,44 @@ func (o *ListPublicFrontendsForAccountOKBody) UnmarshalBinary(b []byte) error { *o = res return nil } + +/* +ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0 list public frontends for account o k body public frontends items0 +swagger:model ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0 +*/ +type ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0 struct { + + // public name + PublicName string `json:"publicName,omitempty"` + + // url template + URLTemplate string `json:"urlTemplate,omitempty"` +} + +// Validate validates this list public frontends for account o k body public frontends items0 +func (o *ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this list public frontends for account o k body public frontends items0 based on context it is used +func (o *ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0) UnmarshalBinary(b []byte) error { + var res ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0 + 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 a9893e35..86159714 100644 --- a/rest_server_zrok/embedded_spec.go +++ b/rest_server_zrok/embedded_spec.go @@ -2083,11 +2083,19 @@ func init() { "description": "public frontends list returned", "schema": { "properties": { - "publicName": { - "type": "string" - }, - "urlTemplate": { - "type": "string" + "publicFrontends": { + "type": "array", + "items": { + "type": "object", + "properties": { + "publicName": { + "type": "string" + }, + "urlTemplate": { + "type": "string" + } + } + } } } } @@ -4977,11 +4985,11 @@ func init() { "description": "public frontends list returned", "schema": { "properties": { - "publicName": { - "type": "string" - }, - "urlTemplate": { - "type": "string" + "publicFrontends": { + "type": "array", + "items": { + "$ref": "#/definitions/PublicFrontendsItems0" + } } } } @@ -5612,6 +5620,17 @@ func init() { } } }, + "PublicFrontendsItems0": { + "type": "object", + "properties": { + "publicName": { + "type": "string" + }, + "urlTemplate": { + "type": "string" + } + } + }, "SharesItems0": { "type": "object", "properties": { diff --git a/rest_server_zrok/operations/metadata/list_public_frontends_for_account.go b/rest_server_zrok/operations/metadata/list_public_frontends_for_account.go index a70c351b..63666f9f 100644 --- a/rest_server_zrok/operations/metadata/list_public_frontends_for_account.go +++ b/rest_server_zrok/operations/metadata/list_public_frontends_for_account.go @@ -8,7 +8,9 @@ package metadata import ( "context" "net/http" + "strconv" + "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" @@ -78,20 +80,86 @@ func (o *ListPublicFrontendsForAccount) ServeHTTP(rw http.ResponseWriter, r *htt // swagger:model ListPublicFrontendsForAccountOKBody type ListPublicFrontendsForAccountOKBody struct { - // public name - PublicName string `json:"publicName,omitempty"` - - // url template - URLTemplate string `json:"urlTemplate,omitempty"` + // public frontends + PublicFrontends []*ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0 `json:"publicFrontends"` } // Validate validates this list public frontends for account o k body func (o *ListPublicFrontendsForAccountOKBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validatePublicFrontends(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } return nil } -// ContextValidate validates this list public frontends for account o k body based on context it is used +func (o *ListPublicFrontendsForAccountOKBody) validatePublicFrontends(formats strfmt.Registry) error { + if swag.IsZero(o.PublicFrontends) { // not required + return nil + } + + for i := 0; i < len(o.PublicFrontends); i++ { + if swag.IsZero(o.PublicFrontends[i]) { // not required + continue + } + + if o.PublicFrontends[i] != nil { + if err := o.PublicFrontends[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("listPublicFrontendsForAccountOK" + "." + "publicFrontends" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listPublicFrontendsForAccountOK" + "." + "publicFrontends" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this list public frontends for account o k body based on the context it is used func (o *ListPublicFrontendsForAccountOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidatePublicFrontends(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ListPublicFrontendsForAccountOKBody) contextValidatePublicFrontends(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(o.PublicFrontends); i++ { + + if o.PublicFrontends[i] != nil { + + if swag.IsZero(o.PublicFrontends[i]) { // not required + return nil + } + + if err := o.PublicFrontends[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("listPublicFrontendsForAccountOK" + "." + "publicFrontends" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listPublicFrontendsForAccountOK" + "." + "publicFrontends" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + return nil } @@ -112,3 +180,43 @@ func (o *ListPublicFrontendsForAccountOKBody) UnmarshalBinary(b []byte) error { *o = res return nil } + +// ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0 list public frontends for account o k body public frontends items0 +// +// swagger:model ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0 +type ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0 struct { + + // public name + PublicName string `json:"publicName,omitempty"` + + // url template + URLTemplate string `json:"urlTemplate,omitempty"` +} + +// Validate validates this list public frontends for account o k body public frontends items0 +func (o *ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this list public frontends for account o k body public frontends items0 based on context it is used +func (o *ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0) UnmarshalBinary(b []byte) error { + var res ListPublicFrontendsForAccountOKBodyPublicFrontendsItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/sdk/nodejs/sdk/src/api/.openapi-generator/FILES b/sdk/nodejs/sdk/src/api/.openapi-generator/FILES index 4507e585..87544f21 100644 --- a/sdk/nodejs/sdk/src/api/.openapi-generator/FILES +++ b/sdk/nodejs/sdk/src/api/.openapi-generator/FILES @@ -39,6 +39,7 @@ models/ListOrganizationMembers200ResponseMembersInner.ts models/ListOrganizations200Response.ts models/ListOrganizations200ResponseOrganizationsInner.ts models/ListPublicFrontendsForAccount200Response.ts +models/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.ts models/LoginRequest.ts models/Metrics.ts models/MetricsSample.ts diff --git a/sdk/nodejs/sdk/src/api/models/ListPublicFrontendsForAccount200Response.ts b/sdk/nodejs/sdk/src/api/models/ListPublicFrontendsForAccount200Response.ts index e87743ba..e05210f9 100644 --- a/sdk/nodejs/sdk/src/api/models/ListPublicFrontendsForAccount200Response.ts +++ b/sdk/nodejs/sdk/src/api/models/ListPublicFrontendsForAccount200Response.ts @@ -13,6 +13,14 @@ */ import { mapValues } from '../runtime'; +import type { ListPublicFrontendsForAccount200ResponsePublicFrontendsInner } from './ListPublicFrontendsForAccount200ResponsePublicFrontendsInner'; +import { + ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerFromJSON, + ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerFromJSONTyped, + ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerToJSON, + ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerToJSONTyped, +} from './ListPublicFrontendsForAccount200ResponsePublicFrontendsInner'; + /** * * @export @@ -21,16 +29,10 @@ import { mapValues } from '../runtime'; export interface ListPublicFrontendsForAccount200Response { /** * - * @type {string} + * @type {Array} * @memberof ListPublicFrontendsForAccount200Response */ - publicName?: string; - /** - * - * @type {string} - * @memberof ListPublicFrontendsForAccount200Response - */ - urlTemplate?: string; + publicFrontends?: Array; } /** @@ -50,8 +52,7 @@ export function ListPublicFrontendsForAccount200ResponseFromJSONTyped(json: any, } return { - 'publicName': json['publicName'] == null ? undefined : json['publicName'], - 'urlTemplate': json['urlTemplate'] == null ? undefined : json['urlTemplate'], + 'publicFrontends': json['publicFrontends'] == null ? undefined : ((json['publicFrontends'] as Array).map(ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerFromJSON)), }; } @@ -66,8 +67,7 @@ export function ListPublicFrontendsForAccount200ResponseToJSONTyped(value?: List return { - 'publicName': value['publicName'], - 'urlTemplate': value['urlTemplate'], + 'publicFrontends': value['publicFrontends'] == null ? undefined : ((value['publicFrontends'] as Array).map(ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerToJSON)), }; } diff --git a/sdk/nodejs/sdk/src/api/models/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.ts b/sdk/nodejs/sdk/src/api/models/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.ts new file mode 100644 index 00000000..74faf6b9 --- /dev/null +++ b/sdk/nodejs/sdk/src/api/models/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.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 ListPublicFrontendsForAccount200ResponsePublicFrontendsInner + */ +export interface ListPublicFrontendsForAccount200ResponsePublicFrontendsInner { + /** + * + * @type {string} + * @memberof ListPublicFrontendsForAccount200ResponsePublicFrontendsInner + */ + publicName?: string; + /** + * + * @type {string} + * @memberof ListPublicFrontendsForAccount200ResponsePublicFrontendsInner + */ + urlTemplate?: string; +} + +/** + * Check if a given object implements the ListPublicFrontendsForAccount200ResponsePublicFrontendsInner interface. + */ +export function instanceOfListPublicFrontendsForAccount200ResponsePublicFrontendsInner(value: object): value is ListPublicFrontendsForAccount200ResponsePublicFrontendsInner { + return true; +} + +export function ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerFromJSON(json: any): ListPublicFrontendsForAccount200ResponsePublicFrontendsInner { + return ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerFromJSONTyped(json, false); +} + +export function ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): ListPublicFrontendsForAccount200ResponsePublicFrontendsInner { + if (json == null) { + return json; + } + return { + + 'publicName': json['publicName'] == null ? undefined : json['publicName'], + 'urlTemplate': json['urlTemplate'] == null ? undefined : json['urlTemplate'], + }; +} + +export function ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerToJSON(json: any): ListPublicFrontendsForAccount200ResponsePublicFrontendsInner { + return ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerToJSONTyped(json, false); +} + +export function ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerToJSONTyped(value?: ListPublicFrontendsForAccount200ResponsePublicFrontendsInner | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'publicName': value['publicName'], + 'urlTemplate': value['urlTemplate'], + }; +} + diff --git a/sdk/nodejs/sdk/src/api/models/index.ts b/sdk/nodejs/sdk/src/api/models/index.ts index 026ac8bf..67ceda0d 100644 --- a/sdk/nodejs/sdk/src/api/models/index.ts +++ b/sdk/nodejs/sdk/src/api/models/index.ts @@ -32,6 +32,7 @@ export * from './ListOrganizationMembers200ResponseMembersInner'; export * from './ListOrganizations200Response'; export * from './ListOrganizations200ResponseOrganizationsInner'; export * from './ListPublicFrontendsForAccount200Response'; +export * from './ListPublicFrontendsForAccount200ResponsePublicFrontendsInner'; export * from './LoginRequest'; export * from './Metrics'; export * from './MetricsSample'; diff --git a/sdk/python/src/.openapi-generator/FILES b/sdk/python/src/.openapi-generator/FILES index eb90a776..c2a56db6 100644 --- a/sdk/python/src/.openapi-generator/FILES +++ b/sdk/python/src/.openapi-generator/FILES @@ -37,6 +37,7 @@ docs/ListOrganizationMembers200ResponseMembersInner.md docs/ListOrganizations200Response.md docs/ListOrganizations200ResponseOrganizationsInner.md docs/ListPublicFrontendsForAccount200Response.md +docs/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.md docs/LoginRequest.md docs/MetadataApi.md docs/Metrics.md @@ -110,6 +111,7 @@ test/test_list_organization_members200_response_members_inner.py test/test_list_organizations200_response.py test/test_list_organizations200_response_organizations_inner.py test/test_list_public_frontends_for_account200_response.py +test/test_list_public_frontends_for_account200_response_public_frontends_inner.py test/test_login_request.py test/test_metadata_api.py test/test_metrics.py @@ -189,6 +191,7 @@ zrok_api/models/list_organization_members200_response_members_inner.py zrok_api/models/list_organizations200_response.py zrok_api/models/list_organizations200_response_organizations_inner.py zrok_api/models/list_public_frontends_for_account200_response.py +zrok_api/models/list_public_frontends_for_account200_response_public_frontends_inner.py zrok_api/models/login_request.py zrok_api/models/metrics.py zrok_api/models/metrics_sample.py diff --git a/sdk/python/src/README.md b/sdk/python/src/README.md index 5667f369..f8e6cdce 100644 --- a/sdk/python/src/README.md +++ b/sdk/python/src/README.md @@ -187,6 +187,7 @@ Class | Method | HTTP request | Description - [ListOrganizations200Response](docs/ListOrganizations200Response.md) - [ListOrganizations200ResponseOrganizationsInner](docs/ListOrganizations200ResponseOrganizationsInner.md) - [ListPublicFrontendsForAccount200Response](docs/ListPublicFrontendsForAccount200Response.md) + - [ListPublicFrontendsForAccount200ResponsePublicFrontendsInner](docs/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.md) - [LoginRequest](docs/LoginRequest.md) - [Metrics](docs/Metrics.md) - [MetricsSample](docs/MetricsSample.md) diff --git a/sdk/python/src/docs/ListPublicFrontendsForAccount200Response.md b/sdk/python/src/docs/ListPublicFrontendsForAccount200Response.md index c3e15e7a..aa41964b 100644 --- a/sdk/python/src/docs/ListPublicFrontendsForAccount200Response.md +++ b/sdk/python/src/docs/ListPublicFrontendsForAccount200Response.md @@ -5,8 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**public_name** | **str** | | [optional] -**url_template** | **str** | | [optional] +**public_frontends** | [**List[ListPublicFrontendsForAccount200ResponsePublicFrontendsInner]**](ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.md) | | [optional] ## Example diff --git a/sdk/python/src/docs/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.md b/sdk/python/src/docs/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.md new file mode 100644 index 00000000..d65e2413 --- /dev/null +++ b/sdk/python/src/docs/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.md @@ -0,0 +1,30 @@ +# ListPublicFrontendsForAccount200ResponsePublicFrontendsInner + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**public_name** | **str** | | [optional] +**url_template** | **str** | | [optional] + +## Example + +```python +from zrok_api.models.list_public_frontends_for_account200_response_public_frontends_inner import ListPublicFrontendsForAccount200ResponsePublicFrontendsInner + +# TODO update the JSON string below +json = "{}" +# create an instance of ListPublicFrontendsForAccount200ResponsePublicFrontendsInner from a JSON string +list_public_frontends_for_account200_response_public_frontends_inner_instance = ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.from_json(json) +# print the JSON string representation of the object +print(ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.to_json()) + +# convert the object into a dict +list_public_frontends_for_account200_response_public_frontends_inner_dict = list_public_frontends_for_account200_response_public_frontends_inner_instance.to_dict() +# create an instance of ListPublicFrontendsForAccount200ResponsePublicFrontendsInner from a dict +list_public_frontends_for_account200_response_public_frontends_inner_from_dict = ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.from_dict(list_public_frontends_for_account200_response_public_frontends_inner_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_list_public_frontends_for_account200_response.py b/sdk/python/src/test/test_list_public_frontends_for_account200_response.py index 61d4f0c9..e3a362d3 100644 --- a/sdk/python/src/test/test_list_public_frontends_for_account200_response.py +++ b/sdk/python/src/test/test_list_public_frontends_for_account200_response.py @@ -35,8 +35,11 @@ class TestListPublicFrontendsForAccount200Response(unittest.TestCase): model = ListPublicFrontendsForAccount200Response() if include_optional: return ListPublicFrontendsForAccount200Response( - public_name = '', - url_template = '' + public_frontends = [ + zrok_api.models.list_public_frontends_for_account_200_response_public_frontends_inner.listPublicFrontendsForAccount_200_response_publicFrontends_inner( + public_name = '', + url_template = '', ) + ] ) else: return ListPublicFrontendsForAccount200Response( diff --git a/sdk/python/src/test/test_list_public_frontends_for_account200_response_public_frontends_inner.py b/sdk/python/src/test/test_list_public_frontends_for_account200_response_public_frontends_inner.py new file mode 100644 index 00000000..f220e9d7 --- /dev/null +++ b/sdk/python/src/test/test_list_public_frontends_for_account200_response_public_frontends_inner.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.list_public_frontends_for_account200_response_public_frontends_inner import ListPublicFrontendsForAccount200ResponsePublicFrontendsInner + +class TestListPublicFrontendsForAccount200ResponsePublicFrontendsInner(unittest.TestCase): + """ListPublicFrontendsForAccount200ResponsePublicFrontendsInner unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ListPublicFrontendsForAccount200ResponsePublicFrontendsInner: + """Test ListPublicFrontendsForAccount200ResponsePublicFrontendsInner + 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 `ListPublicFrontendsForAccount200ResponsePublicFrontendsInner` + """ + model = ListPublicFrontendsForAccount200ResponsePublicFrontendsInner() + if include_optional: + return ListPublicFrontendsForAccount200ResponsePublicFrontendsInner( + public_name = '', + url_template = '' + ) + else: + return ListPublicFrontendsForAccount200ResponsePublicFrontendsInner( + ) + """ + + def testListPublicFrontendsForAccount200ResponsePublicFrontendsInner(self): + """Test ListPublicFrontendsForAccount200ResponsePublicFrontendsInner""" + # 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 6b73a2a5..051dcc98 100644 --- a/sdk/python/src/zrok_api/__init__.py +++ b/sdk/python/src/zrok_api/__init__.py @@ -69,6 +69,7 @@ from zrok_api.models.list_organization_members200_response_members_inner import from zrok_api.models.list_organizations200_response import ListOrganizations200Response from zrok_api.models.list_organizations200_response_organizations_inner import ListOrganizations200ResponseOrganizationsInner from zrok_api.models.list_public_frontends_for_account200_response import ListPublicFrontendsForAccount200Response +from zrok_api.models.list_public_frontends_for_account200_response_public_frontends_inner import ListPublicFrontendsForAccount200ResponsePublicFrontendsInner from zrok_api.models.login_request import LoginRequest from zrok_api.models.metrics import Metrics from zrok_api.models.metrics_sample import MetricsSample diff --git a/sdk/python/src/zrok_api/models/__init__.py b/sdk/python/src/zrok_api/models/__init__.py index a07826c2..372149fd 100644 --- a/sdk/python/src/zrok_api/models/__init__.py +++ b/sdk/python/src/zrok_api/models/__init__.py @@ -47,6 +47,7 @@ from zrok_api.models.list_organization_members200_response_members_inner import from zrok_api.models.list_organizations200_response import ListOrganizations200Response from zrok_api.models.list_organizations200_response_organizations_inner import ListOrganizations200ResponseOrganizationsInner from zrok_api.models.list_public_frontends_for_account200_response import ListPublicFrontendsForAccount200Response +from zrok_api.models.list_public_frontends_for_account200_response_public_frontends_inner import ListPublicFrontendsForAccount200ResponsePublicFrontendsInner from zrok_api.models.login_request import LoginRequest from zrok_api.models.metrics import Metrics from zrok_api.models.metrics_sample import MetricsSample diff --git a/sdk/python/src/zrok_api/models/list_public_frontends_for_account200_response.py b/sdk/python/src/zrok_api/models/list_public_frontends_for_account200_response.py index e9913c1b..bbb43f8e 100644 --- a/sdk/python/src/zrok_api/models/list_public_frontends_for_account200_response.py +++ b/sdk/python/src/zrok_api/models/list_public_frontends_for_account200_response.py @@ -17,8 +17,9 @@ import pprint import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional +from zrok_api.models.list_public_frontends_for_account200_response_public_frontends_inner import ListPublicFrontendsForAccount200ResponsePublicFrontendsInner from typing import Optional, Set from typing_extensions import Self @@ -26,9 +27,8 @@ class ListPublicFrontendsForAccount200Response(BaseModel): """ ListPublicFrontendsForAccount200Response """ # noqa: E501 - public_name: Optional[StrictStr] = Field(default=None, alias="publicName") - url_template: Optional[StrictStr] = Field(default=None, alias="urlTemplate") - __properties: ClassVar[List[str]] = ["publicName", "urlTemplate"] + public_frontends: Optional[List[ListPublicFrontendsForAccount200ResponsePublicFrontendsInner]] = Field(default=None, alias="publicFrontends") + __properties: ClassVar[List[str]] = ["publicFrontends"] model_config = ConfigDict( populate_by_name=True, @@ -69,6 +69,13 @@ class ListPublicFrontendsForAccount200Response(BaseModel): exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of each item in public_frontends (list) + _items = [] + if self.public_frontends: + for _item_public_frontends in self.public_frontends: + if _item_public_frontends: + _items.append(_item_public_frontends.to_dict()) + _dict['publicFrontends'] = _items return _dict @classmethod @@ -81,8 +88,7 @@ class ListPublicFrontendsForAccount200Response(BaseModel): return cls.model_validate(obj) _obj = cls.model_validate({ - "publicName": obj.get("publicName"), - "urlTemplate": obj.get("urlTemplate") + "publicFrontends": [ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.from_dict(_item) for _item in obj["publicFrontends"]] if obj.get("publicFrontends") is not None else None }) return _obj diff --git a/sdk/python/src/zrok_api/models/list_public_frontends_for_account200_response_public_frontends_inner.py b/sdk/python/src/zrok_api/models/list_public_frontends_for_account200_response_public_frontends_inner.py new file mode 100644 index 00000000..551f862a --- /dev/null +++ b/sdk/python/src/zrok_api/models/list_public_frontends_for_account200_response_public_frontends_inner.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 ListPublicFrontendsForAccount200ResponsePublicFrontendsInner(BaseModel): + """ + ListPublicFrontendsForAccount200ResponsePublicFrontendsInner + """ # noqa: E501 + public_name: Optional[StrictStr] = Field(default=None, alias="publicName") + url_template: Optional[StrictStr] = Field(default=None, alias="urlTemplate") + __properties: ClassVar[List[str]] = ["publicName", "urlTemplate"] + + 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 ListPublicFrontendsForAccount200ResponsePublicFrontendsInner 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 ListPublicFrontendsForAccount200ResponsePublicFrontendsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "publicName": obj.get("publicName"), + "urlTemplate": obj.get("urlTemplate") + }) + return _obj + + diff --git a/specs/zrok.yml b/specs/zrok.yml index 474abb64..4fb33256 100644 --- a/specs/zrok.yml +++ b/specs/zrok.yml @@ -1266,10 +1266,15 @@ paths: description: public frontends list returned schema: properties: - publicName: - type: string - urlTemplate: - type: string + publicFrontends: + type: array + items: + type: object + properties: + publicName: + type: string + urlTemplate: + type: string 401: description: unauthorized 500: diff --git a/ui/src/api/.openapi-generator/FILES b/ui/src/api/.openapi-generator/FILES index 4507e585..87544f21 100644 --- a/ui/src/api/.openapi-generator/FILES +++ b/ui/src/api/.openapi-generator/FILES @@ -39,6 +39,7 @@ models/ListOrganizationMembers200ResponseMembersInner.ts models/ListOrganizations200Response.ts models/ListOrganizations200ResponseOrganizationsInner.ts models/ListPublicFrontendsForAccount200Response.ts +models/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.ts models/LoginRequest.ts models/Metrics.ts models/MetricsSample.ts diff --git a/ui/src/api/models/ListPublicFrontendsForAccount200Response.ts b/ui/src/api/models/ListPublicFrontendsForAccount200Response.ts index e87743ba..e05210f9 100644 --- a/ui/src/api/models/ListPublicFrontendsForAccount200Response.ts +++ b/ui/src/api/models/ListPublicFrontendsForAccount200Response.ts @@ -13,6 +13,14 @@ */ import { mapValues } from '../runtime'; +import type { ListPublicFrontendsForAccount200ResponsePublicFrontendsInner } from './ListPublicFrontendsForAccount200ResponsePublicFrontendsInner'; +import { + ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerFromJSON, + ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerFromJSONTyped, + ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerToJSON, + ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerToJSONTyped, +} from './ListPublicFrontendsForAccount200ResponsePublicFrontendsInner'; + /** * * @export @@ -21,16 +29,10 @@ import { mapValues } from '../runtime'; export interface ListPublicFrontendsForAccount200Response { /** * - * @type {string} + * @type {Array} * @memberof ListPublicFrontendsForAccount200Response */ - publicName?: string; - /** - * - * @type {string} - * @memberof ListPublicFrontendsForAccount200Response - */ - urlTemplate?: string; + publicFrontends?: Array; } /** @@ -50,8 +52,7 @@ export function ListPublicFrontendsForAccount200ResponseFromJSONTyped(json: any, } return { - 'publicName': json['publicName'] == null ? undefined : json['publicName'], - 'urlTemplate': json['urlTemplate'] == null ? undefined : json['urlTemplate'], + 'publicFrontends': json['publicFrontends'] == null ? undefined : ((json['publicFrontends'] as Array).map(ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerFromJSON)), }; } @@ -66,8 +67,7 @@ export function ListPublicFrontendsForAccount200ResponseToJSONTyped(value?: List return { - 'publicName': value['publicName'], - 'urlTemplate': value['urlTemplate'], + 'publicFrontends': value['publicFrontends'] == null ? undefined : ((value['publicFrontends'] as Array).map(ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerToJSON)), }; } diff --git a/ui/src/api/models/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.ts b/ui/src/api/models/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.ts new file mode 100644 index 00000000..74faf6b9 --- /dev/null +++ b/ui/src/api/models/ListPublicFrontendsForAccount200ResponsePublicFrontendsInner.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 ListPublicFrontendsForAccount200ResponsePublicFrontendsInner + */ +export interface ListPublicFrontendsForAccount200ResponsePublicFrontendsInner { + /** + * + * @type {string} + * @memberof ListPublicFrontendsForAccount200ResponsePublicFrontendsInner + */ + publicName?: string; + /** + * + * @type {string} + * @memberof ListPublicFrontendsForAccount200ResponsePublicFrontendsInner + */ + urlTemplate?: string; +} + +/** + * Check if a given object implements the ListPublicFrontendsForAccount200ResponsePublicFrontendsInner interface. + */ +export function instanceOfListPublicFrontendsForAccount200ResponsePublicFrontendsInner(value: object): value is ListPublicFrontendsForAccount200ResponsePublicFrontendsInner { + return true; +} + +export function ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerFromJSON(json: any): ListPublicFrontendsForAccount200ResponsePublicFrontendsInner { + return ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerFromJSONTyped(json, false); +} + +export function ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): ListPublicFrontendsForAccount200ResponsePublicFrontendsInner { + if (json == null) { + return json; + } + return { + + 'publicName': json['publicName'] == null ? undefined : json['publicName'], + 'urlTemplate': json['urlTemplate'] == null ? undefined : json['urlTemplate'], + }; +} + +export function ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerToJSON(json: any): ListPublicFrontendsForAccount200ResponsePublicFrontendsInner { + return ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerToJSONTyped(json, false); +} + +export function ListPublicFrontendsForAccount200ResponsePublicFrontendsInnerToJSONTyped(value?: ListPublicFrontendsForAccount200ResponsePublicFrontendsInner | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'publicName': value['publicName'], + 'urlTemplate': value['urlTemplate'], + }; +} + diff --git a/ui/src/api/models/index.ts b/ui/src/api/models/index.ts index 026ac8bf..67ceda0d 100644 --- a/ui/src/api/models/index.ts +++ b/ui/src/api/models/index.ts @@ -32,6 +32,7 @@ export * from './ListOrganizationMembers200ResponseMembersInner'; export * from './ListOrganizations200Response'; export * from './ListOrganizations200ResponseOrganizationsInner'; export * from './ListPublicFrontendsForAccount200Response'; +export * from './ListPublicFrontendsForAccount200ResponsePublicFrontendsInner'; export * from './LoginRequest'; export * from './Metrics'; export * from './MetricsSample'; From 7967f41093a7524309dd6826b1a41dd61b678b92 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Fri, 27 Jun 2025 13:13:37 -0400 Subject: [PATCH 3/4] changelog (#996) --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af8ed098..00cb51e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ FEATURE: New add and delete API endpoints for frontend grants. New `zrok admin c FEATURE: New admin endpoint for deleting accounts. New `zrok admin delete account` CLI for invoking the API endpoint from the command line (https://github.com/openziti/zrok/issues/993) +FEATURE: New API endpoint (`/overview/public-frontends`) that returns the public frontends available to authenticated account. The public frontends include those marked with the `open` permission mode, and those marked `closed` where the user has a frontend grant allowing them to access the frontend (https://github.com/openziti/zrok/issues/996) + ## v1.0.6 CHANGE: The `/overview` endpoint has been adjusted to include a new `remoteAgent` `boolean` on the `environment` instances, indicating whether or not the environment has an enrolled remote agent (https://github.com/openziti/zrok/issues/977) From 1c81a1510e0c92e5d323420f5e5131d9bbc726a0 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Fri, 27 Jun 2025 14:23:35 -0400 Subject: [PATCH 4/4] added 'zrok overview public-frontends' to allow CLI listing (#996) --- CHANGELOG.md | 2 +- cmd/zrok/orgMemberships.go | 5 ++- cmd/zrok/overview.go | 6 ++- cmd/zrok/overviewFrontends.go | 78 +++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 cmd/zrok/overviewFrontends.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 00cb51e0..2ad11102 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ FEATURE: New add and delete API endpoints for frontend grants. New `zrok admin c FEATURE: New admin endpoint for deleting accounts. New `zrok admin delete account` CLI for invoking the API endpoint from the command line (https://github.com/openziti/zrok/issues/993) -FEATURE: New API endpoint (`/overview/public-frontends`) that returns the public frontends available to authenticated account. The public frontends include those marked with the `open` permission mode, and those marked `closed` where the user has a frontend grant allowing them to access the frontend (https://github.com/openziti/zrok/issues/996) +FEATURE: New API endpoint (`/overview/public-frontends`) that returns the public frontends available to authenticated account. The public frontends include those marked with the `open` permission mode, and those marked `closed` where the user has a frontend grant allowing them to access the frontend. New CLI command `zrok overview public-frontends` to allow end users to list the public frontends their account can use (https://github.com/openziti/zrok/issues/996) ## v1.0.6 diff --git a/cmd/zrok/orgMemberships.go b/cmd/zrok/orgMemberships.go index 8dd04128..42e27b9f 100644 --- a/cmd/zrok/orgMemberships.go +++ b/cmd/zrok/orgMemberships.go @@ -2,12 +2,13 @@ package main import ( "fmt" + "os" + httptransport "github.com/go-openapi/runtime/client" "github.com/jedib0t/go-pretty/v6/table" "github.com/openziti/zrok/environment" "github.com/openziti/zrok/tui" "github.com/spf13/cobra" - "os" ) func init() { @@ -45,7 +46,7 @@ func (c *orgMembershipsCommand) run(_ *cobra.Command, _ []string) { zrok, err := root.Client() if err != nil { if !panicInstead { - tui.Error("error loading zrokdir", err) + tui.Error("error getting zrok client", err) } panic(err) } diff --git a/cmd/zrok/overview.go b/cmd/zrok/overview.go index f05fe6b4..e9ff39a4 100644 --- a/cmd/zrok/overview.go +++ b/cmd/zrok/overview.go @@ -2,14 +2,18 @@ package main import ( "fmt" + "github.com/openziti/zrok/environment" "github.com/openziti/zrok/sdk/golang/sdk" "github.com/openziti/zrok/tui" "github.com/spf13/cobra" ) +var overviewCmd *cobra.Command + func init() { - rootCmd.AddCommand(newOverviewCommand().cmd) + overviewCmd = newOverviewCommand().cmd + rootCmd.AddCommand(overviewCmd) } type overviewCommand struct { diff --git a/cmd/zrok/overviewFrontends.go b/cmd/zrok/overviewFrontends.go new file mode 100644 index 00000000..2306e9da --- /dev/null +++ b/cmd/zrok/overviewFrontends.go @@ -0,0 +1,78 @@ +package main + +import ( + "fmt" + "os" + + httptransport "github.com/go-openapi/runtime/client" + "github.com/jedib0t/go-pretty/v6/table" + "github.com/openziti/zrok/environment" + "github.com/openziti/zrok/tui" + "github.com/spf13/cobra" +) + +func init() { + overviewCmd.AddCommand(newOverviewFrontendsCommand().cmd) +} + +type overviewPublicFrontendsCommand struct { + cmd *cobra.Command +} + +func newOverviewFrontendsCommand() *overviewPublicFrontendsCommand { + cmd := &cobra.Command{ + Use: "public-frontends", + Short: "Show the available public frontends", + Aliases: []string{"pf"}, + Args: cobra.NoArgs, + } + command := &overviewPublicFrontendsCommand{cmd: cmd} + cmd.Run = command.run + return command +} + +func (cmd *overviewPublicFrontendsCommand) run(_ *cobra.Command, _ []string) { + root, err := environment.LoadRoot() + if err != nil { + if !panicInstead { + tui.Error("error loading zrokdir", err) + } + panic(err) + } + + if !root.IsEnabled() { + tui.Error("unable to load environment; did you 'zrok enable'?", nil) + } + + zrok, err := root.Client() + if err != nil { + if !panicInstead { + tui.Error("error getting zrok client", err) + } + panic(err) + } + + auth := httptransport.APIKeyAuth("X-TOKEN", "header", root.Environment().AccountToken) + resp, err := zrok.Metadata.ListPublicFrontendsForAccount(nil, auth) + if err != nil { + if !panicInstead { + tui.Error("error listing public frontends", err) + } + panic(err) + } + + if len(resp.Payload.PublicFrontends) > 0 { + fmt.Println() + t := table.NewWriter() + t.SetOutputMirror(os.Stdout) + t.SetStyle(table.StyleColoredDark) + t.AppendHeader(table.Row{"Frontend Name", "URL Template"}) + for _, i := range resp.Payload.PublicFrontends { + t.AppendRow(table.Row{i.PublicName, i.URLTemplate}) + } + t.Render() + fmt.Println() + } else { + fmt.Println("no public frontends found") + } +}