{-# 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.AppConfig.UpdateExtension
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates an AppConfig extension. For more information about extensions,
-- see
-- <https://docs.aws.amazon.com/appconfig/latest/userguide/working-with-appconfig-extensions.html Working with AppConfig extensions>
-- in the /AppConfig User Guide/.
module Amazonka.AppConfig.UpdateExtension
  ( -- * Creating a Request
    UpdateExtension (..),
    newUpdateExtension,

    -- * Request Lenses
    updateExtension_actions,
    updateExtension_description,
    updateExtension_parameters,
    updateExtension_versionNumber,
    updateExtension_extensionIdentifier,

    -- * Destructuring the Response
    Extension (..),
    newExtension,

    -- * Response Lenses
    extension_actions,
    extension_arn,
    extension_description,
    extension_id,
    extension_name,
    extension_parameters,
    extension_versionNumber,
  )
where

import Amazonka.AppConfig.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

-- | /See:/ 'newUpdateExtension' smart constructor.
data UpdateExtension = UpdateExtension'
  { -- | The actions defined in the extension.
    UpdateExtension -> Maybe (HashMap ActionPoint (NonEmpty Action))
actions :: Prelude.Maybe (Prelude.HashMap ActionPoint (Prelude.NonEmpty Action)),
    -- | Information about the extension.
    UpdateExtension -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | One or more parameters for the actions called by the extension.
    UpdateExtension -> Maybe (HashMap Text Parameter)
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Parameter),
    -- | The extension version number.
    UpdateExtension -> Maybe Int
versionNumber :: Prelude.Maybe Prelude.Int,
    -- | The name, the ID, or the Amazon Resource Name (ARN) of the extension.
    UpdateExtension -> Text
extensionIdentifier :: Prelude.Text
  }
  deriving (UpdateExtension -> UpdateExtension -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateExtension -> UpdateExtension -> Bool
$c/= :: UpdateExtension -> UpdateExtension -> Bool
== :: UpdateExtension -> UpdateExtension -> Bool
$c== :: UpdateExtension -> UpdateExtension -> Bool
Prelude.Eq, ReadPrec [UpdateExtension]
ReadPrec UpdateExtension
Int -> ReadS UpdateExtension
ReadS [UpdateExtension]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateExtension]
$creadListPrec :: ReadPrec [UpdateExtension]
readPrec :: ReadPrec UpdateExtension
$creadPrec :: ReadPrec UpdateExtension
readList :: ReadS [UpdateExtension]
$creadList :: ReadS [UpdateExtension]
readsPrec :: Int -> ReadS UpdateExtension
$creadsPrec :: Int -> ReadS UpdateExtension
Prelude.Read, Int -> UpdateExtension -> ShowS
[UpdateExtension] -> ShowS
UpdateExtension -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateExtension] -> ShowS
$cshowList :: [UpdateExtension] -> ShowS
show :: UpdateExtension -> String
$cshow :: UpdateExtension -> String
showsPrec :: Int -> UpdateExtension -> ShowS
$cshowsPrec :: Int -> UpdateExtension -> ShowS
Prelude.Show, forall x. Rep UpdateExtension x -> UpdateExtension
forall x. UpdateExtension -> Rep UpdateExtension x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateExtension x -> UpdateExtension
$cfrom :: forall x. UpdateExtension -> Rep UpdateExtension x
Prelude.Generic)

-- |
-- Create a value of 'UpdateExtension' 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:
--
-- 'actions', 'updateExtension_actions' - The actions defined in the extension.
--
-- 'description', 'updateExtension_description' - Information about the extension.
--
-- 'parameters', 'updateExtension_parameters' - One or more parameters for the actions called by the extension.
--
-- 'versionNumber', 'updateExtension_versionNumber' - The extension version number.
--
-- 'extensionIdentifier', 'updateExtension_extensionIdentifier' - The name, the ID, or the Amazon Resource Name (ARN) of the extension.
newUpdateExtension ::
  -- | 'extensionIdentifier'
  Prelude.Text ->
  UpdateExtension
newUpdateExtension :: Text -> UpdateExtension
newUpdateExtension Text
pExtensionIdentifier_ =
  UpdateExtension'
    { $sel:actions:UpdateExtension' :: Maybe (HashMap ActionPoint (NonEmpty Action))
actions = forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateExtension' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:UpdateExtension' :: Maybe (HashMap Text Parameter)
parameters = forall a. Maybe a
Prelude.Nothing,
      $sel:versionNumber:UpdateExtension' :: Maybe Int
versionNumber = forall a. Maybe a
Prelude.Nothing,
      $sel:extensionIdentifier:UpdateExtension' :: Text
extensionIdentifier = Text
pExtensionIdentifier_
    }

