executor

package
v1.0.56 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package executor calls UiPath services.

Index

Constants

View Source
const NotConfiguredErrorTemplate = `` /* 141-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecutionContext

type ExecutionContext struct {
	Organization string
	Tenant       string
	Method       string
	BaseUri      url.URL
	Route        string
	ContentType  string
	Input        *FileReference
	Parameters   ExecutionContextParameters
	AuthConfig   config.AuthConfig
	Insecure     bool
	Debug        bool
	Plugin       plugin.CommandPlugin
}

The ExecutionContext provides all the data needed by the executor to construct the HTTP request including URL, headers and body.

func NewExecutionContext

func NewExecutionContext(
	organization string,
	tenant string,
	method string,
	uri url.URL,
	route string,
	contentType string,
	input *FileReference,
	parameters ExecutionContextParameters,
	authConfig config.AuthConfig,
	insecure bool,
	debug bool,
	plugin plugin.CommandPlugin) *ExecutionContext

type ExecutionContextParameters added in v1.0.39

type ExecutionContextParameters struct {
	Path   []ExecutionParameter
	Query  []ExecutionParameter
	Header []ExecutionParameter
	Body   []ExecutionParameter
	Form   []ExecutionParameter
}

The ExecutionContextParameters contains list of parameters which are used by the executor to dynamically build the request.

func NewExecutionContextParameters added in v1.0.39

func NewExecutionContextParameters(
	path []ExecutionParameter,
	query []ExecutionParameter,
	header []ExecutionParameter,
	body []ExecutionParameter,
	form []ExecutionParameter) *ExecutionContextParameters

type ExecutionParameter

type ExecutionParameter struct {
	Name  string
	Value interface{}
}

An ExecutionParameter is a value which is used by the executor to build the request. Parameter values are typicall provided by multiple sources like config files, command line arguments and environment variables.

func NewExecutionParameter

func NewExecutionParameter(name string, value interface{}) *ExecutionParameter

type Executor

type Executor interface {
	Call(context ExecutionContext, writer output.OutputWriter, logger log.Logger) error
}

The Executor interface is an abstraction for carrying out CLI commands.

The ExecutionContext provides all the data needed to execute a command. The OutputWriter should be used to output the result of the command. The Logger should be used for providing additional information when running a command.

type FileReference

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

A FileReference provides access to binary data usually referencing a file on disk. This allows the executor to stream large files directly when sending the HTTP request instead of loading them in memory first.

The FileReference can also be initialized from byte array in case the data already resides in memory.

func NewFileReference

func NewFileReference(path string) *FileReference

func NewFileReferenceData added in v1.0.23

func NewFileReferenceData(filename string, data []byte) *FileReference

func (FileReference) Data

func (f FileReference) Data() (io.ReadCloser, int64, error)

func (FileReference) Filename

func (f FileReference) Filename() string

type HttpExecutor

type HttpExecutor struct {
	Authenticators []auth.Authenticator
}

The HttpExecutor implements the Executor interface and constructs HTTP request from the given command line parameters and configurations.

func (HttpExecutor) Call

func (e HttpExecutor) Call(context ExecutionContext, writer output.OutputWriter, logger log.Logger) error

type ParameterFormatter added in v1.0.54

type ParameterFormatter struct{}

The ParameterFormatter converts ExecutionParameter into a string. Depending on the type of the parameter, the formatter converts the value to the proper format: - Integers, Float, etc.. are simply converted to a string - Arrays are formatted comma-separated - Booleans are converted to true or false

func NewParameterFormatter added in v1.0.54

func NewParameterFormatter() *ParameterFormatter

func (ParameterFormatter) Format added in v1.0.54

func (f ParameterFormatter) Format(parameter ExecutionParameter) string

type PluginExecutor added in v1.0.3

type PluginExecutor struct {
	Authenticators []auth.Authenticator
}

The PluginExecutor implements the Executor interface and invokes the registered plugin for the executed command. The plugin takes care of sending the HTTP request or performing other operations.

func (PluginExecutor) Call added in v1.0.3

func (e PluginExecutor) Call(context ExecutionContext, writer output.OutputWriter, logger log.Logger) error

type QueryStringFormatter added in v1.0.54

type QueryStringFormatter struct{}

The QueryStringFormatter converts ExecutionParameter's into a query string.

Depending on the type of the parameter, the formatter converts the value to the proper format and makes sure the query string is properly escaped.

Example: - parameter 'username' and value 'tschmitt' - parameter 'message' and value 'Hello World' --> username=tschmitt&message=Hello+World

func NewQueryStringFormatter added in v1.0.54

func NewQueryStringFormatter() *QueryStringFormatter

func (QueryStringFormatter) Format added in v1.0.54

func (f QueryStringFormatter) Format(parameters []ExecutionParameter) string

type UriFormatter added in v1.0.54

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

The UriFormatter takes an Uri and formats it with ExecutionParameter values.

The formatter supports replacing path placeholders like organization and tenant: https://cloud.uipath.com/{organization} with parameter 'organization' and value 'my-org' --> https://cloud.uipath.com/my-org

The formatter also supports adding query strings to the uri: https://cloud.uipath.com/users with parameter 'firstName' and value 'Thomas' and parameter 'lastName' and value 'Schmitt' --> https://cloud.uipath.com/users?firstName=Thomas&lastName=Schmitt

func NewUriFormatter added in v1.0.54

func NewUriFormatter(baseUri url.URL, route string) *UriFormatter

func (*UriFormatter) AddQueryString added in v1.0.54

func (f *UriFormatter) AddQueryString(parameters []ExecutionParameter)

func (*UriFormatter) FormatPath added in v1.0.54

func (f *UriFormatter) FormatPath(parameter ExecutionParameter)

func (UriFormatter) Uri added in v1.0.54

func (f UriFormatter) Uri() string

Jump to

Keyboard shortcuts

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