Categorygithub.com/webhookrelay/webhookrelay-go
modulepackage
0.3.1
Repository: https://github.com/webhookrelay/webhookrelay-go.git
Documentation: pkg.go.dev

# 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
}

# Packages

No description provided by the author

# Functions

IsName returns true if the string input is a valid Name string.
IsUUID returns true if the string input is a valid UUID string.
New creates a new Webhook Relay v1 API client.
ParseTunnelMode - parses tunnel mode string.
WithHeaders allows you to set custom HTTP headers when making API calls (e.g.
WithHTTPClient accepts a custom *http.Client for making API calls.
WithLogger can be set if you want to get log output from this API instance By default no log output is emitted.
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.
WithUserAgent can be set if you want to send a software name and version for HTTP access logs.

# Constants

Available API access token status.
Available API access token status.
AnyResponseFromOutput indicates that the input should return response from whichever output responds first.
AuthToken specifies that we should authenticate with an API key & secret.
Available tunnel authentication modes.
Available tunnel authentication modes.
Available tunnel authentication modes.
tunnel crypto types.
tunnel crypto types.
tunnel crypto types.
tunnel crypto types.
tunnel crypto types.
IDFormat are the characters allowed to represent an ID.
NameFormat are the characters allowed to represent a name.
default statuses.
default statuses.
default statuses.
default statuses.
default statuses.
if request destination wasn't listening - incoming requests will be stalled.
available tunnel modes.
available tunnel modes.

# Variables

Errors.
ErrNoRef returned when ref is incorrect.
ErrNoSuchInput is the error returned when the Input does not exist.
ErrNoSuchOutput is the error returned when the Output does not exist.
IDPattern is a regular expression to validate a unique id against the collection of restricted characters.
NamePattern is a regular expression to validate names against the collection of restricted characters.

# Structs

AccessToken - auth tokens, can be created for the agents.
AccessTokenCreateOptions - used to create an access token.
AccessTokenCreateResponse - response when creating a token.
AccessTokenDeleteOptions used to delete access token.
AccessTokenListOptions - TODO.
AccessTokenScopes define optional limits for tokens.
API holds the configuration for the current API client.
Bucket - bucket is required for webhook inputs and outputs.
BucketAuth specifies authentication method for incoming requests to the bucket's inputs.
BucketCreateOptions create opts.
BucketDeleteOptions are used to delete bucket.
BucketListOptions - TODO.
CreateFunctionRequest is used when creating a new function.
Domain is a domain reservation.
DomainDeleteOptions are used to delete domain reservation.
DomainListOptions - TODO.
Endpoint - is an address where request should be routed.
Features - optional tunnel features to enable different functionality.
FunctionConfigurationVariableDeleteOptions is used in function configuration variable delete request.
FunctionConfigurationVariablesListOptions is used to list function config variables.
FunctionDeleteOptions is used in function delete request.
FunctionListOptions is used to list functions.
FunctionRequest used for creating/updating functions.
IngressRule is used by the ingress controller to route to multiple targets.
IngressRules - ingress defines custom routing configuration based on paths.
Input - webhook inputs are used to create endpoints which are then used by remote systems.
InputDeleteOptions delete options.
InputListOptions used to query inputs.
InvokeFunctionRequest is a function invoke payload.
InvokeOpts used to invoke functions, carries function ID and payload.
Log - received webhook event.
Output specified webhook forwarding destination.
OutputDeleteOptions delete options.
OutputListOptions used to query outputs.
Region is a server entry that accepts tunnel connections and acts as a hub.
RegionListOptions - region list options.
RetryPolicy specifies number of retries and min/max retry delays This config is used when the client exponentially backs off after errored requests.
SetFunctionConfigRequest sets/updates function configuration.
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.
TunnelAuth - optional auth for tunnels.
TunnelDeleteOptions delete options.
TunnelListOptions - list tunnels options.
UpdateFunctionRequest is used when updating an existing function.
VersionInfo describes version and runtime info.
WebhookLogsListOptions - list logs options.
WebhookLogsResponse is a webhook query response.
WebhookLogsUpdateRequest is used to update Webhook Relay request if used for example with WebSocket transponder (it becomes client's responsibility to do this action).

# Interfaces

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

# Type aliases

AccessTokenAPIAccess - enables/disables API access for the token.
AuthType is a tunnel authentication type.
ExecuteResponse is an alias to reactor v1 pkg.
Function is an alias to reactor_v1 pkg.
Headers - headers are used to store request header info in the webhook log.
ListConfigResponse defines function config.
Option is a functional option for configuring the API client.
RequestStatus - available request statuses.
TunnelMode - tunnel mode.
Variable is function configuration variable.