Documentation
¶
Overview ¶
Package aura provides a Go client library for the Neo4j Aura API.
The client supports all major Aura API operations including instance management, snapshots, tenant operations, and customer-managed encryption keys (CMEK).
Example usage:
client, err := aura.NewClient(
aura.WithCredentials("client-id", "client-secret"),
)
if err != nil {
log.Fatal(err)
}
instances, err := client.Instances.List(ctx)
Package aura provides a Go client library for the Neo4j Aura API.
Index ¶
- Constants
- type AuraAPIClient
- type CmekService
- type ConnectionMetrics
- type CreateGDSSessionConfigData
- type CreateInstanceConfigData
- type CreateInstanceData
- type CreateInstanceResponse
- type CreateSnapshotData
- type CreateSnapshotResponse
- type DeleteGDSSession
- type DeleteGDSSessionResponse
- type DeleteInstanceResponse
- type Error
- type ErrorDetail
- type GDSSessionService
- type GDSSessionSizeEstimationData
- type GDSSessionSizeEstimationResponse
- type GetCmeksData
- type GetCmeksResponse
- type GetGDSSessionData
- type GetGDSSessionListResponse
- type GetGDSSessionResponse
- type GetGDSSessionSizeEstimation
- type GetInstanceResponse
- type GetSnapshotData
- type GetSnapshotDataResponse
- type GetSnapshotsResponse
- type GetTenantMetricsURLData
- type GetTenantMetricsURLResponse
- type GetTenantResponse
- type InstanceData
- type InstanceService
- type InstanceStatus
- type ListInstanceData
- type ListInstancesResponse
- type ListTenantsResponse
- type Option
- type OverwriteInstanceResponse
- type PrometheusHealthMetrics
- type PrometheusMetric
- type PrometheusMetricsResponse
- type PrometheusService
- type QueryMetrics
- type ResourceMetrics
- type RestoreSnapshotResponse
- type SnapshotDate
- type SnapshotService
- type StorageMetrics
- type TenantInstanceConfiguration
- type TenantResponseData
- type TenantService
- type TenantsResponseData
- type UpdateInstanceData
Constants ¶
const AuraAPIClientVersion = "v1.10.0"
AuraAPIClientVersion is the current release version of this library. Updated via changie on each release.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuraAPIClient ¶
type AuraAPIClient struct {
// Grouped services — using interface types for testability.
Tenants TenantService
Instances InstanceService
Snapshots SnapshotService
Cmek CmekService
GraphAnalytics GDSSessionService
Prometheus PrometheusService
// contains filtered or unexported fields
}
AuraAPIClient is the main client for interacting with the Neo4j Aura API.
func NewClient ¶
func NewClient(opts ...Option) (*AuraAPIClient, error)
NewClient creates a new Aura API client with functional options.
type CmekService ¶ added in v1.1.0
type CmekService interface {
// List returns all customer-managed encryption keys, optionally filtered by tenant
List(ctx context.Context, tenantID string) (*GetCmeksResponse, error)
}
CmekService defines operations for customer-managed encryption keys
type ConnectionMetrics ¶ added in v1.3.1
type ConnectionMetrics struct {
ActiveConnections int `json:"active_connections"`
MaxConnections int `json:"max_connections"`
UsagePercent float64 `json:"usage_percent"`
}
ConnectionMetrics contains connection pool information.
type CreateGDSSessionConfigData ¶ added in v1.5.1
type CreateGDSSessionConfigData struct {
Name string `json:"name"`
TTL string `json:"ttl"`
TenantID string `json:"tenant_id"`
InstanceID string `json:"instance_id"`
DatabaseID string `json:"database_uuid"`
CloudProvider string `json:"cloud_provider"`
Region string `json:"region"`
Memory string `json:"memory"`
}
CreateGDSSessionConfigData holds the configuration required to create a new GDS session.
type CreateInstanceConfigData ¶
type CreateInstanceConfigData struct {
Name string `json:"name"`
TenantID string `json:"tenant_id"`
CloudProvider string `json:"cloud_provider"`
Region string `json:"region"`
Type string `json:"type"`
Version string `json:"version,omitempty"`
Memory string `json:"memory"`
}
CreateInstanceConfigData holds the configuration required to provision a new instance.
type CreateInstanceData ¶
type CreateInstanceData struct {
ID string `json:"id"`
Name string `json:"name"`
TenantID string `json:"tenant_id"`
CloudProvider string `json:"cloud_provider"`
ConnectionURL string `json:"connection_url"`
Region string `json:"region"`
Type string `json:"type"`
Username string `json:"username"`
Password string `json:"password"`
}
CreateInstanceData holds the response fields for a newly provisioned instance. It contains the database password returned by the API — treat this value as a secret and avoid logging or serialising the struct directly. The String() method redacts the password for safe use in log output.
func (CreateInstanceData) String ¶ added in v1.8.2
func (c CreateInstanceData) String() string
String implements fmt.Stringer and redacts the Password field so that accidentally logging or printing this struct never exposes credentials.
type CreateInstanceResponse ¶ added in v1.1.0
type CreateInstanceResponse struct {
Data CreateInstanceData `json:"data"`
}
CreateInstanceResponse wraps the response from a successful instance creation.
type CreateSnapshotData ¶ added in v1.1.0
type CreateSnapshotData struct {
SnapshotID string `json:"snapshot_id"`
}
CreateSnapshotData holds the snapshot ID returned after a snapshot is created.
type CreateSnapshotResponse ¶ added in v1.1.0
type CreateSnapshotResponse struct {
Data CreateSnapshotData `json:"data"`
}
CreateSnapshotResponse contains the result of creating a snapshot.
type DeleteGDSSession ¶ added in v1.5.1
type DeleteGDSSession struct {
ID string `json:"id"`
}
DeleteGDSSession holds the ID of the deleted session.
type DeleteGDSSessionResponse ¶ added in v1.5.1
type DeleteGDSSessionResponse struct {
Data DeleteGDSSession `json:"data"`
}
DeleteGDSSessionResponse wraps the response returned when a GDS session is deleted.
type DeleteInstanceResponse ¶ added in v1.6.1
type DeleteInstanceResponse struct {
Data InstanceData `json:"data"`
}
DeleteInstanceResponse wraps the response returned when an instance is deleted.
type ErrorDetail ¶ added in v1.6.0
type ErrorDetail = api.ErrorDetail
ErrorDetail represents individual error details.
type GDSSessionService ¶ added in v1.1.0
type GDSSessionService interface {
// List returns all GDS sessions accessible to the authenticated user
List(ctx context.Context) (*GetGDSSessionListResponse, error)
// Estimate the size of a GDS session
Estimate(ctx context.Context, GDSSessionSizeEstimateRequest *GetGDSSessionSizeEstimation) (*GDSSessionSizeEstimationResponse, error)
// Create a new GDS session
Create(ctx context.Context, GDSSessionConfigRequest *CreateGDSSessionConfigData) (*GetGDSSessionResponse, error)
// Get the details for a single GDS Session
Get(ctx context.Context, GDSSessionID string) (*GetGDSSessionResponse, error)
// Delete a single GDS Session
Delete(ctx context.Context, GDSSessionID string) (*DeleteGDSSessionResponse, error)
}
GDSSessionService defines operations for Graph Data Science sessions
type GDSSessionSizeEstimationData ¶ added in v1.5.1
type GDSSessionSizeEstimationData struct {
EstimatedMemory string `json:"estimated_memory"`
RecommendedSize string `json:"recommended_size"`
}
GDSSessionSizeEstimationData holds the estimated memory and recommended size tier.
type GDSSessionSizeEstimationResponse ¶ added in v1.5.1
type GDSSessionSizeEstimationResponse struct {
Data GDSSessionSizeEstimationData `json:"data"`
}
GDSSessionSizeEstimationResponse wraps the size estimation result.
type GetCmeksData ¶ added in v1.1.0
type GetCmeksData struct {
ID string `json:"id"`
Name string `json:"name"`
TenantID string `json:"tenant_id"`
}
GetCmeksData holds the fields for a single customer-managed encryption key entry.
type GetCmeksResponse ¶ added in v1.1.0
type GetCmeksResponse struct {
Data []GetCmeksData `json:"data"`
}
GetCmeksResponse contains a list of customer managed encryption keys.
type GetGDSSessionData ¶ added in v1.1.0
type GetGDSSessionData struct {
ID string `json:"id"`
Name string `json:"name"`
Memory string `json:"memory"`
InstanceID string `json:"instance_id"`
DatabaseID string `json:"database_uuid"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
Host string `json:"host"`
ExpiresAt time.Time `json:"expiry_date"`
TTL string `json:"ttl"`
UserID string `json:"user_id"`
TenantID string `json:"tenant_id"`
CloudProvider string `json:"cloud_provider"`
Region string `json:"region"`
}
GetGDSSessionData holds the fields returned for a single GDS session.
func (*GetGDSSessionData) UnmarshalJSON ¶ added in v1.10.0
func (g *GetGDSSessionData) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler for GetGDSSessionData. It parses the CreatedAt and ExpiresAt fields from the RFC3339 string format returned by the Aura API into time.Time values. Empty timestamp strings are silently ignored and leave the field at its zero value.
type GetGDSSessionListResponse ¶ added in v1.5.1
type GetGDSSessionListResponse struct {
Data []GetGDSSessionData `json:"data"`
}
GetGDSSessionListResponse contains a list of GDS sessions.
type GetGDSSessionResponse ¶ added in v1.1.0
type GetGDSSessionResponse struct {
Data GetGDSSessionData `json:"data"`
}
GetGDSSessionResponse contains information about a single GDS session.
type GetGDSSessionSizeEstimation ¶ added in v1.5.1
type GetGDSSessionSizeEstimation struct {
NodeCount int `json:"node_count"`
NodePropertyCount int `json:"node_property_count"`
NodeLabelCount int `json:"node_label_count"`
RelationshipCount int `json:"relationship_count"`
RelationshipPropertyCount int `json:"relationship_property_count"`
AlgorithmCategories []string `json:"algorithm_categories"`
}
GetGDSSessionSizeEstimation holds graph statistics used to estimate the memory requirements for a new GDS session.
type GetInstanceResponse ¶ added in v1.1.0
type GetInstanceResponse struct {
Data InstanceData `json:"data"`
}
GetInstanceResponse wraps the response for a single instance lookup.
type GetSnapshotData ¶ added in v1.1.0
type GetSnapshotData struct {
InstanceID string `json:"instance_id"`
SnapshotID string `json:"snapshot_id"`
Profile string `json:"profile"`
Status string `json:"status"`
Timestamp time.Time `json:"timestamp"`
Exportable bool `json:"exportable"`
}
GetSnapshotData holds the fields returned for a single snapshot.
func (*GetSnapshotData) UnmarshalJSON ¶ added in v1.10.0
func (s *GetSnapshotData) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler for GetSnapshotData. It parses the Timestamp field from the RFC3339 string format returned by the Aura API into a time.Time value. An empty timestamp string is silently ignored and leaves the field at its zero value.
type GetSnapshotDataResponse ¶ added in v1.4.1
type GetSnapshotDataResponse struct {
Data GetSnapshotData `json:"data"`
}
GetSnapshotDataResponse wraps the response for a single snapshot lookup.
type GetSnapshotsResponse ¶ added in v1.1.0
type GetSnapshotsResponse struct {
Data []GetSnapshotData `json:"data"`
}
GetSnapshotsResponse contains a list of snapshots for an instance.
type GetTenantMetricsURLData ¶ added in v1.5.1
type GetTenantMetricsURLData struct {
Endpoint string `json:"endpoint"`
}
GetTenantMetricsURLData holds the Prometheus endpoint URL.
type GetTenantMetricsURLResponse ¶ added in v1.5.1
type GetTenantMetricsURLResponse struct {
Data GetTenantMetricsURLData `json:"data"`
}
GetTenantMetricsURLResponse wraps the Prometheus metrics endpoint URL for a tenant.
type GetTenantResponse ¶ added in v1.1.0
type GetTenantResponse struct {
Data TenantResponseData `json:"data"`
}
GetTenantResponse contains details of a tenant.
type InstanceData ¶ added in v1.6.1
type InstanceData struct {
ID string `json:"id"`
Name string `json:"name"`
Status InstanceStatus `json:"status"`
TenantID string `json:"tenant_id"`
CloudProvider string `json:"cloud_provider"`
ConnectionURL string `json:"connection_url"`
Region string `json:"region"`
Type string `json:"type"`
Memory string `json:"memory"`
Storage *string `json:"storage"`
CDCEnrichment string `json:"cdc_enrichment_mode"`
GDSPlugin bool `json:"graph_analytics_plugin"`
MetricsURL string `json:"metrics_integration_url"`
Secondaries int `json:"secondaries_count"`
VectorOptimized bool `json:"vector_optimized"`
}
InstanceData holds the full set of fields returned for a single instance.
type InstanceService ¶ added in v1.1.0
type InstanceService interface {
// List returns all instances accessible to the authenticated user
List(ctx context.Context) (*ListInstancesResponse, error)
// Get retrieves details for a specific instance by ID
Get(ctx context.Context, instanceID string) (*GetInstanceResponse, error)
// Create provisions a new database instance
Create(ctx context.Context, instanceRequest *CreateInstanceConfigData) (*CreateInstanceResponse, error)
// Delete removes an instance by ID
Delete(ctx context.Context, instanceID string) (*DeleteInstanceResponse, error)
// Pause suspends an instance by ID
Pause(ctx context.Context, instanceID string) (*GetInstanceResponse, error)
// Resume restarts a paused instance by ID
Resume(ctx context.Context, instanceID string) (*GetInstanceResponse, error)
// Update modifies an instance's configuration
Update(ctx context.Context, instanceID string, instanceRequest *UpdateInstanceData) (*GetInstanceResponse, error)
// Overwrite replaces instance data from another instance or snapshot
OverwriteFromInstance(ctx context.Context, instanceID string, sourceInstanceID string) (*OverwriteInstanceResponse, error)
// Overwrite replaces instance data from another instance or snapshot
OverwriteFromSnapshot(ctx context.Context, instanceID string, sourceSnapshotID string) (*OverwriteInstanceResponse, error)
}
InstanceService defines operations for managing database instances
type InstanceStatus ¶ added in v1.6.4
type InstanceStatus string
InstanceStatus represents the lifecycle state of an Aura database instance.
const ( StatusRunning InstanceStatus = "running" StatusStopped InstanceStatus = "stopped" StatusPaused InstanceStatus = "paused" StatusAvailable InstanceStatus = "available" StatusCreating InstanceStatus = "creating" StatusDestroying InstanceStatus = "destroying" StatusPausing InstanceStatus = "pausing" StatusSuspending InstanceStatus = "suspending" StatusSuspended InstanceStatus = "suspended" StatusResuming InstanceStatus = "resuming" StatusLoading InstanceStatus = "loading" StatusLoadingFailed InstanceStatus = "loading failed" StatusRestoring InstanceStatus = "restoring" StatusUpdating InstanceStatus = "updating" StatusOverwriting InstanceStatus = "overwriting" // Deprecated: StatusRestroying was a misspelling. Use StatusRestoring. StatusRestroying = StatusRestoring )
Instance status constants returned by the Aura API.
type ListInstanceData ¶ added in v1.1.0
type ListInstanceData struct {
ID string `json:"id"`
Name string `json:"name"`
Created string `json:"created_at"`
TenantID string `json:"tenant_id"`
CloudProvider string `json:"cloud_provider"`
}
ListInstanceData holds the summary fields returned for each instance in a list response.
type ListInstancesResponse ¶ added in v1.1.0
type ListInstancesResponse struct {
Data []ListInstanceData `json:"data"`
}
ListInstancesResponse contains a list of instances in a tenant.
type ListTenantsResponse ¶ added in v1.1.0
type ListTenantsResponse struct {
Data []TenantsResponseData `json:"data"`
}
ListTenantsResponse contains a list of tenants in your organisation.
type Option ¶
type Option func(*options) error
Option is a functional option for configuring the AuraAPIClient.
func WithBaseURL ¶ added in v1.6.1
WithBaseURL overrides the default API base URL. Useful for staging or sandbox environments. The URL must use HTTPS to protect OAuth tokens and API credentials in transit.
func WithCredentials ¶
WithCredentials sets the client ID and secret used for OAuth authentication.
func WithInsecureBaseURL ¶ added in v1.10.0
WithInsecureBaseURL overrides the base URL without enforcing HTTPS. This is intended for local development and in-process testing only (e.g. httptest.Server). Never use this option against a real Aura environment — OAuth tokens and API credentials will be transmitted in cleartext over the network.
func WithLogger ¶
WithLogger sets a custom slog.Logger. Defaults to warn-level logging to stderr.
func WithMaxRetry ¶ added in v1.0.2
WithMaxRetry sets the maximum number of retries for failed requests. Defaults to 3.
func WithTimeout ¶
WithTimeout sets a custom API timeout. Defaults to 120 seconds.
type OverwriteInstanceResponse ¶ added in v1.1.0
type OverwriteInstanceResponse struct {
Data string `json:"data"`
}
OverwriteInstanceResponse wraps the job ID returned when an overwrite operation is started.
type PrometheusHealthMetrics ¶ added in v1.3.1
type PrometheusHealthMetrics struct {
InstanceID string `json:"instance_id"`
Timestamp time.Time `json:"timestamp"`
Resources ResourceMetrics `json:"resources"`
Query QueryMetrics `json:"query"`
Connections ConnectionMetrics `json:"connections"`
Storage StorageMetrics `json:"storage"`
OverallStatus string `json:"overall_status"`
Issues []string `json:"issues"`
Recommendations []string `json:"recommendations"`
}
PrometheusHealthMetrics contains parsed health metrics for an instance.
type PrometheusMetric ¶ added in v1.3.1
PrometheusMetric represents a single parsed metric from Prometheus exposition format.
type PrometheusMetricsResponse ¶ added in v1.3.1
type PrometheusMetricsResponse struct {
Metrics map[string][]PrometheusMetric
}
PrometheusMetricsResponse contains parsed metrics from the raw endpoint.
type PrometheusService ¶ added in v1.3.1
type PrometheusService interface {
// FetchRawMetrics fetches and parses raw Prometheus metrics from an Aura metrics endpoint
FetchRawMetrics(ctx context.Context, prometheusURL string) (*PrometheusMetricsResponse, error)
// GetMetricValue retrieves a specific metric value by name and optional label filters
GetMetricValue(ctx context.Context, metrics *PrometheusMetricsResponse, name string, labelFilters map[string]string) (float64, error)
// GetInstanceHealth retrieves comprehensive health metrics for an instance
GetInstanceHealth(ctx context.Context, instanceID string, prometheusURL string) (*PrometheusHealthMetrics, error)
}
PrometheusService defines operations for querying Prometheus metrics
type QueryMetrics ¶ added in v1.3.1
type QueryMetrics struct {
QueriesPerSecond float64 `json:"queries_per_second"`
AvgLatencyMS float64 `json:"avg_latency_ms"`
}
QueryMetrics contains query performance statistics.
type ResourceMetrics ¶ added in v1.3.1
type ResourceMetrics struct {
CPUUsagePercent float64 `json:"cpu_usage_percent"`
MemoryUsagePercent float64 `json:"memory_usage_percent"`
}
ResourceMetrics contains CPU and memory usage.
type RestoreSnapshotResponse ¶ added in v1.4.1
type RestoreSnapshotResponse struct {
Data InstanceData `json:"data"`
}
RestoreSnapshotResponse stores the response from initiating restoration of an instance using a snapshot. The response is the same as for getting instance configuration details.
type SnapshotDate ¶ added in v1.8.0
SnapshotDate is used as an optional filter when listing an instance's snapshots.
func Today ¶ added in v1.8.0
func Today() *SnapshotDate
Today returns today's date as a *SnapshotDate for use as a snapshot list filter.
type SnapshotService ¶ added in v1.1.0
type SnapshotService interface {
// List returns snapshots for an instance, optionally filtered by date (YYYY-MM-DD)
List(ctx context.Context, instanceID string, snapshotDate *SnapshotDate) (*GetSnapshotsResponse, error)
// Create triggers an on-demand snapshot for an instance
Create(ctx context.Context, instanceID string) (*CreateSnapshotResponse, error)
// Get returns details for a snapshot of an instance
Get(ctx context.Context, instanceID string, snapshotID string) (*GetSnapshotDataResponse, error)
// Restore instance from a snapshot
Restore(ctx context.Context, instanceID string, snapshotID string) (*RestoreSnapshotResponse, error)
}
SnapshotService defines operations for managing instance snapshots
type StorageMetrics ¶ added in v1.3.1
type StorageMetrics struct {
PageCacheHitRate float64 `json:"page_cache_hit_rate,omitempty"`
}
StorageMetrics contains storage usage information.
type TenantInstanceConfiguration ¶ added in v1.1.0
type TenantInstanceConfiguration struct {
CloudProvider string `json:"cloud_provider"`
Region string `json:"region"`
RegionName string `json:"region_name"`
Type string `json:"type"`
Memory string `json:"memory"`
Storage string `json:"storage"`
Version string `json:"version"`
}
TenantInstanceConfiguration describes one available instance configuration for a tenant.
type TenantResponseData ¶ added in v1.1.0
type TenantResponseData struct {
ID string `json:"id"`
Name string `json:"name"`
InstanceConfigurations []TenantInstanceConfiguration `json:"instance_configurations"`
}
TenantResponseData holds the full details returned for a single tenant.
type TenantService ¶ added in v1.1.0
type TenantService interface {
// List returns all tenants accessible to the authenticated user
List(ctx context.Context) (*ListTenantsResponse, error)
// Get retrieves details for a specific tenant by ID
Get(ctx context.Context, tenantID string) (*GetTenantResponse, error)
// GetMetrics gets URL for project level Prometheus metrics
GetMetrics(ctx context.Context, tenantID string) (*GetTenantMetricsURLResponse, error)
}
TenantService defines operations for managing tenants
type TenantsResponseData ¶ added in v1.1.0
TenantsResponseData holds the summary fields for a single tenant in a list response.
type UpdateInstanceData ¶
type UpdateInstanceData struct {
Name string `json:"name,omitempty"`
Memory string `json:"memory,omitempty"`
}
UpdateInstanceData holds the fields that can be modified on an existing instance.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
getInstanceDetails
command
Package main demonstrates retrieving details for a specific Aura instance.
|
Package main demonstrates retrieving details for a specific Aura instance. |
|
listInstances
command
Package main demonstrates listing all Aura instances.
|
Package main demonstrates listing all Aura instances. |
|
listSnapshots
command
Package main demonstrates listing snapshots for an Aura instance.
|
Package main demonstrates listing snapshots for an Aura instance. |
|
listTenants
command
Package main demonstrates listing all tenants in an Aura organisation.
|
Package main demonstrates listing all tenants in an Aura organisation. |
|
prometheus
command
Package main demonstrates querying Prometheus metrics for an Aura instance.
|
Package main demonstrates querying Prometheus metrics for an Aura instance. |
|
restoreFromSnapshot
command
Package main demonstrates restoring an Aura instance from a snapshot.
|
Package main demonstrates restoring an Aura instance from a snapshot. |
|
takesnapshot
command
Package main demonstrates creating and inspecting a snapshot for an Aura instance.
|
Package main demonstrates creating and inspecting a snapshot for an Aura instance. |
|
internal
|
|
|
api
Package api implements the authenticated HTTP request layer for the Aura API.
|
Package api implements the authenticated HTTP request layer for the Aura API. |
|
httpclient
Package httpclient provides a low-level HTTP client with configurable retry behaviour.
|
Package httpclient provides a low-level HTTP client with configurable retry behaviour. |
|
testutil
Package testutil provides mock implementations for use in tests across the aura-client module.
|
Package testutil provides mock implementations for use in tests across the aura-client module. |
|
utils
Package utils provides shared internal helpers for the aura-client module.
|
Package utils provides shared internal helpers for the aura-client module. |