Documentation ¶
Index ¶
- Constants
- Variables
- type APIError
- type APIKey
- type APIKeyPolicy
- type APIKeyService
- type AccessDeniedError
- type AccessTokenInvalidError
- type Asset
- type AssetsService
- func (service *AssetsService) Delete(spaceID string, asset *Asset) error
- func (service *AssetsService) Get(spaceID, assetID string) (*Asset, error)
- func (service *AssetsService) List(spaceID string) *Collection
- func (service *AssetsService) Process(spaceID string, asset *Asset) error
- func (service *AssetsService) Publish(spaceID string, asset *Asset) error
- func (service *AssetsService) Upsert(spaceID string, asset *Asset) error
- type BadRequestError
- type Collection
- func (col *Collection) Next() (*Collection, error)
- func (col *Collection) ToAPIKey() []*APIKey
- func (col *Collection) ToAsset() []*Asset
- func (col *Collection) ToContentType() []*ContentType
- func (col *Collection) ToEntry() []*Entry
- func (col *Collection) ToLocale() []*Locale
- func (col *Collection) ToSpace() []*Space
- func (col *Collection) ToWebhook() []*Webhook
- type CollectionOptions
- type ContentType
- type ContentTypesService
- func (service *ContentTypesService) Activate(spaceID string, ct *ContentType) error
- func (service *ContentTypesService) Deactivate(spaceID string, ct *ContentType) error
- func (service *ContentTypesService) Delete(spaceID string, ct *ContentType) error
- func (service *ContentTypesService) Get(spaceID, contentTypeID string) (*ContentType, error)
- func (service *ContentTypesService) List(spaceID string) *Collection
- func (service *ContentTypesService) Upsert(spaceID string, ct *ContentType) error
- type Contentful
- type DateMinMax
- type EntriesService
- func (service *EntriesService) Delete(spaceID string, entryID string) error
- func (service *EntriesService) Get(spaceID, entryID string) (*Entry, error)
- func (service *EntriesService) GetEntryKey(entry *Entry, key string) (*EntryField, error)
- func (service *EntriesService) List(spaceID string) *Collection
- func (service *EntriesService) Publish(spaceID string, entry *Entry) error
- func (service *EntriesService) Unpublish(spaceID string, entry *Entry) error
- type Entry
- type EntryField
- func (ef *EntryField) Array() []string
- func (ef *EntryField) Asset() *Asset
- func (ef *EntryField) Entry() *Entry
- func (ef *EntryField) Integer() int
- func (ef *EntryField) LArray(locale string) []string
- func (ef *EntryField) LAsset(locale string) *Asset
- func (ef *EntryField) LEntry(locale string) *Entry
- func (ef *EntryField) LInteger(locale string) int
- func (ef *EntryField) LLinkID(locale string) string
- func (ef *EntryField) LLinkType(locale string) string
- func (ef *EntryField) LString(locale string) string
- func (ef *EntryField) LinkID() string
- func (ef *EntryField) LinkType() string
- func (ef *EntryField) String() string
- type ErrorDetail
- type ErrorDetails
- type ErrorResponse
- type Field
- type FieldTypeArrayItem
- type FieldValidation
- type FieldValidationDate
- type FieldValidationDimension
- type FieldValidationFileSize
- type FieldValidationLink
- type FieldValidationMimeType
- type FieldValidationPredefinedValues
- type FieldValidationRange
- type FieldValidationRegex
- type FieldValidationSize
- type FieldValidationUnique
- type File
- type FileDetail
- type FileFields
- type FileImage
- type InvalidQueryError
- type Locale
- type LocalesService
- type MinMax
- type NotFoundError
- type PreviewAPIKey
- type Query
- func (q *Query) All(field string, value []string) *Query
- func (q *Query) ContentType(ct string) *Query
- func (q *Query) Equal(field string, value interface{}) *Query
- func (q *Query) Exists(field string) *Query
- func (q *Query) GreaterThan(field string, value interface{}) *Query
- func (q *Query) GreaterThanOrEqual(field string, value interface{}) *Query
- func (q *Query) In(field string, value []string) *Query
- func (q *Query) Include(include uint16) *Query
- func (q *Query) LessThan(field string, value interface{}) *Query
- func (q *Query) LessThanOrEqual(field string, value interface{}) *Query
- func (q *Query) Limit(limit uint16) *Query
- func (q *Query) Locale(locale string) *Query
- func (q *Query) Match(field, match string) *Query
- func (q *Query) MimeType(mime string) *Query
- func (q *Query) Near(field string, lat, lon int16) *Query
- func (q *Query) NotEqual(field string, value interface{}) *Query
- func (q *Query) NotExists(field string) *Query
- func (q *Query) NotIn(field string, value []string) *Query
- func (q *Query) Order(field string, reverse bool) *Query
- func (q *Query) Query(qStr string) *Query
- func (q *Query) Select(fields []string) *Query
- func (q *Query) Skip(skip uint16) *Query
- func (q *Query) String() string
- func (q *Query) Values() url.Values
- func (q *Query) Within(field string, lat1, lon1, lat2, lon2 int16) *Query
- func (q *Query) WithinRadius(field string, lat1, lon1, radius int16) *Query
- type RateLimitExceededError
- type Regex
- type ServerError
- type Space
- type SpacesService
- type Sys
- type ValidationFailedError
- type VersionMismatchError
- type Webhook
- type WebhookHeader
- type WebhooksService
- func (service *WebhooksService) Delete(spaceID string, webhook *Webhook) error
- func (service *WebhooksService) Get(spaceID, webhookID string) (*Webhook, error)
- func (service *WebhooksService) List(spaceID string) *Collection
- func (service *WebhooksService) Upsert(spaceID string, webhook *Webhook) error
Examples ¶
- ContentTypesService.Activate
- ContentTypesService.Deactivate
- ContentTypesService.Delete
- ContentTypesService.Delete (AllDrafts)
- ContentTypesService.Get
- ContentTypesService.List
- ContentTypesService.Upsert (Create)
- ContentTypesService.Upsert (Update)
- SpacesService.Delete
- SpacesService.Delete (All)
- SpacesService.Get
- SpacesService.List
- SpacesService.Upsert (Create)
- SpacesService.Upsert (Update)
Constants ¶
const ( // FieldTypeText content type field type for text data FieldTypeText = "Text" // FieldTypeSymbol content type field type for text data FieldTypeSymbol = "Symbol" // FieldTypeArray content type field type for array data FieldTypeArray = "Array" // FieldTypeLink content type field type for link data FieldTypeLink = "Link" // FieldTypeInteger content type field type for integer data FieldTypeInteger = "Integer" // FieldTypeLocation content type field type for location data FieldTypeLocation = "Location" // FieldTypeBoolean content type field type for boolean data FieldTypeBoolean = "Boolean" // FieldTypeDate content type field type for date data FieldTypeDate = "Date" // FieldTypeObject content type field type for object data FieldTypeObject = "Object" )
const ( // MimeTypeAttachment mime type validation for content type field MimeTypeAttachment = "attachment" // MimeTypePlainText mime type validation for content type field MimeTypePlainText = "plaintext" // MimeTypeImage mime type validation for content type field MimeTypeImage = "image" // MimeTypeAudio mime type validation for content type field MimeTypeAudio = "audio" // MimeTypeVideo mime type validation for content type field MimeTypeVideo = "video" // MimeTypeRichText mime type validation for content type field MimeTypeRichText = "richtext" // MimeTypePresentation mime type validation for content type field MimeTypePresentation = "presentation" // MimeTypeSpreadSheet mime type validation for content type field MimeTypeSpreadSheet = "spreadsheet" // MimeTypePDF mime type validation for content type field MimeTypePDF = "pdfdocument" // MimeTypeArchive mime type validation for content type field MimeTypeArchive = "archive" // MimeTypeCode mime type validation for content type field MimeTypeCode = "code" // MimeTypeMarkup mime type validation for content type field MimeTypeMarkup = "markup" )
const ( // FieldValidationRegexPatternEmail email validation FieldValidationRegexPatternEmail = `^\w[\w.-]*@([\w-]+\.)+[\w-]+$` // FieldValidationRegexPatternURL url validation FieldValidationRegexPatternURL = `^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$` // FieldValidationRegexPatternUSDate us date validation FieldValidationRegexPatternUSDate = `^(0?[1-9]|[12][0-9]|3[01])[- \/.](0?[1-9]|1[012])[- \/.](19|20)?\d\d$` // FieldValidationRegexPatternEuorpeanDate euorpean date validation FieldValidationRegexPatternEuorpeanDate = `^(0?[1-9]|[12][0-9]|3[01])[- \/.](0?[1-9]|1[012])[- \/.](19|20)?\d\d$` // FieldValidationRegexPattern12HourTime 12-hour time validation FieldValidationRegexPattern12HourTime = `^(0?[1-9]|1[012]):[0-5][0-9](:[0-5][0-9])?\s*[aApP][mM]$` // FieldValidationRegexPattern24HourTime 24-hour time validation FieldValidationRegexPattern24HourTime = `^(0?[0-9]|1[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$` // FieldValidationRegexPatternUSPhoneNumber us phone number validation FieldValidationRegexPatternUSPhoneNumber = `^\d[ -.]?\(?\d\d\d\)?[ -.]?\d\d\d[ -.]?\d\d\d\d$` // FieldValidationRegexPatternUSZipCode us zip code validation FieldValidationRegexPatternUSZipCode = `^\d{5}$|^\d{5}-\d{4}$}` )
Variables ¶
var Version = "0.3.1"
Version for SDK Version
Functions ¶
This section is empty.
Types ¶
type APIKey ¶
type APIKey struct { Sys *Sys `json:"sys,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` AccessToken string `json:"accessToken,omitempty"` Policies []*APIKeyPolicy `json:"policies,omitempty"` PreviewAPIKey *PreviewAPIKey `json:"preview_api_key,omitempty"` }
APIKey model
func (*APIKey) GetVersion ¶
GetVersion returns entity version
func (*APIKey) MarshalJSON ¶
MarshalJSON for custom json marshaling
type APIKeyPolicy ¶
type APIKeyPolicy struct { Effect string `json:"effect,omitempty"` Actions string `json:"actions,omitempty"` }
APIKeyPolicy model
type APIKeyService ¶
type APIKeyService service
APIKeyService service
func (*APIKeyService) Delete ¶
func (service *APIKeyService) Delete(spaceID string, apiKey *APIKey) error
Delete deletes a sinlge api key entity
func (*APIKeyService) Get ¶
func (service *APIKeyService) Get(spaceID, apiKeyID string) (*APIKey, error)
Get returns a single api key entity
func (*APIKeyService) List ¶
func (service *APIKeyService) List(spaceID string) *Collection
List returns all api keys collection
type AccessDeniedError ¶
type AccessDeniedError struct{}
AccessDeniedError error model for access denied responses
type AccessTokenInvalidError ¶
type AccessTokenInvalidError struct {
APIError
}
AccessTokenInvalidError for 401 errors
func (AccessTokenInvalidError) Error ¶
func (e AccessTokenInvalidError) Error() string
type Asset ¶
type Asset struct { Sys *Sys `json:"sys"` Fields *FileFields `json:"fields"` // contains filtered or unexported fields }
Asset model
func (*Asset) MarshalJSON ¶
MarshalJSON for custom json marshaling
func (*Asset) UnmarshalJSON ¶
UnmarshalJSON for custom json unmarshaling
type AssetsService ¶
type AssetsService service
AssetsService service
func (*AssetsService) Delete ¶
func (service *AssetsService) Delete(spaceID string, asset *Asset) error
Delete sends delete request
func (*AssetsService) Get ¶
func (service *AssetsService) Get(spaceID, assetID string) (*Asset, error)
Get returns a single asset entity
func (*AssetsService) List ¶
func (service *AssetsService) List(spaceID string) *Collection
List returns asset collection
func (*AssetsService) Process ¶
func (service *AssetsService) Process(spaceID string, asset *Asset) error
Process the asset
type BadRequestError ¶
type BadRequestError struct{}
BadRequestError error model for bad request responses
type Collection ¶
type Collection struct { Query Sys *Sys `json:"sys"` Total int `json:"total"` Skip int `json:"skip"` Limit int `json:"limit"` Items []interface{} `json:"items"` Includes interface{} `json:"includes"` // contains filtered or unexported fields }
Collection model
func NewCollection ¶
func NewCollection(options *CollectionOptions) *Collection
NewCollection initilazies a new collection
func (*Collection) ToAPIKey ¶
func (col *Collection) ToAPIKey() []*APIKey
ToAPIKey cast Items to APIKey model
func (*Collection) ToAsset ¶
func (col *Collection) ToAsset() []*Asset
ToAsset cast Items to Asset model
func (*Collection) ToContentType ¶
func (col *Collection) ToContentType() []*ContentType
ToContentType cast Items to ContentType model
func (*Collection) ToEntry ¶
func (col *Collection) ToEntry() []*Entry
ToEntry cast Items to Entry model
func (*Collection) ToLocale ¶
func (col *Collection) ToLocale() []*Locale
ToLocale cast Items to Locale model
func (*Collection) ToSpace ¶
func (col *Collection) ToSpace() []*Space
ToSpace cast Items to Space model
func (*Collection) ToWebhook ¶
func (col *Collection) ToWebhook() []*Webhook
ToWebhook cast Items to Webhook model
type CollectionOptions ¶
type CollectionOptions struct {
Limit uint16
}
CollectionOptions holds init options
type ContentType ¶
type ContentType struct { Sys *Sys `json:"sys"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Fields []*Field `json:"fields,omitempty"` DisplayField string `json:"displayField,omitempty"` }
ContentType model
func (*ContentType) GetVersion ¶
func (ct *ContentType) GetVersion() int
GetVersion returns entity version
type ContentTypesService ¶
type ContentTypesService service
ContentTypesService service
func (*ContentTypesService) Activate ¶
func (service *ContentTypesService) Activate(spaceID string, ct *ContentType) error
Activate the contenttype, a.k.a publish
Example ¶
cma := NewCMA("cma-token") contentType, err := cma.ContentTypes.Get("space-id", "content-type-id") if err != nil { log.Fatal(err) } err = cma.ContentTypes.Activate("space-id", contentType) if err != nil { log.Fatal(err) }
Output:
func (*ContentTypesService) Deactivate ¶
func (service *ContentTypesService) Deactivate(spaceID string, ct *ContentType) error
Deactivate the contenttype, a.k.a unpublish
Example ¶
cma := NewCMA("cma-token") contentType, err := cma.ContentTypes.Get("space-id", "content-type-id") if err != nil { log.Fatal(err) } err = cma.ContentTypes.Deactivate("space-id", contentType) if err != nil { log.Fatal(err) }
Output:
func (*ContentTypesService) Delete ¶
func (service *ContentTypesService) Delete(spaceID string, ct *ContentType) error
Delete the content_type
Example ¶
cma := NewCMA("cma-token") contentType, err := cma.ContentTypes.Get("space-id", "content-type-id") if err != nil { log.Fatal(err) } err = cma.ContentTypes.Delete("space-id", contentType) if err != nil { log.Fatal(err) }
Output:
Example (AllDrafts) ¶
cma := NewCMA("cma-token") collection, err := cma.ContentTypes.List("space-id").Next() if err != nil { log.Fatal(err) } contentTypes := collection.ToContentType() for _, contentType := range contentTypes { if contentType.Sys.PublishedAt == "" { err := cma.ContentTypes.Delete("space-id", contentType) if err != nil { log.Fatal(err) } } }
Output:
func (*ContentTypesService) Get ¶
func (service *ContentTypesService) Get(spaceID, contentTypeID string) (*ContentType, error)
Get fetched a content type specified by `contentTypeID`
Example ¶
cma := NewCMA("cma-token") contentType, err := cma.ContentTypes.Get("space-id", "content-type-id") if err != nil { log.Fatal(err) } fmt.Println(contentType.Name)
Output:
func (*ContentTypesService) List ¶
func (service *ContentTypesService) List(spaceID string) *Collection
List return a content type collection
Example ¶
cma := NewCMA("cma-token") collection, err := cma.ContentTypes.List("space-id").Next() if err != nil { log.Fatal(err) } contentTypes := collection.ToContentType() for _, contentType := range contentTypes { fmt.Println(contentType.Sys.ID, contentType.Sys.PublishedAt) }
Output:
func (*ContentTypesService) Upsert ¶
func (service *ContentTypesService) Upsert(spaceID string, ct *ContentType) error
Upsert updates or creates a new content type
Example (Create) ¶
cma := NewCMA("cma-token") contentType := &ContentType{ Name: "test content type", DisplayField: "field1_id", Description: "content type description", Fields: []*Field{ &Field{ ID: "field1_id", Name: "field1", Type: "Symbol", Required: false, Disabled: false, }, &Field{ ID: "field2_id", Name: "field2", Type: "Symbol", Required: false, Disabled: true, }, }, } err := cma.ContentTypes.Upsert("space-id", contentType) if err != nil { log.Fatal(err) }
Output:
Example (Update) ¶
cma := NewCMA("cma-token") contentType, err := cma.ContentTypes.Get("space-id", "content-type-id") if err != nil { log.Fatal(err) } contentType.Name = "modified content type name" err = cma.ContentTypes.Upsert("space-id", contentType) if err != nil { log.Fatal(err) }
Output:
type Contentful ¶
type Contentful struct { Debug bool QueryParams map[string]string Headers map[string]string BaseURL string Spaces *SpacesService APIKeys *APIKeyService Assets *AssetsService ContentTypes *ContentTypesService Entries *EntriesService Locales *LocalesService Webhooks *WebhooksService // contains filtered or unexported fields }
Contentful model
func (*Contentful) SetHTTPClient ¶
func (c *Contentful) SetHTTPClient(client *http.Client)
SetHTTPClient sets the underlying http.Client used to make requests.
func (*Contentful) SetOrganization ¶
func (c *Contentful) SetOrganization(organizationID string) *Contentful
SetOrganization sets the given organization id
type DateMinMax ¶
type DateMinMax struct { Min time.Time `json:"min,omitempty"` Max time.Time `json:"max,omitempty"` }
DateMinMax model
type EntriesService ¶
type EntriesService service
EntriesService servıce
func (*EntriesService) Delete ¶
func (service *EntriesService) Delete(spaceID string, entryID string) error
Delete the entry
func (*EntriesService) Get ¶
func (service *EntriesService) Get(spaceID, entryID string) (*Entry, error)
Get returns a single entry
func (*EntriesService) GetEntryKey ¶
func (service *EntriesService) GetEntryKey(entry *Entry, key string) (*EntryField, error)
GetEntryKey returns the entry's keys
func (*EntriesService) List ¶
func (service *EntriesService) List(spaceID string) *Collection
List returns entries collection
type Entry ¶
type Entry struct { Sys *Sys `json:"sys"` Fields map[string]interface{} // contains filtered or unexported fields }
Entry model
type EntryField ¶
type EntryField struct {
// contains filtered or unexported fields
}
EntryField model
func (*EntryField) Integer ¶
func (ef *EntryField) Integer() int
Integer converts interface to integer
func (*EntryField) LArray ¶
func (ef *EntryField) LArray(locale string) []string
LArray converts interface to slice
func (*EntryField) LAsset ¶
func (ef *EntryField) LAsset(locale string) *Asset
LAsset returns the linked asset
func (*EntryField) LEntry ¶
func (ef *EntryField) LEntry(locale string) *Entry
LEntry returns the linked entry
func (*EntryField) LInteger ¶
func (ef *EntryField) LInteger(locale string) int
LInteger converts interface to integer
func (*EntryField) LLinkID ¶
func (ef *EntryField) LLinkID(locale string) string
LLinkID returns link model
func (*EntryField) LLinkType ¶
func (ef *EntryField) LLinkType(locale string) string
LLinkType returns link model
func (*EntryField) LString ¶
func (ef *EntryField) LString(locale string) string
LString returns the given locale
func (*EntryField) String ¶
func (ef *EntryField) String() string
String converts interface to string
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 Field ¶
type Field 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"` }
Field model
func (*Field) UnmarshalJSON ¶
UnmarshalJSON for custom json unmarshaling
type FieldTypeArrayItem ¶
type FieldTypeArrayItem struct { Type string `json:"type,omitempty"` Validations []FieldValidation `json:"validations,omitempty"` LinkType string `json:"linkType,omitempty"` }
FieldTypeArrayItem model
func (*FieldTypeArrayItem) UnmarshalJSON ¶
func (item *FieldTypeArrayItem) UnmarshalJSON(data []byte) error
UnmarshalJSON for custom json unmarshaling
type FieldValidation ¶
type FieldValidation interface{}
FieldValidation interface
func ParseValidations ¶
func ParseValidations(data []interface{}) (validations []FieldValidation, err error)
ParseValidations converts json representation to go struct
type FieldValidationDate ¶
type FieldValidationDate struct { Range *DateMinMax `json:"dateRange,omitempty"` ErrorMessage string `json:"message,omitempty"` }
FieldValidationDate model
func (*FieldValidationDate) MarshalJSON ¶
func (v *FieldValidationDate) MarshalJSON() ([]byte, error)
MarshalJSON for custom json marshaling
func (*FieldValidationDate) UnmarshalJSON ¶
func (v *FieldValidationDate) UnmarshalJSON(data []byte) error
UnmarshalJSON for custom json unmarshaling
type FieldValidationDimension ¶
type FieldValidationDimension struct { Width *MinMax `json:"width,omitempty"` Height *MinMax `json:"height,omitempty"` ErrorMessage string `json:"message,omitempty"` }
FieldValidationDimension model
func (*FieldValidationDimension) MarshalJSON ¶
func (v *FieldValidationDimension) MarshalJSON() ([]byte, error)
MarshalJSON for custom json marshaling
func (*FieldValidationDimension) UnmarshalJSON ¶
func (v *FieldValidationDimension) UnmarshalJSON(data []byte) error
UnmarshalJSON for custom json unmarshaling
type FieldValidationFileSize ¶
type FieldValidationFileSize struct { Size *MinMax `json:"assetFileSize,omitempty"` ErrorMessage string `json:"message,omitempty"` }
FieldValidationFileSize model
type FieldValidationLink ¶
type FieldValidationLink struct {
LinkContentType []string `json:"linkContentType,omitempty"`
}
FieldValidationLink model
type FieldValidationMimeType ¶
type FieldValidationMimeType struct {
MimeTypes []string `json:"linkMimetypeGroup,omitempty"`
}
FieldValidationMimeType model
type FieldValidationPredefinedValues ¶
type FieldValidationPredefinedValues struct { In []interface{} `json:"in,omitempty"` ErrorMessage string `json:"message"` }
FieldValidationPredefinedValues model
type FieldValidationRange ¶
type FieldValidationRange struct { Range *MinMax `json:"range,omitempty"` ErrorMessage string `json:"message,omitempty"` }
FieldValidationRange model
type FieldValidationRegex ¶
type FieldValidationRegex struct { Regex *Regex `json:"regexp,omitempty"` ErrorMessage string `json:"message,omitempty"` }
FieldValidationRegex model
type FieldValidationSize ¶
type FieldValidationSize struct { Size *MinMax `json:"size,omitempty"` ErrorMessage string `json:"message,omitempty"` }
FieldValidationSize model
type FieldValidationUnique ¶
type FieldValidationUnique struct {
Unique bool `json:"unique"`
}
FieldValidationUnique model
type File ¶
type File struct { Name string `json:"fileName,omitempty"` ContentType string `json:"contentType,omitempty"` URL string `json:"url,omitempty"` UploadURL string `json:"upload,omitempty"` Detail *FileDetail `json:"details,omitempty"` }
File model
type FileDetail ¶
type FileDetail struct { Size int `json:"size,omitempty"` Image *FileImage `json:"image,omitempty"` }
FileDetail model
type FileFields ¶
type FileFields struct { Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` File *File `json:"file,omitempty"` }
FileFields model
type InvalidQueryError ¶
type InvalidQueryError struct{}
InvalidQueryError error model for invalid query responses
type Locale ¶
type Locale struct { Sys *Sys `json:"sys,omitempty"` // Locale name Name string `json:"name,omitempty"` // Language code Code string `json:"code,omitempty"` // If no content is provided for the locale, the Delivery API will return content in a locale specified below: FallbackCode string `json:"fallbackCode,omitempty"` // Make the locale as default locale for your account Default bool `json:"default,omitempty"` // Entries with required fields can still be published if locale is empty. Optional bool `json:"optional,omitempty"` // Includes locale in the Delivery API response. CDA bool `json:"contentDeliveryApi"` // Displays locale to editors and enables it in Management API. CMA bool `json:"contentManagementApi"` }
Locale model
func (*Locale) GetVersion ¶
GetVersion returns entity version
type LocalesService ¶
type LocalesService service
LocalesService service
func (*LocalesService) Delete ¶
func (service *LocalesService) Delete(spaceID string, locale *Locale) error
Delete the locale
func (*LocalesService) Get ¶
func (service *LocalesService) Get(spaceID, localeID string) (*Locale, error)
Get returns a single locale entity
func (*LocalesService) List ¶
func (service *LocalesService) List(spaceID string) *Collection
List returns a locales collection
type NotFoundError ¶
type NotFoundError struct {
APIError
}
NotFoundError for 404 errors
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query model
func (*Query) GreaterThan ¶
GreaterThan [gt] query
func (*Query) GreaterThanOrEqual ¶
GreaterThanOrEqual [lte] query
func (*Query) LessThanOrEqual ¶
LessThanOrEqual [lte] query
type RateLimitExceededError ¶
type RateLimitExceededError struct {
APIError
}
RateLimitExceededError for rate limit errors
func (RateLimitExceededError) Error ¶
func (e RateLimitExceededError) Error() string
type Regex ¶
type Regex struct { Pattern string `json:"pattern,omitempty"` Flags string `json:"flags,omitempty"` }
Regex model
type Space ¶
type Space struct { Sys *Sys `json:"sys,omitempty"` Name string `json:"name,omitempty"` DefaultLocale string `json:"defaultLocale,omitempty"` }
Space model
func (*Space) MarshalJSON ¶
MarshalJSON for custom json marshaling
type SpacesService ¶
type SpacesService service
SpacesService model
func (*SpacesService) Delete ¶
func (service *SpacesService) Delete(space *Space) error
Delete the given space
Example ¶
cma := NewCMA("cma-token") space, err := cma.Spaces.Get("space-id") if err != nil { log.Fatal(err) } err = cma.Spaces.Delete(space) if err != nil { log.Fatal(err) }
Output:
Example (All) ¶
cma := NewCMA("cma-token") collection, err := cma.Spaces.List().Next() if err != nil { log.Fatal(err) } for _, space := range collection.ToSpace() { err := cma.Spaces.Delete(space) if err != nil { log.Fatal(err) } }
Output:
func (*SpacesService) Get ¶
func (service *SpacesService) Get(spaceID string) (*Space, error)
Get returns a single space entity
Example ¶
cma := NewCMA("cma-token") space, err := cma.Spaces.Get("space-id") if err != nil { log.Fatal(err) } fmt.Println(space.Name)
Output:
func (*SpacesService) List ¶
func (service *SpacesService) List() *Collection
List creates a spaces collection
Example ¶
cma := NewCMA("cma-token") collection, err := cma.Spaces.List().Next() if err != nil { log.Fatal(err) } spaces := collection.ToSpace() for _, space := range spaces { fmt.Println(space.Sys.ID, space.Name) }
Output:
func (*SpacesService) Upsert ¶
func (service *SpacesService) Upsert(space *Space) error
Upsert updates or creates a new space
Example (Create) ¶
cma := NewCMA("cma-token") space := &Space{ Name: "space-name", DefaultLocale: "en-US", } err := cma.Spaces.Upsert(space) if err != nil { log.Fatal(err) }
Output:
Example (Update) ¶
cma := NewCMA("cma-token") space, err := cma.Spaces.Get("space-id") if err != nil { log.Fatal(err) } space.Name = "modified" err = cma.Spaces.Upsert(space) if err != nil { log.Fatal(err) }
Output:
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"` UpdatedAt string `json:"updatedAt,omitempty"` UpdatedBy *Sys `json:"updatedBy,omitempty"` Version int `json:"version,omitempty"` Revision int `json:"revision,omitempty"` ContentType *ContentType `json:"contentType,omitempty"` Space *Space `json:"space,omitempty"` FirstPublishedAt string `json:"firstPublishedAt,omitempty"` PublishedCounter int `json:"publishedCounter,omitempty"` PublishedAt string `json:"publishedAt,omitempty"` PublishedBy *Sys `json:"publishedBy,omitempty"` PublishedVersion int `json:"publishedVersion,omitempty"` }
Sys model
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
type Webhook ¶
type Webhook struct { Sys *Sys `json:"sys,omitempty"` Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` Topics []string `json:"topics,omitempty"` HTTPBasicUsername string `json:"httpBasicUsername,omitempty"` HTTPBasicPassword string `json:"httpBasicPassword,omitempty"` Headers []*WebhookHeader `json:"headers,omitempty"` }
Webhook model
func (*Webhook) GetVersion ¶
GetVersion returns entity version
type WebhookHeader ¶
WebhookHeader model
type WebhooksService ¶
type WebhooksService service
WebhooksService service
func (*WebhooksService) Delete ¶
func (service *WebhooksService) Delete(spaceID string, webhook *Webhook) error
Delete the webhook
func (*WebhooksService) Get ¶
func (service *WebhooksService) Get(spaceID, webhookID string) (*Webhook, error)
Get returns a single webhook entity
func (*WebhooksService) List ¶
func (service *WebhooksService) List(spaceID string) *Collection
List returns webhooks collection