Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/moonwalker/gontentful

Contentful client library for Go with a command line interface
https://github.com/moonwalker/gontentful

contentful golang

Last synced: about 1 month ago
JSON representation

Contentful client library for Go with a command line interface

Awesome Lists containing this project

README

        

# Gontentful

Contentful client library for Go with a command line interface for schema export and data sync.

## Library

### Install

```sh
$ go get -u github.com/moonwalker/gontentful
```

### Usage

Create client:

```sh
import (
"github.com/moonwalker/gontentful"
)

client := gontentful.NewClient(&gontentful.ClientOptions{
CdnURL: "cdn.contentful.com",
SpaceID: ,
EnvironmentID: ,
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()
```

## CLI

### Install

```sh
$ go get -u github.com/moonwalker/gontentful/cmd/gfl
```

### Usage

Schema export:

```sh
# generate postgres schema and print to stdout
$ gfl schema pg --space --token

# generate postgres schema and execute on the specified database
$ gfl schema pg --space --token --url postgres://user:pass@host:port/db

# generate graphql schema and print to stdout
$ gfl schema gql --space --token
```

Data sync:

```sh
# sync data to postgres (init sync first then incremental)
$ gfl sync pg --space --token --url postgres://user:pass@host:port/db

# sync data to postgres (init sync always start from scratch)
$ gfl sync pg --init --space --token --url postgres://user:pass@host:port/db
```

## Dependencies

Using Go modules:

```sh
$ go mod vendor
```

## License

Licensed under the [MIT License](LICENSE)

### Acknowledgements

Utilize code from [contentful-go](https://github.com/contentful-labs/contentful-go)