Documentation
¶
Overview ¶
Package client implements an ergonomic SpiceDB client that wraps the official AuthZed gRPC client.
Index ¶
- type Client
- func (c *Client) Check(ctx context.Context, cs *consistency.Strategy, rs ...rel.Interface) ([]bool, error)
- func (c *Client) CheckAll(ctx context.Context, cs *consistency.Strategy, rs []rel.Interface) (bool, error)
- func (c *Client) CheckAny(ctx context.Context, cs *consistency.Strategy, rs []rel.Interface) (bool, error)
- func (c *Client) CheckOne(ctx context.Context, cs *consistency.Strategy, r rel.Interface) (bool, error)
- func (c *Client) Delete(ctx context.Context, f *rel.PreconditionedFilter) error
- func (c *Client) DeleteAtomic(ctx context.Context, f *rel.PreconditionedFilter) (deletedAtRevision string, err error)
- func (c *Client) ExportRelationships(ctx context.Context, fn rel.Func, revision string) error
- func (c *Client) FilterRelationships(ctx context.Context, cs *consistency.Strategy, f *rel.Filter) (iter.Seq2[*rel.Relationship, error], error)
- func (c *Client) ForEachRelationship(ctx context.Context, cs *consistency.Strategy, f *rel.Filter, fn rel.Func) error
- func (c *Client) ForEachUpdate(ctx context.Context, objTypes []string, fs []rel.Filter, fn rel.UpdateFunc) error
- func (c *Client) ForEachUpdateFromRevision(ctx context.Context, objTypes []string, fs []rel.Filter, fn rel.UpdateFunc, ...) error
- func (c *Client) ReadSchema(ctx context.Context) (schema, revision string, err error)
- func (c *Client) Write(ctx context.Context, txn *rel.Txn) (writtenAtRevision string, err error)
- func (c *Client) WriteSchema(ctx context.Context, schema string) (revision string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewPlaintext ¶
NewPlaintext creates a client that does not enforce TLS.
This should be used only for testing (usually against localhost).
func NewSystemTLS ¶
NewSystemTLS creates a client using TLS verified by the operating system's certificate chain.
This should be sufficient for production usage in the typical environments.
func NewWithOpts ¶
func NewWithOpts(endpoint string, opts ...grpc.DialOption) (*Client, error)
NewWithOpts creates a client that allows for configuring gRPC options.
This should only be used if the other methods don't suffice.
I'd love to hear about what DialOptions you're using in the SpiceDB Discord (https://discord.gg/spicedb) or the issue tracker for this library.
func (*Client) Check ¶
func (c *Client) Check(ctx context.Context, cs *consistency.Strategy, rs ...rel.Interface) ([]bool, error)
Check performs a batched permissions check for the provided relationships.
func (*Client) CheckAll ¶
func (c *Client) CheckAll(ctx context.Context, cs *consistency.Strategy, rs []rel.Interface) (bool, error)
CheckAll returns true if all of the provided relationships have access.
func (*Client) CheckAny ¶
func (c *Client) CheckAny(ctx context.Context, cs *consistency.Strategy, rs []rel.Interface) (bool, error)
CheckAny returns true if any of the provided relationships have access.
func (*Client) CheckOne ¶
func (c *Client) CheckOne(ctx context.Context, cs *consistency.Strategy, r rel.Interface) (bool, error)
CheckOne performs a permissions check for a single relationship.
func (*Client) Delete ¶
Delete removes all of the relationships matching the provided filter in batches.
func (*Client) DeleteAtomic ¶
func (c *Client) DeleteAtomic(ctx context.Context, f *rel.PreconditionedFilter) (deletedAtRevision string, err error)
DeleteAtomic removes all of the relationships matching the provided filter in a single transaction.
func (*Client) ExportRelationships ¶
ExportRelationships is similar to ReadRelationships, but cannot be filtered and is optimized for performing full backups of SpiceDB.
A proper backup should include relationships and schema, so this function should be called with the same revision as said schema.
func (*Client) FilterRelationships ¶
func (c *Client) FilterRelationships(ctx context.Context, cs *consistency.Strategy, f *rel.Filter) (iter.Seq2[*rel.Relationship, error], error)
FilterRelationships returns an iterator for all of the relationships matching the provided filter.
func (*Client) ForEachRelationship ¶
func (c *Client) ForEachRelationship(ctx context.Context, cs *consistency.Strategy, f *rel.Filter, fn rel.Func) error
ForEachRelationship calls the provided function for each relationship matching the provided filter.
func (*Client) ForEachUpdate ¶
func (c *Client) ForEachUpdate(ctx context.Context, objTypes []string, fs []rel.Filter, fn rel.UpdateFunc) error
ForEachUpdate performs subscribes to optionally-filtered updates out of the SpiceDB Watch API calling the provided UpdateFunc for each result.
This function can and should be cancelled via context.
func (*Client) ForEachUpdateFromRevision ¶
func (c *Client) ForEachUpdateFromRevision(ctx context.Context, objTypes []string, fs []rel.Filter, fn rel.UpdateFunc, revision string) error
ForEachUpdateFromRevision is the same as ForEachUpdate, but begins at a specific revision onward.
This function can and should be cancelled via context.
func (*Client) ReadSchema ¶
ReadSchema reads the current schema with full consistency.
func (*Client) WriteSchema ¶
WriteSchema applies the provided schema to SpiceDB.
Any schema causing relationships to be unreferenced will throw an error. These relationships must be deleted before the schema can be valid.