repositorypackage
0.0.0-20250403160001-e0ab18e5f635
Repository: https://github.com/moonwalker/gontentful.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
# README
Gontentful
Contentful client library for Go with a command line interface for schema export and data sync.
Library
Install
$ go get -u github.com/moonwalker/gontentful
Usage
Create client:
import (
"github.com/moonwalker/gontentful"
)
client := gontentful.NewClient(&gontentful.ClientOptions{
CdnURL: "cdn.contentful.com",
SpaceID: <spaceid>,
EnvironmentID: <environmentid>,
CdnToken: <cdntoken>,
})
// get entries
query := url.Values{}
query.Set("content_type", "foo")
query.Set("locale", "en")
entries, err := client.Entries.GetEntries(query)
// get entry
entry, err := client.Entries.GetSingle(<entryid>)
CLI
Install
$ go get -u github.com/moonwalker/gontentful/cmd/gfl
Usage
Schema export:
# generate postgres schema and print to stdout
$ gfl schema pg --space <spaceid> --token <token>
# generate postgres schema and execute on the specified database
$ gfl schema pg --space <spaceid> --token <token> --url postgres://user:pass@host:port/db
# generate graphql schema and print to stdout
$ gfl schema gql --space <spaceid> --token <token>
Data sync:
# sync data to postgres (init sync first then incremental)
$ gfl sync pg --space <spaceid> --token <token> --url postgres://user:pass@host:port/db
# sync data to postgres (init sync always start from scratch)
$ gfl sync pg --init --space <spaceid> --token <token> --url postgres://user:pass@host:port/db
Dependencies
Using Go modules:
$ go mod vendor
License
Licensed under the MIT License
Acknowledgements
Utilize code from contentful-go