handlers

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionResponse

type ActionResponse struct {
	ID          string    `json:"id"`
	NamespaceID string    `json:"namespaceId"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"createdAt"`
}

ActionResponse represents a single action definition response

func ToActionResponse

func ToActionResponse(a *core.ActionDefinition) *ActionResponse

ToActionResponse converts a core.ActionDefinition to an ActionResponse

type ActionsListResponse

type ActionsListResponse struct {
	Actions    []*ActionResponse `json:"actions"`
	TotalCount int               `json:"totalCount"`
}

ActionsListResponse represents a list of action definitions

type AnalyticsResponse

type AnalyticsResponse struct {
	Summary   AnalyticsSummary `json:"summary"`
	TimeRange struct {
		Start time.Time `json:"start"`
		End   time.Time `json:"end"`
	} `json:"timeRange"`
	GeneratedAt time.Time `json:"generatedAt"`
}

AnalyticsResponse represents analytics data response

type AnalyticsSummary

type AnalyticsSummary struct {
	TotalPolicies       int                 `json:"totalPolicies"`
	ActivePolicies      int                 `json:"activePolicies"`
	TotalEvaluations    int64               `json:"totalEvaluations"`
	AllowedCount        int64               `json:"allowedCount"`
	DeniedCount         int64               `json:"deniedCount"`
	AvgEvaluationTimeMs float64             `json:"avgEvaluationTimeMs"`
	CacheHitRate        float64             `json:"cacheHitRate"`
	TopPolicies         []PolicyStats       `json:"topPolicies"`
	TopResourceTypes    []ResourceTypeStats `json:"topResourceTypes"`
}

AnalyticsSummary represents summary analytics data

type AuditLogEntry

type AuditLogEntry struct {
	ID                 string                 `json:"id"`
	AppID              string                 `json:"appId"`
	UserOrganizationID *string                `json:"userOrganizationId,omitempty"`
	ActorID            string                 `json:"actorId"`
	Action             string                 `json:"action"`
	ResourceType       string                 `json:"resourceType"`
	ResourceID         string                 `json:"resourceId"`
	OldValue           map[string]interface{} `json:"oldValue,omitempty"`
	NewValue           map[string]interface{} `json:"newValue,omitempty"`
	IPAddress          string                 `json:"ipAddress"`
	UserAgent          string                 `json:"userAgent"`
	Timestamp          time.Time              `json:"timestamp"`
}

AuditLogEntry represents a single audit log entry

func ToAuditLogEntry

func ToAuditLogEntry(e *core.AuditEvent) *AuditLogEntry

ToAuditLogEntry converts a core.AuditEvent to an AuditLogEntry

type AuditLogResponse

type AuditLogResponse struct {
	Entries    []*AuditLogEntry `json:"entries"`
	TotalCount int              `json:"totalCount"`
	Page       int              `json:"page"`
	PageSize   int              `json:"pageSize"`
}

AuditLogResponse represents a list of audit log entries

type BatchEvaluateRequest

type BatchEvaluateRequest struct {
	Evaluations []EvaluateRequest `json:"evaluations" validate:"required,min=1,max=100"`
}

BatchEvaluateRequest represents a batch evaluation request

type BatchEvaluateResponse

type BatchEvaluateResponse struct {
	Results          []*BatchEvaluationResult `json:"results"`
	TotalEvaluations int                      `json:"totalEvaluations"`
	TotalTimeMs      float64                  `json:"totalTimeMs"`
	SuccessCount     int                      `json:"successCount"`
	FailureCount     int                      `json:"failureCount"`
}

BatchEvaluateResponse represents the result of a batch evaluation

type BatchEvaluationResult

type BatchEvaluationResult struct {
	Index    int      `json:"index"`
	Allowed  bool     `json:"allowed"`
	Policies []string `json:"policies,omitempty"`
	Error    string   `json:"error,omitempty"`
}

BatchEvaluationResult represents a single evaluation in a batch

type CreateActionRequest

type CreateActionRequest struct {
	NamespaceID string `json:"namespaceId" validate:"required"`
	Name        string `json:"name" validate:"required,min=3,max=50"`
	Description string `json:"description" validate:"max=500"`
}

CreateActionRequest represents a request to create an action definition

type CreateNamespaceRequest

