{-# 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.ServiceCatalog.UpdateTagOption
-- 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 specified TagOption.
module Amazonka.ServiceCatalog.UpdateTagOption
  ( -- * Creating a Request
    UpdateTagOption (..),
    newUpdateTagOption,

    -- * Request Lenses
    updateTagOption_active,
    updateTagOption_value,
    updateTagOption_id,

    -- * Destructuring the Response
    UpdateTagOptionResponse (..),
    newUpdateTagOptionResponse,

    -- * Response Lenses
    updateTagOptionResponse_tagOptionDetail,
    updateTagOptionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateTagOption' smart constructor.
data UpdateTagOption = UpdateTagOption'
  { -- | The updated active state.
    UpdateTagOption -> Maybe Bool
active :: Prelude.Maybe Prelude.Bool,
    -- | The updated value.
    UpdateTagOption -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The TagOption identifier.
    UpdateTagOption -> Text
id :: Prelude.Text
  }
  deriving (UpdateTagOption -> UpdateTagOption -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateTagOption -> UpdateTagOption -> Bool
$c/= :: UpdateTagOption -> UpdateTagOption -> Bool
== :: UpdateTagOption -> UpdateTagOption -> Bool
$c== :: UpdateTagOption -> UpdateTagOption -> Bool
Prelude.Eq, ReadPrec [UpdateTagOption]
ReadPrec UpdateTagOption
Int -> ReadS UpdateTagOption
ReadS [UpdateTagOption]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateTagOption]
$creadListPrec :: ReadPrec [UpdateTagOption]
readPrec :: ReadPrec UpdateTagOption
$creadPrec :: ReadPrec UpdateTagOption
readList :: ReadS [UpdateTagOption]
$creadList :: ReadS [UpdateTagOption]
readsPrec :: Int -> ReadS UpdateTagOption
$creadsPrec :: Int -> ReadS UpdateTagOption
Prelude.Read, Int -> UpdateTagOption -> ShowS
[UpdateTagOption] -> ShowS
UpdateTagOption -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateTagOption] -> ShowS
$cshowList :: [UpdateTagOption] -> ShowS
show :: UpdateTagOption -> String
$cshow :: UpdateTagOption -> String
showsPrec :: Int -> UpdateTagOption -> ShowS
$cshowsPrec :: Int -> UpdateTagOption -> ShowS
Prelude.Show, forall x. Rep UpdateTagOption x -> UpdateTagOption
forall x. UpdateTagOption -> Rep UpdateTagOption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateTagOption x -> UpdateTagOption
$cfrom :: forall x. UpdateTagOption -> Rep UpdateTagOption x
Prelude.Generic)

-- |
-- Create a value of 'UpdateTagOption' 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:
--
-- 'active', 'updateTagOption_active' - The updated active state.
--
-- 'value', 'updateTagOption_value' - The updated value.
--
-- 'id', 'updateTagOption_id' - The TagOption identifier.
newUpdateTagOption ::
  -- | 'id'
  Prelude.Text ->
  UpdateTagOption
newUpdateTagOption :: Text -> UpdateTagOption
newUpdateTagOption Text
pId_ =
  UpdateTagOption'
    { $sel:active:UpdateTagOption' :: Maybe Bool
active = forall a. Maybe a
Prelude.Nothing,
      $sel:value:UpdateTagOption' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing,
      $sel:id:UpdateTagOption' :: Text
id = Text
pId_
    }

-- | The updated active state.
updateTagOption_active :: Lens.Lens' UpdateTagOption (Prelude.Maybe Prelude.Bool)
updateTagOption_active :: Lens' UpdateTagOption (Maybe Bool)
updateTagOption_active = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTagOption' {Maybe Bool
active :: Maybe Bool
$sel:active:UpdateTagOption' :: UpdateTagOption -> Maybe Bool
active} -> Maybe Bool
active) (\s :: UpdateTagOption
s@UpdateTagOption' {} Maybe Bool
a -> UpdateTagOption
s {$sel:active:UpdateTagOption' :: Maybe Bool
active = Maybe Bool
a} :: UpdateTagOption)

-- | The updated value.
updateTagOption_value :: Lens.Lens' UpdateTagOption (Prelude.Maybe Prelude.Text)
updateTagOption_value :: Lens' UpdateTagOption (Maybe Text)
updateTagOption_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTagOption' {Maybe Text
value :: Maybe Text
$sel:value:UpdateTagOption' :: UpdateTagOption -> Maybe Text
value} -> Maybe Text
value) (\s :: UpdateTagOption
s@UpdateTagOption' {} Maybe Text
a -> UpdateTagOption
s {$sel:value:UpdateTagOption' :: Maybe Text
value = Maybe Text
a} :: UpdateTagOption)

-- | The TagOption identifier.
updateTagOption_id :: Lens.Lens' UpdateTagOption Prelude.Text
updateTagOption_id :: Lens' UpdateTagOption Text
updateTagOption_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTagOption' {Text
id :: Text
$sel:id:UpdateTagOption' :: UpdateTagOption -> Text
id} -> Text
id) (\s :: UpdateTagOption
s@UpdateTagOption' {} Text
a -> UpdateTagOption
s {$sel:id:UpdateTagOption' :: Text
id = Text
a} :: UpdateTagOption)

instance Core.AWSRequest UpdateTagOption where
  type
    AWSResponse UpdateTagOption =
      UpdateTagOptionResponse
  request :: (Service -> Service) -> UpdateTagOption -> Request UpdateTagOption
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 UpdateTagOption
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateTagOption)))
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 ->
          Maybe TagOptionDetail -> Int -> UpdateTagOptionResponse
UpdateTagOptionResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"TagOptionDetail")
            forall (f :: * -> *) a b. Applicative f => 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 UpdateTagOption where
  hashWithSalt :: Int -> UpdateTagOption -> Int
hashWithSalt Int
_salt UpdateTagOption' {Maybe Bool
Maybe Text
Text
id :: Text
value :: Maybe Text
active :: Maybe Bool
$sel:id:UpdateTagOption' :: UpdateTagOption -> Text
$sel:value:UpdateTagOption' :: UpdateTagOption -> Maybe Text
$sel:active:UpdateTagOption' :: UpdateTagOption -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
active
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData UpdateTagOption where
  rnf :: UpdateTagOption -> ()
rnf UpdateTagOption' {Maybe Bool
Maybe Text
Text
id :: Text
value :: Maybe Text
active :: Maybe Bool
$sel:id:UpdateTagOption' :: UpdateTagOption -> Text
$sel:value:UpdateTagOption' :: UpdateTagOption -> Maybe Text
$sel:active:UpdateTagOption' :: UpdateTagOption -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
active
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance Data.ToHeaders UpdateTagOption where
  toHeaders :: UpdateTagOption -> 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
"AWS242ServiceCatalogService.UpdateTagOption" ::
                          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 UpdateTagOption where
  toJSON :: UpdateTagOption -> Value
toJSON UpdateTagOption' {Maybe Bool
Maybe Text
Text
id :: Text
value :: Maybe Text
active :: Maybe Bool
$sel:id:UpdateTagOption' :: UpdateTagOption -> Text
$sel:value:UpdateTagOption' :: UpdateTagOption -> Maybe Text
$sel:active:UpdateTagOption' :: UpdateTagOption -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Active" 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 Bool
active,
            (Key
"Value" 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
value,
            forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateTagOptionResponse' 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:
--
-- 'tagOptionDetail', 'updateTagOptionResponse_tagOptionDetail' - Information about the TagOption.
--
-- 'httpStatus', 'updateTagOptionResponse_httpStatus' - The response's http status code.
newUpdateTagOptionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateTagOptionResponse
newUpdateTagOptionResponse :: Int -> UpdateTagOptionResponse
newUpdateTagOptionResponse Int
pHttpStatus_ =
  UpdateTagOptionResponse'
    { $sel:tagOptionDetail:UpdateTagOptionResponse' :: Maybe TagOptionDetail
tagOptionDetail =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateTagOptionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the TagOption.
updateTagOptionResponse_tagOptionDetail :: Lens.Lens' UpdateTagOptionResponse (Prelude.Maybe TagOptionDetail)
updateTagOptionResponse_tagOptionDetail :: Lens' UpdateTagOptionResponse (Maybe TagOptionDetail)
updateTagOptionResponse_tagOptionDetail = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTagOptionResponse' {Maybe TagOptionDetail
tagOptionDetail :: Maybe TagOptionDetail
$sel:tagOptionDetail:UpdateTagOptionResponse' :: UpdateTagOptionResponse -> Maybe TagOptionDetail
tagOptionDetail} -> Maybe TagOptionDetail
tagOptionDetail) (\s :: UpdateTagOptionResponse
s@UpdateTagOptionResponse' {} Maybe TagOptionDetail
a -> UpdateTagOptionResponse
s {$sel:tagOptionDetail:UpdateTagOptionResponse' :: Maybe TagOptionDetail
tagOptionDetail = Maybe TagOptionDetail
a} :: UpdateTagOptionResponse)

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

instance Prelude.NFData UpdateTagOptionResponse where
  rnf :: UpdateTagOptionResponse -> ()
rnf UpdateTagOptionResponse' {Int
Maybe TagOptionDetail
httpStatus :: Int
tagOptionDetail :: Maybe TagOptionDetail
$sel:httpStatus:UpdateTagOptionResponse' :: UpdateTagOptionResponse -> Int
$sel:tagOptionDetail:UpdateTagOptionResponse' :: UpdateTagOptionResponse -> Maybe TagOptionDetail
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe TagOptionDetail
tagOptionDetail
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus