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

    -- * Request Lenses
    updateTagOption_value,
    updateTagOption_active,
    updateTagOption_id,

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

    -- * Response Lenses
    updateTagOptionResponse_tagOptionDetail,
    updateTagOptionResponse_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.ServiceCatalog.Types

-- | /See:/ 'newUpdateTagOption' smart constructor.
data UpdateTagOption = UpdateTagOption'
  { -- | The updated value.
    UpdateTagOption -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The updated active state.
    UpdateTagOption -> Maybe Bool
active :: Prelude.Maybe Prelude.Bool,
    -- | The TagOption identifier.
    UpdateTagOption -> Text
id :: Prelude.Text
  }
  deriving (UpdateTagOption -> UpdateTagOption -> Bool
(UpdateTagOption -> UpdateTagOption -> Bool)
-> (UpdateTagOption -> UpdateTagOption -> Bool)
-> Eq UpdateTagOption
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]
(Int -> ReadS UpdateTagOption)
-> ReadS [UpdateTagOption]
-> ReadPrec UpdateTagOption
-> ReadPrec [UpdateTagOption]
-> Read 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
(Int -> UpdateTagOption -> ShowS)
-> (UpdateTagOption -> String)
-> ([UpdateTagOption] -> ShowS)
-> Show UpdateTagOption
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. UpdateTagOption -> Rep UpdateTagOption x)
-> (forall x. Rep UpdateTagOption x -> UpdateTagOption)
-> Generic UpdateTagOption
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:
--
-- 'value', 'updateTagOption_value' - The updated value.
--
-- 'active', 'updateTagOption_active' - The updated active state.
--
-- 'id', 'updateTagOption_id' - The TagOption identifier.
newUpdateTagOption ::
  -- | 'id'
  Prelude.Text ->
  UpdateTagOption
newUpdateTagOption :: Text -> UpdateTagOption
newUpdateTagOption Text
pId_ =
  UpdateTagOption' :: Maybe Text -> Maybe Bool -> Text -> UpdateTagOption
UpdateTagOption'
    { $sel:value:UpdateTagOption' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:active:UpdateTagOption' :: Maybe Bool
active = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:id:UpdateTagOption' :: Text
id = Text
pId_
    }

-- | The updated value.
updateTagOption_value :: Lens.Lens' UpdateTagOption (Prelude.Maybe Prelude.Text)
updateTagOption_value :: (Maybe Text -> f (Maybe Text))
-> UpdateTagOption -> f UpdateTagOption
updateTagOption_value = (UpdateTagOption -> Maybe Text)
-> (UpdateTagOption -> Maybe Text -> UpdateTagOption)
-> Lens UpdateTagOption UpdateTagOption (Maybe Text) (Maybe Text)
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 updated active state.
updateTagOption_active :: Lens.Lens' UpdateTagOption (Prelude.Maybe Prelude.Bool)
updateTagOption_active :: (Maybe Bool -> f (Maybe Bool))
-> UpdateTagOption -> f UpdateTagOption
updateTagOption_active = (UpdateTagOption -> Maybe Bool)
-> (UpdateTagOption -> Maybe Bool -> UpdateTagOption)
-> Lens UpdateTagOption UpdateTagOption (Maybe Bool) (Maybe Bool)
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 TagOption identifier.
updateTagOption_id :: Lens.Lens' UpdateTagOption Prelude.Text
updateTagOption_id :: (Text -> f Text) -> UpdateTagOption -> f UpdateTagOption
updateTagOption_id = (UpdateTagOption -> Text)
-> (UpdateTagOption -> Text -> UpdateTagOption)
-> Lens UpdateTagOption UpdateTagOption Text Text
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 :: UpdateTagOption -> Request UpdateTagOption
request = Service -> UpdateTagOption -> Request UpdateTagOption
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateTagOption
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateTagOption)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateTagOption))
-> Logger
-> Service
-> Proxy UpdateTagOption
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateTagOption)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe TagOptionDetail -> Int -> UpdateTagOptionResponse
UpdateTagOptionResponse'
            (Maybe TagOptionDetail -> Int -> UpdateTagOptionResponse)
-> Either String (Maybe TagOptionDetail)
-> Either String (Int -> UpdateTagOptionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe TagOptionDetail)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"TagOptionDetail")
            Either String (Int -> UpdateTagOptionResponse)
-> Either String Int -> Either String UpdateTagOptionResponse
forall (f :: * -> *) a b. Applicative f => 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 UpdateTagOption

instance Prelude.NFData UpdateTagOption

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

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

instance Core.ToQuery UpdateTagOption where
  toQuery :: UpdateTagOption -> QueryString
toQuery = QueryString -> UpdateTagOption -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateTagOptionResponse -> UpdateTagOptionResponse -> Bool)
-> (UpdateTagOptionResponse -> UpdateTagOptionResponse -> Bool)
-> Eq UpdateTagOptionResponse
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]
(Int -> ReadS UpdateTagOptionResponse)
-> ReadS [UpdateTagOptionResponse]
-> ReadPrec UpdateTagOptionResponse
-> ReadPrec [UpdateTagOptionResponse]
-> Read 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
(Int -> UpdateTagOptionResponse -> ShowS)
-> (UpdateTagOptionResponse -> String)
-> ([UpdateTagOptionResponse] -> ShowS)
-> Show UpdateTagOptionResponse
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.
 UpdateTagOptionResponse -> Rep UpdateTagOptionResponse x)
-> (forall x.
    Rep UpdateTagOptionResponse x -> UpdateTagOptionResponse)
-> Generic UpdateTagOptionResponse
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' :: Maybe TagOptionDetail -> Int -> UpdateTagOptionResponse
UpdateTagOptionResponse'
    { $sel:tagOptionDetail:UpdateTagOptionResponse' :: Maybe TagOptionDetail
tagOptionDetail =
        Maybe 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 :: (Maybe TagOptionDetail -> f (Maybe TagOptionDetail))
-> UpdateTagOptionResponse -> f UpdateTagOptionResponse
updateTagOptionResponse_tagOptionDetail = (UpdateTagOptionResponse -> Maybe TagOptionDetail)
-> (UpdateTagOptionResponse
    -> Maybe TagOptionDetail -> UpdateTagOptionResponse)
-> Lens
     UpdateTagOptionResponse
     UpdateTagOptionResponse
     (Maybe TagOptionDetail)
     (Maybe 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 :: (Int -> f Int)
-> UpdateTagOptionResponse -> f UpdateTagOptionResponse
updateTagOptionResponse_httpStatus = (UpdateTagOptionResponse -> Int)
-> (UpdateTagOptionResponse -> Int -> UpdateTagOptionResponse)
-> Lens UpdateTagOptionResponse UpdateTagOptionResponse Int Int
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