Documentation
¶
Index ¶
- Constants
- Variables
- func CreateDocumentFor(contents io.Reader, creator DocumentCreator, deleter DocumentDeleter, ...) error
- func GetFreeDocSlots(ctx context.Context, getter DocumentGetter, totalSlots int) (int, error)
- func NewTokenRetriever(httpClient net.HttpDoer, apiUrl string) auth.TokenRetriever
- type ApiClient
- type AuthorisingDoer
- type Classifier
- type ClassifierList
- type ClassifiersClient
- func (client *ClassifiersClient) Create(ctx context.Context, name string) error
- func (client *ClassifiersClient) Delete(ctx context.Context, name string) error
- func (client *ClassifiersClient) GetAll(ctx context.Context) (ClassifierList, error)
- func (client *ClassifiersClient) Train(ctx context.Context, name string, samplesArchive io.Reader) error
- func (client *ClassifiersClient) Upload(ctx context.Context, name string, contents io.Reader) error
- type CreateDocumentRequest
- type CreateReadProfileRequest
- type Document
- type DocumentClassifier
- type DocumentCreator
- type DocumentDeleter
- type DocumentExtractor
- type DocumentGetter
- type DocumentList
- type DocumentReader
- type DocumentRedactor
- type DocumentsClient
- func (client *DocumentsClient) Classify(ctx context.Context, documentId string, classifierName string, ...) (*results.ClassificationResult, error)
- func (client *DocumentsClient) Create(ctx context.Context, fileContents io.Reader) (Document, error)
- func (client *DocumentsClient) Delete(ctx context.Context, documentId string) error
- func (client *DocumentsClient) Extract(ctx context.Context, documentId string, extractorName string, ...) (*results.ExtractionResult, error)
- func (client *DocumentsClient) ExtractForRedaction(ctx context.Context, documentId string, extractorName string, ...) (*results.ExtractForRedactionResult, error)
- func (client *DocumentsClient) GetAll(ctx context.Context) (DocumentList, error)
- func (client *DocumentsClient) Read(ctx context.Context, documentId string, args ReadProfileArgs) error
- func (client *DocumentsClient) ReadResult(ctx context.Context, documentId string, mode ReadMode, args ReadProfileArgs) (io.ReadCloser, error)
- func (client *DocumentsClient) Redact(ctx context.Context, documentId string, ...) (io.ReadCloser, error)
- type Extractor
- type ExtractorList
- type ExtractorTemplate
- type ExtractorsClient
- func (client *ExtractorsClient) Create(ctx context.Context, name string, config io.Reader) error
- func (client *ExtractorsClient) CreateFromJson(ctx context.Context, name string, jsonTemplate io.Reader) error
- func (client *ExtractorsClient) CreateFromModules(ctx context.Context, name string, modules ExtractorTemplate) error
- func (client *ExtractorsClient) Delete(ctx context.Context, name string) error
- func (client *ExtractorsClient) GetAll(ctx context.Context) (ExtractorList, error)
- type FieldAliasTemplate
- type FileClassifier
- type FileExtractor
- type FileReader
- type FileRedactor
- type LoggingDoer
- type Module
- type ModuleList
- type ModuleTemplate
- type ModulesClient
- type ReadDocumentRequest
- type ReadMode
- type ReadProfile
- type ReadProfileArgs
- type ReadProfileCreator
- type ReadProfileDeleter
- type ReadProfileGetter
- type ReadProfileGetterDeleter
- type ReadProfileList
- type ReadProfilesClient
- type ResponseCheckingDoer
- type TrainClassifierRequest
Constants ¶
const ApiAddress = "https://api.aluma.io"
Variables ¶
var ErrDocSlotsFull = errors.New("all document slots are full")
var TotalDocumentSlots = 30
var Version = "version-local"
Functions ¶
func CreateDocumentFor ¶
func CreateDocumentFor(contents io.Reader, creator DocumentCreator, deleter DocumentDeleter, fn func(Document) error) error
CreateDocumentFor is a helper function that creates a document with a specified DocumentCreator, runs a provided function with the newly-created document, and then deletes the document. It does not accept a context.Context as it assumes the user would want neither the creation nor deletion to be interrupted, since that could lead to 'leaked' documents in aluma.
func GetFreeDocSlots ¶
GetFreeDocSlots is a helper function to retrieve the number of available document slots in aluma, and return an error if there are none.
func NewTokenRetriever ¶
func NewTokenRetriever(httpClient net.HttpDoer, apiUrl string) auth.TokenRetriever
Types ¶
type ApiClient ¶
type ApiClient struct {
Classifiers *ClassifiersClient
Documents *DocumentsClient
Extractors *ExtractorsClient
Modules *ModulesClient
ReadProfiles *ReadProfilesClient
}
type AuthorisingDoer ¶
type AuthorisingDoer struct {
// contains filtered or unexported fields
}
func NewAuthorisingDoer ¶
func NewAuthorisingDoer(retriever auth.TokenRetriever, httpDoer net.HttpDoer, clientId string, clientSecret string) *AuthorisingDoer
type Classifier ¶
type Classifier struct {
Name string
}
type ClassifierList ¶
type ClassifierList []Classifier
func (ClassifierList) Any ¶
func (classifiers ClassifierList) Any() bool
func (ClassifierList) Contains ¶
func (classifiers ClassifierList) Contains(item string) bool
type ClassifiersClient ¶
type ClassifiersClient struct {
// contains filtered or unexported fields
}
func NewClassifiersClient ¶
func NewClassifiersClient(baseUrl string, requestSender net.HttpDoer) *ClassifiersClient
func (*ClassifiersClient) Create ¶
func (client *ClassifiersClient) Create(ctx context.Context, name string) error
func (*ClassifiersClient) Delete ¶
func (client *ClassifiersClient) Delete(ctx context.Context, name string) error
func (*ClassifiersClient) GetAll ¶
func (client *ClassifiersClient) GetAll(ctx context.Context) (ClassifierList, error)
type CreateDocumentRequest ¶
type CreateDocumentRequest struct {
FileContents []byte
}
type CreateReadProfileRequest ¶
type CreateReadProfileRequest struct {
Languages []string `json:"languages"`
}
type DocumentClassifier ¶
type DocumentClassifier interface {
Classify(ctx context.Context, documentId string, classifierName string, args ReadProfileArgs) (*results.ClassificationResult, error)
}
type DocumentCreator ¶
type DocumentDeleter ¶
type DocumentExtractor ¶
type DocumentExtractor interface {
Extract(ctx context.Context, documentId string, extractorName string, args ReadProfileArgs) (*results.ExtractionResult, error)
ExtractForRedaction(ctx context.Context, documentId string, extractorName string, args ReadProfileArgs) (*results.ExtractForRedactionResult, error)
}
type DocumentGetter ¶
type DocumentGetter interface {
GetAll(ctx context.Context) (DocumentList, error)
}
type DocumentList ¶
type DocumentList []Document
type DocumentReader ¶
type DocumentReader interface {
Read(ctx context.Context, documentId string, args ReadProfileArgs) error
ReadResult(ctx context.Context, documentId string, mode ReadMode, args ReadProfileArgs) (io.ReadCloser, error)
}
type DocumentRedactor ¶
type DocumentRedactor interface {
Redact(ctx context.Context, documentId string, redactRequest request.RedactedPdfRequest) (io.ReadCloser, error)
}
type DocumentsClient ¶
type DocumentsClient struct {
// contains filtered or unexported fields
}
func NewDocumentsClient ¶
func NewDocumentsClient(baseUrl string, httpDoer net.HttpDoer) *DocumentsClient
func (*DocumentsClient) Classify ¶
func (client *DocumentsClient) Classify(ctx context.Context, documentId string, classifierName string, args ReadProfileArgs) (*results.ClassificationResult, error)
func (*DocumentsClient) Delete ¶
func (client *DocumentsClient) Delete(ctx context.Context, documentId string) error
func (*DocumentsClient) Extract ¶
func (client *DocumentsClient) Extract(ctx context.Context, documentId string, extractorName string, args ReadProfileArgs) (*results.ExtractionResult, error)
func (*DocumentsClient) ExtractForRedaction ¶
func (client *DocumentsClient) ExtractForRedaction(ctx context.Context, documentId string, extractorName string, args ReadProfileArgs) (*results.ExtractForRedactionResult, error)
ExtractForRedaction performs extracton on a document, and returns the results in a format the "get redacted pdf" http endpoint will accept, namely "application/vnd.waives.requestformats.redact+json".
func (*DocumentsClient) GetAll ¶
func (client *DocumentsClient) GetAll(ctx context.Context) (DocumentList, error)
func (*DocumentsClient) Read ¶
func (client *DocumentsClient) Read(ctx context.Context, documentId string, args ReadProfileArgs) error
func (*DocumentsClient) ReadResult ¶
func (client *DocumentsClient) ReadResult(ctx context.Context, documentId string, mode ReadMode, args ReadProfileArgs) (io.ReadCloser, error)
func (*DocumentsClient) Redact ¶
func (client *DocumentsClient) Redact(ctx context.Context, documentId string, redactRequest request.RedactedPdfRequest) (io.ReadCloser, error)
Redact requests a redacted PDF of the given document.
type ExtractorList ¶
type ExtractorList []Extractor
func (ExtractorList) Contains ¶
func (e ExtractorList) Contains(item string) bool
type ExtractorTemplate ¶
type ExtractorTemplate struct {
Modules []ModuleTemplate `json:"modules"`
}
func NewModulesTemplateFromJson ¶
func NewModulesTemplateFromJson(stream io.Reader) (*ExtractorTemplate, error)
type ExtractorsClient ¶
type ExtractorsClient struct {
// contains filtered or unexported fields
}
func NewExtractorsClient ¶
func NewExtractorsClient(baseUrl string, requestSender net.HttpDoer) *ExtractorsClient
func (*ExtractorsClient) CreateFromJson ¶
func (*ExtractorsClient) CreateFromModules ¶
func (client *ExtractorsClient) CreateFromModules(ctx context.Context, name string, modules ExtractorTemplate) error
func (*ExtractorsClient) Delete ¶
func (client *ExtractorsClient) Delete(ctx context.Context, name string) error
func (*ExtractorsClient) GetAll ¶
func (client *ExtractorsClient) GetAll(ctx context.Context) (ExtractorList, error)
type FieldAliasTemplate ¶
type FileClassifier ¶
type FileClassifier struct {
// contains filtered or unexported fields
}
func NewFileClassifier ¶
func NewFileClassifier(creator DocumentCreator, classifier DocumentClassifier, deleter DocumentDeleter) *FileClassifier
func (*FileClassifier) Classify ¶
func (f *FileClassifier) Classify(ctx context.Context, fileContents io.Reader, classifierName string, args ReadProfileArgs) (*results.ClassificationResult, error)
type FileExtractor ¶
type FileExtractor struct {
// contains filtered or unexported fields
}
func NewFileExtractor ¶
func NewFileExtractor(creator DocumentCreator, extractor DocumentExtractor, deleter DocumentDeleter) *FileExtractor
func (*FileExtractor) Extract ¶
func (f *FileExtractor) Extract(ctx context.Context, fileContents io.Reader, extractorName string, args ReadProfileArgs) (*results.ExtractionResult, error)
Extract creates a document, performs extraction, deletes the doc, then returns the extraction result.
type FileReader ¶
type FileReader struct {
// contains filtered or unexported fields
}
Helper struct which creates a document from a file, performs a read, downloads the read result, then deletes the document.
func NewFileReader ¶
func NewFileReader(creator DocumentCreator, reader DocumentReader, deleter DocumentDeleter) *FileReader
func (*FileReader) Read ¶
func (f *FileReader) Read(ctx context.Context, fileContents io.Reader, mode ReadMode, args ReadProfileArgs) (io.ReadCloser, error)
Read creates a document from fileContents, performs a read, then returns the read results in the format according to mode.
type FileRedactor ¶
type FileRedactor struct {
// contains filtered or unexported fields
}
func NewFileRedactor ¶
func NewFileRedactor(creator DocumentCreator, extractor DocumentExtractor, redactor DocumentRedactor, deleter DocumentDeleter) *FileRedactor
func (*FileRedactor) Redact ¶
func (f *FileRedactor) Redact(ctx context.Context, fileContents io.Reader, extractorName string, args ReadProfileArgs) (io.ReadCloser, error)
Redact creates a document from the fileContents, performs extraction on it, then redacts it with the results of the extraction.
type LoggingDoer ¶
type LoggingDoer struct {
// contains filtered or unexported fields
}
LoggingDoer is an HttpDoer decorator that logs all HTTP requests and responses to the specified io.Writer. It indents any json request / response bodies, and redacts any non-json bodies.
func NewLoggingDoer ¶
func NewLoggingDoer(httpDoer net.HttpDoer, out io.Writer) *LoggingDoer
type Module ¶
type Module struct {
ID string `json:"id"`
Name string `json:"name"`
Summary string `json:"summary"`
Description string `json:"description"`
Fields []struct {
Name string `json:"name"`
Description interface{} `json:"description"`
} `json:"fields"`
Parameters []struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
Required bool `json:"required"`
} `json:"parameters"`
}
type ModuleList ¶
type ModuleList []Module
func (ModuleList) Find ¶
func (l ModuleList) Find(id string) *Module
Find performs a case-insensitive search for the provided ID string, and returns the Module if found and nil if not.
type ModuleTemplate ¶
type ModuleTemplate struct {
ID string `json:"id"`
Arguments map[string]interface{} `json:"arguments,omitempty"`
FieldAliases []FieldAliasTemplate `json:"field_aliases,omitempty"`
}
type ModulesClient ¶
type ModulesClient struct {
// contains filtered or unexported fields
}
func NewModulesClient ¶
func NewModulesClient(baseUrl string, requestSender net.HttpDoer) *ModulesClient
func (*ModulesClient) GetAll ¶
func (m *ModulesClient) GetAll(ctx context.Context) (ModuleList, error)
type ReadDocumentRequest ¶
type ReadDocumentRequest struct {
ProfileName string `json:"read_profile"`
}
type ReadProfile ¶
type ReadProfileArgs ¶
type ReadProfileCreator ¶
type ReadProfileDeleter ¶
type ReadProfileGetter ¶
type ReadProfileGetter interface {
GetAll(ctx context.Context) (ReadProfileList, error)
}
type ReadProfileGetterDeleter ¶
type ReadProfileGetterDeleter interface {
ReadProfileGetter
ReadProfileDeleter
}
type ReadProfileList ¶
type ReadProfileList []ReadProfile
func (*ReadProfileList) Contains ¶
func (l *ReadProfileList) Contains(name string) bool
type ReadProfilesClient ¶
type ReadProfilesClient struct {
// contains filtered or unexported fields
}
func NewReadProfilesClient ¶
func NewReadProfilesClient(baseUrl string, httpDoer net.HttpDoer) *ReadProfilesClient
func (*ReadProfilesClient) Create ¶
func (client *ReadProfilesClient) Create(ctx context.Context, name string, languages []string) (ReadProfile, error)
func (*ReadProfilesClient) Delete ¶
func (client *ReadProfilesClient) Delete(ctx context.Context, name string) error
func (*ReadProfilesClient) GetAll ¶
func (client *ReadProfilesClient) GetAll(ctx context.Context) (ReadProfileList, error)
type ResponseCheckingDoer ¶
type ResponseCheckingDoer struct {
// contains filtered or unexported fields
}
func NewResponseCheckingdoer ¶
func NewResponseCheckingdoer(checker net.ResponseChecker, wrappedSender net.HttpDoer) *ResponseCheckingDoer