Skip to content
Draft
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
112 changes: 112 additions & 0 deletions .github/workflows/sync-openapi-specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Sync OpenAPI Specs

on:
schedule:
# Run monthly on the 1st day at 6:00 AM UTC
- cron: "0 6 1 * *"
workflow_dispatch: # Allow manual trigger

jobs:
sync-specs:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22.5"

- name: Download latest OpenAPI specs
run: |
# Create temporary directory for new specs
mkdir -p temp_specs/cloud temp_specs/core temp_specs/enterprise

# Download Cloud Dedicated spec
curl -f -o temp_specs/cloud/openapi.yml \
https://raw.githubusercontent.com/influxdata/docs-v2/master/api-docs/influxdb3/cloud-dedicated/management/openapi.yml

# Download Core spec
curl -f -o temp_specs/core/ref.yml \
https://raw.githubusercontent.com/influxdata/docs-v2/master/api-docs/influxdb3/core/v3/ref.yml

# Download Enterprise spec
curl -f -o temp_specs/enterprise/ref.yml \
https://raw.githubusercontent.com/influxdata/docs-v2/master/api-docs/influxdb3/enterprise/v3/ref.yml

- name: Check for changes
id: check-changes
run: |
changes_detected=false

# Check Cloud spec
if ! cmp -s temp_specs/cloud/openapi.yml specs/cloud/openapi.yml; then
echo "Changes detected in Cloud spec"
changes_detected=true
fi

# Check Core spec
if ! cmp -s temp_specs/core/ref.yml specs/core/ref.yml; then
echo "Changes detected in Core spec"
changes_detected=true
fi

# Check Enterprise spec
if ! cmp -s temp_specs/enterprise/ref.yml specs/enterprise/ref.yml; then
echo "Changes detected in Enterprise spec"
changes_detected=true
fi

echo "changes_detected=$changes_detected" >> $GITHUB_OUTPUT

- name: Update specs and regenerate code
if: steps.check-changes.outputs.changes_detected == 'true'
run: |
# Copy new specs
cp temp_specs/cloud/openapi.yml specs/cloud/openapi.yml
cp temp_specs/core/ref.yml specs/core/ref.yml
cp temp_specs/enterprise/ref.yml specs/enterprise/ref.yml

# Regenerate Go code
go generate ./...

- name: Create Pull Request
if: steps.check-changes.outputs.changes_detected == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "feat: update OpenAPI specs and regenerate client code"
title: "chore: sync OpenAPI specs from upstream"
body: |
## 🔄 Automated OpenAPI Spec Sync

This PR was automatically generated to sync the OpenAPI specifications with the latest versions from the InfluxData documentation repository.

### Changes
- 🌤️ **InfluxDB Cloud Dedicated**: Updated management API spec
- 🏗️ **InfluxDB Core**: Updated v3 API spec
- 🏢 **InfluxDB Enterprise**: Updated v3 API spec

### What's Updated
- OpenAPI specification files in `specs/` directory
- Generated Go client code in `cloud/`, `core/`, and `enterprise/` packages

### Verification
- [ ] Specs downloaded successfully
- [ ] Go code generation completed without errors
- [ ] All tests pass (if applicable)

---
🤖 This is an automated PR created by the sync workflow.
branch: automated/sync-openapi-specs
delete-branch: true

- name: Cleanup
run: rm -rf temp_specs
31 changes: 31 additions & 0 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "update-changelog"

on:
release:
types:
- published

permissions:
contents: write

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}

- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
latest-version: ${{ github.event.release.tag_name }}
release-notes: ${{ github.event.release.body }}

- name: Commit updated Changelog
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: ${{ github.event.repository.default_branch }}
commit_message: "docs(changelog): update changelog"
file_pattern: CHANGELOG.md
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

All notable changes to this project will automatically be documented in this file.

