# README
Go API client for hubdb
HubDB is a relational data store that presents data as rows, columns, and cells in a table, much like a spreadsheet. HubDB tables can be added or modified in the HubSpot CMS, but you can also use the API endpoints documented here. For more information on HubDB tables and using their data on a HubSpot site, see the CMS developers site. You can also see the documentation for dynamic pages for more details about the useForPages
field.
HubDB tables support draft
and published
versions. This allows you to update data in the table, either for testing or to allow for a manual approval process, without affecting any live pages using the existing data. Draft data can be reviewed, and published by a user working in HubSpot or published via the API. Draft data can also be discarded, allowing users to go back to the published version of the data without disrupting it. If a table is set to be allowed for public access
, you can access the published version of the table and rows without any authentication by specifying the portal id via the query parameter portalId
.
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: v3
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen
Installation
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import hubdb "github.com/GIT_USER_ID/GIT_REPO_ID"
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 sw.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), hubdb.ContextServerIndex, 1)
Templated Server URL
Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables
of type map[string]string
.
ctx := context.WithValue(context.Background(), hubdb.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 sw.ContextOperationServerIndices
and sw.ContextOperationServerVariables
context maps.
ctx := context.WithValue(context.Background(), hubdb.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), hubdb.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
Documentation for API Endpoints
All URIs are relative to https://api.hubapi.com
Class | Method | HTTP request | Description |
---|---|---|---|
RowsApi | CloneDraftTableRow | Post /cms/v3/hubdb/tables/{tableIdOrName}/rows/{rowId}/draft/clone | Clone a row |
RowsApi | CreateTableRow | Post /cms/v3/hubdb/tables/{tableIdOrName}/rows | Add a new row to a table |
RowsApi | GetDraftTableRowByID | Get /cms/v3/hubdb/tables/{tableIdOrName}/rows/{rowId}/draft | Get a row from the draft table |
RowsApi | GetTableRow | Get /cms/v3/hubdb/tables/{tableIdOrName}/rows/{rowId} | Get a table row |
RowsApi | GetTableRows | Get /cms/v3/hubdb/tables/{tableIdOrName}/rows | Get rows for a table |
RowsApi | PurgeDraftTableRow | Delete /cms/v3/hubdb/tables/{tableIdOrName}/rows/{rowId}/draft | Permanently deletes a row |
RowsApi | ReadDraftTableRows | Get /cms/v3/hubdb/tables/{tableIdOrName}/rows/draft | Get rows from draft table |
RowsApi | ReplaceDraftTableRow | Put /cms/v3/hubdb/tables/{tableIdOrName}/rows/{rowId}/draft | Replaces an existing row |
RowsApi | UpdateDraftTableRow | Patch /cms/v3/hubdb/tables/{tableIdOrName}/rows/{rowId}/draft | Updates an existing row |
RowsBatchApi | PostCmsV3HubdbTablesTableIdOrNameRowsBatchReadReadTableRows | Post /cms/v3/hubdb/tables/{tableIdOrName}/rows/batch/read | Get a set of rows |
RowsBatchApi | PostCmsV3HubdbTablesTableIdOrNameRowsDraftBatchCloneCloneDraftTableRows | Post /cms/v3/hubdb/tables/{tableIdOrName}/rows/draft/batch/clone | Clone rows in batch |
RowsBatchApi | PostCmsV3HubdbTablesTableIdOrNameRowsDraftBatchCreateCreateDraftTableRows | Post /cms/v3/hubdb/tables/{tableIdOrName}/rows/draft/batch/create | Create rows in batch |
RowsBatchApi | PostCmsV3HubdbTablesTableIdOrNameRowsDraftBatchPurgePurgeDraftTableRows | Post /cms/v3/hubdb/tables/{tableIdOrName}/rows/draft/batch/purge | Permanently deletes rows |
RowsBatchApi | PostCmsV3HubdbTablesTableIdOrNameRowsDraftBatchReadReadDraftTableRows | Post /cms/v3/hubdb/tables/{tableIdOrName}/rows/draft/batch/read | Get a set of rows from draft table |
RowsBatchApi | PostCmsV3HubdbTablesTableIdOrNameRowsDraftBatchReplaceReplaceDraftTableRows | Post /cms/v3/hubdb/tables/{tableIdOrName}/rows/draft/batch/replace | Replace rows in batch in draft table |
RowsBatchApi | PostCmsV3HubdbTablesTableIdOrNameRowsDraftBatchUpdateUpdateDraftTableRows | Post /cms/v3/hubdb/tables/{tableIdOrName}/rows/draft/batch/update | Update rows in batch in draft table |
TablesApi | ArchiveTable | Delete /cms/v3/hubdb/tables/{tableIdOrName} | Archive a table |
TablesApi | CloneDraftTable | Post /cms/v3/hubdb/tables/{tableIdOrName}/draft/clone | Clone a table |
TablesApi | CreateTable | Post /cms/v3/hubdb/tables | Create a new table |
TablesApi | ExportDraftTable | Get /cms/v3/hubdb/tables/{tableIdOrName}/draft/export | Export a draft table |
TablesApi | ExportTable | Get /cms/v3/hubdb/tables/{tableIdOrName}/export | Export a published version of a table |
TablesApi | GetAllDraftTables | Get /cms/v3/hubdb/tables/draft | Return all draft tables |
TablesApi | GetAllTables | Get /cms/v3/hubdb/tables | Get all published tables |
TablesApi | GetDraftTableDetailsByID | Get /cms/v3/hubdb/tables/{tableIdOrName}/draft | Get details for a draft table |
TablesApi | GetTableDetails | Get /cms/v3/hubdb/tables/{tableIdOrName} | Get details for a published table |
TablesApi | ImportDraftTable | Post /cms/v3/hubdb/tables/{tableIdOrName}/draft/import | Import data into draft table |
TablesApi | PublishDraftTable | Post /cms/v3/hubdb/tables/{tableIdOrName}/draft/publish | Publish a table from draft |
TablesApi | ResetDraftTable | Post /cms/v3/hubdb/tables/{tableIdOrName}/draft/reset | Reset a draft table |
TablesApi | UnpublishTable | Post /cms/v3/hubdb/tables/{tableIdOrName}/unpublish | Unpublish a table |
TablesApi | UpdateDraftTable | Patch /cms/v3/hubdb/tables/{tableIdOrName}/draft | Update an existing table |
Documentation For Models
- BatchInputHubDbTableRowV3BatchUpdateRequest
- BatchInputHubDbTableRowV3Request
- BatchInputString
- BatchResponseHubDbTableRowV3
- BatchResponseHubDbTableRowV3WithErrors
- CollectionResponseWithTotalHubDbTableRowV3ForwardPaging
- CollectionResponseWithTotalHubDbTableV3ForwardPaging
- Column
- ColumnRequest
- Error
- ErrorDetail
- ForeignId
- ForwardPaging
- HubDbTableCloneRequest
- HubDbTableRowV3
- HubDbTableRowV3BatchUpdateRequest
- HubDbTableRowV3Request
- HubDbTableV3
- HubDbTableV3Request
- ImportResult
- NextPage
- Option
- SimpleUser
- StandardError
Documentation For Authorization
Authentication schemes defined for the API:
oauth2_legacy
- Type: OAuth
- Flow: accessCode
- Authorization URL: https://app.hubspot.com/oauth/authorize
- Scopes:
- hubdb: Read from and write to my HubDB
Example
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
import "golang.org/x/oauth2"
/* Perform OAuth2 round trip request and obtain a token */
tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)
private_apps_legacy
- Type: API key
- API key parameter name: private-app-legacy
- Location: HTTP header
Note, each API key must be added to a map of map[string]APIKey
where the key is: private-app-legacy and passed in as the auth context for each request.
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