28ce79eff1
* feat(ooapi): add toplevel client and simplify API This diff should simplify using ooapi from other packages by adding more abstraction that wraps the existing code. Part of https://github.com/ooni/probe/issues/1355. * fix(ooapi): use correct comment for cloners See https://github.com/ooni/probe-cli/pull/248#discussion_r590663843 * fix(ooapi): make sure the documentation is current See https://github.com/ooni/probe-cli/pull/248#discussion_r590665773 * fix(ooapi): automate copying APIs See https://github.com/ooni/probe-cli/pull/248#discussion_r590665837 * feat(ooapi): add unit tests for clientcall.go See https://github.com/ooni/probe-cli/pull/248#discussion_r590666297 * fix(ooapi): rewrite integration tests to use toplevel API See https://github.com/ooni/probe-cli/pull/248#discussion_r590665084
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
// Package ooapi contains a client for the OONI API. We
|
|
// automatically generate the code in this package from the
|
|
// apimodel and internal/generator packages.
|
|
//
|
|
// Usage
|
|
//
|
|
// You need to create a Client. Make sure you set all
|
|
// the mandatory fields. You will then have a function
|
|
// for every supported OONI API. This function will
|
|
// take in input a context and a request. You need to
|
|
// fill the request, of course. The return value is
|
|
// either a response or an error.
|
|
//
|
|
// If an API requires login, we will automatically
|
|
// perform the login. If an API uses caching, we will
|
|
// automatically use the cache.
|
|
//
|
|
// See the example describing auto-login for more information
|
|
// on how to use auto-login.
|
|
//
|
|
// Design
|
|
//
|
|
// Most of the code in this package is auto-generated from the
|
|
// data model in ./apimodel and the definition of APIs provided
|
|
// by ./internal/generator/spec.go.
|
|
//
|
|
// We keep the generated files up-to-date by running
|
|
//
|
|
// go generate ./...
|
|
//
|
|
// We have tests that ensure that the definition of the API
|
|
// used here is reasonably close to the server's one.
|
|
//
|
|
// Testing
|
|
//
|
|
// The following command
|
|
//
|
|
// go test ./...
|
|
//
|
|
// will, among other things, ensure that the our API spec
|
|
// is consistent with the server's one. Running
|
|
//
|
|
// go test -short ./...
|
|
//
|
|
// will exclude most (slow) integration tests.
|
|
//
|
|
// Architecture
|
|
//
|
|
// The ./apimodel package contains the definition of request
|
|
// and response messages. We rely on tagging to specify how
|
|
// we should encode and decode messages.
|
|
//
|
|
// The ./internal/generator contains code to generate most
|
|
// code in this package. In particular, the spec.go file is
|
|
// the specification of the APIs.
|
|
package ooapi
|