webhookrelay

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: BSD-3-Clause Imports: 19 Imported by: 1

README

Webhook Relay API Go client

GoDoc

This library is currently actively developed so the API might change a little bit.

Features

Currently available features:

  • Buckets
  • Inputs
  • Outputs
  • Output rules
  • Domain reservations
  • Tokens
  • Functions
  • Function config variables
  • Invoke function
  • Function execution logs
  • Tunnels
  • Regions
  • Webhook Logs

Installation

You need a working Go environment.

go get github.com/webhookrelay/webhookrelay-go

Authentication

To authenticate, you will need to first get an API token key & secret pair here.

Usage

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/webhookrelay/webhookrelay-go"
)

func main() {
	// Construct a new Webhook Relay API object to perform requests
	api, err := webhookrelay.New(os.Getenv("RELAY_KEY"), os.Getenv("RELAY_SECRET"))
	if err != nil {
		log.Fatal(err)
  }
  
  bucket, err := api.CreateBucket(&webhookrelay.BucketCreateOptions{
    Name: "sendgrid-to-segment",
  })
  if err != nil {
		log.Fatal(err)
  }
  // all buckets get a default input that you can use to receive webhooks, 
  // it can either be used with custom domain + path prefix (https://xxx.hooks.webhookrelay.com) 
  // or input ID such as https://my.webhookrelay.com/v1/webhooks/xxx
  fmt.Println(bucket.Inputs[0].EndpointURL()) 

  // Create a webhook forwarding destination for this webhook
  _, err = api.CreateOutput(&webhookrelay.Output{
    BucketID: bucket.ID,
    Name: "segment",
    Destination: "https://webhooks.segment.com?b=yyyy",
  })
  if err != nil {
		log.Fatal(err)
  }

  // list all buckets
  buckets, err := api.ListBuckets(&webhookrelay.BucketListOptions{})
  if err != nil {
		log.Fatal(err)
  }
  fmt.Println(buckets) // print buckets
}

Documentation

Overview

Package webhookrelay provides a client library to configure Webhook Relay tunnels, manage serverless functions and set up webhook forwarding routing.

Index

Constants

View Source
const (
	CryptoOff            = "off"
	CryptoFlexible       = "flexible"
	CryptoFull           = "full"
	CryptoFullStrict     = "full-strict"
	CryptoTLSPassThrough = "tls-pass-through"
)

tunnel crypto types

View Source
const (
	// IDFormat are the characters allowed to represent an ID.
	IDFormat = `[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}`

	// NameFormat are the characters allowed to represent a name.
	NameFormat = `[a-zA-Z0-9][a-zA-Z0-9~_.-]+`
)
View Source
const AnyResponseFromOutput = "anyOutput"

AnyResponseFromOutput indicates that the input should return response from whichever output responds first.

View Source
const (
	// AuthToken specifies that we should authenticate with an API key & secret
	AuthToken = 1 << iota
)

Variables

View Source
var (
	// IDPattern is a regular expression to validate a unique id against the
	// collection of restricted characters.
	IDPattern = regexp.MustCompile(`^` + IDFormat + `$`)

	// NamePattern is a regular expression to validate names against the
	// collection of restricted characters.
	NamePattern = regexp.MustCompile(`^` + NameFormat + `$`)

	// ErrNoRef returned when ref is incorrect
	ErrNoRef = errors.New("no ref provided or incorrect format")
)
View Source
var (
	ErrEmptyCredentials = errors.New("invalid credentials: key & secret must not be empty")
)

Errors

View Source
var (
	// ErrNoSuchInput is the error returned when the Input does not exist.
	ErrNoSuchInput = errors.New("no such input")
)
View Source
var (
	// ErrNoSuchOutput is the error returned when the Output does not exist.
	ErrNoSuchOutput = errors.New("no such output")
)

Functions

func IsName

func IsName(s string) bool

IsName returns true if the string input is a valid Name string.

func IsUUID

func IsUUID(s string) bool

IsUUID returns true if the string input is a valid UUID string.

Types

type API

