zbpy package¶
Submodules¶
zbpy.auth module¶
-
zbpy.auth.
make_credential_ecdsa
(nonce, uid, rel_bytes, pk)¶ Returns a ProofOfCredential object.
- Parameters:
- uid: string rel_bytes: list of bytes pk: ecdsa.PrivateKey
-
zbpy.auth.
make_credential_jwt
(jwt_token)¶ Returns a ProofOfCredential object with an empty Ecdsa signature, credType set to JWT_TOKEN, and the zetabase user’s jwt token.
- Parameters:
- jwt_token: string
zbpy.basicqueries module¶
-
class
zbpy.basicqueries.
QueryAnd
(left, right)¶ Bases:
object
-
to_sub_query
()¶ Returns TableSubQuery object.
-
-
class
zbpy.basicqueries.
QueryEquals
(field, comp_value)¶ Bases:
object
-
to_sub_query
()¶ Returns TableSubQuery object.
-
-
class
zbpy.basicqueries.
QueryGreaterThan
(field, comp_value)¶ Bases:
object
-
to_sub_query
()¶ Return TableSubQuery object.
-
-
class
zbpy.basicqueries.
QueryGreaterThanEqual
(field, comp_value)¶ Bases:
object
-
to_sub_query
()¶ Returns a TableSubQuery object.
-
-
class
zbpy.basicqueries.
QueryLessThan
(field, comp_value)¶ Bases:
object
-
to_sub_query
()¶ Returns a TableSubQuery object.
-
-
class
zbpy.basicqueries.
QueryLessThanEqual
(field, comp_value)¶ Bases:
object
-
to_sub_query
()¶ Returns TableSubQuery object.
-
-
class
zbpy.basicqueries.
QueryNotEqual
(field, comp_value)¶ Bases:
object
-
to_sub_query
()¶ Returns TableSubQuery object.
-
-
class
zbpy.basicqueries.
QueryOr
(left, right)¶ Bases:
object
-
to_sub_query
()¶ Returns TableSubQuery object.
-
-
class
zbpy.basicqueries.
QueryTextSearch
(field, comp_value)¶ Bases:
object
-
to_sub_query
()¶ Returns TableSubQuery object.
-
-
zbpy.basicqueries.
query_object_typify
(value)¶ Returns string, QueryOrdering.
- Parameters:
- value: any
zbpy.cleanqueries module¶
-
class
zbpy.cleanqueries.
AndExpression
(expression1, expression2)¶ Bases:
object
-
to_sub_query
()¶ Return TableSubQuery object.
-
-
class
zbpy.cleanqueries.
Expression
(expression)¶ Bases:
object
-
to_sub_query
()¶ Return TableSubQuery object.
-
-
class
zbpy.cleanqueries.
Field
(field)¶ Bases:
object
An instance of this class allows you to query your Zetabase table by field.
zbpy.client module¶
A Python SDK for interacting with Zetabase.
-
class
zbpy.client.
NewAccount
(shell=None, **kwargs)¶ Bases:
IPython.core.magic.Magics
-
createaccount
(line)¶
-
magics
= {'cell': {}, 'line': {'createaccount': 'createaccount'}}¶
-
registered
= True¶
-
-
class
zbpy.client.
ZetabaseClient
(uid)¶ Bases:
object
An instance of a Zetabase client.
-
add_permission
(table_id, perm, table_owner_id=None)¶ Adds a new permission to an existing table.
- Parameters:
- table_id: string perm: PermEntry table_owner_id: string (default=self.user_id)
- Returns:
- None (if no error else raises exception)
-
auth_login_jwt
()¶ Uses jwt to login.
- Returns:
- None (if no error else raises exception)
-
check_ready
()¶ Checks to see if the ZetabaseClient is ready to make a request.
- Returns:
- boolean
-
check_version
()¶ Checks to see if Client version is compatible.
- Returns:
- boolean, zbpprotocol_pb2.VersionDetails
-
confirm_new_sub_user
(subuser_id, verification_code)¶ Confirms the creation of a new subuser using the subuser’s verification code (sent to phone).
- Parameters:
- subuser_id: string verification_code: string
- Returns:
- None (if no error else raises exception)
-
confirm_user_identity
(uid, parent_id, verify_str, stub)¶ Raises error if there is an issue.
- Parameters:
- uid (user_id): string parent_id: string verify_str: string stub: ZetabaseProviderStub
- Returns:
- None (if no error else raises exception)
-
connect
()¶ Establishes a connection between the Zetabase client to the server.
-
create_table
(table_id, data_type, indexed_fields=[], perms=[], allow_jwt=False)¶ Creates a table with given attributes.
- Parameters:
- table_id: string data_type: TableDataFormat object indexed_fields: list of IndexedField (default=[]) perms: list of PermEntrys (default=[]) allow_jwt: boolean (default=False)
- Returns:
- None (if no error else raises exception)
-
delete_key
(table_id, key, table_owner_id=None)¶ Deletes the specified key.
- Parameters:
- table_id: string key: string table_owner_id: string (default=self.user_id)
- Returns:
- None (if no error else raises exception)
-
delete_table
(table_id, table_owner_id=None)¶ Deletes the specified table.
- Parameters:
- table_id: string table_owner_id: string (default=self.user_id)
- Returns:
- None (if no error else raises exception)
-
ecdsa_credential
(nonce, extra_bytes)¶ Creates ecdsa proof of credential using the specified nonce and bytes.
- Parameters:
- nonce: int extra_bytes: list of bytes
- Returns:
- ProofOfCredential
-
get
(table_id, keys, table_owner_id=None)¶ Returns all items from the specified table with the specified keys.
- Parameters:
- table_id: string keys: list of strings table_owner_id: string (default=self.user_id)
- Returns:
- PaginationHandler
-
get_credential
(nonce, x_bytes)¶ Creates proof of credential based on which type of proof of credential the zetabase user is using, jwt or ecdsa.
- Parameters:
- nonce: int x_bytes: bytes
- Returns:
- ProofOfCredential
-
get_sub_identities
()¶ Returns all of the subusers of the ZetabaseClient.
- Returns:
- zbprotocol_pb2.SubIdentitiesList.subIdentities
-
grpc_stub
()¶ - Returns:
- ZetabaseProviderStub
-
id
()¶ Gives the ZetabaseClient’s user id.
- Returns:
- string
-
jwt_credential
()¶ Uses the zetabase user’s jwt_token to create proof of credential if they have one.
- Returns:
- ProofOfCredential
-
list_keys
(table_id, table_owner_id=None)¶ Lists the keys for the specified table.
- Parameter:
- table_id: string table_owner_id: string (default=self.user_id)
- Returns:
- PaginationHandler
-
list_tables
(table_owner_id=None)¶ Lists all tables owned by the specified id.
- Parameters:
- table_owner_id: string (default=self.user_id)
- Returns:
- zbprotocol_pb2.ListTablesResponse
-
new_sub_user
(handle, email, mobile, password, signup_code, group_id, pub_key=None)¶ Creates a new subuser and returns the subuser’s id.
- Parameters:
- handle: string email: string mobile: string password: string signup_code: string group_id: string pub_key: fastecdsa.PublicKey (default=self.pub_key)
- Returns:
- string
-
put_data
(table_id, key, value, overwrite=False, table_owner_id=None)¶ Put the specified data into the specified table with the given key.
- Parameters:
- table_id: string key: string value: bytes overwrite: boolean (default=True) table_owner_id: string (default=self.user_id)
- Returns:
- None (if no error else raises exception)
-
put_dataframe
(table_id, dataframe, df_key, overwrite=False, table_owner_id=None)¶ Put pandas DataFrame into a json table with a specified key that will designate all entries of the dataframe.
- Parameters:
- table_id: string dataframe: pandas.DataFrame df_key: string overwrite: boolean (default=False) table_owner_id: string (default=self.user_id)
- Returns:
- None (if no error else raises exception)
-
put_dataframe_new_table
(table_id, dataframe, df_key, perms=[], specify_fields=None, allow_jwt=False)¶ Creates a new table with indexed fields to match the names and types of the dataframe’s columns. By default, all columns will be indexed, but a subset can be specified by listing the names of the columns in the ‘specify_fields’ parameter.
- Parameters:
- table_id: string dataframe: pandas.DataFrame df_key: string perms: list of PermEntry objects (default=[]) specify_fields: list of strings (default=All columns) allow_jwt: boolean (default=False)
- Returns:
- None (if no error else raises exception)
-
put_multi
(table_id, keys, values, overwrite=False, table_owner_id=None)¶ Put multiple pieces of data into a table with the specified keys.
- Parameters:
- table_id: string keys: list of strings values: list of bytes overwrite: boolean (default=False) table_owner_id: string (default=self.user_id)
- Returns:
- None (if no error else raises exception)
-
put_np_array
(table_id, array, key, overwrite=False, table_owner_id=None)¶ Put numpy array into a table with the given key.
- Parameters:
- table_id: string array: np.array key: string overwrite: boolean (default=False) table_owner_id: string (default=self.user_id)
- Returns:
- None (if no error else raises exception)
-
query
(table_id, qry, table_owner_id=None)¶ Queries data based on the specified query and table.
- Parameters:
- table_id: string qry: Query type object table_owner_id: string (default=self.user_id)
- Returns:
- PaginationHandler
-
set_cert_verify
()¶ Sets no certificate verification to False.
-
set_id_key
(priv, pub)¶ Sets the private and public keys of the ZetabaseClient to priv and pub respectively.
- Parameters:
- priv: fastecdsa.PrivateKey pub: fastecdsa.PublicKey
-
set_id_password
(login_id, pwd)¶ Sets the login_id and password of the ZetabaseClient.
- Parameter:
- login_id: string pwd: string
-
set_insecure
()¶ Sets insecure of the ZetabaseClient to true.
-
set_parent
(id)¶ Sets the parent_id of the ZetabaseClient to id.
- Parameters:
- id: string.
-
set_server_addr
(addr)¶ Sets the server address of the ZetabaseClient.
- Parameters:
- addr: string
-
-
zbpy.client.
import_key
(filepath, public, curve=P256)¶ Returns the keys located at the specified filepath.
- Parameters:
- filepath: string public: boolean curve: fastecdsa.curve (default=P256)
- Returns:
- fastecdsa.key (public or private)
zbpy.cryptography module¶
-
zbpy.cryptography.
encode_private_key
(priv_key, point, curve=P256)¶ Returns string.
- Parameters:
- priv_key: int point: fastecdsa.point curve: fastecdsa.curve
-
zbpy.cryptography.
encode_public_key
(pub_key)¶ Returns string.
- Parameters:
- pub_key: fastecdsa.point
-
zbpy.cryptography.
generate_key_pair
()¶ Returns fastecdsa public and private keys (fastecdsa.privKey, fastecdsa.pubKey).
-
zbpy.cryptography.
make_zetabase_signature
(uid, nonce, rel_data, pk)¶ Returns tuple of strings.
- Parameters:
- uid: string nonce: int rel_data: bytes pk: fastecdsa.PrivateKey
-
zbpy.cryptography.
multi_put_extra_signing_bytes
(pairs)¶ Creates extra bytes when inserting multiple pieces of data.
- Parameters:
- pairs: list of DataPair objects
-
zbpy.cryptography.
permission_set_signing_bytes
(perms)¶ Returns list of bytes.
- Parameters:
- perms: list of PermissionsEntry objects
-
zbpy.cryptography.
permission_signing_bytes
(entry)¶ Returns a list of bytes.
- Parameters:
- entry: PermEntry object
-
zbpy.cryptography.
permissions_entry_signing_bytes
(perm)¶ Returns bytes.
- Parameters:
- perm: PermissionsEntry object
-
zbpy.cryptography.
sign_message_bytes
(byts, rel_data_bytes, pk)¶ Return tuple of strings.
-
zbpy.cryptography.
signing_bytes
(uid, nonce)¶ Returns list of bytes.
- Parameters:
- uid: string nonce: int
-
zbpy.cryptography.
table_create_signing_bytes
(table_id, perms)¶ Returns list of bytes.
- Parameters:
- table_id: string perms: list of PermissionsEntry objects
-
zbpy.cryptography.
table_put_extra_signing_bytes
(key, value)¶ Creates extra bytes when inserting a piece of data.
- Parameters:
- key: string value: list of bytes
-
zbpy.cryptography.
validate_signature_bytes
(pub_key, std_signing_bytes, special_data_bytes, r, s)¶ Returns boolean.
- Parameters:
- pub_key: fastecdsa.PublicKey std_sigining_bytes: list of bytes special_data_bytes: list of bytes r: string s: string
zbpy.datasci module¶
-
zbpy.datasci.
df_to_kvp
(dataframe, df_key, start_entry)¶ Returns keys (list of strings), values (list of bytes), done (boolean). df_to_kvp = dataframe to key-value pairs
- Parameters:
- dataframe: pandas.DataFrame df_key: string start_entry: integer
-
zbpy.datasci.
parse_df_column
(col_name, col_type)¶ Returns an IndexedField object.
- Parameters:
- col_name: string col_type: pd.dtype
-
zbpy.datasci.
parse_df_columns
(dataframe, specify_fields)¶ Returns a list of IndexedField objects.
- Parameters:
- dataframe: pd.DataFrame specify_fields: list of strings
-
zbpy.datasci.
parse_np_array
(array)¶ Returns bytes of an encoded
- Parameters:
- array: np.array
zbpy.indexedfieldentity module¶
-
class
zbpy.indexedfieldentity.
IndexedField
(field_name, index_type, lang_code='')¶ Bases:
object
-
set_language_code
(code)¶ Sets the language code of the IndexedField.
- Parameters:
- code: string
-
to_protocol
()¶ - Returns:
- TableIndexField
-
-
zbpy.indexedfieldentity.
indexed_fields_to_protocol
(ifs)¶ - Parameters:
- ifs: IndexedField
- Returns:
- list of TableIndexFields
zbpy.pagination module¶
-
class
zbpy.pagination.
PaginationHandler
(f)¶ Bases:
object
-
data
()¶ Returns dict that maps strings to a list of bytes.
-
data_all
()¶ Returns a dict that maps strings to a list of bytes.
-
keys
()¶ Returns a list of strings.
-
keys_all
()¶ Returns a list of string.
-
next
()¶ Returns the next page if there is one.
-
return_bytes
()¶ Will make items return as bytes when PaginationHandler is iterated through.
-
return_pretty
()¶ Will make items return as Python dictionaries or numpy arrays when PaginationHandler is iterated through.
-
to_dataframe
()¶ Transforms all data in PaginationHandler into pandas.DataFrame.
-
-
zbpy.pagination.
standard_pagination_handler
(f)¶ Returns an object of class PaginationHandler.
- Parameters:
- f: paginationRequester - func (int) -> (dict[string][byte], bool)
zbpy.permissionentity module¶
-
class
zbpy.permissionentity.
PermConstraint
(field, req_value='@uid')¶ Bases:
object
-
class
zbpy.permissionentity.
PermEntry
(level, audience_type, audience_id)¶ Bases:
object
-
add_constraint
(c)¶ Adds constraint to the PermEntry.
- Parameters:
- c: PermConstraint
-
to_protocol
(uid, table_id)¶ Returns PermissionsEntry object.
- Parameters:
- uid: string table_id: string
- Returns:
- PermissionsEntry
-
-
zbpy.permissionentity.
to_field_constraint
(uid, table_id, cs)¶ Returns PermissionConstraint object.
- Parameters:
- uid: string table_id: string cs: PermConstraint object
- Returns:
- PermissionConstraint
-
zbpy.permissionentity.
to_field_constraints
(uid, table_id, cs)¶ Returns PermissionConstraint object.
- Paramters:
- uid: string table_id: string cs: PermConstraint object
- Returns:
- PermissionConstraint
zbpy.util module¶
-
class
zbpy.util.
IdentityDefinition
(id, parent_id, pub_key_enc, priv_key_enc)¶ Bases:
object
-
to_dict
()¶ Returns dictionary.
-
-
zbpy.util.
clean_string_for_filename
(filename)¶ Returns string.
- Parameters:
- filename: string
-
zbpy.util.
empty_signature
()¶ Returns empty EcdsaSignature object.
-
zbpy.util.
get_cert
()¶ Returns Zetabase certificate.
-
zbpy.util.
get_stub
()¶ Returns ZetabaseClientStub.
-
zbpy.util.
is_sem_ver_version_at_least
(user_version, min_version)¶ Returns boolean.
- Parameters:
- user_version: string min_version: string
-
zbpy.util.
new_account_interactive
()¶
-
zbpy.util.
unwrap_zb_error
(error)¶ Unwraps error.
- Parameters:
- error: ZbError
zbpy.zbcert module¶
zbpy.zbprotocol_pb2 module¶
zbpy.zbprotocol_pb2_grpc module¶
-
class
zbpy.zbprotocol_pb2_grpc.
ZetabaseProvider
¶ Bases:
object
Missing associated documentation comment in .proto file
-
static
ConfirmNewIdentity
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
CreateTable
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
CreateUser
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
DeleteObject
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
GetData
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
ListKeys
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
ListSubIdentities
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
ListTables
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
LoginUser
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
ModifySubIdentity
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
PutData
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
PutDataMulti
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
QueryData
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
RegisterNewIdentity
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
SetPermission
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
VersionInfo
(request, target, options=(), channel_credentials=None, call_credentials=None, compression=None, wait_for_ready=None, timeout=None, metadata=None)¶
-
static
-
class
zbpy.zbprotocol_pb2_grpc.
ZetabaseProviderServicer
¶ Bases:
object
Missing associated documentation comment in .proto file
-
ConfirmNewIdentity
(request, context)¶ Missing associated documentation comment in .proto file
-
CreateTable
(request, context)¶ Missing associated documentation comment in .proto file
-
CreateUser
(request, context)¶ Missing associated documentation comment in .proto file
-
DeleteObject
(request, context)¶ Missing associated documentation comment in .proto file
-
GetData
(request, context)¶ Missing associated documentation comment in .proto file
-
ListKeys
(request, context)¶ Missing associated documentation comment in .proto file
-
ListSubIdentities
(request, context)¶ Missing associated documentation comment in .proto file
-
ListTables
(request, context)¶ Missing associated documentation comment in .proto file
-
LoginUser
(request, context)¶ Missing associated documentation comment in .proto file
-
ModifySubIdentity
(request, context)¶ Missing associated documentation comment in .proto file
-
PutData
(request, context)¶ Missing associated documentation comment in .proto file
-
PutDataMulti
(request, context)¶ Missing associated documentation comment in .proto file
-
QueryData
(request, context)¶ Missing associated documentation comment in .proto file
-
RegisterNewIdentity
(request, context)¶ Missing associated documentation comment in .proto file
-
SetPermission
(request, context)¶ Missing associated documentation comment in .proto file
-
VersionInfo
(request, context)¶ Missing associated documentation comment in .proto file
-
-
class
zbpy.zbprotocol_pb2_grpc.
ZetabaseProviderStub
(channel)¶ Bases:
object
Missing associated documentation comment in .proto file
-
zbpy.zbprotocol_pb2_grpc.
add_ZetabaseProviderServicer_to_server
(servicer, server)¶