api

package
v0.4.80 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: BSD-3-Clause Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const (
	O_RDONLY = 0
	O_WRONLY = 1
	O_RDWR   = 2
	O_CREAT  = 64
	O_EXCL   = 128
	O_TRUNC  = 512
	O_APPEND = 1024 // Irods does not support O_APPEND, we need to seek to the end //nolint:staticcheck
)

Variables

View Source
var (
	SkipAll     = filepath.SkipAll                                                //nolint:errname
	SkipDir     = filepath.SkipDir                                                //nolint:errname
	SkipSubDirs = errors.New("skip children of subdirectories of this directory") //nolint:staticcheck,errname
)
View Source
var ErrAttributeIndexMismatch = fmt.Errorf("attribute index mismatch")
View Source
var ErrAttributeOutOfBound = fmt.Errorf("attribute count out of bound")
View Source
var ErrCannotTruncate = errors.New("cannot truncate in reopened handle")
View Source
var ErrChecksumNotFound = errors.New("checksum not found")
View Source
var ErrIncompleteReplicaAccessInfo = errors.New("incomplete replica access info")
View Source
var ErrInvalidItemType = errors.New("invalid item type")
View Source
var ErrInvalidSize = errors.New("invalid size")
View Source
var ErrNoRowFound = &msg.IRODSError{
	Code:    msg.CAT_NO_ROWS_FOUND,
	Message: "query returned zero rows",
}

ErrNoRowFound is returned when no rows are found in a QueryRow result.

View Source
var ErrNoSQLResults = fmt.Errorf("no sql results")
View Source
var ErrRequiresAdmin = errors.New("this API call requires api.Admin = true")
View Source
var ErrRowOutOfBound = fmt.Errorf("row out of bound")
View Source
var ErrSameConnection = errors.New("same connection")
View Source
var ErrSkipNotAllowed = errors.New("skip not allowed")

Functions

func ComparePaths added in v0.4.56

func ComparePaths(a, b string) int

func ErrorCode

func ErrorCode(err error) (msg.ErrorCode, bool)

func Is

func Is(err error, code msg.ErrorCode) bool

func ParseIrodsChecksum added in v0.4.56

func ParseIrodsChecksum(checksum string) ([]byte, error)

func Split

func Split(path string) (string, string)

Split splits the path into dir and file

Types

type API

type API struct {
	Username, Zone  string
	Connect         func(context.Context) (Conn, error) // Handler to obtain a connection to perform requests on
	Admin           bool                                // Whether to act as admin by sending the admin keyword
	DefaultResource string                              // Default resource to use when creating data objects
	ReplicaNumber   *int                                // Replica number to use for open/checksum operations
	NumThreads      int                                 // Number of threads to use for server-side copies
}

API provides the interface to IRODS using the provided connection function. Each time an API method is called, the Connect function is called to obtain a connection, and it is closed afterwards. If used together with an instance of iron.Client, the Connect will take a connection from the pool, and when closed it will be returned to the pool. The Username and Zone must match the username and zone of the connection. If Admin is true, the API will send the admin keyword with each request. The DefaultResource is the resource to use when creating data objects.

func (*API) AddGroupMember

func (api *API) AddGroupMember(ctx context.Context, groupname, username string) error

AddGroupMember adds a user to a group. If a zone needs to be specified, use the username#zone format. This is an administrative call, a connection using a rodsadmin is required.

func (*API) AddMetadata

func (api *API) AddMetadata(ctx context.Context, name string, itemType ObjectType, value Metadata) error

AddMetadata adds a single metadata value of a data object, collection, user or resource.

func (API) AsAdmin

func (api API) AsAdmin() *API

AsAdmin returns a new API with the admin keyword set

func (*API) ChangeUserPassword

func (api *API) ChangeUserPassword(ctx context.Context, username, password string) error

ChangeUserPassword changes the password of a user object If a zone needs to be specified, use the username#zone format. This is an administrative call, a connection using a rodsadmin is required.

func (*API) ChangeUserType

func (api *API) ChangeUserType(ctx context.Context, username, userType string) error

ChangeUserType changes the type of a user If a zone needs to be specified, use the username#zone format. This is an administrative call, a connection using a rodsadmin is required.

func (*API) Checksum added in v0.3.3

