aura

package module
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 15 Imported by: 0

README

Aura API Client

Overview

A Go package that enables the use of Neo4j Aura API in a friendly way e.g client.Instances.List(ctx) to return a list of instances in Aura.

Client Id and Secret are required and these can be obtained from the Neo4j Aura Console.

Table of Contents


Installation

go get github.com/LackOfMorals/aura-client

Quick Start

package main

import (
    "context"
    "log"
    aura "github.com/LackOfMorals/aura-client"
)

func main() {
    client, err := aura.NewClient(
        aura.WithCredentials("your-client-id", "your-client-secret"),
    )
    if err != nil {
        log.Fatalf("Failed to create client: %v", err)
    }

    ctx := context.Background()

    instances, err := client.Instances.List(ctx)
    if err != nil {
        log.Fatalf("Failed to list instances: %v", err)
    }

    for _, instance := range instances.Data {
        log.Printf("Instance: %s (ID: %s)\n", instance.Name, instance.Id)
    }
}

Configuration

Simple Configuration
client, err := aura.NewClient(
    aura.WithCredentials("client-id", "client-secret"),
)
Advanced Configuration
client, err := aura.NewClient(
    aura.WithCredentials("client-id", "client-secret"),
    aura.WithTimeout(60 * time.Second),
    aura.WithMaxRetry(5),
)
Custom Logger
import "log/slog"

opts := &slog.HandlerOptions{Level: slog.LevelDebug}
handler := slog.NewTextHandler(os.Stderr, opts)
logger := slog.New(handler)

client, err := aura.NewClient(
    aura.WithCredentials("client-id", "client-secret"),
    aura.WithLogger(logger),
)
Targeting a Different Base URL

Use WithBaseURL to point the client at a staging or sandbox environment:

client, err := aura.NewClient(
    aura.WithCredentials("client-id", "client-secret"),
    aura.WithBaseURL("https://api.staging.neo4j.io"),
)

Context and Timeouts

Every service method accepts a context.Context as its first argument. This is the standard Go pattern and gives you full control over cancellation and deadlines on a per-call basis.

The client is configured with a default timeout (120 seconds, overridable with WithTimeout). This timeout is applied as a ceiling on each call — if the context you pass already has a shorter deadline, that shorter deadline wins.

Basic usage
ctx := context.Background()
instances, err := client.Instances.List(ctx)
Per-call deadline
// This specific call must complete within 10 seconds
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

instance, err := client.Instances.Get(ctx, "instance-id")
Cancellation
ctx, cancel := context.WithCancel(context.Background())

// Cancel all in-flight calls (e.g. on OS signal or user action)
go func() {
    <-shutdownSignal
    cancel()
}()

instances, err := client.Instances.List(ctx)
if err != nil {
    if ctx.Err() == context.Canceled {
        log.Println("Request was cancelled")
    }
}
Distributed tracing

Because context flows through every call, you can attach trace spans from any OpenTelemetry-compatible library:

ctx, span := tracer.Start(r.Context(), "list-instances")
defer span.End()

instances, err := client.Instances.List(ctx)

Tenant Operations

List All Tenants
ctx := context.Background()

tenants, err := client.Tenants.List(ctx)
if err != nil {
    log.Fatalf("Error: %v", err)
}

for _, tenant := range tenants.Data {
    fmt.Printf("Tenant: %s (ID: %s)\n", tenant.Name, tenant.Id)
}
Get Tenant Details
ctx := context.Background()

tenant, err := client.Tenants.Get(ctx, "your-tenant-id")
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Tenant: %s\n", tenant.Data.Name)
fmt.Printf("Available instance configurations:\n")

for _, config := range tenant.Data.InstanceConfigurations {
    fmt.Printf("  - %s in %s: %s memory, Type: %s\n",
        config.CloudProvider,
        config.RegionName,
        config.Memory,
        config.Type,
    )
}

Instance Operations

List All Instances
ctx := context.Background()

instances, err := client.Instances.List(ctx)
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Found %d instances:\n", len(instances.Data))
for _, instance := range instances.Data {
    fmt.Printf("  - %s (ID: %s) on %s\n",
        instance.Name,
        instance.Id,
        instance.CloudProvider,
    )
}
Get Instance Details
ctx := context.Background()

