api

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2020 License: MIT, MIT Imports: 9 Imported by: 0

Documentation

Overview

Package api exposes the functions that comprise the Strongsalt Go API. It consists of high-level wrapper functions around GRPC function calls.

Index

Constants

View Source
const (
	AdminName     = "adminUserName"
	AdminPassword = "adminUserPassword"
	AdminEmail    = "[email protected]"
	Organization  = "OrganizationOne"
)

Variables

This section is empty.

Functions

func AddSharableOrg added in v0.1.8

func AddSharableOrg(token, orgId string) (success bool, err error)

AddSharableOrg adds a sharable Organization.

func DecryptDocument

func DecryptDocument(token, docID string, ciphertext []byte) (plaintext []byte, err error)

DecryptDocument encrypts a document with Strongdoc. It requires original ciphertext, since the document is not stored

func DecryptDocumentStream added in v0.1.8

func DecryptDocumentStream(token string, docId string) (ec decryptStream, err error)

func DemoteUser added in v0.1.8

func DemoteUser(token, userId string) (success bool, err error)

DemoteUser demotes an administrator to regular user level. privilege level.

Requires administrator privileges.

func DownloadDocument

func DownloadDocument(token string, docID string) (plaintext []byte, err error)

DownloadDocument downloads a document stored in Strongdoc-provided storage.

func EncryptDocument

func EncryptDocument(token string, docName string, plaintext []byte) (docID string, ciphertext []byte, err error)

EncryptDocument encrypts a document with Strongdoc and returns the encrypted ciphertext. No data is ever written to storage on Strongdoc servers.

func EncryptDocumentStream added in v0.1.8

func EncryptDocumentStream(token string, docName string) (ec encryptStream, err error)

EncryptDocument returns an object that implements io.Reader and io.Writer. Write your document and Read the returned encrypted ciphertext. No data is ever written to storage on Strongdoc servers.

func GetConfiguration added in v0.1.8

func GetConfiguration(token string) (config string, err error)

GetConfiguration returns a string representing the configurations set.

func GetDocumentsSize added in v0.1.8

func GetDocumentsSize(token string) (size uint64, err error)

GetDocumentsSize returns the size of all the documents of the organization.

func GetIndexSize added in v0.1.8

func GetIndexSize(token string) (size int64, err error)

GetIndexSize returns the size of all the indexes of the organization.

func Login

func Login(userID, password, orgID string) (string, error)

Login logs the user in, returning a Bearer Token. This token must henceforth be sent with all requests in the same session.

func Logout

func Logout(token string) (status string, err error)

Logout retires the Bearer token in use, ending the session.

func PromoteUser added in v0.1.8

func PromoteUser(token, userId string) (success bool, err error)

PromoteUser promotes a regular user to administrator privilege level.

Requires administrator privileges.

func RegisterOrganization

func RegisterOrganization(orgName, orgAddr, adminName, adminPassword, adminEmail string) (orgID, adminID string, err error)

RegisterOrganization creates an organization. The user who created the organization is automatically an administrator.

func RegisterUser added in v0.1.8

func RegisterUser(token, user, pass, email string, admin bool) (userId string, err error)

Creates new user if it doesn't already exist. Trying to create a user with an existing username throws an error.

Requires administrator privileges.

func RemoveDocument

func RemoveDocument(token, docID string) error

RemoveDocument deletes a document from Strongdoc-provided storage. If you are a regular user, you may only remove a document that belongs to you. If you are an administrator, you can remove all the documents of the organization for which you are an administrator.

func RemoveOrganization

func RemoveOrganization(token string) (success bool, err error)

RemoveOrganization removes an organization, and all of its users, documents, and other data that it owns.

Requires administrator privileges.

func RemoveSharableOrg added in v0.1.8

func RemoveSharableOrg(token, orgId string) (success bool, err error)

RemoveSharableOrg removes a sharable Organization.

func RemoveUser added in v0.1.8

func RemoveUser(token, user string) (count int64, err error)
func Search(token, query string) ([]*proto.DocumentResult, error)

Search searches for the queries in the uploaded and encrypted documents. The list of document IDs and scores are included in the result.

