{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_resourceOwnerAccount,
    startResourceScan_analyzerArn,
    startResourceScan_resourceArn,

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

import Amazonka.AccessAnalyzer.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 Amazon Web Services account ID that owns the resource. For most
    -- Amazon Web Services resources, the owning account is the account in
    -- which the resource was created.
    StartResourceScan -> Maybe Text
resourceOwnerAccount :: Prelude.Maybe Prelude.Text,
    -- | 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
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]
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
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. 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:
--
-- 'resourceOwnerAccount', 'startResourceScan_resourceOwnerAccount' - The Amazon Web Services account ID that owns the resource. For most
-- Amazon Web Services resources, the owning account is the account in
-- which the resource was created.
--
-- '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'
    { $sel:resourceOwnerAccount:StartResourceScan' :: Maybe Text
resourceOwnerAccount =
        forall a. Maybe a
Prelude.Nothing,
      $sel:analyzerArn:StartResourceScan' :: Text
analyzerArn = Text
pAnalyzerArn_,
      $sel:resourceArn:StartResourceScan' :: Text
resourceArn = Text
pResourceArn_
    }

-- | The Amazon Web Services account ID that owns the resource. For most
-- Amazon Web Services resources, the owning account is the account in
-- which the resource was created.
startResourceScan_resourceOwnerAccount :: Lens.Lens' StartResourceScan (Prelude.Maybe Prelude.Text)
startResourceScan_resourceOwnerAccount :: Lens' StartResourceScan (Maybe Text)
startResourceScan_resourceOwnerAccount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartResourceScan' {Maybe Text
resourceOwnerAccount :: Maybe Text
$sel:resourceOwnerAccount:StartResourceScan' :: StartResourceScan -> Maybe Text
resourceOwnerAccount} -> Maybe Text
resourceOwnerAccount) (\s :: StartResourceScan
s@StartResourceScan' {} Maybe Text
a -> StartResourceScan
s {$sel:resourceOwnerAccount:StartResourceScan' :: Maybe Text
resourceOwnerAccount = Maybe Text
a} :: 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_analyzerArn :: Lens.Lens' StartResourceScan Prelude.Text
startResourceScan_analyzerArn :: Lens' StartResourceScan Text
startResourceScan_analyzerArn = 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 :: Lens' StartResourceScan Text
startResourceScan_resourceArn = 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 :: (Service -> Service)
-> StartResourceScan -> Request StartResourceScan
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 StartResourceScan
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartResourceScan)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull StartResourceScanResponse
StartResourceScanResponse'

instance Prelude.Hashable StartResourceScan where
  hashWithSalt :: Int -> StartResourceScan -> Int
hashWithSalt Int
_salt StartResourceScan' {Maybe Text
Text
resourceArn :: Text
analyzerArn :: Text
resourceOwnerAccount :: Maybe Text
$sel:resourceArn:StartResourceScan' :: StartResourceScan -> Text
$sel:analyzerArn:StartResourceScan' :: StartResourceScan -> Text
$sel:resourceOwnerAccount:StartResourceScan' :: StartResourceScan -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceOwnerAccount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
analyzerArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn

instance Prelude.NFData StartResourceScan where
  rnf :: StartResourceScan -> ()
rnf StartResourceScan' {Maybe Text
Text
resourceArn :: Text
analyzerArn :: Text
resourceOwnerAccount :: Maybe Text
$sel:resourceArn:StartResourceScan' :: StartResourceScan -> Text
$sel:analyzerArn:StartResourceScan' :: StartResourceScan -> Text
$sel:resourceOwnerAccount:StartResourceScan' :: StartResourceScan -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceOwnerAccount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
analyzerArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceArn

instance Data.ToHeaders StartResourceScan where
  toHeaders :: StartResourceScan -> [Header]
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 -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

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

-- | /See:/ 'newStartResourceScanResponse' smart constructor.
data StartResourceScanResponse = StartResourceScanResponse'
  {
  }
  deriving (StartResourceScanResponse -> StartResourceScanResponse -> Bool
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]
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
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.
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 where
  rnf :: StartResourceScanResponse -> ()
rnf StartResourceScanResponse
_ = ()