Package io.keyko.nevermined.api
Interface AssetsAPI
-
- All Known Implementing Classes:
AssetsImpl
public interface AssetsAPI
Exposes the Public API related with Assets
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Boolean
consume(String serviceAgreementId, DID did, int serviceDefinitionId, int fileIndex, String basePath)
Downloads an Asset previously ordered through a Service AgreementBoolean
consume(String serviceAgreementId, DID did, int serviceDefinitionId, String basePath)
Downloads an Asset previously ordered through a Service AgreementInputStream
consumeBinary(String serviceAgreementId, DID did, int serviceDefinitionId)
Gets the input stream of one file of the assetInputStream
consumeBinary(String serviceAgreementId, DID did, int serviceDefinitionId, int fileIndex)
Gets the input stream of one file of the assetInputStream
consumeBinary(String serviceAgreementId, DID did, int serviceDefinitionId, int fileIndex, int rangeStart, int rangeEnd)
Gets a range of bytes of the input stream of one file of the assetList<DID>
consumerAssets(String consumerAddress)
List of Asset objects purchased by consumerAddressDDO
create(AssetMetadata metadata, ProviderConfig providerConfig)
Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in MetadataDDO
create(AssetMetadata metadata, ProviderConfig providerConfig, AuthConfig authConfig)
Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in MetadataDDO
createComputingService(AssetMetadata metadata, ProviderConfig providerConfig, ComputingService.Provider computingProvider)
Creates a new ComputingService DDO, registering it on-chain through DidRegistry contract and off-chain in MetadataBoolean
delegatePermissions(DID did, String subjectAddress)
For a existing asset, the owner of the asset delegate to a subject read or access permissString
execute(String agreementId, DID did, int index, String workflowDID)
Executes a remote service associated with an asset and serviceAgreementIdList<AssetMetadata.File>
getMetadataFiles(DID did)
Gets the list of the files that belongs to a DDOBoolean
getPermissions(DID did, String subjectAddress)
Check if an user has permissions in a specific DIDio.reactivex.Flowable<OrderResult>
order(DID did, int serviceDefinitionId)
Purchases an Asset represented by a DID.OrderResult
orderDirect(DID did, int serviceDefinitionId)
Purchases an Asset represented by a DID.String
owner(DID did)
Return the owner of the asset.List<DID>
ownerAssets(String ownerAddress)
List of Asset objects published by ownerAddressSearchResult
query(Map<String,Object> params)
Gets all the DDOs that match the parameters of the querySearchResult
query(Map<String,Object> params, int offset, int page, int sort)
Gets all the DDOs that match the parameters of the queryDDO
resolve(DID did)
Gets a DDO from a DIDBoolean
retire(DID did)
Retire this did of MetadataBoolean
revokePermissions(DID did, String subjectAddress)
For a existing asset, the owner of the asset revoke the access grants of a subject.SearchResult
search(String text)
Gets all the DDO that match the search criteriaSearchResult
search(String text, int offset, int page)
Gets all the DDOs that match the search criteriaBoolean
transferOwnership(DID did, String newOwnerAddress)
Given a DID, transfer the ownership to a new owner.Boolean
validate(AssetMetadata metadata)
Validate the asset metadata.
-
-
-
Method Detail
-
create
DDO create(AssetMetadata metadata, ProviderConfig providerConfig, AuthConfig authConfig) throws DDOException
Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in Metadata- Parameters:
metadata
- the metadata of the DDOproviderConfig
- the endpoints of the DDO's servicesauthConfig
- Auth configuration- Returns:
- an instance of the DDO created
- Throws:
DDOException
- DDOException
-
create
DDO create(AssetMetadata metadata, ProviderConfig providerConfig) throws DDOException
Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in Metadata- Parameters:
metadata
- the metadata of the DDOproviderConfig
- the endpoints of the DDO's services- Returns:
- an instance of the DDO created
- Throws:
DDOException
- DDOException
-
createComputingService
DDO createComputingService(AssetMetadata metadata, ProviderConfig providerConfig, ComputingService.Provider computingProvider) throws DDOException
Creates a new ComputingService DDO, registering it on-chain through DidRegistry contract and off-chain in Metadata- Parameters:
metadata
- the metadata of the DDOproviderConfig
- the endpoints of the DDO's servicescomputingProvider
- the computing provider configuration- Returns:
- an instance of the DDO created
- Throws:
DDOException
- DDOException
-
resolve
DDO resolve(DID did) throws EthereumException, DDOException
Gets a DDO from a DID- Parameters:
did
- the DID to resolve- Returns:
- an instance of the DDO represented by the DID
- Throws:
EthereumException
- EthereumExceptionDDOException
- DDOException
-
getMetadataFiles
List<AssetMetadata.File> getMetadataFiles(DID did) throws DDOException
Gets the list of the files that belongs to a DDO- Parameters:
did
- the DID to resolve- Returns:
- a list of the Files
- Throws:
DDOException
- EncryptionException
-
search
SearchResult search(String text) throws DDOException
Gets all the DDO that match the search criteria- Parameters:
text
- the criteria- Returns:
- a List with all the DDOs found
- Throws:
DDOException
- DDOException
-
search
SearchResult search(String text, int offset, int page) throws DDOException
Gets all the DDOs that match the search criteria- Parameters:
text
- the criteriaoffset
- parameter to paginatepage
- parameter to paginate- Returns:
- a List with all the DDOs found
- Throws:
DDOException
- DDOException
-
query
SearchResult query(Map<String,Object> params, int offset, int page, int sort) throws DDOException
Gets all the DDOs that match the parameters of the query- Parameters:
params
- the criteriaoffset
- parameter to paginatepage
- parameter to paginatesort
- parameter to sort- Returns:
- a List with all the DDOs found
- Throws:
DDOException
- DDOException
-
query
SearchResult query(Map<String,Object> params) throws DDOException
Gets all the DDOs that match the parameters of the query- Parameters:
params
- the criteria- Returns:
- a List with all the DDOs found
- Throws:
DDOException
- DDOException
-
consume
Boolean consume(String serviceAgreementId, DID did, int serviceDefinitionId, String basePath) throws ConsumeServiceException
Downloads an Asset previously ordered through a Service Agreement- Parameters:
serviceAgreementId
- the service agreement id of the assetdid
- the didserviceDefinitionId
- the service definition idbasePath
- the path where the asset will be downloaded- Returns:
- a flag that indicates if the consume flow was executed correctly
- Throws:
ConsumeServiceException
- ConsumeServiceException
-
consume
Boolean consume(String serviceAgreementId, DID did, int serviceDefinitionId, int fileIndex, String basePath) throws ConsumeServiceException
Downloads an Asset previously ordered through a Service Agreement- Parameters:
serviceAgreementId
- the service agreement id of the assetdid
- the didserviceDefinitionId
- the service definition idfileIndex
- index id of the file to consumebasePath
- the path where the asset will be downloaded- Returns:
- a flag that indicates if the consume flow was executed correctly
- Throws:
ConsumeServiceException
- ConsumeServiceException
-
consumeBinary
InputStream consumeBinary(String serviceAgreementId, DID did, int serviceDefinitionId) throws ConsumeServiceException
Gets the input stream of one file of the asset- Parameters:
serviceAgreementId
- the service agreement id of the assetdid
- the didserviceDefinitionId
- the service definition id- Returns:
- the input stream wit the binary content of the file
- Throws:
ConsumeServiceException
- ConsumeServiceException
-
consumeBinary
InputStream consumeBinary(String serviceAgreementId, DID did, int serviceDefinitionId, int fileIndex) throws ConsumeServiceException
Gets the input stream of one file of the asset- Parameters:
serviceAgreementId
- the service agreement id of the assetdid
- the didserviceDefinitionId
- the service definition idfileIndex
- the index of the file- Returns:
- the input stream wit the binary content of the file
- Throws:
ConsumeServiceException
- ConsumeServiceException
-
consumeBinary
InputStream consumeBinary(String serviceAgreementId, DID did, int serviceDefinitionId, int fileIndex, int rangeStart, int rangeEnd) throws ConsumeServiceException
Gets a range of bytes of the input stream of one file of the asset- Parameters:
serviceAgreementId
- the service agreement id of the assetdid
- the didserviceDefinitionId
- the service definition idfileIndex
- the index of the filerangeStart
- the start of the bytes rangerangeEnd
- the end of the bytes range- Returns:
- the input stream wit the binary content of the specified range
- Throws:
ConsumeServiceException
- ConsumeServiceException
-
order
io.reactivex.Flowable<OrderResult> order(DID did, int serviceDefinitionId) throws OrderException
Purchases an Asset represented by a DID. It implies to initialize a Service Agreement between publisher and consumer- Parameters:
did
- the did of the DDOserviceDefinitionId
- the service definition id- Returns:
- a Flowable instance over an OrderResult to get the result of the flow in an asynchronous fashion
- Throws:
OrderException
- OrderException
-
orderDirect
OrderResult orderDirect(DID did, int serviceDefinitionId) throws OrderException, ServiceException, EscrowRewardException
Purchases an Asset represented by a DID. It implies to initialize a Service Agreement between publisher and consumer- Parameters:
did
- the did of the DDOserviceDefinitionId
- the service definition id- Returns:
- OrderResult
- Throws:
OrderException
- OrderExceptionServiceException
- ServiceExceptionEscrowRewardException
- EscrowRewardException
-
execute
String execute(String agreementId, DID did, int index, String workflowDID) throws ServiceException
Executes a remote service associated with an asset and serviceAgreementId- Parameters:
agreementId
- the agreement iddid
- the didindex
- the index of the serviceworkflowDID
- the workflow id- Returns:
- an execution id
- Throws:
ServiceException
- ServiceException
-
owner
String owner(DID did) throws Exception
Return the owner of the asset.- Parameters:
did
- the did- Returns:
- the ethereum address of the owner/publisher of given asset did
- Throws:
Exception
- Exception
-
ownerAssets
List<DID> ownerAssets(String ownerAddress) throws ServiceException
List of Asset objects published by ownerAddress- Parameters:
ownerAddress
- ethereum address of owner/publisher- Returns:
- list of dids
- Throws:
ServiceException
- ServiceException
-
consumerAssets
List<DID> consumerAssets(String consumerAddress) throws ServiceException
List of Asset objects purchased by consumerAddress- Parameters:
consumerAddress
- ethereum address of consumer- Returns:
- list of dids
- Throws:
ServiceException
- ServiceException
-
retire
Boolean retire(DID did) throws DDOException
Retire this did of Metadata- Parameters:
did
- the did- Returns:
- a flag that indicates if the action was executed correctly
- Throws:
DDOException
- DDOException
-
validate
Boolean validate(AssetMetadata metadata) throws DDOException
Validate the asset metadata.- Parameters:
metadata
- the metadata of the DDO- Returns:
- a flag that indicates if the metadata is valid
- Throws:
DDOException
- DDOException
-
transferOwnership
Boolean transferOwnership(DID did, String newOwnerAddress) throws DDOException
Given a DID, transfer the ownership to a new owner. This function only will work if is called by the DID owner.- Parameters:
did
- the didnewOwnerAddress
- the address of the new ownership- Returns:
- a flag that indicates if the action was executed correctly
- Throws:
DDOException
- DDOException
-
delegatePermissions
Boolean delegatePermissions(DID did, String subjectAddress) throws DDOException
For a existing asset, the owner of the asset delegate to a subject read or access permiss- Parameters:
did
- the didsubjectAddress
- the address we want to delegate to- Returns:
- a flag that indicates if the action was executed correctly
- Throws:
DDOException
- DDOException
-
revokePermissions
Boolean revokePermissions(DID did, String subjectAddress) throws DDOException
For a existing asset, the owner of the asset revoke the access grants of a subject.- Parameters:
did
- the didsubjectAddress
- the address we want to revoke to- Returns:
- a flag that indicates if the action was executed correctly
- Throws:
DDOException
- DDOException
-
getPermissions
Boolean getPermissions(DID did, String subjectAddress) throws DDOException
Check if an user has permissions in a specific DID- Parameters:
did
- the didsubjectAddress
- the address- Returns:
- a flag that indicates if the subject address has permissions
- Throws:
DDOException
- DDOException
-
-