type API struct {
	APIKey    string
	APISecret string
	BaseURL   string
	UserAgent string
	// contains filtered or unexported fields
}

API holds the configuration for the current API client. A client should not be modified concurrently.

func New

func New(key, secret string, opts ...Option) (*API, error)

New creates a new Webhook Relay v1 API client.

func (*API) CreateAccessToken

func (api *API) CreateAccessToken(options *AccessTokenCreateOptions) (*AccessTokenCreateResponse, error)

CreateAccessToken - create new access token. Returned Key and Secret pair should be saved on user's side. Server has already hashed the secret so it can't be recovered. If the secret is lost, just create a new access token.

func (*API) CreateBucket

func (api *API) CreateBucket(options *BucketCreateOptions) (*Bucket, error)

CreateBucket creates a Bucket and returns the newly object.

func (*API) CreateFunction

func (api *API) CreateFunction(opts *CreateFunctionRequest) (*Function, error)

CreateFunction - create new function

func (*API) CreateInput

func (api *API) CreateInput(options *Input) (*Input, error)

CreateInput creates an Input and returns the new object.

func (*API) CreateOutput

func (api *API) CreateOutput(options *Output) (*Output, error)

CreateOutput creates an Output and returns the new object

func (*API) CreateTunnel

func (api *API) CreateTunnel(options *Tunnel) (*Tunnel, error)

CreateTunnel creates new tunnel

func (*API) DeleteAccessToken

func (api *API) DeleteAccessToken(options *AccessTokenDeleteOptions) error

DeleteAccessToken deletes access token

func (*API) DeleteBucket

func (api *API) DeleteBucket(options *BucketDeleteOptions) error

DeleteBucket removes a Bucket by its reference.

func (*API) DeleteDomainReservation

func (api *API) DeleteDomainReservation(options *DomainDeleteOptions) error

DeleteDomainReservation deletes domain reservation. It can only be removed once no Input or Tunnel is using it.

func (*API) DeleteFunction

func (api *API) DeleteFunction(options *FunctionDeleteOptions) error

DeleteFunction - delete function

func (*API) DeleteFunctionConfigurationVariable added in v0.3.0

func (api *API) DeleteFunctionConfigurationVariable(options *FunctionConfigurationVariableDeleteOptions) error

DeleteFunctionConfigurationVariable - delete function configuration variable

func (*API) DeleteInput

func (api *API) DeleteInput(options *InputDeleteOptions) error

DeleteInput removes input. If public input is used by the UUID, beware that after deleting an input you will not be able to recreate another one with the same ID.

func (*API) DeleteOutput

func (api *API) DeleteOutput(options *OutputDeleteOptions) error

DeleteOutput deletes output from the bucket

func (*API) DeleteTunnel

func (api *API) DeleteTunnel(options *TunnelDeleteOptions) error

DeleteTunnel delete tunnel by ID or name

func (*API) GetBucket

func (api *API) GetBucket(ref string) (*Bucket, error)

GetBucket gets specific bucket

func (*API) GetFunction

func (api *API) GetFunction(ref string) (*Function, error)

GetFunction - get function by ref

func (*API) GetTunnel

func (api *API) GetTunnel(ref string) (*Tunnel, error)

GetTunnel gets tunnel by ID, name or hostname

func (*API) GetWebhookLog added in v0.3.0

func (api *API) GetWebhookLog(id string) (*Log, error)

GetWebhookLog - returns webhook lgo

func (*API) InvokeFunction

func (api *API) InvokeFunction(options *InvokeOpts) (*ExecuteResponse, error)

InvokeFunction invokes function and gets a response

func (*API) ListAccessTokens

func (api *API) ListAccessTokens(options *AccessTokenListOptions) ([]*AccessToken, error)

ListAccessTokens lists access tokens for an account

func (*API) ListBuckets

func (api *API) ListBuckets(options *BucketListOptions) ([]*Bucket, error)

ListBuckets lists buckets for an account

func (*API) ListDomainReservations

func (api *API) ListDomainReservations(options *DomainListOptions) ([]*Domain, error)

