An SDK to manage the Neon Platform programmatically.
Neon is a serverless Postgres platform designed to help you build reliable and scalable applications faster. Neon separates compute and storage to offer modern developer features such as autoscaling, branching, point-in-time restore, and more. Neon is open source and written in Rust.
Find more about Neon here.
Add the SDK as a module dependency:
go get github.com/kislerdm/neon-sdk-go
Run to specify the release version:
go get github.com/kislerdm/neon-sdk-go@{{.Ver}}
Where {{.Ver}} is the release version.
The following snippet demonstrates how to initialize SDK which will use the default HTTP client.
package main
import (
"log"
neon "github.com/kislerdm/neon-sdk-go"
)
func main() {
client, err := neon.NewClient(neon.Config{Key: "{{.NeonApiKey}}"})
if err != nil {
panic(err)
}
v, err := client.ListProjects(nil, nil, nil, nil, nil, nil)
if err != nil {
panic(err)
}
log.Printf("%d projects found", len(v.Projects))
}The SDK can be initialized with a custom HTTP client.
package main
import (
"net/http"
"log"
"time"
neon "github.com/kislerdm/neon-sdk-go"
)
func main() {
myHTTPClient := &http.Client{Timeout: 30 * time.Second}
client, err := neon.NewClient(neon.Config{Key: "{{.NeonApiKey}}", HTTPClient: myHTTPClient})
if err != nil {
panic(err)
}
v, err := client.ListProjects(nil, nil, nil, nil, nil, nil)
if err != nil {
panic(err)
}
log.Printf("%d projects found", len(v.Projects))
}Find here the example of how to use the SDK to create a Neon project and use its default database afterward.
The SDK codebase is generated using the OpenAPI from the Neon API reference page. The generator application codebase can be found here.
Prerequisites:
- go ~> 1.25.12
- gnuMake / cmake
Run to see all available commands:
make help
Run to generate the SDK codebase and store it to PWD, given the OpenAPI spec is available in the
file openAPIDefinition.json:
make generate-sdk
Run to customize the locations:
make generate-sdk PATH_SDK=##/PATH/TO/OUTPUT/SDK/CODE## PATH_SPEC=##/PATH/TO/SPEC.json##
Run to test the generated SDK by making API calls:
make testacc
Note: it requires the file .env with the following content:
export NEON_API_KEY=...
Run to test generated SDK stored to /PATH/TO/OUTPUT/SDK/CODE:
make tests DIR=/PATH/TO/OUTPUT/SDK/CODE
Run to test the code generator:
make tests DIR=generator
Run to build the code generator:
make build DIR=generator
The SDK is distributed under the MIT license. You can find a full list of dependency licenses here.
Please feel free to open an issue ticket or PR to contribute.