type CreateNamespaceRequest struct {
	Name            string  `json:"name" validate:"required,min=3,max=100"`
	Description     string  `json:"description" validate:"max=500"`
	TemplateID      *string `json:"templateId,omitempty"`
	InheritPlatform bool    `json:"inheritPlatform"`
}

CreateNamespaceRequest represents a request to create a namespace

type CreatePolicyRequest

type CreatePolicyRequest struct {
	NamespaceID  string   `json:"namespaceId" validate:"required"`
	Name         string   `json:"name" validate:"required,min=3,max=100"`
	Description  string   `json:"description" validate:"max=500"`
	Expression   string   `json:"expression" validate:"required"`
	ResourceType string   `json:"resourceType" validate:"required"`
	Actions      []string `json:"actions" validate:"required,min=1"`
	Priority     int      `json:"priority" validate:"min=0,max=1000"`
	Enabled      bool     `json:"enabled"`
}

CreatePolicyRequest represents a request to create a new policy

type CreateResourceRequest

type CreateResourceRequest struct {
	NamespaceID string                   `json:"namespaceId" validate:"required"`
	Type        string                   `json:"type" validate:"required,min=3,max=50"`
	Description string                   `json:"description" validate:"max=500"`
	Attributes  []ResourceAttributeInput `json:"attributes" validate:"required,min=1"`
}

CreateResourceRequest represents a request to create a resource definition

type ErrorResponse

type ErrorResponse = responses.ErrorResponse

Use shared response types from core

type EvaluateRequest

type EvaluateRequest struct {
	Principal    map[string]interface{} `json:"principal" validate:"required"`
	Resource     map[string]interface{} `json:"resource" validate:"required"`
	Action       string                 `json:"action" validate:"required"`
	ResourceType string                 `json:"resourceType" validate:"required"`
	Context      map[string]interface{} `json:"context,omitempty"`
}

EvaluateRequest represents a request to evaluate a permission

type EvaluateResponse

type EvaluateResponse struct {
	Allowed           bool     `json:"allowed"`
	MatchedPolicies   []string `json:"matchedPolicies,omitempty"`
	EvaluatedPolicies int      `json:"evaluatedPolicies"`
	EvaluationTimeMs  float64  `json:"evaluationTimeMs"`
	CacheHit          bool     `json:"cacheHit"`
	Error             string   `json:"error,omitempty"`
	Reason            string   `json:"reason,omitempty"`
}

EvaluateResponse represents the result of a permission evaluation

type InstantiateTemplateRequest

type InstantiateTemplateRequest struct {
	NamespaceID  string                 `json:"namespaceId" validate:"required"`
	Name         string                 `json:"name" validate:"required,min=3,max=100"`
	Description  string                 `json:"description" validate:"max=500"`
	Parameters   map[string]interface{} `json:"parameters" validate:"required"`
	ResourceType string                 `json:"resourceType" validate:"required"`
	Actions      []string               `json:"actions" validate:"required,min=1"`
	Priority     int                    `json:"priority" validate:"min=0,max=1000"`
	Enabled      bool                   `json:"enabled"`
}

InstantiateTemplateRequest represents a request to instantiate a template

type MessageResponse

type MessageResponse = responses.MessageResponse

Use shared response types from core

type MigrateRBACRequest

type MigrateRBACRequest struct {
	NamespaceID         string `json:"namespaceId" validate:"required"`
	ValidateEquivalence bool   `json:"validateEquivalence"`
	KeepRBACPolicies    bool   `json:"keepRbacPolicies"`
	DryRun              bool   `json:"dryRun"`
}

MigrateRBACRequest represents a request to migrate from RBAC to permissions

type MigrationResponse

type MigrationResponse struct {
	MigrationID string    `json:"migrationId"`
	Status      string    `json:"status"`
	Message     string    `json:"message"`
	StartedAt   time.Time `json:"startedAt"`
}

MigrationResponse represents the result of starting a migration

type MigrationStatusResponse

type MigrationStatusResponse struct {
	AppID              string     `json:"appId"`
	UserOrganizationID *string    `json:"userOrganizationId,omitempty"`
	Status             string     `json:"status"`
	StartedAt          time.Time  `json:"startedAt"`
	CompletedAt        *time.Time `json:"completedAt,omitempty"`
	TotalPolicies      int        `json:"totalPolicies"`
	MigratedCount      int        `json:"migratedCount"`
	FailedCount        int        `json:"failedCount"`
	ValidationPassed   bool       `json:"validationPassed"`
	Errors             []string   `json:"errors,omitempty"`
	Progress           float64    `json:"progress"`
}

MigrationStatusResponse represents the status of a migration

type NamespaceResponse

type NamespaceResponse struct {
	ID                 string    `json:"id"`
	AppID              string    `json:"appId"`
	UserOrganizationID *string   `json:"userOrganizationId,omitempty"`
	Name               string    `json:"name"`
	Description        string    `json:"description"`
	TemplateID         *string   `json:"templateId,omitempty"`
	InheritPlatform    bool      `json:"inheritPlatform"`
	ResourceCount      int       `json:"resourceCount"`
	ActionCount        int       `json:"actionCount"`
	PolicyCount        int       `json:"policyCount"`
	CreatedAt          time.Time `json:"createdAt"`
	UpdatedAt          time.Time `json:"updatedAt"`
}

NamespaceResponse represents a single namespace response

func ToNamespaceResponse

func ToNamespaceResponse(n *core.Namespace) *NamespaceResponse

ToNamespaceResponse converts a core.Namespace to a NamespaceResponse

type NamespacesListResponse

type NamespacesListResponse struct {
	Namespaces []*NamespaceResponse `json:"namespaces"`
	TotalCount int                  `json:"totalCount"`
}

NamespacesListResponse represents a list of namespaces

type PoliciesListResponse

type PoliciesListResponse struct {
	Policies   []*PolicyResponse `json:"policies"`
	TotalCount int               `json:"totalCount"`
	Page       int               `json:"page"`
	PageSize   int               `json:"pageSize"`
}

PoliciesListResponse represents a list of policies

type PolicyResponse

type PolicyResponse struct {
	ID                 string    `json:"id"`
	AppID              string    `json:"appId"`
	UserOrganizationID *string   `json:"userOrganizationId,omitempty"`
	NamespaceID        string    `json:"namespaceId"`
	Name               string    `json:"name"`
	Description        string    `json:"description"`
	Expression         string    `json:"expression"`
	ResourceType       string    `json:"resourceType"`
	Actions            []string  `json:"actions"`
	Priority           int       `json:"priority"`
	Enabled            bool      `json:"enabled"`
	Version            int       `json:"version"`
	CreatedBy          string    `json:"createdBy"`
	CreatedAt          time.Time `json:"createdAt"`
	UpdatedAt          time.Time `json:"updatedAt"`
}

PolicyResponse represents a single policy response

func ToPolicyResponse

func ToPolicyResponse(p *core.Policy) *PolicyResponse

ToPolicyResponse converts a core.Policy to a PolicyResponse

type PolicyStats

type PolicyStats struct {
	PolicyID        string  `json:"policyId"`
	PolicyName      string  `json:"policyName"`
	EvaluationCount int64   `json:"evaluationCount"`
	AllowCount      int64   `json:"allowCount"`
	DenyCount       int64   `json:"denyCount"`
	AvgLatencyMs    float64 `json:"avgLatencyMs"`
}

PolicyStats represents statistics for a single policy

type PolicyTestCase

type PolicyTestCase struct {
	Name           string                 `json:"name" validate:"required"`
	Principal      map[string]interface{} `json:"principal" validate:"required"`
	Resource       map[string]interface{} `json:"resource" validate:"required"`
	Action         string                 `json:"action" validate:"required"`
	ExpectedResult bool                   `json:"expectedResult"`
}

PolicyTestCase represents a single test case for policy testing

type PolicyTestResult

type PolicyTestResult struct {
	Name             string  `json:"name"`
	Passed           bool    `json:"passed"`
	ActualResult     bool    `json:"actualResult"`
	ExpectedResult   bool    `json:"expectedResult"`
	Error            string  `json:"error,omitempty"`
	EvaluationTimeMs float64 `json:"evaluationTimeMs"`
}

PolicyTestResult represents the result of a single test case

type ResourceAttributeInput

type ResourceAttributeInput struct {
	Name        string      `json:"name" validate:"required,min=1,max=50"`
	Type        string      `json:"type" validate:"required,oneof=string int bool array object"`
	Required    bool        `json:"required"`
	Default     interface{} `json:"default,omitempty"`
	Description string      `json:"description,omitempty" validate:"max=200"`
}

ResourceAttributeInput represents an attribute in a create/update request

