ot

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: MIT Imports: 14 Imported by: 0

README

OT Go Driver GoDoc Coverage Status

The OpenText driver for Go



Requirements

  • Go 1.12 or higher

  • OpenText 16.x

Installation

go get -u github.com/itcomusic/ot
Usage

To get started with the driver, import the ot package, create a ot.Endpoint and set user to future authentication to your running OpenText server:

ss := ot.NewEndpoint("127.0.0.1").User("test", "test")

To do this in a single step, you can use the Call function:

var res map[string]interface{}
ctx, _ = context.WithTimeout(context.Background(), 30*time.Second)
if err := ss.Call(ctx, "service.method", oscript.M{"argName", 1}, &res); err != nil {
    log.Fatal(err)
}

A context does not stop execution of a request in the opentext, it closes only socket.

Token
token, err := ss.GetToken(context.Background(), "test", "test")
if err != nil {
    log.Fatal(err)
}
sst := ot.NewEndpoint("127.0.0.1").Token(token)
Attributes

To set many attributes by types at once.

if err := cat.Set(
    ot.AttrInt("attr1", 1)
    ot.AttrString("attr2", "hello")
    ot.AttrBool("attr3", true)
    ot.AttrTime("attr4", time.Now())); err != nil {
    log.Fatal(err)
}

To get attribute with explicit type.

var attr1 int
if err := cat.Int("attr1", &attr1); err != nil {
    log.Fatal(err)
}

License

The OT Go driver is licensed under the MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CacheCategory = &cacheCategory{}

CacheCategory is a cache of the categories.

View Source
var (
	ErrTokenExpire = fmt.Errorf("ot: token expired")
)

Functions

This section is empty.

Types

type Category

type Category struct {
	DisplayName string  `oscript:"DisplayName"`
	Key         string  `oscript:"Key"`
	Type        string  `oscript:"Type"`
	Data        []Value `oscript:"Values"`
	// contains filtered or unexported fields
}

Category of the node.

func (*Category) Bool

func (c *Category) Bool(name string, v *bool) error

Bool returns bool value.

func (*Category) Copy

func (c *Category) Copy() *Category

Copy copies category with values.

func (Category) IDVersion

func (c Category) IDVersion() (id int64, version int)

IDVersion returns id and version of the category.

func (*Category) Int

func (c *Category) Int(name string, v *int) error

Int returns int value.

func (*Category) Set

func (c *Category) Set(v ...NameValueType) error

Set sets values.

func (*Category) String

func (c *Category) String(name string, v *string) error

String returns string value.

func (*Category) Time

func (c *Category) Time(name string, v *time.Time) error

Time returns time value.

func (*Category) Upgrade

func (c *Category) Upgrade(new Category) error

Upgrade upgrades category.

type Document

type Document struct {
	Comment        string
	Name           string
	Parent         int64
	Metadata       Metadata
	VersionControl bool
	File           *FileAttr
	Reader         io.Reader
}

type DuplicateNameError

type DuplicateNameError struct {
	*client.OpError
}

type Endpoint

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

Endpoint represents connection address.

func NewEndpoint

func NewEndpoint(addr string) *Endpoint

NewEndpoint creates information about connection to the server opentext. No creates connection to server.

func (*Endpoint) Token

func (e *Endpoint) Token(token string) *Session

Token creates new session with token authentication.

func (*Endpoint) User

func (e *Endpoint) User(username, password string) *Session

User creates new session with auth authentication.

type Feature

type Feature struct {
	Name string `oscript:"Name"`
	Type string `oscript:"Type"`

	BooleanValue *bool      `oscript:"BooleanValue,omitempty"`
	DateValue    *time.Time `oscript:"DateValue,omitempty"`
	IntegerValue *int       `oscript:"IntegerValue,omitempty"`
	LongValue    *float64   `oscript:"LongValue,omitempty"`
	StringValue  *string    `oscript:"StringValue,omitempty"`
	// contains filtered or unexported fields
}

type FileAttr

