{-# 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.ApplicationInsights.UpdateComponent
-- 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 the custom component name and\/or the list of resources that
-- make up the component.
module Amazonka.ApplicationInsights.UpdateComponent
  ( -- * Creating a Request
    UpdateComponent (..),
    newUpdateComponent,

    -- * Request Lenses
    updateComponent_newComponentName,
    updateComponent_resourceList,
    updateComponent_resourceGroupName,
    updateComponent_componentName,

    -- * Destructuring the Response
    UpdateComponentResponse (..),
    newUpdateComponentResponse,

    -- * Response Lenses
    updateComponentResponse_httpStatus,
  )
where

import Amazonka.ApplicationInsights.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:/ 'newUpdateComponent' smart constructor.
data UpdateComponent = UpdateComponent'
  { -- | The new name of the component.
    UpdateComponent -> Maybe Text
newComponentName' :: Prelude.Maybe Prelude.Text,
    -- | The list of resource ARNs that belong to the component.
    UpdateComponent -> Maybe [Text]
resourceList :: Prelude.Maybe [Prelude.Text],
    -- | The name of the resource group.
    UpdateComponent -> Text
resourceGroupName :: Prelude.Text,
    -- | The name of the component.
    UpdateComponent -> Text
componentName :: Prelude.Text
  }
  deriving (UpdateComponent -> UpdateComponent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateComponent -> UpdateComponent -> Bool
$c/= :: UpdateComponent -> UpdateComponent -> Bool
== :: UpdateComponent -> UpdateComponent -> Bool
$c== :: UpdateComponent -> UpdateComponent -> Bool
Prelude.Eq, ReadPrec [UpdateComponent]
ReadPrec UpdateComponent
Int -> ReadS UpdateComponent
ReadS [UpdateComponent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateComponent]
$creadListPrec :: ReadPrec [UpdateComponent]
readPrec :: ReadPrec UpdateComponent
$creadPrec :: ReadPrec UpdateComponent
readList :: ReadS [UpdateComponent]
$creadList :: ReadS [UpdateComponent]
readsPrec :: Int -> ReadS UpdateComponent
$creadsPrec :: Int -> ReadS UpdateComponent
Prelude.Read, Int -> UpdateComponent -> ShowS
[UpdateComponent] -> ShowS
UpdateComponent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateComponent] -> ShowS
$cshowList :: [UpdateComponent] -> ShowS
show :: UpdateComponent -> String
$cshow :: UpdateComponent -> String
showsPrec :: Int -> UpdateComponent -> ShowS
$cshowsPrec :: Int -> UpdateComponent -> ShowS
Prelude.Show, forall x. Rep UpdateComponent x -> UpdateComponent
forall x. UpdateComponent -> Rep UpdateComponent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateComponent x -> UpdateComponent
$cfrom :: forall x. UpdateComponent -> Rep UpdateComponent x
Prelude.Generic)

-- |
-- Create a value of 'UpdateComponent' 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:
--
-- 'newComponentName'', 'updateComponent_newComponentName' - The new name of the component.
--
-- 'resourceList', 'updateComponent_resourceList' - The list of resource ARNs that belong to the component.
--
-- 'resourceGroupName', 'updateComponent_resourceGroupName' - The name of the resource group.
--
-- 'componentName', 'updateComponent_componentName' - The name of the component.
newUpdateComponent ::
  -- | 'resourceGroupName'
  Prelude.Text ->
  -- | 'componentName'
  Prelude.Text ->
  UpdateComponent
newUpdateComponent :: Text -> Text -> UpdateComponent
newUpdateComponent
  Text
pResourceGroupName_
  Text
pComponentName_ =
    UpdateComponent'
      { $sel:newComponentName':UpdateComponent' :: Maybe Text
newComponentName' =
          forall a. Maybe a
Prelude.Nothing,
        $sel:resourceList:UpdateComponent' :: Maybe [Text]
resourceList = forall a. Maybe a
Prelude.Nothing,
        $sel:resourceGroupName:UpdateComponent' :: Text
resourceGroupName = Text
pResourceGroupName_,
        $sel:componentName:UpdateComponent' :: Text
componentName = Text
pComponentName_
      }

-- | The new name of the component.
updateComponent_newComponentName :: Lens.Lens' UpdateComponent (Prelude.Maybe Prelude.Text)
updateComponent_newComponentName :: Lens' UpdateComponent (Maybe Text)
updateComponent_newComponentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateComponent' {Maybe Text
newComponentName' :: Maybe Text
$sel:newComponentName':UpdateComponent' :: UpdateComponent -> Maybe Text
newComponentName'} -> Maybe Text
newComponentName') (\s :: UpdateComponent
s@UpdateComponent' {} Maybe Text
a -> UpdateComponent
s {$sel:newComponentName':UpdateComponent' :: Maybe Text
newComponentName' = Maybe Text
a} :: UpdateComponent)

