client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: ISC Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RecordVerify

func RecordVerify(r pdv2.Record, serverPubKey string) error

RecordVerify verifies the censorship record of a v2 Record.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides a client for interacting with the politeiad API.

func New

func New(rpcHost, rpcCert, rpcUser, rpcPass string, pid *identity.PublicIdentity) (*Client, error)

New returns a new politeiad client.

func (*Client) Author

func (c *Client) Author(ctx context.Context, token string) (string, error)

Author sends the user plugin Author command to the politeiad v2 API.

func (*Client) CommentCount

func (c *Client) CommentCount(ctx context.Context, tokens []string) (map[string]uint32, error)

CommentCount sends a batch of comment plugin Count commands to the politeiad v2 API and returns a map[token]count with the results. If a record is not found for a token or any other error occurs, that token will not be included in the reply.

func (*Client) CommentDel

func (c *Client) CommentDel(ctx context.Context, d comments.Del) (*comments.DelReply, error)

CommentDel sends the comments plugin Del command to the politeiad v2 API.

func (*Client) CommentNew

func (c *Client) CommentNew(ctx context.Context, n comments.New) (*comments.Comment, error)

CommentNew sends the comments plugin New command to the politeiad v2 API.

func (*Client) CommentTimestamps

func (c *Client) CommentTimestamps(ctx context.Context, token string, t comments.Timestamps) (*comments.TimestampsReply, error)

CommentTimestamps sends the comments plugin Timestamps command to the politeiad v2 API.

func (*Client) CommentVote

func (c *Client) CommentVote(ctx context.Context, v comments.Vote) (*comments.VoteReply, error)

CommentVote sends the comments plugin Vote command to the politeiad v2 API.

func (*Client) CommentVotes

func (c *Client) CommentVotes(ctx context.Context, token string, v comments.Votes) ([]comments.CommentVote, error)

CommentVotes sends the comments plugin Votes command to the politeiad v2 API.

func (*Client) CommentsGet

func (c *Client) CommentsGet(ctx context.Context, token string, g comments.Get) (map[uint32]comments.Comment, error)

CommentsGet sends the comments plugin Get command to the politeiad v2 API.

func (*Client) CommentsGetAll

func (c *Client) CommentsGetAll(ctx context.Context, token string) ([]comments.Comment, error)

CommentsGetAll sends the comments plugin GetAll command to the politeiad v2 API.

func (*Client) GetUnvetted

func (c *Client) GetUnvetted(ctx context.Context, token string) (*pdv1.Record, error)

GetUnvetted sends a GetUnvetted request to the politeiad v1 API.

func (*Client) GetVetted

func (c *Client) GetVetted(ctx context.Context, token, version string) (*pdv1.Record, error)

GetVetted sends a GetVetted request to the politeiad v1 API.

func (*Client) Identity

func (c *Client) Identity(ctx context.Context) (*identity.PublicIdentity, error)

Identity sends a Identity request to the politeiad v1 API.

func (*Client) Inventory

func (c *Client) Inventory(ctx context.Context, state pdv2.RecordStateT, status pdv2.RecordStatusT, page uint32) (*pdv2.InventoryReply, error)

Inventory sends a Inventory command to the politeiad v2 API.

func (*Client) InventoryOrdered

func (c *Client) InventoryOrdered(ctx context.Context, state pdv2.RecordStateT, page uint32) ([]string, error)

InventoryOrdered sends a InventoryOrdered command to the politeiad v2 API.

func (*Client) NewRecord

func (c *Client) NewRecord(ctx context.Context, metadata []pdv1.MetadataStream, files []pdv1.File) (*pdv1.CensorshipRecord, error)

NewRecord sends a NewRecord request to the politeiad v1 API.

func (*Client) PluginCommand

func (c *Client) PluginCommand(ctx context.Context, pluginID, cmd, payload string) (string, error)

PluginCommand sends a PluginCommand request to the politeiad v1 API.

func (*Client) PluginInventory

func (c *Client) PluginInventory(ctx context.Context) ([]pdv2.Plugin, error)

PluginInventory sends a PluginInventory command to the politeiad v2 API.

func (*Client) PluginReads

func (c *Client) PluginReads(ctx context.Context, cmds []pdv2.PluginCmd) ([]pdv2.PluginCmdReply, error)

PluginReads sends a PluginReads command to the politeiad v2 API.

func (*Client) PluginWrite

func (c *Client) PluginWrite(ctx context.Context, cmd pdv2.PluginCmd) (string, error)

PluginWrite sends a PluginWrite command to the politeiad v2 API.

func (*Client) RecordEdit

func (c *Client) RecordEdit(ctx context.Context, token string, mdAppend, mdOverwrite []pdv2.MetadataStream, filesAdd []pdv2.File, filesDel []string) (*pdv2.Record, error)

RecordEdit sends a RecordEdit command to the politeiad v2 API.

func (*Client) RecordEditMetadata

func (c *Client) RecordEditMetadata(ctx context.Context, token string, mdAppend, mdOverwrite []pdv2.MetadataStream) (*pdv2.Record, error)

RecordEditMetadata sends a RecordEditMetadata command to the politeiad v2 API.

func (*Client) RecordNew

func (c *Client) RecordNew(ctx context.Context, metadata []pdv2.MetadataStream, files []pdv2.File) (*pdv2.Record, error)

RecordNew sends a RecordNew command to the politeiad v2 API.

func (*Client) RecordSetStatus

func (c *Client) RecordSetStatus(ctx context.Context, token string, status pdv2.RecordStatusT, mdAppend, mdOverwrite []pdv2.MetadataStream) (*pdv2.Record, error)

