documents

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package documents provides a way to read and write documents

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToURIs added in v0.3.3

func ToURIs(docs []*DocumentDescription) []string

ToURIs returns a slice of URIs from a slice of DocumentDescription types

Types

type Collections

type Collections struct {
	Values []string `xml:"http://marklogic.com/rest-api collection" json:"-"`
}

Collections describes collections a document belongs to

type DocumentDescription

type DocumentDescription struct {
	URI       string
	Content   io.ReadWriter
	Metadata  *Metadata
	Format    int
	VersionID int
}

DocumentDescription describes a document to write

func (*DocumentDescription) GetFormat

func (dd *DocumentDescription) GetFormat() int

GetFormat returns int that represents XML or JSON

type Metadata

type Metadata struct {
	*bytes.Buffer
	XMLName        xml.Name                   `xml:"http://marklogic.com/rest-api metadata" json:"-"`
	Collections    []string                   `xml:"http://marklogic.com/rest-api collections" json:"collections,omitempty"`
	Permissions    []Permission               `xml:"http://marklogic.com/rest-api permissions" json:"permissions,omitempty"`
	Properties     util.SerializableStringMap `xml:"http://marklogic.com/xdmp/property properties" json:"properties,omitempty"`
	MetadataValues util.SerializableStringMap `xml:"http://marklogic.com/rest-api metadata-values" json:"metadataValues,omitempty"`
	Quality        int                        `xml:"http://marklogic.com/rest-api quality" json:"quality,omitempty"`
}

Metadata describes a document to write

func (*Metadata) PermissionsMap

func (m *Metadata) PermissionsMap() map[string]string

PermissionsMap associated with the MetadataHandle

type MetadataHandle

type MetadataHandle struct {
	*bytes.Buffer
	VersionID int
	Format    int
	// contains filtered or unexported fields
}

MetadataHandle describes a document to write

func (*MetadataHandle) Deserialize

func (mh *MetadataHandle) Deserialize(bytes []byte)

Deserialize returns Response struct that represents XML or JSON

func (*MetadataHandle) Deserialized

func (mh *MetadataHandle) Deserialized() interface{}

Deserialized returns Metadata as interface{}

func (*MetadataHandle) GetFormat

func (mh *MetadataHandle) GetFormat() int

GetFormat returns int that represents XML or JSON

func (*MetadataHandle) Serialize

func (mh *MetadataHandle) Serialize(metadata interface{})

Serialize returns []byte of XML or JSON that represents the Metadata struct

func (*MetadataHandle) Serialized

func (mh *MetadataHandle) Serialized() string

Serialized returns string of XML or JSON

func (*MetadataHandle) SetTimestamp

func (mh *MetadataHandle) SetTimestamp(timestamp string)

SetTimestamp sets the timestamp

func (*MetadataHandle) Timestamp

func (mh *MetadataHandle) Timestamp() string

Timestamp retieves a timestamp

type MetadataValue

type MetadataValue struct {
	XMLName xml.Name `xml:"http://marklogic.com/rest-api metadata-value" json:"-"`
	Key     string   `xml:"key,attr" json:"key,omitempty"`
	Value   string   `xml:",chardata" json:"value,omitempty"`
}

MetadataValue describes collections a document belongs to

type Permission

type Permission struct {
	XMLName    xml.Name `xml:"http://marklogic.com/rest-api permission" json:"-"`
	RoleName   string   `xml:"http://marklogic.com/rest-api role-name" json:"role-name,omitempty"`
	Capability []string `xml:"http://marklogic.com/rest-api capability" json:"capabilities,omitempty"`
}

Permission describes a permission assigned to a document

type Service

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

Service is used for the documents service

func NewService

func NewService(client *clients.Client) *Service

NewService returns a new documents.Service

func (*Service) Client

func (s *Service) Client() *clients.Client

Client associated with the documents service

func (*Service) Read

func (s *Service) Read(uris []string, categories []string, transform *util.Transform, transaction *util.Transaction, response handle.ResponseHandle) error

Read documents

func (*Service) Write

func (s *Service) Write(documents []*DocumentDescription, transform *util.Transform, transaction *util.Transaction, response handle.ResponseHandle) error

Write documents according to the DocumentDescription slice passed

func (*Service) WriteSet

func (s *Service) WriteSet(documents []*DocumentDescription, metadata handle.Handle, transform *util.Transform, transaction *util.Transaction, response handle.ResponseHandle) error

WriteSet documents according to the DocumentDescription slice passed

Jump to

Keyboard shortcuts

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