instance, err := client.Instances.Get(ctx, "your-instance-id")
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Instance: %s\n", instance.Data.Name)
fmt.Printf("Status: %s\n", instance.Data.Status)
fmt.Printf("Connection URL: %s\n", instance.Data.ConnectionUrl)
fmt.Printf("Memory: %s\n", instance.Data.Memory)
fmt.Printf("Type: %s\n", instance.Data.Type)
fmt.Printf("Region: %s\n", instance.Data.Region)
Create a New Instance
ctx := context.Background()

config := &aura.CreateInstanceConfigData{
    Name:          "my-neo4j-db",
    TenantId:      "your-tenant-id",
    CloudProvider: "gcp",
    Region:        "europe-west1",
    Type:          "enterprise-db",
    Version:       "5",
    Memory:        "8GB",
}

instance, err := client.Instances.Create(ctx, config)
if err != nil {
    log.Fatalf("Error creating instance: %v", err)
}

fmt.Printf("Instance created!\n")
fmt.Printf("  ID: %s\n", instance.Data.Id)
fmt.Printf("  Connection URL: %s\n", instance.Data.ConnectionUrl)
fmt.Printf("  Username: %s\n", instance.Data.Username)
fmt.Printf("  Password: %s\n", instance.Data.Password)

// ⚠️ IMPORTANT: Save these credentials securely!
// The password is only shown once during creation.
Update an Instance
ctx := context.Background()

updateData := &aura.UpdateInstanceData{
    Name:   "my-renamed-instance",
    Memory: "16GB",
}

instance, err := client.Instances.Update(ctx, "instance-id", updateData)
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Instance updated: %s with %s memory\n",
    instance.Data.Name,
    instance.Data.Memory,
)
Pause an Instance
ctx := context.Background()

instance, err := client.Instances.Pause(ctx, "instance-id")
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Instance paused. Status: %s\n", instance.Data.Status)
Resume an Instance
ctx := context.Background()

instance, err := client.Instances.Resume(ctx, "instance-id")
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Instance resumed. Status: %s\n", instance.Data.Status)
Delete an Instance
ctx := context.Background()

// ⚠️ WARNING: This is irreversible!
instance, err := client.Instances.Delete(ctx, "instance-to-delete")
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Instance %s deleted\n", instance.Data.Id)
Overwrite Instance from Another Instance
ctx := context.Background()

result, err := client.Instances.Overwrite(ctx, "target-instance-id", "source-instance-id", "")
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Overwrite initiated: %s\n", result.Data)
// Note: This is asynchronous. Monitor instance status.
Overwrite Instance from Snapshot
ctx := context.Background()

result, err := client.Instances.Overwrite(ctx, "target-instance-id", "", "snapshot-id")
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Overwrite from snapshot initiated\n")

Snapshot Operations

List Snapshots
ctx := context.Background()

// Empty date string returns today's snapshots
snapshots, err := client.Snapshots.List(ctx, "your-instance-id", "")
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Found %d snapshots:\n", len(snapshots.Data))
for _, snapshot := range snapshots.Data {
    fmt.Printf("  - ID: %s, Profile: %s, Status: %s\n",
        snapshot.SnapshotId,
        snapshot.Profile,
        snapshot.Status,
    )
}
List Snapshots for a Specific Date
ctx := context.Background()

snapshots, err := client.Snapshots.List(ctx, "your-instance-id", "2024-01-15")
if err != nil {
    log.Fatalf("Error: %v", err)
}

for _, snapshot := range snapshots.Data {
    fmt.Printf("  - %s at %s\n", snapshot.SnapshotId, snapshot.Timestamp)
}
Get Snapshot Details
ctx := context.Background()

snapshot, err := client.Snapshots.Get(ctx, "your-instance-id", "your-snapshot-id")
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Instance ID: %s\nSnapshot ID: %s\nStatus: %s\nTimestamp: %s\n",
    snapshot.Data.InstanceId,
    snapshot.Data.SnapshotId,
    snapshot.Data.Status,
    snapshot.Data.Timestamp,
)
Create an On-Demand Snapshot
ctx := context.Background()

snapshot, err := client.Snapshots.Create(ctx, "your-instance-id")
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Snapshot creation initiated. Snapshot ID: %s\n", snapshot.Data.SnapshotId)
// Note: Snapshot creation is asynchronous. Poll List() to check completion status.
Restore from a Snapshot
ctx := context.Background()

result, err := client.Snapshots.Restore(ctx, "your-instance-id", "your-snapshot-id")
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Instance ID: %s\nStatus: %s\n", result.Data.Id, result.Data.Status)

