zbpy package¶
Submodules¶
zbpy.client module¶
-
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.
- __Init__ Parameters:
- uid: string
-
add_permission
(table_id, perm, table_owner_id=self.user_id)¶ 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)
-
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: zbprotocol_pb2.TableDataFormat
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=self.user_id)¶ 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=self.user_id)¶ Deletes the specified table.
- Parameters:
- table_id: string
table_owner_id: string (default=self.user_id) - Returns:
- None (if no error else raises exception)
-
get
(table_id, keys, table_owner_id=self.user_id)¶ 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_sub_identities
()¶ Returns all of the subusers of the ZetabaseClient.
- Returns:
- zbprotocol_pb2.SubIdentitiesList.subIdentities
-
grpc_stub
()¶ - Returns:
- zbprotocol_pb2.ZetabaseProviderStub
-
id
()¶ Gives the ZetabaseClient’s user id.
- Returns:
- string
-
list_keys
(table_id, table_owner_id=self.user_id)¶ Lists the keys for the specified table.
- Parameters:
- table_id: string
table_owner_id: string (default=self.user_id) - Returns:
- PaginationHandler
-
list_keys_with_pattern
(table_id, pattern, table_owner_id=self.user_id)¶ Lists keys that begin with a certain prefix.
- Parameters:
- table_id: string
pattern: string
table_owner_id: string (default=self.user_id) - Returns:
- PaginationHandler
-
list_tables
(table_owner_id=self.user_id)¶ 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=self.user_id)¶ 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=self.user_id)¶ 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=self.user_id)¶ 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=self.user_id)¶ 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=self.user_id)¶ 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_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_parent
(id)¶ Sets the parent_id of the ZetabaseClient to id.
- Parameters:
- id: 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.indexedfieldentity module¶
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
()¶ Changes the current data stored in the pagination handler to 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
()¶ Returns the data in the PaginationHandler as a pandas DataFrame.
-
zbpy.permissionentity module¶
-
class
zbpy.permissionentity.
PermConstraint
(field, req_value='@uid')¶ Bases:
object
- __Init__ Parameters:
- field: string
req_value: string (default='@uid')
-
class
zbpy.permissionentity.
PermEntry
(level, audience_type, audience_id)¶ Bases:
object
- __Init__ Parameters:
- level: zbprotocol_pb2.PermissionLevel
audience_type: zbprotocol_pb2.PermissionAudienceType
audience_id: string -
add_constraint
(c)¶ Adds constraint to the PermEntry.
- Parameters:
- c: PermConstraint
zbpy.queries module¶
-
class
zbpy.queries.
Field
(field)¶ Bases:
object
An instance of this class allows you to query your Zetabase table by field.
- __Init__ Parameters:
- field: string
zbpy.zbprotocol_pb2 module¶
-
Enums
¶
-
-
zbpy.zbprotocol_pb2.PermissionAudienceType
¶ Options for who a specific permission applied to a table pertains to.
- Enumerators:
- INDIVIDUAL
USER
PUBLIC
-
zbpy.zbprotocol_pb2.PermissionLevel
¶ Options for what type of permission is applied to a table.
- Enumerators:
- NONE
READ
APPEND
DELETE
ADMINISTER
-
zbpy.zbprotocol_pb2.QueryOrdering
¶ Options for the types of an indexed field.
- Enumerators:
- LEXICOGRAPHIC
REAL_NUMBERS
INTEGRAL_NUMBERS
FULL_TEXT
-
zbpy.zbprotocol_pb2.TableDataFormat
¶ Options for the type of a table.
- Enumerators:
- BINARY
PLAIN_TEXT
JSON
-
-
Messages
¶
-
-
zbpy.zbprotocol_pb2.VersionDetails
¶ -
- Attributes:
- serverVersion: string
clientVersion: string
minClientVersion: string
-
zbpy.zbprotocol_pb2.SubIdentitiesList
¶ -
- Attributes:
- subIdentities: repeated NewSubIdentityRequest
-
zbpy.zbprotocol_pb2.NewSubIdentityRequest
¶ -
- Attributes:
- id: string
name: string
email: string
mobile: string
loginPassword: string
pubKeyEncoded: string
signupCode: string
groupId: string
-