{-# 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.SecurityHub.UpdateActionTarget
-- 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 name and description of a custom action target in Security
-- Hub.
module Amazonka.SecurityHub.UpdateActionTarget
  ( -- * Creating a Request
    UpdateActionTarget (..),
    newUpdateActionTarget,

    -- * Request Lenses
    updateActionTarget_name,
    updateActionTarget_description,
    updateActionTarget_actionTargetArn,

    -- * Destructuring the Response
    UpdateActionTargetResponse (..),
    newUpdateActionTargetResponse,

    -- * Response Lenses
    updateActionTargetResponse_httpStatus,
  )
where

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
import Amazonka.SecurityHub.Types

-- | /See:/ 'newUpdateActionTarget' smart constructor.
data UpdateActionTarget = UpdateActionTarget'
  { -- | The updated name of the custom action target.
    UpdateActionTarget -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The updated description for the custom action target.
    UpdateActionTarget -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the custom action target to update.
    UpdateActionTarget -> Text
actionTargetArn :: Prelude.Text
  }
  deriving (UpdateActionTarget -> UpdateActionTarget -> Bool
(UpdateActionTarget -> UpdateActionTarget -> Bool)
-> (UpdateActionTarget -> UpdateActionTarget -> Bool)
-> Eq UpdateActionTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateActionTarget -> UpdateActionTarget -> Bool
$c/= :: UpdateActionTarget -> UpdateActionTarget -> Bool
== :: UpdateActionTarget -> UpdateActionTarget -> Bool
$c== :: UpdateActionTarget -> UpdateActionTarget -> Bool
Prelude.Eq, ReadPrec [UpdateActionTarget]
ReadPrec UpdateActionTarget
Int -> ReadS UpdateActionTarget
ReadS [UpdateActionTarget]
(Int -> ReadS UpdateActionTarget)
-> ReadS [UpdateActionTarget]
-> ReadPrec UpdateActionTarget
-> ReadPrec [UpdateActionTarget]
-> Read UpdateActionTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateActionTarget]
$creadListPrec :: ReadPrec [UpdateActionTarget]
readPrec :: ReadPrec UpdateActionTarget
$creadPrec :: ReadPrec UpdateActionTarget
readList :: ReadS [UpdateActionTarget]
$creadList :: ReadS [UpdateActionTarget]
readsPrec :: Int -> ReadS UpdateActionTarget
$creadsPrec :: Int -> ReadS UpdateActionTarget
Prelude.Read, Int -> UpdateActionTarget -> ShowS
[UpdateActionTarget] -> ShowS
UpdateActionTarget -> String
(Int -> UpdateActionTarget -> ShowS)
-> (UpdateActionTarget -> String)
-> ([UpdateActionTarget] -> ShowS)
-> Show UpdateActionTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateActionTarget] -> ShowS
$cshowList :: [UpdateActionTarget] -> ShowS
show :: UpdateActionTarget -> String
$cshow :: UpdateActionTarget -> String
showsPrec :: Int -> UpdateActionTarget -> ShowS
$cshowsPrec :: Int -> UpdateActionTarget -> ShowS
Prelude.Show, (forall x. UpdateActionTarget -> Rep UpdateActionTarget x)
-> (forall x. Rep UpdateActionTarget x -> UpdateActionTarget)
-> Generic UpdateActionTarget
forall x. Rep UpdateActionTarget x -> UpdateActionTarget
forall x. UpdateActionTarget -> Rep UpdateActionTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateActionTarget x -> UpdateActionTarget
$cfrom :: forall x. UpdateActionTarget -> Rep UpdateActionTarget x
Prelude.Generic)

-- |
-- Create a value of 'UpdateActionTarget' 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:
--
-- 'name', 'updateActionTarget_name' - The updated name of the custom action target.
--
-- 'description', 'updateActionTarget_description' - The updated description for the custom action target.
--
-- 'actionTargetArn', 'updateActionTarget_actionTargetArn' - The ARN of the custom action target to update.
newUpdateActionTarget ::
  -- | 'actionTargetArn'
  Prelude.Text ->
  UpdateActionTarget
newUpdateActionTarget :: Text -> UpdateActionTarget
newUpdateActionTarget Text
pActionTargetArn_ =
  UpdateActionTarget' :: Maybe Text -> Maybe Text -> Text -> UpdateActionTarget
UpdateActionTarget'
    { $sel:name:UpdateActionTarget' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateActionTarget' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:actionTargetArn:UpdateActionTarget' :: Text
actionTargetArn = Text
pActionTargetArn_
    }

-- | The updated name of the custom action target.
updateActionTarget_name :: Lens.Lens' UpdateActionTarget (Prelude.Maybe Prelude.Text)
updateActionTarget_name :: (Maybe Text -> f (Maybe Text))
-> UpdateActionTarget -> f UpdateActionTarget
updateActionTarget_name = (UpdateActionTarget -> Maybe Text)
-> (UpdateActionTarget -> Maybe Text -> UpdateActionTarget)
-> Lens
     UpdateActionTarget UpdateActionTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateActionTarget' {Maybe Text
