documentdb

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package documentdb implements the DocumentDB service handlers.

Index

Constants

View Source
const (
	DBClusterStatusAvailable = "available"
	DBClusterStatusDeleting  = "deleting"
)

DB cluster states.

View Source
const (
	DBInstanceStatusAvailable = "available"
	DBInstanceStatusDeleting  = "deleting"
)

DB instance states.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateDBClusterInput

type CreateDBClusterInput struct {
	DBClusterIdentifier string `json:"DBClusterIdentifier"`
	Engine              string `json:"Engine,omitempty"`
	EngineVersion       string `json:"EngineVersion,omitempty"`
	MasterUsername      string `json:"MasterUsername,omitempty"`
	MasterUserPassword  string `json:"MasterUserPassword,omitempty"`
	Port                int32  `json:"Port,omitempty"`
	DeletionProtection  bool   `json:"DeletionProtection,omitempty"`
	StorageEncrypted    bool   `json:"StorageEncrypted,omitempty"`
	Tags                []Tag  `json:"Tags,omitempty"`
}

CreateDBClusterInput represents the input for CreateDBCluster.

type CreateDBInstanceInput

type CreateDBInstanceInput struct {
	DBInstanceIdentifier string `json:"DBInstanceIdentifier"`
	DBInstanceClass      string `json:"DBInstanceClass"`
	Engine               string `json:"Engine,omitempty"`
	DBClusterIdentifier  string `json:"DBClusterIdentifier,omitempty"`
	Tags                 []Tag  `json:"Tags,omitempty"`
}

CreateDBInstanceInput represents the input for CreateDBInstance.

type DBCluster

type DBCluster struct {
	DBClusterIdentifier string
	DBClusterArn        string
	Engine              string
	EngineVersion       string
	Status              string
	MasterUsername      string
	Endpoint            string
	ReaderEndpoint      string
	Port                int32
	ClusterCreateTime   time.Time
	DBClusterMembers    []DBClusterMember
	DeletionProtection  bool
	StorageEncrypted    bool
	Tags                []Tag
}

DBCluster represents a DocumentDB database cluster.

type DBClusterMember

type DBClusterMember struct {
	DBInstanceIdentifier          string `json:"DBInstanceIdentifier,omitempty"`
	IsClusterWriter               bool   `json:"IsClusterWriter,omitempty"`
	DBClusterParameterGroupStatus string `json:"DBClusterParameterGroupStatus,omitempty"`
}

DBClusterMember represents a member of a DocumentDB DB cluster.

type DBInstance

type DBInstance struct {
	DBInstanceIdentifier string
	DBInstanceArn        string
	DBInstanceClass      string
	Engine               string
	EngineVersion        string
	DBInstanceStatus     string
	Endpoint             *Endpoint
	DBClusterIdentifier  string
	InstanceCreateTime   time.Time
	Tags                 []Tag
}

DBInstance represents a DocumentDB database instance.

type DeleteDBClusterInput

type DeleteDBClusterInput struct {
	DBClusterIdentifier string `json:"DBClusterIdentifier"`
	SkipFinalSnapshot   bool   `json:"SkipFinalSnapshot,omitempty"`
}

DeleteDBClusterInput represents the input for DeleteDBCluster.

type DeleteDBInstanceInput

type DeleteDBInstanceInput struct {
	DBInstanceIdentifier string `json:"DBInstanceIdentifier"`
	SkipFinalSnapshot    bool   `json:"SkipFinalSnapshot,omitempty"`
}

DeleteDBInstanceInput represents the input for DeleteDBInstance.

type DescribeDBClustersInput

type DescribeDBClustersInput struct {
	DBClusterIdentifier string `json:"DBClusterIdentifier,omitempty"`
}

DescribeDBClustersInput represents the input for DescribeDBClusters.

type DescribeDBInstancesInput

type DescribeDBInstancesInput struct {
	DBInstanceIdentifier string `json:"DBInstanceIdentifier,omitempty"`
}

DescribeDBInstancesInput represents the input for DescribeDBInstances.

type Endpoint

type Endpoint struct {
	Address string `json:"Address,omitempty"`
	Port    int32  `json:"Port,omitempty"`
}

Endpoint represents a database endpoint.

type Error

type Error struct {
	Code    string
	Message string
}

Error represents a DocumentDB error.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

type ErrorResponse

type ErrorResponse struct {
	Type    string `json:"__type"`
	Message string `json:"message"`
}

ErrorResponse represents a DocumentDB error response.

type MemoryStorage

