{-# 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-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)
--
-- 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.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:/ '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
(AssociateTagOptionWithResource
 -> AssociateTagOptionWithResource -> Bool)
-> (AssociateTagOptionWithResource
    -> AssociateTagOptionWithResource -> Bool)
-> Eq AssociateTagOptionWithResource
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]
(Int -> ReadS AssociateTagOptionWithResource)
-> ReadS [AssociateTagOptionWithResource]
-> ReadPrec AssociateTagOptionWithResource
-> ReadPrec [AssociateTagOptionWithResource]
-> Read 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
(Int -> AssociateTagOptionWithResource -> ShowS)
-> (AssociateTagOptionWithResource -> String)
-> ([AssociateTagOptionWithResource] -> ShowS)
-> Show AssociateTagOptionWithResource
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.
 AssociateTagOptionWithResource
 -> Rep AssociateTagOptionWithResource x)
-> (forall x.
    Rep AssociateTagOptionWithResource x
    -> AssociateTagOptionWithResource)
-> Generic AssociateTagOptionWithResource
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' :: Text -> Text -> AssociateTagOptionWithResource
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 :: (Text -> f Text)
-> AssociateTagOptionWithResource
-> f AssociateTagOptionWithResource
associateTagOptionWithResource_resourceId = (AssociateTagOptionWithResource -> Text)
-> (AssociateTagOptionWithResource
    -> Text -> AssociateTagOptionWithResource)
-> Lens
     AssociateTagOptionWithResource
     AssociateTagOptionWithResource
     Text
     Text
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 :: (Text -> f Text)
-> AssociateTagOptionWithResource
-> f AssociateTagOptionWithResource
associateTagOptionWithResource_tagOptionId = (AssociateTagOptionWithResource -> Text)
-> (AssociateTagOptionWithResource
    -> Text -> AssociateTagOptionWithResource)
-> Lens
     AssociateTagOptionWithResource
     AssociateTagOptionWithResource
     Text
     Text
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 :: AssociateTagOptionWithResource
-> Request AssociateTagOptionWithResource
request = Service
-> AssociateTagOptionWithResource
-> Request AssociateTagOptionWithResource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateTagOptionWithResource
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociateTagOptionWithResource)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AssociateTagOptionWithResource))
-> Logger
-> Service
-> Proxy AssociateTagOptionWithResource
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociateTagOptionWithResource)))
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 -> AssociateTagOptionWithResourceResponse
AssociateTagOptionWithResourceResponse'
            (Int -> AssociateTagOptionWithResourceResponse)
-> Either String Int
-> Either String AssociateTagOptionWithResourceResponse
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
    AssociateTagOptionWithResource

instance
  Prelude.NFData
    AssociateTagOptionWithResource

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

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

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

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