ListDomainReservations lists domain reservations for an account

func (*API) ListFunctionConfigurationVariables added in v0.3.0

func (api *API) ListFunctionConfigurationVariables(options *FunctionConfigurationVariablesListOptions) ([]*Variable, error)

ListFunctionConfigurationVariables lists function configuration variables

func (*API) ListFunctions

func (api *API) ListFunctions(options *FunctionListOptions) ([]*Function, error)

ListFunctions lists functions for an account

func (*API) ListInputs

func (api *API) ListInputs(options *InputListOptions) ([]*Input, error)

ListInputs returns a list of inputs belonging to the bucket. If bucket reference not supplied, all account inputs will be returned

func (*API) ListOutputs

func (api *API) ListOutputs(options *OutputListOptions) ([]*Output, error)

ListOutputs returns a list of outputs belonging to the bucket. If bucket reference not supplied, all account outputs will be returned

func (*API) ListRegions

func (api *API) ListRegions(options *RegionListOptions) ([]*Region, error)

ListRegions lists available regions

func (*API) ListTunnels

func (api *API) ListTunnels(options *TunnelListOptions) ([]*Tunnel, error)

ListTunnels lists tunnels for an account

func (*API) ListWebhookLogs added in v0.3.0

func (api *API) ListWebhookLogs(options *WebhookLogsListOptions) (*WebhookLogsResponse, error)

ListWebhookLogs lists webhook logs for an account

func (*API) ReserveDomain

func (api *API) ReserveDomain(options *Domain) (*Domain, error)

ReserveDomain - reserve domain

func (*API) ServerVersion

func (api *API) ServerVersion(ctx context.Context) (*VersionInfo, error)

ServerVersion returns the server's version and runtime info.

func (*API) SetFunctionConfigurationVariable added in v0.3.0

func (api *API) SetFunctionConfigurationVariable(options *SetFunctionConfigRequest) (*Variable, error)

SetFunctionConfigurationVariable allows users to set config variables for a function. Function can then use special methods to retrieve those variables during runtime.

func (*API) UpdateAccessToken added in v0.2.0

func (api *API) UpdateAccessToken(options *AccessToken) (*AccessToken, error)

UpdateAccessToken updates access token scopes, description and enabled/disable API access

func (*API) UpdateBucket

func (api *API) UpdateBucket(options *Bucket) (*Bucket, error)

UpdateBucket updates a Bucket on the server and returns the updated object.

func (*API) UpdateFunction

func (api *API) UpdateFunction(options *UpdateFunctionRequest) (*Function, error)

UpdateFunction - update function

func (*API) UpdateInput

func (api *API) UpdateInput(options *Input) (*Input, error)

UpdateInput updates existing input

func (*API) UpdateOutput

func (api *API) UpdateOutput(options *Output) (*Output, error)

UpdateOutput updates output

func (*API) UpdateTunnel

func (api *API) UpdateTunnel(options *Tunnel) (*Tunnel, error)

UpdateTunnel updates existing tunnel

func (*API) UpdateWebhookLog added in v0.3.0

func (api *API) UpdateWebhookLog(updateRequest *WebhookLogsUpdateRequest) error

UpdateWebhookLog - update webhook log response body, headers and status code.

type AccessToken

type AccessToken struct {
	ID          string            `json:"id"`         // read-only
	CreatedAt   time.Time         `json:"created_at"` // read-only
	UpdatedAt   time.Time         `json:"updated_at"` // read-only
	LastLogin   string            `json:"last_login"` // read-only
	Description string            `json:"description"`
	Scopes      AccessTokenScopes `json:"scopes"`
	// APIAccess allows to enable/disabled API access. Tokens that have disabled
	// access can be used to subscribe to webhooks or tunnel connections.
	// Defaults to "enabled"
	APIAccess AccessTokenAPIAccess `json:"api_access"`
	Active    bool                 `json:"active"`
}

AccessToken - auth tokens, can be created for the agents

func (*AccessToken) MarshalJSON

func (t *AccessToken) MarshalJSON() ([]byte, error)

MarshalJSON helper to marshal unix time