type MemoryStorage struct {
	Clusters  map[string]*DBCluster  `json:"clusters"`
	Instances map[string]*DBInstance `json:"instances"`
	// contains filtered or unexported fields
}

MemoryStorage implements Storage with in-memory data.

func NewMemoryStorage

func NewMemoryStorage(opts ...Option) *MemoryStorage

NewMemoryStorage creates a new MemoryStorage.

func (*MemoryStorage) Close

func (m *MemoryStorage) Close() error

Close saves the storage state to disk if persistence is enabled.

func (*MemoryStorage) CreateDBCluster

func (m *MemoryStorage) CreateDBCluster(_ context.Context, input *CreateDBClusterInput) (*DBCluster, error)

CreateDBCluster creates a new DocumentDB DB cluster.

func (*MemoryStorage) CreateDBInstance

func (m *MemoryStorage) CreateDBInstance(_ context.Context, input *CreateDBInstanceInput) (*DBInstance, error)

CreateDBInstance creates a new DocumentDB DB instance.

func (*MemoryStorage) DeleteDBCluster

func (m *MemoryStorage) DeleteDBCluster(_ context.Context, identifier string, _ bool) (*DBCluster, error)

DeleteDBCluster deletes a DocumentDB DB cluster.

func (*MemoryStorage) DeleteDBInstance

func (m *MemoryStorage) DeleteDBInstance(_ context.Context, identifier string, _ bool) (*DBInstance, error)

DeleteDBInstance deletes a DocumentDB DB instance.

func (*MemoryStorage) DescribeDBClusters

func (m *MemoryStorage) DescribeDBClusters(_ context.Context, identifier string) ([]DBCluster, error)

DescribeDBClusters describes DocumentDB DB clusters.

func (*MemoryStorage) DescribeDBInstances

func (m *MemoryStorage) DescribeDBInstances(_ context.Context, identifier string) ([]DBInstance, error)

DescribeDBInstances describes DocumentDB DB instances.

func (*MemoryStorage) MarshalJSON

func (m *MemoryStorage) MarshalJSON() ([]byte, error)

MarshalJSON serializes the storage state to JSON.

func (*MemoryStorage) ModifyDBCluster

func (m *MemoryStorage) ModifyDBCluster(_ context.Context, input *ModifyDBClusterInput) (*DBCluster, error)

ModifyDBCluster modifies a DocumentDB DB cluster.

func (*MemoryStorage) UnmarshalJSON

func (m *MemoryStorage) UnmarshalJSON(data []byte) error

UnmarshalJSON restores the storage state from JSON.

type ModifyDBClusterInput

type ModifyDBClusterInput struct {
	DBClusterIdentifier string `json:"DBClusterIdentifier"`
	EngineVersion       string `json:"EngineVersion,omitempty"`
	MasterUserPassword  string `json:"MasterUserPassword,omitempty"`
	Port                *int32 `json:"Port,omitempty"`
	DeletionProtection  *bool  `json:"DeletionProtection,omitempty"`
}

ModifyDBClusterInput represents the input for ModifyDBCluster.

type Option

type Option func(*MemoryStorage)

Option is a configuration option for MemoryStorage.

func WithDataDir

func WithDataDir(dir string) Option

WithDataDir enables persistent storage in the specified directory.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service implements the DocumentDB service.

func New

func New(storage Storage) *Service

New creates a new DocumentDB service.

func (*Service) Actions

func (s *Service) Actions() []string

Actions returns the list of action names this service handles.

func (*Service) Close

func (s *Service) Close() error

Close saves the storage state if persistence is enabled.

func (*Service) CreateDBCluster

func (s *Service) CreateDBCluster(w http.ResponseWriter, r *http.Request)

CreateDBCluster handles the CreateDBCluster action.

func (*Service) CreateDBInstance

func (s *Service) CreateDBInstance(w http.ResponseWriter, r *http.Request)

CreateDBInstance handles the CreateDBInstance action.

func (*Service) DeleteDBCluster

func (s *Service) DeleteDBCluster(w http.ResponseWriter, r *http.Request)

DeleteDBCluster handles the DeleteDBCluster action.

func (*Service) DeleteDBInstance

func (s *Service) DeleteDBInstance(w http.ResponseWriter, r *http.Request)

DeleteDBInstance handles the DeleteDBInstance action.

func (*Service) DescribeDBClusters

func (s *Service) DescribeDBClusters(w http.ResponseWriter, r *http.Request)

DescribeDBClusters handles the DescribeDBClusters action.

func (*Service) DescribeDBInstances

func (s *Service) DescribeDBInstances(w http.ResponseWriter, r *http.Request)