-- | The list of resource ARNs that belong to the component.
updateComponent_resourceList :: Lens.Lens' UpdateComponent (Prelude.Maybe [Prelude.Text])
updateComponent_resourceList :: Lens' UpdateComponent (Maybe [Text])
updateComponent_resourceList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateComponent' {Maybe [Text]
resourceList :: Maybe [Text]
$sel:resourceList:UpdateComponent' :: UpdateComponent -> Maybe [Text]
resourceList} -> Maybe [Text]
resourceList) (\s :: UpdateComponent
s@UpdateComponent' {} Maybe [Text]
a -> UpdateComponent
s {$sel:resourceList:UpdateComponent' :: Maybe [Text]
resourceList = Maybe [Text]
a} :: UpdateComponent) 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 name of the resource group.
updateComponent_resourceGroupName :: Lens.Lens' UpdateComponent Prelude.Text
updateComponent_resourceGroupName :: Lens' UpdateComponent Text
updateComponent_resourceGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateComponent' {Text
resourceGroupName :: Text
$sel:resourceGroupName:UpdateComponent' :: UpdateComponent -> Text
resourceGroupName} -> Text
resourceGroupName) (\s :: UpdateComponent
s@UpdateComponent' {} Text
a -> UpdateComponent
s {$sel:resourceGroupName:UpdateComponent' :: Text
resourceGroupName = Text
a} :: UpdateComponent)

-- | The name of the component.
updateComponent_componentName :: Lens.Lens' UpdateComponent Prelude.Text
updateComponent_componentName :: Lens' UpdateComponent Text
updateComponent_componentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateComponent' {Text
componentName :: Text
$sel:componentName:UpdateComponent' :: UpdateComponent -> Text
componentName} -> Text
componentName) (\s :: UpdateComponent
s@UpdateComponent' {} Text
a -> UpdateComponent
s {$sel:componentName:UpdateComponent' :: Text
componentName = Text
a} :: UpdateComponent)

instance Core.AWSRequest UpdateComponent where
  type
    AWSResponse UpdateComponent =
      UpdateComponentResponse
  request :: (Service -> Service) -> UpdateComponent -> Request UpdateComponent
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 UpdateComponent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateComponent)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateComponentResponse
UpdateComponentResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateComponent where
  hashWithSalt :: Int -> UpdateComponent -> Int
hashWithSalt Int
_salt UpdateComponent' {Maybe [Text]
Maybe Text
Text
componentName :: Text
resourceGroupName :: Text
resourceList :: Maybe [Text]
newComponentName' :: Maybe Text
$sel:componentName:UpdateComponent' :: UpdateComponent -> Text
$sel:resourceGroupName:UpdateComponent' :: UpdateComponent -> Text
$sel:resourceList:UpdateComponent' :: UpdateComponent -> Maybe [Text]
$sel:newComponentName':UpdateComponent' :: UpdateComponent -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
newComponentName'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
resourceList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
componentName

instance Prelude.NFData UpdateComponent where
  rnf :: UpdateComponent -> ()
rnf UpdateComponent' {Maybe [Text]
Maybe Text
Text
componentName :: Text
resourceGroupName :: Text
resourceList :: Maybe [Text]
newComponentName' :: Maybe Text
$sel:componentName:UpdateComponent' :: UpdateComponent -> Text
$sel:resourceGroupName:UpdateComponent' :: UpdateComponent -> Text
$sel:resourceList:UpdateComponent' :: UpdateComponent -> Maybe [Text]
$sel:newComponentName':UpdateComponent' :: UpdateComponent -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
newComponentName'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
resourceList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
componentName

instance Data.ToHeaders UpdateComponent where
  toHeaders :: UpdateComponent -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"EC2WindowsBarleyService.UpdateComponent" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateComponent where
  toJSON :: UpdateComponent -> Value
toJSON UpdateComponent' {Maybe [Text]
Maybe Text
Text
componentName :: Text
resourceGroupName :: Text
resourceList :: Maybe [Text]
newComponentName' :: Maybe Text
$sel:componentName:UpdateComponent' :: UpdateComponent -> Text
$sel:resourceGroupName:UpdateComponent' :: UpdateComponent -> Text
$sel:resourceList:UpdateComponent' :: UpdateComponent -> Maybe [Text]
$sel:newComponentName':UpdateComponent' :: UpdateComponent -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"NewComponentName" 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
newComponentName',
            (Key
"ResourceList" 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]
resourceList,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ResourceGroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceGroupName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ComponentName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
componentName)
          ]
      )

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

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

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

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

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

instance Prelude.NFData UpdateComponentResponse where
  rnf :: UpdateComponentResponse -> ()
rnf UpdateComponentResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateComponentResponse' :: UpdateComponentResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus