{-# LANGUAGE OverloadedStrings #-}

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

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

    -- * Errors
    , _AccessDeniedException
    , _AssessmentRunInProgressException
    , _NoSuchEntityException
    , _AgentsAlreadyRunningAssessmentException
    , _InvalidCrossAccountRoleException
    , _InvalidInputException
    , _InternalException
    , _LimitExceededException

    -- * AgentHealth
    , AgentHealth (..)

    -- * AgentHealthCode
    , AgentHealthCode (..)

    -- * AssessmentRunNotificationSNSStatusCode
    , AssessmentRunNotificationSNSStatusCode (..)

    -- * AssessmentRunState
    , AssessmentRunState (..)

    -- * AssetType
    , AssetType (..)

    -- * FailedItemErrorCode
    , FailedItemErrorCode (..)

    -- * InspectorEvent
    , InspectorEvent (..)

    -- * Locale
    , Locale (..)

    -- * Severity
    , Severity (..)

    -- * AgentFilter
    , AgentFilter
    , agentFilter
    , afAgentHealths
    , afAgentHealthCodes

    -- * AgentPreview
    , AgentPreview
    , agentPreview
    , apAutoScalingGroup
    , apAgentId

    -- * AssessmentRun
    , AssessmentRun
    , assessmentRun
    , arStartedAt
    , arCompletedAt
    , arArn
    , arName
    , arAssessmentTemplateARN
    , arState
    , arDurationInSeconds
    , arRulesPackageARNs
    , arUserAttributesForFindings
    , arCreatedAt
    , arStateChangedAt
    , arDataCollected
    , arStateChanges
    , arNotifications

    -- * AssessmentRunAgent
    , AssessmentRunAgent
    , assessmentRunAgent
    , araAutoScalingGroup
    , araAgentHealthDetails
    , araAgentId
    , araAssessmentRunARN
    , araAgentHealth
    , araAgentHealthCode
    , araTelemetryMetadata

    -- * AssessmentRunFilter
    , AssessmentRunFilter
    , assessmentRunFilter
    , arfStates
    , arfNamePattern
    , arfStartTimeRange
    , arfStateChangeTimeRange
    , arfRulesPackageARNs
    , arfCompletionTimeRange
    , arfDurationRange

    -- * AssessmentRunNotification
    , AssessmentRunNotification
    , assessmentRunNotification
    , arnSnsTopicARN
    , arnSnsPublishStatusCode
    , arnMessage
    , arnDate
    , arnEvent
    , arnError

    -- * AssessmentRunStateChange
    , AssessmentRunStateChange
    , assessmentRunStateChange
    , arscStateChangedAt
    , arscState

    -- * AssessmentTarget
    , AssessmentTarget
    , assessmentTarget
    , aArn
    , aName
    , aResourceGroupARN
    , aCreatedAt
    , aUpdatedAt

    -- * AssessmentTargetFilter
    , AssessmentTargetFilter
    , assessmentTargetFilter
    , atfAssessmentTargetNamePattern

    -- * AssessmentTemplate
    , AssessmentTemplate
    , assessmentTemplate
    , atArn
    , atName
    , atAssessmentTargetARN
    , atDurationInSeconds
    , atRulesPackageARNs
    , atUserAttributesForFindings
    , atCreatedAt

    -- * AssessmentTemplateFilter
    , AssessmentTemplateFilter
    , assessmentTemplateFilter
    , atfNamePattern
    , atfRulesPackageARNs
    , atfDurationRange

    -- * AssetAttributes
    , AssetAttributes
    , assetAttributes
    , aaHostname
    , aaAutoScalingGroup
    , aaIpv4Addresses
    , aaAgentId
    , aaAmiId
    , aaSchemaVersion

    -- * Attribute
    , Attribute
    , attribute
    , aValue
    , aKey

    -- * DurationRange
    , DurationRange
    , durationRange
    , drMinSeconds
    , drMaxSeconds

    -- * EventSubscription
    , EventSubscription
    , eventSubscription
    , esEvent
    , esSubscribedAt

    -- * FailedItemDetails
    , FailedItemDetails
    , failedItemDetails
    , fidFailureCode
    , fidRetryable

    -- * Finding
    , Finding
    , finding
    , fService
    , fSeverity
    , fSchemaVersion
    , fConfidence
    , fAssetAttributes
    , fServiceAttributes
    , fId
    , fNumericSeverity
    , fAssetType
    , fTitle
    , fIndicatorOfCompromise
    , fDescription
    , fRecommendation
    , fArn
    , fAttributes
    , fUserAttributes
    , fCreatedAt
    , fUpdatedAt

    -- * FindingFilter
    , FindingFilter
    , findingFilter
    , ffAgentIds
    , ffRuleNames
    , ffUserAttributes
    , ffRulesPackageARNs
    , ffAttributes
    , ffSeverities
    , ffCreationTimeRange
    , ffAutoScalingGroups

    -- * InspectorServiceAttributes
    , InspectorServiceAttributes
    , inspectorServiceAttributes
    , isaRulesPackageARN
    , isaAssessmentRunARN
    , isaSchemaVersion

    -- * ResourceGroup
    , ResourceGroup
    , resourceGroup
    , rgArn
    , rgTags
    , rgCreatedAt

    -- * ResourceGroupTag
    , ResourceGroupTag
    , resourceGroupTag
    , rgtValue
    , rgtKey

    -- * RulesPackage
    , RulesPackage
    , rulesPackage
    , rpDescription
    , rpArn
    , rpName
    , rpVersion
    , rpProvider

    -- * Subscription
    , Subscription
    , subscription
    , sResourceARN
    , sTopicARN
    , sEventSubscriptions

    -- * Tag
    , Tag
    , tag
    , tagValue
    , tagKey

    -- * TelemetryMetadata
    , TelemetryMetadata
    , telemetryMetadata
    , tmDataSize
    , tmMessageType
    , tmCount

    -- * TimestampRange
    , TimestampRange
    , timestampRange
    , trEndDate
    , trBeginDate
    ) where

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

