Voedger Internals
  • Introduction
  • 💡Concepts
    • Event Sourcing & CQRS
    • Editions (deprecated)
      • Community Edition
      • Standart Edition
      • Standart Edition (v1)
  • 🚀Server
    • Overview (Server)
    • Design
      • Query Processor
      • API Gateway implementation
      • N1 Cluster
      • N3 Cluster
      • N5 Cluster
      • Orchestration
      • Sequences
      • Packages overview
        • sys
        • registry
    • Features
      • API Gateway
        • API v2
          • Conventions
            • API URL
            • HTTP methods and processors
            • Naming conventions
            • Query constraints
            • Error handling
          • Documents and records
            • Create document or record
            • Update document or record
            • Deactivate document or record
            • Read document or record
            • Read from CDoc collection
          • Queries
            • Read from query
          • Views
            • Read from view
          • Commands
            • Execute command
          • BLOBs
            • Create BLOB
            • Read BLOB
          • Temporary BLOBs
            • Create temporary BLOB
            • Read temporary BLOB
          • Schemas
            • List app workspaces
            • List workspace roles
            • Read workspace role schema
        • API v1
          • API Conventions
          • BLOBs
      • Admin Endpoint
      • Clusters
        • Bootstrap
        • Monitoring
        • Secure prometheus and grafana
        • Alerting
        • Maintenance
          • SELECT, UPDATE
      • VVMs
      • Applications
        • Deploy Application
        • Sidecar Applications
      • AuthNZ
        • Issue Principal Token
        • Refresh Principal Token
        • Enrich Principal Token
        • ACL Rules
        • Global Roles
      • Data types
        • Core types
        • Small integers
        • Uniques With Multiple Fields
        • Verifiable Fields
      • Workspaces
        • Create Workspace
        • Deactivate Workspace
        • See also (Workspaces)
      • Invites
        • Invite to Workspace
        • Join Workspace
        • Leave Workspace
        • Cancel sent Invite
        • Cancel accepted Invite
        • Update Invite roles
      • Users
        • Create a new user
        • Change user password
        • Send Email
        • Reset password
        • Change Email
      • Notifications
        • Heartbeats
      • Devices
        • Create a new device
        • Join device to workspace
      • Jobs
      • DMBS Drivers
        • AmazonDB Driver
      • Frozen
        • Ephemeral Storage
        • Storage Extensions
  • 🛠️Framework
    • Overview (Framework)
    • Features
      • vpm
      • vpm init
      • vpm tidy
      • vpm baseline
      • vpm orm
      • vpm build
      • API for testing
  • Development
    • Requirements Management
    • Requirements Management (Overview)
Powered by GitBook
On this page
  • Motivation
  • Functional Design
  • Headers
  • Parameters
  • Result
  • Technical Design
  • Components
  • See Also

Was this helpful?

Edit on GitHub
  1. 🚀Server
  2. Features
  3. API Gateway
  4. API v2
  5. Schemas

Read workspace role schema

PreviousList workspace rolesNextAPI v1

Last updated 16 days ago

Was this helpful?

Motivation

Return the schema of the resources, available to specified role in a given workspace.

Functional Design

GET /api/v2/apps/{owner}/{app}/schemas/{pkg}.{workspace}/roles/{pkg}.{role}

If is specified, the user must have sys.Developer role in the workspace to see the schema.

Headers

Key
Value
Description

Authorization

Bearer {PrincipalToken}

optional

Accept

application/json

To get the response in OpenAPI format (default)

Accept

text/html

Shows schema in Swagger UI

Parameters

Parameter
Type
Description

owner

string

name of a user who owns the application

app

string

name of an application

pkg.workspace

string

identifies a workspace

pkg.role

string

identifies a published role

Result

Code
Description
Body

200

OK

role schema in the selected format

400

Bad Request

Technical Design

  • QPv2 reads the schema of the resources available to the role and generates OpenAPI schema for this role

Components

pkg/appdef/acl

New function PublishedTypes ~cmp.publishedTypes~✅

/*
    PublishedTypes lists the resources allowed to the published role in the workspace and ancestors (including resources available to non-authenticated requests):
    - Documents
    - Views
    - Commands
    - Queries

    When fieldNames is empty, it means all fields are allowed
*/
func PublishedTypes(ws appdef.IWorkspace, role appdef.QName) iter.Seq2[appdef.IType,
  iter.Seq2[appdef.OperationKind, *[]appdef.FieldName]] {
…
}

Usage:

import "github.com/voedger/voedger/pkg/appdef/acl"

for t, ops := range acl.PublishedTypes(ws, role) {
  for op, fields := range ops {
    if fields == nil {
      fmt.Println(t, op, "all fields")
    } else {
      fmt.Println(t, op, *fields...)
    }
  }
}

pkg/processors/query2

1. IApiPathHandler implementation for handling ApiPath_Schemas_WorkspaceRole

~cmp.schemasRoleHandler~✅

2. newQueryProcessorPipeline: provide API handler for ApiPath_Schemas_WorkspaceRole

~cmp.provideSchemasRoleHandler~✅

3. New function CreateOpenApiSchema

type SchemaMeta struct {
    schemaTitle string
    schemaVerstion string
}

type PublishedTypesFunc func(ws appdef.IWorkspace, role appdef.QName) iter.Seq2[appdef.IType,
  iter.Seq2[appdef.OperationKind, *[]appdef.FieldName]]

func CreateOpenApiSchema(writer io.Wrter, ws appdef.IWorkspace, role appdef.QName, 
      pubTypesFunc PublishedTypesFunc, meta SchemaMeta) error

~cmp.CreateOpenApiSchema~✅

4. pkg/sys/it

integration test ~it.TestQueryProcessor2_SchemasRole~✅

See Also

WorkspaceQName and QName of the role are provided to QPv2 in

non-published role
List workspace roles
List app workspaces
error object
QueryMessage
design: QPv2