mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-27 05:17:49 +08:00
coreapi: object API tests
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@858d49b07c This commit was moved from ipfs/boxo@d878d81227
This commit is contained in:
parent
540ec53bf8
commit
a8a84d5b1b
@ -219,6 +219,14 @@ type ObjectAPI interface {
|
||||
// * "json"
|
||||
WithInputEnc(e string) options.ObjectPutOption
|
||||
|
||||
// WithDataType specifies the encoding of data field when using Josn or XML
|
||||
// input encoding.
|
||||
//
|
||||
// Supported types:
|
||||
// * "text" (default)
|
||||
// * "base64"
|
||||
WithDataType(t string) options.ObjectPutOption
|
||||
|
||||
// Get returns the node for the path
|
||||
Get(context.Context, Path) (Node, error)
|
||||
|
||||
@ -234,20 +242,20 @@ type ObjectAPI interface {
|
||||
// AddLink adds a link under the specified path. child path can point to a
|
||||
// subdirectory within the patent which must be present (can be overridden
|
||||
// with WithCreate option).
|
||||
AddLink(ctx context.Context, base Path, name string, child Path, opts ...options.ObjectAddLinkOption) (Node, error)
|
||||
AddLink(ctx context.Context, base Path, name string, child Path, opts ...options.ObjectAddLinkOption) (Path, error)
|
||||
|
||||
// WithCreate is an option for AddLink which specifies whether create required
|
||||
// directories for the child
|
||||
WithCreate(create bool) options.ObjectAddLinkOption
|
||||
|
||||
// RmLink removes a link from the node
|
||||
RmLink(ctx context.Context, base Path, link string) (Node, error)
|
||||
RmLink(ctx context.Context, base Path, link string) (Path, error)
|
||||
|
||||
// AppendData appends data to the node
|
||||
AppendData(context.Context, Path, io.Reader) (Node, error)
|
||||
AppendData(context.Context, Path, io.Reader) (Path, error)
|
||||
|
||||
// SetData sets the data contained in the node
|
||||
SetData(context.Context, Path, io.Reader) (Node, error)
|
||||
SetData(context.Context, Path, io.Reader) (Path, error)
|
||||
}
|
||||
|
||||
// ObjectStat provides information about dag nodes
|
||||
@ -267,7 +275,7 @@ type ObjectStat struct {
|
||||
// DataSize is the size of data block section
|
||||
DataSize int
|
||||
|
||||
// CumulativeSize is size of node
|
||||
// CumulativeSize is size of the tree (BlockSize + link sizes)
|
||||
CumulativeSize int
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ type ObjectNewSettings struct {
|
||||
|
||||
type ObjectPutSettings struct {
|
||||
InputEnc string
|
||||
DataType string
|
||||
}
|
||||
|
||||
type ObjectAddLinkSettings struct {
|
||||
@ -33,6 +34,7 @@ func ObjectNewOptions(opts ...ObjectNewOption) (*ObjectNewSettings, error) {
|
||||
func ObjectPutOptions(opts ...ObjectPutOption) (*ObjectPutSettings, error) {
|
||||
options := &ObjectPutSettings{
|
||||
InputEnc: "json",
|
||||
DataType: "text",
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
@ -74,6 +76,13 @@ func (api *ObjectOptions) WithInputEnc(e string) ObjectPutOption {
|
||||
}
|
||||
}
|
||||
|
||||
func (api *ObjectOptions) WithDataType(t string) ObjectPutOption {
|
||||
return func(settings *ObjectPutSettings) error {
|
||||
settings.DataType = t
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (api *ObjectOptions) WithCreate(create bool) ObjectAddLinkOption {
|
||||
return func(settings *ObjectAddLinkSettings) error {
|
||||
settings.Create = create
|
||||
|
||||
Loading…
Reference in New Issue
Block a user