gontentful

package module
v0.0.0-...-928302f Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 30 Imported by: 0

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/james-elicx/gontentful
Usage

Create client:

import (
	"github.com/james-elicx/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/james-elicx/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

Documentation

Index

Constants

View Source
const (
	ASSET              = "Asset"
	DELETED_ASSET      = "DeletedAsset"
	ASSET_TABLE_NAME   = "_asset"
	ASSET_DISPLAYFIELD = "title"
	IMAGE_FOLDER_NAME  = "_images"
)
View Source
const (
	CONTENT_TYPE         = "ContentType"
	DELETED_CONTENT_TYPE = "DeletedContentType"
)
View Source
const (
	ENTRY         = "Entry"
	DELETED_ENTRY = "DeletedEntry"
)
View Source
const (
	LINK  = "Link"
	ARRAY = "Array"
)
View Source
const (
	DefaultLocale = "en"
)

Variables

This section is empty.

Functions

func GetAssetImageURL

func GetAssetImageURL(entry *Entry, imageURLs map[string]string)

func GetBlob

func GetBlob(repo string, path string, file string) (*string, error)

func GetBlobURL

func GetBlobURL(repo string, path string, file string) (string, error)

func GetCMSEntries

func GetCMSEntries(contentType string, repo string, include int) (*Entries, *ContentTypes, error)

func GetCloudflareImagesID

func GetCloudflareImagesID(repoName string) string

func GetContentfulType

func GetContentfulType(fieldType string) string

func GetImageFileName

func GetImageFileName(fileName string, sysId string, locale string) string

func GetLocalContentsRecursive

func GetLocalContentsRecursive(path string) ([]*github.RepositoryContent, error)

func GetSyncToken

func GetSyncToken(databaseURL string, schemaName string) (string, error)

func IsVideoFile

func IsVideoFile(fileName string) bool

func MigrateGamesPGSQL

func MigrateGamesPGSQL(databaseURL string, newSchemaName string, contentSchemaName string, locales []*Locale, types []*ContentType, cmaTypes []*ContentType, entries []*Entry, syncToken string) error

func MigratePGSQL

func MigratePGSQL(databaseURL string, newSchemaName string, locales []*Locale, types []*ContentType, cmaTypes []*ContentType, entries []*Entry, syncToken string, createFunctions bool, incrementalMigration bool) error

func NewPGSQLTable

func NewPGSQLTable(item *ContentType, items map[string]*ContentType, includeDepth int64) (*PGSQLTable, []*PGSQLTable, []*PGSQLReference, []*PGSQLDependency, *PGSQLProcedure)

func PublishCFChanges

func PublishCFChanges(repo string, entries []gh.BlobEntry) (github.Rate, error)

func SaveSyncToken

func SaveSyncToken(databaseURL string, schemaName string, token string) error

func SwapSchemas

func SwapSchemas(databaseURL string, schemaName string, oldSchemaName string, newSchemaName string) error

func TransformEntry

func TransformEntry(locales []*Locale, model *Entry, brand string, fmtVideoURL func(string) string) map[string]*content.ContentData

func TransformModel

func TransformModel(model *ContentType) *content.Schema

func TransformPublishedEntry

func TransformPublishedEntry(locales []*Locale, model *PublishedEntry, localizedFields map[string]bool, brand string, fmtVideoURL func(string) string) map[string]*content.ContentData

Types

type APIError

type APIError struct {
	// contains filtered or unexported fields
}

APIError model

type AccessDeniedError

type AccessDeniedError struct{}

type AccessTokenInvalidError

type AccessTokenInvalidError struct {
	APIError
}

AccessTokenInvalidError for 401 errors

func (AccessTokenInvalidError) Error

func (e AccessTokenInvalidError) Error() string

type AssetFields

type AssetFields struct {
	Title map[string]string
	File  map[string]*AssetFile
}

type AssetFile

type AssetFile struct {
	URL         string `json:"url"`
	FileName    string `json:"fileName"`
	ContentType string `json:"contentType"`
	Details     struct {
		Size  int `json:"size"`
		Image struct {
			Width  int `json:"width"`
			Height int `json:"height"`
		} `json:"image"`
	} `json:"details"`
}

type AssetsService

type AssetsService service

func (*AssetsService) Create

func (s *AssetsService) Create(body []byte) ([]byte, error)

func (*AssetsService) GetEntries

func (s *AssetsService) GetEntries(query url.Values) (*Entries, error)

func (*AssetsService) GetSingle

func (s *AssetsService) GetSingle(id string) ([]byte, error)

func (*AssetsService) Process

func (s *AssetsService) Process(id string, locale string) ([]byte, error)

func (*AssetsService) Publish

func (s *AssetsService) Publish(id string, version string) ([]byte, error)

type BadRequestError

type BadRequestError struct{}

type Client

type Client struct {
	Options      *ClientOptions
	AfterRequest func(c *Client, req *http.Request, res *http.Response, elapsed time.Duration)

	Entries      *EntriesService
	Spaces       *SpacesService
	Locales      *LocalesService
	Assets       *AssetsService
	Uploads      *UploadsService
	ContentTypes *ContentTypesService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options *ClientOptions) *Client

type ClientOptions

type ClientOptions struct {
	OrgID         string
	SpaceID       string
	EnvironmentID string
	CdnToken      string
	PreviewToken  string
	CmaToken      string
	CdnURL        string
	PreviewURL    string
	CmaURL        string
	UsePreview    bool
}

type Config

type Config struct {
	Token   string
	WorkDir string `json:"workdir" yaml:"workdir"`
}

type ContentType

type ContentType struct {
	Sys          *Sys                `json:"sys"`
	Name         string              `json:"name,omitempty"`
	Description  string              `json:"description,omitempty"`
	Fields       []*ContentTypeField `json:"fields,omitempty"`
	DisplayField string              `json:"displayField,omitempty"`
}

func GetCMSSchema

func GetCMSSchema(repo string, ct string) (*ContentType, error)

type ContentTypeField

type ContentTypeField struct {
	ID           string                 `json:"id,omitempty"`
	Name         string                 `json:"name"`
	Type         string                 `json:"type"`
	LinkType     string                 `json:"linkType,omitempty"`
	Items        *FieldTypeArrayItem    `json:"items,omitempty"`
	Required     bool                   `json:"required,omitempty"`
	Localized    bool                   `json:"localized,omitempty"`
	Disabled     bool                   `json:"disabled,omitempty"`
	Omitted      bool                   `json:"omitted,omitempty"`
	Validations  []*FieldValidation     `json:"validations,omitempty"`
	DefaultValue map[string]interface{} `json:"defaultValue,omitempty"`
}

type ContentTypes

type ContentTypes struct {
	Total int            `json:"total"`
	Limit int            `json:"limit"`
	Skip  int            `json:"skip"`
	Items []*ContentType `json:"items"`
}

func GetCMSSchemas

func GetCMSSchemas(repo string, ct string) (*ContentTypes, error)

func GetCMSSchemasExpanded

func GetCMSSchemasExpanded(repo string, ct string) (*ContentTypes, error)

type ContentTypesService

type ContentTypesService service

func (*ContentTypesService) Create

func (s *ContentTypesService) Create(contentType string, body []byte) ([]byte, error)

func (*ContentTypesService) Delete

func (s *ContentTypesService) Delete(contentType string) ([]byte, error)

func (*ContentTypesService) Get

func (s *ContentTypesService) Get(query url.Values) ([]byte, error)

func (*ContentTypesService) GetCMATypes

func (s *ContentTypesService) GetCMATypes() (*ContentTypes, error)

func (*ContentTypesService) GetSingle

func (s *ContentTypesService) GetSingle(contentTypeId string) ([]byte, error)

func (*ContentTypesService) GetSingleCMA

func (s *ContentTypesService) GetSingleCMA(contentTypeId string) (*ContentType, error)

func (*ContentTypesService) GetTypes

func (s *ContentTypesService) GetTypes() (*ContentTypes, error)

func (*ContentTypesService) Publish

func (s *ContentTypesService) Publish(contentType string, version string) ([]byte, error)

func (*ContentTypesService) UnPublish

func (s *ContentTypesService) UnPublish(contentType string) ([]byte, error)

func (*ContentTypesService) Update

func (s *ContentTypesService) Update(contentType string, body []byte, version string) ([]byte, error)

type CreateSpace

type CreateSpace struct {
	Name          string `json:"name"`
	DefaultLocale string `json:"defaultLocale"`
}

type Entries

type Entries struct {
	Sys      *Sys     `json:"sys"`
	Total    int      `json:"total"`
	Skip     int      `json:"skip"`
	Limit    int      `json:"limit"`
	Items    []*Entry `json:"items"`
	Includes *Include `json:"includes,omitempty"`
}

func GetCMSEntry

func GetCMSEntry(contentType string, repo string, name string, locales []*Locale, include int) (*Entries, error)

type EntriesService

type EntriesService service

func (*EntriesService) Archive

func (s *EntriesService) Archive(entryId string, version string) ([]byte, error)

func (*EntriesService) Create

func (s *EntriesService) Create(contentType string, body []byte) ([]byte, error)

func (*EntriesService) Delete

func (s *EntriesService) Delete(entryId string, version string) ([]byte, error)

func (*EntriesService) Get

func (s *EntriesService) Get(query url.Values) ([]byte, error)

func (*EntriesService) GetEntries

func (s *EntriesService) GetEntries(query url.Values) (*Entries, error)

func (*EntriesService) GetSingle

func (s *EntriesService) GetSingle(entryId string) ([]byte, error)

func (*EntriesService) Publish

func (s *EntriesService) Publish(entryId string, version string) ([]byte, error)

func (*EntriesService) UnArchive

func (s *EntriesService) UnArchive(entryId string, version string) ([]byte, error)

func (*EntriesService) UnPublish

func (s *EntriesService) UnPublish(entryId string, version string) ([]byte, error)

func (*EntriesService) Update

func (s *EntriesService) Update(version string, entryId string, body []byte) ([]byte, error)

type Entry

type Entry struct {
	Sys    *Sys   `json:"sys"`
	Locale string `json:"locale,omitempty"`
	Fields Fields `json:"fields,omitempty"` // fields are dynamic
}

func FormatData

func FormatData(contentType string, id string, schemas map[string]*content.Schema, locData map[string]map[string]map[string]content.ContentData) (*Entry, map[string]string, error)

type ErrorDetail

type ErrorDetail struct {
	ID      string      `json:"id,omitempty"`
	Name    string      `json:"name,omitempty"`
	Path    interface{} `json:"path,omitempty"`
	Details string      `json:"details,omitempty"`
	Value   interface{} `json:"value,omitempty"`
}

ErrorDetail model

type ErrorDetails

type ErrorDetails struct {
	Errors []*ErrorDetail `json:"errors,omitempty"`
}

ErrorDetails model

type ErrorResponse

type ErrorResponse struct {
	Sys       *Sys          `json:"sys"`
	Message   string        `json:"message,omitempty"`
	RequestID string        `json:"requestId,omitempty"`
	Details   *ErrorDetails `json:"details,omitempty"`
}

ErrorResponse model

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

type FieldTypeArrayItem

type FieldTypeArrayItem struct {
	Type        string             `json:"type,omitempty"`
	Validations []*FieldValidation `json:"validations,omitempty"`
	LinkType    string             `json:"linkType,omitempty"`
}

type FieldValidation

type FieldValidation struct {
	LinkContentType   []string          `json:"linkContentType"`
	LinkMimetypeGroup []string          `json:"linkMimetypeGroup"`
	Unique            bool              `json:"unique"`
	In                []string          `json:"in,omitempty"`
	Size              *RangeValidation  `json:"size,omitempty"`
	Range             *RangeValidation  `json:"range,omitempty"`
	Regexp            *RegexpValidation `json:"regexp,omitempty"`
}

type Fields

type Fields map[string]interface{}

type GHDelete

type GHDelete struct {
	FolderName string
	FileName   string
	SysID      string
	Locales    []*Locale
}

func NewGHDelete

func NewGHDelete(sys *Sys, filaName string, locales *Locales) *GHDelete

func (*GHDelete) Exec

func (s *GHDelete) Exec(repo string) ([]gh.BlobEntry, error)

type GHDeleteContentType

type GHDeleteContentType struct {
	FolderName string
	SysID      string
}

func NewGHDeleteContentType

func NewGHDeleteContentType(sys *Sys) *GHDeleteContentType

func (*GHDeleteContentType) Exec

func (s *GHDeleteContentType) Exec(repo string) error

type GHPublish

type GHPublish struct {
	Entry           *PublishedEntry
	RepoName        string
	FileName        string
	Locales         []*Locale
	LocalizedFields map[string]bool
}

func NewGHPublish

func NewGHPublish(entry *PublishedEntry, repoName, fileName string, locales *Locales, localizedFields map[string]bool) *GHPublish

func (*GHPublish) Exec

func (s *GHPublish) Exec(fmtVideoURL func(string) string) ([]gh.BlobEntry, error)

type GHSyncSchema

type GHSyncSchema struct {
	FolderName string
	Schema     *ContentType
}

func NewGHSyncSchema

func NewGHSyncSchema(sys *Sys, schema *ContentType) *GHSyncSchema

func (*GHSyncSchema) Exec

func (s *GHSyncSchema) Exec(repo string) error

type GraphQLField

type GraphQLField struct {
	FieldName string
	FieldType string
}

func NewGraphQLField

func NewGraphQLField(schema *GraphQLSchema, f *ContentTypeField) *GraphQLField

type GraphQLResolver

type GraphQLResolver struct {
	Name   string
	Args   []*GraphQLResolverArg
	Result string
}

func NewGraphQLResolver

func NewGraphQLResolver(collection bool, name string, args []*GraphQLResolverArg, result string) *GraphQLResolver

type GraphQLResolverArg

type GraphQLResolverArg struct {
	ArgName string
	ArgType string
}

type GraphQLSchema

type GraphQLSchema struct {
	Items    []*ContentType
	TypeDefs []*GraphQLType
}

func NewGraphQLSchema

func NewGraphQLSchema(items []*ContentType) *GraphQLSchema

func (*GraphQLSchema) Render

func (s *GraphQLSchema) Render() (string, error)

type GraphQLType

type GraphQLType struct {
	Schema    GraphQLSchema
	TypeName  string
	Fields    []*GraphQLField
	Resolvers []*GraphQLResolver
}

func NewGraphQLTypeDef

func NewGraphQLTypeDef(schema *GraphQLSchema, typeName string, fields []*ContentTypeField) *GraphQLType

type Include

type Include struct {
	Entry []*Entry `json:"entry,omitempty"`
	Asset []*Entry `json:"asset,omitempty"`
}

type InvalidQueryError

type InvalidQueryError struct{}

type Locale

type Locale struct {
	Code         string   `json:"code"`
	Default      bool     `json:"default"`
	Name         string   `json:"name"`
	FallbackCode string   `json:"fallbackCode"`
	CFLocales    []string `json:"cfFallbackCode"`
}

type Locales

type Locales struct {
	Total int       `json:"total"`
	Limit int       `json:"limit"`
	Skip  int       `json:"skip"`
	Items []*Locale `json:"items"`
}

type LocalesService

type LocalesService service

func (*LocalesService) Get

func (s *LocalesService) Get(query url.Values) ([]byte, error)

func (*LocalesService) GetLocales

func (s *LocalesService) GetLocales() (*Locales, error)

type NotFoundError

type NotFoundError struct {
	APIError
}

NotFoundError for 404 errors

func (NotFoundError) Error

func (e NotFoundError) Error() string

type PGDelete

type PGDelete struct {
	SchemaName string
	TableName  string
	SysID      string
}

func NewPGDelete

func NewPGDelete(schemaName string, sys *Sys) *PGDelete

func (*PGDelete) Exec

func (s *PGDelete) Exec(databaseURL string) error

type PGDeleteContentType

type PGDeleteContentType struct {
	SchemaName string
	TableName  string
	SysID      string
}

func NewPGDeleteContentType

func NewPGDeleteContentType(schemaName string, sys *Sys) *PGDeleteContentType

func (*PGDeleteContentType) Exec

func (s *PGDeleteContentType) Exec(databaseURL string) error

type PGDeletedTable

type PGDeletedTable struct {
	TableName string
	SysIDs    []string
}

type PGDrop

type PGDrop struct {
	SchemaName string
}

func NewPGDrop

func NewPGDrop(schemaName string) *PGDrop

func (*PGDrop) Exec

func (s *PGDrop) Exec(databaseURL string) error

type PGFunctions

type PGFunctions struct {
	Schema *PGSQLSchema
}

func NewPGFunctions

func NewPGFunctions(schema *PGSQLSchema) *PGFunctions

func (*PGFunctions) Exec

func (s *PGFunctions) Exec(databaseURL string) error

func (*PGFunctions) Render

func (s *PGFunctions) Render() (string, error)

type PGFunctionsPublish

type PGFunctionsPublish struct {
	Schema         *PGSQLSchema
	Locale         string
	FallbackLocale string
}

func NewPGFunctionsPublish

func NewPGFunctionsPublish(schema *PGSQLSchema, locale string, fallbackLocale string) *PGFunctionsPublish

func (*PGFunctionsPublish) Render

func (s *PGFunctionsPublish) Render() (string, error)

type PGJSONBMetaRow

type PGJSONBMetaRow struct {
	Name      string `json:"name,omitempty"`
	Type      string `json:"type,omitempty"`
	LinkType  string `json:"linkType,omitempty"`
	Items     string `json:"version,omitempty"`
	Required  bool   `json:"required,omitempty"`
	Localized bool   `json:"localized,omitempty"`
	// Unique      bool   `json:"unique,omitempty"`
	Disabled    bool   `json:"disabled,omitempty"`
	Omitted     bool   `json:"omitted,omitempty"`
	Validations string `json:"validations,omitempty"`
}

func NewPGJSONBMetaRow

func NewPGJSONBMetaRow(field *ContentTypeField) *PGJSONBMetaRow

type PGJSONBModelTable

type PGJSONBModelTable struct {
	TableName        string            `json:"tableName,omitempty"`
	Name             string            `json:"name,omitempty"`
	Description      string            `json:"description,omitempty"`
	DisplayField     string            `json:"displayField,omitempty"`
	Version          int               `json:"version,omitempty"`
	Revision         int               `json:"revision,omitempty"`
	PublishedVersion int               `json:"publishedVersion,omitempty"`
	CreatedAt        string            `json:"createdAt,omitempty"`
	CreatedBy        string            `json:"createdBy,omitempty"`
	UpdatedAt        string            `json:"updatedAt,omitempty"`
	UpdatedBy        string            `json:"updatedBy,omitempty"`
	PublishedAt      string            `json:"publishedAt,omitempty"`
	PublishedBy      string            `json:"publishedBy,omitempty"`
	Metas            []*PGJSONBMetaRow `json:"metas,omitempty"`
}

func NewPGJSONBModelTable

func NewPGJSONBModelTable(item *ContentType) *PGJSONBModelTable

type PGJSONBSchema

type PGJSONBSchema struct {
	SchemaName      string
	AssetTableName  string
	ModelsTableName string
	Tables          []*PGJSONBModelTable
}

func NewPGJSONBSchema

func NewPGJSONBSchema(schemaName string, items []*ContentType) *PGJSONBSchema

func (*PGJSONBSchema) Render

func (s *PGJSONBSchema) Render() (string, error)

type PGMatView

type PGMatView struct {
	Locales   []*Locale
	TableName string
}

type PGMatViews

type PGMatViews struct {
	Schema *PGSQLSchema
}

func NewPGMatViews

func NewPGMatViews(schema *PGSQLSchema) *PGMatViews

func (*PGMatViews) Exec

func (s *PGMatViews) Exec(databaseURL string, schemaName string) error

func (*PGMatViews) ExecPublish

func (s *PGMatViews) ExecPublish(databaseURL string, schemaName string, tableName string) (string, error)

type PGPublish

type PGPublish struct {
	SchemaName       string
	TableName        string
	Columns          []string
	Rows             []*PGSyncRow
	ConTables        map[string]*PGSyncConTable
	DeletedConTables map[string]*PGSyncConTable
	Locales          []*Locale
}

func NewPGPublish

func NewPGPublish(schemaName string, locales []*Locale, contentModel *ContentType, item *PublishedEntry) *PGPublish

func (*PGPublish) Exec

func (s *PGPublish) Exec(databaseURL string) error

type PGQuery

type PGQuery struct {
	SchemaName string
	TableName  string
	Locale     string
	Filters    *[]string
	Order      string
	Limit      int
	Skip       int
}

func NewPGQuery

func NewPGQuery(schemaName string, contentType string, locale string, filters url.Values, order string, skip int, limit int) *PGQuery

func ParsePGQuery

func ParsePGQuery(schemaName string, defaultLocale string, q url.Values) *PGQuery

func (*PGQuery) Exec

func (s *PGQuery) Exec(databaseURL string) (int64, string, error)

type PGReferences

type PGReferences struct {
	Schema *PGSQLSchema
}

func NewPGReferences

func NewPGReferences(schema *PGSQLSchema) *PGReferences

func (*PGReferences) Exec

func (s *PGReferences) Exec(databaseURL string) error

func (*PGReferences) Render

func (s *PGReferences) Render() (string, error)

type PGSQLColumn

type PGSQLColumn struct {
	ColumnName string
	ColumnType string
	ColumnDesc string
	Required   bool
	IsIndex    bool
}

func NewPGSQLColumn

func NewPGSQLColumn(field *ContentTypeField) *PGSQLColumn

type PGSQLData

type PGSQLData struct {
	ID           string
	Label        string
	Description  string
	DisplayField string
	Fields       []map[string]interface{}
	Version      int
	CreatedAt    string
	CreatedBy    string
	UpdatedAt    string
	UpdatedBy    string
	Metas        []*PGSQLMeta
}

type PGSQLDeleteTrigger

type PGSQLDeleteTrigger struct {
	TableName string
	ConTables []string
}

type PGSQLDependency

type PGSQLDependency struct {
	TableName string
	Reference string
}

type PGSQLMeta

type PGSQLMeta struct {
	Name      string
	Label     string
	Type      string
	ItemsType string
	LinkType  string
	Required  bool
	Localized bool
	Unique    bool
	Disabled  bool
	Omitted   bool
}

type PGSQLProcedure

type PGSQLProcedure struct {
	TableName    string
	Columns      []*PGSQLProcedureColumn
	HasLocalized bool
}

type PGSQLProcedureColumn

type PGSQLProcedureColumn struct {
	TableName    string
	ColumnName   string
	Alias        string
	ConTableName string
	Reference    *PGSQLProcedureReference
	JoinAlias    string
	IsAsset      bool
	Localized    bool
	SqlType      string
}

func NewPGSQLProcedureColumn

func NewPGSQLProcedureColumn(columnName string, field *ContentTypeField, items map[string]*ContentType, tableName string, maxIncludeDepth int64, includeDepth int64, path string) *PGSQLProcedureColumn

type PGSQLProcedureReference

type PGSQLProcedureReference struct {
	TableName    string
	ForeignKey   string
	Columns      []*PGSQLProcedureColumn
	JoinAlias    string
	Localized    bool
	HasLocalized bool
}

type PGSQLReference

type PGSQLReference struct {
	TableName    string
	ForeignKey   string
	Reference    string
	IsManyToMany bool
}

type PGSQLSchema

type PGSQLSchema struct {
	SchemaName         string
	Locales            []*Locale
	Tables             []*PGSQLTable
	ConTables          []*PGSQLTable
	References         []*PGSQLReference
	Dependencies       []*PGSQLDependency
	Functions          []*PGSQLProcedure
	DeleteTriggers     []*PGSQLDeleteTrigger
	AssetTableName     string
	AssetColumns       []string
	DropTables         bool
	ContentTypePublish bool
	ContentSchema      string
}

func NewPGSQLSchema

func NewPGSQLSchema(schemaName string, locales []*Locale, contentTypeFilter string, items []*ContentType, includeDepth int64) *PGSQLSchema

func (*PGSQLSchema) Exec

func (s *PGSQLSchema) Exec(databaseURL string) error

func (*PGSQLSchema) Render

func (s *PGSQLSchema) Render() (string, error)

type PGSQLTable

type PGSQLTable struct {
	TableName string
	Data      *PGSQLData
	Columns   []*PGSQLColumn
	Indices   map[string]string
	Schema    *content.Schema
}

func NewPGSQLCon

func NewPGSQLCon(tableName string, fieldName string, reference string) *PGSQLTable

type PGSyncConTable

type PGSyncConTable struct {
	TableName string
	Columns   []string
	Rows      [][]interface{}
}

type PGSyncField

type PGSyncField struct {
	Type  string
	Value interface{}
}

type PGSyncRow

type PGSyncRow struct {
	ID           string
	SysID        string
	FieldColumns []string
	FieldValues  map[string]interface{}
	Locale       string
	Version      int
	CreatedAt    string
	UpdatedAt    string
}

func (*PGSyncRow) Fields

func (r *PGSyncRow) Fields() []interface{}

func (*PGSyncRow) GetFieldValue

func (r *PGSyncRow) GetFieldValue(fieldColumn string) string

type PGSyncSchema

type PGSyncSchema struct {
	SchemaName       string
	Locales          []*Locale
	DefaultLocale    string
	Tables           map[string]*PGSyncTable
	Deleted          map[string]*PGDeletedTable
	ConTables        map[string]*PGSyncConTable
	DeletedConTables map[string]*PGSyncConTable
	InitSync         bool
}

func NewPGSyncSchema

func NewPGSyncSchema(schemaName string, locales []*Locale, types []*ContentType, entries []*Entry, initSync bool) *PGSyncSchema

func (*PGSyncSchema) Exec

func (s *PGSyncSchema) Exec(databaseURL string) error

func (*PGSyncSchema) Render

func (s *PGSyncSchema) Render() (string, error)

type PGSyncTable

type PGSyncTable struct {
	TableName string
	Columns   []string
	Rows      []*PGSyncRow
}

type PublishFields

type PublishFields map[string]map[string]interface{}

type PublishedEntries

type PublishedEntries struct {
	Sys      *Sys              `json:"sys"`
	Total    int               `json:"total"`
	Skip     int               `json:"skip"`
	Limit    int               `json:"limit"`
	Items    []*PublishedEntry `json:"items"`
	Includes *Include          `json:"includes,omitempty"`
}

type PublishedEntry

type PublishedEntry struct {
	Sys    *Sys          `json:"sys"`
	Fields PublishFields `json:"fields"`
}

func GetPublishedEntry

func GetPublishedEntry(repo string, contentType string, files []string) (*PublishedEntry, error)

type RangeValidation

type RangeValidation struct {
	Min *int `json:"min,omitempty"`
	Max *int `json:"max,omitempty"`
}

type RateLimitExceededError

type RateLimitExceededError struct {
	APIError
}

RateLimitExceededError for rate limit errors

func (RateLimitExceededError) Error

func (e RateLimitExceededError) Error() string

type RegexpValidation

type RegexpValidation struct {
	Pattern int `json:"pattern"`
	Flags   int `json:"flags"`
}

type ServerError

type ServerError struct{}

type Space

type Space struct {
	Sys     *Sys      `json:"sys"`
	Name    string    `json:"name"`
	Locales []*Locale `json:"locales"`
}

type Spaces

type Spaces struct {
	Sys   *Sys     `json:"sys"`
	Total int      `json:"total"`
	Limit int      `json:"limit"`
	Skip  int      `json:"skip"`
	Items []*Space `json:"items"`
}

type SpacesService

type SpacesService service

func (*SpacesService) Create

func (s *SpacesService) Create(body []byte) ([]byte, error)

func (*SpacesService) Get

func (s *SpacesService) Get(query url.Values) ([]byte, error)

func (*SpacesService) GetSpace

func (s *SpacesService) GetSpace() (*Space, error)

func (*SpacesService) Sync

func (s *SpacesService) Sync(token string) (*SyncResult, error)

func (*SpacesService) SyncPaged

func (s *SpacesService) SyncPaged(token string, callback SyncCallback) (string, error)

type SyncCallback

type SyncCallback func(*SyncResponse) error

type SyncJSONBRow

type SyncJSONBRow struct {
	ID               string `json:"id,omitempty"`
	Fields           string `json:"fields,omitempty"`
	Type             string `json:"type,omitempty"`
	Version          int    `json:"version,omitempty"`
	Revision         int    `json:"revision,omitempty"`
	PublishedVersion int    `json:"publishedVersion,omitempty"`
	CreatedAt        string `json:"createdAt,omitempty"`
	CreatedBy        string `json:"createdBy,omitempty"`
	UpdatedAt        string `json:"updatedAt,omitempty"`
	UpdatedBy        string `json:"updatedBy,omitempty"`
	PublishedAt      string `json:"publishedAt,omitempty"`
	PublishedBy      string `json:"publishedBy,omitempty"`
}

func NewSyncJSONBRow

func NewSyncJSONBRow(item *Entry) SyncJSONBRow

type SyncJSONBSchema

type SyncJSONBSchema struct {
	SchemaName     string
	AssetTableName string
	Tables         []SyncJSONBTable
	Deleted        []SyncJSONBTable
}

func NewSyncJSONBSchema

func NewSyncJSONBSchema(schemaName string, assetTableName string, items []*Entry) SyncJSONBSchema

func (*SyncJSONBSchema) Render

func (s *SyncJSONBSchema) Render() (string, error)

type SyncJSONBTable

type SyncJSONBTable struct {
	TableName string
	Rows      []SyncJSONBRow
}

func NewSyncJSONBTable

func NewSyncJSONBTable(tableName string, rows []SyncJSONBRow) SyncJSONBTable

type SyncResponse

type SyncResponse struct {
	Sys         *Sys     `json:"sys"`
	Items       []*Entry `json:"items"`
	NextPageURL string   `json:"nextPageUrl"`
	NextSyncURL string   `json:"nextSyncUrl"`
}

type SyncResult

type SyncResult struct {
	Items []*Entry
	Token string
}

type Sys

type Sys struct {
	ID               string       `json:"id,omitempty"`
	Type             string       `json:"type,omitempty"`
	LinkType         string       `json:"linkType,omitempty"`
	CreatedAt        string       `json:"createdAt,omitempty"`
	CreatedBy        *Entry       `json:"createdBy,omitempty"`
	UpdatedAt        string       `json:"updatedAt,omitempty"`
	UpdatedBy        *Entry       `json:"updatedBy,omitempty"`
	DeletedAt        string       `json:"deletedAt,omitempty"`
	DeletedBy        *Entry       `json:"deletedBy,omitempty"`
	Version          int          `json:"version,omitempty"`
	Revision         int          `json:"revision,omitempty"`
	ContentType      *ContentType `json:"contentType,omitempty"`
	FirstPublishedAt string       `json:"firstPublishedAt,omitempty"`
	PublishedCounter int          `json:"publishedCounter,omitempty"`
	PublishedAt      string       `json:"publishedAt,omitempty"`
	PublishedBy      *Entry       `json:"publishedBy,omitempty"`
	PublishedVersion int          `json:"publishedVersion,omitempty"`
	Space            *Space       `json:"space,omitempty"`
}

type UploadsService

type UploadsService service

func (*UploadsService) Create

func (s *UploadsService) Create(data io.Reader) ([]byte, error)

type ValidationFailedError

type ValidationFailedError struct {
	APIError
}

ValidationFailedError model

func (ValidationFailedError) Error

func (e ValidationFailedError) Error() string

type VersionMismatchError

type VersionMismatchError struct {
	APIError
}

VersionMismatchError for 409 errors

func (VersionMismatchError) Error

func (e VersionMismatchError) Error() string

Directories

Path Synopsis
cmd
gfl

Jump to

Keyboard shortcuts

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