Documentation
¶
Overview ¶
package client provides methods for SFO Museum API clients.
Index ¶
- Constants
- func ExecuteMethodPaginatedWithClient(ctx context.Context, cl Client, verb string, args *url.Values) iter.Seq2[io.ReadSeeker, error]
- func RegisterClient(ctx context.Context, scheme string, f ClientInitializeFunc) error
- func Schemes() []string
- type Client
- type ClientInitializeFunc
- type OAuth2Client
Constants ¶
const API_ENDPOINT string = "https://api.sfomuseum.org/rest"
API_ENDPOINT is the default endpoint for the api.sfomuseum.org API.
Variables ¶
This section is empty.
Functions ¶
func ExecuteMethodPaginatedWithClient ¶
func ExecuteMethodPaginatedWithClient(ctx context.Context, cl Client, verb string, args *url.Values) iter.Seq2[io.ReadSeeker, error]
ExecuteMethodPaginatedWithClient performs as many paginated API requests for a given method. It returns a `iter.Seq2[io.ReadSeeker, error]` instance which can be iterated through to yield each API result.
func RegisterClient ¶
func RegisterClient(ctx context.Context, scheme string, f ClientInitializeFunc) error
Register a new URI scheme and ClientInitializeFunc function for a implementation of the Client interface.
Types ¶
type Client ¶
type Client interface {
// ExecuteMethod performs an API method request.
ExecuteMethod(context.Context, string, *url.Values) (io.ReadSeekCloser, error)
}
type Client is an interface for SFO Museum API client implementations.
func NewClient ¶
Create a new instance of the Client interface. Client instances are created by passing in a context.Context instance and a URI string. The form and substance of URI strings are specific to their implementations.
For example to create a OAuth2Client you might write:
cl, _ := client.NewClient(ctx, "oauth2://collection?access_token={TOKEN}")
func NewOAuth2Client ¶
NewOAuth2Client creates a new `OAuth2Client` instance configured by 'uri' which is expected to take the form of:
oauth2://{HOST}/{PATH}?{PARAMETERS}
Where {PARAMETERS} is: - `?access_token={TOKEN}` A valid OAuth2 access token. - `?insecure={BOOLEAN}` A boolean flag signaling that TLS verification will be skipped.
type ClientInitializeFunc ¶
The initialization function signature for implementation of the Client interface.
type OAuth2Client ¶
type OAuth2Client struct {
Client
// contains filtered or unexported fields
}
OAuth2Client implements the `Client` interface for API endpoints that require OAuth2 access token authentication.
func (*OAuth2Client) ExecuteMethod ¶
func (cl *OAuth2Client) ExecuteMethod(ctx context.Context, verb string, args *url.Values) (io.ReadSeekCloser, error)
ExecuteMethod will perform an API request derived from 'verb' and 'args'.