{-# 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.AccessAnalyzer.StartResourceScan
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Immediately starts a scan of the policies applied to the specified
-- resource.
module Amazonka.AccessAnalyzer.StartResourceScan
  ( -- * Creating a Request
    StartResourceScan (..),
    newStartResourceScan,

    -- * Request Lenses
    startResourceScan_analyzerArn,
    startResourceScan_resourceArn,

    -- * Destructuring the Response
    StartResourceScanResponse (..),
    newStartResourceScanResponse,
  )
where

import Amazonka.AccessAnalyzer.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Starts a scan of the policies applied to the specified resource.
--
-- /See:/ 'newStartResourceScan' smart constructor.
data StartResourceScan = StartResourceScan'
  { -- | The
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#permission-resources ARN of the analyzer>
    -- to use to scan the policies applied to the specified resource.
    StartResourceScan -> Text
analyzerArn :: Prelude.Text,
    -- | The ARN of the resource to scan.
    StartResourceScan -> Text
resourceArn :: Prelude.Text
  }
  deriving (StartResourceScan -> StartResourceScan -> Bool
(StartResourceScan -> StartResourceScan -> Bool)
-> (StartResourceScan -> StartResourceScan -> Bool)
-> Eq StartResourceScan
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartResourceScan -> StartResourceScan -> Bool
$c/= :: StartResourceScan -> StartResourceScan -> Bool
== :: StartResourceScan -> StartResourceScan -> Bool
$c== :: StartResourceScan -> StartResourceScan -> Bool
Prelude.Eq, ReadPrec [StartResourceScan]
ReadPrec StartResourceScan
Int -> ReadS StartResourceScan
ReadS [StartResourceScan]
(Int -> ReadS StartResourceScan)
-> ReadS [StartResourceScan]
-> ReadPrec StartResourceScan
-> ReadPrec [StartResourceScan]
-> Read StartResourceScan
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartResourceScan]
$creadListPrec :: ReadPrec [StartResourceScan]
readPrec :: ReadPrec StartResourceScan
$creadPrec :: ReadPrec StartResourceScan
readList :: ReadS [StartResourceScan]
$creadList :: ReadS [StartResourceScan]
readsPrec :: Int -> ReadS StartResourceScan
$creadsPrec :: Int -> ReadS StartResourceScan
Prelude.Read, Int -> StartResourceScan -> ShowS
[StartResourceScan] -> ShowS
StartResourceScan -> String
(Int -> StartResourceScan -> ShowS)
-> (StartResourceScan -> String)
-> ([StartResourceScan] -> ShowS)
-> Show StartResourceScan
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartResourceScan] -> ShowS
$cshowList :: [StartResourceScan] -> ShowS
show :: StartResourceScan -> String
$cshow :: StartResourceScan -> String
showsPrec :: Int -> StartResourceScan -> ShowS
$cshowsPrec :: Int -> StartResourceScan -> ShowS
Prelude.Show, (forall x. StartResourceScan -> Rep StartResourceScan x)
-> (forall x. Rep StartResourceScan x -> StartResourceScan)
-> Generic StartResourceScan
forall x. Rep StartResourceScan x -> StartResourceScan
forall x. StartResourceScan -> Rep StartResourceScan x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartResourceScan x -> StartResourceScan
$cfrom :: forall x. StartResourceScan -> Rep StartResourceScan x
Prelude.Generic)

-- |
-- Create a value of 'StartResourceScan' 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:
--
-- 'analyzerArn', 'startResourceScan_analyzerArn' - The
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#permission-resources ARN of the analyzer>
-- to use to scan the policies applied to the specified resource.
--
-- 'resourceArn', 'startResourceScan_resourceArn' - The ARN of the resource to scan.
newStartResourceScan ::
  -- | 'analyzerArn'
  Prelude.Text ->
  -- | 'resourceArn'
  Prelude.Text ->
  StartResourceScan
newStartResourceScan :: Text -> Text -> StartResourceScan
newStartResourceScan Text
pAnalyzerArn_ Text
pResourceArn_ =
  StartResourceScan' :: Text -> Text -> StartResourceScan
StartResourceScan'
    { $sel:analyzerArn:StartResourceScan' :: Text
analyzerArn = Text
pAnalyzerArn_,
      $sel:resourceArn:StartResourceScan' :: Text
resourceArn = Text
pResourceArn_
    }

-- | The
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#permission-resources ARN of the analyzer>
-- to use to scan the policies applied to the specified resource.
startResourceScan_analyzerArn :: Lens.Lens' StartResourceScan Prelude.Text
startResourceScan_analyzerArn :: (Text -> f Text) -> StartResourceScan -> f StartResourceScan
startResourceScan_analyzerArn = (StartResourceScan -> Text)
-> (StartResourceScan -> Text -> StartResourceScan)
-> Lens StartResourceScan StartResourceScan Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartResourceScan' {Text
analyzerArn :: Text
$sel:analyzerArn:StartResourceScan' :: StartResourceScan -> Text
analyzerArn} -> Text
analyzerArn) (\s :: StartResourceScan
s@StartResourceScan' {} Text
a -> StartResourceScan
s {$sel:analyzerArn:StartResourceScan' :: Text
analyzerArn = Text
a} :: StartResourceScan)

-- | The ARN of the resource to scan.
startResourceScan_resourceArn :: Lens.Lens' StartResourceScan Prelude.Text
startResourceScan_resourceArn :: (Text -> f Text) -> StartResourceScan -> f StartResourceScan
startResourceScan_resourceArn = (StartResourceScan -> Text)
-> (StartResourceScan -> Text -> StartResourceScan)
-> Lens StartResourceScan StartResourceScan Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartResourceScan' {Text
resourceArn :: Text
$sel:resourceArn:StartResourceScan' :: StartResourceScan -> Text
resourceArn} -> Text
resourceArn) (\s :: StartResourceScan
s@StartResourceScan' {} Text
a -> StartResourceScan
s {$sel:resourceArn:StartResourceScan' :: Text
resourceArn = Text
a} :: StartResourceScan)

instance Core.AWSRequest StartResourceScan where
  type
    AWSResponse StartResourceScan =
      StartResourceScanResponse
  request :: StartResourceScan -> Request StartResourceScan
request = Service -> StartResourceScan -> Request StartResourceScan
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartResourceScan
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartResourceScan)))
response =
    AWSResponse StartResourceScan
-> Logger
-> Service
-> Proxy StartResourceScan
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartResourceScan)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse StartResourceScan
StartResourceScanResponse
StartResourceScanResponse'

instance Prelude.Hashable StartResourceScan

instance Prelude.NFData StartResourceScan

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

instance Core.ToJSON StartResourceScan where
  toJSON :: StartResourceScan -> Value
toJSON StartResourceScan' {Text
resourceArn :: Text
analyzerArn :: Text
$sel:resourceArn:StartResourceScan' :: StartResourceScan -> Text
$sel:analyzerArn:StartResourceScan' :: StartResourceScan -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"analyzerArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
analyzerArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"resourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceArn)
          ]
      )

instance Core.ToPath StartResourceScan where
  toPath :: StartResourceScan -> ByteString
toPath = ByteString -> StartResourceScan -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/resource/scan"

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

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

-- |
-- Create a value of 'StartResourceScanResponse' 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.
newStartResourceScanResponse ::
  StartResourceScanResponse
newStartResourceScanResponse :: StartResourceScanResponse
newStartResourceScanResponse =
  StartResourceScanResponse
StartResourceScanResponse'

instance Prelude.NFData StartResourceScanResponse