bhive.conveyor module¶
-
class
bhive.conveyor.
Conveyor
(url='https://conveyor.hive.blog', hive_instance=None)¶ Bases:
object
Class to access hiveio Conveyor instances: https://gitlab.syncad.com/hive-group//conveyor
Description from the official documentation:
Feature flags: “Feature flags allows our apps (condenser mainly) to hide certain features behind flags.”
User data: “Conveyor is the central point for storing sensitive user data (email, phone, etc). No other services should store this data and should instead query for it here every time.”
User tags: “Tagging mechanism for other services, allows defining and assigning tags to accounts (or other identifiers) and querying for them.”
Not contained in the documentation, but implemented and working:
Draft handling: saving, listing and removing post drafts consisting of a post title and a body.
The underlying RPC authentication and request signing procedure is described here: https://gitlab.syncad.com/hive-group//rpc-auth
-
get_feature_flag
(account, flag, signing_account=None)¶ Test if a specific feature flag is set for an account. The request has to be signed by the requested account or an admin account.
- Parameters
account (str) – requested account
flag (str) – flag to be tested
signing_account (str) – (optional) account to sign the request. If unset, account is used.
Example:
from bhive import Hive from bhive.conveyor import Conveyor s = Hive(keys=["5JPOSTINGKEY"]) c = Conveyor(hive_instance=s) print(c.get_feature_flag('accountname', 'accepted_tos'))
-
get_feature_flags
(account, signing_account=None)¶ Get the account’s feature flags. The request has to be signed by the requested account or an admin account.
- Parameters
account (str) – requested account
signing_account (str) – (optional) account to sign the request. If unset, account is used.
Example:
from bhive import Hive from bhive.conveyor import Conveyor s = Hive(keys=["5JPOSTINGKEY"]) c = Conveyor(hive_instance=s) print(c.get_feature_flags('accountname'))
-
get_user_data
(account, signing_account=None)¶ Get the account’s email address and phone number. The request has to be signed by the requested account or an admin account.
- Parameters
account (str) – requested account
signing_account (str) – (optional) account to sign the request. If unset, account is used.
Example:
from bhive import Hive from bhive.conveyor import Conveyor s = Hive(keys=["5JPOSTINGKEY"]) c = Conveyor(hive_instance=s) print(c.get_user_data('accountname'))
-
healthcheck
()¶ Get the Conveyor status
Sample output:
{ 'ok': True, 'version': '1.1.1-4d28e36-1528725174', 'date': '2018-07-21T12:12:25.502Z' }
-
list_drafts
(account)¶ List all saved drafts from account
- Parameters
account (str) – requested account
Sample output:
{ 'jsonrpc': '2.0', 'id': 2, 'result': [ {'title': 'draft-title', 'body': 'draft-body', 'uuid': '06497e1e-ac30-48cb-a069-27e1672924c9'} ] }
-
prehash_message
(timestamp, account, method, params, nonce)¶ Prepare a hash for the Conveyor API request with SHA256 according to https://gitlab.syncad.com/hive-group//rpc-auth Hashing of second is then done inside ecdsasig.sign_message().
- Parameters
timestamp (str) – valid iso8601 datetime ending in “Z”
account (str) – valid hive blockchain account name
method (str) – Conveyor method name to be called
param (bytes) – base64 encoded request parameters
nonce (bytes) – random 8 bytes
-
remove_draft
(account, uuid)¶ Remove a draft from the Conveyor database
- Parameters
account (str) – requested account
uuid (str) – draft identifier as returned from list_drafts
-
save_draft
(account, title, body)¶ Save a draft in the Conveyor database
- Parameters
account (str) – requested account
title (str) – draft post title
body (str) – draft post body
-
set_user_data
(account, params, signing_account=None)¶ Set the account’s email address and phone number. The request has to be signed by an admin account.
- Parameters
account (str) – requested account
param (dict) – user data to be set
signing_account (str) – (optional) account to sign the request. If unset, account is used.
Example:
from bhive import Hive from bhive.conveyor import Conveyor s = Hive(keys=["5JADMINPOSTINGKEY"]) c = Conveyor(hive_instance=s) userdata = {'email': 'foo@bar.com', 'phone':'+123456789'} c.set_user_data('accountname', userdata, 'adminaccountname')