type FileAttr struct {
	NodeID   int64     `oscript:"-"`
	Created  time.Time `oscript:"CreatedDate"`
	Modified time.Time `oscript:"ModifiedDate"`
	Name     string    `oscript:"Name"`
	Size     int64     `oscript:"DataForkSize"`
}

FileAttr information about files.

func OpenFile

func OpenFile(name string) (*os.File, *FileAttr, error)

OpenFile opens the named file for reading.

func (*FileAttr) MarshalOscriptBuf

func (f *FileAttr) MarshalOscriptBuf(buf oscript.Buffer) error

MarshalOscriptBuf marshals to specific format, the fields for process unmarshal/marshal are identified differently.

type Metadata

type Metadata struct {
	// TODO: Category as pointer
	Categories []Category `oscript:"AttributeGroups"`
	// contains filtered or unexported fields
}

func (Metadata) Find

func (m Metadata) Find(name string) *Category

Find finds category by display name.

type NameValueType

type NameValueType struct {
	Name  string
	Value []interface{}
	Type  TypeValue
}

func AttrBool

func AttrBool(name string, v bool) NameValueType

func AttrInt

func AttrInt(name string, v int) NameValueType

func AttrNil

func AttrNil(name string) NameValueType

func AttrString

func AttrString(name string, v string) NameValueType

func AttrTime

func AttrTime(name string, v time.Time) NameValueType

type Node

type Node struct {
	Catalog         int32               `oscript:"Catalog,omitempty"`
	Comment         string              `oscript:"Comment"`
	ContainerInfo   NodeContainerInfo   `oscript:"ContainerInfo"`
	CreateDate      time.Time           `oscript:"CreateDate,omitempty"`
	CreatedBy       int32               `oscript:"CreatedBy,omitempty"`
	DisplayType     string              `oscript:"DisplayType"`
	Feature         []Feature           `oscript:"Features"`
	ID              int64               `oscript:"ID"`
	IsContainer     bool                `oscript:"IsContainer"`
	IsReference     bool                `oscript:"IsReference"`
	IsReservable    bool                `oscript:"IsReservable"`
	IsVersional     bool                `oscript:"IsVersionable"`
	Metadata        Metadata            `oscript:"Metadata"`
	ModifyDate      time.Time           `oscript:"ModifyDate,omitempty"`
	Name            string              `oscript:"Name"`
	Nickname        string              `oscript:"Nickname,omitempty"`
	Parent          int64               `oscript:"ParentID"`
	PartialData     bool                `oscript:"PartialData"`
	Permissions     Permissions         `oscript:"Permissions"`
	Position        int64               `oscript:"Position,omitempty"`
	ReferenceInfo   NodeReferenceInfo   `oscript:"ReferenceInfo"`
	Released        bool                `oscript:"Released"`
	ReservationInfo NodeReservationInfo `oscript:"ReservationInfo"`
	Type            string              `oscript:"Type"`
	VersionInfo     NodeVersionInfo     `oscript:"VersionInfo"`
	VolumeID        int64               `oscript:"VolumeID"`
	// contains filtered or unexported fields
}

type NodeContainerInfo

type NodeContainerInfo struct {
	ChildCount int      `oscript:"ChildCount"`
	ChildTypes []string `oscript:"ChildTypes"`
	// contains filtered or unexported fields
}

type NodeReferenceInfo

type NodeReferenceInfo struct {
	OriginalID   int64  `oscript:"OriginalID"`
	OriginalType string `oscript:"OriginalType"`
	VersionNum   int64  `oscript:"VersionNum,omitempty"`
	// contains filtered or unexported fields
}

type NodeReservationInfo

type NodeReservationInfo struct {
	Reserved     bool       `oscript:"Reserved"`
	ReservedBy   int64      `oscript:"ReservedBy"`
	ReservedDate *time.Time `oscript:"ReservedDate,omitempty"`
	// contains filtered or unexported fields
}

type NodeRetrievalError

type NodeRetrievalError struct {
	*client.OpError
	// contains filtered or unexported fields
}

func (*NodeRetrievalError) NotFound

func (re *NodeRetrievalError) NotFound() bool

type NodeRight

