nevermined_sdk_py.nevermined.assets module

class nevermined_sdk_py.nevermined.assets.Assets(keeper, did_resolver, agreements, asset_consumer, asset_executor, config)

Bases: object

Nevermined assets class.

access(service_agreement_id, did, service_index, consumer_account, destination, index=None)

Consume the asset data.

Using the service endpoint defined in the ddo’s service pointed to by service_definition_id. Consumer’s permissions is checked implicitly by the secret-store during decryption of the contentUrls. The service endpoint is expected to also verify the consumer’s permissions to access this asset. This method downloads and saves the asset datafiles to disk.

Parameters
  • service_agreement_id – str

  • did – DID, str

  • service_index – identifier of the service inside the asset DDO, str

  • consumer_account – Account instance of the consumer

  • destination – str path

  • index – Index of the document that is going to be downloaded, int

Returns

str path to saved files

consumer_assets(consumer_address)

List of Asset objects purchased by consumerAddress

Parameters

consumer_address – ethereum address of consumer, hes-str

Returns

list of dids

create(metadata, publisher_account, service_descriptors=None, providers=None, authorization_type='PSK-RSA', use_secret_store=False)

Register an asset in both the keeper’s DIDRegistry (on-chain) and in the Metadata store.

Parameters
  • metadata – dict conforming to the Metadata accepted by Nevermined Protocol.

  • publisher_account – Account of the publisher registering this asset

  • service_descriptors – list of ServiceDescriptor tuples of length 2. The first item must be one of ServiceTypes and the second item is a dict of parameters and values required by the service

  • providers – list of addresses of providers of this asset (a provider is an ethereum account that is authorized to provide asset services)

  • authorization_type – str indicate the authorization type that is going to be used

to encrypt the urls.

SecretStore, PSK-RSA and PSK-ECDSA are supported.

Parameters

use_secret_store – bool indicate whether to use the secret store directly for encrypting urls (Uses Gateway provider service if set to False)

Returns

DDO instance

delegate_persmission(did, address_to_grant, account)

Grant access permission to an address.

Parameters
  • did – the id of an asset on-chain, hex str

  • address_to_grant – ethereum account address, hex str

  • account – Account executing the action

Returns

bool

execute(agreement_id, did, index, consumer_account, workflow_did)

:param agreement_id:representation of bytes32 id, hexstr :param did: computing service did, str :param index: id of the service within the asset DDO, str :param consumer_account: Account instance of the consumer ordering the service :param workflow_did: the asset did (of workflow type) which consist of did:nv: and the assetId hex str (without 0x prefix), str :return: local path on the file system where the asset data files are downloaded, str

get_permissions(did, address)

Gets access permission of a grantee

Parameters
  • did – the id of an asset on-chain, hex str

  • address – ethereum account address, hex str

Returns

true if the address has access permission to a DID

order(did, index, consumer_account, auto_consume=False)

Place order by directly creating an SEA (agreement) on-chain.

Parameters

did – str starting with the prefix did:nv: and followed by the asset id which is

a hex str :param index: str the service definition id identifying a specific service in the DDO (DID document) :param consumer_account: Account instance of the consumer :param auto_consume: boolean :return: agreement_id the service agreement id (can be used to query

the nevermined-contracts for the status of the service agreement)

order_direct(did, index, consumer_account, account)
owner(did)

Return the owner of the asset.

Parameters

did – DID, str

Returns

the ethereum address of the owner/publisher of given asset did, hex-str

owner_assets(owner_address)

List of Asset objects published by ownerAddress

Parameters

owner_address – ethereum address of owner/publisher, hex-str

Returns

list of dids

query(query, sort=None, offset=100, page=1, metadata_url=None)

Search an asset in oceanDB using search query.

Parameters
  • query – dict with query parameters (e.g.) https://github.com/keyko-io/nevermined-metadata/blob/develop/docs /for_api_users/API.md

  • sort – Dictionary to choose order main in some value

  • offset – Number of elements shows by page

  • page – Page number

  • metadata_url – Url of the Metadata where you want to search. If there is not provided take the default

Returns

List of assets that match with the query.

resolve(did)

When you pass a did retrieve the ddo associated.

Parameters

did – DID, str

Returns

DDO instance

retire(did)

Retire this did of Metadata

Parameters

did – DID, str

Returns

bool

revoke_permissions(did, address_to_revoke, account)

Revoke access permission to an address.

Parameters
  • did – the id of an asset on-chain, hex str

  • address_to_revoke – ethereum account address, hex str

  • account – Account executing the action

Returns

bool

search(text, sort=None, offset=100, page=1, metadata_url=None)

Search an asset in oceanDB using Metadata.

Parameters
  • text – String with the value that you are searching

  • sort – Dictionary to choose order main in some value

  • offset – Number of elements shows by page

  • page – Page number

  • metadata_url – Url of the Metadata where you want to search. If there is not provided take the default

Returns

List of assets that match with the query

transfer_ownership(did, new_owner_address, account)

Transfer did ownership to an address.

Parameters
  • did – the id of an asset on-chain, hex str

  • new_owner_address – ethereum account address, hex str

  • account – Account executing the action

Returns

bool

validate(metadata)

Validate that the metadata is ok to be stored in Metadata.

Parameters

metadata – dict conforming to the Metadata accepted by Nevermined Protocol.

Returns

bool