func (api *API) Checksum(ctx context.Context, path string, force bool) ([]byte, error)

Checksum returns the sha256 checksum of a data object as stored in the catalog. If no checksum is present, it is calculated on the fly. A target resource can be specified with WithDefaultResource() first if needed. A replica number can be specified with WithReplicaNumber() first if needed. The force flag is used to recompute any saved checksums.

func (*API) CopyDataObject

func (api *API) CopyDataObject(ctx context.Context, oldPath, newPath string) error

CopyDataObject copies a data object. A target resource can be specified with WithDefaultResource() first if needed. It will fail if the target already exists.

func (*API) CopyMetadata added in v0.4.17

func (api *API) CopyMetadata(ctx context.Context, oldName string, oldItemType ObjectType, newName string, newItemType ObjectType) error

CopyMetadata copies metadata from one data object to another.

func (*API) CreateCollection

func (api *API) CreateCollection(ctx context.Context, name string) error

CreateCollection creates a collection. If the collection already exists, an error is returned.

func (*API) CreateCollectionAll

func (api *API) CreateCollectionAll(ctx context.Context, name string) error

CreateCollectionAll creates a collection and its parents recursively. If the collection already exists, nothing happens.

func (*API) CreateDataObject

func (api *API) CreateDataObject(ctx context.Context, path string, mode int) (File, error)

CreateDataObject creates a data object. A target resource can be specified with WithDefaultResource() first if needed. This method blocks an irods connection until the file has been closed. If the context is canceled, Seek, Read, Write, Truncate, Touch and Reopen will fail.

func (*API) CreateGroup

func (api *API) CreateGroup(ctx context.Context, groupname string) error

CreateGroup creates a group. If a zone needs to be specified, use the groupname#zone format. This is an administrative call, a connection using a rodsadmin is required.

func (*API) CreateUser

func (api *API) CreateUser(ctx context.Context, username, userType string) error

CreateUser creates a user with the given type If a zone needs to be specified, use the username#zone format. This is an administrative call, a connection using a rodsadmin is required.

func (*API) DeleteCollection

func (api *API) DeleteCollection(ctx context.Context, name string, skipTrash bool) error

DeleteCollection deletes a collection. If the collection is not empty, an error is returned. If force is true, the collection is not moved to the trash.

func (*API) DeleteCollectionAll

func (api *API) DeleteCollectionAll(ctx context.Context, name string, skipTrash bool) error

DeleteCollectionAll deletes a collection and its children recursively. If force is true, the collection is not moved to the trash.

func (*API) DeleteDataObject

func (api *API) DeleteDataObject(ctx context.Context, path string, skipTrash bool) error

DeleteDataObject deletes a data object. If force is true, the data object is not moved to the trash.

func (*API) ElevateRequest

func (api *API) ElevateRequest(ctx context.Context, apiNumber msg.APINumber, request, response any, paths ...string) error

ElevateRequest is a wrapper around api.Request, that elevates permissions on the given path if the request fails with CAT_NO_ACCESS_PERMISSION, if the admin flag is set; for operations that ignore the admin keyword. If giving permissions fails with CAT_NO_ROWS_FOUND, it will try to elevate permissions on the parent directory.

func (*API) ExecuteExternalRule

func (api *API) ExecuteExternalRule(ctx context.Context, rule string, params map[string]string, instance string) (map[string]string, error)

ExecuteExternalRule executes an irods external rule. The rule should be the string representation of the rule, without the "@external rule {" and "}" wrappers. The parameters should be a map of parameter names to values. The optional instance parameter specifies the iRODS instance to run the rule on. This is an administrative call, a connection using a rodsadmin is required.

func (*API) GenericQuery added in v0.4.41

func (api *API) GenericQuery(query string) GenericQuery

GenericQuery prepares a genquery2 query

func (*API) GenericQueryColumns added in v0.4.41

func (api *API) GenericQueryColumns(ctx context.Context) ([]string, error)

GenericQueryColumns returns the possible columns

func (*API) GenericQueryRow added in v0.4.42

func (api *API) GenericQueryRow(query string) GenericSingleRowQuery

GenericQuery prepares a genquery2 query

func (*API) GetCollection

func (api *API) GetCollection(ctx context.Context, path string) (*Collection, error)

GetCollection returns a collection for the path

