Documentation ¶
Overview ¶
Package api handles interaction between the C3PM Command Line Interface (CLI), and C3PM's API. The package's role is to abstract all needed low level interaction, such as HTTP or filesystem calls exposing an interface simple, clear and easy to understand from the rest of the CLI.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
API represents a connection to c3pm's backend, used for authentication and publishing purposes
func (*API) CountDownload ¶ added in v0.3.0
func (*API) Login ¶
Login handles the login logic with the API. It takes the user's email and password as strings, sends them to the API, and returns the ApiKey object to be used in further calls to the API.
Example ¶
package main import ( "fmt" "github.com/c3pm-labs/c3pm/api" "net/http" ) func main() { c := api.New(&http.Client{}, "xxxx") key, err := c.Login("login", "password") fmt.Println(key, err) }
Output:
func (API) Upload ¶
Upload is a wrapper function around C3PM's publish endpoint. It takes an array of file paths, creates a tar file containing them, then uploads it to the API.
Example ¶
package main import ( "fmt" "github.com/c3pm-labs/c3pm/api" "net/http" ) func main() { c := api.New(&http.Client{}, "xxxx") err := c.Upload([]string{"../../testhelpers/tars/single.tar"}) fmt.Println(err) }
Output: