module Hasura.Server.Types
  ( ExperimentalFeature (..),
    experimentalFeatureKey,
    InstanceId (..),
    generateInstanceId,
    MetadataDbId (..),
    DbUid (..),
    mdDbIdToDbUid,
    MaintenanceMode (..),
    EventingMode (..),
    ReadOnlyMode (..),
    DbVersion (DbVersion),
    PGVersion (PGVersion),
    pgToDbVersion,
    RequestId (..),
    CheckFeatureFlag (..),
    getRequestId,
    ApolloFederationStatus (..),
    isApolloFederationEnabled,
    GranularPrometheusMetricsState (..),
    CloseWebsocketsOnMetadataChangeStatus (..),
    isCloseWebsocketsOnMetadataChangeStatusEnabled,
    MonadGetPolicies (..),
  )
where

import Data.Aeson
import Data.Text (intercalate, unpack)
import Database.PG.Query qualified as PG
import Hasura.Prelude hiding (intercalate)
import Hasura.RQL.Types.ApiLimit
import Hasura.Server.Init.FeatureFlag (CheckFeatureFlag (..))
import Hasura.Server.Utils
import Network.HTTP.Types qualified as HTTP

newtype RequestId = RequestId {RequestId -> Text
unRequestId :: Text}
  deriving (Int -> RequestId -> ShowS
[RequestId] -> ShowS
RequestId -> String
(Int -> RequestId -> ShowS)
-> (RequestId -> String)
-> ([RequestId] -> ShowS)
-> Show RequestId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RequestId -> ShowS
showsPrec :: Int -> RequestId -> ShowS
$cshow :: RequestId -> String
show :: RequestId -> String
$cshowList :: [RequestId] -> ShowS
showList :: [RequestId] -> ShowS
Show, RequestId -> RequestId -> Bool
(RequestId -> RequestId -> Bool)
-> (RequestId -> RequestId -> Bool) -> Eq RequestId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RequestId -> RequestId -> Bool
== :: RequestId -> RequestId -> Bool
$c/= :: RequestId -> RequestId -> Bool
/= :: RequestId -> RequestId -> Bool
Eq, [RequestId] -> Value
[RequestId] -> Encoding
RequestId -> Value
RequestId -> Encoding
(RequestId -> Value)
-> (RequestId -> Encoding)
-> ([RequestId] -> Value)
-> ([RequestId] -> Encoding)
-> ToJSON RequestId
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: RequestId -> Value
toJSON :: RequestId -> Value
$ctoEncoding :: RequestId -> Encoding
toEncoding :: RequestId -> Encoding
$ctoJSONList :: [RequestId] -> Value
toJSONList :: [RequestId] -> Value
$ctoEncodingList :: [RequestId] -> Encoding
toEncodingList :: [RequestId] -> Encoding
ToJSON, Value -> Parser [RequestId]
Value -> Parser RequestId
(Value -> Parser RequestId)
-> (Value -> Parser [RequestId]) -> FromJSON RequestId
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser RequestId
parseJSON :: Value -> Parser RequestId
$cparseJSONList :: Value -> Parser [RequestId]
parseJSONList :: Value -> Parser [RequestId]
FromJSON, Eq RequestId
Eq RequestId
-> (Int -> RequestId -> Int)
-> (RequestId -> Int)
-> Hashable RequestId
Int -> RequestId -> Int
RequestId -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> RequestId -> Int
hashWithSalt :: Int -> RequestId -> Int
$chash :: RequestId -> Int
hash :: RequestId -> Int
Hashable)

getRequestId :: (MonadIO m) => [HTTP.Header] -> m (RequestId, [HTTP.Header])
getRequestId :: forall (m :: * -> *).
MonadIO m =>
[Header] -> m (RequestId, [Header])
getRequestId [Header]
headers = do
  -- generate a request id for every request if the client has not sent it
  let mkHeader :: t -> (HeaderName, t)
mkHeader = (HeaderName
forall a. IsString a => a
requestIdHeader,)
  case HeaderName -> [Header] -> Maybe ByteString
getRequestHeader HeaderName
forall a. IsString a => a
requestIdHeader [Header]
headers of
    Maybe ByteString
Nothing -> do
      Text
reqId <- IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO Text
generateFingerprint
      let r :: RequestId
r = Text -> RequestId
RequestId Text
reqId
      (RequestId, [Header]) -> m (RequestId, [Header])
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (RequestId
r, ByteString -> Header
forall {t}. t -> (HeaderName, t)
mkHeader (Text -> ByteString
txtToBs Text
reqId) Header -> [Header] -> [Header]
forall a. a -> [a] -> [a]
: [Header]
headers)
    Just ByteString
reqId -> (RequestId, [Header]) -> m (RequestId, [Header])
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text -> RequestId
RequestId (Text -> RequestId) -> Text -> RequestId
forall a b. (a -> b) -> a -> b
$ ByteString -> Text
bsToTxt ByteString
reqId, [Header]
headers)

-- | A uuid of a source database.
newtype DbUid = DbUid {DbUid -> Text
getDbUid :: Text}
  deriving (Int -> DbUid -> ShowS
[DbUid] -> ShowS
DbUid -> String
(Int -> DbUid -> ShowS)
-> (DbUid -> String) -> ([DbUid] -> ShowS) -> Show DbUid
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DbUid -> ShowS
showsPrec :: Int -> DbUid -> ShowS
$cshow :: DbUid -> String
show :: DbUid -> String
$cshowList :: [DbUid] -> ShowS
showList :: [DbUid] -> ShowS
Show, DbUid -> DbUid -> Bool
(DbUid -> DbUid -> Bool) -> (DbUid -> DbUid -> Bool) -> Eq DbUid
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DbUid -> DbUid -> Bool
== :: DbUid -> DbUid -> Bool
$c/= :: DbUid -> DbUid -> Bool
/= :: DbUid -> DbUid -> Bool
Eq, [DbUid] -> Value
[DbUid] -> Encoding
DbUid -> Value
DbUid -> Encoding
(DbUid -> Value)
-> (DbUid -> Encoding)
-> ([DbUid] -> Value)
-> ([DbUid] -> Encoding)
-> ToJSON DbUid
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: DbUid -> Value
toJSON :: DbUid -> Value
$ctoEncoding :: DbUid -> Encoding
toEncoding :: DbUid -> Encoding
$ctoJSONList :: [DbUid] -> Value
toJSONList :: [DbUid] -> Value
$ctoEncodingList :: [DbUid] -> Encoding
toEncodingList :: [DbUid] -> Encoding
ToJSON, Value -> Parser [DbUid]
Value -> Parser DbUid
(Value -> Parser DbUid)
-> (Value -> Parser [DbUid]) -> FromJSON DbUid
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser DbUid
parseJSON :: Value -> Parser DbUid
$cparseJSONList :: Value -> Parser [DbUid]
parseJSONList :: Value -> Parser [DbUid]
FromJSON)

newtype DbVersion = DbVersion {DbVersion -> Text
unDbVersion :: Text}
  deriving (Int -> DbVersion -> ShowS
[DbVersion] -> ShowS
DbVersion -> String
(Int -> DbVersion -> ShowS)
-> (DbVersion -> String)
-> ([DbVersion] -> ShowS)
-> Show DbVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DbVersion -> ShowS
showsPrec :: Int -> DbVersion -> ShowS
$cshow :: DbVersion -> String
show :: DbVersion -> String
$cshowList :: [DbVersion] -> ShowS
showList :: [DbVersion] -> ShowS
Show, DbVersion -> DbVersion -> Bool
(DbVersion -> DbVersion -> Bool)
-> (DbVersion -> DbVersion -> Bool) -> Eq DbVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DbVersion -> DbVersion -> Bool
== :: DbVersion -> DbVersion -> Bool
$c/= :: DbVersion -> DbVersion -> Bool
/= :: DbVersion -> DbVersion -> Bool
Eq, [DbVersion] -> Value
[DbVersion] -> Encoding
DbVersion -> Value
DbVersion -> Encoding
(DbVersion -> Value)
-> (DbVersion -> Encoding)
-> ([DbVersion] -> Value)
-> ([DbVersion] -> Encoding)
-> ToJSON DbVersion
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: DbVersion -> Value
toJSON :: DbVersion -> Value
$ctoEncoding :: DbVersion -> Encoding
toEncoding :: DbVersion -> Encoding
$ctoJSONList :: [DbVersion] -> Value
toJSONList :: [DbVersion] -> Value
$ctoEncodingList :: [DbVersion] -> Encoding
toEncodingList :: [DbVersion] -> Encoding
ToJSON)

newtype PGVersion = PGVersion {PGVersion -> Int
unPGVersion :: Int}
  deriving (Int -> PGVersion -> ShowS
[PGVersion] -> ShowS
PGVersion -> String
(Int -> PGVersion -> ShowS)
-> (PGVersion -> String)
-> ([PGVersion] -> ShowS)
-> Show PGVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PGVersion -> ShowS
showsPrec :: Int -> PGVersion -> ShowS
$cshow :: PGVersion -> String
show :: PGVersion -> String
$cshowList :: [PGVersion] -> ShowS
showList :: [PGVersion] -> ShowS
Show, PGVersion -> PGVersion -> Bool
(PGVersion -> PGVersion -> Bool)
-> (PGVersion -> PGVersion -> Bool) -> Eq PGVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PGVersion -> PGVersion -> Bool
== :: PGVersion -> PGVersion -> Bool
$c/= :: PGVersion -> PGVersion -> Bool
/= :: PGVersion -> PGVersion -> Bool
Eq, [PGVersion] -> Value
[PGVersion] -> Encoding
PGVersion -> Value
PGVersion -> Encoding
(PGVersion -> Value)
-> (PGVersion -> Encoding)
-> ([PGVersion] -> Value)
-> ([PGVersion] -> Encoding)
-> ToJSON PGVersion
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: PGVersion -> Value
toJSON :: PGVersion -> Value
$ctoEncoding :: PGVersion -> Encoding
toEncoding :: PGVersion -> Encoding
$ctoJSONList :: [PGVersion] -> Value
toJSONList :: [PGVersion] -> Value
$ctoEncodingList :: [PGVersion] -> Encoding
toEncodingList :: [PGVersion] -> Encoding
ToJSON)

pgToDbVersion :: PGVersion -> DbVersion
pgToDbVersion :: PGVersion -> DbVersion
pgToDbVersion = Text -> DbVersion
DbVersion (Text -> DbVersion)
-> (PGVersion -> Text) -> PGVersion -> DbVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Text
forall a. Show a => a -> Text
tshow (Int -> Text) -> (PGVersion -> Int) -> PGVersion -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PGVersion -> Int
unPGVersion

-- | A uuid of the postgres metadata db.
newtype MetadataDbId = MetadataDbId {MetadataDbId -> Text
getMetadataDbId :: Text}
  deriving (Int -> MetadataDbId -> ShowS
[MetadataDbId] -> ShowS
MetadataDbId -> String
(Int -> MetadataDbId -> ShowS)
-> (MetadataDbId -> String)
-> ([MetadataDbId] -> ShowS)
-> Show MetadataDbId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MetadataDbId -> ShowS
showsPrec :: Int -> MetadataDbId -> ShowS
$cshow :: MetadataDbId -> String
show :: MetadataDbId -> String
$cshowList :: [MetadataDbId] -> ShowS
showList :: [MetadataDbId] -> ShowS
Show, MetadataDbId -> MetadataDbId -> Bool
(MetadataDbId -> MetadataDbId -> Bool)
-> (MetadataDbId -> MetadataDbId -> Bool) -> Eq MetadataDbId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MetadataDbId -> MetadataDbId -> Bool
== :: MetadataDbId -> MetadataDbId -> Bool
$c/= :: MetadataDbId -> MetadataDbId -> Bool
/= :: MetadataDbId -> MetadataDbId -> Bool
Eq, [MetadataDbId] -> Value
[MetadataDbId] -> Encoding
MetadataDbId -> Value
MetadataDbId -> Encoding
(MetadataDbId -> Value)
-> (MetadataDbId -> Encoding)
-> ([MetadataDbId] -> Value)
-> ([MetadataDbId] -> Encoding)
-> ToJSON MetadataDbId
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: MetadataDbId -> Value
toJSON :: MetadataDbId -> Value
$ctoEncoding :: MetadataDbId -> Encoding
toEncoding :: MetadataDbId -> Encoding
$ctoJSONList :: [MetadataDbId] -> Value
toJSONList :: [MetadataDbId] -> Value
$ctoEncodingList :: [MetadataDbId] -> Encoding
toEncodingList :: [MetadataDbId] -> Encoding
ToJSON, Value -> Parser [MetadataDbId]
Value -> Parser MetadataDbId
(Value -> Parser MetadataDbId)
-> (Value -> Parser [MetadataDbId]) -> FromJSON MetadataDbId
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser MetadataDbId
parseJSON :: Value -> Parser MetadataDbId
$cparseJSONList :: Value -> Parser [MetadataDbId]
parseJSONList :: Value -> Parser [MetadataDbId]
FromJSON, Maybe ByteString -> Either Text MetadataDbId
(Maybe ByteString -> Either Text MetadataDbId)
-> FromCol MetadataDbId
forall a. (Maybe ByteString -> Either Text a) -> FromCol a
$cfromCol :: Maybe ByteString -> Either Text MetadataDbId
fromCol :: Maybe ByteString -> Either Text MetadataDbId
PG.FromCol, MetadataDbId -> PrepArg
(MetadataDbId -> PrepArg) -> ToPrepArg MetadataDbId
forall a. (a -> PrepArg) -> ToPrepArg a
$ctoPrepVal :: MetadataDbId -> PrepArg
toPrepVal :: MetadataDbId -> PrepArg
PG.ToPrepArg)