-- | The actions defined in the extension.
updateExtension_actions :: Lens.Lens' UpdateExtension (Prelude.Maybe (Prelude.HashMap ActionPoint (Prelude.NonEmpty Action)))
updateExtension_actions :: Lens'
  UpdateExtension (Maybe (HashMap ActionPoint (NonEmpty Action)))
updateExtension_actions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateExtension' {Maybe (HashMap ActionPoint (NonEmpty Action))
actions :: Maybe (HashMap ActionPoint (NonEmpty Action))
$sel:actions:UpdateExtension' :: UpdateExtension -> Maybe (HashMap ActionPoint (NonEmpty Action))
actions} -> Maybe (HashMap ActionPoint (NonEmpty Action))
actions) (\s :: UpdateExtension
s@UpdateExtension' {} Maybe (HashMap ActionPoint (NonEmpty Action))
a -> UpdateExtension
s {$sel:actions:UpdateExtension' :: Maybe (HashMap ActionPoint (NonEmpty Action))
actions = Maybe (HashMap ActionPoint (NonEmpty Action))
a} :: UpdateExtension) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Information about the extension.
updateExtension_description :: Lens.Lens' UpdateExtension (Prelude.Maybe Prelude.Text)
updateExtension_description :: Lens' UpdateExtension (Maybe Text)
updateExtension_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateExtension' {Maybe Text
description :: Maybe Text
$sel:description:UpdateExtension' :: UpdateExtension -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateExtension
s@UpdateExtension' {} Maybe Text
a -> UpdateExtension
s {$sel:description:UpdateExtension' :: Maybe Text
description = Maybe Text
a} :: UpdateExtension)

-- | One or more parameters for the actions called by the extension.
updateExtension_parameters :: Lens.Lens' UpdateExtension (Prelude.Maybe (Prelude.HashMap Prelude.Text Parameter))
updateExtension_parameters :: Lens' UpdateExtension (Maybe (HashMap Text Parameter))
updateExtension_parameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateExtension' {Maybe (HashMap Text Parameter)
parameters :: Maybe (HashMap Text Parameter)
$sel:parameters:UpdateExtension' :: UpdateExtension -> Maybe (HashMap Text Parameter)
parameters} -> Maybe (HashMap Text Parameter)
parameters) (\s :: UpdateExtension
s@UpdateExtension' {} Maybe (HashMap Text Parameter)
a -> UpdateExtension
s {$sel:parameters:UpdateExtension' :: Maybe (HashMap Text Parameter)
parameters = Maybe (HashMap Text Parameter)
a} :: UpdateExtension) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The extension version number.
updateExtension_versionNumber :: Lens.Lens' UpdateExtension (Prelude.Maybe Prelude.Int)
updateExtension_versionNumber :: Lens' UpdateExtension (Maybe Int)
updateExtension_versionNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateExtension' {Maybe Int
versionNumber :: Maybe Int
$sel:versionNumber:UpdateExtension' :: UpdateExtension -> Maybe Int
versionNumber} -> Maybe Int
versionNumber) (\s :: UpdateExtension
s@UpdateExtension' {} Maybe Int
a -> UpdateExtension
s {$sel:versionNumber:UpdateExtension' :: Maybe Int
versionNumber = Maybe Int
a} :: UpdateExtension)

-- | The name, the ID, or the Amazon Resource Name (ARN) of the extension.
updateExtension_extensionIdentifier :: Lens.Lens' UpdateExtension Prelude.Text
updateExtension_extensionIdentifier :: Lens' UpdateExtension Text
updateExtension_extensionIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateExtension' {Text
extensionIdentifier :: Text
$sel:extensionIdentifier:UpdateExtension' :: UpdateExtension -> Text
extensionIdentifier} -> Text
extensionIdentifier) (\s :: UpdateExtension
s@UpdateExtension' {} Text
a -> UpdateExtension
s {$sel:extensionIdentifier:UpdateExtension' :: Text
extensionIdentifier = Text
a} :: UpdateExtension)

instance Core.AWSRequest UpdateExtension where
  type AWSResponse UpdateExtension = Extension
  request :: (Service -> Service) -> UpdateExtension -> Request UpdateExtension
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateExtension
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateExtension)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable UpdateExtension where
  hashWithSalt :: Int -> UpdateExtension -> Int
