restapi

package
v0.9.0-beta Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(logger *zap.Logger) base.IConnector

Types

type APIKeyAuth

type APIKeyAuth struct {
	AuthType     AuthType     `json:"auth_type"`
	Key          string       `json:"key"`
	Value        string       `json:"value"`
	AuthLocation AuthLocation `json:"auth_location"`
}

ApiKeyAuth is the API key authentication method

func (APIKeyAuth) GenAuthHeader

func (aka APIKeyAuth) GenAuthHeader() (string, string, error)

func (APIKeyAuth) GenAuthQuery

func (aka APIKeyAuth) GenAuthQuery() (string, string, error)

func (APIKeyAuth) GetAuthLocation

func (aka APIKeyAuth) GetAuthLocation() AuthLocation

type AuthLocation

type AuthLocation string

AuthLocation is the enum for AuthLocation field in ApiKeyAuth struct, which represents the location of the authentication string, it can be "header" or "query"

const (
	Header AuthLocation = "header"
	Query  AuthLocation = "query"
)

type AuthType

type AuthType string
const (
	NoAuthType      AuthType = "NO_AUTH"
	BasicAuthType   AuthType = "BASIC_AUTH"
	APIKeyType      AuthType = "API_KEY"
	BearerTokenType AuthType = "BEARER_TOKEN"
)

type Authentication

type Authentication interface {
	// GetAuthLocation returns the location of the authentication string, it can be "header" or "query"
	GetAuthLocation() AuthLocation
	// GenAuthHeader generates the authentication header key and value
	GenAuthHeader() (key, value string, err error)
	// GenAuthQuery generates the authentication key and value for query parameter
	GenAuthQuery() (key, value string, err error)
}

Authentication authentication interface

type BasicAuth

type BasicAuth struct {
	AuthType AuthType `json:"auth_type"`
	Username string   `json:"username"`
	Password string   `json:"password"`
}

BasicAuth is the basic authentication method

func (BasicAuth) GenAuthHeader

func (ba BasicAuth) GenAuthHeader() (string, string, error)

func (BasicAuth) GenAuthQuery

func (ba BasicAuth) GenAuthQuery() (string, string, error)

func (BasicAuth) GetAuthLocation

func (ba BasicAuth) GetAuthLocation() AuthLocation

type BearerTokenAuth

type BearerTokenAuth struct {
	AuthType AuthType `json:"auth_type"`
	Token    string   `json:"token"`
}

BearerTokenAuth is the bearer token authentication method

func (BearerTokenAuth) GenAuthHeader

func (bta BearerTokenAuth) GenAuthHeader() (string, string, error)

func (BearerTokenAuth) GenAuthQuery

func (bta BearerTokenAuth) GenAuthQuery() (string, string, error)

func (BearerTokenAuth) GetAuthLocation

func (bta BearerTokenAuth) GetAuthLocation() AuthLocation

type Client

type Client struct {
	BaseURL        string         `json:"base_url"`
	Authentication Authentication `json:"authentication"`
	HTTPClient     util.HTTPClient
}

func NewClient

func NewClient(config *structpb.Struct) (Client, error)

type Connector

type Connector struct {
	base.Connector
}

func (*Connector) CreateExecution

func (c *Connector) CreateExecution(defUID uuid.UUID, task string, config *structpb.Struct, logger *zap.Logger) (base.IExecution, error)

func (*Connector) Test

func (c *Connector) Test(defUid uuid.UUID, config *structpb.Struct, logger *zap.Logger) (pipelinePB.Connector_State, error)

type Execution

type Execution struct {
	base.Execution
}

func (*Execution) Execute

func (e *Execution) Execute(inputs []*structpb.Struct) ([]*structpb.Struct, error)

type NoAuth

type NoAuth struct {
	AuthType AuthType `json:"auth_type"`
}

NoAuth is the no authentication method

func (NoAuth) GenAuthHeader

func (na NoAuth) GenAuthHeader() (string, string, error)

func (NoAuth) GenAuthQuery

func (na NoAuth) GenAuthQuery() (string, string, error)

func (NoAuth) GetAuthLocation

func (na NoAuth) GetAuthLocation() AuthLocation

type TaskInput

type TaskInput struct {
	EndpointPath *string                `json:"endpoint_path,omitempty"`
	Body         map[string]interface{} `json:"body,omitempty"`
}

type TaskOutput

type TaskOutput struct {
	StatusCode int                    `json:"status_code"`
	Body       map[string]interface{} `json:"body"`
	Header     map[string][]string    `json:"header"`
}

Jump to

Keyboard shortcuts

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