func (*API) GetDataObject

func (api *API) GetDataObject(ctx context.Context, path string) (*DataObject, error)

GetDataObject returns a data object for the path

func (*API) GetRecord added in v0.4.0

func (api *API) GetRecord(ctx context.Context, path string, options ...WalkOption) (Record, error)

GetRecord retrieves a Record for the given path. The Record is a combination of os.FileInfo and iRODS metadata. The metadata is only retrieved if the FetchMetadata or FetchAccess WalkOptions are given.

func (*API) GetResource

func (api *API) GetResource(ctx context.Context, name string) (*Resource, error)

GetResource returns information about a resource, identified by its name

func (*API) GetUser

func (api *API) GetUser(ctx context.Context, name string) (*User, error)

GetUser returns information about a user, identified by its name If a zone needs to be specified, use the username#zone format.

func (*API) Glob added in v0.4.59

func (api *API) Glob(ctx context.Context, root, pattern string, walkFn WalkFunc) error

Glob finds records matching the given glob pattern, and calls the given function for each match. The pattern is matched component-by-component using filepath.Match against directory entries obtained via ListSubCollections and ListDataObjectsInCollection.

If the pattern is absolute, absolute paths are passed to walkFn. If the pattern is relative, the search is within root and relative paths are passed to walkFn. If the function returns an error or SkipAll, the traversal is stopped.

func (*API) ListAccess

func (api *API) ListAccess(ctx context.Context, path string, itemType ObjectType, conditions ...Condition) ([]Access, error)

ListAccess retrieves a list of access permissions for a given data object or collection. The function takes optional conditions to refine the query.

func (*API) ListCollections

func (api *API) ListCollections(ctx context.Context, conditions ...Condition) ([]Collection, error)

ListCollections returns a list of collections satisfying the given conditions

func (*API) ListDataObjects

func (api *API) ListDataObjects(ctx context.Context, conditions ...Condition) ([]DataObject, error)

ListDataObjects returns a list of data objects satisfying the given conditions

func (*API) ListDataObjectsInCollection

func (api *API) ListDataObjectsInCollection(ctx context.Context, collectionPath string) ([]DataObject, error)

ListDataObjectsInCollection returns a list of data objects contained in a collection

func (*API) ListMetadata

func (api *API) ListMetadata(ctx context.Context, name string, itemType ObjectType, conditions ...Condition) ([]Metadata, error)

ListMetadata returns a list of metadata records attached to the given object. The function takes optional conditions to refine the query.

func (*API) ListResources

func (api *API) ListResources(ctx context.Context, conditions ...Condition) ([]Resource, error)

ListResources returns a list of resources satisfying the given conditions

func (*API) ListSubCollections

func (api *API) ListSubCollections(ctx context.Context, collectionPath string) ([]Collection, error)

ListSubCollections returns a list of subcollections of the given collection

func (*API) ListUsers

func (api *API) ListUsers(ctx context.Context, conditions ...Condition) ([]User, error)

ListUsers returns a list of users satisfying the given conditions

func (*API) ModifyAccess

func (api *API) ModifyAccess(ctx context.Context, path, user, accessLevel string, recursive bool) error

ModifyAccess modifies the access level of a data object or collection. For users of federated zones, specify <name>#<zone> as user.

func (*API) ModifyMetadata

func (api *API) ModifyMetadata(ctx context.Context, name string, itemType ObjectType, add, remove []Metadata) error

ModifyMetadata does a bulk update of metadata, removing and adding the given values.

func (*API) ModifyModificationTime added in v0.4.56

func (api *API) ModifyModificationTime(ctx context.Context, path string, t time.Time) error

ModifyModificationTime updates the modification time of a data object or collection. The object must already exist.

func (*API) ModifyReplicaAttribute

func (api *API) ModifyReplicaAttribute(ctx context.Context, path string, replica Replica, key msg.KeyWord, value string) error

ModifyReplicaAttribute repairs an attribute of a data object. It is equivalent to iadmin modrepl. The keyword can be e.g. dataComments, replStatus, dataSize. This is an administrative call, a connection using a rodsadmin is required.

func (*API) OpenDataObject

func (api *API) OpenDataObject(ctx context.Context, path string, mode int) (File, error)