DescribeDBInstances handles the DescribeDBInstances action.

func (*Service) DispatchAction

func (s *Service) DispatchAction(w http.ResponseWriter, r *http.Request)

DispatchAction routes the request to the appropriate handler based on Action parameter.

func (*Service) ModifyDBCluster

func (s *Service) ModifyDBCluster(w http.ResponseWriter, r *http.Request)

ModifyDBCluster handles the ModifyDBCluster action.

func (*Service) Name

func (s *Service) Name() string

Name returns the service name.

func (*Service) QueryProtocol

func (s *Service) QueryProtocol()

QueryProtocol is a marker method that indicates DocumentDB uses AWS Query protocol.

func (*Service) RegisterRoutes

func (s *Service) RegisterRoutes(_ service.Router)

RegisterRoutes registers routes with the router. DocumentDB uses Query protocol, so routes are registered via DispatchAction.

func (*Service) ServiceIdentifier

func (s *Service) ServiceIdentifier() string

ServiceIdentifier returns the SDK service identifier for User-Agent disambiguation.

func (*Service) TargetPrefix

func (s *Service) TargetPrefix() string

TargetPrefix returns the X-Amz-Target header prefix for DocumentDB. DocumentDB uses the same target prefix as RDS.

type Storage

type Storage interface {
	CreateDBCluster(ctx context.Context, input *CreateDBClusterInput) (*DBCluster, error)
	DeleteDBCluster(ctx context.Context, identifier string, skipFinalSnapshot bool) (*DBCluster, error)
	DescribeDBClusters(ctx context.Context, identifier string) ([]DBCluster, error)
	ModifyDBCluster(ctx context.Context, input *ModifyDBClusterInput) (*DBCluster, error)
	CreateDBInstance(ctx context.Context, input *CreateDBInstanceInput) (*DBInstance, error)
	DeleteDBInstance(ctx context.Context, identifier string, skipFinalSnapshot bool) (*DBInstance, error)
	DescribeDBInstances(ctx context.Context, identifier string) ([]DBInstance, error)
}

Storage defines the DocumentDB storage interface.

type Tag

type Tag struct {
	Key   string `json:"Key,omitempty"`
	Value string `json:"Value,omitempty"`
}

Tag represents a resource tag.

type XMLCreateDBClusterResponse

type XMLCreateDBClusterResponse struct {
	XMLName   xml.Name     `xml:"CreateDBClusterResponse"`
	Xmlns     string       `xml:"xmlns,attr"`
	DBCluster XMLDBCluster `xml:"CreateDBClusterResult>DBCluster"`
	RequestID string       `xml:"ResponseMetadata>RequestId"`
}

XMLCreateDBClusterResponse is the XML response for CreateDBCluster.

type XMLCreateDBInstanceResponse

type XMLCreateDBInstanceResponse struct {
	XMLName    xml.Name      `xml:"CreateDBInstanceResponse"`
	Xmlns      string        `xml:"xmlns,attr"`
	DBInstance XMLDBInstance `xml:"CreateDBInstanceResult>DBInstance"`
	RequestID  string        `xml:"ResponseMetadata>RequestId"`
}

XMLCreateDBInstanceResponse is the XML response for CreateDBInstance.

type XMLDBCluster

type XMLDBCluster struct {
	DBClusterIdentifier string              `xml:"DBClusterIdentifier"`
	DBClusterArn        string              `xml:"DBClusterArn"`
	Engine              string              `xml:"Engine"`
	EngineVersion       string              `xml:"EngineVersion,omitempty"`
	Status              string              `xml:"Status"`
	MasterUsername      string              `xml:"MasterUsername,omitempty"`
	Endpoint            string              `xml:"Endpoint"`
	ReaderEndpoint      string              `xml:"ReaderEndpoint"`
	Port                int32               `xml:"Port"`
	ClusterCreateTime   string              `xml:"ClusterCreateTime"`
	DBClusterMembers    XMLDBClusterMembers `xml:"DBClusterMembers"`
	DeletionProtection  bool                `xml:"DeletionProtection"`
	StorageEncrypted    bool                `xml:"StorageEncrypted"`
}

XMLDBCluster is the XML representation of a DocumentDB DB cluster.

type XMLDBClusterMember

type XMLDBClusterMember struct {
	DBInstanceIdentifier          string `xml:"DBInstanceIdentifier"`
	IsClusterWriter               bool   `xml:"IsClusterWriter"`
	DBClusterParameterGroupStatus string `xml:"DBClusterParameterGroupStatus,omitempty"`
}