func (*AccessToken) UnmarshalJSON

func (t *AccessToken) UnmarshalJSON(data []byte) error

UnmarshalJSON helper to unmarshal unix time

type AccessTokenAPIAccess added in v0.2.0

type AccessTokenAPIAccess string

AccessTokenAPIAccess - enables/disables API access for the token

const (
	AccessTokenAPIAccessEnabled  AccessTokenAPIAccess = "enabled"
	AccessTokenAPIAccessDisabled AccessTokenAPIAccess = "disabled"
)

Available API access token status

type AccessTokenCreateOptions

type AccessTokenCreateOptions struct {
	Description string               `json:"description"`
	Scopes      AccessTokenScopes    `json:"scopes"`
	APIAccess   AccessTokenAPIAccess `json:"api_access"`
}

AccessTokenCreateOptions - used to create an access token

type AccessTokenCreateResponse

type AccessTokenCreateResponse struct {
	Key    string `json:"key"`
	Secret string `json:"secret"`
}

AccessTokenCreateResponse - response when creating a token

type AccessTokenDeleteOptions

type AccessTokenDeleteOptions struct {
	ID string `json:"id"` // ID/Key
}

AccessTokenDeleteOptions used to delete access token

type AccessTokenListOptions

type AccessTokenListOptions struct{}

AccessTokenListOptions - TODO

type AccessTokenScopes added in v0.2.0

type AccessTokenScopes struct {
	Tunnels []string `json:"tunnels"`
	Buckets []string `json:"buckets"`
}

AccessTokenScopes define optional limits for tokens

type AuthType

type AuthType int

AuthType is a tunnel authentication type

const (
	AuthTypeNone AuthType = iota
	AuthTypeBasic
	AuthTypeToken
)

Available tunnel authentication modes

func (AuthType) MarshalJSON

func (r AuthType) MarshalJSON() ([]byte, error)

MarshalJSON is generated so AuthType satisfies json.Marshaler.

func (AuthType) String

func (s AuthType) String() string

func (*AuthType) UnmarshalJSON

func (r *AuthType) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so AuthType satisfies json.Unmarshaler.

type Bucket

type Bucket struct {
	ID          string     `json:"id"`         // readonly
	CreatedAt   time.Time  `json:"created_at"` // readonly
	UpdatedAt   time.Time  `json:"updated_at"` // readonly
	Name        string     `json:"name"`
	Description string     `json:"description"`
	Stream      bool       `json:"stream"`
	Ephemeral   bool       `json:"ephemeral"`
	Auth        BucketAuth `json:"auth"`
	Inputs      []*Input   `json:"inputs"`  // readonly
	Outputs     []*Output  `json:"outputs"` // readonly
}

Bucket - bucket is required for webhook inputs and outputs. There should probably be one Input per Bucket to make it easy to manage. Buckets control policies such as retries, manipulation, logs, rate limitting

func (*Bucket) MarshalJSON

func (b *Bucket) MarshalJSON() ([]byte, error)

MarshalJSON helper to marshal unix time

func (*Bucket) UnmarshalJSON

func (b *Bucket) UnmarshalJSON(data []byte) error

UnmarshalJSON helper to unmarshal unix time

type BucketAuth

type BucketAuth struct {
	Type     AuthType `json:"type"`
	Username string   `json:"username,omitempty"`
	Password string   `json:"password,omitempty"`
	Token    string   `json:"token,omitempty"`
}

BucketAuth specifies authentication method for incoming requests to the bucket's inputs

type BucketCreateOptions

type BucketCreateOptions struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

BucketCreateOptions create opts

type BucketDeleteOptions

type BucketDeleteOptions struct {
	Ref   string `json:"ref"`
	Force bool   `json:"force"`
}

BucketDeleteOptions are used to delete bucket

type BucketListOptions

type BucketListOptions struct{}

BucketListOptions - TODO

type CreateFunctionRequest

type CreateFunctionRequest struct {
	Name    string
	Driver  string
	Payload io.Reader
}

CreateFunctionRequest is used when creating a new function