OpenDataObject opens a data object. A target resource can be specified with WithDefaultResource() first if needed. A replica number can be specified with WithReplicaNumber() first if needed. This method blocks an irods connection until the file has been closed. If the context is canceled, Seek, Read, Write, Truncate, Touch and Reopen will fail.

func (*API) Procs added in v0.4.36

func (api *API) Procs(ctx context.Context) *Result

Procs returns a list of processes with columns ICAT_COLUMN_PROCESS_ID, ICAT_COLUMN_STARTTIME, ICAT_COLUMN_PROXY_NAME, ICAT_COLUMN_PROXY_ZONE, ICAT_COLUMN_CLIENT_NAME, ICAT_COLUMN_CLIENT_ZONE, ICAT_COLUMN_REMOTE_ADDR, ICAT_COLUMN_SERVER_ADDR, ICAT_COLUMN_PROG_NAME.

func (*API) Query

func (api *API) Query(columns ...Column) PreparedQuery

Query prepares a query to read from the irods catalog, with the specified columns and their aggregation levels.

func (*API) QueryRow

func (api *API) QueryRow(columns ...Column) PreparedSingleRowQuery

QueryRow prepares a query to read a single row from the irods catalog, with the specified columns and their aggregation levels.

func (*API) RegisterReplica

func (api *API) RegisterReplica(ctx context.Context, path, resource, physicalPath string) error

RegisterReplica registers a replica of a data object. This is an administrative call, a connection using a rodsadmin is required.

func (*API) RemoveGroup

func (api *API) RemoveGroup(ctx context.Context, groupname string) error

RemoveGroup removes a group. If a zone needs to be specified, use the groupname#zone format. This is an administrative call, a connection using a rodsadmin is required.

func (*API) RemoveGroupMember

func (api *API) RemoveGroupMember(ctx context.Context, groupname, username string) error

RemoveGroupMember removes a user from a group. If a zone needs to be specified, use the username#zone format. This is an administrative call, a connection using a rodsadmin is required.

func (*API) RemoveMetadata

func (api *API) RemoveMetadata(ctx context.Context, name string, itemType ObjectType, value Metadata) error

RemoveMetadata removes a single metadata value of a data object, collection, user or resource.

func (*API) RemoveUser

func (api *API) RemoveUser(ctx context.Context, username string) error

RemoveUser removes a user or a group. If a zone needs to be specified, use the username#zone format. This is an administrative call, a connection using a rodsadmin is required.

func (*API) RenameCollection

func (api *API) RenameCollection(ctx context.Context, oldName, newName string) error

RenameCollection renames a collection. It will fail if the target already exists.

func (*API) RenameDataObject

func (api *API) RenameDataObject(ctx context.Context, oldPath, newPath string) error

RenameDataObject renames a data object. It will fail if the target already exists.

func (*API) ReplicateDataObject

func (api *API) ReplicateDataObject(ctx context.Context, path, resource string) error

ReplicateDataObject replicates a data object to the specified resource.

func (*API) Request

func (api *API) Request(ctx context.Context, apiNumber msg.APINumber, request, response any) error

Request is a wrapper function for using api.Connect to obtain a connection, use conn.Request on the connection, and Close the connection.

func (*API) RequestWithBuffers

func (api *API) RequestWithBuffers(ctx context.Context, apiNumber msg.APINumber, request, response any, requestBuf, responseBuf []byte) error

RequestWithBuffers is a wrapper function for using api.Connect to obtain a connection, use conn.RequestWithBuffers on the connection, and Close the connection.

func (*API) SetCollectionInheritance

func (api *API) SetCollectionInheritance(ctx context.Context, path string, inherit, recursive bool) error

SetCollectionInheritance sets the inheritance of a collection.

func (*API) SetGroupQuota

func (api *API) SetGroupQuota(ctx context.Context, groupname, resource, value string) error

SetGroupQuota sets quota for a given group and resource ('total' for global) If a zone needs to be specified, use the groupname#zone format. This is an administrative call, a connection using a rodsadmin is required.

func (*API) SetMetadata

func (api *API) SetMetadata(ctx context.Context, name string, itemType ObjectType, value Metadata) error

SetMetadata add a single metadata value for the given key and removes old metadata values with the same key.

func (*API) SetUserQuota