type NodeRight struct {
	ID   int64       `oscript:"RightID"`
	Type string      `oscript:"Type"` // "ACL", "OwnerGroup", "Owner", "Public" - may be set enum?
	Perm Permissions `oscript:"Permissions"`
	// contains filtered or unexported fields
}

type NodeRights

type NodeRights struct {
	ACLRights       []NodeRight `oscript:"ACLRights"`
	OwnerGroupRight NodeRight   `oscript:"OwnerGroupRight"`
	OwnerRight      NodeRight   `oscript:"OwnerRight"`
	PublicRight     NodeRight   `oscript:"PublicRight"`
	// contains filtered or unexported fields
}

type NodeVersionInfo

type NodeVersionInfo struct {
	AdvancedVersionControl         bool      `oscript:"AdvancedVersionControl"`
	FileDataSize                   int64     `oscript:"FileDataSize"`
	FileResSize                    int64     `oscript:"FileResSize"`
	Major                          int64     `oscript:"Major"`
	MimeType                       string    `oscript:"MimeType"`
	SupportsAdvancedVersionControl bool      `oscript:"SupportsAdvancedVersionControl"`
	VersionNum                     int64     `oscript:"VersionNum"`
	Versions                       []Version `oscript:"Versions"`
	VersionsToKeep                 int       `oscript:"VersionsToKeep"`
	// contains filtered or unexported fields
}

type Permissions

type Permissions struct {
	See        bool `oscript:"SeePermission"`
	SeeContent bool `oscript:"SeeContentsPermission"`
	Modify     bool `oscript:"ModifyPermission"`
	EditAttr   bool `oscript:"EditAttributesPermission"`
	EditPerm   bool `oscript:"EditPermissionsPermission"`
	DeleteVer  bool `oscript:"DeleteVersionsPermission"`
	Delete     bool `oscript:"DeletePermission"`
	Reserve    bool `oscript:"ReservePermission"`
	Create     bool `oscript:"AddItemsPermission"`
	// contains filtered or unexported fields
}

type Session

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

Session a information about authentication user.

func (*Session) AddNodeRight

func (s *Session) AddNodeRight(ctx context.Context, id int64, right NodeRight) error

func (*Session) AddVersionFile

func (s *Session) AddVersionFile(ctx context.Context, file *FileAttr, r io.Reader) error

AddVersionFile adds new version of the file.

func (*Session) Call

func (s *Session) Call(ctx context.Context, serviceMethod string, args oscript.M, reply interface{}) error

Call invokes the service function, waits for it to complete, and returns its error status.

func (*Session) CreateDocument

func (s *Session) CreateDocument(ctx context.Context, doc Document) error

CreateDocument creates document.

func (*Session) CreateFile

func (s *Session) CreateFile(ctx context.Context, parent int64, name string, file *FileAttr, r io.Reader) error

CreateFile creates a document.

func (*Session) CreateFolder

func (s *Session) CreateFolder(ctx context.Context, parentID int64, name, comment string, metadata Metadata) (*Node, error)

CreateFolder creates folder.

func (*Session) CreateGroup

func (s *Session) CreateGroup(ctx context.Context, name string, leaderID *string) (int64, error)

CreateGroup creates group.

func (*Session) CreateNode

func (s *Session) CreateNode(ctx context.Context, node *Node) error

CreateNode creates node.

func (*Session) Debug

func (s *Session) Debug(w io.Writer) *Session

Debug wraps dialer in debug.

func (*Session) DeleteNode

func (s *Session) DeleteNode(ctx context.Context, id int64) error

DeleteNode deletes node.

func (*Session) GetCategory

func (s *Session) GetCategory(ctx context.Context, id int64) (*Category, error)

GetCategory gets category.

func (*Session) GetNode

func (s *Session) GetNode(ctx context.Context, id int64) (*Node, error)

GetNode gets node

func (*Session) GetNodeByNickname

func (s *Session) GetNodeByNickname(ctx context.Context, nickname string) (*Node, error)

GetNodeByNickname gets node by nickname.

func (*Session) GetNodeRights

