api

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: MIT, MIT Imports: 10 Imported by: 1

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

This section is empty.

Variables

This section is empty.

Functions

func AddSharableOrg

func AddSharableOrg(sdc client.StrongDocClient, orgID string) (success bool, err error)

AddSharableOrg adds a sharable Organization.

func DecryptDocument

func DecryptDocument(sdc client.StrongDocClient, docID string, cipherText []byte) (plaintext []byte, err error)

DecryptDocument decrypts a document with Strongdoc and returns the plaintext. It accepts a the cipherText and its docId.

func DecryptDocumentStream

func DecryptDocumentStream(sdc client.StrongDocClient, docID string, cipherStream io.Reader) (plainStream io.Reader, err error)

DecryptDocumentStream decrypts any document previously decrypted with Strongdoc and makes the plaintext available via an io.Reader interface. It accepts an io.Reader, which should contain the ciphertext, and you must also pass in its docID.

It then returns an io.Reader object that contains the plaintext of the Reqed document.

func DemoteUser

func DemoteUser(sdc client.StrongDocClient, userID string) (success bool, err error)

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

Requires administrator privileges.

func DownloadDocument

func DownloadDocument(sdc client.StrongDocClient, docID string) (plaintext []byte, err error)

DownloadDocument downloads a document stored in Strongdoc-provided storage. You must provide it with its docID.

func DownloadDocumentStream

func DownloadDocumentStream(sdc client.StrongDocClient, docID string) (plainStream io.Reader, err error)

DownloadDocumentStream decrypts any document previously stored on Strongdoc-provided storage, and makes the plaintext available via an io.Reader interface. You must also pass in its docId.

It then returns an io.Reader object that contains the plaintext of the Reqed document.

func EncryptDocument

func EncryptDocument(sdc client.StrongDocClient, docName string, plaintext []byte) (docID string, ciphertext []byte, err error)

EncryptDocument encrypts a document with Strongdoc and returns the encrypted ciphertext without storing it on any storage. It accepts a the plaintext and the document name. The returned docId uniquely identifies the document.

func EncryptDocumentStream

func EncryptDocumentStream(sdc client.StrongDocClient, docName string, plainStream io.Reader) (cipherStream io.Reader, docID string, err error)

EncryptDocumentStream encrypts a document with Strongdoc and makes the encrypted ciphertext available via an io.Reader interface. It accepts an io.Reader (which should contain the plaintext) and the document name.

It then returns an io.Reader object that contains the ciphertext of the Reqed document, and a docID that uniquely identifies the document.

func Login

func Login(sdc client.StrongDocClient, userID, password, orgID string) (token string, err error)

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

func Logout

func Logout(sdc client.StrongDocClient) (status string, err error)

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

func PromoteUser

func PromoteUser(sdc client.StrongDocClient, userID string) (success bool, err error)

PromoteUser promotes a regular user to administrator privilege level.

Requires administrator privileges.

func RegisterOrganization

func RegisterOrganization(sdc client.StrongDocClient, orgName, orgAddr, orgEmail, adminName, adminPassword,
	adminEmail, source, sourceData string) (orgID, adminID string, err error)

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

func RegisterUser

func RegisterUser(sdc client.StrongDocClient, user, pass, email string, admin bool) (userID string, err error)

