Agility CMS REST API for retrieving content from the Agility CMS. The API Types are fetch (for published content) and preview (for latest, or staging content).
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: v1
- Package version: 1.0.0
- Generator version: 7.14.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://help.agilitycms.com
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/net/contextPut the package under your project folder and add the following in import:
import agilitycms "github.com/kevin-dev/agility-fetch-go"To use a proxy, set the environment variable HTTP_PROXY:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.
For using other server than the one defined on index 0 set context value agilitycms.ContextServerIndex of type int.
ctx := context.WithValue(context.Background(), agilitycms.ContextServerIndex, 1)Templated server URL is formatted using default variables from configuration or from context value agilitycms.ContextServerVariables of type map[string]string.
ctx := context.WithValue(context.Background(), agilitycms.ContextServerVariables, map[string]string{
"basePath": "v2",
})Note, enum values are always validated and all unused variables are silently ignored.
Each operation can use different server URL defined using OperationServers map in the Configuration.
An operation is uniquely identified by "{classname}Service.{nickname}" string.
Similar rules for overriding default operation server index and variables applies by using agilitycms.ContextOperationServerIndices and agilitycms.ContextOperationServerVariables context maps.
ctx := context.WithValue(context.Background(), agilitycms.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), agilitycms.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})All URIs are relative to http://localhost
| Class | Method | HTTP request | Description |
|---|---|---|---|
| ContentModelsAPI | ContentmodelsGet | Get /{guid}/{apitype}/contentmodels | Returns content models for the Agility instance. |
| GalleryAPI | GalleryIdGet | Get /{guid}/{apitype}/gallery/{id} | Gets the gallery by ID. |
| ItemAPI | ItemIdGet | Get /{guid}/{apitype}/{locale}/item/{id} | Gets the details of a content item by ther Content ID. |
| ListAPI | ListReferenceNameGet | Get /{guid}/{apitype}/{locale}/list/{referenceName} | Retrieves a list of content items by reference name. |
| PageAPI | PageChannelGet | Get /{guid}/{apitype}/{locale}/page/{channel} | Gets the details of a page by its Page path, in a specific channel. |
| PageAPI | PageIdGet | Get /{guid}/{apitype}/{locale}/page/{id} | Gets the details of a page by its Page ID. |
| SitemapAPI | SitemapFlatChannelNameGet | Get /{guid}/{apitype}/{locale}/sitemap/flat/{channelName} | Gets the sitemap, returned in a flat list, where the dictionary key is the page path. This method is ideal for page routing. |
| SitemapAPI | SitemapNestedChannelNameGet | Get /{guid}/{apitype}/{locale}/sitemap/nested/{channelName} | Gets the sitemap as an array in a nested format, ideal for generating menus. |
| SyncAPI | SyncItemsGet | Get /{guid}/{apitype}/{locale}/sync/items | Retrieves all content items in a paged format. Each call returns a sync token that should be persisted and passed into subsequent requests to maintain sync state. |
| SyncAPI | SyncPagesGet | Get /{guid}/{apitype}/{locale}/sync/pages | Retrieves all pages items in a paged format. Each call returns a sync token that should be persisted and passed into subsequent requests to maintain sync state. |
| UrlRedirectionAPI | UrlredirectionGet | Get /{guid}/{apitype}/urlredirection | Gets the list of all URL Redirections since a particular date/time. Persist the lastAccessDate that is returned and use that value to maintain state on subsequent requests. |
- APIType
- AgilityDefinition
- AgilityField
- AgilityFieldType
- HeadlessContentItem
- HeadlessContentItemHeadlessSync
- HeadlessContentItemProperties
- HeadlessContentItemSeo
- HeadlessContentListResponse
- HeadlessContentPage
- HeadlessContentPageBase
- HeadlessContentPageByPath
- HeadlessContentPageHeadlessSync
- HeadlessContentPageVisibility
- HeadlessContentScripts
- HeadlessContentSiteMapItem
- HeadlessContentSiteMapNestedItem
- HeadlessContentZone
- HeadlessGallery
- HeadlessMediaItem
- NotFoundResult
- RedirectUrl
- UrlRedirection
Authentication schemes defined for the API:
- Type: API key
- API key parameter name: APIKey
- Location: HTTP header
Note, each API key must be added to a map of map[string]APIKey where the key is: APIKeyAuthorization and passed in as the auth context for each request.
Example
auth := context.WithValue(
context.Background(),
agilitycms.ContextAPIKeys,
map[string]agilitycms.APIKey{
"APIKeyAuthorization": {Key: "API_KEY_STRING"},
},
)
r, err := client.Service.Operation(auth, args)Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBoolPtrIntPtrInt32PtrInt64PtrFloatPtrFloat32PtrFloat64PtrStringPtrTime