Documentation
¶
Overview ¶
Package todo provides easy API access to Sourcehut issue trackers.
Index ¶
- Constants
- type Client
- func (c *Client) GetUser(username string) (sourcehut.User, error)
- func (c *Client) NewTracker(name, description string) (*Tracker, error)
- func (c *Client) Tracker(username, tracker string) (*Tracker, error)
- func (c *Client) Trackers(username string) (TrackerIter, error)
- func (c *Client) Version() (string, error)
- type Option
- type ShortTracker
- type Tracker
- type TrackerIter
Examples ¶
Constants ¶
const BaseURL = "https://todo.sr.ht/api/"
BaseURL is the default public Sourcehut issue trackers API URL. It is exported for convenience.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles communication with the issue tracker related methods of the Sourcehut API.
API docs: https://man.sr.ht/todo.sr.ht/api.md
func (*Client) GetUser ¶
GetUser returns information about the provided username, or the currently authenticated user if the username is empty.
func (*Client) NewTracker ¶
NewTracker creates and returns a new repository from the provided template.
func (*Client) Tracker ¶
Tracker returns information about a specific issue tracker owned by the provided username. If an empty username is provided, the authenticated user is used.
type Option ¶
Option is used to configure an API client.
func Base ¶
Base returns an option that configures the public Sourcehut API URL.
If base does not have a trailing slash, one is added automatically. If unspecified, BaseURL is used.
func SrhtClient ¶
func SrhtClient(client sourcehut.Client) Option
SrhtClient returns an option that configures the client to use the provided sourcehut.Client for API requests. If unspecified, a default sourcehut.Client (with no options of its own) is used.
type ShortTracker ¶
type ShortTracker struct { Name string `json:"name"` Owner sourcehut.ShortUser `json:"owner"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` }
ShortTracker represents the unexpanded form of an issue tracker.
type Tracker ¶
type Tracker struct { ShortTracker Desc string `json:"description"` Perms struct { Anonymous []string `json:"anonymous"` Submitter []string `json:"submitter"` User []string `json:"user"` } `json:"default_permissions"` }
Tracker represents the expanded form of an issue tracker.
type TrackerIter ¶
type TrackerIter struct {
*sourcehut.Iter
}
TrackerIter is used for iterating over a collection of issue trackers.
Example ¶
srhtClient := sourcehut.NewClient(sourcehut.Token("<personal access token>")) todoClient, _ := todo.NewClient(todo.SrhtClient(srhtClient)) iter, _ := todoClient.Trackers("~sircmpwn") for iter.Next() { p := iter.Tracker() log.Printf("Tracker %s: %s\n", p.Name, p.Desc) } if err := iter.Err(); err != nil { log.Fatalf("Error fetching posts: %q", err) }
func (TrackerIter) Tracker ¶
func (i TrackerIter) Tracker() *Tracker
Tracker returns the issue tracker which the iterator is currently pointing to.