{-# LANGUAGE OverloadedStrings #-}

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

-- |
-- Module      : Network.AWS.OpsWorks.Types
-- Copyright   : (c) 2013-2015 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.OpsWorks.Types
    (
    -- * Service Configuration
      opsWorks

    -- * Errors
    , _ValidationException
    , _ResourceNotFoundException

    -- * AppAttributesKeys
    , AppAttributesKeys (..)

    -- * AppType
    , AppType (..)

    -- * Architecture
    , Architecture (..)

    -- * AutoScalingType
    , AutoScalingType (..)

    -- * DeploymentCommandName
    , DeploymentCommandName (..)

    -- * LayerAttributesKeys
    , LayerAttributesKeys (..)

    -- * LayerType
    , LayerType (..)

    -- * RootDeviceType
    , RootDeviceType (..)

    -- * SourceType
    , SourceType (..)

    -- * StackAttributesKeys
    , StackAttributesKeys (..)

    -- * VirtualizationType
    , VirtualizationType (..)

    -- * VolumeType
    , VolumeType (..)

    -- * AgentVersion
    , AgentVersion
    , agentVersion
    , avVersion
    , avConfigurationManager

    -- * App
    , App
    , app
    , appSSLConfiguration
    , appEnvironment
    , appEnableSSL
    , appCreatedAt
    , appShortname
    , appDataSources
    , appAppSource
    , appAppId
    , appAttributes
    , appName
    , appType
    , appStackId
    , appDomains
    , appDescription

    -- * AutoScalingThresholds
    , AutoScalingThresholds
    , autoScalingThresholds
    , astInstanceCount
    , astIgnoreMetricsTime
    , astLoadThreshold
    , astThresholdsWaitTime
    , astAlarms
    , astMemoryThreshold
    , astCPUThreshold

    -- * BlockDeviceMapping
    , BlockDeviceMapping
    , blockDeviceMapping
    , bdmVirtualName
    , bdmNoDevice
    , bdmEBS
    , bdmDeviceName

    -- * ChefConfiguration
    , ChefConfiguration
    , chefConfiguration
    , ccBerkshelfVersion
    , ccManageBerkshelf

    -- * Command
    , Command
    , command
    , cDeploymentId
    , cInstanceId
    , cStatus
    , cLogURL
    , cCreatedAt
    , cCommandId
    , cExitCode
    , cType
    , cCompletedAt
    , cAcknowledgedAt

    -- * DataSource
    , DataSource
    , dataSource
    , dsARN
    , dsDatabaseName
    , dsType

    -- * Deployment
    , Deployment
    , deployment
    , dDeploymentId
    , dStatus
    , dCommand
    , dCreatedAt
    , dCustomJSON
    , dIAMUserARN
    , dAppId
    , dInstanceIds
    , dCompletedAt
    , dStackId
    , dComment
    , dDuration

    -- * DeploymentCommand
    , DeploymentCommand
    , deploymentCommand
    , dcArgs
    , dcName

    -- * EBSBlockDevice
    , EBSBlockDevice
    , ebsBlockDevice
    , ebdDeleteOnTermination
    , ebdVolumeSize
    , ebdIOPS
    , ebdVolumeType
    , ebdSnapshotId

    -- * EcsCluster
    , EcsCluster
    , ecsCluster
    , ecEcsClusterARN
    , ecEcsClusterName
    , ecRegisteredAt
    , ecStackId

    -- * ElasticIP
    , ElasticIP
    , elasticIP
    , eiInstanceId
    , eiDomain
    , eiIP
    , eiName
    , eiRegion

    -- * ElasticLoadBalancer
    , ElasticLoadBalancer
    , elasticLoadBalancer
    , elbSubnetIds
    , elbVPCId
    , elbAvailabilityZones
    , elbRegion
    , elbElasticLoadBalancerName
    , elbStackId
    , elbEC2InstanceIds
    , elbLayerId
    , elbDNSName

    -- * EnvironmentVariable
    , EnvironmentVariable
    , environmentVariable
    , evSecure
    , evKey
    , evValue

    -- * Instance
    , Instance
    , instance'
    , iPrivateDNS
    , iReportedAgentVersion
    , iInstanceId
    , iStatus
    , iPrivateIP
    , iInstallUpdatesOnBoot
    , iVirtualizationType
    , iInstanceProfileARN
    , iPlatform
    , iHostname
    , iSSHHostRsaKeyFingerprint
    , iSecurityGroupIds
    , iEcsClusterARN
    , iCreatedAt
    , iEC2InstanceId
    , iSSHKeyName
    , iAgentVersion
    , iRootDeviceVolumeId
    , iSubnetId
    , iInfrastructureClass
    , iSSHHostDsaKeyFingerprint
    , iInstanceType
    , iEBSOptimized
    , iElasticIP
    , iOS
    , iAvailabilityZone
    , iLastServiceErrorId
    , iAutoScalingType
    , iLayerIds
    , iArchitecture
    , iPublicDNS
    , iAMIId
    , iPublicIP
    , iReportedOS
    , iRegisteredBy
    , iStackId
    , iRootDeviceType
    , iEcsContainerInstanceARN
    , iBlockDeviceMappings

    -- * InstanceIdentity
    , InstanceIdentity
    , instanceIdentity
    , iiSignature
    , iiDocument

    -- * InstancesCount
    , InstancesCount
    , instancesCount
    , icTerminating
    , icPending
    , icOnline
    , icUnassigning
    , icDeregistering
    , icRunningSetup
    , icRequested
    , icBooting
    , icStopped
    , icRebooting
    , icAssigning
    , icShuttingDown
    , icSetupFailed
    , icConnectionLost
    , icTerminated
    , icStopping
    , icRegistered
    , icStartFailed
    , icRegistering

    -- * Layer
    , Layer
    , layer
    , lCustomInstanceProfileARN
    , lCustomSecurityGroupIds
    , lInstallUpdatesOnBoot
    , lLifecycleEventConfiguration
    , lCreatedAt
    , lShortname
    , lDefaultRecipes
    , lCustomRecipes
    , lCustomJSON
    , lVolumeConfigurations
    , lEnableAutoHealing
    , lPackages
    , lAttributes
    , lName
    , lAutoAssignPublicIPs
    , lType
    , lUseEBSOptimizedInstances
    , lStackId
    , lLayerId
    , lDefaultSecurityGroupNames
    , lAutoAssignElasticIPs

    -- * LifecycleEventConfiguration
    , LifecycleEventConfiguration
    , lifecycleEventConfiguration
    , lecShutdown

    -- * LoadBasedAutoScalingConfiguration
    , LoadBasedAutoScalingConfiguration
    , loadBasedAutoScalingConfiguration
    , lbascUpScaling
    , lbascEnable
    , lbascDownScaling
    , lbascLayerId

    -- * Permission
    , Permission
    , permission
    , pIAMUserARN
    , pAllowSudo
    , pStackId
    , pLevel
    , pAllowSSH

    -- * RAIdArray
    , RAIdArray
    , rAIdArray
    , raiaInstanceId
    , raiaSize
    , raiaIOPS
    , raiaCreatedAt
    , raiaRAIdLevel
    , raiaDevice
    , raiaNumberOfDisks
    , raiaAvailabilityZone
    , raiaName
    , raiaRAIdArrayId
    , raiaVolumeType
    , raiaStackId
    , raiaMountPoint

    -- * RDSDBInstance
    , RDSDBInstance
    , rdsDBInstance
    , rdiRDSDBInstanceARN
    , rdiDBUser
    , rdiMissingOnRDS
    , rdiEngine
    , rdiAddress
    , rdiDBInstanceIdentifier
    , rdiRegion
    , rdiStackId
    , rdiDBPassword

    -- * Recipes
    , Recipes
    , recipes
    , rSetup
    , rShutdown
    , rUndeploy
    , rConfigure
    , rDeploy

    -- * ReportedOS
    , ReportedOS
    , reportedOS
    , roFamily
    , roName
    , roVersion

    -- * SSLConfiguration
    , SSLConfiguration
    , sslConfiguration
    , scChain
    , scCertificate
    , scPrivateKey

    -- * SelfUserProfile
    , SelfUserProfile
    , selfUserProfile
    , supSSHPublicKey
    , supSSHUsername
    , supIAMUserARN
    , supName

    -- * ServiceError'
    , ServiceError'
    , serviceError'
    , seInstanceId
    , seCreatedAt
    , seServiceErrorId
    , seType
    , seStackId
    , seMessage

    -- * ShutdownEventConfiguration
    , ShutdownEventConfiguration
    , shutdownEventConfiguration
    , secExecutionTimeout
    , secDelayUntilElbConnectionsDrained

    -- * Source
    , Source
    , source
    , sURL
    , sUsername
    , sSSHKey
    , sPassword
    , sType
    , sRevision

    -- * Stack
    , Stack
    , stack
    , sDefaultInstanceProfileARN
    , sServiceRoleARN
    , sDefaultRootDeviceType
    , sARN
    , sCreatedAt
    , sVPCId
    , sChefConfiguration
    , sAgentVersion
    , sDefaultSSHKeyName
    , sCustomJSON
    , sCustomCookbooksSource
    , sDefaultAvailabilityZone
    , sAttributes
    , sName
    , sDefaultOS
    , sUseOpsworksSecurityGroups
    , sUseCustomCookbooks
    , sDefaultSubnetId
    , sRegion
    , sConfigurationManager
    , sStackId
    , sHostnameTheme

    -- * StackConfigurationManager
    , StackConfigurationManager
    , stackConfigurationManager
    , scmName
    , scmVersion

    -- * StackSummary
    , StackSummary
    , stackSummary
    , ssARN
    , ssAppsCount
    , ssName
    , ssStackId
    , ssLayersCount
    , ssInstancesCount

    -- * TemporaryCredential
    , TemporaryCredential
    , temporaryCredential
    , tcInstanceId
    , tcUsername
    , tcPassword
    , tcValidForInMinutes

    -- * TimeBasedAutoScalingConfiguration
    , TimeBasedAutoScalingConfiguration
    , timeBasedAutoScalingConfiguration
    , tbascInstanceId
    , tbascAutoScalingSchedule

    -- * UserProfile
    , UserProfile
    , userProfile
    , upAllowSelfManagement
    , upSSHPublicKey
    , upSSHUsername
    , upIAMUserARN
    , upName

    -- * Volume
    , Volume
    , volume
    , vInstanceId
    , vStatus
    , vSize
    , vIOPS
    , vDevice
    , vAvailabilityZone
    , vName
    , vRAIdArrayId
    , vVolumeId
    , vRegion
    , vVolumeType
    , vEC2VolumeId
    , vMountPoint

    -- * VolumeConfiguration
    , VolumeConfiguration
    , volumeConfiguration
    , vcIOPS
    , vcRAIdLevel
    , vcVolumeType
    , vcMountPoint
    , vcNumberOfDisks
    , vcSize

    -- * WeeklyAutoScalingSchedule
    , WeeklyAutoScalingSchedule
    , weeklyAutoScalingSchedule
    , wassThursday
    , wassWednesday
    , wassSaturday
    , wassMonday
    , wassFriday
    , wassSunday
    , wassTuesday
    ) where

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

-- | API version '2013-02-18' of the Amazon OpsWorks SDK configuration.
opsWorks :: Service
opsWorks =
    Service
    { _svcAbbrev = "OpsWorks"
    , _svcSigner = v4
    , _svcPrefix = "opsworks"
    , _svcVersion = "2013-02-18"
    , _svcEndpoint = defaultEndpoint opsWorks
    , _svcTimeout = Just 70
    , _svcCheck = statusSuccess
    , _svcError = parseJSONError
    , _svcRetry = retry
    }
  where
    retry =
        Exponential
        { _retryBase = 5.0e-2
        , _retryGrowth = 2
        , _retryAttempts = 5
        , _retryCheck = check
        }
    check e
      | has (hasCode "ThrottlingException" . hasStatus 400) e =
          Just "throttling_exception"
      | has (hasCode "Throttling" . hasStatus 400) e = Just "throttling"
      | has (hasStatus 503) e = Just "service_unavailable"
      | has (hasStatus 500) e = Just "general_server_error"
      | has (hasStatus 509) e = Just "limit_exceeded"
      | otherwise = Nothing

-- | Indicates that a request was invalid.
_ValidationException :: AsError a => Getting (First ServiceError) a ServiceError
_ValidationException = _ServiceError . hasCode "ValidationException"

-- | Indicates that a resource was not found.
_ResourceNotFoundException :: AsError a => Getting (First ServiceError) a ServiceError
_ResourceNotFoundException =
    _ServiceError . hasCode "ResourceNotFoundException"