docs-v2/layouts/partials/api/all-endpoints-list.html

222 lines
8.6 KiB
HTML

{{/*
All Endpoints List
Renders all API operations grouped by version (v3, v2, v1) and sorted by path.
Links point to tag pages with hash anchors (e.g., /api/cache-data/#operation/PostConfigureDistinctCache)
Excludes conceptual/trait tag operations.
Uses frontmatter params:
- articleDataKey: product data key (e.g., 'influxdb3-core')
- articleSection: section slug (e.g., 'api' or 'management-api')
*/}}
{{ $currentPage := . }}
{{/* Read data key and section from frontmatter */}}
{{ $dataKey := .Params.articleDataKey | default "" }}
{{ $section := .Params.articleSection | default "" }}
{{/* Get article data using frontmatter-driven lookup */}}
{{ $articles := slice }}
{{ if and $dataKey $section }}
{{ with site.Data.article_data }}
{{ with index . "influxdb" }}
{{ with index . $dataKey }}
{{ with index . $section }}
{{ with index . "articles" }}
{{ with .articles }}
{{ $articles = . }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{/* Build a map of tag name -> article path for URL lookups */}}
{{ $tagToPath := dict }}
{{ range $articles }}
{{ if and (reflect.IsMap .) (isset . "fields") }}
{{ $fields := index . "fields" }}
{{ if reflect.IsMap $fields }}
{{ if isset $fields "tag" }}
{{ $tag := index $fields "tag" }}
{{ $path := index . "path" }}
{{ $tagToPath = merge $tagToPath (dict $tag $path) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{/* Collect all operations from non-conceptual articles */}}
{{ $allOperations := slice }}
{{ range $articles }}
{{ if and (reflect.IsMap .) (isset . "fields") }}
{{ $fields := index . "fields" }}
{{ if reflect.IsMap $fields }}
{{ $isConceptual := false }}
{{ if isset $fields "isConceptual" }}
{{ $isConceptual = index $fields "isConceptual" }}
{{ end }}
{{ if not $isConceptual }}
{{ if isset $fields "operations" }}
{{ $tag := index $fields "tag" }}
{{ $articlePath := index . "path" }}
{{ range index $fields "operations" }}
{{ $allOperations = $allOperations | append (dict "op" . "tag" $tag "articlePath" $articlePath) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ if gt (len $allOperations) 0 }}
{{/* Group operations by API version prefix */}}
{{ $v3Ops := slice }}
{{ $v2Ops := slice }}
{{ $v1Ops := slice }}
{{ $otherOps := slice }}
{{ range $allOperations }}
{{ $path := .op.path }}
{{ if hasPrefix $path "/api/v3" }}
{{ $v3Ops = $v3Ops | append . }}
{{ else if hasPrefix $path "/api/v2" }}
{{ $v2Ops = $v2Ops | append . }}
{{ else if or (hasPrefix $path "/api/v1") (hasPrefix $path "/health") (hasPrefix $path "/ping") (hasPrefix $path "/metrics") (hasPrefix $path "/query") (hasPrefix $path "/write") }}
{{ $v1Ops = $v1Ops | append . }}
{{ else }}
{{ $otherOps = $otherOps | append . }}
{{ end }}
{{ end }}
{{/* Sort each group by path then method */}}
{{ $sortV3 := slice }}
{{ range $v3Ops }}
{{ $sortKey := printf "%s %s" .op.path (upper .op.method) }}
{{ $sortV3 = $sortV3 | append (dict "sortKey" $sortKey "data" .) }}
{{ end }}
{{ $sortV3 = sort $sortV3 "sortKey" }}
{{ $sortV2 := slice }}
{{ range $v2Ops }}
{{ $sortKey := printf "%s %s" .op.path (upper .op.method) }}
{{ $sortV2 = $sortV2 | append (dict "sortKey" $sortKey "data" .) }}
{{ end }}
{{ $sortV2 = sort $sortV2 "sortKey" }}
{{ $sortV1 := slice }}
{{ range $v1Ops }}
{{ $sortKey := printf "%s %s" .op.path (upper .op.method) }}
{{ $sortV1 = $sortV1 | append (dict "sortKey" $sortKey "data" .) }}
{{ end }}
{{ $sortV1 = sort $sortV1 "sortKey" }}
{{/* Render v3 API endpoints */}}
{{ if gt (len $sortV3) 0 }}
<section class="api-operations-list api-version-group">
<h2 id="v3-api">v3 API</h2>
<div class="api-operations-grid">
{{ range $sortV3 }}
{{ $op := .data.op }}
{{ $articlePath := .data.articlePath }}
{{/* Build tag page URL with hash anchor: operation/{operationId} */}}
{{/* Build tag page URL relative to the section (parent of all-endpoints) */}}
{{ $sectionUrl := $currentPage.Parent.RelPermalink }}
{{ $tagSlug := path.Base $articlePath }}
{{ $tagPageUrl := printf "%s%s/" $sectionUrl $tagSlug }}
{{ $hashAnchor := printf "#operation/%s" $op.operationId }}
<a href="{{ $tagPageUrl }}{{ $hashAnchor | safeURL }}" class="api-operation-card">
<span class="api-method api-method--{{ lower $op.method }}">{{ upper $op.method }}</span>
<code class="api-path">{{ $op.path }}</code>
<span class="api-operation-summary">{{ $op.summary }}</span>
</a>
{{ end }}
</div>
</section>
{{ end }}
{{/* Render v2-compatible endpoints */}}
{{ if gt (len $sortV2) 0 }}
<section class="api-operations-list api-version-group">
<h2 id="v2-compatible">v2-compatible API</h2>
<div class="api-operations-grid">
{{ range $sortV2 }}
{{ $op := .data.op }}
{{ $articlePath := .data.articlePath }}
{{/* Build tag page URL with hash anchor: operation/{operationId} */}}
{{/* Build tag page URL relative to the section (parent of all-endpoints) */}}
{{ $sectionUrl := $currentPage.Parent.RelPermalink }}
{{ $tagSlug := path.Base $articlePath }}
{{ $tagPageUrl := printf "%s%s/" $sectionUrl $tagSlug }}
{{ $hashAnchor := printf "#operation/%s" $op.operationId }}
<a href="{{ $tagPageUrl }}{{ $hashAnchor | safeURL }}" class="api-operation-card">
<span class="api-method api-method--{{ lower $op.method }}">{{ upper $op.method }}</span>
<code class="api-path">{{ $op.path }}</code>
<span class="api-operation-summary">{{ $op.summary }}</span>
{{ with $op.compatVersion }}<span class="api-compat-badge api-compat-badge--{{ . }}">{{ . }}</span>{{ end }}
</a>
{{ end }}
</div>
</section>
{{ end }}
{{/* Render v1-compatible endpoints */}}
{{ if gt (len $sortV1) 0 }}
<section class="api-operations-list api-version-group">
<h2 id="v1-compatible">v1-compatible API</h2>
<div class="api-operations-grid">
{{ range $sortV1 }}
{{ $op := .data.op }}
{{ $articlePath := .data.articlePath }}
{{/* Build tag page URL with hash anchor: operation/{operationId} */}}
{{/* Build tag page URL relative to the section (parent of all-endpoints) */}}
{{ $sectionUrl := $currentPage.Parent.RelPermalink }}
{{ $tagSlug := path.Base $articlePath }}
{{ $tagPageUrl := printf "%s%s/" $sectionUrl $tagSlug }}
{{ $hashAnchor := printf "#operation/%s" $op.operationId }}
<a href="{{ $tagPageUrl }}{{ $hashAnchor | safeURL }}" class="api-operation-card">
<span class="api-method api-method--{{ lower $op.method }}">{{ upper $op.method }}</span>
<code class="api-path">{{ $op.path }}</code>
<span class="api-operation-summary">{{ $op.summary }}</span>
{{ with $op.compatVersion }}<span class="api-compat-badge api-compat-badge--{{ . }}">{{ . }}</span>{{ end }}
</a>
{{ end }}
</div>
</section>
{{ end }}
{{/* Render Management API endpoints (paths not matching v1/v2/v3 patterns) */}}
{{ if gt (len $otherOps) 0 }}
{{ $sortOther := slice }}
{{ range $otherOps }}
{{ $sortKey := printf "%s %s" .op.path (upper .op.method) }}
{{ $sortOther = $sortOther | append (dict "sortKey" $sortKey "data" .) }}
{{ end }}
{{ $sortOther = sort $sortOther "sortKey" }}
<section class="api-operations-list api-version-group">
<h2 id="management-api">Management API</h2>
<div class="api-operations-grid">
{{ range $sortOther }}
{{ $op := .data.op }}
{{ $articlePath := .data.articlePath }}
{{/* Build tag page URL with hash anchor: operation/{operationId} */}}
{{/* Build tag page URL relative to the section (parent of all-endpoints) */}}
{{ $sectionUrl := $currentPage.Parent.RelPermalink }}
{{ $tagSlug := path.Base $articlePath }}
{{ $tagPageUrl := printf "%s%s/" $sectionUrl $tagSlug }}
{{ $hashAnchor := printf "#operation/%s" $op.operationId }}
<a href="{{ $tagPageUrl }}{{ $hashAnchor | safeURL }}" class="api-operation-card">
<span class="api-method api-method--{{ lower $op.method }}">{{ upper $op.method }}</span>
<code class="api-path">{{ $op.path }}</code>
<span class="api-operation-summary">{{ $op.summary }}</span>
</a>
{{ end }}
</div>
</section>
{{ end }}
{{ else }}
<p>No endpoints available.</p>
{{ end }}