Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ packages/**/*/build
**/*.eslintcache
.pnp.*
.yarn/
dist/

.DS_Store
**/*.DS_Store
Expand Down
127 changes: 121 additions & 6 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,152 @@
GCP_ARTIFACT_HOST: ${{ vars.SHARED_WIF_LOCATON }}-docker.pkg.dev
GCP_REGISTRY: ${{ vars.SHARED_WIF_LOCATON }}-docker.pkg.dev/${{ vars.SHARED_WIF_PROJECT }}/${{ vars.SHARED_WIF_REPO }}
IMAGE_NAME: portal-public-api-docs
PYTHON_VERSION: 3.14

jobs:
python-build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
# v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0

- name: Set up Python
# v7.0.0
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Init Python
run: |
mkdir -p "dist/neon-data-api-docs-site"
python -m pip install --upgrade pip
python -m pip install --no-cache-dir -r requirements.txt
sed -i "s/{{TIMESTAMP}}/$(date +%s)/g" docs/content/explorer/index.md
sed -i "s/{{TIMESTAMP}}/$(date +%s)/g" docs/content/graphql/explorer/index.md
sed -i "s/{{COPYRIGHT_YEAR}}/$(date +%Y)/g" mkdocs.yml
mkdocs build --config-file mkdocs.yml
mv site dist/neon-data-api-docs-site/

- name: Upload Build Artifact
# v7.0.1
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: neon-data-api-docs-site
path: dist/neon-data-api-docs-site
if-no-files-found: error
retention-days: 1

go-build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ linux-amd64, linux-arm64 ]
include:
- os: linux-amd64
goarch: amd64
- os: linux-arm64
goarch: arm64
steps:
- name: Checkout
# v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0

- name: Set up Go
# v7.0.0
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e
env:
# Ensure cache consistency on Linux, see https://github.com/actions/setup-go/pull/383
ImageOS: ${{ matrix.os }}
with:
go-version-file: 'server/go.mod'
check-latest: true
cache: false

- name: Build Go
env:
GOOS: linux
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
cd server
mkdir -p "dist/linux/${GOARCH}"
go build -trimpath -o "dist/linux/${GOARCH}/server" server.go

- name: Upload Build Artifact
# v7.0.1
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: server-${{ matrix.goarch }}
path: server/dist/linux/${{ matrix.goarch }}/server
retention-days: 1

docker-publish:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
needs:
- go-build
- python-build
steps:
- name: Checkout
uses: actions/checkout@v6
# v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0

- name: Download Python Build Artifacts
# v8.0.1
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
name: neon-data-api-docs-site
path: dist/neon-data-api-docs-site

- name: Download Go Build Artifacts
# v8.0.1
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
path: dist/
pattern: "server-*"
merge-multiple: false

- name: Google Auth
id: 'auth'
uses: 'google-github-actions/auth@v3'
# v3.0.0
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093
with:
workload_identity_provider: "${{ vars.SHARED_WIF_PROVIDER }}"
service_account: "${{ vars.SHARED_WIF_SERVICE_ACCOUNT }}"
token_format: 'access_token'

- name: Docker Login
uses: 'docker/login-action@v4'
# v4.6.0
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f
with:
registry: ${{ env.GCP_ARTIFACT_HOST }}
username: 'oauth2accesstoken'
password: ${{ steps.auth.outputs.access_token }}

# Setup QEMU for multi-platform / arm64 support
- name: Setup QEMU
# v4.2.0
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8

- name: Docker Buildx Setup
uses: docker/setup-buildx-action@v4
# v4.3.0
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e

