gorods

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2018 License: BSD-3-Clause Imports: 21 Imported by: 1

README

GoRODS

Golang binding for iRODS C API. Compatible with golang version >= 1.5

GoDoc

Installation

Install GoRODS (assuming GOPATH is setup)

$ export CGO_LDFLAGS_ALLOW=.*
$ go get github.com/jjacquay712/GoRODS 
Run Tests In Docker Container

Clone repository and run:

$ docker build -t gorods .
$ docker run -it gorods -irods.host=192.168.1.147 -irods.username=rods -irods.password=mypassword
Docs

iRODS client binding

iRODS microservice binding

Usage Guide and Examples

iRODS client binding

iRODS microservice binding

Basic Usage

package main

import (
	"fmt"
	"log"
	"github.com/jjacquay712/GoRODS"
)

func main() {
	
	client, conErr := gorods.New(gorods.ConnectionOptions{
		Type: gorods.UserDefined,

		Host: "localhost",
		Port: 1247,
		Zone: "tempZone",

		Username: "rods",
		Password: "password",
	})

	// Ensure the client initialized successfully and connected to the iCAT server
	if conErr != nil {
		log.Fatal(conErr)
	}


	// Open a collection reference for /tempZone/home/rods
	if openErr := client.OpenCollection(gorods.CollectionOptions{
		Path: "/tempZone/home/rods",
	}, func(col *gorods.Collection, con *gorods.Connection) {

		// Output collection's string representation
		fmt.Printf("String(): %v \n", col)

		// Loop over the data objects in the collection, print the file name
		col.EachDataObj(func(obj *gorods.DataObj) {
			fmt.Printf("%v \n", obj.Name())
		})

		// Loop over the subcollections in the collection, print the name
		col.EachCollection(func(subcol *gorods.Collection) {
			fmt.Printf("%v \n", subcol.Name())
		})

	}); openErr != nil {
		log.Fatal(openErr)
	}

}

Output:

CLI GoRODS Output

iRODS HTTP Mount


package main

import (
	"github.com/jjacquay712/GoRODS"
	"log"
	"net/http"
)

func main() {

	client, conErr := gorods.New(gorods.ConnectionOptions{
		Type: gorods.UserDefined,

		Host: "localhost",
		Port: 1247,
		Zone: "tempZone",

		Username: "rods",
		Password: "password",
	})

	// Ensure the client initialized successfully and connected to the iCAT server
	if conErr != nil {
		log.Fatal(conErr)
	}

	mountPath := "/irods/"

	// Setup the GoRODS FileServer
	fs := gorods.FileServer(gorods.FSOptions{
		Path:   "/tempZone/home/rods",
		Client: client,
		Download: true,
		StripPrefix: mountPath,
	})

	// Create the URL router
	mux := http.NewServeMux()

	// Serve the iRODS collection at /irods/
	mux.Handle(mountPath, http.StripPrefix(mountPath, fs))

	// Start HTTP server on port 8080
	log.Fatal(http.ListenAndServe(":8080", mux))

}

Output:

HTTP GoRODS Output HTTP GoRODS Output

Contributing

Send me a pull request!

Todo

Code Polish
  • Complete unit tests

Known Issues

Copyright (c) 2016, University of Florida Research Foundation, Inc. and The BioTeam, Inc. All Rights Reserved.

GoRODS is released under a 3-clause BSD License. For more information please refer to the LICENSE.md file

Documentation

Overview

Package gorods is a Golang binding for the iRODS C API (iRODS client library). GoRods uses cgo to call iRODS client functions.

Index

Constants

View Source
const (
	EnvironmentDefined = iota
	UserDefined
)

EnvironmentDefined and UserDefined constants are used when calling gorods.New(ConnectionOptions{ Type: ... }) When EnvironmentDefined is specified, the options stored in ~/.irods/irods_environment.json will be used. When UserDefined is specified you must also pass Host, Port, Username, and Zone. Password should be set regardless.

View Source
const (
	DataObjType = iota
	CollectionType
	ResourceType
	ResourceGroupType
	ZoneType
	UserType
	AdminType
	GroupAdminType
	GroupType
	UnknownType
	Cache
	Archive
	Null
	Read
	Write
	Own
	Inherit
	NoInherit
	Local
	Remote
	PAMAuth
	PasswordAuth
)

Used when calling Type() on different gorods objects

View Source
const (
	Info = iota
	Warn
	Fatal
)

Log level constants

Variables

This section is empty.

Functions

func FileServer added in v0.1.5

func FileServer(opts FSOptions) http.Handler

func GetShortTypeString added in v1.0.5

func GetShortTypeString(typ int) string

func GetTypeString added in v1.0.1

func GetTypeString(typ int) string

Types

type ACL added in v0.1.5

type ACL struct {
	AccessObject AccessObject
	AccessLevel  int
	Type         int
}

ACL is used to describe the access level that a particular AccessObject (User/Group) has on a DataObj or Collection

func (*ACL) AccessLevelString added in v1.0.3

func (acl *ACL) AccessLevelString() string

AccessLevelString gets the string represenation of the AccessLevel

func (*ACL) Group added in v0.1.5

func (acl *ACL) Group() *Group

Group is a shortcut to cast the AccessObject as it's underlying data structure type (*Group)

func (*ACL) String added in v0.1.5

func (acl *ACL) String() string

String returns a formatted string describing the ACL struct example: g:designers#tempZone:read

func (*ACL) User added in v0.1.5

func (acl *ACL) User() *User

User is a shortcut to cast the AccessObject as it's underlying data structure type (*User)

type ACLs added in v0.1.5

type ACLs []*ACL

ACLs is a slice of ACL pointers

type AccessObject added in v0.1.5

type AccessObject interface {
	Name() string
	Zone() *Zone
	Comment() (string, error)
	CreateTime() (time.Time, error)
	ModifyTime() (time.Time, error)
	Id() (int, error)
	Type() int
	Con() *Connection
}

AccessObject is an interface for Users and Groups, used within ACL slices to denote the access level of a DataObj or Collection

type ByteArr added in v0.1.5

type ByteArr struct {
	Contents []byte
	Ptr      unsafe.Pointer
}

func (ByteArr) Free added in v0.1.5

func (br ByteArr) Free()

type Client added in v0.1.5

type Client struct {
	Options    *ConnectionOptions
	ConnectErr error
}

Client structs are used to store connection options, and instatiate connections with those options

func New

func New(opts ConnectionOptions) (*Client, error)

New creates a test connection to an iRODS iCAT server, and returns a *Client struct if successful. EnvironmentDefined and UserDefined constants are used in ConnectionOptions{ Type: ... }). When EnvironmentDefined is specified, the options stored in ~/.irods/irods_environment.json will be used. When UserDefined is specified you must also pass Host, Port, Username, and Zone. Password should be set unless using an anonymous user account with tickets.

func (*Client) DisplayMemInfo added in v0.1.5

func (cli *Client) DisplayMemInfo()

func (*Client) OpenCollection added in v0.1.5

func (cli *Client) OpenCollection(opts CollectionOptions, handler func(*Collection, *Connection)) error