hashWithSalt Int
_salt UpdateExtension' {Maybe Int
Maybe Text
Maybe (HashMap Text Parameter)
Maybe (HashMap ActionPoint (NonEmpty Action))
Text
extensionIdentifier :: Text
versionNumber :: Maybe Int
parameters :: Maybe (HashMap Text Parameter)
description :: Maybe Text
actions :: Maybe (HashMap ActionPoint (NonEmpty Action))
$sel:extensionIdentifier:UpdateExtension' :: UpdateExtension -> Text
$sel:versionNumber:UpdateExtension' :: UpdateExtension -> Maybe Int
$sel:parameters:UpdateExtension' :: UpdateExtension -> Maybe (HashMap Text Parameter)
$sel:description:UpdateExtension' :: UpdateExtension -> Maybe Text
$sel:actions:UpdateExtension' :: UpdateExtension -> Maybe (HashMap ActionPoint (NonEmpty Action))
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap ActionPoint (NonEmpty Action))
actions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Parameter)
parameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
versionNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
extensionIdentifier

instance Prelude.NFData UpdateExtension where
  rnf :: UpdateExtension -> ()
rnf UpdateExtension' {Maybe Int
Maybe Text
Maybe (HashMap Text Parameter)
Maybe (HashMap ActionPoint (NonEmpty Action))
Text
extensionIdentifier :: Text
versionNumber :: Maybe Int
parameters :: Maybe (HashMap Text Parameter)
description :: Maybe Text
actions :: Maybe (HashMap ActionPoint (NonEmpty Action))
$sel:extensionIdentifier:UpdateExtension' :: UpdateExtension -> Text
$sel:versionNumber:UpdateExtension' :: UpdateExtension -> Maybe Int
$sel:parameters:UpdateExtension' :: UpdateExtension -> Maybe (HashMap Text Parameter)
$sel:description:UpdateExtension' :: UpdateExtension -> Maybe Text
$sel:actions:UpdateExtension' :: UpdateExtension -> Maybe (HashMap ActionPoint (NonEmpty Action))
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap ActionPoint (NonEmpty Action))
actions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Parameter)
parameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
versionNumber
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
extensionIdentifier

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

instance Data.ToJSON UpdateExtension where
  toJSON :: UpdateExtension -> Value
toJSON UpdateExtension' {Maybe Int
Maybe Text
Maybe (HashMap Text Parameter)
Maybe (HashMap ActionPoint (NonEmpty Action))
Text
extensionIdentifier :: Text
versionNumber :: Maybe Int
parameters :: Maybe (HashMap Text Parameter)
description :: Maybe Text
actions :: Maybe (HashMap ActionPoint (NonEmpty Action))
$sel:extensionIdentifier:UpdateExtension' :: UpdateExtension -> Text
$sel:versionNumber:UpdateExtension' :: UpdateExtension -> Maybe Int
$sel:parameters:UpdateExtension' :: UpdateExtension -> Maybe (HashMap Text Parameter)
$sel:description:UpdateExtension' :: UpdateExtension -> Maybe Text
$sel:actions:UpdateExtension' :: UpdateExtension -> Maybe (HashMap ActionPoint (NonEmpty Action))
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Actions" 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 (HashMap ActionPoint (NonEmpty Action))
actions,
            (Key
"Description" 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
description,
            (Key
"Parameters" 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 (HashMap Text Parameter)
parameters,
            (Key
"VersionNumber" 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 Int
versionNumber
          ]
      )

instance Data.ToPath UpdateExtension where
  toPath :: UpdateExtension -> ByteString
toPath UpdateExtension' {Maybe Int
Maybe Text
Maybe (HashMap Text Parameter)
Maybe (HashMap ActionPoint (NonEmpty Action))
Text
extensionIdentifier :: Text
versionNumber :: Maybe Int
parameters :: Maybe (HashMap Text Parameter)
description :: Maybe Text
actions :: Maybe (HashMap ActionPoint (NonEmpty Action))
$sel:extensionIdentifier:UpdateExtension' :: UpdateExtension -> Text
$sel:versionNumber:UpdateExtension' :: UpdateExtension -> Maybe Int
$sel:parameters:UpdateExtension' :: UpdateExtension -> Maybe (HashMap Text Parameter)
$sel:description:UpdateExtension' :: UpdateExtension -> Maybe Text
$sel:actions:UpdateExtension' :: UpdateExtension -> Maybe (HashMap ActionPoint (NonEmpty Action))
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/extensions/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
extensionIdentifier]

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