The format is based on vKeep a Changelog(https://keepachangelog.com/en/1.0.0/),
and this project adheres to vSemantic Versioning(https://semver.org/spec/v2.0.0.html).
104 changes: 34 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,46 @@
# InfluxDB v3 Cloud Dedicated Management API Go Client Library
# InfluxDB v3 Management Go Client Library

The InfluxDB v3 Management API Go client library lets you manage an InfluxDB Cloud Dedicated instance and integrate functions such as creating and managing databases, permissions, and tokens into your workflow or application.
A Go client library for InfluxDB v3 products, supporting Cloud Dedicated, Core, and Enterprise deployments.

## Generated types and API client
## Supported products

This library is generated using [oapi-codegen](https://github.com/oapi-codegen/oapi-codegen) from this [OpenAPI spec](https://github.com/influxdata/docs-v2/blob/master/api-docs/influxdb3/cloud-dedicated/management/openapi.yml)
### InfluxDB 3 Cloud Dedicated

### Generate
Management API for InfluxDB Cloud Dedicated clusters, databases, and tokens.

```go
go generate ./...
```
**Import**: `import "github.com/komminarlabs/influxdb3-management-go/cloud"`

### InfluxDB 3 Core

Core API for writing data, querying with SQL/InfluxQL, and managing local instances.

**Import**: `import "github.com/komminarlabs/influxdb3-management-go/core"`

### InfluxDB 3 Enterprise

Enterprise API with advanced features including processing engine and fine-grained permissions.

## Usage
**Import**: `import "github.com/komminarlabs/influxdb3-management-go/enterprise"`

### Environment variables
## 🚀 Installation

Install the product(s) you need:

```bash
export INFLUXDB_BASE_URL="https://console.influxdata.com/api/v0"
export INFLUXDB_ACCOUNT_ID="4ade9b2e-0a52-4a46-b3b8-1b43ea493a98"
export INFLUXDB_CLUSTER_ID="a379c48a-791e-47fe-ba64-628ba19507e8"
export INFLUXDB_TOKEN="1e0f14063eb14a9e94fe765bf999a90cb7962f8e0f394110b91053ea26cdce5071d6bca29e4d4684bed463cf2ea9f381"
# Cloud Dedicated
go get github.com/komminarlabs/influxdb3-management-go/cloud

# Core
go get github.com/komminarlabs/influxdb3-management-go/core

# Enterprise
go get github.com/komminarlabs/influxdb3-management-go/enterprise
```

### Sample code to list database tokens

```go
package main

import (
"context"
"io"
"net/http"

"github.com/caarlos0/env/v11"
"github.com/komminarlabs/influxdb3"
)

type InfluxdbConfig struct {
AccountId influxdb3.UuidV4 `env:"INFLUXDB_ACCOUNT_ID"`
BaseURL string `env:"INFLUXDB_BASE_URL"`
ClusterId influxdb3.UuidV4 `env:"INFLUXDB_CLUSTER_ID"`
Token string `env:"INFLUXDB_TOKEN"`
}

func main() {
cfg := InfluxdbConfig{}
opts := env.Options{RequiredIfNoDef: true}

err := env.ParseWithOptions(&cfg, opts)
if err != nil {
panic(err)
}

ctx := context.Background()
client, err := influxdb3.NewClient(cfg.BaseURL, influxdb3.WithRequestEditorFn(func(ctx context.Context, req *http.Request) error {
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer "+cfg.Token)
return nil

}))
if err != nil {
panic(err)
}

resp, err := client.GetDatabaseTokens(ctx, cfg.AccountId, cfg.ClusterId)
if err != nil {
panic(err)
}
defer resp.Body.Close()

if resp.StatusCode == http.StatusOK {
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
bodyString := string(bodyBytes)
println(bodyString)
}
}
## 🔧 Development

### Generate Go Code from OpenAPI Specs

```bash
go generate ./...
```
30 changes: 30 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Upgrading Notes

This document captures required refactoring on your part when upgrading to a module version that contains breaking changes.

## Upgrading to v1.0.0

### Key Changes

#### Before (Old Structure)

```go
import "github.com/komminarlabs/influxdb3"

// Single client for Cloud Dedicated only
client, err := influxdb3.NewClient(baseURL)
```

### After (New Structure)

```go
// Choose your InfluxDB variant
import "github.com/komminarlabs/influxdb3-management-go/cloud" // Cloud Dedicated
import "github.com/komminarlabs/influxdb3-management-go/core" // Core
import "github.com/komminarlabs/influxdb3-management-go/enterprise" // Enterprise

// Create variant-specific clients
cloudClient, err := cloud.NewClient(baseURL)
coreClient, err := core.NewClient(baseURL)
enterpriseClient, err := enterprise.NewClient(baseURL)
```
40 changes: 20 additions & 20 deletions client.gen.go → cloud/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading