Class ConsistencyPolicy

java.lang.Object
com.azure.resourcemanager.cosmos.models.ConsistencyPolicy
All Implemented Interfaces:
com.azure.json.JsonSerializable<ConsistencyPolicy>

public final class ConsistencyPolicy extends Object implements com.azure.json.JsonSerializable<ConsistencyPolicy>
The consistency policy for the Cosmos DB database account.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of ConsistencyPolicy class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the defaultConsistencyLevel property: The default consistency level and configuration settings of the Cosmos DB account.
    fromJson(com.azure.json.JsonReader jsonReader)
    Reads an instance of ConsistencyPolicy from the JsonReader.
    Get the maxIntervalInSeconds property: When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated.
    Get the maxStalenessPrefix property: When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated.
    com.azure.json.JsonWriter
    toJson(com.azure.json.JsonWriter jsonWriter)
    void
    Validates the instance.
    Set the defaultConsistencyLevel property: The default consistency level and configuration settings of the Cosmos DB account.
    withMaxIntervalInSeconds(Integer maxIntervalInSeconds)
    Set the maxIntervalInSeconds property: When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated.
    withMaxStalenessPrefix(Long maxStalenessPrefix)
    Set the maxStalenessPrefix property: When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface com.azure.json.JsonSerializable

    toJson, toJson, toJsonBytes, toJsonString
  • Constructor Details

    • ConsistencyPolicy

      public ConsistencyPolicy()
      Creates an instance of ConsistencyPolicy class.
  • Method Details

    • defaultConsistencyLevel

      public DefaultConsistencyLevel defaultConsistencyLevel()
      Get the defaultConsistencyLevel property: The default consistency level and configuration settings of the Cosmos DB account.
      Returns:
      the defaultConsistencyLevel value.
    • withDefaultConsistencyLevel

      public ConsistencyPolicy withDefaultConsistencyLevel(DefaultConsistencyLevel defaultConsistencyLevel)
      Set the defaultConsistencyLevel property: The default consistency level and configuration settings of the Cosmos DB account.
      Parameters:
      defaultConsistencyLevel - the defaultConsistencyLevel value to set.
      Returns:
      the ConsistencyPolicy object itself.
    • maxStalenessPrefix

      public Long maxStalenessPrefix()
      Get the maxStalenessPrefix property: When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated. Accepted range for this value is 1 – 2,147,483,647. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'.
      Returns:
      the maxStalenessPrefix value.
    • withMaxStalenessPrefix

      public ConsistencyPolicy withMaxStalenessPrefix(Long maxStalenessPrefix)
      Set the maxStalenessPrefix property: When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated. Accepted range for this value is 1 – 2,147,483,647. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'.
      Parameters:
      maxStalenessPrefix - the maxStalenessPrefix value to set.
      Returns:
      the ConsistencyPolicy object itself.
    • maxIntervalInSeconds

      public Integer maxIntervalInSeconds()
      Get the maxIntervalInSeconds property: When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 5 - 86400. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'.
      Returns:
      the maxIntervalInSeconds value.
    • withMaxIntervalInSeconds

      public ConsistencyPolicy withMaxIntervalInSeconds(Integer maxIntervalInSeconds)
      Set the maxIntervalInSeconds property: When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 5 - 86400. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'.
      Parameters:
      maxIntervalInSeconds - the maxIntervalInSeconds value to set.
      Returns:
      the ConsistencyPolicy object itself.
    • validate

      public void validate()
      Validates the instance.
      Throws:
      IllegalArgumentException - thrown if the instance is not valid.
    • toJson

      public com.azure.json.JsonWriter toJson(com.azure.json.JsonWriter jsonWriter) throws IOException
      Specified by:
      toJson in interface com.azure.json.JsonSerializable<ConsistencyPolicy>
      Throws:
      IOException
    • fromJson

      public static ConsistencyPolicy fromJson(com.azure.json.JsonReader jsonReader) throws IOException
      Reads an instance of ConsistencyPolicy from the JsonReader.
      Parameters:
      jsonReader - The JsonReader being read.
      Returns:
      An instance of ConsistencyPolicy if the JsonReader was pointing to an instance of it, or null if it was pointing to JSON null.
      Throws:
      IllegalStateException - If the deserialized JSON object was missing any required properties.
      IOException - If an error occurs while reading the ConsistencyPolicy.