module Network.AWS.CloudHSM.Types
(
CloudHSM
, JSONError
, CloudHsmObjectState (..)
, SubscriptionType (..)
, HsmStatus (..)
, ClientVersion (..)
) where
import Network.AWS.Prelude
import Network.AWS.Signing
import qualified GHC.Exts
data CloudHSM
instance AWSService CloudHSM where
type Sg CloudHSM = V4
type Er CloudHSM = JSONError
service = service'
where
service' :: Service CloudHSM
service' = Service
{ _svcAbbrev = "CloudHSM"
, _svcPrefix = "cloudhsm"
, _svcVersion = "2014-05-30"
, _svcTargetPrefix = Just "CloudHsmFrontendService"
, _svcJSONVersion = Just "1.1"
, _svcHandle = handle
, _svcRetry = retry
}
handle :: Status
-> Maybe (LazyByteString -> ServiceError JSONError)
handle = jsonError statusSuccess service'
retry :: Retry CloudHSM
retry = Exponential
{ _retryBase = 0.05
, _retryGrowth = 2
, _retryAttempts = 5
, _retryCheck = check
}
check :: Status
-> JSONError
-> Bool
check (statusCode -> s) (awsErrorCode -> e)
| s == 500 = True
| s == 509 = True
| s == 503 = True
| otherwise = False
data CloudHsmObjectState
= Degraded
| Ready
| Updating
deriving (Eq, Ord, Read, Show, Generic, Enum)
instance Hashable CloudHsmObjectState
instance FromText CloudHsmObjectState where
parser = takeLowerText >>= \case
"degraded" -> pure Degraded
"ready" -> pure Ready
"updating" -> pure Updating
e -> fail $
"Failure parsing CloudHsmObjectState from " ++ show e
instance ToText CloudHsmObjectState where
toText = \case
Degraded -> "DEGRADED"
Ready -> "READY"
Updating -> "UPDATING"
instance ToByteString CloudHsmObjectState
instance ToHeader CloudHsmObjectState
instance ToQuery CloudHsmObjectState
instance FromJSON CloudHsmObjectState where
parseJSON = parseJSONText "CloudHsmObjectState"
instance ToJSON CloudHsmObjectState where
toJSON = toJSONText
data SubscriptionType
= Production
deriving (Eq, Ord, Read, Show, Generic, Enum)
instance Hashable SubscriptionType
instance FromText SubscriptionType where
parser = takeLowerText >>= \case
"production" -> pure Production
e -> fail $
"Failure parsing SubscriptionType from " ++ show e
instance ToText SubscriptionType where
toText Production = "PRODUCTION"
instance ToByteString SubscriptionType
instance ToHeader SubscriptionType
instance ToQuery SubscriptionType
instance FromJSON SubscriptionType where
parseJSON = parseJSONText "SubscriptionType"
instance ToJSON SubscriptionType where
toJSON = toJSONText
data HsmStatus
= HSDegraded
| HSPending
| HSRunning
| HSSuspended
| HSTerminated
| HSTerminating
| HSUpdating
deriving (Eq, Ord, Read, Show, Generic, Enum)
instance Hashable HsmStatus
instance FromText HsmStatus where
parser = takeLowerText >>= \case
"degraded" -> pure HSDegraded
"pending" -> pure HSPending
"running" -> pure HSRunning
"suspended" -> pure HSSuspended
"terminated" -> pure HSTerminated
"terminating" -> pure HSTerminating
"updating" -> pure HSUpdating
e -> fail $
"Failure parsing HsmStatus from " ++ show e
instance ToText HsmStatus where
toText = \case
HSDegraded -> "DEGRADED"
HSPending -> "PENDING"
HSRunning -> "RUNNING"
HSSuspended -> "SUSPENDED"
HSTerminated -> "TERMINATED"
HSTerminating -> "TERMINATING"
HSUpdating -> "UPDATING"
instance ToByteString HsmStatus
instance ToHeader HsmStatus
instance ToQuery HsmStatus
instance FromJSON HsmStatus where
parseJSON = parseJSONText "HsmStatus"
instance ToJSON HsmStatus where
toJSON = toJSONText
data ClientVersion
= V51
| V53
deriving (Eq, Ord, Read, Show, Generic, Enum)
instance Hashable ClientVersion
instance FromText ClientVersion where
parser = takeLowerText >>= \case
"5.1" -> pure V51
"5.3" -> pure V53
e -> fail $
"Failure parsing ClientVersion from " ++ show e
instance ToText ClientVersion where
toText = \case
V51 -> "5.1"
V53 -> "5.3"
instance ToByteString ClientVersion
instance ToHeader ClientVersion
instance ToQuery ClientVersion
instance FromJSON ClientVersion where
parseJSON = parseJSONText "ClientVersion"
instance ToJSON ClientVersion where
toJSON = toJSONText