mdDbIdToDbUid :: MetadataDbId -> DbUid
mdDbIdToDbUid :: MetadataDbId -> DbUid
mdDbIdToDbUid = Text -> DbUid
DbUid (Text -> DbUid) -> (MetadataDbId -> Text) -> MetadataDbId -> DbUid
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetadataDbId -> Text
getMetadataDbId

-- | A UUID for each running instance of graphql-engine, generated fresh each
-- time graphql-engine starts up
newtype InstanceId = InstanceId {InstanceId -> Text
getInstanceId :: Text}
  deriving (Int -> InstanceId -> ShowS
[InstanceId] -> ShowS
InstanceId -> String
(Int -> InstanceId -> ShowS)
-> (InstanceId -> String)
-> ([InstanceId] -> ShowS)
-> Show InstanceId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InstanceId -> ShowS
showsPrec :: Int -> InstanceId -> ShowS
$cshow :: InstanceId -> String
show :: InstanceId -> String
$cshowList :: [InstanceId] -> ShowS
showList :: [InstanceId] -> ShowS
Show, InstanceId -> InstanceId -> Bool
(InstanceId -> InstanceId -> Bool)
-> (InstanceId -> InstanceId -> Bool) -> Eq InstanceId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InstanceId -> InstanceId -> Bool
== :: InstanceId -> InstanceId -> Bool
$c/= :: InstanceId -> InstanceId -> Bool
/= :: InstanceId -> InstanceId -> Bool
Eq, [InstanceId] -> Value
[InstanceId] -> Encoding
InstanceId -> Value
InstanceId -> Encoding
(InstanceId -> Value)
-> (InstanceId -> Encoding)
-> ([InstanceId] -> Value)
-> ([InstanceId] -> Encoding)
-> ToJSON InstanceId
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: InstanceId -> Value
toJSON :: InstanceId -> Value
$ctoEncoding :: InstanceId -> Encoding
toEncoding :: InstanceId -> Encoding
$ctoJSONList :: [InstanceId] -> Value
toJSONList :: [InstanceId] -> Value
$ctoEncodingList :: [InstanceId] -> Encoding
toEncodingList :: [InstanceId] -> Encoding
ToJSON, Value -> Parser [InstanceId]
Value -> Parser InstanceId
(Value -> Parser InstanceId)
-> (Value -> Parser [InstanceId]) -> FromJSON InstanceId
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser InstanceId
parseJSON :: Value -> Parser InstanceId
$cparseJSONList :: Value -> Parser [InstanceId]
parseJSONList :: Value -> Parser [InstanceId]
FromJSON, Maybe ByteString -> Either Text InstanceId
(Maybe ByteString -> Either Text InstanceId) -> FromCol InstanceId
forall a. (Maybe ByteString -> Either Text a) -> FromCol a
$cfromCol :: Maybe ByteString -> Either Text InstanceId
fromCol :: Maybe ByteString -> Either Text InstanceId
PG.FromCol, InstanceId -> PrepArg
(InstanceId -> PrepArg) -> ToPrepArg InstanceId
forall a. (a -> PrepArg) -> ToPrepArg a
$ctoPrepVal :: InstanceId -> PrepArg
toPrepVal :: InstanceId -> PrepArg
PG.ToPrepArg)

-- | Generate an 'InstanceId' from a 'UUID'
generateInstanceId :: IO InstanceId
generateInstanceId :: IO InstanceId
generateInstanceId = Text -> InstanceId
InstanceId (Text -> InstanceId) -> IO Text -> IO InstanceId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO Text
generateFingerprint

data ExperimentalFeature
  = EFInheritedRoles
  | EFOptimizePermissionFilters
  | EFNamingConventions
  | EFStreamingSubscriptions
  | EFApolloFederation
  | EFHideUpdateManyFields
  | EFBigQueryStringNumericInput
  | EFHideAggregationPredicates
  | EFHideStreamFields
  | EFGroupByAggregations
  | EFDisablePostgresArrays
  deriving (ExperimentalFeature
ExperimentalFeature
-> ExperimentalFeature -> Bounded ExperimentalFeature
forall a. a -> a -> Bounded a
$cminBound :: ExperimentalFeature
minBound :: ExperimentalFeature
$cmaxBound :: ExperimentalFeature
maxBound :: ExperimentalFeature
Bounded, Int -> ExperimentalFeature
ExperimentalFeature -> Int
ExperimentalFeature -> [ExperimentalFeature]
ExperimentalFeature -> ExperimentalFeature
ExperimentalFeature -> ExperimentalFeature -> [ExperimentalFeature]
ExperimentalFeature
-> ExperimentalFeature
-> ExperimentalFeature
-> [ExperimentalFeature]
(ExperimentalFeature -> ExperimentalFeature)
-> (ExperimentalFeature -> ExperimentalFeature)
-> (Int -> ExperimentalFeature)
-> (ExperimentalFeature -> Int)
-> (ExperimentalFeature -> [ExperimentalFeature])
-> (ExperimentalFeature
    -> ExperimentalFeature -> [ExperimentalFeature])
-> (ExperimentalFeature
    -> ExperimentalFeature -> [ExperimentalFeature])
-> (ExperimentalFeature
    -> ExperimentalFeature
    -> ExperimentalFeature
    -> [ExperimentalFeature])
-> Enum ExperimentalFeature
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: ExperimentalFeature -> ExperimentalFeature
succ :: ExperimentalFeature -> ExperimentalFeature
$cpred :: ExperimentalFeature -> ExperimentalFeature
pred :: ExperimentalFeature -> ExperimentalFeature
$ctoEnum :: Int -> ExperimentalFeature
toEnum :: Int -> ExperimentalFeature
$cfromEnum :: ExperimentalFeature -> Int
fromEnum :: ExperimentalFeature -> Int
$cenumFrom :: ExperimentalFeature -> [ExperimentalFeature]
enumFrom :: ExperimentalFeature -> [ExperimentalFeature]
$cenumFromThen :: ExperimentalFeature -> ExperimentalFeature -> [ExperimentalFeature]
enumFromThen :: ExperimentalFeature -> ExperimentalFeature -> [ExperimentalFeature]
$cenumFromTo :: ExperimentalFeature -> ExperimentalFeature -> [ExperimentalFeature]
enumFromTo :: ExperimentalFeature -> ExperimentalFeature -> [ExperimentalFeature]
$cenumFromThenTo :: ExperimentalFeature
-> ExperimentalFeature
-> ExperimentalFeature
-> [ExperimentalFeature]
enumFromThenTo :: ExperimentalFeature
-> ExperimentalFeature
-> ExperimentalFeature
-> [ExperimentalFeature]
Enum, ExperimentalFeature -> ExperimentalFeature -> Bool
(ExperimentalFeature -> ExperimentalFeature -> Bool)
-> (ExperimentalFeature -> ExperimentalFeature -> Bool)
-> Eq ExperimentalFeature
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ExperimentalFeature -> ExperimentalFeature -> Bool
== :: ExperimentalFeature -> ExperimentalFeature -> Bool
$c/= :: ExperimentalFeature -> ExperimentalFeature -> Bool
/= :: ExperimentalFeature -> ExperimentalFeature -> Bool
Eq, (forall x. ExperimentalFeature -> Rep ExperimentalFeature x)
-> (forall x. Rep ExperimentalFeature x -> ExperimentalFeature)
-> Generic ExperimentalFeature
forall x. Rep ExperimentalFeature x -> ExperimentalFeature
forall x. ExperimentalFeature -> Rep ExperimentalFeature x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ExperimentalFeature -> Rep ExperimentalFeature x
from :: forall x. ExperimentalFeature -> Rep ExperimentalFeature x
$cto :: forall x. Rep ExperimentalFeature x -> ExperimentalFeature
to :: forall x. Rep ExperimentalFeature x -> ExperimentalFeature
Generic, Int -> ExperimentalFeature -> ShowS
[ExperimentalFeature] -> ShowS
ExperimentalFeature -> String
(Int -> ExperimentalFeature -> ShowS)
-> (ExperimentalFeature -> String)
-> ([ExperimentalFeature] -> ShowS)
-> Show ExperimentalFeature
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExperimentalFeature -> ShowS
showsPrec :: Int -> ExperimentalFeature -> ShowS
$cshow :: ExperimentalFeature -> String
show :: ExperimentalFeature -> String
$cshowList :: [ExperimentalFeature] -> ShowS
showList :: [ExperimentalFeature] -> ShowS
Show)

experimentalFeatureKey :: ExperimentalFeature -> Text
experimentalFeatureKey :: ExperimentalFeature -> Text
experimentalFeatureKey = \case
  ExperimentalFeature
EFInheritedRoles -> Text
"inherited_roles"
  ExperimentalFeature
EFOptimizePermissionFilters -> Text
"optimize_permission_filters"
  ExperimentalFeature
EFNamingConventions -> Text
"naming_convention"
  ExperimentalFeature
EFStreamingSubscriptions -> Text
"streaming_subscriptions"
  ExperimentalFeature
EFApolloFederation -> Text
"apollo_federation"
  ExperimentalFeature
EFHideUpdateManyFields -> Text
"hide_update_many_fields"
  ExperimentalFeature
EFBigQueryStringNumericInput -> Text
"bigquery_string_numeric_input"
  ExperimentalFeature
EFHideAggregationPredicates -> Text
"hide_aggregation_predicates"
  ExperimentalFeature
EFHideStreamFields -> Text
"hide_stream_fields"
  ExperimentalFeature
EFGroupByAggregations -> Text
"group_by_aggregations"
  ExperimentalFeature
EFDisablePostgresArrays -> Text
"disable_postgres_arrays"

instance Hashable ExperimentalFeature

instance FromJSON ExperimentalFeature where
  parseJSON :: Value -> Parser ExperimentalFeature
parseJSON = String
-> (Text -> Parser ExperimentalFeature)
-> Value
-> Parser ExperimentalFeature
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"ExperimentalFeature" ((Text -> Parser ExperimentalFeature)
 -> Value -> Parser ExperimentalFeature)
-> (Text -> Parser ExperimentalFeature)
-> Value
-> Parser ExperimentalFeature
forall a b. (a -> b) -> a -> b
$ \case
    Text
k | Just (Text
_, ExperimentalFeature
ef) <- ((Text, ExperimentalFeature) -> Bool)
-> [(Text, ExperimentalFeature)]
-> Maybe (Text, ExperimentalFeature)
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find ((Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
k) (Text -> Bool)
-> ((Text, ExperimentalFeature) -> Text)
-> (Text, ExperimentalFeature)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text, ExperimentalFeature) -> Text
forall a b. (a, b) -> a
fst) [(Text, ExperimentalFeature)]
experimentalFeatures -> ExperimentalFeature -> Parser ExperimentalFeature
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (ExperimentalFeature -> Parser ExperimentalFeature)
-> ExperimentalFeature -> Parser ExperimentalFeature
forall a b. (a -> b) -> a -> b
$ ExperimentalFeature
ef
    Text
_ ->
      String -> Parser ExperimentalFeature
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail
        (String -> Parser ExperimentalFeature)
-> String -> Parser ExperimentalFeature
forall a b. (a -> b) -> a -> b
$ String
"ExperimentalFeature can only be one of these values: "
        String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
unpack (Text -> [Text] -> Text
intercalate Text
"," (((Text, ExperimentalFeature) -> Text)
-> [(Text, ExperimentalFeature)] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map (Text, ExperimentalFeature) -> Text
forall a b. (a, b) -> a
fst [(Text, ExperimentalFeature)]
experimentalFeatures))
    where
      experimentalFeatures :: [(Text, ExperimentalFeature)]
      experimentalFeatures :: [(Text, ExperimentalFeature)]