XMLDBClusterMember is the XML representation of a DB cluster member.

type XMLDBClusterMembers

type XMLDBClusterMembers struct {
	Items []XMLDBClusterMember `xml:"DBClusterMember"`
}

XMLDBClusterMembers is a list of DB cluster members.

type XMLDBClusters

type XMLDBClusters struct {
	Items []XMLDBCluster `xml:"DBCluster"`
}

XMLDBClusters is a list of XML DB clusters.

type XMLDBInstance

type XMLDBInstance struct {
	DBInstanceIdentifier string       `xml:"DBInstanceIdentifier"`
	DBInstanceArn        string       `xml:"DBInstanceArn"`
	DBInstanceClass      string       `xml:"DBInstanceClass"`
	Engine               string       `xml:"Engine"`
	EngineVersion        string       `xml:"EngineVersion,omitempty"`
	DBInstanceStatus     string       `xml:"DBInstanceStatus"`
	Endpoint             *XMLEndpoint `xml:"Endpoint,omitempty"`
	DBClusterIdentifier  string       `xml:"DBClusterIdentifier,omitempty"`
	InstanceCreateTime   string       `xml:"InstanceCreateTime"`
}

XMLDBInstance is the XML representation of a DocumentDB DB instance.

type XMLDBInstances

type XMLDBInstances struct {
	Items []XMLDBInstance `xml:"DBInstance"`
}

XMLDBInstances is a list of XML DB instances.

type XMLDeleteDBClusterResponse

type XMLDeleteDBClusterResponse struct {
	XMLName   xml.Name     `xml:"DeleteDBClusterResponse"`
	Xmlns     string       `xml:"xmlns,attr"`
	DBCluster XMLDBCluster `xml:"DeleteDBClusterResult>DBCluster"`
	RequestID string       `xml:"ResponseMetadata>RequestId"`
}

XMLDeleteDBClusterResponse is the XML response for DeleteDBCluster.

type XMLDeleteDBInstanceResponse

type XMLDeleteDBInstanceResponse struct {
	XMLName    xml.Name      `xml:"DeleteDBInstanceResponse"`
	Xmlns      string        `xml:"xmlns,attr"`
	DBInstance XMLDBInstance `xml:"DeleteDBInstanceResult>DBInstance"`
	RequestID  string        `xml:"ResponseMetadata>RequestId"`
}

XMLDeleteDBInstanceResponse is the XML response for DeleteDBInstance.

type XMLDescribeDBClustersResponse

type XMLDescribeDBClustersResponse struct {
	XMLName    xml.Name      `xml:"DescribeDBClustersResponse"`
	Xmlns      string        `xml:"xmlns,attr"`
	DBClusters XMLDBClusters `xml:"DescribeDBClustersResult>DBClusters"`
	RequestID  string        `xml:"ResponseMetadata>RequestId"`
}

XMLDescribeDBClustersResponse is the XML response for DescribeDBClusters.

type XMLDescribeDBInstancesResponse

type XMLDescribeDBInstancesResponse struct {
	XMLName     xml.Name       `xml:"DescribeDBInstancesResponse"`
	Xmlns       string         `xml:"xmlns,attr"`
	DBInstances XMLDBInstances `xml:"DescribeDBInstancesResult>DBInstances"`
	RequestID   string         `xml:"ResponseMetadata>RequestId"`
}

XMLDescribeDBInstancesResponse is the XML response for DescribeDBInstances.

type XMLEndpoint

type XMLEndpoint struct {
	Address string `xml:"Address"`
	Port    int32  `xml:"Port"`
}

XMLEndpoint is the XML representation of an endpoint.

type XMLError

type XMLError struct {
	Code    string `xml:"Code"`
	Message string `xml:"Message"`
}

XMLError is an XML error.

type XMLErrorResponse

type XMLErrorResponse struct {
	XMLName   xml.Name `xml:"ErrorResponse"`
	Error     XMLError `xml:"Error"`
	RequestID string   `xml:"RequestId"`
}

XMLErrorResponse is the XML error response.

type XMLModifyDBClusterResponse

type XMLModifyDBClusterResponse struct {
	XMLName   xml.Name     `xml:"ModifyDBClusterResponse"`
	Xmlns     string       `xml:"xmlns,attr"`
	DBCluster XMLDBCluster `xml:"ModifyDBClusterResult>DBCluster"`
	RequestID string       `xml:"ResponseMetadata>RequestId"`
}

XMLModifyDBClusterResponse is the XML response for ModifyDBCluster.

Jump to

Keyboard shortcuts

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