storyblok-go-sdk

command module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 0 Imported by: 0

README

Go SDK for Storyblok

This repository contains the go sdk for the Storyblok Management API.

Installation

This repository depends on redocly to bundle the yaml files and oapi-codegen to generate the Go SDK.

pnpm install -g @redocly/openapi-cli
go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest

Development

The source.yaml is the entrypoint for the code generation. There we define the REST routes as references to files in the path directory. These files reference schemas from the schemas directory.

  1. edit the source.yaml or any of the referenced files.
  2. bundle the yaml files into a new openapi.yaml file
  3. generate a new Go SDK with the oapi-codegen
redocly bundle > openapi.yaml
oapi-codegen -config oapi-config.yaml openapi.yaml

Example

package main

import (
    "context"
    "fmt"

    "github.com/deepmap/oapi-codegen/pkg/securityprovider"
    "github.com/labd/storyblok-go-sdk/sbmgmt"
)

const token    = "<your personal api key>"
const spaceId  = "<your space id>"
const endpoint = "https://mapi.storyblok.com"

func ref[T any](s T) *T {
    return &s
}

func main() {
    ctx := context.Background()

    apiKeyProvider, err := securityprovider.NewSecurityProviderApiKey("header", "Authorization", token)
    if err != nil {
        panic(err)
    }

    client, err := sbmgmt.NewClientWithResponses(endpoint, sbmgmt.WithRequestEditorFn(apiKeyProvider.Intercept))
    if err != nil {
        panic(err)
    }

    resp, err := client.GetSpaceWithResponse(ctx, spaceId)
    if err != nil {
        panic(err)
    }
    fmt.Println(resp.JSON200.Space.Name)
}

Progress

  • Stories
  • Collaborators
  • Components
  • Component Groups
  • Assets
  • Asset Folders
  • Datasources
  • Datasource Entries
  • Spaces
  • Space Roles
  • Tasks
  • Approvals
  • Activities
  • Presets
  • Field Types
  • Workflow Stage
  • Workflow Stage Change
  • Releases
  • Branch deployments

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package sbmgmt provides primitives to interact with the openapi HTTP API.
Package sbmgmt provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL