Class GatewayService


  • public class GatewayService
    extends Object
    Service for Gateway's Integration
    • Constructor Detail

      • GatewayService

        public GatewayService()
    • Method Detail

      • initializeAccessServiceAgreement

        @Deprecated
        public static GatewayService.ServiceAgreementResult initializeAccessServiceAgreement​(String url,
                                                                                             InitializeAccessSLA payload)
        Deprecated.
        This method is Deprecated and will be removed in further versions Calls a Gateway's endpoint to request the initialization of a new Service Agreement
        Parameters:
        url - the url
        payload - the payload
        Returns:
        an object that indicates if the Gateway initialized the Service Agreement correctly
      • consumeUrl

        public static io.keyko.common.helpers.HttpHelper.DownloadResult consumeUrl​(String serviceEndpoint,
                                                                                   String consumerAddress,
                                                                                   String serviceAgreementId,
                                                                                   String url,
                                                                                   String destinationPath)
                                                                            throws IOException,
                                                                                   URISyntaxException
        Calls a Gateway´s endpoint to download an asset
        Parameters:
        serviceEndpoint - the service endpoint
        consumerAddress - the address of the consumer
        serviceAgreementId - the serviceAgreement Id
        url - the url
        destinationPath - the path to download the resource
        Returns:
        DownloadResult Instance of DownloadResult that indicates if the download was correct
        Throws:
        IOException - IOException
        URISyntaxException - URISyntaxException
      • downloadUrl

        public static void downloadUrl​(String serviceEndpoint,
                                       String consumerAddress,
                                       String serviceAgreementId,
                                       String url,
                                       String destinationPath)
                                throws IOException
        Calls a Gateway endpoint to download an asset
        Parameters:
        serviceEndpoint - the service endpoint
        consumerAddress - the address of the consumer
        serviceAgreementId - the serviceAgreement Id
        url - the url
        destinationPath - the path to download the resource
        Throws:
        IOException - Exception during the download process
      • downloadUrl

        public static InputStream downloadUrl​(String serviceEndpoint,
                                              String consumerAddress,
                                              String serviceAgreementId,
                                              String did,
                                              int index,
                                              String signature,
                                              Boolean isRangeRequest,
                                              Integer startRange,
                                              Integer endRange)
                                       throws IOException
        Calls a Gateway endpoint to download an asset
        Parameters:
        serviceEndpoint - the service endpoint
        consumerAddress - the address of the consumer
        serviceAgreementId - the serviceAgreement Id
        did - asset decentralized identifier
        index - index position of the file in the DDO
        signature - User signature of the service agreement
        startRange - the start of the bytes range
        endRange - the end of the bytes range
        isRangeRequest - indicates if is a range request
        Returns:
        an InputStream that represents the binary content
        Throws:
        IOException - Exception during the download process
      • downloadUrlByOwner

        public static InputStream downloadUrlByOwner​(String serviceEndpoint,
                                                     String consumerAddress,
                                                     String did,
                                                     int index,
                                                     String signature,
                                                     Boolean isRangeRequest,
                                                     Integer startRange,
                                                     Integer endRange)
                                              throws IOException
        Calls a Gateway endpoint by the owner of an asset to to download it
        Parameters:
        serviceEndpoint - the service endpoint
        consumerAddress - the address of the consumer
        did - asset decentralized identifier
        index - index position of the file in the DDO
        signature - User signature of the service agreement
        startRange - the start of the bytes range
        endRange - the end of the bytes range
        isRangeRequest - indicates if is a range request
        Returns:
        an InputStream that represents the binary content
        Throws:
        IOException - Exception during the download process
      • downloadToPath

        public static void downloadToPath​(String serviceEndpoint,
                                          String consumerAddress,
                                          String serviceAgreementId,
                                          String did,
                                          int index,
                                          String signature,
                                          String destinationPath,
                                          Boolean isRangeRequest,
                                          Integer startRange,
                                          Integer endRange)
                                   throws IOException
        Calls a Gateway endpoint to download an asset
        Parameters:
        serviceEndpoint - the service endpoint
        consumerAddress - the address of the consumer
        serviceAgreementId - the serviceAgreement Id
        did - asset decentralized identifier
        index - index position of the file in the DDO
        signature - User signature of the service agreement
        destinationPath - path where the downloaded asset will be stored
        startRange - the start of the bytes range
        endRange - the end of the bytes range
        isRangeRequest - indicates if is a range request
        Throws:
        IOException - Exception during the download process
      • downloadToPathByOwner

        public static void downloadToPathByOwner​(String serviceEndpoint,
                                                 String consumerAddress,
                                                 String did,
                                                 int index,
                                                 String signature,
                                                 String destinationPath,
                                                 Boolean isRangeRequest,
                                                 Integer startRange,
                                                 Integer endRange)
                                          throws IOException
        Calls a Gateway endpoint to download an asset
        Parameters:
        serviceEndpoint - the service endpoint
        consumerAddress - the address of the consumer
        did - asset decentralized identifier
        index - index position of the file in the DDO
        signature - User signature of the service agreement
        destinationPath - path where the downloaded asset will be stored
        startRange - the start of the bytes range
        endRange - the end of the bytes range
        isRangeRequest - indicates if is a range request
        Throws:
        IOException - Exception during the download process
      • getStatus

        public static Status getStatus​(String serviceEndpoint)
                                throws IOException
        Calls a Gateway endpoint to download an asset
        Parameters:
        serviceEndpoint - the service endpoint
        Returns:
        an InputStream that represents the binary content
        Throws:
        IOException - Exception during the download process
      • encrypt

        public static EncryptionResponse encrypt​(String gatewayUrl,
                                                 String message,
                                                 AuthorizationService.AuthTypes authType)
                                          throws ServiceException
        Calls a Gateway endpoint to request the execution of a Compute Service
        Parameters:
        gatewayUrl - encryption endpoint
        message - the message to encrypt
        authType - AuthType to use for encryption
        Returns:
        EncryptionResponse an object that indicates if Gateway initialized the Execution of the Service correctly
        Throws:
        ServiceException - Service Exception
      • encrypt

        public static EncryptionResponse encrypt​(String gatewayUrl,
                                                 String message,
                                                 AuthorizationService.AuthTypes authType,
                                                 String did)
                                          throws ServiceException
        Calls a Gateway endpoint to request the execution of a Compute Service
        Parameters:
        gatewayUrl - encryption endpoint
        message - the message to encrypt
        authType - AuthType to use for encryption
        did - DID used to encrypt when using SecretStore
        Returns:
        EncryptionResponse an object with the gateway encryption response
        Throws:
        ServiceException - Service Exception
      • initializeServiceExecution

        public static GatewayService.ServiceExecutionResult initializeServiceExecution​(String serviceEndpoint,
                                                                                       ExecuteService executeService)
        Calls a Gateway endpoint to request the execution of a Compute Service
        Parameters:
        serviceEndpoint - the serviceEndpoint
        executeService - the payload
        Returns:
        an object that indicates if Gateway initialized the Execution of the Service correctly
      • getComputeLogs

        public static List<ComputeLogs> getComputeLogs​(String serviceEndpoint,
                                                       String consumerAddress,
                                                       String signature)
                                                throws ServiceException
        Calls a gateway endpoint to get the compute logs
        Parameters:
        serviceEndpoint - the gateway service endpoint
        consumerAddress - the address of the consumer of the compute to the data job
        signature - the signature of the executionId
        Returns:
        a list of compute logs.
        Throws:
        ServiceException - ServiceException
      • getComputeStatus

        public static ComputeStatus getComputeStatus​(String serviceEndpoint,
                                                     String consumerAddress,
                                                     String signature)
                                              throws ServiceException
        Calls a gateway endpoint to get the compute status
        Parameters:
        serviceEndpoint - the gateway service endpoint
        consumerAddress - the address of the consumer of the compute to the data job
        signature - the signature of the executionId
        Returns:
        the current status of the compute job.
        Throws:
        ServiceException - ServiceException