CMEK Operations

List Customer Managed Encryption Keys
ctx := context.Background()

// Pass an empty string to list all CMEKs regardless of tenant
cmeks, err := client.Cmek.List(ctx, "")
if err != nil {
    log.Fatalf("Error: %v", err)
}

for _, cmek := range cmeks.Data {
    fmt.Printf("  - %s (ID: %s) in tenant %s\n", cmek.Name, cmek.Id, cmek.TenantId)
}
Filter CMEKs by Tenant
ctx := context.Background()

cmeks, err := client.Cmek.List(ctx, "your-tenant-id")
if err != nil {
    log.Fatalf("Error: %v", err)
}

for _, cmek := range cmeks.Data {
    fmt.Printf("  - %s\n", cmek.Name)
}

GDS Session Operations

List Graph Data Science Sessions
ctx := context.Background()

sessions, err := client.GraphAnalytics.List(ctx)
if err != nil {
    log.Fatalf("Error: %v", err)
}

for _, session := range sessions.Data {
    fmt.Printf("  - %s (ID: %s)\n", session.Name, session.Id)
    fmt.Printf("    Memory: %s, Status: %s\n", session.Memory, session.Status)
    fmt.Printf("    Instance: %s, Expires: %s\n", session.InstanceId, session.Expiry)
}

Prometheus Metrics Operations

Each Aura instance exposes Prometheus metrics for monitoring.

Get the Prometheus URL for an Instance
ctx := context.Background()

instance, err := client.Instances.Get(ctx, "your-instance-id")
if err != nil {
    log.Fatalf("Error: %v", err)
}

prometheusURL := instance.Data.MetricsURL
Get Instance Health Metrics
ctx := context.Background()

health, err := client.Prometheus.GetInstanceHealth(ctx, "your-instance-id", prometheusURL)
if err != nil {
    log.Fatalf("Error: %v", err)
}

fmt.Printf("Health Status: %s\n", health.OverallStatus)
fmt.Printf("CPU Usage: %.2f%%\n", health.Resources.CPUUsagePercent)
fmt.Printf("Memory Usage: %.2f%%\n", health.Resources.MemoryUsagePercent)
fmt.Printf("Queries/sec: %.2f\n", health.Query.QueriesPerSecond)
fmt.Printf("Active Connections: %d/%d (%.1f%%)\n",
    health.Connections.ActiveConnections,
    health.Connections.MaxConnections,
    health.Connections.UsagePercent,
)

if len(health.Issues) > 0 {
    fmt.Println("\nIssues detected:")
    for _, issue := range health.Issues {
        fmt.Printf("  - %s\n", issue)
    }
}

if len(health.Recommendations) > 0 {
    fmt.Println("\nRecommendations:")
    for _, rec := range health.Recommendations {
        fmt.Printf("  - %s\n", rec)
    }
}

For more detailed information on Prometheus operations, see the Prometheus documentation.


Error Handling

Basic Error Handling
ctx := context.Background()

instance, err := client.Instances.Get(ctx, "instance-id")
if err != nil {
    log.Printf("Error: %v\n", err)
    return
}
Typed API Errors
ctx := context.Background()

instance, err := client.Instances.Get(ctx, "non-existent-id")
if err != nil {
    if apiErr, ok := err.(*aura.Error); ok {
        fmt.Printf("API Error %d: %s\n", apiErr.StatusCode, apiErr.Message)

        switch {
        case apiErr.IsNotFound():
            fmt.Println("Instance not found")
        case apiErr.IsUnauthorized():
            fmt.Println("Authentication failed - check credentials")
        case apiErr.IsBadRequest():
            fmt.Println("Invalid request parameters")
        }

        if apiErr.HasMultipleErrors() {
            fmt.Println("All errors:")
            for _, msg := range apiErr.AllErrors() {
                fmt.Printf("  - %s\n", msg)
            }
        }
        return
    }

    log.Printf("Unexpected error: %v\n", err)
    return
}
Context Errors
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

instances, err := client.Instances.List(ctx)
if err != nil {
    switch ctx.Err() {
    case context.DeadlineExceeded:
        log.Println("Request timed out")
    case context.Canceled:
        log.Println("Request was cancelled")
    default:
        log.Printf("Error: %v\n", err)
    }
    return
}

Best Practices

