Class DeepSpaceNetworkClient

java.lang.Object
net.adambruce.dsn.now.client.DeepSpaceNetworkClient

public class DeepSpaceNetworkClient extends Object
Client for requesting information from the DSN Now API.
  • Method Details

    • newDeepSpaceNetworkClient

      public static DeepSpaceNetworkClient newDeepSpaceNetworkClient()
      Creates a new instance of the client with the default max configuration age (30 mins).
      Returns:
      a new client
    • newDeepSpaceNetworkClient

      public static DeepSpaceNetworkClient newDeepSpaceNetworkClient(Duration maxConfigurationAge)
      Creates a new instance of the client.
      Parameters:
      maxConfigurationAge - the maximum configuration age before fetchMergedData() will trigger refresh
      Returns:
      a new client
    • fetchConfiguration

      public Configuration fetchConfiguration() throws Exception
      Fetches the DSN Now configuration, and caches it for later use.
      Returns:
      the configuration
      Throws:
      Exception - the network request failed, or the response could not be deserialized
    • fetchState

      public State fetchState() throws Exception
      Fetches the current state of the DSN.
      Returns:
      the current DSN state
      Throws:
      Exception - the network request failed, or the response could not be deserialized
    • fetchMergedData

      public MergedData fetchMergedData() throws Exception
      Fetches the current state of the DSN and merges the response with the DSN Now configuration to provide a complete representation of DSN's current state. If the configuration is uninitialized or expired, a new configuration will be fetched.
      Returns:
      the current DSN state merged with the DSN Now configuration
      Throws:
      Exception - the network request failed, or the response could not be deserialized