type ResourceResponse

type ResourceResponse struct {
	ID          string                   `json:"id"`
	NamespaceID string                   `json:"namespaceId"`
	Type        string                   `json:"type"`
	Description string                   `json:"description"`
	Attributes  []core.ResourceAttribute `json:"attributes"`
	CreatedAt   time.Time                `json:"createdAt"`
}

ResourceResponse represents a single resource definition response

func ToResourceResponse

func ToResourceResponse(r *core.ResourceDefinition) *ResourceResponse

ToResourceResponse converts a core.ResourceDefinition to a ResourceResponse

type ResourceTypeStats

type ResourceTypeStats struct {
	ResourceType    string  `json:"resourceType"`
	EvaluationCount int64   `json:"evaluationCount"`
	AllowRate       float64 `json:"allowRate"`
	AvgLatencyMs    float64 `json:"avgLatencyMs"`
}

ResourceTypeStats represents statistics for a resource type

type ResourcesListResponse

type ResourcesListResponse struct {
	Resources  []*ResourceResponse `json:"resources"`
	TotalCount int                 `json:"totalCount"`
}

ResourcesListResponse represents a list of resource definitions

type StatusResponse

type StatusResponse = responses.StatusResponse

Use shared response types from core

type TemplateResponse

type TemplateResponse struct {
	ID          string                   `json:"id"`
	Name        string                   `json:"name"`
	Description string                   `json:"description"`
	Category    string                   `json:"category"`
	Expression  string                   `json:"expression"`
	Parameters  []core.TemplateParameter `json:"parameters"`
	Examples    []string                 `json:"examples"`
}

TemplateResponse represents a single policy template

type TemplatesListResponse

type TemplatesListResponse struct {
	Templates  []*TemplateResponse `json:"templates"`
	TotalCount int                 `json:"totalCount"`
	Categories []string            `json:"categories"`
}

TemplatesListResponse represents a list of policy templates

type TestPolicyRequest

type TestPolicyRequest struct {
	Expression   string           `json:"expression" validate:"required"`
	ResourceType string           `json:"resourceType" validate:"required"`
	TestCases    []PolicyTestCase `json:"testCases" validate:"required,min=1"`
}

TestPolicyRequest represents a request to test a policy with sample data

type TestPolicyResponse

type TestPolicyResponse struct {
	Results     []*PolicyTestResult `json:"results"`
	TotalTests  int                 `json:"totalTests"`
	PassedTests int                 `json:"passedTests"`
	FailedTests int                 `json:"failedTests"`
	Message     string              `json:"message,omitempty"`
}

TestPolicyResponse represents the result of policy testing

type UpdateNamespaceRequest

type UpdateNamespaceRequest struct {
	Name            *string `json:"name,omitempty" validate:"omitempty,min=3,max=100"`
	Description     *string `json:"description,omitempty" validate:"omitempty,max=500"`
	InheritPlatform *bool   `json:"inheritPlatform,omitempty"`
}

UpdateNamespaceRequest represents a request to update a namespace

type UpdatePolicyRequest

type UpdatePolicyRequest struct {
	Name         *string  `json:"name,omitempty" validate:"omitempty,min=3,max=100"`
	Description  *string  `json:"description,omitempty" validate:"omitempty,max=500"`
	Expression   *string  `json:"expression,omitempty"`
	ResourceType *string  `json:"resourceType,omitempty"`
	Actions      []string `json:"actions,omitempty"`
	Priority     *int     `json:"priority,omitempty" validate:"omitempty,min=0,max=1000"`
	Enabled      *bool    `json:"enabled,omitempty"`
}

UpdatePolicyRequest represents a request to update an existing policy

type ValidatePolicyRequest

type ValidatePolicyRequest struct {
	Expression   string `json:"expression" validate:"required"`
	ResourceType string `json:"resourceType" validate:"required"`
}

ValidatePolicyRequest represents a request to validate a policy expression

type ValidatePolicyResponse

type ValidatePolicyResponse struct {
	Valid      bool     `json:"valid"`
	Errors     []string `json:"errors,omitempty"`
	Warnings   []string `json:"warnings,omitempty"`
	Complexity int      `json:"complexity,omitempty"`
	Message    string   `json:"message,omitempty"`
}

ValidatePolicyResponse represents the result of policy validation

Jump to

Keyboard shortcuts

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