1. Secure Credential Management
clientID := os.Getenv("AURA_CLIENT_ID")
clientSecret := os.Getenv("AURA_CLIENT_SECRET")

if clientID == "" || clientSecret == "" {
    log.Fatal("Missing AURA credentials in environment")
}

client, err := aura.NewClient(
    aura.WithCredentials(clientID, clientSecret),
)
2. Save Instance Credentials Immediately After Creation
ctx := context.Background()

instance, err := client.Instances.Create(ctx, config)
if err != nil {
    log.Fatal(err)
}

// ⚠️ CRITICAL: Save these immediately — they are only shown once!
credentials := map[string]string{
    "instance_id":    instance.Data.Id,
    "connection_url": instance.Data.ConnectionUrl,
    "username":       instance.Data.Username,
    "password":       instance.Data.Password,
}
// Store in a secrets manager. Do NOT log passwords in production.
3. Polling for Async Operations
ctx := context.Background()

instanceID := newInstance.Data.Id

for range 30 {
    inst, err := client.Instances.Get(ctx, instanceID)
    if err != nil {
        log.Printf("Error checking status: %v", err)
    } else if inst.Data.Status == aura.StatusRunning {
        fmt.Println("Instance is ready!")
        break
    } else {
        fmt.Printf("Status: %s, waiting...\n", inst.Data.Status)
    }
    time.Sleep(10 * time.Second)
}
4. Graceful Shutdown
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)

go func() {
    <-sigChan
    fmt.Println("\nShutting down gracefully...")
    cancel()
}()

// Pass ctx to any in-flight calls — they will be cancelled on signal
instances, err := client.Instances.List(ctx)
5. Retry Logic for Transient Failures
func retryOperation(maxRetries int, fn func() error) error {
    var err error
    for i := range maxRetries {
        err = fn()
        if err == nil {
            return nil
        }

        if apiErr, ok := err.(*aura.Error); ok {
            // Don't retry client errors (4xx except 429 Too Many Requests)
            if apiErr.StatusCode >= 400 && apiErr.StatusCode < 500 && apiErr.StatusCode != 429 {
                return err
            }
        }

        wait := time.Duration(math.Pow(2, float64(i))) * time.Second
        fmt.Printf("Attempt %d failed, retrying in %v...\n", i+1, wait)
        time.Sleep(wait)
    }
    return fmt.Errorf("operation failed after %d retries: %w", maxRetries, err)
}

// Usage
ctx := context.Background()
err := retryOperation(3, func() error {
    _, err := client.Instances.List(ctx)
    return err
})

Complete Example Application

package main

import (
    "context"
    "fmt"
    "log"
    "os"
    "time"

    aura "github.com/LackOfMorals/aura-client"
)

func main() {
    clientID := os.Getenv("AURA_CLIENT_ID")
    clientSecret := os.Getenv("AURA_CLIENT_SECRET")
    tenantID := os.Getenv("AURA_TENANT_ID")

    if clientID == "" || clientSecret == "" {
        log.Fatal("Missing required environment variables")
    }

    client, err := aura.NewClient(
        aura.WithCredentials(clientID, clientSecret),
        aura.WithTimeout(120 * time.Second),
    )
    if err != nil {
        log.Fatalf("Failed to create client: %v", err)
    }

    ctx := context.Background()

    fmt.Println("=== Current Instances ===")
    instances, err := client.Instances.List(ctx)
    if err != nil {
        log.Fatalf("Failed to list instances: %v", err)
    }

    for _, inst := range instances.Data {
        fmt.Printf("- %s: %s (%s)\n", inst.Name, inst.Id, inst.CloudProvider)
    }

    if tenantID != "" {
        fmt.Println("\n=== Tenant Configuration ===")
        tenant, err := client.Tenants.Get(ctx, tenantID)
        if err != nil {
            log.Printf("Warning: Could not get tenant: %v", err)
        } else {
            fmt.Printf("Tenant: %s\n", tenant.Data.Name)
            fmt.Printf("Available configurations: %d\n", len(tenant.Data.InstanceConfigurations))
        }
    }

    fmt.Println("\n✓ Client is working correctly!")
}

Run with:

export AURA_CLIENT_ID="your-client-id"
export AURA_CLIENT_SECRET="your-client-secret"
export AURA_TENANT_ID="your-tenant-id"
go run main.go

Migration from v1.x

Breaking Changes in v2.0
1. context.Context is now required on every service call