experimentalFeatures =
        [ (ExperimentalFeature -> Text
experimentalFeatureKey ExperimentalFeature
ef, ExperimentalFeature
ef)
          | ExperimentalFeature
ef <- [ExperimentalFeature
forall a. Bounded a => a
minBound .. ExperimentalFeature
forall a. Bounded a => a
maxBound]
        ]

instance ToJSON ExperimentalFeature where
  toJSON :: ExperimentalFeature -> Value
toJSON = Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value)
-> (ExperimentalFeature -> Text) -> ExperimentalFeature -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExperimentalFeature -> Text
experimentalFeatureKey

data MaintenanceMode a = MaintenanceModeEnabled a | MaintenanceModeDisabled
  deriving (Int -> MaintenanceMode a -> ShowS
[MaintenanceMode a] -> ShowS
MaintenanceMode a -> String
(Int -> MaintenanceMode a -> ShowS)
-> (MaintenanceMode a -> String)
-> ([MaintenanceMode a] -> ShowS)
-> Show (MaintenanceMode a)
forall a. Show a => Int -> MaintenanceMode a -> ShowS
forall a. Show a => [MaintenanceMode a] -> ShowS
forall a. Show a => MaintenanceMode a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> MaintenanceMode a -> ShowS
showsPrec :: Int -> MaintenanceMode a -> ShowS
$cshow :: forall a. Show a => MaintenanceMode a -> String
show :: MaintenanceMode a -> String
$cshowList :: forall a. Show a => [MaintenanceMode a] -> ShowS
showList :: [MaintenanceMode a] -> ShowS
Show, MaintenanceMode a -> MaintenanceMode a -> Bool
(MaintenanceMode a -> MaintenanceMode a -> Bool)
-> (MaintenanceMode a -> MaintenanceMode a -> Bool)
-> Eq (MaintenanceMode a)
forall a. Eq a => MaintenanceMode a -> MaintenanceMode a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => MaintenanceMode a -> MaintenanceMode a -> Bool
== :: MaintenanceMode a -> MaintenanceMode a -> Bool
$c/= :: forall a. Eq a => MaintenanceMode a -> MaintenanceMode a -> Bool
/= :: MaintenanceMode a -> MaintenanceMode a -> Bool
Eq)

instance FromJSON (MaintenanceMode ()) where
  parseJSON :: Value -> Parser (MaintenanceMode ())
parseJSON =
    String
-> (Bool -> Parser (MaintenanceMode ()))
-> Value
-> Parser (MaintenanceMode ())
forall a. String -> (Bool -> Parser a) -> Value -> Parser a
withBool String
"MaintenanceMode"
      ((Bool -> Parser (MaintenanceMode ()))
 -> Value -> Parser (MaintenanceMode ()))
-> (Bool -> Parser (MaintenanceMode ()))
-> Value
-> Parser (MaintenanceMode ())
forall a b. (a -> b) -> a -> b
$ MaintenanceMode () -> Parser (MaintenanceMode ())
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
      (MaintenanceMode () -> Parser (MaintenanceMode ()))