-- | API version '2016-02-16' of the Amazon Inspector SDK configuration.
inspector :: Service
inspector =
    Service
    { _svcAbbrev = "Inspector"
    , _svcSigner = v4
    , _svcPrefix = "inspector"
    , _svcVersion = "2016-02-16"
    , _svcEndpoint = defaultEndpoint inspector
    , _svcTimeout = Just 70
    , _svcCheck = statusSuccess
    , _svcError = parseJSONError "Inspector"
    , _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

-- | You do not have required permissions to access the requested resource.
_AccessDeniedException :: AsError a => Getting (First ServiceError) a ServiceError
_AccessDeniedException = _ServiceError . hasCode "AccessDeniedException"

-- | You cannot perform a specified action if an assessment run is currently in progress.
_AssessmentRunInProgressException :: AsError a => Getting (First ServiceError) a ServiceError
_AssessmentRunInProgressException =
    _ServiceError . hasCode "AssessmentRunInProgressException"

-- | The request was rejected because it referenced an entity that does not exist. The error code describes the entity.
_NoSuchEntityException :: AsError a => Getting (First ServiceError) a ServiceError
_NoSuchEntityException = _ServiceError . hasCode "NoSuchEntityException"

-- | You started an assessment run, but one of the instances is already participating in another assessment run.
_AgentsAlreadyRunningAssessmentException :: AsError a => Getting (First ServiceError) a ServiceError
_AgentsAlreadyRunningAssessmentException =
    _ServiceError . hasCode "AgentsAlreadyRunningAssessmentException"

-- | Amazon Inspector cannot assume the cross-account role that it needs to list your EC2 instances during the assessment run.
_InvalidCrossAccountRoleException :: AsError a => Getting (First ServiceError) a ServiceError
_InvalidCrossAccountRoleException =
    _ServiceError . hasCode "InvalidCrossAccountRoleException"

-- | The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
_InvalidInputException :: AsError a => Getting (First ServiceError) a ServiceError
_InvalidInputException = _ServiceError . hasCode "InvalidInputException"

-- | Internal server error.
_InternalException :: AsError a => Getting (First ServiceError) a ServiceError
_InternalException = _ServiceError . hasCode "InternalException"

-- | The request was rejected because it attempted to create resources beyond the current AWS account limits. The error code describes the limit exceeded.
_LimitExceededException :: AsError a => Getting (First ServiceError) a ServiceError
_LimitExceededException = _ServiceError . hasCode "LimitExceededException"