func (api *API) SetUserQuota(ctx context.Context, username, resource, value string) error

SetUserQuota sets quota for a given user and resource ('total' for global) If a zone needs to be specified, use the username#zone format. This is an administrative call, a connection using a rodsadmin is required.

func (*API) StatPhysicalReplica

func (api *API) StatPhysicalReplica(ctx context.Context, path string, replica Replica) (*msg.FileStatResponse, error)

StatPhysicalReplica executes a system stat on the physical replica file. This is an administrative call, a connection using a rodsadmin is required.

func (*API) TrimDataObject

func (api *API) TrimDataObject(ctx context.Context, path, resource string) error

TrimDataObject removes a data object from the specified resource.

func (*API) TrimDataObjectReplica

func (api *API) TrimDataObjectReplica(ctx context.Context, path string, replicaNumber int) error

TrimDataObjectReplica removes a specific replica of a data object.

func (*API) VerifyChecksum added in v0.4.56

func (api *API) VerifyChecksum(ctx context.Context, path string) error

VerifyChecksum verifies the checksum of a data object against the checksum stored in the database. If no checksum is present, an error is returned. A target resource can be specified with WithDefaultResource() first if needed. A replica number can be specified with WithReplicaNumber() first if needed.

func (*API) Walk

func (api *API) Walk(ctx context.Context, path string, walkFn WalkFunc, opts ...WalkOption) error

Walk traverses the iRODS hierarchy rooted at the given path, calling the given function for each encountered file or directory. The function is called with the path relative to the root of the traversal, the corresponding Record, and any error encountered while walking. If the function returns an error or SkipAll, the traversal is stopped. If the function returns SkipDir for a collection, the children of the collection are not visited. If the function returns SkipSubDirs for a collection, the children of subcollections are not visited, but the subcollections are visited as apparent being empty. This avoids querying all children of the subcollections; otherwise the walk function on a collection is called after retrieving all children in memory. The order in which the collections are visited is not specified in general. The only guarantees are that parent collections are visited before their children.

func (API) WithDefaultResource

func (api API) WithDefaultResource(resource string) *API

WithDefaultResource returns a new API with the default resource set

func (API) WithNumThreads

func (api API) WithNumThreads(n int) *API

WithNumThreads returns a new API with the number of threads set

func (API) WithReplicaNumber added in v0.3.3

func (api API) WithReplicaNumber(n int) *API

WithReplicaNumber returns a new API with the replica number set

type Access

type Access struct {
	User       User
	Permission string
}

type Attributes

type Attributes struct {
	User     *User
	Metadata []Metadata
	Access   []struct {
		UserID     int64
		Permission string
	}
	CollectionSize int64
}

type Collection

type Collection struct {
	ID          int64
	Path        string // Path has an absolute path to the collection
	Owner       string
	OwnerZone   string
	CreatedAt   time.Time
	ModifiedAt  time.Time
	Inheritance bool
}

func (*Collection) Identifier

func (c *Collection) Identifier() int64

func (*Collection) IsDir

func (c *Collection) IsDir() bool

func (*Collection) ModTime

func (c *Collection) ModTime() time.Time

func (*Collection) Mode

func (c *Collection) Mode() os.FileMode

func (*Collection) Name

func (c *Collection) Name() string

func (*Collection) ObjectType

func (c *Collection) ObjectType() ObjectType

func (*Collection) Size

func (c *Collection) Size() int64

func (*Collection) Sys

func (c *Collection) Sys() any

type Column added in v0.4.59

type Column interface {
	Int() int
	AggregationLevel() int
}

func Avg added in v0.4.59

func Avg(column msg.ColumnNumber) Column

func Count added in v0.4.59

func Count(column msg.ColumnNumber) Column

func Max added in v0.4.59

func Max(column msg.ColumnNumber) Column

func Min added in v0.4.59

func Min(column msg.ColumnNumber) Column

func Sum added in v0.4.59

func Sum(column msg.ColumnNumber) Column

type Condition

type Condition struct {
	Column msg.ColumnNumber
	Op     string
	Value  string
}

Condition defines a condition

func Equal

func Equal[V string | int | int64](column msg.ColumnNumber, value V) Condition

Equal creates a Condition that checks if the specified column is equal to the given value.

func In

