strongdoc.api package

account module

class strongdoc.api.account.AccountInfo(proto_account_info)[source]

Bases: object

orgid

str

org_email

str

subscription

Subscription

payments

list(Payment)

org_address

str

multilevel_sharing

bool

sharable_orgs

list(str)

class strongdoc.api.account.Payment(proto_payment)[source]

Bases: object

billed_at

datetime.datetime

period_start

datetime.datetime

period_end

datetime.datetime

amount

float

status

str

class strongdoc.api.account.Subscription(proto_subscription)[source]

Bases: object

type

str

status

str

class strongdoc.api.account.UserInfo(proto_user)[source]

Bases: object

userid

str

name

str

email

optional str, otherwise None

orgid

optional str, otherwise None

is_admin

bool

strongdoc.api.account.add_sharable_org(token, orgid)[source]

Adds another org as a sharable org. This requires an administrator privilege.

Parameters:
  • token (str) – The user JWT token.
  • orgid (str) – The orgid of the org to add as a sharable org.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

Whether the addition was a success.

Return type:

bool

strongdoc.api.account.change_user_password(token, old_password, new_password)[source]

Change user password.

Parameters:
  • token (str) – The user JWT token.
  • old_password (str) – The user’s current password.
  • new_password (str) – The user’s new password.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

Whether the change was a success.

Return type:

bool

strongdoc.api.account.demote_user(token, userid)[source]

Removes admin privileges from a user. This requires an administrator privilege. A gRPC connection timeout will be implemented.

Parameters:
  • token (str) – The user JWT token.
  • userid (str) – The userid of the user to demote.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

Whether the demotion was a success.

Return type:

bool

strongdoc.api.account.get_account_info(token)[source]

Gets account information such as subscription details, payments, sharable orgs, etc. This requires an administrator privilege.

Parameters:token (str) – The user JWT token.
Raises:grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.
Returns:The account information
Return type:AccountInfo
strongdoc.api.account.get_user_info(token)[source]

Gets information about the active user.

Parameters:token (str) – The user JWT token.
Raises:grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.
Returns:The user information
Return type:UserInfo
strongdoc.api.account.list_users(token)[source]

Lists the users of the active organization.

Parameters:token (str) – The user JWT token.
Raises:grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.
Returns:A list of all the users in the organization.
Return type:list(UserInfo)
strongdoc.api.account.promote_user(token, userid)[source]

Promotes a user to admin status. This requires an administrator privilege. A gRPC connection timeout will be implemented.

Parameters:
  • token (str) – The user JWT token.
  • userid (str) – The userid of the user to promote.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

Whether the promotion was a success.

Return type:

bool

strongdoc.api.account.register_user(token, name, password, email, make_admin)[source]

Registers a user for the active organization. This requires an administrator privilege. A gRPC connection timeout will be implemented.

Parameters:
  • token (str) – The user JWT token.
  • name (str) – The new user’s name.
  • password (str) – The new user’s password.
  • email (str) – The new user’s email address.
  • make_admin (bool) – Whether or not the new user will be an admin.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

The userID of the new user.

Return type:

str

strongdoc.api.account.remove_organization(token, force)[source]

Removes an organization, deleting all data stored with the organization. This requires an administrator privilege. A gRPC connection timeout will be implemented.

Parameters:
  • token (str) – The user JWT token.
  • force (bool) – If this is false, removal will fail if there are still data stored with the organization. This prevents accidental deletion.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

Whether the removal was a success.

Return type:

bool

strongdoc.api.account.remove_sharable_org(token, orgid)[source]

Removes a sharable org. This requires an administrator privilege.

Parameters:
  • token (str) – The user JWT token.
  • orgid (str) – The orgid of the org to remove as a sharable org.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

Whether the removal was a success.

Return type:

bool

strongdoc.api.account.remove_user(token, userid)[source]

Removes a user from the active organization. Deletes the user if this is the user’s only organization. This requires an administrator privilege. A gRPC connection timeout will be implemented.

Parameters:
  • token (str) – The user JWT token.
  • userid (str) – The userid of the user to remove.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

The number of users removed.

Return type:

int

strongdoc.api.account.set_account_info(token, org_email, org_address)[source]

Set organization account info. This requires an administrator privilege.

Parameters:
  • token (str) – The user JWT token.
  • email (str) – The organization email address. Must be a valid email address.
  • address (str) – The organization address.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

Whether the change was a success.

Return type:

bool

strongdoc.api.account.set_multilevel_sharing(token, enable)[source]

