rest

package module
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: BSD-3-Clause Imports: 13 Imported by: 8

README

REST

This activity allows you to invoke a REST service.

Installation

Flogo CLI
flogo install github.com/AiRISTAFlowInc/fs-contrib/activity/rest

Configuration

Settings:
Name Type Description
method string The HTTP method to invoke (Allowed values are GET, POST, PUT, DELETE, and PATCH) - REQUIRED
uri string The URI of the service to invoke - REQUIRED
headers params The HTTP header parameters
proxy string The address of the proxy server to be used
timeout int The request timeout in seconds
skipSSLVerify bool Skip SSL validation, defaults to false
certFile string The path to PEM encoded client certificate
keyFile string The path to PEM encoded client key
CAFile string The path to PEM encoded root certificates file
Input:
Name Type Description
pathParams params The path parameters (e.g., 'id' in http://.../pet/:id/name )
queryParams params The query parameters (e.g., 'id' in http://.../pet?id=someValue )
headers params The HTTP header parameters
content any The message content to send. This is only used in POST, PUT, and PATCH
Output:
Name Type Description
status int The HTTP status code
data any The HTTP response data

Examples

Simple

The below example retrieves a pet with number '1234' from the swagger petstore:

{
  "id": "rest_activity",
  "name": "REST Activity",
  "activity": {
    "ref": "github.com/AiRISTAFlowInc/fs-contrib/activity/rest",
    "settings": {
      "method": "GET",
      "uri": "http://petstore.swagger.io/v2/pet/1234"
    }
  }
}
Using Path Params

The below example is the same as above, it retrieves a pet with number '1234' from the swagger petstore, but uses a URI parameter to configure the ID:

{
  "id": "rest_activity",
  "name": "REST Activity",
  "activity": {
    "ref": "github.com/AiRISTAFlowInc/fs-contrib/activity/rest",
    "settings": {
      "method": "GET",
      "uri": "http://petstore.swagger.io/v2/pet/:id"
    },
    "input": {
      "params": { "id": "1234"}
    }
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildURI

func BuildURI(uri string, values map[string]string) string

BuildURI is a temporary crude URI builder

func New

Types

type Activity

type Activity struct {
	// contains filtered or unexported fields
}

Activity is an activity that is used to invoke a REST Operation settings : {method, uri, headers, proxy, skipSSL} input : {pathParams, queryParams, headers, content} outputs : {status, result}

func (*Activity) Eval

func (a *Activity) Eval(ctx activity.Context) (done bool, err error)

Eval implements api.Activity.Eval - Invokes a REST Operation

func (*Activity) Metadata

func (a *Activity) Metadata() *activity.Metadata

type Input

type Input struct {
	PathParams  map[string]string `md:"pathParams"`  // The query parameters (e.g., 'id' in http://.../pet?id=someValue )
	QueryParams map[string]string `md:"queryParams"` // The path parameters (e.g., 'id' in http://.../pet/:id/name )
	Headers     map[string]string `md:"headers"`     // The HTTP header parameters
	Content     interface{}       `md:"content"`     // The message content to send. This is only used in POST, PUT, and PATCH
}

func (*Input) FromMap

func (i *Input) FromMap(values map[string]interface{}) error

func (*Input) ToMap

func (i *Input) ToMap() map[string]interface{}

type Output

type Output struct {
	Status int         `md:"status"` // The HTTP status code
	Data   interface{} `md:"data"`   // The HTTP response data
}

func (*Output) FromMap

func (o *Output) FromMap(values map[string]interface{}) error

func (*Output) ToMap

func (o *Output) ToMap() map[string]interface{}

type Settings

type Settings struct {
	Method        string            `md:"method,required,allowed(GET,POST,PUT,PATCH,DELETE)"` // The HTTP method to invoke
	Uri           string            `md:"uri,required"`                                       // The URI of the service to invoke
	Headers       map[string]string `md:"headers"`                                            // The HTTP header parameters
	Proxy         string            `md:"proxy"`                                              // The address of the proxy server to be use
	Timeout       int               `md:"timeout"`                                            // The request timeout in seconds
	SkipSSLVerify bool              `md:"skipSSLVerify"`                                      // Skip SSL validation
	CertFile      string            `md:"certFile"`                                           // Path to PEM encoded client certificate
	KeyFile       string            `md:"keyFile"`                                            // Path to PEM encoded client key
	CAFile        string            `md:"CAFile"`                                             // Path to PEM encoded root certificates file

}

Jump to

Keyboard shortcuts

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