OpenCollection will create a new connection using the previously configured iRODS client. It will execute the handler, and close *Collection and *Collection automatically when your handler finishes execution. Operations on a single connection are queued when shared between goroutines (iRODS C API doesn't support concurrent operations on a single connection), so be sure to open up new connections for long-running operations to prevent blocking between goroutines.

func (*Client) OpenConnection added in v0.1.5

func (cli *Client) OpenConnection(handler func(*Connection)) error

OpenConnection will create a new connection using the previously configured iRODS client. It will execute the handler, and close *Collection automatically when your handler finishes execution. Operations on a single connection are queued when shared between goroutines (iRODS C API doesn't support concurrent operations on a single connection), so be sure to open up new connections for long-running operations to prevent blocking between goroutines.

func (*Client) OpenDataObject added in v0.1.5

func (cli *Client) OpenDataObject(path string, handler func(*DataObj, *Connection)) error

OpenDataObject will create a new connection using the previously configured iRODS client. It will execute the handler, and close *DataObj and *Collection automatically when your handler finishes execution. Operations on a single connection are queued when shared between goroutines (iRODS C API doesn't support concurrent operations on a single connection), so be sure to open up new connections for long-running operations to prevent blocking between goroutines.

type Collection

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

Collection structs contain information about single collections in an iRODS zone.

func CreateCollection added in v0.1.3

func CreateCollection(name string, coll *Collection) (*Collection, error)

CreateCollection creates a collection in the specified collection using provided options. Returns the newly created collection object.

func (*Collection) ACL added in v0.1.5

func (col *Collection) ACL() (ACLs, error)

ACL returns a slice of ACL structs. Example of slice in string format: [rods#tempZone:own developers#tempZone:modify object designers#tempZone:read object]

func (*Collection) AddMeta added in v0.1.1

func (col *Collection) AddMeta(m Meta) (newMeta *Meta, err error)

AddMeta adds a single Meta triple struct

func (*Collection) All

func (col *Collection) All() (IRodsObjs, error)

All returns generic interface slice containing both data objects and collections combined

func (*Collection) Attribute

func (col *Collection) Attribute(attr string) (Metas, error)

Attribute gets slice of Meta AVU triples, matching by Attribute name for Collection

func (*Collection) Backup added in v0.1.5

func (col *Collection) Backup(targetResource interface{}, opts DataObjOptions) error

Backup is similar to Replicate. In backup mode, if a good copy already exists in this resource group or resource, don't make another one.

func (*Collection) Cd

func (col *Collection) Cd(path string) *Collection

Cd is a shortcut for calling collection.GetCollections().Find(path). It effectively returns (or changes to) the sub collection you specify collection-relatively or absolutely.

func (*Collection) Chmod added in v0.1.5

func (col *Collection) Chmod(userOrGroup string, accessLevel int, recursive bool) error

Chmod changes the permissions/ACL of the collection accessLevel: Null | Read | Write | Own

func (*Collection) Close

func (col *Collection) Close() error

Close closes the Collection connection and resets the handle

func (*Collection) Col

func (col *Collection) Col() *Collection

Col returns the *Collection of the collection

func (*Collection) Collections

func (col *Collection) Collections() (response IRodsObjs, err error)

Collections returns only the IRodsObjs that represent collections

func (*Collection) Con

func (col *Collection) Con() *Connection

Connection returns the *Connection used to get collection

func (*Collection) CopyTo added in v0.1.5

func (col *Collection) CopyTo(iRODSCollection interface{}) error

CopyTo copies all collections and data objects contained withing the collection to the specified collection. Accepts string or *Collection types.

func (*Collection) CreateDataObj

func (col *Collection) CreateDataObj(opts DataObjOptions) (*DataObj, error)

CreateDataObj creates a data object within the collection using the options specified

func (*Collection) CreateSubCollection added in v0.1.3

func (col *Collection) CreateSubCollection(name string) (*Collection, error)

CreateSubCollection creates a collection within the collection using the options specified

func (*Collection) CreateTime added in v0.1.4

func (col *Collection) CreateTime() time.Time

CreateTime returns the create time of the collection

func (*Collection) DataObjs

func (col *Collection) DataObjs() (response IRodsObjs, err error)

DataObjs returns only the data objects contained within the collection

func (*Collection) Delete added in v0.1.4

func (col *Collection) Delete(recursive bool) error

Delete is equivalent to irm -f {-r}

func (*Collection) DeleteMeta added in v0.1.1

func (col *Collection) DeleteMeta(attr string) (*MetaCollection, error)

DeleteMeta deletes a single Meta triple struct, identified by Attribute field

func (*Collection) Destroy added in v0.1.4

func (col *Collection) Destroy() error

Destroy is equivalent to irm -rf

func (*Collection) DownloadTo added in v0.1.5

func (col *Collection) DownloadTo(localPath string) error

DownloadTo recursively downloads all data objects and collections contained within the collection, into the path specified

func (*Collection) Each added in v1.0.3

func (col *Collection) Each(ittr func(obj IRodsObj) error) error

EachDataObj is an iterator for data objects

func (*Collection) EachCollection added in v0.1.5

func (col *Collection) EachCollection(ittr func(obj *Collection)) error

EachCollection is an iterator for collections

func (*Collection) EachDataObj added in v0.1.5

func (col *Collection) EachDataObj(ittr func(obj *DataObj)) error

EachDataObj is an iterator for data objects

func (*Collection) Exists

func (col *Collection) Exists(path string) bool

Exists returns true of false depending on whether the DataObj or Collection is found

func (*Collection) Find

func (col *Collection) Find(path string) IRodsObj

Find returns either a DataObject or Collection using the collection-relative or absolute path specified.

func (*Collection) FindCol added in v0.1.1

func (col *Collection) FindCol(path string) *Collection

FindCol returns a sub collection in the *Collection, matching based on the absolute path or name

func (*Collection) FindObj added in v0.1.1

func (col *Collection) FindObj(path string) *DataObj

FindObj returns a data object contained in the *Collection, matching based on the absolute path or name. Equivalent to *Collection.Get.

func (*Collection) FindRecursive added in v0.1.1

func (col *Collection) FindRecursive(path string) IRodsObj

Find returns either a DataObject or Collection using the collection-relative or absolute path specified.

func (*Collection) Get

func (col *Collection) Get(path string) *DataObj

Get is a shortcut for calling collection.DataObjs().Find(path). It effectively returns the DataObj you specify collection-relatively or absolutely.

func (*Collection) GrantAccess added in v0.1.5

func (col *Collection) GrantAccess(userOrGroup AccessObject, accessLevel int, recursive bool) error

GrantAccess will add permissions (ACL) to the collection

func (*Collection) Inheritance added in v0.1.5

func (col *Collection) Inheritance() (bool, error)

Inheritance returns true or false, depending on the collection's inheritance setting

func (*Collection) IsDir added in v1.0.1

func (col *Collection) IsDir() bool

func (*Collection) IsRecursive added in v0.1.1

func (col *Collection) IsRecursive() bool

IsRecursive returns true or false

func (*Collection) Length added in v1.0.2

func (col *Collection) Length() int

Length returns the total number of data objects and collections contained within the collection, recursively

func (*Collection) Meta

func (col *Collection) Meta() (*MetaCollection, error)

Meta returns collection of all metadata AVU triples for Collection

func (*Collection) ModTime added in v1.0.1

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

func (*Collection) Mode added in v1.0.1

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

func (*Collection) ModifyTime added in v0.1.4

func (col *Collection) ModifyTime() time.Time

ModifyTime returns the modify time of the collection

func (*Collection) MoveTo added in v0.1.5

func (col *Collection) MoveTo(iRODSCollection interface{}) error

MoveTo moves the collection to the specified collection. Supports Collection struct or string as input. Also refreshes the source and destination collections automatically to maintain correct state. Returns error.

func (*Collection) MoveToResource added in v0.1.5

func (col *Collection) MoveToResource(targetResource interface{}) error

MoveToResource recursively moves all data objects contained within the collection to the specified resource. Accepts string or *Resource type.

func (*Collection) Name

func (col *Collection) Name() string

Name returns the Name of the collection

func (*Collection) Open

func (col *Collection) Open() error

Open connects to iRODS and sets the handle for Collection. Usually called by Collection.init()

func (*Collection) Owner added in v0.1.5

func (col *Collection) Owner() *User

Owner returns a User struct, representing the user who owns the collection

func (*Collection) OwnerName added in v0.1.4

func (col *Collection) OwnerName() string

OwnerName returns the owner name of the collection

func (*Collection) Path

func (col *Collection) Path() string

Path returns the Path of the collection

func (*Collection) Put

func (col *Collection) Put(localPath string, opts DataObjOptions) (*DataObj, error)

Put reads the entire file from localPath and adds it the collection, using the options specified.

func (*Collection) ReadCollection

func (col *Collection) ReadCollection() error

ReadCollection reads data (overwrites) into col.dataObjects field.

func (*Collection) ReadCollectionOpts added in v1.0.2

func (col *Collection) ReadCollectionOpts(opts CollectionReadOpts) (CollectionReadInfo, error)

func (*Collection) ReadInfo added in v1.0.2

func (col *Collection) ReadInfo() *CollectionReadInfo

func (*Collection) Refresh

func (col *Collection) Refresh() error

Refresh is an alias of ReadCollection()

func (*Collection) Rename added in v0.1.5

func (col *Collection) Rename(newFileName string) error

Rename is equivalent to the Linux mv command except that the collection must stay within it's current collection (directory), returns error.

func (*Collection) Replicate added in v0.1.5

func (col *Collection) Replicate(targetResource interface{}, opts DataObjOptions) error

Replicate recursively copies all data objects contained within the collection to the specified resource. Accepts string or *Resource type for targetResource parameter.

func (*Collection) Rm added in v0.1.4

func (col *Collection) Rm(recursive bool, force bool) error

Rm is equivalent to irm {-r} {-f}

func (*Collection) RmTrash added in v1.0.5

func (col *Collection) RmTrash() error

RmTrash is used (sometimes internally) by GoRODS to delete items in the trash permanently. The collection's path should be in the trash collection.

func (*Collection) SetInheritance added in v0.1.5

func (col *Collection) SetInheritance(inherits bool, recursive bool) error

SetInheritance sets the inheritance option of the collection. If true, sub-collections and data objects inherit the permissions (ACL) of this collection.

func (*Collection) Size added in v0.1.5

func (col *Collection) Size() int64

Size returns the total size in bytes of all contained data objects and collections, recursively

func (*Collection) Stat added in v0.1.5

func (col *Collection) Stat() (map[string]interface{}, error)

Stat returns a map (key/value pairs) of the system meta information. The following keys can be used with the map:

"objSize"

"dataMode"

"dataId"

"chksum"

"ownerName"

"ownerZone"

"createTime"

"modifyTime"

func (*Collection) String

func (obj *Collection) String() string

String shows the contents of the collection.

d = DataObj

C = Collection

Sample output:

Collection: /tempZone/home/admin/gorods
	d: build.sh
	C: bin
	C: pkg
	C: src

func (*Collection) Sys added in v1.0.1

func (col *Collection) Sys() interface{}

func (*Collection) Trash added in v0.1.4

func (col *Collection) Trash(recursive bool) error

Trash is equivalent to irm {-r}

func (*Collection) TrimRepls added in v0.1.5

func (col *Collection) TrimRepls(opts TrimOptions) error

TrimRepls recursively trims data object replicas (removes from resource servers), using the rules defined in opts.

func (*Collection) Type

func (col *Collection) Type() int

Type gets the type

func (*Collection) Walk added in v1.0.1

func (col *Collection) Walk(callback func(IRodsObj) error) error

type CollectionOptions added in v0.1.5

type CollectionOptions struct {
	Path      string
	Recursive bool
	GetRepls  bool
	SkipCache bool
}

CollectionOptions stores options relating to collection initialization. Path is the full path of the collection you're requesting. Recursive if set to true will load sub collections into memory, until the end of the collection "tree" is found.

type CollectionReadInfo added in v1.0.2

type CollectionReadInfo struct {
	ColResultTotal int
	ObjResultTotal int
	ResultTotal    int

	ColTotal int
	ObjTotal int
	Total    int
}

type CollectionReadOpts added in v1.0.2

type CollectionReadOpts struct {
	Limit  int
	Offset int
	Filter func(obj IRodsObj) bool
}

type Connection

type Connection struct {
	PAMToken   string
	Connected  bool
	Init       bool
	Options    *ConnectionOptions
	OpenedObjs IRodsObjs
	// contains filtered or unexported fields
}

Connection structs hold information about the iRODS iCAT server, and the user who's connecting. It also contains a cache of opened Collections and DataObjs

func NewConnection added in v0.1.5

func NewConnection(opts *ConnectionOptions) (*Connection, error)

NewConnection creates a connection to an iRODS iCAT server. EnvironmentDefined and UserDefined constants are used in ConnectionOptions{ Type: ... }). When EnvironmentDefined is specified, the options stored in ~/.irods/irods_environment.json will be used. When UserDefined is specified you must also pass Host, Port, Username, and Zone. Password should be set unless using an anonymous user account with tickets.

func (*Connection) Collection

func (con *Connection) Collection(opts CollectionOptions) (*Collection, error)

Collection initializes and returns an existing iRODS collection using the specified path

func (*Connection) CollectionOpts added in v1.0.2

func (con *Connection) CollectionOpts(opts CollectionOptions, readOpts CollectionReadOpts) (*Collection, error)

CollectionOpts initializes and returns an existing iRODS collection using the specified path

func (*Connection) CreateGroup added in v0.1.5

func (con *Connection) CreateGroup(name string) (*Group, error)

CreateGroup creates a group within the local zone. You must have the proper groupadmin or rodsadmin privileges to use this function.

func (*Connection) CreateUser added in v0.1.5

func (con *Connection) CreateUser(name string, typ int) (*User, error)

CreateUser creates an iRODS user within the local zone. You must have the proper rodsadmin privileges to use this function.

func (*Connection) DataObject added in v0.1.1

func (con *Connection) DataObject(dataObjPath string) (dataobj *DataObj, err error)

DataObject directly returns a specific DataObj without the need to traverse collections. Must pass full path of data object.

func (*Connection) Disconnect

func (con *Connection) Disconnect() error

Disconnect closes connection to iRODS iCAT server, returns error on failure or nil on success

func (*Connection) EmptyTrash added in v1.0.5

func (con *Connection) EmptyTrash() error

EmptyTrash

func (*Connection) FetchGroups added in v0.1.5

func (con *Connection) FetchGroups() (Groups, error)

FetchGroups returns a slice of *Group, fresh from the iCAT server.

func (*Connection) FetchResources added in v0.1.5

func (con *Connection) FetchResources() (Resources, error)

FetchResources returns a slice of *Resource, fresh from the iCAT server.

func (*Connection) FetchUsers added in v0.1.5

func (con *Connection) FetchUsers() (Users, error)

FetchUsers returns a slice of *User, fresh from the iCAT server.

func (*Connection) FetchZones added in v0.1.5

func (con *Connection) FetchZones() (Zones, error)

FetchZones returns a slice of *Zone, fresh from the iCAT server.

func (*Connection) GetCcon added in v0.1.4

func (con *Connection) GetCcon() *C.rcComm_t

GetCcon checks out the connection handle for use in all iRODS operations. Basically a mutex for connections. Other goroutines calling this function will block until the handle is returned with con.ReturnCcon, by the goroutine using it. This prevents errors in the net code since concurrent API calls aren't supported over a single iRODS connection.

func (*Connection) Groups added in v0.1.5

func (con *Connection) Groups() (Groups, error)

Groups returns a slice of all *Group in the iCAT. You must have the proper groupadmin or rodsadmin privileges to use this function.

func (*Connection) IQuest added in v0.1.5

func (con *Connection) IQuest(query string, upperCase bool) ([]map[string]string, error)

IQuest accepts a SQL query fragment, returns results in slice of maps If upperCase is true, all records will be matched using their uppercase representation.

func (*Connection) IQuestSQL added in v1.0.5

func (con *Connection) IQuestSQL(specificQuery string, queryArgs ...string) ([][]string, error)

IQuestSQL executes a specific query on the iCAT server and returns a multi-dimensional string slice of results. Equivalent to: "iquest --sql {specificQuery} {queryArgs}..."

func (*Connection) InitCon added in v1.0.1

func (con *Connection) InitCon() error

func (*Connection) LocalZone added in v0.1.5

func (con *Connection) LocalZone() (*Zone, error)

LocalZone returns the *Zone. First it checks the ConnectionOptions.Zone and uses that, otherwise it pulls it fresh from the iCAT server.

func (*Connection) PathType added in v0.1.5

func (con *Connection) PathType(p string) (int, error)

PathType returns DataObjType, CollectionType, or -1 (error) for the iRODS path specified

func (*Connection) QueryMeta added in v0.1.1

func (con *Connection) QueryMeta(qString string) (response IRodsObjs, err error)

QueryMeta queries both data objects and collections for matching metadata. Returns IRodsObjs.

func (*Connection) RefreshGroups added in v0.1.5

func (con *Connection) RefreshGroups() error

RefreshGroups updates the slice returned by con.Groups() with fresh data from the iCAT server.

func (*Connection) RefreshResources added in v0.1.5

func (con *Connection) RefreshResources() error

RefreshResources updates the slice returned by con.Resources() with fresh data from the iCAT server.

func (*Connection) RefreshUsers added in v0.1.5

func (con *Connection) RefreshUsers() error

RefreshUsers updates the slice returned by con.Users() with fresh data from the iCAT server.

func (*Connection) RefreshZones added in v0.1.5

func (con *Connection) RefreshZones() error

RefreshZones updates the slice returned by con.Zones() with fresh data from the iCAT server.

func (*Connection) RegPhysObj added in v1.0.5

func (con *Connection) RegPhysObj(opts RegOptions) error

RegPhysObj is equivalent to the ireg icommand

func (*Connection) Resources added in v0.1.5

func (con *Connection) Resources() (Resources, error)

Resources returns a slice of all *Resource in the iCAT. You must have the proper rodsadmin privileges to use this function.

func (*Connection) ReturnCcon added in v0.1.4

func (con *Connection) ReturnCcon(ccon *C.rcComm_t)

ReturnCcon returns the connection handle for use in other threads. Unlocks the mutex.

func (*Connection) SetThreads added in v0.1.5

func (con *Connection) SetThreads(num int)

SetThreads changes the ccon.transStat.numThreads value. Not sure if it does anything.

func (*Connection) SetTicket added in v0.1.2

func (con *Connection) SetTicket(t string) error

SetTicket is equivalent to using the -t flag with icommands

func (*Connection) String

func (obj *Connection) String() string

String provides connection status and options provided during initialization (gorods.New)

func (*Connection) Threads added in v0.1.5

func (con *Connection) Threads() int

Threads returns ccon.transStat.numThreads

func (*Connection) UserInfo added in v1.0.5

func (con *Connection) UserInfo() (map[string]string, error)

func (*Connection) Users added in v0.1.5

func (con *Connection) Users() (Users, error)

Users returns a slice of all *User in the iCAT. You must have the proper rodsadmin privileges to use this function.

func (*Connection) Zones added in v0.1.5

func (con *Connection) Zones() (Zones, error)

Zones returns a slice of all *Zone in the iCAT. You must have the proper rodsadmin privileges to use this function.

type ConnectionOptions

type ConnectionOptions struct {
	Type          int
	AuthType      int
	PAMPassFile   string
	PAMToken      string
	PAMPassExpire int
	Host          string
	Port          int
	Zone          string
	Username      string
	Password      string
	Ticket        string
	FastInit      bool
	Threads       int
}

ConnectionOptions are used when creating iRODS iCAT server connections see gorods.New() docs for more info.

func (*ConnectionOptions) String added in v1.0.5

func (conOpts *ConnectionOptions) String() string

type DataObj

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

DataObj structs contain information about single data objects in an iRODS zone.

func CreateDataObj

func CreateDataObj(opts DataObjOptions, coll *Collection) (*DataObj, error)

CreateDataObj creates and adds a data object to the specified collection using provided options. Returns the newly created data object.

func (*DataObj) ACL added in v0.1.5

func (obj *DataObj) ACL() (ACLs, error)

ACL retuns a slice of ACL structs. Example of slice in string format: [rods#tempZone:own developers#tempZone:modify object designers#tempZone:read object]

func (*DataObj) AddMeta added in v0.1.1

func (obj *DataObj) AddMeta(m Meta) (nm *Meta, err error)

AddMeta adds a single Meta triple struct

func (*DataObj) Attribute

func (obj *DataObj) Attribute(attrName string) (Metas, error)

Attribute gets slice of Meta AVU triples, matching by Attribute name for DataObj

func (*DataObj) Backup added in v0.1.5

func (obj *DataObj) Backup(targetResource interface{}, opts DataObjOptions) error

Backup is similar to Replicate. In backup mode, if a good copy already exists in this resource group or resource, don't make another one.

func (*DataObj) Checksum added in v0.1.3

func (obj *DataObj) Checksum() string

Checksum returns the hash of the data object data

func (*DataObj) Chksum

func (obj *DataObj) Chksum() (string, error)

Chksum returns md5 hash string of data object

func (*DataObj) Chmod added in v0.1.5

func (obj *DataObj) Chmod(userOrGroup string, accessLevel int, recursive bool) error

Chmod changes the permissions/ACL of a data object. accessLevel: Null | Read | Write | Own

func (*DataObj) Close

func (obj *DataObj) Close() error

Close closes the data object, resets handler

func (*DataObj) Col

func (obj *DataObj) Col() *Collection

GetName returns the *Collection of the data object

func (*DataObj) Con

func (obj *DataObj) Con() *Connection

Connection returns the *Connection used to get data object

func (*DataObj) CopyTo

func (obj *DataObj) CopyTo(iRODSCollection interface{}) error

CopyTo copies the data object to the specified collection. Supports Collection struct or string as input. Also refreshes the destination collection automatically to maintain correct state. Returns error.

func (*DataObj) CopyToOpts added in v0.1.5

func (obj *DataObj) CopyToOpts(iRODSCollection interface{}, opts DataObjOptions) error

CopyTo copies the data object to the specified collection. Supports Collection struct or string as input. Also refreshes the destination collection automatically to maintain correct state. Returns error.

func (*DataObj) CreateTime added in v0.1.4

func (obj *DataObj) CreateTime() time.Time

CreateTime returns the create time of the data object

func (*DataObj) DataId added in v0.1.3

func (obj *DataObj) DataId() string

func (*DataObj) Delete

func (obj *DataObj) Delete(recursive bool) error

Delete is equivalent to irm -f {-r}

func (*DataObj) DeleteMeta added in v0.1.1

func (obj *DataObj) DeleteMeta(attr string) (*MetaCollection, error)

DeleteMeta deletes a single Meta triple struct, identified by Attribute field

func (*DataObj) Destroy added in v0.1.4

func (obj *DataObj) Destroy() error

Destroy is equivalent to irm -rf

func (*DataObj) DownloadTo

func (obj *DataObj) DownloadTo(localPath string) error

DownloadTo downloads and writes the entire data object to the provided path. Don't use this with large files unless you have RAM to spare, use ReadChunk() instead. Returns error.

func (*DataObj) FastRead added in v0.1.5

func (obj *DataObj) FastRead(pos int64, length int, callback func([]byte) error) error

FastRead is similar to ReadBytes, except it doesn't copy bytes into a new byte slice, making the process more efficient. It uses the existing C byte array and casts it as a go []byte. Once your call back is run, the allocated memory is freed automatically. This function will block until bytes are received and your callback has been run.

func (*DataObj) FastReadFree added in v0.1.5

func (obj *DataObj) FastReadFree(pos int64, length int) (*ByteArr, error)

FastReadFree is similar to ReadBytes, except it doesn't copy bytes into a new byte slice, making the process more efficient. It uses the existing C byte array and casts it as a go []byte. You must explicitally call ByteArr.Free on the returned struct or there will be a memory leak.

func (*DataObj) GrantAccess added in v0.1.5

func (obj *DataObj) GrantAccess(userOrGroup AccessObject, accessLevel int, recursive bool) error

GrantAccess will add permissions (ACL) to the data object.

func (*DataObj) Handle added in v1.0.5

func (obj *DataObj) Handle() int

Handle returns the internal handle index

func (*DataObj) IsDir added in v1.0.1

func (obj *DataObj) IsDir() bool

func (*DataObj) LSeek

func (obj *DataObj) LSeek(offset int64) error

LSeek sets the read/write offset pointer of a data object, returns error

func (*DataObj) Meta

func (obj *DataObj) Meta() (*MetaCollection, error)

Meta returns collection of Meta AVU triple structs of the data object

func (*DataObj) ModTime added in v1.0.1

func (obj *DataObj) ModTime() time.Time

func (*DataObj) Mode added in v1.0.1

func (obj *DataObj) Mode() os.FileMode

func (*DataObj) ModifyTime added in v0.1.4

func (obj *DataObj) ModifyTime() time.Time

ModifyTime returns the modify time of the data object

func (*DataObj) MoveTo

func (obj *DataObj) MoveTo(iRODSCollection interface{}) error

MoveTo moves the data object to the specified collection. Supports Collection struct or string as input. Also refreshes the source and destination collections automatically to maintain correct state. Returns error.

func (*DataObj) MoveToResource

func (obj *DataObj) MoveToResource(targetResource interface{}) error

MoveToResource moves data object to the specified resource. Accepts string or *Resource type.

func (*DataObj) Name

func (obj *DataObj) Name() string

GetName returns the Name of the data object

func (*DataObj) Offset

func (obj *DataObj) Offset() int64

Offset returns the offset bytes for the pointer of the data object. LSeek will change this value.

func (*DataObj) Open

func (obj *DataObj) Open() error

Open opens a connection to iRODS and sets the data object handle

func (*DataObj) OpenRW added in v0.1.4

func (obj *DataObj) OpenRW() error

OpenRW opens a connection to iRODS and sets the data object handle for read/write access

func (*DataObj) Owner added in v0.1.5

func (obj *DataObj) Owner() *User

GetOwnerName returns the owner name of the data object

func (*DataObj) OwnerName added in v0.1.4

func (obj *DataObj) OwnerName() string

GetOwnerName returns the owner name of the data object

func (*DataObj) Path

func (obj *DataObj) Path() string

GetName returns the Path of the data object

func (*DataObj) PhyPath added in v0.1.3

func (obj *DataObj) PhyPath() string

PhyPath is the actual location where the data object is stored on the iRODS server.

func (*DataObj) Read

func (obj *DataObj) Read() ([]byte, error)

Read reads the entire data object into memory and returns a []byte slice. Don't use this for large files.

func (*DataObj) ReadBytes

func (obj *DataObj) ReadBytes(pos int64, length int) ([]byte, error)

ReadBytes reads bytes from a data object at the specified position and length, returns []byte slice and error.

func (*DataObj) ReadChunk

func (obj *DataObj) ReadChunk(size int64, callback func([]byte)) error

ReadChunk reads the entire data object in chunks (size of chunk specified by size parameter), passing the data into a callback function for each chunk. Use this to read/write large files.

func (*DataObj) ReadChunkFree added in v0.1.5

func (obj *DataObj) ReadChunkFree(size int64, callback func(*ByteArr)) error

ReadChunkFree is similar to ReadChunk, except it doesn't copy bytes into a new byte slice, making the process more efficient. It uses the existing C byte array and casts it as a go []byte. You must explicitally call ByteArr.Free on the returned struct or there will be a memory leak.

func (*DataObj) Reader added in v1.0.5

func (obj *DataObj) Reader() *Reader

Reader returns *gorods.Reader whuch implements io.Reader interface

func (*DataObj) Rename

func (obj *DataObj) Rename(newFileName string) error

Rename is equivalent to the Linux mv command except that the data object must stay within the current collection (directory), returns error.

func (*DataObj) ReplNum added in v0.1.5

func (obj *DataObj) ReplNum() int

ReplNum returns the replica index of the data object

func (*DataObj) ReplStatus added in v0.1.5

func (obj *DataObj) ReplStatus() int

func (*DataObj) Replicate

func (obj *DataObj) Replicate(targetResource interface{}, opts DataObjOptions) error

Replicate copies the data object to the specified resource. Accepts string or *Resource type for targetResource parameter.

func (*DataObj) RescHier added in v0.1.5

func (obj *DataObj) RescHier() string

func (*DataObj) Resource added in v0.1.3

func (obj *DataObj) Resource() *Resource

Resource returns the *Resource where the data object is stored

func (*DataObj) Rm added in v0.1.4

func (obj *DataObj) Rm(recursive bool, force bool) error

Rm is equivalent to irm {-r} {-f}

func (*DataObj) RmTrash added in v1.0.5

func (obj *DataObj) RmTrash() error

RmTrash is used (sometimes internally) by GoRODS to delete items in the trash permanently. The data object's path should be in the trash collection.

func (*DataObj) Size

func (obj *DataObj) Size() int64

Size returns the size in bytes of the data object

func (*DataObj) Stat

func (obj *DataObj) Stat() (map[string]interface{}, error)

Stat returns a map (key/value pairs) of the system meta information. The following keys can be used with the map:

"objSize"

"dataMode"

"dataId"

"chksum"

"ownerName"

"ownerZone"

"createTime"

"modifyTime"

func (*DataObj) String

func (obj *DataObj) String() string

String returns path of data object

func (*DataObj) Sys added in v1.0.1

func (obj *DataObj) Sys() interface{}

func (*DataObj) Trash added in v0.1.4

func (obj *DataObj) Trash(recursive bool) error

Trash is equivalent to irm {-r}

func (*DataObj) TrimRepls added in v0.1.5

func (obj *DataObj) TrimRepls(opts TrimOptions) error

TrimRepls trims data object replicas (removes from resource servers), using the rules defined in opts.

func (*DataObj) Type

func (obj *DataObj) Type() int

Type gets the type (DataObjType), used in interfaces

func (obj *DataObj) Unlink() error

Unlink deletes the data object from the iRODS server, no force flag is used

func (*DataObj) Verify

func (obj *DataObj) Verify(md5Checksum string) bool

Verify returns true or false depending on whether the checksum md5 string matches

func (*DataObj) Write

func (obj *DataObj) Write(data []byte) error

Write writes the data to the data object, starting from the beginning. Returns error.

func (*DataObj) WriteBytes

func (obj *DataObj) WriteBytes(data []byte) error

WriteBytes writes to the data object wherever the object's offset pointer is currently set to. It advances the pointer to the end of the written data for supporting subsequent writes. Be sure to call obj.LSeek(0) before hand if you wish to write from the beginning. Returns error.

func (*DataObj) Writer added in v1.0.5

func (obj *DataObj) Writer() *Writer

Writer returns *gorods.Writer whuch implements io.Writer interface

type DataObjOptions

type DataObjOptions struct {
	Name     string
	Size     int64
	Mode     int
	Force    bool
	Resource interface{}
}

DataObjOptions is used for passing options to the CreateDataObj and DataObj.Copy function

type FSOptions added in v0.1.5

type FSOptions struct {
	Client         *Client
	Connection     *Connection
	Path           string
	Download       bool
	StripPrefix    string
	CollectionView string
}

type GoRodsError

type GoRodsError struct {
	LogLevel  int
	Message   string
	IRODSCode string
	Time      time.Time
}

GoRodsError stores information about errors

func (*GoRodsError) Error

func (err *GoRodsError) Error() string

Error returns error string, alias of String(). Sample output:

2016-04-22 10:02:30.802355258 -0400 EDT: Fatal - iRODS Connect Failed: rcConnect failed

func (*GoRodsError) String

func (err *GoRodsError) String() string

String returns error string. Sample output:

2016-04-22 10:02:30.802355258 -0400 EDT: Fatal - iRODS Connect Failed: rcConnect failed

type Group added in v0.1.5

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

Group holds info about iRODS groups

func (*Group) AddMeta added in v1.0.5

func (grp *Group) AddMeta(m Meta) (nm *Meta, err error)

AddMeta adds a single Meta triple struct

func (*Group) AddUser added in v0.1.5

func (grp *Group) AddUser(usr interface{}) error

AddUser adds an iRODS uset to the group. Accepts a string or *User struct.

func (*Group) Attribute added in v1.0.5

func (grp *Group) Attribute(attrName string) (Metas, error)

Attribute gets slice of Meta AVU triples, matching by Attribute name for Group

func (*Group) Comment added in v0.1.5

func (grp *Group) Comment() (string, error)

Comment loads data from iRODS if needed, and returns the group's comment attribute.

func (*Group) Con added in v0.1.5

func (grp *Group) Con() *Connection

Con returns the *Connection used to fetch group info

func (*Group) CreateTime added in v0.1.5

func (grp *Group) CreateTime() (time.Time, error)

CreateTime loads data from iRODS if needed, and returns the group's createTime attribute.

func (*Group) Delete added in v0.1.5

func (grp *Group) Delete() error

Delete deletes the group from iCAT server. Refreshes Connection group cache.

func (*Group) DeleteMeta added in v1.0.5

func (grp *Group) DeleteMeta(attr string) (*MetaCollection, error)

DeleteMeta deletes a single Meta triple struct, identified by Attribute field

func (*Group) FetchInfo added in v0.1.5

func (grp *Group) FetchInfo() (map[string]string, error)

FetchInfo returns a map of fresh group info from the iCAT server

func (*Group) FetchUsers added in v0.1.5

func (grp *Group) FetchUsers() (Users, error)

FetchUsers returns a slice of fresh *User from the iCAT server

func (*Group) Id added in v0.1.5

func (grp *Group) Id() (int, error)

Id loads data from iRODS if needed, and returns the group's Id attribute.

func (*Group) Info added in v0.1.5

func (grp *Group) Info() (string, error)

Info loads data from iRODS if needed, and returns the group's Info attribute.

func (*Group) Meta added in v1.0.5

func (grp *Group) Meta() (*MetaCollection, error)

Meta returns collection of Meta AVU triple structs of the group object

func (*Group) ModifyTime added in v0.1.5

func (grp *Group) ModifyTime() (time.Time, error)

ModifyTime loads data from iRODS if needed, and returns the group's modifyTime attribute.

func (*Group) Name added in v0.1.5

func (grp *Group) Name() string

Name returns the name of the group.

func (*Group) Path added in v1.0.5

func (grp *Group) Path() string

Path returns the name of the group. Used in gorods.MetaObj interface.

func (*Group) RefreshInfo added in v0.1.5

func (grp *Group) RefreshInfo() error

RefreshInfo refreshes the attributes of the group, pulling fresh data from the iCAT server.

func (*Group) RefreshUsers added in v0.1.5

func (grp *Group) RefreshUsers() error

RefreshUsers pulls fresh data from the iCAT server and sets the internal field returned by *Group.Users

func (*Group) Remove added in v0.1.5

func (grp *Group) Remove() bool

Remove deletes the group from the parent slice

func (*Group) RemoveUser added in v0.1.5

func (grp *Group) RemoveUser(usr interface{}) error

RemoveUser removes an iRODS user from the group. Accepts a string or *User struct.

func (*Group) String added in v0.1.5

func (grp *Group) String() string

String returns the group name

func (*Group) Type added in v0.1.5

func (grp *Group) Type() int

Type returns GroupType, used in AccessObject and MetaObj interfaces

func (*Group) Users added in v0.1.5

func (grp *Group) Users() (Users, error)

Users loads data from iRODS if needed, and returns the group's Users slice.

func (*Group) Zone added in v0.1.5

func (grp *Group) Zone() *Zone

Zone returns the *Zone struct that this group belongs to.

type Groups added in v0.1.5

type Groups []*Group

Groups is a slice of *Group structs.

func (Groups) FindByName added in v0.1.5

func (grps Groups) FindByName(name string, con *Connection) *Group

FindByName searches the slice (itself) and attempts to return a match based on name. If no match is found, a new group with that name is created and returned. This was designed to resolve issues of casting resources for DataObjects and Collections, even though the cache was empty due to permissions.

func (*Groups) Remove added in v0.1.5

func (grps *Groups) Remove(index int)

type HandlerFactory added in v0.1.5

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

func (*HandlerFactory) ServeHTTP added in v0.1.5

func (hf *HandlerFactory) ServeHTTP(response http.ResponseWriter, request *http.Request)

type HttpHandler added in v0.1.5

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

func (*HttpHandler) AddACL added in v0.1.5

func (handler *HttpHandler) AddACL(obj IRodsObj)

func (*HttpHandler) AddMetaAVU added in v0.1.5

func (handler *HttpHandler) AddMetaAVU(obj IRodsObj)

func (*HttpHandler) CreateCollection added in v0.1.5

func (handler *HttpHandler) CreateCollection(col *Collection)

func (*HttpHandler) DeleteMetaAVU added in v0.1.5

func (handler *HttpHandler) DeleteMetaAVU(obj IRodsObj)

func (*HttpHandler) DeleteObj added in v0.1.5

func (handler *HttpHandler) DeleteObj(obj IRodsObj)

func (*HttpHandler) Serve404 added in v0.1.5

func (handler *HttpHandler) Serve404()

func (*HttpHandler) ServeCollectionView added in v0.1.5

func (handler *HttpHandler) ServeCollectionView(col *Collection)

func (*HttpHandler) ServeDataObj added in v0.1.5

func (handler *HttpHandler) ServeDataObj(obj *DataObj)

func (*HttpHandler) ServeHTTP added in v0.1.5

func (handler *HttpHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)

func (*HttpHandler) ServeJSONMeta added in v0.1.5

func (handler *HttpHandler) ServeJSONMeta(obj IRodsObj)

func (*HttpHandler) Upload added in v0.1.5

func (handler *HttpHandler) Upload(col *Collection)

type IRodsObj

type IRodsObj interface {
	Type() int
	Name() string
	Path() string
	Col() *Collection
	Con() *Connection
	ACL() (ACLs, error)
	Stat() (map[string]interface{}, error)

	Size() int64
	Mode() os.FileMode
	ModTime() time.Time
	IsDir() bool
	Sys() interface{}

	Owner() *User
	OwnerName() string
	CreateTime() time.Time
	ModifyTime() time.Time

	Rename(string) error

	CopyTo(interface{}) error
	MoveTo(interface{}) error
	DownloadTo(string) error

	// irm -rf
	Destroy() error

	// irm -f {-r}
	Delete(bool) error

	// irm {-r}
	Trash(bool) error

	// irm {-r} {-f}
	Rm(bool, bool) error

	RmTrash() error

	Chmod(string, int, bool) error
	GrantAccess(AccessObject, int, bool) error

	Replicate(interface{}, DataObjOptions) error
	Backup(interface{}, DataObjOptions) error
	MoveToResource(interface{}) error
	TrimRepls(TrimOptions) error

	Meta() (*MetaCollection, error)
	Attribute(string) (Metas, error)
	AddMeta(Meta) (*Meta, error)
	DeleteMeta(string) (*MetaCollection, error)

	String() string
	Open() error
	Close() error
}

IRodsObj is a generic interface used to detect the object type and access common fields

type IRodsObjs added in v0.1.1

type IRodsObjs []IRodsObj

IRodsObjs is a slice of IRodsObj (Either a *DataObj or *Collection).

func (IRodsObjs) Each added in v0.1.3

func (objs IRodsObjs) Each(iterator func(IRodsObj)) error

Each provides an iterator for IRodsObjs slice

func (IRodsObjs) Exists added in v0.1.1

func (objs IRodsObjs) Exists(path string) bool

Exists checks to see if a collection exists in the slice and returns true or false

func (IRodsObjs) Find added in v0.1.1

func (objs IRodsObjs) Find(path string) IRodsObj

Find gets a collection from the slice and returns nil if one is not found. Both the collection name or full path can be used as input.

func (IRodsObjs) FindRecursive added in v0.1.1

func (objs IRodsObjs) FindRecursive(path string) IRodsObj

FindRecursive acts just like Find, but also searches sub collections recursively. If the collection was not explicitly loaded recursively, only the first level of sub collections will be searched.

type JSONArr added in v0.1.5

type JSONArr []JSONMap

type JSONMap added in v0.1.5

type JSONMap map[string]string

type Meta

type Meta struct {
	Attribute string
	Value     string
	Units     string
	Parent    *MetaCollection
}

Meta structs contain information about a single iRODS metadata attribute-value-units (AVU) triple

func (*Meta) Delete added in v0.1.1

func (m *Meta) Delete() (*MetaCollection, error)

Delete deletes the current Meta struct from iRODS object

func (*Meta) Rename added in v0.1.1

func (m *Meta) Rename(attributeName string) (*Meta, error)

Rename will modify metadata AVU attribute name only

func (*Meta) Set added in v0.1.1

func (m *Meta) Set(value string, units string) (*Meta, error)

Set will modify metadata AVU value & units

func (*Meta) SetAll added in v0.1.1

func (m *Meta) SetAll(attributeName string, value string, units string) (newMeta *Meta, e error)

SetAll will modify metadata AVU with all three paramaters (Attribute, Value, Unit)

func (*Meta) SetUnits added in v0.1.1

func (m *Meta) SetUnits(units string) (*Meta, error)

SetUnits will modify metadata AVU units only

func (*Meta) SetValue added in v0.1.1

func (m *Meta) SetValue(value string) (*Meta, error)

SetValue will modify metadata AVU value only

func (*Meta) String

func (m *Meta) String() string

String shows the contents of the meta struct.

Sample output:

Attr1: Val (unit: foo)

type MetaCollection

type MetaCollection struct {
	Metas Metas
	Obj   MetaObj
	Con   *Connection
}

MetaCollection is a collection of metadata AVU triples for a single data object

func (*MetaCollection) Add added in v0.1.1

func (mc *MetaCollection) Add(m Meta) (*Meta, error)

Add creates a new meta AVU triple, returns pointer to the created Meta struct

func (*MetaCollection) All added in v0.1.2

func (mc *MetaCollection) All() (Metas, error)

All returns a slice of all Meta structs in the MetaCollection

func (*MetaCollection) Delete added in v0.1.1

func (mc *MetaCollection) Delete(attr string) (err error)

Delete deletes the meta AVU triple from the data object, identified by it's Attribute field

func (*MetaCollection) Each added in v0.1.2

func (mc *MetaCollection) Each(iterator func(*Meta)) error

Each accepts an iterator function for looping over all Meta structs in the MetaCollection

func (*MetaCollection) First added in v0.1.4

func (mc *MetaCollection) First(attr string) (*Meta, error)

First finds the first matching Meta struct by it's Attribute field

func (*MetaCollection) Get

func (mc *MetaCollection) Get(attr string) (Metas, error)

Get returns a Meta struct slice (since attributes can share the same name in iRODS), matching by their Attribute field. Similar to Attribute() function of other types

func (*MetaCollection) ReadMeta added in v0.1.1

func (mc *MetaCollection) ReadMeta() error

ReadMeta clears existing metadata triples and grabs updated copy from iCAT server.

func (*MetaCollection) Refresh added in v0.1.1

func (mc *MetaCollection) Refresh() error

Refresh clears existing metadata triples and grabs updated copy from iCAT server. It's an alias of ReadMeta()

func (*MetaCollection) String

func (mc *MetaCollection) String() string

String shows the contents of the meta collection.

Sample output:

Attr1: Val (unit: )
Attr2: Yes (unit: bool)

type MetaObj added in v1.0.5

type MetaObj interface {
	Type() int
	Con() *Connection
	Name() string
	Path() string

	Meta() (*MetaCollection, error)
	Attribute(string) (Metas, error)
	AddMeta(Meta) (*Meta, error)
	DeleteMeta(string) (*MetaCollection, error)
}

type Metas added in v0.1.2

type Metas []*Meta

Metas is a slice of *Meta

func (Metas) MatchOne added in v0.1.4

func (ms Metas) MatchOne(m *Meta) *Meta

MatchOne returns a single Meta struct from the slice, matching on Attribute, Value, and Units

func (Metas) String added in v0.1.4

func (ms Metas) String() string

String shows the contents of the meta slice struct.

Sample output:

Attr1: Val (unit: foo)

type RangeOutput added in v0.1.5

type RangeOutput []RangeSegmentOutput

func (RangeOutput) TotalLength added in v0.1.5

func (ro RangeOutput) TotalLength() string

type RangeSegmentOutput added in v0.1.5

type RangeSegmentOutput struct {
	ContentRange string
	ContentType  string
	ByteContent  []byte
}

type Reader added in v1.0.5

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

Reader provides an io.Reader interface for *gorods.DataObj

func (*Reader) Read added in v1.0.5

func (r *Reader) Read(p []byte) (n int, err error)

Read implements io.Reader interface

type RegOptions added in v1.0.5

type RegOptions struct {
	PhysicalFilePath string
	RodsPath         string
	Force            bool
	Replica          bool
	Resource         interface{}
	ExcludeFiles     string
}

type Resource added in v0.1.5

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

Resource holds information about a resource server registered with iCAT.

func (*Resource) Children added in v0.1.5

func (resc *Resource) Children() (string, error)

Children loads data from iCAT if needed, and returns the resources children attribute.

func (*Resource) Class added in v0.1.5

func (resc *Resource) Class() (int, error)

Class loads data from iCAT if needed, and returns the resources class attribute.

func (*Resource) Comment added in v0.1.5

func (resc *Resource) Comment() (string, error)

Comment loads data from iCAT if needed, and returns the resources comment attribute.

func (*Resource) Context added in v0.1.5

func (resc *Resource) Context() (string, error)

Context loads data from iCAT if needed, and returns the resources context attribute.

func (*Resource) CreateTime added in v0.1.5

func (resc *Resource) CreateTime() (time.Time, error)

CreateTime loads data from iCAT if needed, and returns the resources createTime attribute.

func (*Resource) FetchInfo added in v0.1.5

func (resc *Resource) FetchInfo() (map[string]string, error)

FetchInfo fetches fresh resource info from the iCAT server and returns it as a map

func (*Resource) FreeSpace added in v0.1.5

func (resc *Resource) FreeSpace() (int, error)

FreeSpace loads data from iCAT if needed, and returns the resources freeSpace attribute.

func (*Resource) FreeSpaceTime added in v0.1.5

func (resc *Resource) FreeSpaceTime() (time.Time, error)

FreeSpaceTime loads data from iCAT if needed, and returns the resources freeSpaceTime attribute.

func (*Resource) Id added in v0.1.5

func (resc *Resource) Id() (int, error)

Id loads data from iCAT if needed, and returns the resources id attribute.

func (*Resource) Info added in v0.1.5

func (resc *Resource) Info() (string, error)

Info loads data from iCAT if needed, and returns the resources info attribute.

func (*Resource) ModifyTime added in v0.1.5

func (resc *Resource) ModifyTime() (time.Time, error)

ModifyTime loads data from iCAT if needed, and returns the resources modifyTime attribute.

func (*Resource) Name added in v0.1.5

func (resc *Resource) Name() string

Name returns the resource name

func (*Resource) Net added in v0.1.5

func (resc *Resource) Net() (string, error)

Net loads data from iCAT if needed, and returns the resources net attribute.

func (*Resource) ObjCount added in v0.1.5

func (resc *Resource) ObjCount() (int, error)

ObjCount loads data from iCAT if needed, and returns the resources status attribute.

func (*Resource) ParentStr added in v0.1.5

func (resc *Resource) ParentStr() (string, error)

ParentStr loads data from iCAT if needed, and returns the resources parentStr attribute.

func (*Resource) PhysPath added in v0.1.5

func (resc *Resource) PhysPath() (string, error)

PhysPath loads data from iCAT if needed, and returns the resources physPath attribute.

func (*Resource) RefreshInfo added in v0.1.5

func (resc *Resource) RefreshInfo() error

RefreshInfo fetches fresh resource data from the iCAT server, and unloads it to the resource struct's fields.

func (*Resource) Remove added in v0.1.5

func (resc *Resource) Remove() bool

Remove removes the resource from it's parent slice

func (*Resource) Status added in v0.1.5

func (resc *Resource) Status() (string, error)

Status loads data from iCAT if needed, and returns the resources status attribute.

func (*Resource) StorageType added in v0.1.5

func (resc *Resource) StorageType() (string, error)

Status loads data from iCAT if needed, and returns the resources info attribute.

func (*Resource) String added in v0.1.5

func (resc *Resource) String() string

String returns the resource name and zone name

func (*Resource) Type added in v0.1.5

func (resc *Resource) Type() (int, error)

Id loads data from iCAT if needed, and returns the resources id attribute.

func (*Resource) Zone added in v0.1.5

func (resc *Resource) Zone() *Zone

Zone returns the *Zone to which the resource belongs to.

type Resources added in v0.1.5

type Resources []*Resource

Resources is a slice of *Resource.

func (Resources) FindByName added in v0.1.5

func (rescs Resources) FindByName(name string) *Resource

FindByName returns the matching *Resource based on the name.

func (*Resources) Remove added in v0.1.5

func (rescs *Resources) Remove(index int)

Remove removes the specific element from itself, based on index.

type TrimOptions added in v0.1.5

type TrimOptions struct {
	NumCopiesKeep  int
	MinAgeMins     int
	TargetResource interface{}
}

TrimOptions store the options for trim operations. NumCopiesKeep is the miniumum number of data object replicas to maintain. MinAgeMinues is the minimum age in minutes of the data object to trim. TargetResource is a string or *Resource type.

type User added in v0.1.5

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

User contains information relating to an iRODS user

func (*User) AddMeta added in v1.0.5

func (usr *User) AddMeta(m Meta) (nm *Meta, err error)

AddMeta adds a single Meta triple struct

func (*User) AddToGroup added in v0.1.5

func (usr *User) AddToGroup(grp interface{}) error

AddToGroup adds the user to an existing iRODS group. Accepts string or *Group types.

func (*User) Attribute added in v1.0.5

func (usr *User) Attribute(attrName string) (Metas, error)

Attribute gets slice of Meta AVU triples, matching by Attribute name for User

func (*User) ChangePassword added in v0.1.5

func (usr *User) ChangePassword(newPass string) error

ChangePassword changes the user's password. You will need to be a rodsadmin for this to succeed (I think).

func (*User) Comment added in v0.1.5

func (usr *User) Comment() (string, error)

Comment loads data from iRODS if needed, and returns the user's comment attribute.

func (*User) Con added in v0.1.5

func (usr *User) Con() *Connection

Con returns the connection used to initalize the user

func (*User) CreateTime added in v0.1.5

func (usr *User) CreateTime() (time.Time, error)

CreateTime loads data from iRODS if needed, and returns the user's createTime attribute.

func (*User) Delete added in v0.1.5

func (usr *User) Delete() error

Delete deletes the user from the iCAT server

func (*User) DeleteMeta added in v1.0.5

func (usr *User) DeleteMeta(attr string) (*MetaCollection, error)

DeleteMeta deletes a single Meta triple struct, identified by Attribute field

func (*User) FetchGroups added in v0.1.5

func (usr *User) FetchGroups() (Groups, error)

FetchGroups fetches and returns fresh data about the user's groups from the iCAT server.

func (*User) FetchInfo added in v0.1.5

func (usr *User) FetchInfo() (map[string]string, error)

FetchInfo fetches fresh user info from the iCAT server, and returns it as a map.

func (*User) Groups added in v0.1.5

func (usr *User) Groups() (Groups, error)

Groups loads data from iRODS if needed, and returns the user's groups slice.

func (*User) Id added in v0.1.5

func (usr *User) Id() (int, error)

Id loads data from iRODS if needed, and returns the user's id attribute.

func (*User) Info added in v0.1.5

func (usr *User) Info() (string, error)

Info loads data from iRODS if needed, and returns the user's info attribute.

func (*User) Meta added in v1.0.5

func (usr *User) Meta() (*MetaCollection, error)

Meta returns collection of Meta AVU triple structs of the user object

func (*User) ModifyTime added in v0.1.5

func (usr *User) ModifyTime() (time.Time, error)

ModifyTime loads data from iRODS if needed, and returns the user's modifyTime attribute.

func (*User) Name added in v0.1.5

func (usr *User) Name() string

Name returns the users name.

func (*User) Path added in v1.0.5

func (usr *User) Path() string

Path returns the users name. Used in gorods.MetaObj interface.

func (*User) RefreshGroups added in v0.1.5

func (usr *User) RefreshGroups() error

RefreshGroups fetches group data from iCAT, and unloads it into the *User fields

func (*User) RefreshInfo added in v0.1.5

func (usr *User) RefreshInfo() error

RefreshInfo fetches user data from iCAT, and unloads it into the *User fields

func (*User) Remove added in v0.1.5

func (usr *User) Remove() bool

Remove removed the user from it's parent slice.

func (*User) RemoveFromGroup added in v0.1.5

func (usr *User) RemoveFromGroup(grp interface{}) error

RemoveFromGroup removes the user from an iRODS group. Accepts string or *Group types.

func (*User) String added in v0.1.5

func (usr *User) String() string

String returns a user's type, name, and zone.

func (*User) Type added in v0.1.5

func (usr *User) Type() int

Type loads data from iRODS if needed, and returns the user's typ attribute. Used in AccessObject and MetaObj interfaces.

func (*User) Zone added in v0.1.5

func (usr *User) Zone() *Zone

Zone returns the *Zone to which the user belongs.

type Users added in v0.1.5

type Users []*User

Users is a slice of *User

func (Users) FindByName added in v0.1.5

func (usrs Users) FindByName(name string, con *Connection) *User

FindByName searches the slice for a user by name. If no match is found, a new user with that name is created and returned. This was designed to resolve issues of casting resources for DataObjects and Collections, even though the cache was empty due to permissions.

func (*Users) Remove added in v0.1.5

func (usrs *Users) Remove(index int)

Remove deletes an item from the slice based on the index.

type Writer added in v1.0.5

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

Writer provides an io.Writer interface for *gorods.DataObj

func (*Writer) Write added in v1.0.5

func (w *Writer) Write(p []byte) (n int, err error)

Write implements io.Writer interface

type Zone added in v0.1.5

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

Zone contains information representing an iRODS zone.

func (*Zone) Comment added in v0.1.5

func (zne *Zone) Comment() (string, error)

Comment loads data from iRODS if needed, and returns the zone's comment attribute.

func (*Zone) ConString added in v0.1.5

func (zne *Zone) ConString() (string, error)

ConString loads data from iRODS if needed, and returns the zone's conString attribute.

func (*Zone) CreateTime added in v0.1.5

func (zne *Zone) CreateTime() (time.Time, error)

CreateTime loads data from iRODS if needed, and returns the zone's createTime attribute.

func (*Zone) FetchInfo added in v0.1.5

func (zne *Zone) FetchInfo() (map[string]string, error)

FetchInfo returns a map of fresh zone info from the iCAT server.

func (*Zone) Id added in v0.1.5

func (zne *Zone) Id() (int, error)

Id loads data from iRODS if needed, and returns the zone's id attribute.

func (*Zone) ModifyTime added in v0.1.5

func (zne *Zone) ModifyTime() (time.Time, error)

ModifyTime loads data from iRODS if needed, and returns the zone's modifyTime attribute.

func (*Zone) Name added in v0.1.5

func (zne *Zone) Name() string

Name returns the zone's name.

func (*Zone) RefreshInfo added in v0.1.5

func (zne *Zone) RefreshInfo() error

RefreshInfo pulls fresh info from the iCAT server, and sets it's zone fields based on the data.

func (*Zone) Remove added in v0.1.5

func (zne *Zone) Remove() bool

Remove removes the zone from it's parent slice

func (*Zone) String added in v0.1.5

func (zne *Zone) String() string

String returns the zone type and name.

func (*Zone) Type added in v0.1.5

func (zne *Zone) Type() (int, error)

Type loads data from iRODS if needed, and returns the zone's typ attribute.

type Zones added in v0.1.5

type Zones []*Zone

Zones is a slice of *Zone.

func (Zones) FindByName added in v0.1.5

func (znes Zones) FindByName(name string, con *Connection) *Zone

FindByName searches the slice (itself) for a matching zone, based on name. If the zone isn't found, one is initialized. If no match is found, a new zone with that name is created and returned. This was designed to resolve issues of casting zone strings to structs, even though the cache was empty due to permissions.

func (*Zones) Remove added in v0.1.5

func (znes *Zones) Remove(index int)

Remove removes an item from itself based on index.

Notes

Bugs

Directories

Path Synopsis
Package msi is package that contains utilities for use in microservices written in Golang.
Package msi is package that contains utilities for use in microservices written in Golang.

Jump to

Keyboard shortcuts

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