meta

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2019 License: BSD-2-Clause Imports: 9 Imported by: 1

Documentation

Overview

Package meta provides easy API access to Sourcehut account info.

Index

Constants

View Source
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 NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient returns a new API client.

func (*Client) DeletePGPKey

func (c *Client) DeletePGPKey(id int64) error

DeletePGPKey deletes the PGP key with the provided ID.

func (*Client) DeleteSSHKey

func (c *Client) DeleteSSHKey(id int64) error

DeleteSSHKey deletes the SSH key with the provided ID.

func (*Client) GetPGPKey

func (c *Client) GetPGPKey(id int64) (PGPKey, error)

GetPGPKey returns the PGP key with the provided ID.

func (*Client) GetSSHKey

func (c *Client) GetSSHKey(id int64) (SSHKey, error)

GetSSHKey returns the SSH key with the provided ID.

func (*Client) GetUser

func (c *Client) GetUser() (User, error)

GetUser returns information about the currently authenticated user.

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

func (c *Client) NewPGPKey(k string) (PGPKey, error)

NewPGPKey creates a new PGP key. The key should be in authorized_keys format.

func (*Client) NewSSHKey

func (c *Client) NewSSHKey(k string) (SSHKey, error)

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.

func (*Client) Version

func (c *Client) Version() (string, error)

Version returns the version of the API.

API docs: https://man.sr.ht/api-conventions.md#get-apiversion

type Option

type Option func(*Client) error

Option is used to configure an API client.

func Base

func Base(base string) Option

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.

type User

type User struct {
	sourcehut.User

	UsePGPKey string `json:"use_pgp_key"`
}

User expands on the standard user struct.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL