diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2023-05-01 14:19:32 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2023-09-25 09:43:37 +0200 |
| commit | d4939e8694a6762dc9de2f4027266850f49790ac (patch) | |
| tree | 89545f23dbb74766ed42dd1824c59eae35f26800 /docs/src/api/go | |
| parent | c654b48763592baae78b10f6fefec10be29e979b (diff) | |
Docs: Update API section for V2
Diffstat (limited to 'docs/src/api/go')
| -rw-r--r-- | docs/src/api/go/README.md | 12 | ||||
| -rw-r--r-- | docs/src/api/go/example.md | 17 | ||||
| -rw-r--r-- | docs/src/api/go/functions.md | 76 |
3 files changed, 0 insertions, 105 deletions
diff --git a/docs/src/api/go/README.md b/docs/src/api/go/README.md deleted file mode 100644 index 2b71f99..0000000 --- a/docs/src/api/go/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Go -The API that has no additional wrapper code is the Go API. To begin to use the Go library in a Go client you first need to import it: - -```go -import "github.com/eduvpn/eduvpn-common/client" -``` - -This brings the client library into scope using the client prefix. - -The documentation to then use this API and the rest is online at [pkg.go.dev](https://pkg.go.dev/github.com/eduvpn/eduvpn-common). - -[We also provide an example](./example.md). diff --git a/docs/src/api/go/example.md b/docs/src/api/go/example.md deleted file mode 100644 index a7f293b..0000000 --- a/docs/src/api/go/example.md +++ /dev/null @@ -1,17 +0,0 @@ -# Example with comments -The following is an example [in the repository](https://github.com/eduvpn/eduvpn-common/blob/main/cmd/cli/main.go). It is a command line client with the following flags -``` - -get-custom string - The url of a custom server to connect to - -get-institute string - The url of an institute to connect to - -get-secure string - Gets secure internet servers -``` -```go -{{#include ../../../../cmd/cli/main.go}} -``` - -The documentation to then use this API is online at [pkg.go.dev](https://pkg.go.dev/github.com/eduvpn/eduvpn-common). - -[We also provide an example](./example.md). diff --git a/docs/src/api/go/functions.md b/docs/src/api/go/functions.md deleted file mode 100644 index 2cbab78..0000000 --- a/docs/src/api/go/functions.md +++ /dev/null @@ -1,76 +0,0 @@ -# Functions -## Registering -See [Overview](../overview/registering.html) -```go -func Register(name string, directory string, stateCallback func, debug bool) error -``` -- `name`: The name of the client -- `directory`: The directory where the configs and logging should be stored -- `stateCallback`: function with three arguments, full type: - ```go - func StateCallback(oldState string, newState string, data string) - ``` -- `debug`: Whether or not we want to enable debugging - -Returns an `error` type, nil if no error - -## Discovery -See [Overview](../overview/discovery.html) -```go -func GetDiscoServers() (string, error) -func GetDiscoOrganizations() (string, error) -``` - -Returns a string of JSON data with the servers/organizations and an `error`, nil if no error - -## OpenVPN/Wireguard config -See [Overview](../overview/getconfig.html) -```go -func GetConfigInstituteAccess(url string, preferTCP bool) (string, string, error) -func GetConfigSecureInternet(url string, preferTCP bool) (string, string, error) -``` -- `url`: The URL of the Institute Access or Secure Internet server to get a connect config for -- `preferTCP`: Whether or not we want to prefer TCP - -Returns: -- A `string` of the OpenVPN/Wireguard config -- A `string`, `openvpn` or `wireguard` indicating if it is an OpenVPN or Wireguard config -- An `error` (can be nil) - -### Cancelling OAuth -```go -func CancelOAuth() error -``` -Returns an `error`, can be nil indicating no error - -### Setting a profile ID -```go -func SetProfileID(profileID string) error -``` -- `profileID`: The profile ID to connect to - -Returns an `error`, can be nil indicating no error - -## Connecting/Disconnecting -See [Overview](../overview/connecting.html) -```go -func SetConnected() error -func SetDisconnected() error -``` - -Returns an `error`, can be nil indicating no error - -## Deregister -See [Overview](../overview/deregistering.html) -```go -func Deregister() error -``` - -Returns an `error`, can be nil indicating no error - -# Note on Callbacks -Some functions (e.g. [the API for getting an OpenVPN/Wireguard config](http://localhost:3000/api/overview/getconfig.html)) need a (or multiple) callback(s) set. In Go, the callback function is given in the [Register function](#registering). The signature of this function is the following: -```go -func StateCallback(oldState string, newState string, data string) -``` -Because certain callbacks need to be set, you can simply compare against `oldState` and `newState`. To show how this can be done in practice, we will give an example in the next section. |
