{-# 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.AssociateTagOptionWithResource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associate the specified TagOption with the specified portfolio or
-- product.
module Amazonka.ServiceCatalog.AssociateTagOptionWithResource
  ( -- * Creating a Request
    AssociateTagOptionWithResource (..),
    newAssociateTagOptionWithResource,

    -- * Request Lenses
    associateTagOptionWithResource_resourceId,
    associateTagOptionWithResource_tagOptionId,

    -- * Destructuring the Response
    AssociateTagOptionWithResourceResponse (..),
    newAssociateTagOptionWithResourceResponse,

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

-- |
-- Create a value of 'AssociateTagOptionWithResource' 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:
--
-- 'resourceId', 'associateTagOptionWithResource_resourceId' - The resource identifier.
--
-- 'tagOptionId', 'associateTagOptionWithResource_tagOptionId' - The TagOption identifier.
newAssociateTagOptionWithResource ::
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'tagOptionId'
  Prelude.Text ->
  AssociateTagOptionWithResource
newAssociateTagOptionWithResource :: Text -> Text -> AssociateTagOptionWithResource
newAssociateTagOptionWithResource
  Text
pResourceId_
  Text
pTagOptionId_ =
    AssociateTagOptionWithResource'
      { $sel:resourceId:AssociateTagOptionWithResource' :: Text
resourceId =
          Text
pResourceId_,
        $sel:tagOptionId:AssociateTagOptionWithResource' :: Text
tagOptionId = Text
pTagOptionId_
      }

-- | The resource identifier.
associateTagOptionWithResource_resourceId :: Lens.Lens' AssociateTagOptionWithResource Prelude.Text
associateTagOptionWithResource_resourceId :: Lens' AssociateTagOptionWithResource Text
associateTagOptionWithResource_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateTagOptionWithResource' {Text
resourceId :: Text
$sel:resourceId:AssociateTagOptionWithResource' :: AssociateTagOptionWithResource -> Text
resourceId} -> Text
resourceId) (\s :: AssociateTagOptionWithResource
s@AssociateTagOptionWithResource' {} Text
a -> AssociateTagOptionWithResource
s {$sel:resourceId:AssociateTagOptionWithResource' :: Text
resourceId = Text
a} :: AssociateTagOptionWithResource)

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

instance
  Core.AWSRequest
    AssociateTagOptionWithResource
  where
  type
    AWSResponse AssociateTagOptionWithResource =
      AssociateTagOptionWithResourceResponse
  request :: (Service -> Service)
-> AssociateTagOptionWithResource
-> Request AssociateTagOptionWithResource
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 AssociateTagOptionWithResource
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociateTagOptionWithResource)))
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 -> AssociateTagOptionWithResourceResponse
AssociateTagOptionWithResourceResponse'
            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
    AssociateTagOptionWithResource
  where
  hashWithSalt :: Int -> AssociateTagOptionWithResource -> Int
hashWithSalt
    Int
_salt
    AssociateTagOptionWithResource' {Text
tagOptionId :: Text
resourceId :: Text
$sel:tagOptionId:AssociateTagOptionWithResource' :: AssociateTagOptionWithResource -> Text
$sel:resourceId:AssociateTagOptionWithResource' :: AssociateTagOptionWithResource -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tagOptionId

instance
  Prelude.NFData
    AssociateTagOptionWithResource
  where
  rnf :: AssociateTagOptionWithResource -> ()
rnf AssociateTagOptionWithResource' {Text
tagOptionId :: Text
resourceId :: Text
$sel:tagOptionId:AssociateTagOptionWithResource' :: AssociateTagOptionWithResource -> Text
$sel:resourceId:AssociateTagOptionWithResource' :: AssociateTagOptionWithResource -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tagOptionId

instance
  Data.ToHeaders
    AssociateTagOptionWithResource
  where
  toHeaders :: AssociateTagOptionWithResource -> 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.AssociateTagOptionWithResource" ::
                          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 AssociateTagOptionWithResource where
  toJSON :: AssociateTagOptionWithResource -> Value
toJSON AssociateTagOptionWithResource' {Text
tagOptionId :: Text
resourceId :: Text
$sel:tagOptionId:AssociateTagOptionWithResource' :: AssociateTagOptionWithResource -> Text
$sel:resourceId:AssociateTagOptionWithResource' :: AssociateTagOptionWithResource -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"ResourceId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceId),
            forall a. a -> Maybe a
Prelude.Just (Key
"TagOptionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tagOptionId)
          ]
      )

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

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

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

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

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

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