{-# 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.Inspector.RegisterCrossAccountAccessRole
-- 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)
--
-- Registers the IAM role that grants Amazon Inspector access to AWS
-- Services needed to perform security assessments.
module Amazonka.Inspector.RegisterCrossAccountAccessRole
  ( -- * Creating a Request
    RegisterCrossAccountAccessRole (..),
    newRegisterCrossAccountAccessRole,

    -- * Request Lenses
    registerCrossAccountAccessRole_roleArn,

    -- * Destructuring the Response
    RegisterCrossAccountAccessRoleResponse (..),
    newRegisterCrossAccountAccessRoleResponse,
  )
where

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

-- | /See:/ 'newRegisterCrossAccountAccessRole' smart constructor.
data RegisterCrossAccountAccessRole = RegisterCrossAccountAccessRole'
  { -- | The ARN of the IAM role that grants Amazon Inspector access to AWS
    -- Services needed to perform security assessments.
    RegisterCrossAccountAccessRole -> Text
roleArn :: Prelude.Text
  }
  deriving (RegisterCrossAccountAccessRole
-> RegisterCrossAccountAccessRole -> Bool
(RegisterCrossAccountAccessRole
 -> RegisterCrossAccountAccessRole -> Bool)
-> (RegisterCrossAccountAccessRole
    -> RegisterCrossAccountAccessRole -> Bool)
-> Eq RegisterCrossAccountAccessRole
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterCrossAccountAccessRole
-> RegisterCrossAccountAccessRole -> Bool
$c/= :: RegisterCrossAccountAccessRole
-> RegisterCrossAccountAccessRole -> Bool
== :: RegisterCrossAccountAccessRole
-> RegisterCrossAccountAccessRole -> Bool
$c== :: RegisterCrossAccountAccessRole
-> RegisterCrossAccountAccessRole -> Bool
Prelude.Eq, ReadPrec [RegisterCrossAccountAccessRole]
ReadPrec RegisterCrossAccountAccessRole
Int -> ReadS RegisterCrossAccountAccessRole
ReadS [RegisterCrossAccountAccessRole]
(Int -> ReadS RegisterCrossAccountAccessRole)
-> ReadS [RegisterCrossAccountAccessRole]
-> ReadPrec RegisterCrossAccountAccessRole
-> ReadPrec [RegisterCrossAccountAccessRole]
-> Read RegisterCrossAccountAccessRole
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterCrossAccountAccessRole]
$creadListPrec :: ReadPrec [RegisterCrossAccountAccessRole]
readPrec :: ReadPrec RegisterCrossAccountAccessRole
$creadPrec :: ReadPrec RegisterCrossAccountAccessRole
readList :: ReadS [RegisterCrossAccountAccessRole]
$creadList :: ReadS [RegisterCrossAccountAccessRole]
readsPrec :: Int -> ReadS RegisterCrossAccountAccessRole
$creadsPrec :: Int -> ReadS RegisterCrossAccountAccessRole
Prelude.Read, Int -> RegisterCrossAccountAccessRole -> ShowS
[RegisterCrossAccountAccessRole] -> ShowS
RegisterCrossAccountAccessRole -> String
(Int -> RegisterCrossAccountAccessRole -> ShowS)
-> (RegisterCrossAccountAccessRole -> String)
-> ([RegisterCrossAccountAccessRole] -> ShowS)
-> Show RegisterCrossAccountAccessRole
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterCrossAccountAccessRole] -> ShowS
$cshowList :: [RegisterCrossAccountAccessRole] -> ShowS
show :: RegisterCrossAccountAccessRole -> String
$cshow :: RegisterCrossAccountAccessRole -> String
showsPrec :: Int -> RegisterCrossAccountAccessRole -> ShowS
$cshowsPrec :: Int -> RegisterCrossAccountAccessRole -> ShowS
Prelude.Show, (forall x.
 RegisterCrossAccountAccessRole
 -> Rep RegisterCrossAccountAccessRole x)
-> (forall x.
    Rep RegisterCrossAccountAccessRole x
    -> RegisterCrossAccountAccessRole)
-> Generic RegisterCrossAccountAccessRole
forall x.
Rep RegisterCrossAccountAccessRole x
-> RegisterCrossAccountAccessRole
forall x.
RegisterCrossAccountAccessRole
-> Rep RegisterCrossAccountAccessRole x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterCrossAccountAccessRole x
-> RegisterCrossAccountAccessRole
$cfrom :: forall x.
RegisterCrossAccountAccessRole
-> Rep RegisterCrossAccountAccessRole x
Prelude.Generic)

-- |
-- Create a value of 'RegisterCrossAccountAccessRole' 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:
--
-- 'roleArn', 'registerCrossAccountAccessRole_roleArn' - The ARN of the IAM role that grants Amazon Inspector access to AWS
-- Services needed to perform security assessments.
newRegisterCrossAccountAccessRole ::
  -- | 'roleArn'
  Prelude.Text ->
  RegisterCrossAccountAccessRole
newRegisterCrossAccountAccessRole :: Text -> RegisterCrossAccountAccessRole
newRegisterCrossAccountAccessRole Text
pRoleArn_ =
  RegisterCrossAccountAccessRole' :: Text -> RegisterCrossAccountAccessRole
RegisterCrossAccountAccessRole'
    { $sel:roleArn:RegisterCrossAccountAccessRole' :: Text
roleArn =
        Text
pRoleArn_
    }

-- | The ARN of the IAM role that grants Amazon Inspector access to AWS
-- Services needed to perform security assessments.
registerCrossAccountAccessRole_roleArn :: Lens.Lens' RegisterCrossAccountAccessRole Prelude.Text
registerCrossAccountAccessRole_roleArn :: (Text -> f Text)
-> RegisterCrossAccountAccessRole
-> f RegisterCrossAccountAccessRole
registerCrossAccountAccessRole_roleArn = (RegisterCrossAccountAccessRole -> Text)
-> (RegisterCrossAccountAccessRole
    -> Text -> RegisterCrossAccountAccessRole)
-> Lens
     RegisterCrossAccountAccessRole
     RegisterCrossAccountAccessRole
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterCrossAccountAccessRole' {Text
roleArn :: Text
$sel:roleArn:RegisterCrossAccountAccessRole' :: RegisterCrossAccountAccessRole -> Text
roleArn} -> Text
roleArn) (\s :: RegisterCrossAccountAccessRole
s@RegisterCrossAccountAccessRole' {} Text
a -> RegisterCrossAccountAccessRole
s {$sel:roleArn:RegisterCrossAccountAccessRole' :: Text
roleArn = Text
a} :: RegisterCrossAccountAccessRole)

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

instance
  Prelude.Hashable
    RegisterCrossAccountAccessRole

instance
  Prelude.NFData
    RegisterCrossAccountAccessRole

instance
  Core.ToHeaders
    RegisterCrossAccountAccessRole
  where
  toHeaders :: RegisterCrossAccountAccessRole -> [Header]
toHeaders =
    [Header] -> RegisterCrossAccountAccessRole -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"InspectorService.RegisterCrossAccountAccessRole" ::
                          Prelude.ByteString
                      ),
            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 RegisterCrossAccountAccessRole where
  toJSON :: RegisterCrossAccountAccessRole -> Value
toJSON RegisterCrossAccountAccessRole' {Text
roleArn :: Text
$sel:roleArn:RegisterCrossAccountAccessRole' :: RegisterCrossAccountAccessRole -> 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
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn)]
      )

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

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

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

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

instance
  Prelude.NFData
    RegisterCrossAccountAccessRoleResponse