-> (Bool -> MaintenanceMode ())
-> Bool
-> Parser (MaintenanceMode ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MaintenanceMode ()
-> MaintenanceMode () -> Bool -> MaintenanceMode ()
forall a. a -> a -> Bool -> a
bool MaintenanceMode ()
forall a. MaintenanceMode a
MaintenanceModeDisabled (() -> MaintenanceMode ()
forall a. a -> MaintenanceMode a
MaintenanceModeEnabled ())

instance ToJSON (MaintenanceMode ()) where
  toJSON :: MaintenanceMode () -> Value
toJSON = Bool -> Value
Bool (Bool -> Value)
-> (MaintenanceMode () -> Bool) -> MaintenanceMode () -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (MaintenanceMode () -> MaintenanceMode () -> Bool
forall a. Eq a => a -> a -> Bool
== () -> MaintenanceMode ()
forall a. a -> MaintenanceMode a
MaintenanceModeEnabled ())

-- | See Note [ReadOnly Mode]
data ReadOnlyMode = ReadOnlyModeEnabled | ReadOnlyModeDisabled
  deriving (Int -> ReadOnlyMode -> ShowS
[ReadOnlyMode] -> ShowS
ReadOnlyMode -> String
(Int -> ReadOnlyMode -> ShowS)
-> (ReadOnlyMode -> String)
-> ([ReadOnlyMode] -> ShowS)
-> Show ReadOnlyMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReadOnlyMode -> ShowS
showsPrec :: Int -> ReadOnlyMode -> ShowS
$cshow :: ReadOnlyMode -> String
show :: ReadOnlyMode -> String
$cshowList :: [ReadOnlyMode] -> ShowS
showList :: [ReadOnlyMode] -> ShowS
Show, ReadOnlyMode -> ReadOnlyMode -> Bool
(ReadOnlyMode -> ReadOnlyMode -> Bool)
-> (ReadOnlyMode -> ReadOnlyMode -> Bool) -> Eq ReadOnlyMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReadOnlyMode -> ReadOnlyMode -> Bool
== :: ReadOnlyMode -> ReadOnlyMode -> Bool
$c/= :: ReadOnlyMode -> ReadOnlyMode -> Bool
/= :: ReadOnlyMode -> ReadOnlyMode -> Bool
Eq)

-- | EventingMode decides whether the eventing subsystem should be enabled or disabled.
-- `EventDisabled` mode disables Event Triggers, Async Actions, Scheduled Events and source catalaog migrations.
-- This is an internal feature and will not be exposed to users.
data EventingMode = EventingEnabled | EventingDisabled
  deriving (Int -> EventingMode -> ShowS
[EventingMode] -> ShowS
EventingMode -> String
(Int -> EventingMode -> ShowS)
-> (EventingMode -> String)
-> ([EventingMode] -> ShowS)
-> Show EventingMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EventingMode -> ShowS
showsPrec :: Int -> EventingMode -> ShowS
$cshow :: EventingMode -> String
show :: EventingMode -> String
$cshowList :: [EventingMode] -> ShowS
showList :: [EventingMode] -> ShowS
Show, EventingMode -> EventingMode -> Bool
(EventingMode -> EventingMode -> Bool)
-> (EventingMode -> EventingMode -> Bool) -> Eq EventingMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EventingMode -> EventingMode -> Bool
== :: EventingMode -> EventingMode -> Bool
$c/= :: EventingMode -> EventingMode -> Bool
/= :: EventingMode -> EventingMode -> Bool
Eq)

-- | Whether or not to enable apollo federation fields.
data ApolloFederationStatus = ApolloFederationEnabled | ApolloFederationDisabled
  deriving stock (Int -> ApolloFederationStatus -> ShowS
[ApolloFederationStatus] -> ShowS
ApolloFederationStatus -> String
(Int -> ApolloFederationStatus -> ShowS)
-> (ApolloFederationStatus -> String)
-> ([ApolloFederationStatus] -> ShowS)
-> Show ApolloFederationStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ApolloFederationStatus -> ShowS
showsPrec :: Int -> ApolloFederationStatus -> ShowS
$cshow :: ApolloFederationStatus -> String
show :: ApolloFederationStatus -> String
$cshowList :: [ApolloFederationStatus] -> ShowS
showList :: [ApolloFederationStatus] -> ShowS
Show, ApolloFederationStatus -> ApolloFederationStatus -> Bool
(ApolloFederationStatus -> ApolloFederationStatus -> Bool)
-> (ApolloFederationStatus -> ApolloFederationStatus -> Bool)
-> Eq ApolloFederationStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ApolloFederationStatus -> ApolloFederationStatus -> Bool
== :: ApolloFederationStatus -> ApolloFederationStatus -> Bool
$c/= :: ApolloFederationStatus -> ApolloFederationStatus -> Bool
/= :: ApolloFederationStatus -> ApolloFederationStatus -> Bool
Eq, Eq ApolloFederationStatus
Eq ApolloFederationStatus
-> (ApolloFederationStatus -> ApolloFederationStatus -> Ordering)
-> (ApolloFederationStatus -> ApolloFederationStatus -> Bool)
-> (ApolloFederationStatus -> ApolloFederationStatus -> Bool)
-> (ApolloFederationStatus -> ApolloFederationStatus -> Bool)
-> (ApolloFederationStatus -> ApolloFederationStatus -> Bool)
-> (ApolloFederationStatus
    -> ApolloFederationStatus -> ApolloFederationStatus)
-> (ApolloFederationStatus
    -> ApolloFederationStatus -> ApolloFederationStatus)
-> Ord ApolloFederationStatus
ApolloFederationStatus -> ApolloFederationStatus -> Bool
ApolloFederationStatus -> ApolloFederationStatus -> Ordering
ApolloFederationStatus
-> ApolloFederationStatus -> ApolloFederationStatus
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ApolloFederationStatus -> ApolloFederationStatus -> Ordering
compare :: ApolloFederationStatus -> ApolloFederationStatus -> Ordering
$c< :: ApolloFederationStatus -> ApolloFederationStatus -> Bool
< :: ApolloFederationStatus -> ApolloFederationStatus -> Bool
$c<= :: ApolloFederationStatus -> ApolloFederationStatus -> Bool
<= :: ApolloFederationStatus -> ApolloFederationStatus -> Bool
$c> :: ApolloFederationStatus -> ApolloFederationStatus -> Bool
> :: ApolloFederationStatus -> ApolloFederationStatus -> Bool
$c>= :: ApolloFederationStatus -> ApolloFederationStatus -> Bool
>= :: ApolloFederationStatus -> ApolloFederationStatus -> Bool
$cmax :: ApolloFederationStatus
-> ApolloFederationStatus -> ApolloFederationStatus
max :: ApolloFederationStatus
-> ApolloFederationStatus -> ApolloFederationStatus
$cmin :: ApolloFederationStatus
-> ApolloFederationStatus -> ApolloFederationStatus
min :: ApolloFederationStatus
-> ApolloFederationStatus -> ApolloFederationStatus
Ord, (forall x. ApolloFederationStatus -> Rep ApolloFederationStatus x)
-> (forall x.
    Rep ApolloFederationStatus x -> ApolloFederationStatus)
-> Generic ApolloFederationStatus
forall x. Rep ApolloFederationStatus x -> ApolloFederationStatus
forall x. ApolloFederationStatus -> Rep ApolloFederationStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ApolloFederationStatus -> Rep ApolloFederationStatus x
from :: forall x. ApolloFederationStatus -> Rep ApolloFederationStatus x
$cto :: forall x. Rep ApolloFederationStatus x -> ApolloFederationStatus
to :: forall x. Rep ApolloFederationStatus x -> ApolloFederationStatus
Generic)

instance NFData ApolloFederationStatus

instance Hashable ApolloFederationStatus

instance FromJSON ApolloFederationStatus where
  parseJSON :: Value -> Parser ApolloFederationStatus
parseJSON = (Bool -> ApolloFederationStatus)
-> Parser Bool -> Parser ApolloFederationStatus
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ApolloFederationStatus
-> ApolloFederationStatus -> Bool -> ApolloFederationStatus
forall a. a -> a -> Bool -> a
bool ApolloFederationStatus
ApolloFederationDisabled ApolloFederationStatus
ApolloFederationEnabled) (Parser Bool -> Parser ApolloFederationStatus)
-> (Value -> Parser Bool) -> Value -> Parser ApolloFederationStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Parser Bool
forall a. FromJSON a => Value -> Parser a
parseJSON

isApolloFederationEnabled :: ApolloFederationStatus -> Bool
isApolloFederationEnabled :: ApolloFederationStatus -> Bool
isApolloFederationEnabled = \case
  ApolloFederationStatus
ApolloFederationEnabled -> Bool
True
  ApolloFederationStatus
ApolloFederationDisabled -> Bool
False

instance ToJSON ApolloFederationStatus where
  toJSON :: ApolloFederationStatus -> Value
toJSON = Bool -> Value
forall a. ToJSON a => a -> Value
toJSON (Bool -> Value)
-> (ApolloFederationStatus -> Bool)
-> ApolloFederationStatus
-> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ApolloFederationStatus -> Bool
isApolloFederationEnabled

