v2

package
v2.0.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: MIT Imports: 50 Imported by: 1

README

Temporal API V2

API Reference

Documentation

Overview

Package v2 is the main package for Temporal's V2 http API. API reference is available [here](https://documenter.getpostman.com/view/4295780/RWEcQM6W#intro)

Index

Constants

View Source
const (
	// FilesUploadBucket is the bucket files are stored into before being processed
	FilesUploadBucket = "filesuploadbucket"
	// RtcCostUsd is the price of a single RTC in USD
	RtcCostUsd = 0.125
)

Variables

This section is empty.

Functions

func CheckAccessForPrivateNetwork

func CheckAccessForPrivateNetwork(username, networkName string, db *gorm.DB) error

CheckAccessForPrivateNetwork checks if a user has access to a private network

func Fail

func Fail(c *gin.Context, err error, code ...int)

Fail fails context with given error and optional status code. Defaults to http.StatusInternalServerError

func FailNotAuthorized

func FailNotAuthorized(c *gin.Context, message string)

FailNotAuthorized is a failure used when a user is unauthorized for an action

func FailWithBadRequest

func FailWithBadRequest(c *gin.Context, message string)

FailWithBadRequest fails context with a bad request error and given message

func FailWithMessage

func FailWithMessage(c *gin.Context, message string, code ...int)

FailWithMessage fails context with given message and optional status code. Defaults to http.StatusInternalServerError

func FailWithMissingField

func FailWithMissingField(c *gin.Context, field string)

FailWithMissingField is a failure used when a post form does not exist

func GetAuthToken

func GetAuthToken(c *gin.Context) string

GetAuthToken is used to retrieve the jwt token from an authenticated request

func GetAuthenticatedUserFromContext

func GetAuthenticatedUserFromContext(c *gin.Context) (string, error)

GetAuthenticatedUserFromContext is used to pull the eth address of hte user

func Respond

func Respond(c *gin.Context, status int, body gin.H)

Respond is a wrapper used to handle API responses

func Unzip

func Unzip(src string, dest string) ([]string, error)

Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2). from https://golangcode.com/unzip-files-in-go/

Types

type API

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

API is our API service

func Initialize

func Initialize(
	ctx context.Context,

	cfg *config.TemporalConfig,
	version string,
	opts Options,
	clients Clients,

	l *zap.SugaredLogger,

) (*API, error)

Initialize is used ot initialize our API service. debug = true is useful for debugging database issues.

func (*API) Close

func (api *API) Close()

Close releases API resources

func (*API) ConfirmETHPayment

func (api *API) ConfirmETHPayment(c *gin.Context)

ConfirmETHPayment is used to confirm an ethereum based payment

func (*API) CreateDashPayment

func (api *API) CreateDashPayment(c *gin.Context)

CreateDashPayment is used to create a dash payment via chainrider

func (*API) FileSizeCheck

func (api *API) FileSizeCheck(size int64) error

FileSizeCheck is used to check and validate the size of the uploaded file

func (*API) GetIPFSEndpoint

func (api *API) GetIPFSEndpoint(networkName string) string

GetIPFSEndpoint is used to construct the api url to connect to for private ipfs networks. in the case of dev mode it returns an default, non nexus based ipfs api address

func (*API) ListenAndServe

func (api *API) ListenAndServe(ctx context.Context, addr string, tlsConfig *TLSConfig) error

ListenAndServe spins up the API server

func (*API) LogError

func (api *API) LogError(c *gin.Context, err error, message string, fields ...interface{}) func(code ...int)

LogError is a wrapper used by the API to handle logging of errors. Returns a callback to also fail a gin context with an optional status code, which defaults to http.StatusInternalServerError. Fields is an optional set of params provided in pairs, where the first of a pair is the key, and the second is the value

Passing in the initial gin.Context to LogError is used to extract the X-Request-ID associated with the given request to make it easier to debug user-submitted erros.

func (*API) RequestSignedPaymentMessage

func (api *API) RequestSignedPaymentMessage(c *gin.Context)

RequestSignedPaymentMessage is used to get a signed message from the GRPC API Payments Server this is currently used for ETH+RTC smart-contract facilitated payments

func (*API) SystemsCheck

func (api *API) SystemsCheck(c *gin.Context)

SystemsCheck is a basic check of system integrity

type Clients

type Clients struct {
	Lens   pbLens.LensV2Client
	Orch   pbOrch.ServiceClient
	Signer pbSigner.SignerClient
}

Clients is used to configure service clients we use

type CreditRefund

type CreditRefund struct {
	Username string
	CallType string
	Cost     float64
}

CreditRefund is a data object to contain refund information

type Options

type Options struct {
	DebugLogging bool
	DevMode      bool
}

Options is used to non-critical options

type TLSConfig

type TLSConfig struct {
	CertFile string
	KeyFile  string
}

TLSConfig is used to enable TLS on the API service

Jump to

Keyboard shortcuts

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