RecordSetStatus sends a RecordSetStatus command to the politeiad v2 API.

func (*Client) RecordTimestamps

func (c *Client) RecordTimestamps(ctx context.Context, token string, version uint32) (*pdv2.RecordTimestampsReply, error)

RecordTimestamps sends a RecordTimestamps command to the politeiad v2 API.

func (*Client) Records

func (c *Client) Records(ctx context.Context, reqs []pdv2.RecordRequest) (map[string]pdv2.Record, error)

Records sends a Records command to the politeiad v2 API.

func (*Client) SetUnvettedStatus

func (c *Client) SetUnvettedStatus(ctx context.Context, token string, status pdv1.RecordStatusT, mdAppend, mdOverwrite []pdv1.MetadataStream) error

SetUnvettedStatus sends a SetUnvettedStatus request to the politeiad v1 API.

func (*Client) SetVettedStatus

func (c *Client) SetVettedStatus(ctx context.Context, token string, status pdv1.RecordStatusT, mdAppend, mdOverwrite []pdv1.MetadataStream) error

SetVettedStatus sends a SetVettedStatus request to the politeiad v1 API.

func (*Client) TicketVoteAuthorize

func (c *Client) TicketVoteAuthorize(ctx context.Context, a ticketvote.Authorize) (*ticketvote.AuthorizeReply, error)

TicketVoteAuthorize sends the ticketvote plugin Authorize command to the politeiad v2 API.

func (*Client) TicketVoteCastBallot

func (c *Client) TicketVoteCastBallot(ctx context.Context, token string, cb ticketvote.CastBallot) (*ticketvote.CastBallotReply, error)

TicketVoteCastBallot sends the ticketvote plugin CastBallot command to the politeiad v2 API.

func (*Client) TicketVoteDetails

func (c *Client) TicketVoteDetails(ctx context.Context, token string) (*ticketvote.DetailsReply, error)

TicketVoteDetails sends the ticketvote plugin Details command to the politeiad v2 API.

func (*Client) TicketVoteInventory

func (c *Client) TicketVoteInventory(ctx context.Context, i ticketvote.Inventory) (*ticketvote.InventoryReply, error)

TicketVoteInventory sends the ticketvote plugin Inventory command to the politeiad v2 API.

func (*Client) TicketVoteResults

func (c *Client) TicketVoteResults(ctx context.Context, token string) (*ticketvote.ResultsReply, error)

TicketVoteResults sends the ticketvote plugin Results command to the politeiad v2 API.

func (*Client) TicketVoteStart

func (c *Client) TicketVoteStart(ctx context.Context, token string, s ticketvote.Start) (*ticketvote.StartReply, error)

TicketVoteStart sends the ticketvote plugin Start command to the politeiad v2 API.

func (*Client) TicketVoteSubmissions

func (c *Client) TicketVoteSubmissions(ctx context.Context, token string) ([]string, error)

TicketVoteSubmissions sends the ticketvote plugin Submissions command to the politeiad v2 API.

func (*Client) TicketVoteSummaries

func (c *Client) TicketVoteSummaries(ctx context.Context, tokens []string) (map[string]ticketvote.SummaryReply, error)

TicketVoteSummaries sends a batch of ticketvote plugin Summary commands to the politeiad v2 API. Individual summary errors are not returned, the token will simply be left out of the returned map.

func (*Client) TicketVoteSummary

func (c *Client) TicketVoteSummary(ctx context.Context, token string) (*ticketvote.SummaryReply, error)

TicketVoteSummary sends the ticketvote plugin Summary command to the politeiad v2 API.

func (*Client) TicketVoteTimestamps

func (c *Client) TicketVoteTimestamps(ctx context.Context, token string, t ticketvote.Timestamps) (*ticketvote.TimestampsReply, error)

TicketVoteTimestamps sends the ticketvote plugin Timestamps command to the politeiad v2 API.

func (*Client) UpdateUnvetted

func (c *Client) UpdateUnvetted(ctx context.Context, token string, mdAppend, mdOverwrite []pdv1.MetadataStream, filesAdd []pdv1.File, filesDel []string) error

UpdateUnvetted sends a UpdateRecord request to the unvetted politeiad v1 API.

func (*Client) UpdateVetted

func (c *Client) UpdateVetted(ctx context.Context, token string, mdAppend, mdOverwrite []pdv1.MetadataStream, filesAdd []pdv1.File, filesDel []string) error

UpdateVetted sends a UpdateRecord request to the vetted politeiad v1 API.

func (*Client) UpdateVettedMetadata

func (c *Client) UpdateVettedMetadata(ctx context.Context, token string, mdAppend, mdOverwrite []pdv1.MetadataStream) error

UpdateVettedMetadata sends a UpdateVettedMetadata request to the politeiad v1 API.

func (*Client) UserRecords

func (c *Client) UserRecords(ctx context.Context, userID string) (*usermd.UserRecordsReply, error)

UserRecords sends the user plugin UserRecords command to the politeiad v2 API.

type ErrorReply

type ErrorReply struct {
	PluginID     string `json:"pluginid"`
	ErrorCode    uint32 `json:"errorcode"`
	ErrorContext string `json:"errorcontext"`
}

ErrorReply represents the request body that is returned from politeaid when an error occurs. PluginID will only be populated if the error occurred during execution of a plugin command.

type RespError

type RespError struct {
	HTTPCode   int
	ErrorReply ErrorReply
}

RespErr represents a politeiad response error. A RespError is returned anytime the politeiad response is not a 200.

func (RespError) Error

func (e RespError) Error() string

Error satisfies the error interface.

Jump to

Keyboard shortcuts

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