func SetMultiLevelSharing added in v0.1.8

func SetMultiLevelSharing(token string, enable bool) (success bool, err error)

SetMultiLevelSharing sets MultiLevel Sharing.

func ShareDocument added in v0.1.8

func ShareDocument(token, docId, userId string) (success bool, err error)

func UnshareDocument added in v0.1.8

func UnshareDocument(token, docId, userId string) (count int64, err error)

UnshareDocument rescinds permission earlier granted for other users to access their documents.

func UploadDocument

func UploadDocument(token string, docName string, plaintext []byte) (docID string, err error)

UploadDocument uploads a document to Strongdoc-provided storage.

func UploadDocumentStream

func UploadDocumentStream(token string, docName string, reader *bytes.Reader) (docID string, err error)

UploadDocumentStream accepts a reader and reads from it until it ends. Incomplete downloads will not be completed.

Types

type BillingDetails added in v0.1.8

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

func Billing added in v0.1.8

func Billing(token string) (bd BillingDetails)

func (*BillingDetails) CurrentPeriod added in v0.1.8

func (bd *BillingDetails) CurrentPeriod() (CurrentPeriod *BillingPeriod, err error)

func (*BillingDetails) Documents added in v0.1.8

func (bd *BillingDetails) Documents() (bdoc *BillingDocuments, err error)

func (*BillingDetails) Index added in v0.1.8

func (bd *BillingDetails) Index() (bi *BillingIndex, err error)

func (*BillingDetails) NextPeriod added in v0.1.8

func (bd *BillingDetails) NextPeriod() (bp *BillingPeriod, err error)

func (*BillingDetails) TotalCost added in v0.1.8

func (bd *BillingDetails) TotalCost() (TotalCost int32, err error)

func (*BillingDetails) Traffic added in v0.1.8

func (bd *BillingDetails) Traffic() (bt *BillingTraffic, err error)

type BillingDocuments added in v0.1.8

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

func (*BillingDocuments) Cost added in v0.1.8

func (d *BillingDocuments) Cost() int32

func (*BillingDocuments) Size added in v0.1.8

func (d *BillingDocuments) Size() float64

type BillingIndex added in v0.1.8

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

func (*BillingIndex) Cost added in v0.1.8

func (i *BillingIndex) Cost() int32

func (*BillingIndex) Size added in v0.1.8

func (i *BillingIndex) Size() int64

type BillingPeriod added in v0.1.8

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

func (*BillingPeriod) Frequency added in v0.1.8

func (bp *BillingPeriod) Frequency() string

func (*BillingPeriod) PeriodEnd added in v0.1.8

func (bp *BillingPeriod) PeriodEnd() *timestamp.Timestamp

func (*BillingPeriod) PeriodStart added in v0.1.8

func (bp *BillingPeriod) PeriodStart() *timestamp.Timestamp

type BillingTraffic added in v0.1.8

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

func (*BillingTraffic) Cost added in v0.1.8

func (t *BillingTraffic) Cost() int32

func (*BillingTraffic) Incoming added in v0.1.8

func (t *BillingTraffic) Incoming() float64

func (*BillingTraffic) Outgoing added in v0.1.8

func (t *BillingTraffic) Outgoing() float64

type Documents added in v0.1.8

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

func ListDocuments added in v0.1.8

func ListDocuments(token string) (docs Documents, err error)

ListDocuments returns a slice of Document objects, representing the documents accessible by the user.

type S3Stream added in v0.1.8

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

func DownloadDocumentStream added in v0.1.8

func DownloadDocumentStream(token string, docID string) (s3stream S3Stream, err error)

DownloadDocumentStream generates an S3Stream object, which implements the io.Reader interface. It contains a client which maintains a connection to Strongdoc-provided storage. Returns 0, EOF iff the stream has been exhausted.

func (*S3Stream) Read added in v0.1.8

func (stream *S3Stream) Read(p []byte) (n int, err error)

TODO: handle empty p Read reads the length of the stream. It assumes that the stream from server still has data or that the internal buffer still has some data in it.

Notes

Bugs

  • for some reason, stream crashes when 0 bytes are available in the stream.

Jump to

Keyboard shortcuts

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