The most significant change. Contexts are no longer stored inside the client at construction time — they flow through each individual call instead. This follows the standard Go convention and enables per-call cancellation, deadlines, and distributed tracing.

Before (v1.x):

client, _ := aura.NewClient(
    aura.WithCredentials(id, secret),
    aura.   // ❌ Removed
)

instances, err := client.Instances.List()
tenant, err := client.Tenants.Get(tenantID)

After (v2.0):

client, _ := aura.NewClient(
    aura.WithCredentials(id, secret),
    // No WithContext — pass ctx to each call instead
)

ctx := context.Background()

instances, err := client.Instances.List(ctx)
tenant, err := client.Tenants.Get(ctx, tenantID)

The quickest way to find all call sites is:

grep -rn "client\.\(Instances\|Tenants\|Snapshots\|Cmek\|GraphAnalytics\|Prometheus\)\." ./
2. WithContext option removed

WithContext has been removed from NewClient. Pass a context directly to each service method instead (see above).

3. WithBaseURL option added

A new WithBaseURL option is available for targeting non-production environments:

client, _ := aura.NewClient(
    aura.WithCredentials(id, secret),
    aura.WithBaseURL("https://api.staging.neo4j.io"),
)
Migration Steps
Step 1: Update the dependency
go get github.com/LackOfMorals/[email protected]
go mod tidy
Step 2: Remove WithContext from NewClient
// Before
client, _ := aura.NewClient(
    aura.WithCredentials(id, secret),
    aura.  // remove this line
)

// After
client, _ := aura.NewClient(
    aura.WithCredentials(id, secret),
)
Step 3: Add ctx to every service call

Add ctx as the first argument to every method call. If you don't have a specific context, use context.Background():

ctx := context.Background()

// Before
instances, err := client.Instances.List()
instance, err := client.Instances.Get(id)
instance, err := client.Instances.Create(config)
instance, err := client.Instances.Delete(id)
instance, err := client.Instances.Pause(id)
instance, err := client.Instances.Resume(id)
instance, err := client.Instances.Update(id, data)
result, err  := client.Instances.Overwrite(id, srcID, snapID)

tenants, err := client.Tenants.List()
tenant, err  := client.Tenants.Get(id)
metrics, err := client.Tenants.GetMetrics(id)

snapshots, err := client.Snapshots.List(id, date)
snapshot, err  := client.Snapshots.Get(id, snapID)
snapshot, err  := client.Snapshots.Create(id)
result, err    := client.Snapshots.Restore(id, snapID)

cmeks, err := client.Cmek.List(tenantID)

sessions, err := client.GraphAnalytics.List()
session, err  := client.GraphAnalytics.Get(id)
session, err  := client.GraphAnalytics.Create(config)
estimate, err := client.GraphAnalytics.Estimate(req)
result, err   := client.GraphAnalytics.Delete(id)

raw, err    := client.Prometheus.FetchRawMetrics(url)
val, err    := client.Prometheus.GetMetricValue(raw, name, filters)
health, err := client.Prometheus.GetInstanceHealth(id, url)

// After
instances, err := client.Instances.List(ctx)
instance, err := client.Instances.Get(ctx, id)
instance, err := client.Instances.Create(ctx, config)
instance, err := client.Instances.Delete(ctx, id)
instance, err := client.Instances.Pause(ctx, id)
instance, err := client.Instances.Resume(ctx, id)
instance, err := client.Instances.Update(ctx, id, data)
result, err  := client.Instances.Overwrite(ctx, id, srcID, snapID)

tenants, err := client.Tenants.List(ctx)
tenant, err  := client.Tenants.Get(ctx, id)
metrics, err := client.Tenants.GetMetrics(ctx, id)

snapshots, err := client.Snapshots.List(ctx, id, date)
snapshot, err  := client.Snapshots.Get(ctx, id, snapID)
snapshot, err  := client.Snapshots.Create(ctx, id)
result, err    := client.Snapshots.Restore(ctx, id, snapID)

cmeks, err := client.Cmek.List(ctx, tenantID)

sessions, err := client.GraphAnalytics.List(ctx)
session, err  := client.GraphAnalytics.Get(ctx, id)
session, err  := client.GraphAnalytics.Create(ctx, config)
estimate, err := client.GraphAnalytics.Estimate(ctx, req)
result, err   := client.GraphAnalytics.Delete(ctx, id)