type Domain

type Domain struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	// Domain can be any 3rd party domain such as
	// user.example.com
	Domain string `json:"domain"`
}

Domain is a domain reservation

func (*Domain) MarshalJSON

func (d *Domain) MarshalJSON() ([]byte, error)

MarshalJSON helper to marshal unix time

func (*Domain) UnmarshalJSON

func (d *Domain) UnmarshalJSON(data []byte) error

UnmarshalJSON helper to unmarshal unix time

type DomainDeleteOptions

type DomainDeleteOptions struct {
	Ref string `json:"ref"`
}

DomainDeleteOptions are used to delete domain reservation

type DomainListOptions

type DomainListOptions struct{}

DomainListOptions - TODO

type Endpoint

type Endpoint struct {
	Address string `json:"address"`
}

Endpoint - is an address where request should be routed

type ExecuteResponse

type ExecuteResponse = reactor_v1.ExecuteResponse

ExecuteResponse is an alias to reactor v1 pkg

type Features

type Features struct {
	RewriteHostHeader string `json:"rewrite_host_header"`
}

Features - optional tunnel features to enable different functionality

type Function

type Function = reactor_v1.Function

Function is an alias to reactor_v1 pkg

type FunctionConfigurationVariableDeleteOptions added in v0.3.0

type FunctionConfigurationVariableDeleteOptions struct {
	ID  string
	Key string
}

FunctionConfigurationVariableDeleteOptions is used in function configuration variable delete request

type FunctionConfigurationVariablesListOptions added in v0.3.0

type FunctionConfigurationVariablesListOptions struct {
	ID string
}

FunctionConfigurationVariablesListOptions is used to list function config variables

type FunctionDeleteOptions

type FunctionDeleteOptions struct {
	ID string `json:"id"`
}

FunctionDeleteOptions is used in function delete request

type FunctionListOptions

type FunctionListOptions struct{}

FunctionListOptions is used to list functions

type FunctionRequest

type FunctionRequest struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Payload string `json:"payload"`
	Driver  string `json:"driver"`
}

FunctionRequest used for creating/updating functions

type Headers added in v0.3.0

type Headers map[string]interface{}

Headers - headers are used to store request header info in the webhook log

type IngressRule

type IngressRule struct {
	// Name is an option identifier for the ingress rule, it usually is a service name
	// if used with webrelay-ingress
	Name string `json:"name"`

	// Path is an extended POSIX regex as defined by IEEE Std 1003.1,
	// (i.e this follows the egrep/unix syntax, not the perl syntax)
	// matched against the path of an incoming request. Currently it can
	// contain characters disallowed from the conventional "path"
	// part of a URL as defined by RFC 3986. Paths must begin with
	// a '/'. If unspecified, the path defaults to a catch all sending
	// traffic to the backend.
	// +optional
	Path string `json:"path"`

	// Endpoints
	Endpoints []*Endpoint `json:"endpoints"`
}

IngressRule is used by the ingress controller to route to multiple targets

type IngressRules

type IngressRules struct {
	Rules []*IngressRule `json:"rules"`
}

IngressRules - ingress defines custom routing configuration based on paths

type Input

type Input struct {
	ID         string              `json:"id"`
	CreatedAt  time.Time           `json:"created_at"`
	UpdatedAt  time.Time           `json:"updated_at"`
	Name       string              `json:"name"`
	FunctionID string              `json:"function_id"`
	BucketID   string              `json:"bucket_id"`
	Headers    map[string][]string `json:"headers"`
	StatusCode int                 `json:"status_code"`
	Body       string              `json:"body"`
	// either output ID or "anyOutput" to indicate that the first response
	// from any output is good enough. Empty string
	ResponseFromOutput string `json:"response_from_output"`
	CustomDomain       string `json:"custom_domain"`
	PathPrefix         string `json:"path_prefix"`
	Description        string `json:"description"`
}

Input - webhook inputs are used to create endpoints which are then used by remote systems

func (*Input) EndpointURL

func (i *Input) EndpointURL() string

