Skip to content

5PK/agility-fetch-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for agilitycms

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).

Overview

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

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put 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")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

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

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.

URLs Configuration per Operation

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",
	},
})

Documentation for API Endpoints

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.

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

APIKeyAuthorization

  • 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)

Documentation for Utility Methods

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:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

About

GO wrapper for the AgilityCMS FetchAPI, generated by openapi

Resources

Stars

Watchers

Forks

Packages

No packages published