func In[V string | int | int64](column msg.ColumnNumber, values []V) Condition

In creates a Condition that checks if the specified column is in the given list of values. Note that it is not safe to use this method if one of the values contains a ' character, and at least two values are provided.

func Like

func Like(column msg.ColumnNumber, value string) Condition

Like creates a Condition that checks if the specified column matches the given SQL LIKE expression.

func NotEqual

func NotEqual[V string | int | int64](column msg.ColumnNumber, value V) Condition

NotEqual creates a Condition that checks if the specified column is equal to the given value.

type Conn

type Conn interface {
	// ClientSignature returns the client signature
	ClientSignature() string

	// NativePassword returns the native password
	// In case of PAM authentication, this is the generated password
	NativePassword() string

	// Request sends an API request for the given API number and expects a response.
	// Both request and response should represent a type such as in `msg/types.go`.
	// The request and response will be marshaled and unmarshaled automatically.
	// If a negative IntInfo is returned, an appropriate error will be returned.
	Request(ctx context.Context, apiNumber msg.APINumber, request, response any) error

	// RequestWithBuffers behaves as Request, with provided buffers for the request
	// and response binary data. Both requestBuf and responseBuf could be nil.
	RequestWithBuffers(ctx context.Context, apiNumber msg.APINumber, request, response any, requestBuf, responseBuf []byte) error

	// Close closes the connection or releases it back to the pool.
	Close() error

	// RegisterCloseHandler registers a function to be called when the connection is
	// about to closed. It is used to ensure opened files are closed.
	RegisterCloseHandler(handler func() error) context.CancelFunc
}

Conn is a limited interface to an iRODS connection to avoid dependency cycles. Use iron.Conn instead.

type DataObject

type DataObject struct {
	ID           int64
	CollectionID int64
	Path         string
	DataType     string
	Replicas     []Replica
}

func (*DataObject) Identifier

func (d *DataObject) Identifier() int64

func (*DataObject) IsDir

func (d *DataObject) IsDir() bool

func (*DataObject) ModTime

func (d *DataObject) ModTime() time.Time

func (*DataObject) Mode

func (d *DataObject) Mode() os.FileMode

func (*DataObject) Name

func (d *DataObject) Name() string

func (*DataObject) ObjectType

func (d *DataObject) ObjectType() ObjectType

func (*DataObject) Size

func (d *DataObject) Size() int64

func (*DataObject) Sys

func (d *DataObject) Sys() any

type Dialog added in v0.3.11

type Dialog struct {
	msg.APINumber
	Request, Response       any
	RequestBuf, ResponseBuf []byte
}

type File

type File interface {
	// Name returns the name of the file as passed to OpenDataObject or CreateDataObject.
	Name() string

	// Close closes the file.
	// If the file was reopened, Close() will block until the additional handles are closed.
	Close() error

	// CloseReturnConnection closes the file and returns the connection used by the file.
	// The connection itself is not closed and should be closed by the caller.
	// The connection is returned regardless of whether an error occurs during closing the file.
	CloseReturnConnection() (Conn, error)

	// Size returns the size of the file
	Size() (int64, error)

	// Seek moves file pointer of a data object, returns offset
	Seek(offset int64, whence int) (int64, error)

	// Read reads data from the file
	Read(b []byte) (int, error)

	// Write writes data to the file
	Write(b []byte) (int, error)

	// Truncate truncates the file
	// In our implementation, the file seems to be truncated in further read/write operations
	// on this handle or on reopened handles, but the file is not truncated on the server
	// until Close() is called.
	// Truncate requires retrieving file descriptor information, and this does not support
	// the admin keyword.
	Truncate(size int64) error

	// Touch changes the modification time of the file
	// A zero value for mtime means the current time. The file is not touched on the server
	// until Close() is called.
	// Touch does not support the admin keyword.
	Touch(mtime time.Time) error

	// Reopen reopens the file using another connection.
	// When called using iron.Client, nil can be passed instead of a connection,
	// and another connection from the pool will be used and blocked until the
	// file is closed. When called using iron.Conn directly, the caller is
	// responsible for providing a valid connection.
	// Reopen takes ownership of the connection, and closes it when done,
	// also if an error is returned.
	// A reopened file must be closed before the original handle is closed.
	Reopen(conn Conn, mode int) (File, error)
}