RegisterUser 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(sdc client.StrongDocClient, 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(sdc client.StrongDocClient, force bool) (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

func RemoveSharableOrg(sdc client.StrongDocClient, orgID string) (success bool, err error)

RemoveSharableOrg removes a sharable Organization.

func RemoveUser

func RemoveUser(sdc client.StrongDocClient, user string) (count int64, err error)

RemoveUser removes the user from the organization. The users documents still exist, but belong to the organization, only accessible by the admin of their former organization.

Requires administrator privileges.

func SetMultiLevelSharing

func SetMultiLevelSharing(sdc client.StrongDocClient, enable bool) (success bool, err error)

SetMultiLevelSharing sets MultiLevel Sharing.

func ShareDocument

func ShareDocument(sdc client.StrongDocClient, docID, userID string) (success bool, err error)

ShareDocument shares the document with other users. Note that the user that you are sharing with be be in an organization that has been declared available for sharing with the Add Sharable Organizations function.

func UnshareDocument

func UnshareDocument(sdc client.StrongDocClient, docID, userID string) (count int64, err error)

UnshareDocument rescinds permission granted earlier, removing other users' access to those documents.

func UploadDocument

func UploadDocument(sdc client.StrongDocClient, docName string, plaintext []byte) (docID string, err error)

UploadDocument uploads a document to Strongdoc-provided storage. It then returns a docId that uniquely identifies the document.

func UploadDocumentStream

func UploadDocumentStream(sdc client.StrongDocClient, docName string, plainStream io.Reader) (docID string, err error)

UploadDocumentStream encrypts a document with Strongdoc and stores it in Strongdoc-provided storage. It accepts an io.Reader (which should contain the plaintext) and the document name.

It then returns a docID that uniquely identifies the document.

Types

type AccountInfo added in v0.1.12

type AccountInfo struct {
	// Account's orgID
	OrgID string
	// Account's subscription info
	Subscription *Subscription
	// List of all account's payments
	Payments []*Payment
	// The address of the organization
	OrgAddress string
	// The ability to "reshare" a document that was shared to him/her to another user
	MultiLevelShare bool
	// The list of sharable organization IDs.
	SharableOrgs []string
}

AccountInfo is info on the organization account

func GetAccountInfo added in v0.1.12

func GetAccountInfo(sdc client.StrongDocClient) (*AccountInfo, error)

GetAccountInfo obtain information about the account

type BillingDetails

type BillingDetails struct {
	// Start of the requested billing period
	PeriodStart time.Time
	// End of the requested billing period
	PeriodEnd time.Time
	// Total cost incurred during the requested billing period
	TotalCost float64
	// Usage and cost breakdown for stored documents
	Documents *DocumentCosts
	// Usage and cost breakdown for stored search indices
	Search *SearchCosts
	// Usage and cost breakdown for used traffic
	Traffic *TrafficCosts
}

BillingDetails stores the billing details for the organization

func GetBillingDetails added in v0.1.12

func GetBillingDetails(sdc client.StrongDocClient) (bill *BillingDetails, err error)

GetBillingDetails list all items of the cost breakdown and also other details such as the billing frequency

type BillingFrequency added in v0.1.12

type BillingFrequency struct {
	// Billing frequency
	Frequency proto.TimeInterval
	// Start fo billing frequency validity
	ValidFrom *time.Time
	// End of billing frequency validity
	ValidTo *time.Time
}

BillingFrequency shows the billing frequency information

func GetBillingFrequencyList added in v0.1.12

func GetBillingFrequencyList(sdc client.StrongDocClient) ([]*BillingFrequency, error)

GetBillingFrequencyList obtains the list of billing frequencies (past, current and future)

func SetNextBillingFrequency added in v0.1.12

func SetNextBillingFrequency(sdc client.StrongDocClient, freq proto.TimeInterval, validFrom time.Time) (*BillingFrequency, error)

SetNextBillingFrequency changes the next billing frequency

type DocActionHistory added in v0.1.14

type DocActionHistory struct {
	// The document ID.
	DocID string

	UserID string
	// The document name.
	DocName string

	ActionTime timestamp.Timestamp

	ActionType string

	OtherUserID string
}

DocActionHistory contains the document information

func ListDocActionHistory added in v0.1.14

func ListDocActionHistory(sdc client.StrongDocClient) ([]DocActionHistory, int32, int32, error)

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

type Document added in v0.1.12

type Document struct {
	// The document ID.
	DocID string
	// The document name.
	DocName string
	// The document size.
	Size uint64
}

Document contains the document information

func ListDocuments

func ListDocuments(sdc client.StrongDocClient) (docs []Document, err error)

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

type DocumentCosts added in v0.1.12

type DocumentCosts struct {
	// Cost of document storage incurred during a billing period
	Cost float64
	// Size of documents stored during a billing period (in MBhours)
	Size float64
	// Cost tier reached for document storage during a billing period
	Tier string
}

DocumentCosts stores the document cost portion of the bill

type DocumentResult added in v0.1.12

type DocumentResult struct {
	// The document ID that contains the query terms.
	DocID string
	// The score of the search result.
	Score float64
}

DocumentResult contains the document search result

func Search(sdc client.StrongDocClient, query string) ([]*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.

type LargeTraffic added in v0.1.12

type LargeTraffic struct {
	// Details of large traffic events
	LargeTraffic []*TrafficDetail
	// Start of the requested billing period
	PeriodStart time.Time
	// End of the requested billing period
	PeriodEnd time.Time
}

LargeTraffic contains the large traffic data

func GetLargeTraffic added in v0.1.12

func GetLargeTraffic(sdc client.StrongDocClient, at time.Time) (*LargeTraffic, error)

GetLargeTraffic obtains the list of large traffic usages

type Payment added in v0.1.12

type Payment struct {
	// Timestamp of the payment billing transaction
	BilledAt *time.Time
	// Start of the payment period
	PeriodStart *time.Time
	// End of the payment period
	PeriodEnd *time.Time
	// Amount of  payment
	Amount float64
	// Payment status ("No Payment","Zero Payment","Payment Pending","Payment Success","Payment Failed")
	Status string
}

Payment is the payment information for the organization

type SearchCosts added in v0.1.12

type SearchCosts struct {
	// Cost of search index storage incurred during a billing period
	Cost float64
	// Size of search indices stored during a billing period (in MBhours)
	Size float64
	// Cost tier reached for search index storage during a billing period
	Tier string
}

SearchCosts stores the search cost portion of the bill

type Subscription added in v0.1.12

type Subscription struct {
	// Subscription type (AWS Marketplace, Credit Card, etc.)
	Type string
	// State of the subscription (Created, Subscribed, Unsubscribed, etc.)
	Status string
}

Subscription is the subscript type of the organization

type TrafficCosts added in v0.1.12

type TrafficCosts struct {
	// Cost of network traffic incurred during a billing period
	Cost float64
	// Size of incoming requests during a billing period (in MB)
	Incoming float64
	// Size of outgoing requests during a billing period (in MB)
	Outgoing float64
	// Cost tier reached for network traffic during a billing period
	Tier string
}

TrafficCosts stores the traffic coast portion of the bill

type TrafficDetail added in v0.1.12

type TrafficDetail struct {
	// Timestamp of the large traffic event
	Time time.Time
	// The ID of the user who made the request
	UserID string
	// HTTP method of the request
	Method string
	// URI called by the request
	URI string
	// Size of the request (in MB)
	Incoming float64
	// Size of the response (in MB)
	Outgoing float64
}

TrafficDetail contains the traffic detail

type User added in v0.1.12

type User struct {
	UserName string
	UserID   string
	IsAdmin  bool
}

User is the user of the organization

func ListUsers added in v0.1.12

func ListUsers(sdc client.StrongDocClient) (users []User, err error)

ListUsers lists the users of the organization

type UserInfo added in v0.1.12

type UserInfo struct {
	// The user's userID
	UserID string
	// The user's email
	Email string
	// The user's name
	UserName string
	// The user's orgID
	OrgID string
	// Whether the user is an admin
	IsAdmin bool
}

UserInfo is info on the user account

func GetUserInfo added in v0.1.12

func GetUserInfo(sdc client.StrongDocClient) (*UserInfo, error)

GetUserInfo obtain information about logged user

Jump to

Keyboard shortcuts

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