EndpointURL returns default input URL. If CustomDomain is set (all new inputs from 2020 06 01 are getting them), then it's this domain with path prefix, otherwise it's the URL based on the input ID

func (*Input) MarshalJSON

func (i *Input) MarshalJSON() ([]byte, error)

MarshalJSON helper to change time into unix

func (*Input) String

func (i *Input) String() string

func (*Input) UnmarshalJSON

func (i *Input) UnmarshalJSON(data []byte) error

UnmarshalJSON helper to change time from unix

type InputDeleteOptions

type InputDeleteOptions struct {
	Bucket string
	Input  string // ID or name
}

InputDeleteOptions delete options

type InputListOptions

type InputListOptions struct {
	Bucket string // Bucket reference - ID or name
}

InputListOptions used to query inputs

type InvokeFunctionRequest

type InvokeFunctionRequest struct {
	Headers     map[string][]string `json:"headers"`
	RawQuery    string              `json:"raw_query"`
	RequestBody string              `json:"request_body"`
	Method      string              `json:"method"`
}

InvokeFunctionRequest is a function invoke payload

type InvokeOpts

type InvokeOpts struct {
	ID                    string
	InvokeFunctionRequest InvokeFunctionRequest
}

InvokeOpts used to invoke functions, carries function ID and payload

type ListConfigResponse added in v0.3.0

type ListConfigResponse = reactor_v1.ListConfigResponse

ListConfigResponse defines function config

type Log added in v0.3.0

type Log struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	AccountID string `json:"account_id"`
	OutputID  string `json:"output_id"`
	InputID   string `json:"input_id"`
	BucketID  string `json:"bucket_id"`

	Internal        bool          `json:"internal"`
	StatusCode      int           `json:"status_code"`
	ResponseBody    []byte        `json:"response_body"`
	ResponseHeaders Headers       `json:"response_headers" `
	Status          RequestStatus `json:"status"`
	Retries         int           `json:"retries"`

	// request details
	Headers   Headers `json:"headers"`
	RawQuery  string  `json:"raw_query"`
	Method    string  `json:"method"`
	ExtraPath string  `json:"extra_path"`

	Body string `json:"body"`

	// If true, doesn't save request body, query or headers,
	// inherits from the bucket configuration
	Ephemeral bool `json:"ephemeral"`
}

Log - received webhook event

func (*Log) MarshalJSON added in v0.3.0

func (l *Log) MarshalJSON() ([]byte, error)

MarshalJSON converst Go time into unix time

func (*Log) UnmarshalJSON added in v0.3.0

func (l *Log) UnmarshalJSON(data []byte) error

UnmarshalJSON parses unix time

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger defines the interface this library needs to use logging This is a subset of the methods implemented in the log package

type Option

type Option func(*API) error

Option is a functional option for configuring the API client.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient accepts a custom *http.Client for making API calls.

func WithHeaders

func WithHeaders(headers http.Header) Option

WithHeaders allows you to set custom HTTP headers when making API calls (e.g. for satisfying HTTP proxies, or for debugging).

func WithLogger

func WithLogger(logger Logger) Option

WithLogger can be set if you want to get log output from this API instance By default no log output is emitted

func WithRetryPolicy

func WithRetryPolicy(maxRetries int, minRetryDelaySecs int, maxRetryDelaySecs int) Option

WithRetryPolicy applies a non-default number of retries and min/max retry delays This will be used when the client exponentially backs off after errored requests

func WithUserAgent

func WithUserAgent(userAgent string) Option

WithUserAgent can be set if you want to send a software name and version for HTTP access logs. It is recommended to set it in order to help future Customer Support diagnostics and prevent collateral damage by sharing generic User-Agent string with abusive users. E.g. "my-software/1.2.3". By default generic Go User-Agent is used.

type Output