type GenericQuery added in v0.4.41

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

func (GenericQuery) Execute added in v0.4.41

func (gq GenericQuery) Execute(ctx context.Context) *GenericResult

func (GenericQuery) SQL added in v0.4.41

func (gq GenericQuery) SQL(ctx context.Context) (string, error)

type GenericResult added in v0.4.41

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

func (*GenericResult) Close added in v0.4.41

func (gr *GenericResult) Close() error

func (*GenericResult) Err added in v0.4.41

func (gr *GenericResult) Err() error

func (*GenericResult) Next added in v0.4.41

func (gr *GenericResult) Next() bool

func (*GenericResult) Rows added in v0.4.56

func (gr *GenericResult) Rows() [][]string

func (*GenericResult) Scan added in v0.4.41

func (gr *GenericResult) Scan(dest ...any) error

type GenericSingleRowQuery added in v0.4.42

type GenericSingleRowQuery GenericQuery

func (GenericSingleRowQuery) Execute added in v0.4.42

func (GenericSingleRowQuery) SQL added in v0.4.42

type GenericSingleRowResult added in v0.4.42

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

func (*GenericSingleRowResult) Err added in v0.4.56

func (grr *GenericSingleRowResult) Err() error

func (*GenericSingleRowResult) Row added in v0.4.56

func (grr *GenericSingleRowResult) Row() []string

func (*GenericSingleRowResult) Scan added in v0.4.42

func (grr *GenericSingleRowResult) Scan(dest ...any) error

type Metadata

type Metadata struct {
	Name  string
	Value string
	Units string
}

type MockConn added in v0.3.11

type MockConn struct {
	Dialog []Dialog
}

func (*MockConn) Add added in v0.3.11

func (c *MockConn) Add(apiNumber msg.APINumber, request, response any)

func (*MockConn) AddBuffer added in v0.3.11

func (c *MockConn) AddBuffer(apiNumber msg.APINumber, request, response any, requestBuf, responseBuf []byte)

func (*MockConn) AddResponse added in v0.3.11

func (c *MockConn) AddResponse(response any)

func (*MockConn) AddResponses added in v0.3.11

func (c *MockConn) AddResponses(responses []any)

func (*MockConn) ClientSignature added in v0.3.11

func (c *MockConn) ClientSignature() string

func (*MockConn) Close added in v0.3.11

func (c *MockConn) Close() error

func (*MockConn) NativePassword added in v0.3.11

func (c *MockConn) NativePassword() string

func (*MockConn) RegisterCloseHandler added in v0.3.11

func (c *MockConn) RegisterCloseHandler(handler func() error) context.CancelFunc

func (*MockConn) Request added in v0.3.11

func (c *MockConn) Request(ctx context.Context, apiNumber msg.APINumber, request, response any) error

func (*MockConn) RequestWithBuffers added in v0.3.11

func (c *MockConn) RequestWithBuffers(ctx context.Context, apiNumber msg.APINumber, request, response any, requestBuf, responseBuf []byte) error

type Object

type Object interface {
	Identifier() int64
	ObjectType() ObjectType
}

type ObjectType

type ObjectType string
const (
	UserType       ObjectType = "u"
	CollectionType ObjectType = "C"
	DataObjectType ObjectType = "d"
	ResourceType   ObjectType = "R"
)

func (ObjectType) String

func (o ObjectType) String() string

type PreparedQuery

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

Query defines a query

func (PreparedQuery) Execute

func (q PreparedQuery) Execute(ctx context.Context) *Result

Execute executes the query. This method blocks an irods connection until the result has been closed. If the context is closed, no more results will be returned.

func (PreparedQuery) Limit

func (q PreparedQuery) Limit(limit int) PreparedQuery

Limit limits the number of results.

func (PreparedQuery) Where

func (q PreparedQuery) Where(column msg.ColumnNumber, condition string) PreparedQuery

Where adds a condition to the query for the specified column. The condition is a string that will be used to filter results based on the specified column.

func (PreparedQuery) With

func (q PreparedQuery) With(condition ...Condition) PreparedQuery

With adds a list of conditions to the query.

type PreparedSingleRowQuery

type PreparedSingleRowQuery PreparedQuery

func (PreparedSingleRowQuery) Execute

Execute executes the query.

func (PreparedSingleRowQuery) Where

Where adds a condition to the query for the specified column. The condition is a string that will be used to filter results based on the specified column.

func (PreparedSingleRowQuery) With

With adds a list of conditions to the query.

type QueryResult added in v0.4.41

type QueryResult interface {
	Err() error
	Next() bool
	Scan(dest ...any) error
	Close() error
}

type Record

type Record interface {
	os.FileInfo
	Metadata() []Metadata
	Access() []Access
	Type() ObjectType
}

type Replica

type Replica struct {
	Number            int
	Owner             string
	OwnerZone         string
	Checksum          string
	Status            string
	Size              int64
	ResourceName      string
	PhysicalPath      string
	ResourceHierarchy string
	CreatedAt         time.Time
	ModifiedAt        time.Time
}

type ReplicaAccessInfo

type ReplicaAccessInfo struct {
	ReplicaNumber     int
	ReplicaToken      string
	ResourceHierarchy string
}

type Resource

type Resource struct {
	ID         int64
	ParentID   int64
	Name       string
	Zone       string
	Type       string
	Class      string
	Location   string
	Path       string
	Context    string
	CreatedAt  time.Time
	ModifiedAt time.Time
}

func (*Resource) Identifier

func (r *Resource) Identifier() int64

func (*Resource) ObjectType

func (r *Resource) ObjectType() ObjectType

type Result

type Result struct {
	Conn    Conn
	Context context.Context //nolint:containedctx
	Query   PreparedQuery
	// contains filtered or unexported fields
}

func (*Result) Close

func (r *Result) Close() error

Close releases all resources associated with the result. It's safe to call Close multiple times.

func (*Result) Columns added in v0.4.36

func (r *Result) Columns() []msg.ColumnNumber

func (*Result) Err

func (r *Result) Err() error

Err returns an error if the result has one.

func (*Result) Next

func (r *Result) Next() bool

Next returns true if there are more results.

func (*Result) Scan

func (r *Result) Scan(dest ...any) error

Scan reads the values in the current row into the values pointed to by dest, in order. If an error occurs during scanning, the error is returned. The values pointed to by dest before the error occurred might be modified.

type SingleRowResult

type SingleRowResult struct {
	Query PreparedSingleRowQuery
	// contains filtered or unexported fields
}

func (*SingleRowResult) Scan

func (r *SingleRowResult) Scan(dest ...any) error

Scan reads the values in the current row into the values pointed to by dest, in order. If an error occurs during scanning, the error is returned. The values pointed to by dest before the error occurred might be modified. If no rows are found, ErrNoRowFound is returned.

type User

type User struct {
	ID         int64
	Name       string
	Zone       string
	Type       string
	CreatedAt  time.Time
	ModifiedAt time.Time
}

func (*User) Identifier

func (u *User) Identifier() int64

func (*User) ObjectType

func (u *User) ObjectType() ObjectType

type WalkFunc

type WalkFunc func(path string, record Record, err error) error

type WalkOption

type WalkOption int
const (
	// FetchAccess prefetches ACL information for all records. If not given,
	// the Access() method will be empty on all records.
	FetchAccess WalkOption = 1 << iota

	// FetchMetadata prefetches metadata for all records. If not given,
	// the Metadata() method will be empty on all records.
	FetchMetadata

	// If the option LexographicalOrder is given, the order is guaranteed to be
	// lexographical, but the irods queries will be significantly more expensive,
	// unless the option NoSkip is also given.
	LexographicalOrder

	// If the option NoSkip is given, the walk function may not return SkipSubDirs
	// or SkipDir, but it may return SkipAll. This is useful in combination with
	// LexographicalOrder to speed up the irods queries.
	NoSkip

	// If the option BreadthFirst is given, a single level of collections is handled
	// first, before moving to the next level: collections at level N are handled first,
	// followed by data objects at level N+1, collections at level N+1 for which children
	// are skipped (see SkipSubDirs option) and finally collections at level N + 1.
	// Note that this option caches at level N, a list of subcollections of level N + 1,
	// this might require a significant amount of memory for large collections.
	BreadthFirst

	// If the option FetchCollectionSize is given, Size() will be populated
	// for collections.
	FetchCollectionSize
)

Jump to

Keyboard shortcuts

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