# Interface CAClientType

All Superinterfaces:
  `AutoCloseable`, `com.io7m.hibiscus.api.HBClientCloseableType<CAClientException>`, `com.io7m.hibiscus.api.HBClientType<CAIMessageType,CAClientConnectionParameters,CAClientException>`, `com.io7m.hibiscus.api.HBIOOperationsType<CAIMessageType,CAClientException>`, `com.io7m.repetoir.core.RPServiceType`

All Known Implementing Classes:
  `CAClient`

public interface CAClientType extends com.io7m.hibiscus.api.HBClientType<CAIMessageType,CAClientConnectionParameters,CAClientException>, com.io7m.repetoir.core.RPServiceType
The type of client instances.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default CAIMessageType`
  `connectOrThrow(CAClientConnectionParameters parameters)`
  Call `HBClientType.connect(HBConnectionParametersType)` but throw an exception if the result is an `CAIResponseError`.
  `default String`
  `description()`
  `void`
  `fileDownload(CAFileID fileID, Path file, Path fileTmp, long size, String hashAlgorithm, String hashValue, Consumer<CAClientTransferStatistics> statistics)`
  Download the data associated with the given file.
  `void`
  `fileUpload(CAFileID fileID, Path file, String contentType, String description, Consumer<CAClientTransferStatistics> statistics)`
  Upload the data associated with the given file.
  `default <R extends CAIResponseType>
  R`
  `sendAndWaitOrThrow(CAICommandType<R> message, Duration timeout)`
  Call `HBIOOperationsType.sendAndWait(HBMessageType, Duration)` but throw an exception if the result is an `CAIResponseError`.
  `List<CAIResponseType>`
  `transaction(List<CAICommandType<?>> commands)`
  Execute all the given commands in order, in a single transaction.
  `Optional<CAUserID>`
  `userId()`

  ### Methods inherited from interface com.io7m.hibiscus.api.HBClientCloseableType

  `close, isClosed`

  ### Methods inherited from interface com.io7m.hibiscus.api.HBClientType

  `connect, disconnect, state, stateNow`

  ### Methods inherited from interface com.io7m.hibiscus.api.HBIOOperationsType

  `receive, send, sendAndForget, sendAndWait`

- ## Method Details

  - ### description

    default String description()
    Specified by:
      `description` in interface `com.io7m.repetoir.core.RPServiceType`

  - ### userId

    Optional<CAUserID> userId()
    Returns:
      The current logged-in user

  - ### fileDownload

    void fileDownload(CAFileID fileID, Path file, Path fileTmp, long size, String hashAlgorithm, String hashValue, Consumer<CAClientTransferStatistics> statistics) throws InterruptedException, CAClientException
    Download the data associated with the given file. The file will be downloaded to a temporary file and then, if everything succeeds and the hash value matches, the temporary file will atomically replace the output file.
    Parameters:
      `fileID` - The file ID
      `file` - The output file
      `fileTmp` - The temporary output file
      `size` - The expected size
      `hashAlgorithm` - The hash algorithm
      `hashValue` - The expected hash value
      `statistics` - A receiver of transfer statistics
    Throws:
      `CAClientException` - On errors
      `InterruptedException` - On interruption

  - ### fileUpload

    void fileUpload(CAFileID fileID, Path file, String contentType, String description, Consumer<CAClientTransferStatistics> statistics) throws InterruptedException, CAClientException
    Upload the data associated with the given file.
    Parameters:
      `fileID` - The file ID
      `file` - The input file
      `contentType` - The content type
      `description` - The file description
      `statistics` - A receiver of transfer statistics
    Throws:
      `CAClientException` - On errors
      `InterruptedException` - On interruption

  - ### connectOrThrow

    default CAIMessageType connectOrThrow(CAClientConnectionParameters parameters) throws CAClientException, InterruptedException
    Call `HBClientType.connect(HBConnectionParametersType)` but throw an exception if the result is an `CAIResponseError`.
    Parameters:
      `parameters` - The connection parameters
    Returns:
      The success message
    Throws:
      `CAClientException` - On errors
      `InterruptedException` - On interruption

  - ### sendAndWaitOrThrow

    default <R extends CAIResponseType> R sendAndWaitOrThrow(CAICommandType<R> message, Duration timeout) throws CAClientException, InterruptedException, TimeoutException
    Call `HBIOOperationsType.sendAndWait(HBMessageType, Duration)` but throw an exception if the result is an `CAIResponseError`.
    Type Parameters:
      `R` - The type of results
    Parameters:
      `message` - The message
      `timeout` - The timeout
    Returns:
      The result
    Throws:
      `CAClientException` - On errors
      `InterruptedException` - On interruption
      `TimeoutException` - On timeouts

  - ### transaction

    List<CAIResponseType> transaction(List<CAICommandType<?>> commands) throws CAClientException, InterruptedException
    Execute all the given commands in order, in a single transaction.
    Parameters:
      `commands` - The commands
    Returns:
      The responses
    Throws:
      `CAClientException`
      `InterruptedException`