- name: Docker Metadata
id: meta
uses: docker/metadata-action@v6
# v6.2.0
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302
with:
images: ${{ env.GCP_REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
Expand All @@ -51,7 +165,8 @@
latest=false

- name: Docker Build
uses: docker/bake-action@v7
# v7.3.0
uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b
with:
source: .
files: |
Expand Down
45 changes: 5 additions & 40 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,16 @@
#-------------------------------------------------------------------------------
# Builder container for reproducible build environment

FROM python:3.14-alpine AS builder

WORKDIR /usr/src/app
COPY ./docs /usr/src/app/build-temp/api-docs/docs
COPY ./mkdocs.yml /usr/src/app/build-temp/api-docs
COPY ./requirements.txt /usr/src/app/build-temp/api-docs

RUN apk add --no-cache build-base
RUN cd /usr/src/app/build-temp/api-docs \
&& pip install --upgrade pip \
&& pip install -r requirements.txt
RUN cd /usr/src/app/build-temp/api-docs \
&& sed -i "s/{{TIMESTAMP}}/$(date +%s)/g" docs/content/explorer/index.md \
&& sed -i "s/{{TIMESTAMP}}/$(date +%s)/g" docs/content/graphql/explorer/index.md \
&& sed -i "s/{{COPYRIGHT_YEAR}}/$(date +%Y)/g" mkdocs.yml \
&& mkdocs build --config-file mkdocs.yml \
&& mv /usr/src/app/build-temp/api-docs/site /usr/src/app/ \
&& rm -rf /usr/src/app/build-temp

#-------------------------------------------------------------------------------
# Builder container for reproducible build environment

FROM golang:1.25-alpine AS go-builder

WORKDIR /go/src/app

COPY ./server/server.go .
COPY ./server/go.mod .
COPY --from=builder /usr/src/app .

RUN go mod verify \
&& go build server.go \
&& rm server.go \
&& rm go.mod

#-------------------------------------------------------------------------------
# Build production container with only necessary artifacts

FROM alpine:3.23
FROM alpine:3.24

ARG TARGETARCH

EXPOSE 3020

# Copy build artifacts from builder container
WORKDIR /go/src/app
COPY --from=go-builder /go/src/app .
COPY --chmod=500 dist/server-${TARGETARCH} .
COPY dist/neon-data-api-docs-site .

# Set app wide env variables
ENV PORTAL_CLIENT_ROUTE="/"
Expand Down
2 changes: 1 addition & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ target "docker-metadata-action" {
}

target "bootstrap" {
platforms = [ "linux/amd64" ]
platforms = [ "linux/amd64", "linux/arm64" ]
no-cache = true
}

Expand Down
35 changes: 18 additions & 17 deletions docs/content/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@
You do not need to authenticate in order to explore information about NEON data or locations. However, if you will be using the APIs to download data products or sample data, or using the APIs intensively, then you will need to sign up for and use an [API Token](#api-tokens). To learn more about setting up and utilizing an API Token, see [API Token Setup](https://www.neonscience.org/resources/learning-hub/tutorials/api-token-setup).

<a name="api-tokens"></a>
## **API Tokens**
## **API Tokens**

The NEON data API provides users the ability to manage and obtain API tokens.

### **Generation**

In order to generate an API Token, you must first sign in with your account
or create an account with the Data Portal. You can sign up or sign in by accessing
the [My Account](https://data.neonscience.org/myaccount) page. Once authenticated
and verified, you can request a token using the API Token management section
In order to generate an API Token, you must first sign in with your account
or create an account with the Data Portal. You can sign up or sign in by accessing
the [My Account](https://data.neonscience.org/myaccount) page. Once authenticated
and verified, you can request a token using the API Token management section
provided on the account page.

!!! warning
Tokens should be treated like credentials.
Never share your API token and store it in a secure location.
It is strongly recommended to never commit this token to source control
repositories such as GitHub. If your token has been compromised,
please disable or delete the token through the
[My Account](https://data.neonscience.org/myaccount) page and discontinue
Tokens should be treated like credentials.
Never share your API token and store it in a secure location.
It is strongly recommended to never commit this token to source control
repositories such as GitHub. If your token has been compromised,
please disable or delete the token through the
[My Account](https://data.neonscience.org/myaccount) page and discontinue
use of the token.

### **Utilization**

To utilize an API Token when making a request, include it as a header or query
parameter:
To utilize an API Token when making a request, include it as a header or query
parameter:

- Header Name: `X-API-Token`
- Query Parameter Name: `apiToken`
- Query Parameter Name: `apiToken`

=== "cURL"

Expand All @@ -40,13 +40,13 @@ parameter:
curl --verbose -H "X-API-Token: TOKEN_VALUE" \
-X GET https://data.neonscience.org/api/v0/products/DP1.00001.001 \
>> neon-data-products-DP1.00001.001.json
```
```
``` bash
# apiToken query parameter
curl --verbose \
-X GET https://data.neonscience.org/api/v0/products/DP1.00001.001?apiToken=TOKEN_VALUE \
>> neon-data-products-DP1.00001.001.json
```
```

=== "HTTPie"

Expand All @@ -56,7 +56,7 @@ parameter:
http --download --output=neon-data-products-DP1.00001.001.json \
GET https://data.neonscience.org/api/v0/products/DP1.00001.001 \
X-API-Token:TOKEN_VALUE
```
```
``` bash
# apiToken query parameter
http --download --output=neon-data-products-DP1.00001.001.json \
Expand All @@ -69,6 +69,7 @@ Endpoints that require authentication are identified in the documentation for ea

- [Data Endpoints](/data-api/endpoints/data)
- [Data Query Endpoints](/data-api/endpoints/data-query)
- [Prototype Datasets Endpoints](/data-api/endpoints/prototype-datasets)
- [Releases Endpoints](/data-api/endpoints/releases)
- [Samples Endpoints](/data-api/endpoints/samples)

Expand Down
21 changes: 20 additions & 1 deletion docs/content/endpoints/prototype-datasets.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Prototype Datasets Endpoint

!!! requires-auth "Requires Authentication"

One or more endpoints require [API Token](/data-api/authentication#api-tokens) authentication, indicated below.


The `/prototype/datasets` endpoint provides information about all prototype NEON datasets. Prototype datasets have generally been collected during the design and construction of NEON. These datasets are not necessarily representative of the long-term standardized data otherwise available on the NEON data portal. Prototype data are provided as downloadable zip files.

The `/prototype/data` endpoint provides access to all data associated with a single dataset.
Expand Down Expand Up @@ -82,6 +87,13 @@ Get information about a prototype dataset
<a name="get_prototype_data_uuid"></a>
### GET `/prototype/data/{uuid}`

#### **Authentication**

!!! requires-auth "Requires Authentication"

[API Token](/data-api/authentication#api-tokens) required to utilize this endpoint.


#### **Description**
Get information about data files for the prototype dataset

Expand Down Expand Up @@ -121,6 +133,13 @@ Get information about data files for the prototype dataset
<a name="get_prototype_data_uuid_file"></a>
### GET `/prototype/data/{uuid}/{filename}`

#### **Authentication**

!!! requires-auth "Requires Authentication"

[API Token](/data-api/authentication#api-tokens) required to utilize this endpoint.


#### **Description**
Gets a data file

Expand Down Expand Up @@ -324,7 +343,7 @@ Type definition for a prototype dataset related data product
|**dataProductDescription** |A brief description of the data product|string|

<a name="error"></a>
### **error**
### **error**

Information about errors in the response

Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/content/explorer/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin="">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter:300,400,400i,700%7CRoboto+Mono&amp;display=fallback">
<title>NEON Data API REST Explorer</title>
<script type="module" crossorigin src="./assets/index-DQyYJE7k.js"></script>
<script type="module" crossorigin src="./assets/index-BbpVoW5T.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-BrfHAX51.css">
</head>
<body>
Expand Down
Loading
Loading