raw, err    := client.Prometheus.FetchRawMetrics(ctx, url)
val, err    := client.Prometheus.GetMetricValue(ctx, raw, name, filters)
health, err := client.Prometheus.GetInstanceHealth(ctx, id, url)
Step 4: Verify
go build ./...
go test ./...
Quick Migration Checklist
  • go get github.com/LackOfMorals/[email protected] and go mod tidy
  • Remove aura.WithContext(...) from all NewClient calls
  • Add ctx as first argument to every service method call
  • Ensure context is imported wherever service calls are made
  • go build ./... — fix any remaining compilation errors
  • go test ./...

Additional Resources


Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

See LICENSE file for details.

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)

types.go - Exported error types for use by consumers

interfaces.go

Index

Constants

View Source
const (
	StatusRunning   = "running"
	StatusStopped   = "stopped"
	StatusPaused    = "paused"
	StatusAvailable = "available"
)

instance status values that we're interested in

View Source
const AuraAPIClientVersion = "v1.6.1"

Currently set manually to match changie latest

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"`
}

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"`
	Memory        string `json:"memory"`
}

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"`
}

type CreateInstanceResponse added in v1.1.0

type CreateInstanceResponse struct {
	Data CreateInstanceData `json:"data"`
}

type CreateSnapshotData added in v1.1.0

type CreateSnapshotData struct {
	SnapshotId string `json:"snapshot_id"`
}

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"`
}

type DeleteGDSSessionResponse added in v1.5.1

type DeleteGDSSessionResponse struct {
	Data DeleteGDSSession `json:"data"`
}

type DeleteInstanceResponse added in v1.6.1

type DeleteInstanceResponse struct {
	Data InstanceData `json:"data"`
}

type Error added in v1.6.0

type Error = api.Error

Error represents an error response from the Aura API

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"`
}

type GDSSessionSizeEstimationResponse added in v1.5.1

type GDSSessionSizeEstimationResponse struct {
	Data GDSSessionSizeEstimationData `json:"data"`
}

type GetCmeksData added in v1.1.0

type GetCmeksData struct {
	Id       string `json:"id"`
	Name     string `json:"name"`
	TenantId string `json:"tenant_id"`
}

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"`
	Create        string `json:"created_at"`
	Host          string `json:"host"`
	Expiry        string `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"`
}

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"`
}

type GetInstanceResponse added in v1.1.0

type GetInstanceResponse struct {
	Data InstanceData `json:"data"`
}

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  string `json:"timestamp"`
	Exportable bool   `json:"exportable"`
}

type GetSnapshotDataResponse added in v1.4.1

type GetSnapshotDataResponse struct {
	Data GetSnapshotData `json:"data"`
}

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"`
}

type GetTenantMetricsURLResponse added in v1.5.1

type GetTenantMetricsURLResponse struct {
	Data GetTenantMetricsURLData `json:"data"`
}

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          string  `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"`
}

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
	Overwrite(ctx context.Context, instanceID string, sourceInstanceID string, sourceSnapshotID string) (*OverwriteInstanceResponse, error)
}

InstanceService defines operations for managing database instances

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"`
}

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

func WithBaseURL(baseURL string) Option

WithBaseURL overrides the default API base URL. Useful for staging or sandbox environments.

func WithCredentials

func WithCredentials(clientID, clientSecret string) Option

WithCredentials sets both client ID and secret

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets a custom logger (optional)

func WithMaxRetry added in v1.0.2

func WithMaxRetry(maxRetry int) Option

WithMaxRetry sets a custom max number of retries (optional)

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets a custom API timeout (optional)

type OverwriteInstanceResponse added in v1.1.0

type OverwriteInstanceResponse struct {
	Data string `json:"data"`
}

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

type PrometheusMetric struct {
	Name      string
	Labels    map[string]string
	Value     float64
	Timestamp int64
}

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 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 string) (*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"`
}

type TenantResponseData added in v1.1.0

type TenantResponseData struct {
	Id                     string                        `json:"id"`
	Name                   string                        `json:"name"`
	InstanceConfigurations []TenantInstanceConfiguration `json:"instance_configurations"`
}

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

type TenantsResponseData struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

type UpdateInstanceData

type UpdateInstanceData struct {
	Name   string `json:"name"`
	Memory string `json:"memory"`
}

Directories

Path Synopsis
internal
api

Jump to

Keyboard shortcuts

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