models

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package models contains data structures and types used throughout the Google Secret Manager emulator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatPermissionDeniedError

func FormatPermissionDeniedError(permission, resourcePath string) string

FormatPermissionDeniedError creates a properly formatted permission denied error message.

func FormatResourceExistsError

func FormatResourceExistsError(resourceType, projectID, resourceID string) string

FormatResourceExistsError creates a properly formatted "already exists" error message.

func FormatResourceNotFoundError

func FormatResourceNotFoundError(resourceType, projectID, resourceID string) string

FormatResourceNotFoundError creates a properly formatted "not found" error message.

Types

type AccessSecretVersionResponse

type AccessSecretVersionResponse struct {
	Name    string         `json:"name"`
	Payload *SecretPayload `json:"payload"`
}

AccessSecretVersionResponse represents the response for accessing a secret version.

type AddSecretVersionRequest

type AddSecretVersionRequest struct {
	Payload *SecretPayload `json:"payload"`
}

AddSecretVersionRequest represents the request to add a new version to an existing secret.

type AutomaticReplication

type AutomaticReplication struct {
	CustomerManagedEncryption *CustomerManagedEncryption `json:"customerManagedEncryption,omitempty"`
}

AutomaticReplication represents Google-managed replication policy.

type CreateSecretData

type CreateSecretData struct {
	Labels      map[string]string `json:"labels,omitempty"`
	Replication *Replication      `json:"replication,omitempty"`
}

CreateSecretData contains the secret metadata for creation requests.

type CreateSecretRequest

type CreateSecretRequest struct {
	SecretID string            `json:"secretId"`
	Secret   *CreateSecretData `json:"secret"`
}

CreateSecretRequest represents the request to create a new secret.

type CustomerManagedEncryption

type CustomerManagedEncryption struct {
	KmsKeyName string `json:"kmsKeyName"`
}

CustomerManagedEncryption represents customer-managed encryption configuration.

type ErrorDetail

type ErrorDetail struct {
	Code    int           `json:"code"`
	Message string        `json:"message"`
	Status  string        `json:"status"`
	Errors  []ErrorItem   `json:"errors,omitempty"`
	Details []interface{} `json:"details,omitempty"`
}

ErrorDetail contains the details of an API error with optional extended information.

type ErrorInfo