Enables or disables multi-level sharing. This requires an administrator privilege.

Parameters:
  • token (str) – The user JWT token.
  • enable (bool) – Whether or not multi-level sharing should be enabled.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

Whether the change was a success.

Return type:

bool

strongdoc.api.account.set_user_info(token, name, email)[source]

Set user info.

Parameters:
  • token (str) – The user JWT token.
  • name (str) – The user’s name. Cannot be an empty string.
  • email (str) – The user’s email address. Must be a valid email address.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

Whether the change was a success.

Return type:

bool

document module

class strongdoc.api.document.DocumentMetadata(_doc)[source]

Bases: object

docid

str

doc_name

str

size

int

strongdoc.api.document.decrypt_document(token, docid, ciphertext)[source]

Decrypt a document using the service. The user must provide the ciphertext returned during the encryptDocument API call.

Parameters:
  • token (str) – The user JWT token.
  • docid (str) – The ID of the document.
  • ciphertext (bytes or io.BufferedIOBase (must be readable)) – The document ciphertext to be decrypted.
Returns:

The decrypted plaintext content of the document.

Return type:

bytes

Raises:
  • TypeError – If ciphertext is not of type bytes or type io.BufferedIOBase and readable.
  • grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.
strongdoc.api.document.decrypt_document_stream(token, docid, ciphertext, output_stream)[source]

Decrypt a document using the service. The user must provide the ciphertext returned during the encryptDocument API call.

Parameters:
  • token (str) – The user JWT token.
  • docid (str) – The ID of the document.
  • ciphertext (bytes or io.BufferedIOBase (must be readable)) – The document ciphertext to be decrypted.
  • output_stream (io.BufferedIOBase (must be writable)) – The output stream the plaintext will be written to.
Return type:

None

Raises:
strongdoc.api.document.download_document(token, docid)[source]

Download a document from the service.

Parameters:
  • token (str) – The user JWT token.
  • docid (str) – The ID of the document.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

The downloaded document.

Return type:

bytes

strongdoc.api.document.download_document_stream(token, docid, output_stream)[source]

Download a document from the service.

Parameters:
  • token (str) – The user JWT token.
  • docid (str) – The ID of the document.
  • output_stream (io.BufferedIOBase (must be writable)) – The output stream the document will be written to.
Return type:

None

Raises:
  • TypeError – If output_stream is not type io.BufferedIOBase and writable.
  • grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.
strongdoc.api.document.encrypt_document(token, doc_name, plaintext)[source]

Encrypts a document using the service, but do not store it. Instead return the encrypted ciphertext.

Parameters:
  • token (str) – The user JWT token.
  • doc_name (str) – The name of the document.
  • plaintext (bytes or io.BufferedIOBase (must be readable)) – The text of the document.
Raises:
  • TypeError – If plaintext is not of type bytes or type io.BufferedIOBase and readable.
  • grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.
Returns:

  • docID (str) – The document ID for the uploaded document. This ID is needed to decrypt the document.
  • ciphertext (bytes) – The encrypted ciphertext of the document.

strongdoc.api.document.encrypt_document_stream(token, doc_name, plaintext, output_stream)[source]

Encrypts a document using the service, but do not store it. Instead return the encrypted ciphertext.

Parameters:
  • token (str) – The user JWT token.
  • doc_name (str) – The name of the document.
  • plaintext (bytes or io.BufferedIOBase (must be readable)) – The text of the document.
  • output_stream (io.BufferedIOBase (must be writable)) – The output stream the ciphertext will be written to.
Raises:
Returns:

The document ID for the uploaded document. This ID is needed to decrypt the document.

Return type:

str

strongdoc.api.document.list_documents(token)[source]

Lists the documents that are accessible to the active user.

Parameters:token (str) – The user JWT token.
Raises:grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.
Returns:A list of documents
Return type:list(DocumentMetadata)
strongdoc.api.document.remove_document(token, docid)[source]

Remove a document from the service.

Parameters:
  • token (str) – The user JWT token.
  • docid (str) – The ID of the document.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

Whether the removal was a success.

Return type:

bool

strongdoc.api.document.share_document(token, docid, userid)[source]

Shares a document with another user.

Parameters:
  • token (str) – The user JWT token.
  • docid (str) – The DocID of the document.
  • userid (str) – The UserID of the user to be shared with.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

Whether the share was a success.

Return type:

bool

strongdoc.api.document.unshare_document(token, docid, userid)[source]

Unshares a document from another user.

Parameters:
  • token (str) – The user JWT token.
  • docid (str) – The DocID of the document.
  • userid (str) – The UserID of the user to be unshared from.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