type Output struct {
	ID          string              `json:"id"`
	CreatedAt   time.Time           `json:"created_at"`
	UpdatedAt   time.Time           `json:"updated_at"`
	Name        string              `json:"name"`
	BucketID    string              `json:"bucket_id"`
	FunctionID  string              `json:"function_id"`
	Headers     map[string][]string `json:"headers"`
	Destination string              `json:"destination"`
	Disabled    bool                `json:"disabled"` // Allows disabling forwarding to specific output
	// LockPath ensures that the request path cannot be changed from what is
	// specified in the destination. For example if request is coming to /v1/webhooks/xxx/github-jenkins,
	// with lock path 'false' and destination 'http://localhost:8080' it would go to http://localhost:8080/github-jenkins.
	// However, with lock path 'true', it will be sent to 'http://localhost:8080'
	LockPath    bool   `json:"lock_path"`
	Internal    bool   `json:"internal"`
	Timeout     int    `json:"timeout"` // Destination response timeout
	Description string `json:"description"`
}

Output specified webhook forwarding destination

func (*Output) MarshalJSON

func (o *Output) MarshalJSON() ([]byte, error)

MarshalJSON helper to change time into unix

func (*Output) UnmarshalJSON

func (o *Output) UnmarshalJSON(data []byte) error

UnmarshalJSON helper to change time from unix

type OutputDeleteOptions

type OutputDeleteOptions struct {
	Bucket string
	Output string // ID or name
}

OutputDeleteOptions delete options

type OutputListOptions

type OutputListOptions struct {
	Bucket string // Bucket reference - ID or name
}

OutputListOptions used to query outputs

type Region

type Region struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Name      string    `json:"name"`
	// for default region it's just [xx].webrelay.io
	// but for Australia region it could be [xx].au.webrelay.io or even
	// a completely different, non webrelay domain. This way in theory we could allow
	// self-hosted but managed regions
	DomainSuffix string `json:"domain_suffix"`

	// ServerAddress is a tunneling server HOSTNAME:PORT address
	ServerAddress string `json:"server_address"`
}

Region is a server entry that accepts tunnel connections and acts as a hub

func (*Region) MarshalJSON

func (r *Region) MarshalJSON() ([]byte, error)

MarshalJSON helper to marshal unix time

func (*Region) UnmarshalJSON

func (r *Region) UnmarshalJSON(data []byte) error

UnmarshalJSON helper to unmarshal unix time

type RegionListOptions

type RegionListOptions struct{}

RegionListOptions - region list options

type RequestStatus added in v0.3.0

type RequestStatus int

RequestStatus - available request statuses

const (
	RequestStatusPreparing RequestStatus = iota
	RequestStatusSent
	RequestStatusFailed
	RequestStatusStalled // if request destination wasn't listening - incoming requests will be stalled
	RequestStatusReceived
	RequestStatusRejected
)

default statuses

func (RequestStatus) MarshalJSON added in v0.3.0

func (r RequestStatus) MarshalJSON() ([]byte, error)

MarshalJSON is generated so RequestStatus satisfies json.Marshaler.

func (RequestStatus) String added in v0.3.0

func (s RequestStatus) String() string

func (*RequestStatus) UnmarshalJSON added in v0.3.0