-- | Whether or not to enable granular metrics for Prometheus.
--
-- `GranularMetricsOn` will enable the dynamic labels for the metrics.
-- `GranularMetricsOff` will disable the dynamic labels for the metrics.
--
-- **Warning**: Enabling dynamic labels for Prometheus metrics can cause cardinality
-- issues and can cause memory usage to increase.
data GranularPrometheusMetricsState
  = GranularMetricsOff
  | GranularMetricsOn
  deriving (GranularPrometheusMetricsState
-> GranularPrometheusMetricsState -> Bool
(GranularPrometheusMetricsState
 -> GranularPrometheusMetricsState -> Bool)
-> (GranularPrometheusMetricsState
    -> GranularPrometheusMetricsState -> Bool)
-> Eq GranularPrometheusMetricsState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GranularPrometheusMetricsState
-> GranularPrometheusMetricsState -> Bool
== :: GranularPrometheusMetricsState
-> GranularPrometheusMetricsState -> Bool
$c/= :: GranularPrometheusMetricsState
-> GranularPrometheusMetricsState -> Bool
/= :: GranularPrometheusMetricsState
-> GranularPrometheusMetricsState -> Bool
Eq, Int -> GranularPrometheusMetricsState -> ShowS
[GranularPrometheusMetricsState] -> ShowS
GranularPrometheusMetricsState -> String
(Int -> GranularPrometheusMetricsState -> ShowS)
-> (GranularPrometheusMetricsState -> String)
-> ([GranularPrometheusMetricsState] -> ShowS)
-> Show GranularPrometheusMetricsState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GranularPrometheusMetricsState -> ShowS
showsPrec :: Int -> GranularPrometheusMetricsState -> ShowS
$cshow :: GranularPrometheusMetricsState -> String
show :: GranularPrometheusMetricsState -> String
$cshowList :: [GranularPrometheusMetricsState] -> ShowS
showList :: [GranularPrometheusMetricsState] -> ShowS
Show)

instance FromJSON GranularPrometheusMetricsState where
  parseJSON :: Value -> Parser GranularPrometheusMetricsState
parseJSON = String
-> (Bool -> Parser GranularPrometheusMetricsState)
-> Value
-> Parser GranularPrometheusMetricsState
forall a. String -> (Bool -> Parser a) -> Value -> Parser a
withBool String
"GranularPrometheusMetricsState" ((Bool -> Parser GranularPrometheusMetricsState)
 -> Value -> Parser GranularPrometheusMetricsState)
-> (Bool -> Parser GranularPrometheusMetricsState)
-> Value
-> Parser GranularPrometheusMetricsState
forall a b. (a -> b) -> a -> b
$ \case
    Bool
False -> GranularPrometheusMetricsState
-> Parser GranularPrometheusMetricsState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure GranularPrometheusMetricsState
GranularMetricsOff
    Bool
True -> GranularPrometheusMetricsState
-> Parser GranularPrometheusMetricsState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure GranularPrometheusMetricsState
GranularMetricsOn

instance ToJSON GranularPrometheusMetricsState where
  toJSON :: GranularPrometheusMetricsState -> Value
toJSON = \case
    GranularPrometheusMetricsState
GranularMetricsOff -> Bool -> Value
Bool Bool
False
    GranularPrometheusMetricsState
GranularMetricsOn -> Bool -> Value
Bool Bool
True

-- | Whether or not to close websocket connections on metadata change.
data CloseWebsocketsOnMetadataChangeStatus = CWMCEnabled | CWMCDisabled
  deriving stock (Int -> CloseWebsocketsOnMetadataChangeStatus -> ShowS
[CloseWebsocketsOnMetadataChangeStatus] -> ShowS
CloseWebsocketsOnMetadataChangeStatus -> String
(Int -> CloseWebsocketsOnMetadataChangeStatus -> ShowS)
-> (CloseWebsocketsOnMetadataChangeStatus -> String)
-> ([CloseWebsocketsOnMetadataChangeStatus] -> ShowS)
-> Show CloseWebsocketsOnMetadataChangeStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CloseWebsocketsOnMetadataChangeStatus -> ShowS
showsPrec :: Int -> CloseWebsocketsOnMetadataChangeStatus -> ShowS
$cshow :: CloseWebsocketsOnMetadataChangeStatus -> String
show :: CloseWebsocketsOnMetadataChangeStatus -> String
$cshowList :: [CloseWebsocketsOnMetadataChangeStatus] -> ShowS
showList :: [CloseWebsocketsOnMetadataChangeStatus] -> ShowS
Show, CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
(CloseWebsocketsOnMetadataChangeStatus
 -> CloseWebsocketsOnMetadataChangeStatus -> Bool)
-> (CloseWebsocketsOnMetadataChangeStatus
    -> CloseWebsocketsOnMetadataChangeStatus -> Bool)
-> Eq CloseWebsocketsOnMetadataChangeStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
== :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
$c/= :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
/= :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
Eq, Eq CloseWebsocketsOnMetadataChangeStatus
Eq CloseWebsocketsOnMetadataChangeStatus
-> (CloseWebsocketsOnMetadataChangeStatus
    -> CloseWebsocketsOnMetadataChangeStatus -> Ordering)
-> (CloseWebsocketsOnMetadataChangeStatus
    -> CloseWebsocketsOnMetadataChangeStatus -> Bool)
-> (CloseWebsocketsOnMetadataChangeStatus
    -> CloseWebsocketsOnMetadataChangeStatus -> Bool)
-> (CloseWebsocketsOnMetadataChangeStatus
    -> CloseWebsocketsOnMetadataChangeStatus -> Bool)
-> (CloseWebsocketsOnMetadataChangeStatus
    -> CloseWebsocketsOnMetadataChangeStatus -> Bool)
-> (CloseWebsocketsOnMetadataChangeStatus
    -> CloseWebsocketsOnMetadataChangeStatus
    -> CloseWebsocketsOnMetadataChangeStatus)
-> (CloseWebsocketsOnMetadataChangeStatus
    -> CloseWebsocketsOnMetadataChangeStatus
    -> CloseWebsocketsOnMetadataChangeStatus)
-> Ord CloseWebsocketsOnMetadataChangeStatus
CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Ordering
CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Ordering
compare :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Ordering
$c< :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
< :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
$c<= :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
<= :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
$c> :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
> :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
$c>= :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
>= :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus -> Bool
$cmax :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus
max :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus
$cmin :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus
min :: CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus
Ord, (forall x.
 CloseWebsocketsOnMetadataChangeStatus
 -> Rep CloseWebsocketsOnMetadataChangeStatus x)
-> (forall x.
    Rep CloseWebsocketsOnMetadataChangeStatus x
    -> CloseWebsocketsOnMetadataChangeStatus)
-> Generic CloseWebsocketsOnMetadataChangeStatus
forall x.
Rep CloseWebsocketsOnMetadataChangeStatus x
-> CloseWebsocketsOnMetadataChangeStatus
forall x.
CloseWebsocketsOnMetadataChangeStatus
-> Rep CloseWebsocketsOnMetadataChangeStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
CloseWebsocketsOnMetadataChangeStatus
-> Rep CloseWebsocketsOnMetadataChangeStatus x
from :: forall x.
CloseWebsocketsOnMetadataChangeStatus
-> Rep CloseWebsocketsOnMetadataChangeStatus x
$cto :: forall x.
Rep CloseWebsocketsOnMetadataChangeStatus x
-> CloseWebsocketsOnMetadataChangeStatus
to :: forall x.
Rep CloseWebsocketsOnMetadataChangeStatus x
-> CloseWebsocketsOnMetadataChangeStatus
Generic)

