Documentation
¶
Overview ¶
Package schema is the Portal Backend's provider schema bounded context: schemas, schema submissions, their PDP policy metadata, and the schema API.
Index ¶
- Variables
- type CreateSchemaRequest
- type CreateSchemaSubmissionRequest
- type Handler
- func (h *Handler) CreateSchema(w http.ResponseWriter, r *http.Request)
- func (h *Handler) CreateSchemaSubmission(w http.ResponseWriter, r *http.Request)
- func (h *Handler) DeleteSchemaPolicyMetadata(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetAllSchemaSubmissions(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetAllSchemas(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetSchema(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetSchemaSubmission(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ListSchemaPolicyMetadata(w http.ResponseWriter, r *http.Request)
- func (h *Handler) PatchSchemaPolicyMetadata(w http.ResponseWriter, r *http.Request)
- func (h *Handler) RevokeSchemaPolicyAllowListEntry(w http.ResponseWriter, r *http.Request)
- func (h *Handler) UpdateSchema(w http.ResponseWriter, r *http.Request)
- func (h *Handler) UpdateSchemaSubmission(w http.ResponseWriter, r *http.Request)
- type Schema
- type SchemaResponse
- type SchemaSubmission
- type SchemaSubmissionResponse
- type Service
- func (s *Service) CreateSchema(req *CreateSchemaRequest) (*SchemaResponse, error)
- func (s *Service) CreateSchemaSubmission(req *CreateSchemaSubmissionRequest) (*SchemaSubmissionResponse, error)
- func (s *Service) DeletePolicyMetadata(schemaID, id string) error
- func (s *Service) GetSchema(schemaID string) (*SchemaResponse, error)
- func (s *Service) GetSchemaSubmission(submissionID string) (*SchemaSubmissionResponse, error)
- func (s *Service) GetSchemaSubmissions(memberID *string, statusFilter *[]string) ([]*SchemaSubmissionResponse, error)
- func (s *Service) GetSchemas(memberID *string) ([]*SchemaResponse, error)
- func (s *Service) ListPolicyMetadata(schemaID string) (*policy.PolicyMetadataListResponse, error)
- func (s *Service) PatchPolicyMetadata(schemaID, id string, req *policy.PolicyMetadataPatchRequest) (*policy.PolicyMetadataResponse, error)
- func (s *Service) RevokeAllowListEntry(schemaID, id, applicationID string) error
- func (s *Service) UpdateSchema(schemaID string, req *UpdateSchemaRequest) (*SchemaResponse, error)
- func (s *Service) UpdateSchemaSubmission(submissionID string, req *UpdateSchemaSubmissionRequest) (*SchemaSubmissionResponse, error)
- type UpdateSchemaRequest
- type UpdateSchemaSubmissionRequest
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidSchemaID is returned when a caller-supplied schema ID doesn't // match schemaIDPattern. ErrInvalidSchemaID = errors.New("invalid schemaId: use 3-64 lowercase letters, digits, '.', '_' or '-', starting with a letter or digit") // ErrSchemaAlreadyExists is returned when a caller-supplied schema ID is // already taken. ErrSchemaAlreadyExists = errors.New("a schema with this schemaId already exists") )
var ErrPolicyMetadataNotFound = errors.New("policy metadata not found")
ErrPolicyMetadataNotFound is returned when a policy metadata record does not exist in the requested schema.
Functions ¶
This section is empty.
Types ¶
type CreateSchemaRequest ¶
type CreateSchemaRequest struct {
// SchemaID optionally fixes the schema's ID, e.g. "drp-person-v1", so the
// Orchestration Engine's SDL and config can reference it. A UUID is
// generated when it's empty. It can't be changed after creation.
SchemaID string `json:"schemaId,omitempty"`
SchemaName string `json:"schemaName" validate:"required"`
SchemaDescription *string `json:"schemaDescription,omitempty"`
// SDL is a GraphQL SDL string annotated with @accessControl/@source (and
// optionally @displayName/@description/@isOwner/@owner) directives, parsed
// into policy metadata records. Mutually exclusive with Fields.
SDL string `json:"sdl,omitempty"`
// Fields lets a caller declare policy metadata records directly, skipping
// SDL/GraphQL parsing entirely - each FieldName is used as-is (no forced
// typename.fieldName prefix the way SDL-derived field paths get).
// Mutually exclusive with SDL.
Fields []policy.PolicyMetadataCreateRequestRecord `json:"fields,omitempty"`
Endpoint string `json:"endpoint" validate:"required"`
MemberID string `json:"memberId" validate:"required"`
}
CreateSchemaRequest creates a new provider schema. Exactly one of SDL or Fields must be provided.
type CreateSchemaSubmissionRequest ¶
type CreateSchemaSubmissionRequest struct {
SchemaName string `json:"schemaName" validate:"required"`
SchemaDescription *string `json:"schemaDescription,omitempty"`
SDL string `json:"sdl" validate:"required"`
SchemaEndpoint string `json:"schemaEndpoint" validate:"required"`
PreviousSchemaID *string `json:"previousSchemaId,omitempty"`
MemberID string `json:"memberId" validate:"required"`
}
CreateSchemaSubmissionRequest Provider Schema Submission DTOs
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles the schema, schema submission and schema policy metadata HTTP API
func NewHandler ¶
NewHandler creates a new schema Handler
func (*Handler) CreateSchema ¶
func (h *Handler) CreateSchema(w http.ResponseWriter, r *http.Request)
CreateSchema handles POST /api/v1/schemas
func (*Handler) CreateSchemaSubmission ¶
func (h *Handler) CreateSchemaSubmission(w http.ResponseWriter, r *http.Request)
CreateSchemaSubmission handles POST /api/v1/schema-submissions
func (*Handler) DeleteSchemaPolicyMetadata ¶
func (h *Handler) DeleteSchemaPolicyMetadata(w http.ResponseWriter, r *http.Request)
DeleteSchemaPolicyMetadata handles DELETE /api/v1/schemas/{schemaId}/policy-metadata/{id}
func (*Handler) GetAllSchemaSubmissions ¶
func (h *Handler) GetAllSchemaSubmissions(w http.ResponseWriter, r *http.Request)
GetAllSchemaSubmissions handles GET /api/v1/schema-submissions
func (*Handler) GetAllSchemas ¶
func (h *Handler) GetAllSchemas(w http.ResponseWriter, r *http.Request)
GetAllSchemas handles GET /api/v1/schemas
func (*Handler) GetSchema ¶
func (h *Handler) GetSchema(w http.ResponseWriter, r *http.Request)
GetSchema handles GET /api/v1/schemas/{schemaId}
func (*Handler) GetSchemaSubmission ¶
func (h *Handler) GetSchemaSubmission(w http.ResponseWriter, r *http.Request)
GetSchemaSubmission handles GET /api/v1/schema-submissions/{submissionId}
func (*Handler) ListSchemaPolicyMetadata ¶
func (h *Handler) ListSchemaPolicyMetadata(w http.ResponseWriter, r *http.Request)
ListSchemaPolicyMetadata handles GET /api/v1/schemas/{schemaId}/policy-metadata
func (*Handler) PatchSchemaPolicyMetadata ¶
func (h *Handler) PatchSchemaPolicyMetadata(w http.ResponseWriter, r *http.Request)
PatchSchemaPolicyMetadata handles PATCH /api/v1/schemas/{schemaId}/policy-metadata/{id}
func (*Handler) RevokeSchemaPolicyAllowListEntry ¶
func (h *Handler) RevokeSchemaPolicyAllowListEntry(w http.ResponseWriter, r *http.Request)
RevokeSchemaPolicyAllowListEntry handles DELETE /api/v1/schemas/{schemaId}/policy-metadata/{id}/allowlist/{applicationId}
func (*Handler) UpdateSchema ¶
func (h *Handler) UpdateSchema(w http.ResponseWriter, r *http.Request)
UpdateSchema handles PUT /api/v1/schemas/{schemaId}
func (*Handler) UpdateSchemaSubmission ¶
func (h *Handler) UpdateSchemaSubmission(w http.ResponseWriter, r *http.Request)
UpdateSchemaSubmission handles PUT /api/v1/schema-submissions/{submissionId}
type Schema ¶
type Schema struct {
SchemaID string `gorm:"primarykey;column:schema_id" json:"schemaId"`
MemberID string `gorm:"column:member_id;not null" json:"memberId"`
SchemaName string `gorm:"column:schema_name;not null" json:"schemaName"`
SDL string `gorm:"column:sdl;not null" json:"sdl"`
Endpoint string `gorm:"column:endpoint;not null" json:"endpoint"`
Version string `gorm:"column:version;not null" json:"version"`
SchemaDescription *string `gorm:"column:schema_description" json:"schemaDescription,omitempty"`
kernel.BaseModel
// Relationships
Member member.Member `gorm:"foreignKey:MemberID;references:MemberID" json:"member"`
}
Schema represents the provider_schemas table
type SchemaResponse ¶
type SchemaResponse struct {
SchemaID string `json:"schemaId"`
MemberID string `json:"memberId"`
SchemaName string `json:"schemaName"`
SDL string `json:"sdl"`
Endpoint string `json:"endpoint"`
Version string `json:"version"`
SchemaDescription *string `json:"schemaDescription,omitempty"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type SchemaSubmission ¶
type SchemaSubmission struct {
SubmissionID string `gorm:"primarykey;column:submission_id" json:"submissionId"`
PreviousSchemaID *string `gorm:"column:previous_schema_id" json:"previousSchemaId,omitempty"`
SchemaName string `gorm:"column:schema_name;not null" json:"schemaName"`
SchemaDescription *string `gorm:"column:schema_description" json:"schemaDescription,omitempty"`
SDL string `gorm:"column:sdl;not null" json:"sdl"`
SchemaEndpoint string `gorm:"column:schema_endpoint;not null" json:"schemaEndpoint"`
Status string `gorm:"column:status;not null" json:"status"`
MemberID string `gorm:"column:member_id;not null" json:"memberId"`
Review *string `gorm:"column:review" json:"review,omitempty"`
kernel.BaseModel
// Relationships
Member member.Member `gorm:"foreignKey:MemberID;references:MemberID" json:"member"`
PreviousSchema *Schema `gorm:"foreignKey:PreviousSchemaID;references:SchemaID" json:"previousSchema,omitempty"`
}
SchemaSubmission represents the provider_schema_submissions table
func (SchemaSubmission) TableName ¶
func (SchemaSubmission) TableName() string
TableName sets the table name for GORM
type SchemaSubmissionResponse ¶
type SchemaSubmissionResponse struct {
SubmissionID string `json:"submissionId"`
PreviousSchemaID *string `json:"previousSchemaId,omitempty"`
SchemaName string `json:"schemaName"`
SchemaDescription *string `json:"schemaDescription,omitempty"`
SDL string `json:"sdl"`
SchemaEndpoint string `json:"schemaEndpoint"`
Status string `json:"status"`
MemberID string `json:"memberId"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
Review *string `json:"review,omitempty"`
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles schema-related operations
func NewService ¶
NewService creates a new schema service
func (*Service) CreateSchema ¶
func (s *Service) CreateSchema(req *CreateSchemaRequest) (*SchemaResponse, error)
CreateSchema creates a new schema. Exactly one of req.SDL / req.Fields must be set: SDL is parsed into policy metadata records via GraphQL directives, while Fields are used directly, skipping that parsing entirely.
req.SchemaID, if set, becomes the schema's ID; otherwise a UUID is generated. A fixed ID lets the Orchestration Engine's SDL and config name the schema (`@sourceInfo(schemaId: ...)`) the same way in every environment.
func (*Service) CreateSchemaSubmission ¶
func (s *Service) CreateSchemaSubmission(req *CreateSchemaSubmissionRequest) (*SchemaSubmissionResponse, error)
CreateSchemaSubmission creates a new schema
func (*Service) DeletePolicyMetadata ¶
DeletePolicyMetadata deletes one of a schema's policy metadata records
func (*Service) GetSchema ¶
func (s *Service) GetSchema(schemaID string) (*SchemaResponse, error)
GetSchema retrieves a schema by ID
func (*Service) GetSchemaSubmission ¶
func (s *Service) GetSchemaSubmission(submissionID string) (*SchemaSubmissionResponse, error)
GetSchemaSubmission retrieves a schema submission by ID
func (*Service) GetSchemaSubmissions ¶
func (s *Service) GetSchemaSubmissions(memberID *string, statusFilter *[]string) ([]*SchemaSubmissionResponse, error)
GetSchemaSubmissions Get all schema submissions and filter by member ID OR Status Array if given
func (*Service) GetSchemas ¶
func (s *Service) GetSchemas(memberID *string) ([]*SchemaResponse, error)
GetSchemas Get all schemas and filter by member ID if given
func (*Service) ListPolicyMetadata ¶
func (s *Service) ListPolicyMetadata(schemaID string) (*policy.PolicyMetadataListResponse, error)
ListPolicyMetadata lists the PDP policy metadata records of a schema
func (*Service) PatchPolicyMetadata ¶
func (s *Service) PatchPolicyMetadata(schemaID, id string, req *policy.PolicyMetadataPatchRequest) (*policy.PolicyMetadataResponse, error)
PatchPolicyMetadata updates selected properties of one of a schema's policy metadata records
func (*Service) RevokeAllowListEntry ¶
RevokeAllowListEntry removes one application from the allow-list of one of a schema's fields
func (*Service) UpdateSchema ¶
func (s *Service) UpdateSchema(schemaID string, req *UpdateSchemaRequest) (*SchemaResponse, error)
UpdateSchema updates an existing schema
func (*Service) UpdateSchemaSubmission ¶
func (s *Service) UpdateSchemaSubmission(submissionID string, req *UpdateSchemaSubmissionRequest) (*SchemaSubmissionResponse, error)
UpdateSchemaSubmission updates an existing schema submission
type UpdateSchemaRequest ¶
type UpdateSchemaRequest struct {
SchemaName *string `json:"schemaName,omitempty"`
SchemaDescription *string `json:"schemaDescription,omitempty"`
SDL *string `json:"sdl,omitempty"`
Endpoint *string `json:"endpoint,omitempty"`
Version *string `json:"version,omitempty"`
}
UpdateSchemaRequest updates an existing provider schema
type UpdateSchemaSubmissionRequest ¶
type UpdateSchemaSubmissionRequest struct {
SchemaName *string `json:"schemaName,omitempty"`
SchemaDescription *string `json:"schemaDescription,omitempty"`
SDL *string `json:"sdl,omitempty"`
SchemaEndpoint *string `json:"schemaEndpoint,omitempty"`
Status *string `json:"status,omitempty"`
PreviousSchemaID *string `json:"previousSchemaId,omitempty"`
Review *string `json:"review,omitempty"`
}
UpdateSchemaSubmissionRequest updates the status of a provider schema submission