{-# 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.UpdateAssessmentTarget
-- 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)
--
-- Updates the assessment target that is specified by the ARN of the
-- assessment target.
--
-- If resourceGroupArn is not specified, all EC2 instances in the current
-- AWS account and region are included in the assessment target.
module Amazonka.Inspector.UpdateAssessmentTarget
  ( -- * Creating a Request
    UpdateAssessmentTarget (..),
    newUpdateAssessmentTarget,

    -- * Request Lenses
    updateAssessmentTarget_resourceGroupArn,
    updateAssessmentTarget_assessmentTargetArn,
    updateAssessmentTarget_assessmentTargetName,

    -- * Destructuring the Response
    UpdateAssessmentTargetResponse (..),
    newUpdateAssessmentTargetResponse,
  )
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:/ 'newUpdateAssessmentTarget' smart constructor.
data UpdateAssessmentTarget = UpdateAssessmentTarget'
  { -- | The ARN of the resource group that is used to specify the new resource
    -- group to associate with the assessment target.
    UpdateAssessmentTarget -> Maybe Text
resourceGroupArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the assessment target that you want to update.
    UpdateAssessmentTarget -> Text
assessmentTargetArn :: Prelude.Text,
    -- | The name of the assessment target that you want to update.
    UpdateAssessmentTarget -> Text
assessmentTargetName :: Prelude.Text
  }
  deriving (UpdateAssessmentTarget -> UpdateAssessmentTarget -> Bool
(UpdateAssessmentTarget -> UpdateAssessmentTarget -> Bool)
-> (UpdateAssessmentTarget -> UpdateAssessmentTarget -> Bool)
-> Eq UpdateAssessmentTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAssessmentTarget -> UpdateAssessmentTarget -> Bool
$c/= :: UpdateAssessmentTarget -> UpdateAssessmentTarget -> Bool
== :: UpdateAssessmentTarget -> UpdateAssessmentTarget -> Bool
$c== :: UpdateAssessmentTarget -> UpdateAssessmentTarget -> Bool
Prelude.Eq, ReadPrec [UpdateAssessmentTarget]
ReadPrec UpdateAssessmentTarget
Int -> ReadS UpdateAssessmentTarget
ReadS [UpdateAssessmentTarget]
(Int -> ReadS UpdateAssessmentTarget)
-> ReadS [UpdateAssessmentTarget]
-> ReadPrec UpdateAssessmentTarget
-> ReadPrec [UpdateAssessmentTarget]
-> Read UpdateAssessmentTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAssessmentTarget]
$creadListPrec :: ReadPrec [UpdateAssessmentTarget]
readPrec :: ReadPrec UpdateAssessmentTarget
$creadPrec :: ReadPrec UpdateAssessmentTarget
readList :: ReadS [UpdateAssessmentTarget]
$creadList :: ReadS [UpdateAssessmentTarget]
readsPrec :: Int -> ReadS UpdateAssessmentTarget
$creadsPrec :: Int -> ReadS UpdateAssessmentTarget
Prelude.Read, Int -> UpdateAssessmentTarget -> ShowS
[UpdateAssessmentTarget] -> ShowS
UpdateAssessmentTarget -> String
(Int -> UpdateAssessmentTarget -> ShowS)
-> (UpdateAssessmentTarget -> String)
-> ([UpdateAssessmentTarget] -> ShowS)
-> Show UpdateAssessmentTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAssessmentTarget] -> ShowS
$cshowList :: [UpdateAssessmentTarget] -> ShowS
show :: UpdateAssessmentTarget -> String
$cshow :: UpdateAssessmentTarget -> String
showsPrec :: Int -> UpdateAssessmentTarget -> ShowS
$cshowsPrec :: Int -> UpdateAssessmentTarget -> ShowS
Prelude.Show, (forall x. UpdateAssessmentTarget -> Rep UpdateAssessmentTarget x)
-> (forall x.
    Rep UpdateAssessmentTarget x -> UpdateAssessmentTarget)
-> Generic UpdateAssessmentTarget
forall x. Rep UpdateAssessmentTarget x -> UpdateAssessmentTarget
forall x. UpdateAssessmentTarget -> Rep UpdateAssessmentTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAssessmentTarget x -> UpdateAssessmentTarget
$cfrom :: forall x. UpdateAssessmentTarget -> Rep UpdateAssessmentTarget x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAssessmentTarget' 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:
--
-- 'resourceGroupArn', 'updateAssessmentTarget_resourceGroupArn' - The ARN of the resource group that is used to specify the new resource
-- group to associate with the assessment target.
--
-- 'assessmentTargetArn', 'updateAssessmentTarget_assessmentTargetArn' - The ARN of the assessment target that you want to update.
--
-- 'assessmentTargetName', 'updateAssessmentTarget_assessmentTargetName' - The name of the assessment target that you want to update.
newUpdateAssessmentTarget ::
  -- | 'assessmentTargetArn'
  Prelude.Text ->
  -- | 'assessmentTargetName'
  Prelude.Text ->
  UpdateAssessmentTarget
newUpdateAssessmentTarget :: Text -> Text -> UpdateAssessmentTarget
newUpdateAssessmentTarget
  Text
pAssessmentTargetArn_
  Text
pAssessmentTargetName_ =
    UpdateAssessmentTarget' :: Maybe Text -> Text -> Text -> UpdateAssessmentTarget