type ErrorInfo struct {
	Type     string            `json:"@type"`
	Reason   string            `json:"reason"`
	Domain   string            `json:"domain"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

ErrorInfo provides detailed error information following AIP-193 standard.

type ErrorItem

type ErrorItem struct {
	Domain       string `json:"domain"`
	Reason       string `json:"reason"`
	Message      string `json:"message"`
	LocationType string `json:"locationType,omitempty"`
	Location     string `json:"location,omitempty"`
}

ErrorItem represents individual error details in the errors array.

type ErrorResponse

type ErrorResponse struct {
	Error *ErrorDetail `json:"error"`
}

ErrorResponse represents an API error response following Google Cloud API standards.

func NewDetailedErrorResponse

func NewDetailedErrorResponse(code int, message, status string, errors []ErrorItem) *ErrorResponse

NewDetailedErrorResponse creates an error response with additional error details.

func NewErrorResponse

func NewErrorResponse(code int, message, status string) *ErrorResponse

NewErrorResponse creates a new error response with the given details.

func NewErrorResponseWithInfo

func NewErrorResponseWithInfo(code int, message, status, reason, domain string, metadata map[string]string) *ErrorResponse

NewErrorResponseWithInfo creates an error response with ErrorInfo details following AIP-193.

type HealthResponse

type HealthResponse struct {
	Status    string    `json:"status"`
	Timestamp time.Time `json:"timestamp"`
	Version   string    `json:"version"`
}

HealthResponse represents the health check response.

type ListSecretVersionsResponse

type ListSecretVersionsResponse struct {
	Versions      []*SecretVersion `json:"versions"`
	NextPageToken string           `json:"nextPageToken,omitempty"`
	TotalSize     int              `json:"totalSize"`
}

ListSecretVersionsResponse represents the response for listing versions of a secret.

type ListSecretsResponse

type ListSecretsResponse struct {
	Secrets       []*Secret `json:"secrets"`
	NextPageToken string    `json:"nextPageToken,omitempty"`
	TotalSize     int       `json:"totalSize"`
}

ListSecretsResponse represents the response for listing secrets in a project.

type Replica

type Replica struct {
	Location                  string                     `json:"location"`
	CustomerManagedEncryption *CustomerManagedEncryption `json:"customerManagedEncryption,omitempty"`
}

Replica represents a single replica location in user-managed replication.

type Replication

type Replication struct {
	Automatic   *AutomaticReplication   `json:"automatic,omitempty"`
	UserManaged *UserManagedReplication `json:"userManaged,omitempty"`
}

Replication describes the replication policy for a secret.

type Secret

type Secret struct {
	Name         string                    `json:"name"`
	CreateTime   time.Time                 `json:"createTime"`
	Labels       map[string]string         `json:"labels,omitempty"`
	Replication  Replication               `json:"replication"`
	Etag         string                    `json:"etag"`
	Versions     map[string]*SecretVersion `json:"-"`
	VersionCount int                       `json:"-"`
}

Secret represents a Google Secret Manager secret resource.

func NewSecret

func NewSecret(projectID, secretID string, labels map[string]string) *Secret

NewSecret creates a new secret with the given project ID, secret ID, and labels.

func (*Secret) GetProjectID

func (s *Secret) GetProjectID() string

GetProjectID extracts the project ID from the secret's resource name.

func (*Secret) GetSecretID

func (s *Secret) GetSecretID() string

GetSecretID extracts the secret ID from the secret's resource name.

type SecretPayload

type SecretPayload struct {
	Data     []byte                 `json:"data"`
	Checksum *SecretVersionChecksum `json:"checksum,omitempty"`
}

SecretPayload contains the actual secret data and its checksums.

type SecretVersion

type SecretVersion struct {
	Name       string                 `json:"name"`
	CreateTime time.Time              `json:"createTime"`
	State      SecretVersionState     `json:"state"`
	Etag       string                 `json:"etag"`
	Data       []byte                 `json:"-"`
	Checksum   *SecretVersionChecksum `json:"checksum,omitempty"`
}

SecretVersion represents a version of a secret with its data and metadata.

func NewSecretVersion

func NewSecretVersion(projectID, secretID string, versionID string, data []byte) *SecretVersion

NewSecretVersion creates a new secret version with the given parameters and data.

func (*SecretVersion) GetProjectID

func (v *SecretVersion) GetProjectID() string

GetProjectID extracts the project ID from the version's resource name.

func (*SecretVersion) GetSecretID

func (v *SecretVersion) GetSecretID() string

GetSecretID extracts the secret ID from the version's resource name.

func (*SecretVersion) GetVersionID

func (v *SecretVersion) GetVersionID() string

GetVersionID extracts the version ID from the version's resource name.

type SecretVersionChecksum

type SecretVersionChecksum struct {
	Crc32c string `json:"crc32c,omitempty"`
	Sha256 string `json:"sha256,omitempty"`
}

SecretVersionChecksum contains checksums for verifying secret data integrity.

type SecretVersionState

type SecretVersionState string

SecretVersionState represents the state of a secret version.

const (
	// StateEnabled indicates the version is enabled and accessible.
	StateEnabled SecretVersionState = "ENABLED"
	// StateDisabled indicates the version is disabled and cannot be accessed.
	StateDisabled SecretVersionState = "DISABLED"
	// StateDestroyed indicates the version has been permanently destroyed.
	StateDestroyed SecretVersionState = "DESTROYED"
)

type UserManagedReplication

type UserManagedReplication struct {
	Replicas []*Replica `json:"replicas"`
}

UserManagedReplication represents user-managed replication policy.

Jump to

Keyboard shortcuts

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