api

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

README

API plugin

This plugin provides a REST API allowing for the creation of flow events.

Use

Interaction with this plugin is carried out through HTTP requests to particular URLs we refer to as endpoints. The currently available endpoints (as defined in endpoints.go) are detailed below. Please note there is an ongoing effort to adhere to the OpenAPI specification.

GET /

Returns JSON-formatted object detailing the available endpoints.

$ curl http://127.0.0.1:7777
{
    "ApiRoutes": [
        {
            "method": "GET",
            "path": "/",
            "name": "github.com/scitags/flowd/plugins/api.handleRoot"
        },
        {
            "method": "GET",
            "path": "/dummy/start",
            "name": "github.com/scitags/flowd/plugins/api.handleDummyStartFlow"
        },
        {
            "method": "GET",
            "path": "/dummy/end",
            "name": "github.com/scitags/flowd/plugins/api.handleDummyEndFlow"
        }
    ]
}
GET /dummy/start

Creates a flow start event with hardcoded information. The created flow event is returned as a JSON object.

$ curl http://127.0.0.1:7777/dummy/start
{
    "State": 0,
    "Protocol": 0,
    "Src": {
        "IP": "::1",
        "Port": 2345
    },
    "Dst": {
        "IP": "::1",
        "Port": 5777
    },
    "Experiment": 65535,
    "Activity": 65535,
    "StartTs": "2024-11-07T12:22:05.571768742+01:00",
    "EndTs": "0001-01-01T00:00:00Z",
    "NetLink": ""
}
GET /dummy/end

Creates a flow end event with hardcoded information. The created flow event is returned as a JSON object.

$ curl http://127.0.0.1:7777/dummy/end
{
    "State": 1,
    "Protocol": 0,
    "Src": {
        "IP": "::1",
        "Port": 2345
    },
    "Dst": {
        "IP": "::1",
        "Port": 5777
    },
    "Experiment": 65535,
    "Activity": 65535,
    "StartTs": "0001-01-01T00:00:00Z",
    "EndTs": "2024-11-07T12:22:27.150587581+01:00",
    "NetLink": ""
}

Configuration

Please refer to the Markdown-formatted documentation at the repository's root for more information on available options. The following replicates the default configuration:

{
    "plugins": {
        "api": {
            "bindAddress": "127.0.0.1",
            "bindPort": 7777
        }
    }
}

Documentation

Index

Constants

View Source
const (
	JSON_PRETTY_INDENT string = "    "
)

Variables

View Source
var (
	Defaults = map[string]interface{}{
		"bindAddress": "127.0.0.1",
		"bindPort":    7777,
	}
)

Functions

This section is empty.

Types

type ApiPlugin

type ApiPlugin struct {
	BindAddress string `json:"bindAddress"`
	BindPort    int    `json:"bindPort"`
	// contains filtered or unexported fields
}

func (*ApiPlugin) Cleanup

func (p *ApiPlugin) Cleanup() error

func (*ApiPlugin) Init

func (p *ApiPlugin) Init() error

func (*ApiPlugin) Run

func (p *ApiPlugin) Run(done <-chan struct{}, outChan chan<- glowdTypes.FlowID)

func (*ApiPlugin) String

func (p *ApiPlugin) String() string

Jump to

Keyboard shortcuts

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