The number of users unshared with.

Return type:

int

strongdoc.api.document.upload_document(token, doc_name, plaintext)[source]

Uploads a document to the service for storage.

Parameters:
  • token (str) – The user JWT token.
  • doc_name (str) – The name of the document.
  • plaintext (bytes or io.BufferedIOBase (must be readable)) – The text of the document.
Returns:

The uploaded document ID.

Return type:

str

Raises:
  • TypeError – If plaintext is not of type bytes or type io.BufferedIOBase and readable.
  • grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

login module

strongdoc.api.login.login(userid, password, orgid)[source]

Verify the user and organization identity, and returns a JWT token for future API use. There must be a one second difference between logout and login. A gRPC connection timeout will be implemented.

Parameters:
  • userid (str) – The login user ID
  • password (str) – The login user password
  • orgid (str) – The login organization ID
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

The JWT token used to authenticate user/org when using StrongDoc APIs.

Return type:

str

strongdoc.api.login.logout(token)[source]

Logs out the user associated with the specified token.

Parameters:token (str) – The user JWT token.
Returns:The logout status of the user.
Return type:str

search module

class strongdoc.api.search.DocumentResult(docid, score)[source]

Bases: object

A class that will hold a single document that matches the search result from the Search query.

docid

str - The matching document ID.

score

float - The score of the matching document.

strongdoc.api.search.search(token, query)[source]

Search for document that contains a specific word. A gRPC connection timeout will be implemented.

Parameters:
  • token (str) – The user JWT token.
  • query (str) – The query string.
Raises:

grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.

Returns:

The hit list of the search.

Return type:

list(DocumentResult)

billing module

strongdoc.api.billing.FREQ_MONTHLY = 'MONTHLY'
strongdoc.api.billing.FREQ_YEARLY = 'YEARLY'
class strongdoc.api.billing.BillingFrequency(_freq)[source]

Bases: object

frequency

str (such as FREQ_MONTHLY or FREQ_YEARLY)

valid_from

datetime.datetime

valid_to

datetime.datetime

class strongdoc.api.billing.DocumentCosts(_costs)[source]

Bases: object

cost

float

size

float

tier

str

class strongdoc.api.billing.SearchCosts(_costs)[source]

Bases: object

cost

float

size

float

tier

str

class strongdoc.api.billing.TrafficCosts(_costs)[source]

Bases: object

cost

float

incoming

float - Traffic sent to us, in MB

outgoing

float - Traffic sent to you, in MB

tier

str

class strongdoc.api.billing.BillingDetails(_details)[source]

Bases: object

period_start

datetime.datetime

period_end

datetime.datetime

total_cost

float

documents

DocumentCosts

search

SearchCosts

traffic

TrafficCosts

billing_frequency

BillingFrequency

class strongdoc.api.billing.LargeTrafficDetails(proto_large_traffic)[source]

Bases: object

large_traffic_list

list(TrafficDetails)

period_start

datetime.datetime - Start of the billing period

period_end

datetime.datetime - End of the billing period

class strongdoc.api.billing.TrafficDetails(proto_traffic)[source]

Bases: object

time

datetime.datetime

userid

str

method

str - “STREAM” or “UNARY”

uri

str - The operation this traffic corresponds to

incoming

float - Traffic sent to us, in MB

outgoing

float - Traffic sent to you, in MB

strongdoc.api.billing.get_billing_details(token, at_time=None)[source]

Gets the billing details at a specified time, or the current time if no time is specified. This requires an administrator privilege.

Parameters:
  • token (str) – The user JWT token.
  • at_time (datetime.datetime) – Optional UTC timestamp to check for billing details at. Defaults to current time.
Raises:
  • grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.
  • ValueError – If at_time is not a valid datetime.
Returns:

The requested billing details, or None if none are found for the specified time.

Return type:

BillingDetails or None

strongdoc.api.billing.get_large_traffic(token, at_time=None)[source]

Gets a list of large traffic events (at least 512 MB in one direction) within a specified billing period. This requires an administrator privilege.

Parameters:
  • token (str) – The user JWT token.
  • at_time (datetime.datetime) – Optional UTC timestamp which falls within the desired billing period. Defaults to current time.
Returns:

The requested large traffic details, or None if none are found for the specified time.

Return type:

LargeTrafficDetails or None

Raises:
  • ValueError – If at_time is not a valid datetime.
  • grpc.RpcError – Raised by the gRPC library to indicate non-OK-status RPC termination.