name :: Maybe Text
$sel:name:UpdateActionTarget' :: UpdateActionTarget -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateActionTarget
s@UpdateActionTarget' {} Maybe Text
a -> UpdateActionTarget
s {$sel:name:UpdateActionTarget' :: Maybe Text
name = Maybe Text
a} :: UpdateActionTarget)

-- | The updated description for the custom action target.
updateActionTarget_description :: Lens.Lens' UpdateActionTarget (Prelude.Maybe Prelude.Text)
updateActionTarget_description :: (Maybe Text -> f (Maybe Text))
-> UpdateActionTarget -> f UpdateActionTarget
updateActionTarget_description = (UpdateActionTarget -> Maybe Text)
-> (UpdateActionTarget -> Maybe Text -> UpdateActionTarget)
-> Lens
     UpdateActionTarget UpdateActionTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateActionTarget' {Maybe Text
description :: Maybe Text
$sel:description:UpdateActionTarget' :: UpdateActionTarget -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateActionTarget
s@UpdateActionTarget' {} Maybe Text
a -> UpdateActionTarget
s {$sel:description:UpdateActionTarget' :: Maybe Text
description = Maybe Text
a} :: UpdateActionTarget)

-- | The ARN of the custom action target to update.
updateActionTarget_actionTargetArn :: Lens.Lens' UpdateActionTarget Prelude.Text
updateActionTarget_actionTargetArn :: (Text -> f Text) -> UpdateActionTarget -> f UpdateActionTarget
updateActionTarget_actionTargetArn = (UpdateActionTarget -> Text)
-> (UpdateActionTarget -> Text -> UpdateActionTarget)
-> Lens UpdateActionTarget UpdateActionTarget Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateActionTarget' {Text
actionTargetArn :: Text
$sel:actionTargetArn:UpdateActionTarget' :: UpdateActionTarget -> Text
actionTargetArn} -> Text
actionTargetArn) (\s :: UpdateActionTarget
s@UpdateActionTarget' {} Text
a -> UpdateActionTarget
s {$sel:actionTargetArn:UpdateActionTarget' :: Text
actionTargetArn = Text
a} :: UpdateActionTarget)

instance Core.AWSRequest UpdateActionTarget where
  type
    AWSResponse UpdateActionTarget =
      UpdateActionTargetResponse
  request :: UpdateActionTarget -> Request UpdateActionTarget
request = Service -> UpdateActionTarget -> Request UpdateActionTarget
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateActionTarget
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateActionTarget)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateActionTarget))
-> Logger
-> Service
-> Proxy UpdateActionTarget
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateActionTarget)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateActionTargetResponse
UpdateActionTargetResponse'
            (Int -> UpdateActionTargetResponse)
-> Either String Int -> Either String UpdateActionTargetResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateActionTarget

instance Prelude.NFData UpdateActionTarget

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

instance Core.ToJSON UpdateActionTarget where
  toJSON :: UpdateActionTarget -> Value
toJSON UpdateActionTarget' {Maybe Text
Text
actionTargetArn :: Text
description :: Maybe Text
name :: Maybe Text
$sel:actionTargetArn:UpdateActionTarget' :: UpdateActionTarget -> Text
$sel:description:UpdateActionTarget' :: UpdateActionTarget -> Maybe Text
$sel:name:UpdateActionTarget' :: UpdateActionTarget -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Name" 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
name,
            (Text
"Description" 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
description
          ]
      )

instance Core.ToPath UpdateActionTarget where
  toPath :: UpdateActionTarget -> ByteString
toPath UpdateActionTarget' {Maybe Text
Text
actionTargetArn :: Text
description :: Maybe Text
name :: Maybe Text
$sel:actionTargetArn:UpdateActionTarget' :: UpdateActionTarget -> Text
$sel:description:UpdateActionTarget' :: UpdateActionTarget -> Maybe Text
$sel:name:UpdateActionTarget' :: UpdateActionTarget -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/actionTargets/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
actionTargetArn]

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

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

-- |
-- Create a value of 'UpdateActionTargetResponse' 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:
--
-- 'httpStatus', 'updateActionTargetResponse_httpStatus' - The response's http status code.
newUpdateActionTargetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateActionTargetResponse
newUpdateActionTargetResponse :: Int -> UpdateActionTargetResponse
newUpdateActionTargetResponse Int
pHttpStatus_ =
  UpdateActionTargetResponse' :: Int -> UpdateActionTargetResponse
UpdateActionTargetResponse'
    { $sel:httpStatus:UpdateActionTargetResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData UpdateActionTargetResponse