fn_go

package module
v0.8.10 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 3 Imported by: 4

README

FnProject SDK

This is a golang SDK for accessing the Fn API - it allows you to create and modify applications and functions programmatically.

Most of the code in the repository is automatically generated from the latest Fn project API Swagger.

To generate a new client manually:

  • Clone a local copy of fn, this will be used to provide a path to the swagger spec into your go path (e.g. ../fn from this repo)

Run the following commands:

./regenerate.sh

Example:

package main

import (
	"github.com/fnproject/fn_go/provider"
	"github.com/fnproject/fn_go"
	"github.com/fnproject/fn_go/client/apps"
	"context"
	"fmt"
)

func main() {

	config := provider.NewConfigSourceFromMap(map[string]string{
		"api-url": "http://localhost:8080",
	})

	currentProvider, err := fn_go.DefaultProviders.ProviderFromConfig("default", config, &provider.NopPassPhraseSource{})

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

	appClient := currentProvider.APIClient().Apps

	ctx := context.Background()

	var cursor string
	for {
		params := &apps.GetAppsParams{
			Context: ctx,
		}
		if cursor != "" {
			params.Cursor = &cursor
		}

		gotApps, err := appClient.GetApps(params)
		if err != nil {
			panic(err.Error())
		}

		for _, app := range gotApps.Payload.Apps {
			fmt.Printf("App %s\n", app.Name)
		}

		if gotApps.Payload.NextCursor == "" {
			break
		}
		cursor = gotApps.Payload.NextCursor
	}
}

Documentation

Index

Constants

View Source
const (
	// provider names
	DefaultProvider  = "default"
	OracleProvider   = "oracle"
	OracleIPProvider = "oracle-ip"
	OracleCSProvider = "oracle-cs"
)

Variables

DefaultProviders includes the bundled providers available in the client

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
client
fns
oracle/shim/client
Package client is a generated GoMock package.
Package client is a generated GoMock package.

Jump to

Keyboard shortcuts

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