Documentation
¶
Index ¶
- Constants
- Variables
- func ComparePaths(a, b string) int
- func ErrorCode(err error) (msg.ErrorCode, bool)
- func Is(err error, code msg.ErrorCode) bool
- func ParseIrodsChecksum(checksum string) ([]byte, error)
- func Split(path string) (string, string)
- type API
- func (api *API) AddGroupMember(ctx context.Context, groupname, username string) error
- func (api *API) AddMetadata(ctx context.Context, name string, itemType ObjectType, value Metadata) error
- func (api API) AsAdmin() *API
- func (api *API) ChangeUserPassword(ctx context.Context, username, password string) error
- func (api *API) ChangeUserType(ctx context.Context, username, userType string) error
- func (api *API) Checksum(ctx context.Context, path string, force bool) ([]byte, error)
- func (api *API) CopyDataObject(ctx context.Context, oldPath, newPath string) error
- func (api *API) CopyMetadata(ctx context.Context, oldName string, oldItemType ObjectType, newName string, ...) error
- func (api *API) CreateCollection(ctx context.Context, name string) error
- func (api *API) CreateCollectionAll(ctx context.Context, name string) error
- func (api *API) CreateDataObject(ctx context.Context, path string, mode int) (File, error)
- func (api *API) CreateGroup(ctx context.Context, groupname string) error
- func (api *API) CreateUser(ctx context.Context, username, userType string) error
- func (api *API) DeleteCollection(ctx context.Context, name string, skipTrash bool) error
- func (api *API) DeleteCollectionAll(ctx context.Context, name string, skipTrash bool) error
- func (api *API) DeleteDataObject(ctx context.Context, path string, skipTrash bool) error
- func (api *API) ElevateRequest(ctx context.Context, apiNumber msg.APINumber, request, response any, ...) error
- func (api *API) ExecuteExternalRule(ctx context.Context, rule string, params map[string]string, instance string) (map[string]string, error)
- func (api *API) GenericQuery(query string) GenericQuery
- func (api *API) GenericQueryColumns(ctx context.Context) ([]string, error)
- func (api *API) GenericQueryRow(query string) GenericSingleRowQuery
- func (api *API) GetCollection(ctx context.Context, path string) (*Collection, error)
- func (api *API) GetDataObject(ctx context.Context, path string) (*DataObject, error)
- func (api *API) GetRecord(ctx context.Context, path string, options ...WalkOption) (Record, error)
- func (api *API) GetResource(ctx context.Context, name string) (*Resource, error)
- func (api *API) GetUser(ctx context.Context, name string) (*User, error)
- func (api *API) Glob(ctx context.Context, root, pattern string, walkFn WalkFunc) error
- func (api *API) ListAccess(ctx context.Context, path string, itemType ObjectType, conditions ...Condition) ([]Access, error)
- func (api *API) ListCollections(ctx context.Context, conditions ...Condition) ([]Collection, error)
- func (api *API) ListDataObjects(ctx context.Context, conditions ...Condition) ([]DataObject, error)
- func (api *API) ListDataObjectsInCollection(ctx context.Context, collectionPath string) ([]DataObject, error)
- func (api *API) ListMetadata(ctx context.Context, name string, itemType ObjectType, conditions ...Condition) ([]Metadata, error)
- func (api *API) ListResources(ctx context.Context, conditions ...Condition) ([]Resource, error)
- func (api *API) ListSubCollections(ctx context.Context, collectionPath string) ([]Collection, error)
- func (api *API) ListUsers(ctx context.Context, conditions ...Condition) ([]User, error)
- func (api *API) ModifyAccess(ctx context.Context, path, user, accessLevel string, recursive bool) error
- func (api *API) ModifyMetadata(ctx context.Context, name string, itemType ObjectType, add, remove []Metadata) error
- func (api *API) ModifyModificationTime(ctx context.Context, path string, t time.Time) error
- func (api *API) ModifyReplicaAttribute(ctx context.Context, path string, replica Replica, key msg.KeyWord, ...) error
- func (api *API) OpenDataObject(ctx context.Context, path string, mode int) (File, error)
- func (api *API) Procs(ctx context.Context) *Result
- func (api *API) Query(columns ...Column) PreparedQuery
- func (api *API) QueryRow(columns ...Column) PreparedSingleRowQuery
- func (api *API) RegisterReplica(ctx context.Context, path, resource, physicalPath string) error
- func (api *API) RemoveGroup(ctx context.Context, groupname string) error
- func (api *API) RemoveGroupMember(ctx context.Context, groupname, username string) error
- func (api *API) RemoveMetadata(ctx context.Context, name string, itemType ObjectType, value Metadata) error
- func (api *API) RemoveUser(ctx context.Context, username string) error
- func (api *API) RenameCollection(ctx context.Context, oldName, newName string) error
- func (api *API) RenameDataObject(ctx context.Context, oldPath, newPath string) error
- func (api *API) ReplicateDataObject(ctx context.Context, path, resource string) error
- func (api *API) Request(ctx context.Context, apiNumber msg.APINumber, request, response any) error
- func (api *API) RequestWithBuffers(ctx context.Context, apiNumber msg.APINumber, request, response any, ...) error
- func (api *API) SetCollectionInheritance(ctx context.Context, path string, inherit, recursive bool) error
- func (api *API) SetGroupQuota(ctx context.Context, groupname, resource, value string) error
- func (api *API) SetMetadata(ctx context.Context, name string, itemType ObjectType, value Metadata) error
- func (api *API) SetUserQuota(ctx context.Context, username, resource, value string) error
- func (api *API) StatPhysicalReplica(ctx context.Context, path string, replica Replica) (*msg.FileStatResponse, error)
- func (api *API) TrimDataObject(ctx context.Context, path, resource string) error
- func (api *API) TrimDataObjectReplica(ctx context.Context, path string, replicaNumber int) error
- func (api *API) VerifyChecksum(ctx context.Context, path string) error
- func (api *API) Walk(ctx context.Context, path string, walkFn WalkFunc, opts ...WalkOption) error
- func (api API) WithDefaultResource(resource string) *API
- func (api API) WithNumThreads(n int) *API
- func (api API) WithReplicaNumber(n int) *API
- type Access
- type Attributes
- type Collection
- type Column
- type Condition
- type Conn
- type DataObject
- type Dialog
- type File
- type GenericQuery
- type GenericResult
- type GenericSingleRowQuery
- type GenericSingleRowResult
- type Metadata
- type MockConn
- func (c *MockConn) Add(apiNumber msg.APINumber, request, response any)
- func (c *MockConn) AddBuffer(apiNumber msg.APINumber, request, response any, requestBuf, responseBuf []byte)
- func (c *MockConn) AddResponse(response any)
- func (c *MockConn) AddResponses(responses []any)
- func (c *MockConn) ClientSignature() string
- func (c *MockConn) Close() error
- func (c *MockConn) NativePassword() string
- func (c *MockConn) RegisterCloseHandler(handler func() error) context.CancelFunc
- func (c *MockConn) Request(ctx context.Context, apiNumber msg.APINumber, request, response any) error
- func (c *MockConn) RequestWithBuffers(ctx context.Context, apiNumber msg.APINumber, request, response any, ...) error
- type Object
- type ObjectType
- type PreparedQuery
- type PreparedSingleRowQuery
- type QueryResult
- type Record
- type Replica
- type ReplicaAccessInfo
- type Resource
- type Result
- type SingleRowResult
- type User
- type WalkFunc
- type WalkOption
Constants ¶
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 ¶
var ( SkipAll = filepath.SkipAll //nolint:errname SkipDir = filepath.SkipDir //nolint:errname SkipSubDirs = errors.New("skip children of subdirectories of this directory") //nolint:staticcheck,errname )
var ErrAttributeIndexMismatch = fmt.Errorf("attribute index mismatch")
var ErrAttributeOutOfBound = fmt.Errorf("attribute count out of bound")
var ErrCannotTruncate = errors.New("cannot truncate in reopened handle")
var ErrChecksumNotFound = errors.New("checksum not found")
var ErrIncompleteReplicaAccessInfo = errors.New("incomplete replica access info")
var ErrInvalidItemType = errors.New("invalid item type")
var ErrInvalidSize = errors.New("invalid size")
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.
var ErrNoSQLResults = fmt.Errorf("no sql results")
var ErrRequiresAdmin = errors.New("this API call requires api.Admin = true")
var ErrRowOutOfBound = fmt.Errorf("row out of bound")
var ErrSameConnection = errors.New("same connection")
var ErrSkipNotAllowed = errors.New("skip not allowed")
Functions ¶
func ComparePaths ¶ added in v0.4.56
func ParseIrodsChecksum ¶ added in v0.4.56
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 ¶
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) ChangeUserPassword ¶
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 ¶
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
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 ¶
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 ¶
CreateCollection creates a collection. If the collection already exists, an error is returned.
func (*API) CreateCollectionAll ¶
CreateCollectionAll creates a collection and its parents recursively. If the collection already exists, nothing happens.
func (*API) CreateDataObject ¶
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 ¶
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 ¶
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 ¶
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 ¶
DeleteCollectionAll deletes a collection and its children recursively. If force is true, the collection is not moved to the trash.
func (*API) DeleteDataObject ¶
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
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 ¶
GetCollection returns a collection for the path
func (*API) GetDataObject ¶
GetDataObject returns a data object for the path
func (*API) GetRecord ¶ added in v0.4.0
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 ¶
GetResource returns information about a resource, identified by its name
func (*API) GetUser ¶
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
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 ¶
ListCollections returns a list of collections satisfying the given conditions
func (*API) ListDataObjects ¶
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 ¶
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) 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
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 ¶
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
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 ¶
RegisterReplica registers a replica of a data object. This is an administrative call, a connection using a rodsadmin is required.
func (*API) RemoveGroup ¶
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 ¶
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 ¶
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 ¶
RenameCollection renames a collection. It will fail if the target already exists.
func (*API) RenameDataObject ¶
RenameDataObject renames a data object. It will fail if the target already exists.
func (*API) ReplicateDataObject ¶
ReplicateDataObject replicates a data object to the specified resource.
func (*API) Request ¶
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 ¶
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 ¶
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 ¶
TrimDataObject removes a data object from the specified resource.
func (*API) TrimDataObjectReplica ¶
TrimDataObjectReplica removes a specific replica of a data object.
func (*API) VerifyChecksum ¶ added in v0.4.56
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 ¶
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 ¶
WithDefaultResource returns a new API with the default resource set
func (API) WithNumThreads ¶
WithNumThreads returns a new API with the number of threads set
func (API) WithReplicaNumber ¶ added in v0.3.3
WithReplicaNumber returns a new API with the replica number set
type Attributes ¶
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
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 ¶
Equal creates a Condition that checks if the specified column is equal to the given value.
func In ¶
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.
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 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
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 (gqr GenericSingleRowQuery) Execute(ctx context.Context) *GenericSingleRowResult
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 MockConn ¶ added in v0.3.11
type MockConn struct {
Dialog []Dialog
}
func (*MockConn) AddResponse ¶ added in v0.3.11
func (*MockConn) AddResponses ¶ added in v0.3.11
func (*MockConn) ClientSignature ¶ added in v0.3.11
func (*MockConn) NativePassword ¶ added in v0.3.11
func (*MockConn) RegisterCloseHandler ¶ added in v0.3.11
func (c *MockConn) RegisterCloseHandler(handler func() error) context.CancelFunc
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 ¶
func (r PreparedSingleRowQuery) Execute(ctx context.Context) *SingleRowResult
Execute executes the query.
func (PreparedSingleRowQuery) Where ¶
func (r PreparedSingleRowQuery) Where(column msg.ColumnNumber, condition string) PreparedSingleRowQuery
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 ¶
func (r PreparedSingleRowQuery) With(condition ...Condition) PreparedSingleRowQuery
With adds a list of conditions to the query.
type QueryResult ¶ added in v0.4.41
type Record ¶
type Record interface {
os.FileInfo
Metadata() []Metadata
Access() []Access
Type() ObjectType
}
type ReplicaAccessInfo ¶
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 (*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 ¶
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
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 (*User) ObjectType ¶
func (u *User) ObjectType() ObjectType
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 )