Skip to content

Add Template API support - #280

Merged
MovieStoreGuy merged 4 commits into
signalfx:masterfrom
jdillman-splunk:dashm-1965-template-api
Sep 25, 2026
Merged

MovieStoreGuy merged 4 commits into
signalfx:masterfrom
jdillman-splunk:dashm-1965-template-api

Conversation

@jdillman-splunk

Copy link
Copy Markdown
Contributor
  • Client methods for Create, Get, Update, Delete, and Search of Template records
  • Template model support for Dashboard and Chart root elements, including imports and datasource metadata
  • Tests and fixtures covering create/get/update/delete/search and error responses

@jdillman-splunk
jdillman-splunk marked this pull request as ready for review September 10, 2026 18:06
@jdillman-splunk
jdillman-splunk requested review from a team as code owners September 10, 2026 18:06
@jdillman-splunk jdillman-splunk changed the title Draft: Add Template API support Add Template API support Sep 10, 2026
Comment thread template/model_template.go Outdated
import "encoding/json"

// RecordType is the schema type used by Template API records.
const RecordType = "https://schema.splunkdev.com/dashify/v1/templates/Record"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had just tried to resolve this URL, and it doesn't work.
Is that to be expected?

@jdillman-splunk jdillman-splunk Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that's expected. Not really sure why we do that either (maybe it's a future thing) but everywhere we refer to the TemplateRecord we use that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additional info in this comment: #280 (comment)

Comment thread template/model_template.go
Comment thread template/model_template.go Outdated
Comment on lines +104 to +112
// Collection describes a page of Template URI references.
type Collection struct {
Type string `json:"type"`
Self string `json:"self"`
Next *string `json:"next"`
Prev *string `json:"prev"`
Count int64 `json:"count"`
Items []string `json:"items"`
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is pagination definition for what exactly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template search.

/v2/template?size=200&search=foobar&rootElement=Dashboard

"data": {
        "count": 186,
        "items": [
            "/v2/template/HKAB1GoAEBY",
            ...
        ],
        "next": null,
        "prev": null,
        "self": "/v2/template?rootElement=Dashboard&offset=0&size=200&search=j",
        "type": "https://schema.splunkdev.com/dashify/v1/common/Collection"
    },

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to rename this type or update the godoc to make it clearer to the user that this is a pagination value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed and made it a bit more clear it's related to pagination in the comments

Comment thread testdata/fixtures/template/chart_success.json
"data": {
"id": "HNPz_pNAIAE",
"self": "/v2/template/HNPz_pNAIAE",
"type": "https://schema.splunkdev.com/dashify/v1/templates/Record",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a non resolvable domain

@jdillman-splunk jdillman-splunk Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep.

All our reference types are like this and I can't say I fully understand the reason ... placeholder maybe?

Here is what AI said:

Why URIs instead of a plain enum string like "Record": it's a namespacing convention — borrowing splunkdev.com to make the tag globally unique and attributable to this org/product, the same way XML namespaces or JSON-LD @type values work. It doesn't imply a fetchable document. There's real precedent for this: RFC 7807 (Problem Details for HTTP APIs) defines a type field as a URI reference that clients are explicitly told need not be dereferenceable — it's identity, not location.

@MovieStoreGuy MovieStoreGuy Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference is to omit the domain and schema and just have #/path/to/reference similar to how one would define in OpenAPI spec.

What I am trying to avoid is a future bug bounty issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the domain and schema

Comment thread template/model_template.go Outdated
Comment thread template.go Outdated
Comment thread template_test.go
Drop the schema.splunkdev.com domain from record/collection type
URIs in favor of local #/... fragments, avoiding a URI that looks
dereferenceable and reads as an internal-domain reference. Rename
Content -> CreateUpdateTemplateRequest and Collection -> SearchPage
for clarity per review feedback.
@MovieStoreGuy
MovieStoreGuy merged commit aa76ac8 into signalfx:master Sep 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants