thc

package module
v0.0.0-...-97b7398 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: AGPL-3.0 Imports: 10 Imported by: 0

README

thc

thc (Temporal HTTP Client) is a Golang library for interacting with Temporal's HTTP API. Additionally it includes a command line tool that lets you use a subset of the API from the command line! This makes it extremely easy to use Temporal as a backup tool, or even for easily hosting your website on IPFS.

Download (CLI)

We curently distribute pre-built binaries in a wide variety of platforms, including:

  • linux (32+64 bit)
  • arm
  • darwin/mac (32+64 bit)
  • windows (32+64 bit)

To access the prebuilt binaries, including the sha256 checksums, please see here

Usage (CLI)

To use the CLI, regardless of the command you're using, you must provide the flags --user.name, and --user.pass for the Temporal account that you want to use. The values for these flags are used to authenticate with the API, and generate the JWT used to authenticate calls like pins, lens indexing, etc...

Currently the supported commands are:

  • File uploads
    • This is used to uplaod files, and is essentially a wrapper around ipfs add
  • Directory uploads
    • This is used to add directories, and is essentially a wrapper around ipfs add -r
  • Pin adds
    • This is used to add a pin to Temporal's IPFS nodes
  • Pin extend
    • This is used to extend the pin duration of your ipfs hashes
  • Lens search
    • This is used to search the lens search engine
    • Please note this command is very experimental, and the output is quite ugly
  • Lens index
    • This is used to submit content for indexing by the lens search engine

Examples

Upload a directory called release, and recursively pin the directory hash for 18 months

thc --user.name foo --user.pass bar upload dir --dir release --hold.time 18

Pin a hash QmCheese for 2 months

thc --user.name foo --user.pass bar pin --hash QmCheese --hold.time 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call string

Call is a typed string representing an API call

const (
	// DevURL is the api url for development temporal environment
	DevURL = "https://dev.api.temporal.cloud/v2"
	// ProdURL is the api url for production temporal environment
	ProdURL = "https://api.temporal.cloud/v2"
	// Login is the login api call
	Login Call = "/auth/login"
	// FileAddPublic is a file upload api call for public ipfs network
	FileAddPublic Call = "/ipfs/public/file/add"
	// PinAddPublic is a pin add api call for public ipfs network
	PinAddPublic Call = "/ipfs/public/pin/%s"
	// PinExtendPublic is used to extend pin durations
	PinExtendPublic Call = "/ipfs/public/pin/%s/extend"
	// LensIndex is used to index content against lens
	LensIndex Call = "/lens/index"
	// LensSearch is used to submit a search against the lens index
	LensSearch Call = "/lens/search"
)

func (Call) FillParams

func (c Call) FillParams(args ...interface{}) Call

FillParams is used to fill parameter placements for api calls

func (Call) String

func (c Call) String() string

String returns a string type of the call

type FileAddOpts

type FileAddOpts struct {
	Encrypted  bool
	Passphrase string
	HoldTime   string
}

FileAddOpts are options used to configure file uploads

type IndexResponse

type IndexResponse struct {
	Hash        string   `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
	DisplayName string   `protobuf:"bytes,2,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"`
	MimeType    string   `protobuf:"bytes,3,opt,name=mime_type,json=mimeType,proto3" json:"mime_type,omitempty"`
	Category    string   `protobuf:"bytes,4,opt,name=category,proto3" json:"category,omitempty"`
	Tags        []string `protobuf:"bytes,5,rep,name=tags,proto3" json:"tags,omitempty"`
}

IndexResponse is a response from a lens index call

type LoginResponse

type LoginResponse struct {
	Expire string `json:"expire"`
	Token  string `json:"token"`
}

LoginResponse is a response from the login api call

type Response

type Response struct {
	Code     int    `json:"code"`
	Response string `json:"response"`
}

Response is a general api response applicable for multiple calls

type SearchResponse

type SearchResponse struct {
	Code     int `json:"code"`
	Response struct {
		Results []struct {
			Score float64 `json:"score"`
			Doc   struct {
				Hash     string `json:"hash"`
				MimeType string `json:"mime_type"`
				Category string `json:"category"`
			} `json:"doc"`
		} `json:"results"`
	} `json:"response"`
}

type V2

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

V2 is our interface with temporal's v2 api

func NewV2

func NewV2(user, pass, url string) *V2

NewV2 instantiates our V2 client

func (*V2) FileAdd

func (v2 *V2) FileAdd(filePath string, opts FileAddOpts) (string, error)

FileAdd is used to add a file to ipfs it returns the hash of the file that was uploaded

func (*V2) GetJWT

func (v2 *V2) GetJWT() (string, error)

GetJWT is used to return the JWT you use to authorize this account

func (*V2) IndexHash

func (v2 *V2) IndexHash(hash string, reindex bool) (string, error)

IndexHash is used to index a hash with lens

func (*V2) Login

func (v2 *V2) Login() error

Login is used to authenticate with the API and generate a JWT

func (*V2) PinAdd

func (v2 *V2) PinAdd(hash, holdTime string) (string, error)

PinAdd is used to pin an ipfs hash

func (*V2) PinExtend

func (v2 *V2) PinExtend(hash, holdTime string) (string, error)

PinExtend is used to extend a hold time for a pin

func (*V2) SearchLens

func (v2 *V2) SearchLens(query string) (*SearchResponse, error)

Directories

Path Synopsis
cmd
thc

Jump to

Keyboard shortcuts

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