Documentation
¶
Overview ¶
Package meta provides easy API access to Sourcehut account info.
Index ¶
- Constants
- type AuditLog
- type AuditLogIter
- type Client
- func (c *Client) DeletePGPKey(id int64) error
- func (c *Client) DeleteSSHKey(id int64) error
- func (c *Client) GetPGPKey(id int64) (PGPKey, error)
- func (c *Client) GetSSHKey(id int64) (SSHKey, error)
- func (c *Client) GetUser() (User, error)
- func (c *Client) ListAuditLog() (AuditLogIter, error)
- func (c *Client) ListPGPKeys() (PGPKeyIter, error)
- func (c *Client) ListSSHKeys() (SSHKeyIter, error)
- func (c *Client) NewPGPKey(k string) (PGPKey, error)
- func (c *Client) NewSSHKey(k string) (SSHKey, error)
- func (c *Client) UpdateUser(user ProfileParams) (User, error)
- func (c *Client) Version() (string, error)
- type Option
- type PGPKey
- type PGPKeyIter
- type ProfileParams
- type SSHKey
- type SSHKeyIter
- type User
Constants ¶
const BaseURL = "https://meta.sr.ht/api/"
BaseURL is the default public Sourcehut user API URL. It is exported for convenience.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditLog ¶
type AuditLog struct { ID int64 `json:"id"` IP string `json:"ip"` Action string `json:"action"` Details string `json:"details"` Created time.Time `json:"created"` }
AuditLog represents a single entry in the audit log.
type AuditLogIter ¶
type AuditLogIter struct {
*sourcehut.Iter
}
AuditLogIter is used for iterating over the account's PGP keys.
func (AuditLogIter) Log ¶
func (i AuditLogIter) Log() AuditLog
Log returns the audit log entry which the iterator is currently pointing to.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles communication with the user related methods of the Sourcehut API.
API docs: https://man.sr.ht/meta.sr.ht/user-api.md
func (*Client) DeletePGPKey ¶
DeletePGPKey deletes the PGP key with the provided ID.
func (*Client) DeleteSSHKey ¶
DeleteSSHKey deletes the SSH key with the provided ID.
func (*Client) ListAuditLog ¶
func (c *Client) ListAuditLog() (AuditLogIter, error)
ListAuditLog returns an iterator over all audit log entries available to the authenticated user.
func (*Client) ListPGPKeys ¶
func (c *Client) ListPGPKeys() (PGPKeyIter, error)
ListPGPKeys returns an iterator over all PGP keys authorized on the users account.
func (*Client) ListSSHKeys ¶
func (c *Client) ListSSHKeys() (SSHKeyIter, error)
ListSSHKeys returns an iterator over all SSH keys authorized on the users account.
func (*Client) NewPGPKey ¶
NewPGPKey creates a new PGP key. The key should be in authorized_keys format.
func (*Client) NewSSHKey ¶
NewSSHKey creates a new SSH key. The key should be in authorized_keys format.
func (*Client) UpdateUser ¶
func (c *Client) UpdateUser(user ProfileParams) (User, error)
UpdateUser sets information about the user. Nil values indicate that the field should not be updated. If the email field is updated it will trigger a confirmation email.
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, the default sourcehut.Client (with no options of its own) is used.
type PGPKey ¶
type PGPKey struct { ID int64 `json:"id"` Authorized time.Time `json:"authorized"` Email string `json:"email"` KeyID string `json:"key_id"` Key string `json:"key"` LastUsed time.Time `json:"last_used"` Owner sourcehut.ShortUser `json:"owner"` }
PGPKey contains information about an PGP key.
type PGPKeyIter ¶
type PGPKeyIter struct {
*sourcehut.Iter
}
PGPKeyIter is used for iterating over the account's PGP keys.
func (PGPKeyIter) Key ¶
func (i PGPKeyIter) Key() PGPKey
Key returns the PGP key which the iterator is currently pointing to.
type ProfileParams ¶
type ProfileParams struct { Email *string `json:"email,omitempty"` URL *string `json:"url,omitempty"` Location *string `json:"location,omitempty"` Bio *string `json:"bio,omitempty"` }
ProfileParams is like sourcehut.User except that it omits the username fields and allows nil values for some fields that should not be updated.
type SSHKey ¶
type SSHKey struct { ID int64 `json:"id"` Authorized time.Time `json:"authorized"` Comment string `json:"comment"` Fingerprint string `json:"fingerprint"` Key string `json:"key"` Owner sourcehut.ShortUser `json:"owner"` LastUsed time.Time `json:"last_used"` }
SSHKey contains information about an SSH key.
type SSHKeyIter ¶
type SSHKeyIter struct {
*sourcehut.Iter
}
SSHKeyIter is used for iterating over the account's authorized SSH keys.
func (SSHKeyIter) Key ¶
func (i SSHKeyIter) Key() SSHKey
Key returns the SSH key which the iterator is currently pointing to.