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 ¶
- type AuditService
- type BuildInfo
- type Controller
- func (c *Controller) BulkSetRulesEnabled(ctx context.Context, req *contractsv1.BulkSetRulesEnabledRequest) (*contractsv1.BulkSetRulesEnabledResponse, error)
- func (c *Controller) CreateRule(ctx context.Context, req *commonv1.GuardrailRule) (*commonv1.GuardrailRule, error)
- func (c *Controller) DeleteRule(ctx context.Context, req *contractsv1.DeleteRuleRequest) (*emptypb.Empty, error)
- func (c *Controller) GetAuditRecord(ctx context.Context, req *contractsv1.GetAuditRecordRequest) (*commonv1.AuditRecord, error)
- func (c *Controller) GetDataTypes(_ context.Context, _ *contractsv1.GetDataTypesRequest) (*contractsv1.GetDataTypesResponse, error)
- func (c *Controller) GetRule(ctx context.Context, req *contractsv1.GetRuleRequest) (*commonv1.GuardrailRule, error)
- func (c *Controller) GetSettings(_ context.Context, _ *contractsv1.GetSettingsRequest) (*commonv1.GuardrailsSettings, error)
- func (c *Controller) GetVersion(_ context.Context, _ *contractsv1.GetVersionRequest) (*contractsv1.GetVersionResponse, error)
- func (c *Controller) ListAuditRecords(ctx context.Context, req *contractsv1.ListAuditRecordsRequest) (*contractsv1.ListAuditRecordsResponse, error)
- func (c *Controller) ListRules(ctx context.Context, req *contractsv1.ListRulesRequest) (*contractsv1.ListRulesResponse, error)
- func (c *Controller) Scan(ctx context.Context, req *contractsv1.ScanRequest) (*contractsv1.ScanResponse, error)
- func (c *Controller) SetRuleEnabled(ctx context.Context, req *contractsv1.SetRuleEnabledRequest) (*commonv1.GuardrailRule, error)
- func (c *Controller) UpdateRule(ctx context.Context, req *commonv1.GuardrailRule) (*commonv1.GuardrailRule, error)
- func (c *Controller) UpdateSettings(ctx context.Context, req *commonv1.GuardrailsSettings) (*commonv1.GuardrailsSettings, error)
- type Deps
- type OriginalsDecrypter
- type ScanHandler
- type SettingsService
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 ¶
func (c *Controller) BulkSetRulesEnabled(ctx context.Context, req *contractsv1.BulkSetRulesEnabledRequest) (*contractsv1.BulkSetRulesEnabledResponse, error)
BulkSetRulesEnabled enables or disables many rules. It is best-effort: each id is attempted independently and failures are reported per item.
func (*Controller) CreateRule ¶
func (c *Controller) CreateRule(ctx context.Context, req *commonv1.GuardrailRule) (*commonv1.GuardrailRule, error)
CreateRule creates a custom rule.
func (*Controller) DeleteRule ¶
func (c *Controller) DeleteRule(ctx context.Context, req *contractsv1.DeleteRuleRequest) (*emptypb.Empty, error)
DeleteRule removes a custom rule by ID.
func (*Controller) GetAuditRecord ¶
func (c *Controller) GetAuditRecord(ctx context.Context, req *contractsv1.GetAuditRecordRequest) (*commonv1.AuditRecord, error)
GetAuditRecord reads one masking audit record by request ID.
func (*Controller) GetDataTypes ¶
func (c *Controller) GetDataTypes(_ context.Context, _ *contractsv1.GetDataTypesRequest) (*contractsv1.GetDataTypesResponse, error)
GetDataTypes lists the toggleable data-type groups plus CUSTOM.
func (*Controller) GetRule ¶
func (c *Controller) GetRule(ctx context.Context, req *contractsv1.GetRuleRequest) (*commonv1.GuardrailRule, error)
GetRule reads one rule by ID.
func (*Controller) GetSettings ¶
func (c *Controller) GetSettings(_ context.Context, _ *contractsv1.GetSettingsRequest) (*commonv1.GuardrailsSettings, error)
GetSettings reads the global guardrails settings.
func (*Controller) GetVersion ¶
func (c *Controller) GetVersion(_ context.Context, _ *contractsv1.GetVersionRequest) (*contractsv1.GetVersionResponse, error)
GetVersion reports the service build identity and live masking mode.
func (*Controller) ListAuditRecords ¶
func (c *Controller) ListAuditRecords(ctx context.Context, req *contractsv1.ListAuditRecordsRequest) (*contractsv1.ListAuditRecordsResponse, error)
ListAuditRecords lists masking audit records.
func (*Controller) ListRules ¶
func (c *Controller) ListRules(ctx context.Context, req *contractsv1.ListRulesRequest) (*contractsv1.ListRulesResponse, error)
ListRules returns built-in and/or custom rules filtered by source.
func (*Controller) Scan ¶
func (c *Controller) Scan(ctx context.Context, req *contractsv1.ScanRequest) (*contractsv1.ScanResponse, error)
Scan runs a dry-run masking check on sample text(s).
func (*Controller) SetRuleEnabled ¶
func (c *Controller) SetRuleEnabled(ctx context.Context, req *contractsv1.SetRuleEnabledRequest) (*commonv1.GuardrailRule, error)
SetRuleEnabled enables or disables one rule.
func (*Controller) UpdateRule ¶
func (c *Controller) UpdateRule(ctx context.Context, req *commonv1.GuardrailRule) (*commonv1.GuardrailRule, error)
UpdateRule replaces an existing custom rule. The rule_id comes from the path.
func (*Controller) UpdateSettings ¶
func (c *Controller) UpdateSettings(ctx context.Context, req *commonv1.GuardrailsSettings) (*commonv1.GuardrailsSettings, error)
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 ¶
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.