{-# 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-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 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.Lens as Lens
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
(UpdateComponent -> UpdateComponent -> Bool)
-> (UpdateComponent -> UpdateComponent -> Bool)
-> Eq UpdateComponent
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]
(Int -> ReadS UpdateComponent)
-> ReadS [UpdateComponent]
-> ReadPrec UpdateComponent
-> ReadPrec [UpdateComponent]
-> Read 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
(Int -> UpdateComponent -> ShowS)
-> (UpdateComponent -> String)
-> ([UpdateComponent] -> ShowS)
-> Show UpdateComponent
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. UpdateComponent -> Rep UpdateComponent x)
-> (forall x. Rep UpdateComponent x -> UpdateComponent)
-> Generic UpdateComponent
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' :: Maybe Text -> Maybe [Text] -> Text -> Text -> UpdateComponent
UpdateComponent'
      { $sel:newComponentName':UpdateComponent' :: Maybe Text
newComponentName' =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:resourceList:UpdateComponent' :: Maybe [Text]
resourceList = Maybe [Text]
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 :: (Maybe Text -> f (Maybe Text))
-> UpdateComponent -> f UpdateComponent
updateComponent_newComponentName = (UpdateComponent -> Maybe Text)
-> (UpdateComponent -> Maybe Text -> UpdateComponent)
-> Lens UpdateComponent UpdateComponent (Maybe Text) (Maybe Text)
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 :: (Maybe [Text] -> f (Maybe [Text]))
-> UpdateComponent -> f UpdateComponent
updateComponent_resourceList = (UpdateComponent -> Maybe [Text])
-> (UpdateComponent -> Maybe [Text] -> UpdateComponent)
-> Lens
     UpdateComponent UpdateComponent (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> UpdateComponent -> f UpdateComponent)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> UpdateComponent
-> f UpdateComponent
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: (Text -> f Text) -> UpdateComponent -> f UpdateComponent
updateComponent_resourceGroupName = (UpdateComponent -> Text)
-> (UpdateComponent -> Text -> UpdateComponent)
-> Lens UpdateComponent UpdateComponent Text Text
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 :: (Text -> f Text) -> UpdateComponent -> f UpdateComponent
updateComponent_componentName = (UpdateComponent -> Text)
-> (UpdateComponent -> Text -> UpdateComponent)
-> Lens UpdateComponent UpdateComponent Text Text
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 :: UpdateComponent -> Request UpdateComponent
request = Service -> UpdateComponent -> Request UpdateComponent
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateComponent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateComponent)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateComponent))
-> Logger
-> Service
-> Proxy UpdateComponent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateComponent)))
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 -> UpdateComponentResponse
UpdateComponentResponse'
            (Int -> UpdateComponentResponse)
-> Either String Int -> Either String UpdateComponentResponse
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 UpdateComponent

instance Prelude.NFData UpdateComponent

instance Core.ToHeaders UpdateComponent where
  toHeaders :: UpdateComponent -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateComponent -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"EC2WindowsBarleyService.UpdateComponent" ::
                          Prelude.ByteString
                      ),
            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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NewComponentName" 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
newComponentName',
            (Text
"ResourceList" 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]
resourceList,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ResourceGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceGroupName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ComponentName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
componentName)
          ]
      )

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

instance Core.ToQuery UpdateComponent where
  toQuery :: UpdateComponent -> QueryString
toQuery = QueryString -> UpdateComponent -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateComponentResponse -> UpdateComponentResponse -> Bool)
-> (UpdateComponentResponse -> UpdateComponentResponse -> Bool)
-> Eq UpdateComponentResponse
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]
(Int -> ReadS UpdateComponentResponse)
-> ReadS [UpdateComponentResponse]
-> ReadPrec UpdateComponentResponse
-> ReadPrec [UpdateComponentResponse]
-> Read 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
(Int -> UpdateComponentResponse -> ShowS)
-> (UpdateComponentResponse -> String)
-> ([UpdateComponentResponse] -> ShowS)
-> Show UpdateComponentResponse
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.
 UpdateComponentResponse -> Rep UpdateComponentResponse x)
-> (forall x.
    Rep UpdateComponentResponse x -> UpdateComponentResponse)
-> Generic UpdateComponentResponse
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' :: Int -> UpdateComponentResponse
UpdateComponentResponse' {$sel:httpStatus:UpdateComponentResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
updateComponentResponse_httpStatus :: Lens.Lens' UpdateComponentResponse Prelude.Int
updateComponentResponse_httpStatus :: (Int -> f Int)
-> UpdateComponentResponse -> f UpdateComponentResponse
updateComponentResponse_httpStatus = (UpdateComponentResponse -> Int)
-> (UpdateComponentResponse -> Int -> UpdateComponentResponse)
-> Lens UpdateComponentResponse UpdateComponentResponse Int Int
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