{-# 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.CreateTagOption
-- 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)
--
-- Creates a TagOption.
module Amazonka.ServiceCatalog.CreateTagOption
  ( -- * Creating a Request
    CreateTagOption (..),
    newCreateTagOption,

    -- * Request Lenses
    createTagOption_key,
    createTagOption_value,

    -- * Destructuring the Response
    CreateTagOptionResponse (..),
    newCreateTagOptionResponse,

    -- * Response Lenses
    createTagOptionResponse_tagOptionDetail,
    createTagOptionResponse_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:/ 'newCreateTagOption' smart constructor.
data CreateTagOption = CreateTagOption'
  { -- | The TagOption key.
    CreateTagOption -> Text
key :: Prelude.Text,
    -- | The TagOption value.
    CreateTagOption -> Text
value :: Prelude.Text
  }
  deriving (CreateTagOption -> CreateTagOption -> Bool
(CreateTagOption -> CreateTagOption -> Bool)
-> (CreateTagOption -> CreateTagOption -> Bool)
-> Eq CreateTagOption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTagOption -> CreateTagOption -> Bool
$c/= :: CreateTagOption -> CreateTagOption -> Bool
== :: CreateTagOption -> CreateTagOption -> Bool
$c== :: CreateTagOption -> CreateTagOption -> Bool
Prelude.Eq, ReadPrec [CreateTagOption]
ReadPrec CreateTagOption
Int -> ReadS CreateTagOption
ReadS [CreateTagOption]
(Int -> ReadS CreateTagOption)
-> ReadS [CreateTagOption]
-> ReadPrec CreateTagOption
-> ReadPrec [CreateTagOption]
-> Read CreateTagOption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTagOption]
$creadListPrec :: ReadPrec [CreateTagOption]
readPrec :: ReadPrec CreateTagOption
$creadPrec :: ReadPrec CreateTagOption
readList :: ReadS [CreateTagOption]
$creadList :: ReadS [CreateTagOption]
readsPrec :: Int -> ReadS CreateTagOption
$creadsPrec :: Int -> ReadS CreateTagOption
Prelude.Read, Int -> CreateTagOption -> ShowS
[CreateTagOption] -> ShowS
CreateTagOption -> String
(Int -> CreateTagOption -> ShowS)
-> (CreateTagOption -> String)
-> ([CreateTagOption] -> ShowS)
-> Show CreateTagOption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTagOption] -> ShowS
$cshowList :: [CreateTagOption] -> ShowS
show :: CreateTagOption -> String
$cshow :: CreateTagOption -> String
showsPrec :: Int -> CreateTagOption -> ShowS
$cshowsPrec :: Int -> CreateTagOption -> ShowS
Prelude.Show, (forall x. CreateTagOption -> Rep CreateTagOption x)
-> (forall x. Rep CreateTagOption x -> CreateTagOption)
-> Generic CreateTagOption
forall x. Rep CreateTagOption x -> CreateTagOption
forall x. CreateTagOption -> Rep CreateTagOption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTagOption x -> CreateTagOption
$cfrom :: forall x. CreateTagOption -> Rep CreateTagOption x
Prelude.Generic)

-- |
-- Create a value of 'CreateTagOption' 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:
--
-- 'key', 'createTagOption_key' - The TagOption key.
--
-- 'value', 'createTagOption_value' - The TagOption value.
newCreateTagOption ::
  -- | 'key'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  CreateTagOption
newCreateTagOption :: Text -> Text -> CreateTagOption
newCreateTagOption Text
pKey_ Text
pValue_ =
  CreateTagOption' :: Text -> Text -> CreateTagOption
CreateTagOption' {$sel:key:CreateTagOption' :: Text
key = Text
pKey_, $sel:value:CreateTagOption' :: Text
value = Text
pValue_}

-- | The TagOption key.
createTagOption_key :: Lens.Lens' CreateTagOption Prelude.Text
createTagOption_key :: (Text -> f Text) -> CreateTagOption -> f CreateTagOption
createTagOption_key = (CreateTagOption -> Text)
-> (CreateTagOption -> Text -> CreateTagOption)
-> Lens CreateTagOption CreateTagOption Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTagOption' {Text
key :: Text
$sel:key:CreateTagOption' :: CreateTagOption -> Text
key} -> Text
key) (\s :: CreateTagOption
s@CreateTagOption' {} Text
a -> CreateTagOption
s {$sel:key:CreateTagOption' :: Text
key = Text
a} :: CreateTagOption)

-- | The TagOption value.
createTagOption_value :: Lens.Lens' CreateTagOption Prelude.Text
createTagOption_value :: (Text -> f Text) -> CreateTagOption -> f CreateTagOption
createTagOption_value = (CreateTagOption -> Text)
-> (CreateTagOption -> Text -> CreateTagOption)
-> Lens CreateTagOption CreateTagOption Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTagOption' {Text
value :: Text
$sel:value:CreateTagOption' :: CreateTagOption -> Text
value} -> Text
value) (\s :: CreateTagOption
s@CreateTagOption' {} Text
a -> CreateTagOption
s {$sel:value:CreateTagOption' :: Text
value = Text
a} :: CreateTagOption)

instance Core.AWSRequest CreateTagOption where
  type
    AWSResponse CreateTagOption =
      CreateTagOptionResponse
  request :: CreateTagOption -> Request CreateTagOption
request = Service -> CreateTagOption -> Request CreateTagOption
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateTagOption
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTagOption)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateTagOption))
-> Logger
-> Service
-> Proxy CreateTagOption
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTagOption)))
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 -> CreateTagOptionResponse
CreateTagOptionResponse'
            (Maybe TagOptionDetail -> Int -> CreateTagOptionResponse)
-> Either String (Maybe TagOptionDetail)
-> Either String (Int -> CreateTagOptionResponse)
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 -> CreateTagOptionResponse)
-> Either String Int -> Either String CreateTagOptionResponse
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 CreateTagOption

instance Prelude.NFData CreateTagOption

instance Core.ToHeaders CreateTagOption where
  toHeaders :: CreateTagOption -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateTagOption -> 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.CreateTagOption" ::
                          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 CreateTagOption where
  toJSON :: CreateTagOption -> Value
toJSON CreateTagOption' {Text
value :: Text
key :: Text
$sel:value:CreateTagOption' :: CreateTagOption -> Text
$sel:key:CreateTagOption' :: CreateTagOption -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
value)
          ]
      )

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

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

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

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

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

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

instance Prelude.NFData CreateTagOptionResponse