func (s *Session) GetNodeRights(ctx context.Context, id int64) (*NodeRights, error)

func (*Session) GetSessionExpiration

func (s *Session) GetSessionExpiration(ctx context.Context) (time.Time, error)

GetSessionExpiration returns expiration time.

func (*Session) GetToken

func (s *Session) GetToken(ctx context.Context, username, password string) (string, error)

GetToken creates token.

func (*Session) ReadFile

func (s *Session) ReadFile(ctx context.Context, id, version int64, w io.Writer) (*FileAttr, error)

ReadFile reads content and returns information about the file.

func (*Session) RefreshToken

func (s *Session) RefreshToken(ctx context.Context) (string, error)

RefreshToken refreshes or creates token.

func (*Session) RemoveNodeRight

func (s *Session) RemoveNodeRight(ctx context.Context, id int64, right NodeRight) error

func (*Session) RenameNode

func (s *Session) RenameNode(ctx context.Context, id int64, name string) error

RenameNode renames node.

func (*Session) ReserveNode

func (s *Session) ReserveNode(ctx context.Context, id int64, user int64) error

ReserveNode reserves node.

func (*Session) UnreserveNode

func (s *Session) UnreserveNode(ctx context.Context, id int64) error

UnreserveNode unreserves node.

func (*Session) UpdateNode

func (s *Session) UpdateNode(ctx context.Context, node *Node) error

UpdateNode updates node. Checks on update Catalog, Comment, Name, Position. Always updates the fields Metadata, Nickname.

func (*Session) UpdateNodeRight

func (s *Session) UpdateNodeRight(ctx context.Context, id int64, right NodeRight) error

func (*Session) UpdateVersion

func (s *Session) UpdateVersion(ctx context.Context, v Version) error

UpdateVersion updates version. Checks on update Comment, MimeType.

type TypeValue

type TypeValue int
const (
	NilType TypeValue = iota
	StringType
	IntType
	BoolType
	TimeType
)

func (TypeValue) MarshalOscript

func (t TypeValue) MarshalOscript() ([]byte, error)

func (TypeValue) String

func (t TypeValue) String() string

func (*TypeValue) UnmarshalOscript

func (t *TypeValue) UnmarshalOscript(b []byte) error

type Value

type Value struct {
	Description string        `oscript:"Description"`
	Key         string        `oscript:"Key"`
	Value       []interface{} `oscript:"Values"`

	Type TypeValue `oscript:"_SDOName"`
}

Value is the attributes of the category.

type Version

type Version struct {
	Comment        string    `oscript:"Comment"`
	CreateDate     time.Time `oscript:"CreateDate"`
	FileCreateDate time.Time `oscript:"FileCreateDate"`
	FileCreator    string    `oscript:"FileCreator"`
	FileDataSize   int64     `oscript:"FileDataSize"`
	FileModifyDate time.Time `oscript:"FileModifyDate"`
	FileName       string    `oscript:"Filename"`
	FilePlatform   int       `oscript:"FilePlatform"`
	FileResSize    int64     `oscript:"FileResSize"`
	FileType       string    `oscript:"FileType"`
	ID             int64     `oscript:"ID"`
	Locked         int       `oscript:"Locked"`
	LockedBy       int64     `oscript:"LockedBy,omitempty"`
	LockedDate     time.Time `oscript:"LockedDate"`
	Metadata       Metadata  `oscript:"Metadata"`
	MimeType       string    `oscript:"MimeType"`
	ModifyDate     time.Time `oscript:"ModifyDate"`
	Name           string    `oscript:"Name"`
	NodeID         int64     `oscript:"NodeID"`
	Number         int64     `oscript:"Number"`
	Owner          int64     `oscript:"Owner"`
	ProviderID     int64     `oscript:"ProviderID"`
	ProviderName   string    `oscript:"ProviderName"`
	Type           string    `oscript:"Type"`
	VerMajor       int64     `oscript:"VerMajor"`
	VerMinor       int64     `oscript:"VerMinor"`
	// contains filtered or unexported fields
}

Directories

Path Synopsis
example
internal
pkg

Jump to

Keyboard shortcuts

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