# Class CAClient

java.lang.Object
com.io7m.hibiscus.api.HBClientAbstract<CAIMessageType,CAClientConnectionParameters,CAClientException>
com.io7m.cardant.client.basic.internal.CAClient

All Implemented Interfaces:
  `CAClientType`, `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`, `AutoCloseable`

public final class CAClient extends com.io7m.hibiscus.api.HBClientAbstract<CAIMessageType,CAClientConnectionParameters,CAClientException> implements CAClientType
The synchronous client.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CAClient(CAClientConfiguration inConfiguration, CAStrings inStrings, Supplier<HttpClient> inHttpClients)`
  The client.

- ## Method Summary

  Modifier and Type
  Method
  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.
  `String`
  `toString()`
  `List<CAIResponseType>`
  `transaction(List<CAICommandType<?>> commands)`
  Execute all the given commands in order, in a single transaction.
  `Optional<CAUserID>`
  `userId()`

  ### Methods inherited from class com.io7m.hibiscus.api.HBClientAbstract

  `checkNotClosingOrClosed, close, connect, disconnect, handler, isClosed, receive, send, sendAndForget, sendAndWait, state, stateNow`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface com.io7m.cardant.client.api.CAClientType

  `connectOrThrow, description, sendAndWaitOrThrow`

  ### 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`

- ## Constructor Details

  - ### CAClient

    public CAClient(CAClientConfiguration inConfiguration, CAStrings inStrings, Supplier<HttpClient> inHttpClients)
    The client.
    Parameters:
      `inConfiguration` - The configuration
      `inStrings` - The string resources
      `inHttpClients` - The HTTP clients

- ## Method Details

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### userId

    public Optional<CAUserID> userId()
    Specified by:
      `userId` in interface `CAClientType`
    Returns:
      The current logged-in user

  - ### fileDownload

    public void fileDownload(CAFileID fileID, Path file, Path fileTmp, long size, String hashAlgorithm, String hashValue, Consumer<CAClientTransferStatistics> statistics) throws InterruptedException, CAClientException
    Description copied from interface: `CAClientType`
    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.
    Specified by:
      `fileDownload` in interface `CAClientType`
    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:
      `InterruptedException` - On interruption
      `CAClientException` - On errors

  - ### fileUpload

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

  - ### transaction

    public List<CAIResponseType> transaction(List<CAICommandType<?>> commands) throws CAClientException, InterruptedException
    Description copied from interface: `CAClientType`
    Execute all the given commands in order, in a single transaction.
    Specified by:
      `transaction` in interface `CAClientType`
    Parameters:
      `commands` - The commands
    Returns:
      The responses
    Throws:
      `CAClientException`
      `InterruptedException`