Interface AssetsAPI

  • All Known Implementing Classes:
    AssetsImpl

    public interface AssetsAPI
    Exposes the Public API related with Assets
    • Method Detail

      • create

        DDO create​(AssetMetadata metadata,
                   ProviderConfig providerConfig,
                   int threshold)
            throws DDOException
        Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in Aquarius
        Parameters:
        metadata - the metadata of the DDO
        providerConfig - the endpoints of the DDO's services
        threshold - the secret store threshold
        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 Aquarius
        Parameters:
        metadata - the metadata of the DDO
        providerConfig - the endpoints of the DDO's services
        Returns:
        an instance of the DDO created
        Throws:
        DDOException - 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 criteria
        offset - parameter to paginate
        page - 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 criteria
        offset - parameter to paginate
        page - parameter to paginate
        sort - parameter to sort
        Returns:
        a List with all the DDOs found
        Throws:
        DDOException - DDOException
      • consume

        Boolean consume​(String serviceAgreementId,
                        DID did,
                        String serviceDefinitionId,
                        Integer index,
                        String basePath,
                        int threshold)
                 throws ConsumeServiceException
        Downloads a single file of an Asset previously ordered through a Service Agreement
        Parameters:
        serviceAgreementId - the service agreement id of the asset
        did - the did
        serviceDefinitionId - the service definition id
        index - of the file inside the files definition in metadata
        basePath - the path where the asset will be downloaded
        threshold - secret store threshold to decrypt the urls of the asset
        Returns:
        a flag that indicates if the consume flow was executed correctly
        Throws:
        ConsumeServiceException - ConsumeServiceException
      • consume

        Boolean consume​(String serviceAgreementId,
                        DID did,
                        String serviceDefinitionId,
                        Integer index,
                        String basePath)
                 throws ConsumeServiceException
        Downloads a single file of an Asset previously ordered through a Service Agreement
        Parameters:
        serviceAgreementId - the service agreement id of the asset
        did - the did
        serviceDefinitionId - the service definition id
        index - of the file inside the files definition in metadata
        basePath - 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,
                        String serviceDefinitionId,
                        String basePath,
                        int threshold)
                 throws ConsumeServiceException
        Downloads an Asset previously ordered through a Service Agreement
        Parameters:
        serviceAgreementId - the service agreement id of the asset
        did - the did
        serviceDefinitionId - the service definition id
        basePath - the path where the asset will be downloaded
        threshold - secret store threshold to decrypt the urls of the asset
        Returns:
        a flag that indicates if the consume flow was executed correctly
        Throws:
        ConsumeServiceException - ConsumeServiceException
      • consume

        Boolean consume​(String serviceAgreementId,
                        DID did,
                        String serviceDefinitionId,
                        String basePath)
                 throws ConsumeServiceException
        Downloads an Asset previously ordered through a Service Agreement
        Parameters:
        serviceAgreementId - the service agreement id of the asset
        did - the did
        serviceDefinitionId - the service definition id
        basePath - 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,
                                  String serviceDefinitionId,
                                  Integer index)
                           throws ConsumeServiceException
        Gets the input stream of one file of the asset
        Parameters:
        serviceAgreementId - the service agreement id of the asset
        did - the did
        serviceDefinitionId - the service definition id
        index - 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,
                                  String serviceDefinitionId,
                                  Integer index,
                                  int threshold)
                           throws ConsumeServiceException
        Gets the input stream of one file of the asset
        Parameters:
        serviceAgreementId - the service agreement id of the asset
        did - the did
        serviceDefinitionId - the service definition id
        index - the index of the file
        threshold - secret store threshold to decrypt the urls of the asset
        Returns:
        the input stream wit the binary content of the file
        Throws:
        ConsumeServiceException - ConsumeServiceException
      • consumeBinary

        InputStream consumeBinary​(String serviceAgreementId,
                                  DID did,
                                  String serviceDefinitionId,
                                  Integer index,
                                  Integer rangeStart,
                                  Integer 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 asset
        did - the did
        serviceDefinitionId - the service definition id
        index - the index of the file
        rangeStart - the start of the bytes range
        rangeEnd - the end of the bytes range
        Returns:
        the input stream wit the binary content of the specified range
        Throws:
        ConsumeServiceException - ConsumeServiceException
      • consumeBinary

        InputStream consumeBinary​(String serviceAgreementId,
                                  DID did,
                                  String serviceDefinitionId,
                                  Integer index,
                                  Integer rangeStart,
                                  Integer rangeEnd,
                                  int threshold)
                           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 asset
        did - the did
        serviceDefinitionId - the service definition id
        index - the index of the file
        rangeStart - the start of the bytes range
        rangeEnd - the end of the bytes range
        threshold - secret store threshold to decrypt the urls of the asset
        Returns:
        the input stream wit the binary content of the specified range
        Throws:
        ConsumeServiceException - ConsumeServiceException
      • order

        io.reactivex.Flowable<OrderResult> order​(DID did,
                                                 String 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 DDO
        serviceDefinitionId - 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
      • 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 Aquarius
        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