{-# LANGUAGE OverloadedStrings #-}

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

-- |
-- Module      : Network.AWS.OpsWorksCM.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.OpsWorksCM.Types
    (
    -- * Service Configuration
      opsWorksCM

    -- * Errors
    , _ValidationException
    , _ResourceAlreadyExistsException
    , _InvalidNextTokenException
    , _ResourceNotFoundException
    , _InvalidStateException
    , _LimitExceededException

    -- * BackupStatus
    , BackupStatus (..)

    -- * BackupType
    , BackupType (..)

    -- * MaintenanceStatus
    , MaintenanceStatus (..)

    -- * NodeAssociationStatus
    , NodeAssociationStatus (..)

    -- * ServerStatus
    , ServerStatus (..)

    -- * AccountAttribute
    , AccountAttribute
    , accountAttribute
    , aaUsed
    , aaMaximum
    , aaName

    -- * Backup
    , Backup
    , backup
    , bEngineVersion
    , bServiceRoleARN
    , bStatus
    , bInstanceProfileARN
    , bSecurityGroupIds
    , bStatusDescription
    , bServerName
    , bSubnetIds
    , bKeyPair
    , bCreatedAt
    , bBackupId
    , bEngine
    , bInstanceType
    , bEngineModel
    , bPreferredMaintenanceWindow
    , bUserARN
    , bPreferredBackupWindow
    , bS3LogURL
    , bS3DataSize
    , bBackupARN
    , bS3DataURL
    , bDescription
    , bBackupType
    , bToolsVersion

    -- * EngineAttribute
    , EngineAttribute
    , engineAttribute
    , eaValue
    , eaName

    -- * Server
    , Server
    , server
    , sEngineVersion
    , sServiceRoleARN
    , sDisableAutomatedBackup
    , sStatus
    , sInstanceProfileARN
    , sSecurityGroupIds
    , sServerName
    , sSubnetIds
    , sKeyPair
    , sCreatedAt
    , sServerARN
    , sEngine
    , sMaintenanceStatus
    , sInstanceType
    , sEngineModel
    , sEngineAttributes
    , sPreferredMaintenanceWindow
    , sPreferredBackupWindow
    , sStatusReason
    , sEndpoint
    , sBackupRetentionCount

    -- * ServerEvent
    , ServerEvent
    , serverEvent
    , seLogURL
    , seServerName
    , seCreatedAt
    , seMessage
    ) where

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

-- | API version @2016-11-01@ of the Amazon OpsWorks for Chef Automate SDK configuration.
opsWorksCM :: Service
opsWorksCM =
    Service
    { _svcAbbrev = "OpsWorksCM"
    , _svcSigner = v4
    , _svcPrefix = "opsworks-cm"
    , _svcVersion = "2016-11-01"
    , _svcEndpoint = defaultEndpoint opsWorksCM
    , _svcTimeout = Just 70
    , _svcCheck = statusSuccess
    , _svcError = parseJSONError "OpsWorksCM"
    , _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

-- | One or more of the provided request parameters are not valid.
--
--
_ValidationException :: AsError a => Getting (First ServiceError) a ServiceError
_ValidationException = _ServiceError . hasCode "ValidationException"

-- | The requested resource cannot be created because it already exists.
--
--
_ResourceAlreadyExistsException :: AsError a => Getting (First ServiceError) a ServiceError
_ResourceAlreadyExistsException =
    _ServiceError . hasCode "ResourceAlreadyExistsException"

-- | This occurs when the provided nextToken is not valid.
--
--
_InvalidNextTokenException :: AsError a => Getting (First ServiceError) a ServiceError
_InvalidNextTokenException =
    _ServiceError . hasCode "InvalidNextTokenException"

-- | The requested resource does not exist, or access was denied.
--
--
_ResourceNotFoundException :: AsError a => Getting (First ServiceError) a ServiceError
_ResourceNotFoundException =
    _ServiceError . hasCode "ResourceNotFoundException"

-- | The resource is in a state that does not allow you to perform a specified action.
--
--
_InvalidStateException :: AsError a => Getting (First ServiceError) a ServiceError
_InvalidStateException = _ServiceError . hasCode "InvalidStateException"

-- | The limit of servers or backups has been reached.
--
--
_LimitExceededException :: AsError a => Getting (First ServiceError) a ServiceError
_LimitExceededException = _ServiceError . hasCode "LimitExceededException"