instance NFData CloseWebsocketsOnMetadataChangeStatus

instance Hashable CloseWebsocketsOnMetadataChangeStatus

instance FromJSON CloseWebsocketsOnMetadataChangeStatus where
  parseJSON :: Value -> Parser CloseWebsocketsOnMetadataChangeStatus
parseJSON = (Bool -> CloseWebsocketsOnMetadataChangeStatus)
-> Parser Bool -> Parser CloseWebsocketsOnMetadataChangeStatus
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (CloseWebsocketsOnMetadataChangeStatus
-> CloseWebsocketsOnMetadataChangeStatus
-> Bool
-> CloseWebsocketsOnMetadataChangeStatus
forall a. a -> a -> Bool -> a
bool CloseWebsocketsOnMetadataChangeStatus
CWMCDisabled CloseWebsocketsOnMetadataChangeStatus
CWMCEnabled) (Parser Bool -> Parser CloseWebsocketsOnMetadataChangeStatus)
-> (Value -> Parser Bool)
-> Value
-> Parser CloseWebsocketsOnMetadataChangeStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Parser Bool
forall a. FromJSON a => Value -> Parser a
parseJSON

isCloseWebsocketsOnMetadataChangeStatusEnabled :: CloseWebsocketsOnMetadataChangeStatus -> Bool
isCloseWebsocketsOnMetadataChangeStatusEnabled :: CloseWebsocketsOnMetadataChangeStatus -> Bool
isCloseWebsocketsOnMetadataChangeStatusEnabled = \case
  CloseWebsocketsOnMetadataChangeStatus
CWMCEnabled -> Bool
True
  CloseWebsocketsOnMetadataChangeStatus
CWMCDisabled -> Bool
False

instance ToJSON CloseWebsocketsOnMetadataChangeStatus where
  toJSON :: CloseWebsocketsOnMetadataChangeStatus -> Value
toJSON = Bool -> Value
forall a. ToJSON a => a -> Value
toJSON (Bool -> Value)
-> (CloseWebsocketsOnMetadataChangeStatus -> Bool)
-> CloseWebsocketsOnMetadataChangeStatus
-> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CloseWebsocketsOnMetadataChangeStatus -> Bool
isCloseWebsocketsOnMetadataChangeStatusEnabled

class (Monad m) => MonadGetPolicies m where
  runGetApiTimeLimit ::
    m (Maybe MaxTime)

  -- 'GranularPrometheusMetricsState' is used to decide if dynamic labels needs to be
  -- added when emitting the prometheus metric. The state of this can be dynamically
  -- changed via policies. Hence we need to fetch the value from the policy everytime
  -- before emitting the metric. Thus we create an IO action which fetches the value.
  runGetPrometheusMetricsGranularity ::
    m (IO GranularPrometheusMetricsState)

instance (MonadGetPolicies m) => MonadGetPolicies (ReaderT r m) where
  runGetApiTimeLimit :: ReaderT r m (Maybe MaxTime)
runGetApiTimeLimit = m (Maybe MaxTime) -> ReaderT r m (Maybe MaxTime)
forall (m :: * -> *) a. Monad m => m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Maybe MaxTime)
forall (m :: * -> *). MonadGetPolicies m => m (Maybe MaxTime)
runGetApiTimeLimit
  runGetPrometheusMetricsGranularity :: ReaderT r m (IO GranularPrometheusMetricsState)
runGetPrometheusMetricsGranularity = m (IO GranularPrometheusMetricsState)
-> ReaderT r m (IO GranularPrometheusMetricsState)
forall (m :: * -> *) a. Monad m => m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (IO GranularPrometheusMetricsState)
forall (m :: * -> *).
MonadGetPolicies m =>
m (IO GranularPrometheusMetricsState)
runGetPrometheusMetricsGranularity

instance (MonadGetPolicies m) => MonadGetPolicies (ExceptT e m) where
  runGetApiTimeLimit :: ExceptT e m (Maybe MaxTime)
runGetApiTimeLimit = m (Maybe MaxTime) -> ExceptT e m (Maybe MaxTime)
forall (m :: * -> *) a. Monad m => m a -> ExceptT e m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Maybe MaxTime)
forall (m :: * -> *). MonadGetPolicies m => m (Maybe MaxTime)
runGetApiTimeLimit
  runGetPrometheusMetricsGranularity :: ExceptT e m (IO GranularPrometheusMetricsState)
runGetPrometheusMetricsGranularity = m (IO GranularPrometheusMetricsState)
-> ExceptT e m (IO GranularPrometheusMetricsState)
forall (m :: * -> *) a. Monad m => m a -> ExceptT e m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (IO GranularPrometheusMetricsState)
forall (m :: * -> *).
MonadGetPolicies m =>
m (IO GranularPrometheusMetricsState)
runGetPrometheusMetricsGranularity

instance (MonadGetPolicies m) => MonadGetPolicies (StateT w m) where
  runGetApiTimeLimit :: StateT w m (Maybe MaxTime)
runGetApiTimeLimit = m (Maybe MaxTime) -> StateT w m (Maybe MaxTime)
forall (m :: * -> *) a. Monad m => m a -> StateT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Maybe MaxTime)
forall (m :: * -> *). MonadGetPolicies m => m (Maybe MaxTime)
runGetApiTimeLimit
  runGetPrometheusMetricsGranularity :: StateT w m (IO GranularPrometheusMetricsState)
runGetPrometheusMetricsGranularity = m (IO GranularPrometheusMetricsState)
-> StateT w m (IO GranularPrometheusMetricsState)
forall (m :: * -> *) a. Monad m => m a -> StateT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (IO GranularPrometheusMetricsState)
forall (m :: * -> *).
MonadGetPolicies m =>
m (IO GranularPrometheusMetricsState)
runGetPrometheusMetricsGranularity