Memory Agent class
- class starfish.agent.MemoryAgent(ddo: Optional[starfish.network.ddo.DDO] = None)
Bases:
starfish.agent.agent_base.AgentBase
Memory Agent class allows to register, list, purchase and consume assets.
- Parameters
ddo (
DDO
) – ddo to access the agent
- consume_asset(listing: Any, account: Any, purchase_id: str) bool
Consume the asset and download the data. The actual payment to the asset provider will be made at this point.
- Parameters
- Returns
True if the asset has been consumed and downloaded
- Type
boolean
- create_listing(listing_data: starfish.types.ListingData, asset_did: str) starfish.types.Listing
Create a listing on the market place for this asset
- get_asset_purchase_ids(asset: Any) Any
Returns as list of purchase id’s that have been used for this asset
- is_access_granted_for_asset(asset: Any, account: Any, purchase_id: Optional[str] = None) bool
Check to see if the account and purchase_id have access to the assed data.
- Parameters
asset (
Asset
object) – Asset to check for access.account (
Account
object to use for registration.) – Ocean account to purchase the asset.purchase_id (str) – purchase id that was used to purchase the asset.
- Returns
True if the asset can be accessed and consumed.
- Type
boolean
- purchase_asset(listing: Any, account: Any) Any
Purchase an asset using it’s listing and an account.
- Parameters
listing (
Listing
) – Listing to use for the purchase.account (
Account
object to use for registration.) – Ocean account to purchase the asset.
- purchase_wait_for_completion(asset: Any, account: Any, purchase_id: str, timeoutSeconds: int) bool
Wait for completion of the purchase
TODO: issues here… + No method as yet to pass back paramaters and values during the purchase process + We assume that the following templates below will always be used.
- register_asset(asset: starfish.types.Asset) starfish.types.Asset
Register a memory asset.
- search_listings(text: str, sort: Optional[str] = None, offset: int = 100, page: int = 0) Any
Search for listings with the givien ‘text’
- Parameters
- Returns
a list of listing objects found using the search.
- Type
Listing
objects
For example:
# return the 300 -> 399 records in the search for the text 'weather' in the metadata. my_result = agent.search_registered_assets('weather', None, 100, 3)