UpdateAssessmentTarget'
      { $sel:resourceGroupArn:UpdateAssessmentTarget' :: Maybe Text
resourceGroupArn =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:assessmentTargetArn:UpdateAssessmentTarget' :: Text
assessmentTargetArn = Text
pAssessmentTargetArn_,
        $sel:assessmentTargetName:UpdateAssessmentTarget' :: Text
assessmentTargetName = Text
pAssessmentTargetName_
      }

-- | The ARN of the resource group that is used to specify the new resource
-- group to associate with the assessment target.
updateAssessmentTarget_resourceGroupArn :: Lens.Lens' UpdateAssessmentTarget (Prelude.Maybe Prelude.Text)
updateAssessmentTarget_resourceGroupArn :: (Maybe Text -> f (Maybe Text))
-> UpdateAssessmentTarget -> f UpdateAssessmentTarget
updateAssessmentTarget_resourceGroupArn = (UpdateAssessmentTarget -> Maybe Text)
-> (UpdateAssessmentTarget -> Maybe Text -> UpdateAssessmentTarget)
-> Lens
     UpdateAssessmentTarget
     UpdateAssessmentTarget
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAssessmentTarget' {Maybe Text
resourceGroupArn :: Maybe Text
$sel:resourceGroupArn:UpdateAssessmentTarget' :: UpdateAssessmentTarget -> Maybe Text
resourceGroupArn} -> Maybe Text
resourceGroupArn) (\s :: UpdateAssessmentTarget
s@UpdateAssessmentTarget' {} Maybe Text
a -> UpdateAssessmentTarget
s {$sel:resourceGroupArn:UpdateAssessmentTarget' :: Maybe Text
resourceGroupArn = Maybe Text
a} :: UpdateAssessmentTarget)

-- | The ARN of the assessment target that you want to update.
updateAssessmentTarget_assessmentTargetArn :: Lens.Lens' UpdateAssessmentTarget Prelude.Text
updateAssessmentTarget_assessmentTargetArn :: (Text -> f Text)
-> UpdateAssessmentTarget -> f UpdateAssessmentTarget
updateAssessmentTarget_assessmentTargetArn = (UpdateAssessmentTarget -> Text)
-> (UpdateAssessmentTarget -> Text -> UpdateAssessmentTarget)
-> Lens UpdateAssessmentTarget UpdateAssessmentTarget Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAssessmentTarget' {Text
assessmentTargetArn :: Text
$sel:assessmentTargetArn:UpdateAssessmentTarget' :: UpdateAssessmentTarget -> Text
assessmentTargetArn} -> Text
assessmentTargetArn) (\s :: UpdateAssessmentTarget
s@UpdateAssessmentTarget' {} Text
a -> UpdateAssessmentTarget
s {$sel:assessmentTargetArn:UpdateAssessmentTarget' :: Text
assessmentTargetArn = Text
a} :: UpdateAssessmentTarget)

-- | The name of the assessment target that you want to update.
updateAssessmentTarget_assessmentTargetName :: Lens.Lens' UpdateAssessmentTarget Prelude.Text
updateAssessmentTarget_assessmentTargetName :: (Text -> f Text)
-> UpdateAssessmentTarget -> f UpdateAssessmentTarget
updateAssessmentTarget_assessmentTargetName = (UpdateAssessmentTarget -> Text)
-> (UpdateAssessmentTarget -> Text -> UpdateAssessmentTarget)
-> Lens UpdateAssessmentTarget UpdateAssessmentTarget Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAssessmentTarget' {Text
assessmentTargetName :: Text
$sel:assessmentTargetName:UpdateAssessmentTarget' :: UpdateAssessmentTarget -> Text
assessmentTargetName} -> Text
assessmentTargetName) (\s :: UpdateAssessmentTarget
s@UpdateAssessmentTarget' {} Text
a -> UpdateAssessmentTarget
s {$sel:assessmentTargetName:UpdateAssessmentTarget' :: Text
assessmentTargetName = Text
a} :: UpdateAssessmentTarget)

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

instance Prelude.Hashable UpdateAssessmentTarget

instance Prelude.NFData UpdateAssessmentTarget

instance Core.ToHeaders UpdateAssessmentTarget where
  toHeaders :: UpdateAssessmentTarget -> [Header]
toHeaders =
    [Header] -> UpdateAssessmentTarget -> [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.UpdateAssessmentTarget" ::
                          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 UpdateAssessmentTarget where
  toJSON :: UpdateAssessmentTarget -> Value
toJSON UpdateAssessmentTarget' {Maybe Text
Text
assessmentTargetName :: Text
assessmentTargetArn :: Text
resourceGroupArn :: Maybe Text
$sel:assessmentTargetName:UpdateAssessmentTarget' :: UpdateAssessmentTarget -> Text
$sel:assessmentTargetArn:UpdateAssessmentTarget' :: UpdateAssessmentTarget -> Text
$sel:resourceGroupArn:UpdateAssessmentTarget' :: UpdateAssessmentTarget -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"resourceGroupArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceGroupArn,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"assessmentTargetArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
assessmentTargetArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"assessmentTargetName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
assessmentTargetName
              )
          ]
      )

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

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

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

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

instance
  Prelude.NFData
    UpdateAssessmentTargetResponse