{-# LANGUAGE OverloadedStrings #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Network.AWS.Shield.Types
-- Copyright   : (c) 2013-2016 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
module Network.AWS.Shield.Types
    (
    -- * Service Configuration
      shield

    -- * Errors
    , _InvalidResourceException
    , _InvalidParameterException
    , _LimitsExceededException
    , _InternalErrorException
    , _ResourceAlreadyExistsException
    , _OptimisticLockException
    , _InvalidOperationException
    , _LockedSubscriptionException
    , _ResourceNotFoundException

    -- * SubResourceType
    , SubResourceType (..)

    -- * AttackDetail
    , AttackDetail
    , attackDetail
    , adAttackId
    , adStartTime
    , adSubResources
    , adMitigations
    , adAttackCounters
    , adResourceARN
    , adEndTime

    -- * AttackSummary
    , AttackSummary
    , attackSummary
    , asAttackVectors
    , asAttackId
    , asStartTime
    , asResourceARN
    , asEndTime

    -- * AttackVectorDescription
    , AttackVectorDescription
    , attackVectorDescription
    , avdVectorType

    -- * Mitigation
    , Mitigation
    , mitigation
    , mMitigationName

    -- * Protection
    , Protection
    , protection
    , pResourceARN
    , pName
    , pId

    -- * SubResourceSummary
    , SubResourceSummary
    , subResourceSummary
    , srsCounters
    , srsAttackVectors
    , srsId
    , srsType

    -- * Subscription
    , Subscription
    , subscription
    , sTimeCommitmentInSeconds
    , sStartTime

    -- * SummarizedAttackVector
    , SummarizedAttackVector
    , summarizedAttackVector
    , savVectorCounters
    , savVectorType

    -- * SummarizedCounter
    , SummarizedCounter
    , summarizedCounter
    , scMax
    , scAverage
    , scN
    , scName
    , scSum
    , scUnit

    -- * TimeRange
    , TimeRange
    , timeRange
    , trFromInclusive
    , trToExclusive
    ) where

import           Network.AWS.Lens
import           Network.AWS.Prelude
import           Network.AWS.Shield.Types.Product
import           Network.AWS.Shield.Types.Sum
import           Network.AWS.Sign.V4

-- | API version @2016-06-02@ of the Amazon Shield SDK configuration.
shield :: Service
shield =
    Service
    { _svcAbbrev = "Shield"
    , _svcSigner = v4
    , _svcPrefix = "shield"
    , _svcVersion = "2016-06-02"
    , _svcEndpoint = defaultEndpoint shield
    , _svcTimeout = Just 70
    , _svcCheck = statusSuccess
    , _svcError = parseJSONError "Shield"
    , _svcRetry = retry
    }
  where
    retry =
        Exponential
        { _retryBase = 5.0e-2
        , _retryGrowth = 2
        , _retryAttempts = 5
        , _retryCheck = check
        }
    check e
      | has (hasStatus 429) e = Just "too_many_requests"
      | has (hasCode "ThrottlingException" . hasStatus 400) e =
          Just "throttling_exception"
      | has (hasCode "Throttling" . hasStatus 400) e = Just "throttling"
      | has (hasStatus 504) e = Just "gateway_timeout"
      | has (hasStatus 502) e = Just "bad_gateway"
      | has (hasStatus 503) e = Just "service_unavailable"
      | has (hasStatus 500) e = Just "general_server_error"
      | has (hasStatus 509) e = Just "limit_exceeded"
      | otherwise = Nothing

-- | Exception that indicates that the resource is invalid. You might not have access to the resource, or the resource might not exist.
--
--
_InvalidResourceException :: AsError a => Getting (First ServiceError) a ServiceError
_InvalidResourceException = _ServiceError . hasCode "InvalidResourceException"

-- | Exception that indicates that the parameters passed to the API are invalid.
--
--
_InvalidParameterException :: AsError a => Getting (First ServiceError) a ServiceError
_InvalidParameterException =
    _ServiceError . hasCode "InvalidParameterException"

-- | Exception that indicates that the operation would exceed a limit.
--
--
_LimitsExceededException :: AsError a => Getting (First ServiceError) a ServiceError
_LimitsExceededException = _ServiceError . hasCode "LimitsExceededException"

-- | Exception that indicates that a problem occurred with the service infrastructure. You can retry the request.
--
--
_InternalErrorException :: AsError a => Getting (First ServiceError) a ServiceError
_InternalErrorException = _ServiceError . hasCode "InternalErrorException"

-- | Exception indicating the specified resource already exists.
--
--
_ResourceAlreadyExistsException :: AsError a => Getting (First ServiceError) a ServiceError
_ResourceAlreadyExistsException =
    _ServiceError . hasCode "ResourceAlreadyExistsException"

-- | Exception that indicates that the protection state has been modified by another client. You can retry the request.
--
--
_OptimisticLockException :: AsError a => Getting (First ServiceError) a ServiceError
_OptimisticLockException = _ServiceError . hasCode "OptimisticLockException"

-- | Exception that indicates that the operation would not cause any change to occur.
--
--
_InvalidOperationException :: AsError a => Getting (First ServiceError) a ServiceError
_InvalidOperationException =
    _ServiceError . hasCode "InvalidOperationException"

-- | Exception that indicates that the subscription has been modified by another client. You can retry the request.
--
--
_LockedSubscriptionException :: AsError a => Getting (First ServiceError) a ServiceError
_LockedSubscriptionException =
    _ServiceError . hasCode "LockedSubscriptionException"

-- | Exception indicating the specified resource does not exist.
--
--
_ResourceNotFoundException :: AsError a => Getting (First ServiceError) a ServiceError
_ResourceNotFoundException =
    _ServiceError . hasCode "ResourceNotFoundException"