func (r *RequestStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so RequestStatus satisfies json.Unmarshaler.

type RetryPolicy

type RetryPolicy struct {
	MaxRetries    int
	MinRetryDelay time.Duration
	MaxRetryDelay time.Duration
}

RetryPolicy specifies number of retries and min/max retry delays This config is used when the client exponentially backs off after errored requests

type SetFunctionConfigRequest added in v0.3.0

type SetFunctionConfigRequest struct {
	ID    string `json:"-"` // function ID
	Key   string `json:"key"`
	Value string `json:"value"`
}

SetFunctionConfigRequest sets/updates function configuration

type Tunnel

type Tunnel struct {
	ID           string       `json:"id"`
	CreatedAt    time.Time    `json:"created_at"`
	UpdatedAt    time.Time    `json:"updated_at"`
	Name         string       `json:"name"` // tunnel name
	Group        string       `json:"group"`
	Region       string       `json:"region"`
	Destination  string       `json:"destination"` // destination host, defaults to 127.0.0.1:8000
	Host         string       `json:"host"`
	Addr         string       `json:"addr"`
	Mode         TunnelMode   `json:"mode"`
	Protocol     string       `json:"protocol"` // tunnel protocol - http/tcp
	Crypto       string       `json:"crypto"`
	AccountID    string       `json:"account_id"`
	Description  string       `json:"description"`
	Auth         TunnelAuth   `json:"auth"`
	Features     Features     `json:"features"`
	IngressRules IngressRules `json:"ingress_rules"`
}

Tunnel is a type to store bidirectional tunnel data these tunnels are different from webhook buckets in a way that they provide responses to whatever calls them

func (*Tunnel) GetURL

func (t *Tunnel) GetURL() string

GetURL helper

func (*Tunnel) MarshalJSON

func (t *Tunnel) MarshalJSON() ([]byte, error)

MarshalJSON marshal to unix time

func (*Tunnel) UnmarshalJSON

func (t *Tunnel) UnmarshalJSON(data []byte) error

UnmarshalJSON unamrshal unix time

type TunnelAuth

type TunnelAuth struct {
	Type AuthType `json:"type"`

	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	Token    string `json:"token,omitempty"`
}

TunnelAuth - optional auth for tunnels

type TunnelDeleteOptions

type TunnelDeleteOptions struct {
	ID   string
	Name string
}

TunnelDeleteOptions delete options

type TunnelListOptions

type TunnelListOptions struct{}

TunnelListOptions - list tunnels options

type TunnelMode

type TunnelMode int

TunnelMode - tunnel mode

const (
	TunnelModeInactive TunnelMode = iota
	TunnelModeActive
)

available tunnel modes

func ParseTunnelMode

func ParseTunnelMode(mode string) TunnelMode

ParseTunnelMode - parses tunnel mode string

func (TunnelMode) MarshalJSON

func (r TunnelMode) MarshalJSON() ([]byte, error)

MarshalJSON is generated so TunnelMode satisfies json.Marshaler.

func (TunnelMode) String

func (s TunnelMode) String() string

func (*TunnelMode) UnmarshalJSON

func (r *TunnelMode) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so TunnelMode satisfies json.Unmarshaler.

type UpdateFunctionRequest

type UpdateFunctionRequest struct {
	ID      string
	Name    string
	Driver  string
	Payload io.Reader
}

UpdateFunctionRequest is used when updating an existing function

type Variable added in v0.3.0

type Variable = reactor_v1.Variable

Variable is function configuration variable

type VersionInfo

type VersionInfo struct {
	Name          string `json:"name"`
	BuildDate     string `json:"buildDate"`
	Revision      string `json:"revision"`
	Version       string `json:"version"`
	APIVersion    string `json:"apiVersion"`
	GoVersion     string `json:"goVersion"`
	OS            string `json:"os"`
	Arch          string `json:"arch"`
	KernelVersion string `json:"kernelVersion"`
	Experimental  bool   `json:"experimental"`
}

VersionInfo describes version and runtime info.

type WebhookLogsListOptions added in v0.3.0

type WebhookLogsListOptions struct {
	BucketID string
	Status   RequestStatus
	From     time.Time
	To       time.Time
	Limit    int
	Offset   int
}

WebhookLogsListOptions - list logs options

type WebhookLogsResponse added in v0.3.0

type WebhookLogsResponse struct {
	Data   []*Log `json:"data"`
	Total  int    `json:"total"`
	Limit  int    `json:"limit"`
	Offset int    `json:"offset"`
}

WebhookLogsResponse is a webhook query response

type WebhookLogsUpdateRequest added in v0.3.0

type WebhookLogsUpdateRequest struct {
	ID              string        `json:"id"`
	StatusCode      int           `json:"status_code"`
	ResponseBody    []byte        `json:"response_body"`
	ResponseHeaders Headers       `json:"response_headers" `
	Status          RequestStatus `json:"status"`
	Retries         int           `json:"retries"`
}

WebhookLogsUpdateRequest is used to update Webhook Relay request if used for example with WebSocket transponder (it becomes client's responsibility to do this action). Response information must be sent within 10 seconds of receiving the webhook.

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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