api

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api is the gRPC implementation of the management API (GuardrailsApi): custom rule CRUD, global settings, data-type discovery and dry-run masking checks. REST is served from the same contract via grpc-gateway (wired in internal/app). It is separate from the data-plane proxy in internal/controller/gateway, which stays plain HTTP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditService

type AuditService interface {
	GetAuditRecord(ctx context.Context, requestID string) (models.AuditRecord, error)
	ListAuditRecords(ctx context.Context, q repository.AuditQuery) (repository.AuditPage, error)
}

AuditService is the masking-audit dependency of the API. The method set matches repository.AuditStore, so the store satisfies it directly. A nil service means the audit trail is disabled and the audit RPCs report FailedPrecondition.

type BuildInfo

type BuildInfo struct {
	Version      string
	Commit       string
	Date         string
	Topology     string
	StoreBackend string
}

BuildInfo is the static service identity reported by GetVersion. Topology is "standalone"; StoreBackend is the configured persistence backend name.

type Controller

type Controller struct {
	servicev1.UnimplementedGuardrailsApiServer
	// contains filtered or unexported fields
}

Controller implements servicev1.GuardrailsApiServer over the use-case layer.

func NewController

func NewController(d Deps) *Controller

NewController wires the gRPC controller from its dependencies.

func (*Controller) BulkSetRulesEnabled

BulkSetRulesEnabled enables or disables many rules. It is best-effort: each id is attempted independently and failures are reported per item.

func (*Controller) CreateRule

CreateRule creates a custom rule.

func (*Controller) DeleteRule

DeleteRule removes a custom rule by ID.

func (*Controller) GetAuditRecord

GetAuditRecord reads one masking audit record by request ID.

func (*Controller) GetDataTypes

GetDataTypes lists the toggleable data-type groups plus CUSTOM.

func (*Controller) GetRule

GetRule reads one rule by ID.

func (*Controller) GetSettings

GetSettings reads the global guardrails settings.

func (*Controller) GetVersion

GetVersion reports the service build identity and live masking mode.

func (*Controller) ListAuditRecords

ListAuditRecords lists masking audit records.

func (*Controller) ListRules

ListRules returns built-in and/or custom rules filtered by source.

func (*Controller) Scan

Scan runs a dry-run masking check on sample text(s).

func (*Controller) SetRuleEnabled

SetRuleEnabled enables or disables one rule.

func (*Controller) UpdateRule

UpdateRule replaces an existing custom rule. The rule_id comes from the path.

func (*Controller) UpdateSettings

UpdateSettings replaces the global guardrails settings.

type Deps

type Deps struct {
	Create     create.CommandHandler
	Update     update.CommandHandler
	Delete     deleterule.CommandHandler
	SetEnabled setenabled.CommandHandler
	Get        get.CommandHandler
	List       list.CommandHandler
	Scan       ScanHandler
	Settings   SettingsService
	Audit      AuditService       // nil = audit disabled
	Originals  OriginalsDecrypter // nil = no decryption of audit originals
	DataTypes  []rule.DataType
	BuildInfo  BuildInfo
}

Deps are the dependencies of the gRPC controller. The rule handlers reuse the existing per-scenario use-case CommandHandler interfaces.

type OriginalsDecrypter

type OriginalsDecrypter interface {
	DecryptString(value string) (string, error)
}

OriginalsDecrypter opens encrypted audit-replacement originals on the read path (statecodec.Codec satisfies it). A plaintext value passes through; an undecryptable value is dropped by the caller. nil disables decryption.

type ScanHandler

type ScanHandler interface {
	Handle(ctx context.Context, cmd scan.Command) (scan.CommandResponse, error)
}

ScanHandler runs a dry-run masking scan.

type SettingsService

type SettingsService interface {
	Global() models.GuardrailsSettings
	Update(ctx context.Context, gs models.GuardrailsSettings) error
}

SettingsService is the global-settings dependency of the API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL