{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

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

-- |
-- Module      : Amazonka.Inspector2.GetConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves setting configurations for Inspector scans.
module Amazonka.Inspector2.GetConfiguration
  ( -- * Creating a Request
    GetConfiguration (..),
    newGetConfiguration,

    -- * Destructuring the Response
    GetConfigurationResponse (..),
    newGetConfigurationResponse,

    -- * Response Lenses
    getConfigurationResponse_ecrConfiguration,
    getConfigurationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector2.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetConfiguration' smart constructor.
data GetConfiguration = GetConfiguration'
  {
  }
  deriving (GetConfiguration -> GetConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetConfiguration -> GetConfiguration -> Bool
$c/= :: GetConfiguration -> GetConfiguration -> Bool
== :: GetConfiguration -> GetConfiguration -> Bool
$c== :: GetConfiguration -> GetConfiguration -> Bool
Prelude.Eq, ReadPrec [GetConfiguration]
ReadPrec GetConfiguration
Int -> ReadS GetConfiguration
ReadS [GetConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetConfiguration]
$creadListPrec :: ReadPrec [GetConfiguration]
readPrec :: ReadPrec GetConfiguration
$creadPrec :: ReadPrec GetConfiguration
readList :: ReadS [GetConfiguration]
$creadList :: ReadS [GetConfiguration]
readsPrec :: Int -> ReadS GetConfiguration
$creadsPrec :: Int -> ReadS GetConfiguration
Prelude.Read, Int -> GetConfiguration -> ShowS
[GetConfiguration] -> ShowS
GetConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetConfiguration] -> ShowS
$cshowList :: [GetConfiguration] -> ShowS
show :: GetConfiguration -> String
$cshow :: GetConfiguration -> String
showsPrec :: Int -> GetConfiguration -> ShowS
$cshowsPrec :: Int -> GetConfiguration -> ShowS
Prelude.Show, forall x. Rep GetConfiguration x -> GetConfiguration
forall x. GetConfiguration -> Rep GetConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetConfiguration x -> GetConfiguration
$cfrom :: forall x. GetConfiguration -> Rep GetConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'GetConfiguration' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
newGetConfiguration ::
  GetConfiguration
newGetConfiguration :: GetConfiguration
newGetConfiguration = GetConfiguration
GetConfiguration'

instance Core.AWSRequest GetConfiguration where
  type
    AWSResponse GetConfiguration =
      GetConfigurationResponse
  request :: (Service -> Service)
-> GetConfiguration -> Request GetConfiguration
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetConfiguration
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetConfiguration)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe EcrConfigurationState -> Int -> GetConfigurationResponse
GetConfigurationResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ecrConfiguration")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetConfiguration where
  hashWithSalt :: Int -> GetConfiguration -> Int
hashWithSalt Int
_salt GetConfiguration
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData GetConfiguration where
  rnf :: GetConfiguration -> ()
rnf GetConfiguration
_ = ()

instance Data.ToHeaders GetConfiguration where
  toHeaders :: GetConfiguration -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetConfiguration where
  toJSON :: GetConfiguration -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath GetConfiguration where
  toPath :: GetConfiguration -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/configuration/get"

instance Data.ToQuery GetConfiguration where
  toQuery :: GetConfiguration -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetConfigurationResponse' smart constructor.
data GetConfigurationResponse = GetConfigurationResponse'
  { -- | Specifies how the ECR automated re-scan duration is currently configured
    -- for your environment.
    GetConfigurationResponse -> Maybe EcrConfigurationState
ecrConfiguration :: Prelude.Maybe EcrConfigurationState,
    -- | The response's http status code.
    GetConfigurationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetConfigurationResponse -> GetConfigurationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetConfigurationResponse -> GetConfigurationResponse -> Bool
$c/= :: GetConfigurationResponse -> GetConfigurationResponse -> Bool
== :: GetConfigurationResponse -> GetConfigurationResponse -> Bool
$c== :: GetConfigurationResponse -> GetConfigurationResponse -> Bool
Prelude.Eq, ReadPrec [GetConfigurationResponse]
ReadPrec GetConfigurationResponse
Int -> ReadS GetConfigurationResponse
ReadS [GetConfigurationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetConfigurationResponse]
$creadListPrec :: ReadPrec [GetConfigurationResponse]
readPrec :: ReadPrec GetConfigurationResponse
$creadPrec :: ReadPrec GetConfigurationResponse
readList :: ReadS [GetConfigurationResponse]
$creadList :: ReadS [GetConfigurationResponse]
readsPrec :: Int -> ReadS GetConfigurationResponse
$creadsPrec :: Int -> ReadS GetConfigurationResponse
Prelude.Read, Int -> GetConfigurationResponse -> ShowS
[GetConfigurationResponse] -> ShowS
GetConfigurationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetConfigurationResponse] -> ShowS
$cshowList :: [GetConfigurationResponse] -> ShowS
show :: GetConfigurationResponse -> String
$cshow :: GetConfigurationResponse -> String
showsPrec :: Int -> GetConfigurationResponse -> ShowS
$cshowsPrec :: Int -> GetConfigurationResponse -> ShowS
Prelude.Show, forall x.
Rep GetConfigurationResponse x -> GetConfigurationResponse
forall x.
GetConfigurationResponse -> Rep GetConfigurationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetConfigurationResponse x -> GetConfigurationResponse
$cfrom :: forall x.
GetConfigurationResponse -> Rep GetConfigurationResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetConfigurationResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'ecrConfiguration', 'getConfigurationResponse_ecrConfiguration' - Specifies how the ECR automated re-scan duration is currently configured
-- for your environment.
--
-- 'httpStatus', 'getConfigurationResponse_httpStatus' - The response's http status code.
newGetConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetConfigurationResponse
newGetConfigurationResponse :: Int -> GetConfigurationResponse
newGetConfigurationResponse Int
pHttpStatus_ =
  GetConfigurationResponse'
    { $sel:ecrConfiguration:GetConfigurationResponse' :: Maybe EcrConfigurationState
ecrConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetConfigurationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Specifies how the ECR automated re-scan duration is currently configured
-- for your environment.
getConfigurationResponse_ecrConfiguration :: Lens.Lens' GetConfigurationResponse (Prelude.Maybe EcrConfigurationState)
getConfigurationResponse_ecrConfiguration :: Lens' GetConfigurationResponse (Maybe EcrConfigurationState)
getConfigurationResponse_ecrConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetConfigurationResponse' {Maybe EcrConfigurationState
ecrConfiguration :: Maybe EcrConfigurationState
$sel:ecrConfiguration:GetConfigurationResponse' :: GetConfigurationResponse -> Maybe EcrConfigurationState
ecrConfiguration} -> Maybe EcrConfigurationState
ecrConfiguration) (\s :: GetConfigurationResponse
s@GetConfigurationResponse' {} Maybe EcrConfigurationState
a -> GetConfigurationResponse
s {$sel:ecrConfiguration:GetConfigurationResponse' :: Maybe EcrConfigurationState
ecrConfiguration = Maybe EcrConfigurationState
a} :: GetConfigurationResponse)

-- | The response's http status code.
getConfigurationResponse_httpStatus :: Lens.Lens' GetConfigurationResponse Prelude.Int
getConfigurationResponse_httpStatus :: Lens' GetConfigurationResponse Int
getConfigurationResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetConfigurationResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetConfigurationResponse' :: GetConfigurationResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetConfigurationResponse
s@GetConfigurationResponse' {} Int
a -> GetConfigurationResponse
s {$sel:httpStatus:GetConfigurationResponse' :: Int
httpStatus = Int
a} :: GetConfigurationResponse)

instance Prelude.NFData GetConfigurationResponse where
  rnf :: GetConfigurationResponse -> ()
rnf GetConfigurationResponse' {Int
Maybe EcrConfigurationState
httpStatus :: Int
ecrConfiguration :: Maybe EcrConfigurationState
$sel:httpStatus:GetConfigurationResponse' :: GetConfigurationResponse -> Int
$sel:ecrConfiguration:GetConfigurationResponse' :: GetConfigurationResponse -> Maybe EcrConfigurationState
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EcrConfigurationState
ecrConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus