{-# 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.AssociateBudgetWithResource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates the specified budget with the specified resource.
module Amazonka.ServiceCatalog.AssociateBudgetWithResource
  ( -- * Creating a Request
    AssociateBudgetWithResource (..),
    newAssociateBudgetWithResource,

    -- * Request Lenses
    associateBudgetWithResource_budgetName,
    associateBudgetWithResource_resourceId,

    -- * Destructuring the Response
    AssociateBudgetWithResourceResponse (..),
    newAssociateBudgetWithResourceResponse,

    -- * Response Lenses
    associateBudgetWithResourceResponse_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:/ 'newAssociateBudgetWithResource' smart constructor.
data AssociateBudgetWithResource = AssociateBudgetWithResource'
  { -- | The name of the budget you want to associate.
    AssociateBudgetWithResource -> Text
budgetName :: Prelude.Text,
    -- | The resource identifier. Either a portfolio-id or a product-id.
    AssociateBudgetWithResource -> Text
resourceId :: Prelude.Text
  }
  deriving (AssociateBudgetWithResource -> AssociateBudgetWithResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateBudgetWithResource -> AssociateBudgetWithResource -> Bool
$c/= :: AssociateBudgetWithResource -> AssociateBudgetWithResource -> Bool
== :: AssociateBudgetWithResource -> AssociateBudgetWithResource -> Bool
$c== :: AssociateBudgetWithResource -> AssociateBudgetWithResource -> Bool
Prelude.Eq, ReadPrec [AssociateBudgetWithResource]
ReadPrec AssociateBudgetWithResource
Int -> ReadS AssociateBudgetWithResource
ReadS [AssociateBudgetWithResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateBudgetWithResource]
$creadListPrec :: ReadPrec [AssociateBudgetWithResource]
readPrec :: ReadPrec AssociateBudgetWithResource
$creadPrec :: ReadPrec AssociateBudgetWithResource
readList :: ReadS [AssociateBudgetWithResource]
$creadList :: ReadS [AssociateBudgetWithResource]
readsPrec :: Int -> ReadS AssociateBudgetWithResource
$creadsPrec :: Int -> ReadS AssociateBudgetWithResource
Prelude.Read, Int -> AssociateBudgetWithResource -> ShowS
[AssociateBudgetWithResource] -> ShowS
AssociateBudgetWithResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateBudgetWithResource] -> ShowS
$cshowList :: [AssociateBudgetWithResource] -> ShowS
show :: AssociateBudgetWithResource -> String
$cshow :: AssociateBudgetWithResource -> String
showsPrec :: Int -> AssociateBudgetWithResource -> ShowS
$cshowsPrec :: Int -> AssociateBudgetWithResource -> ShowS
Prelude.Show, forall x.
Rep AssociateBudgetWithResource x -> AssociateBudgetWithResource
forall x.
AssociateBudgetWithResource -> Rep AssociateBudgetWithResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateBudgetWithResource x -> AssociateBudgetWithResource
$cfrom :: forall x.
AssociateBudgetWithResource -> Rep AssociateBudgetWithResource x
Prelude.Generic)

-- |
-- Create a value of 'AssociateBudgetWithResource' 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:
--
-- 'budgetName', 'associateBudgetWithResource_budgetName' - The name of the budget you want to associate.
--
-- 'resourceId', 'associateBudgetWithResource_resourceId' - The resource identifier. Either a portfolio-id or a product-id.
newAssociateBudgetWithResource ::
  -- | 'budgetName'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  AssociateBudgetWithResource
newAssociateBudgetWithResource :: Text -> Text -> AssociateBudgetWithResource
newAssociateBudgetWithResource
  Text
pBudgetName_
  Text
pResourceId_ =
    AssociateBudgetWithResource'
      { $sel:budgetName:AssociateBudgetWithResource' :: Text
budgetName =
          Text
pBudgetName_,
        $sel:resourceId:AssociateBudgetWithResource' :: Text
resourceId = Text
pResourceId_
      }

-- | The name of the budget you want to associate.
associateBudgetWithResource_budgetName :: Lens.Lens' AssociateBudgetWithResource Prelude.Text
associateBudgetWithResource_budgetName :: Lens' AssociateBudgetWithResource Text
associateBudgetWithResource_budgetName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateBudgetWithResource' {Text
budgetName :: Text
$sel:budgetName:AssociateBudgetWithResource' :: AssociateBudgetWithResource -> Text
budgetName} -> Text
budgetName) (\s :: AssociateBudgetWithResource
s@AssociateBudgetWithResource' {} Text
a -> AssociateBudgetWithResource
s {$sel:budgetName:AssociateBudgetWithResource' :: Text
budgetName = Text
a} :: AssociateBudgetWithResource)

-- | The resource identifier. Either a portfolio-id or a product-id.
associateBudgetWithResource_resourceId :: Lens.Lens' AssociateBudgetWithResource Prelude.Text
associateBudgetWithResource_resourceId :: Lens' AssociateBudgetWithResource Text
associateBudgetWithResource_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateBudgetWithResource' {Text
resourceId :: Text
$sel:resourceId:AssociateBudgetWithResource' :: AssociateBudgetWithResource -> Text
resourceId} -> Text
resourceId) (\s :: AssociateBudgetWithResource
s@AssociateBudgetWithResource' {} Text
a -> AssociateBudgetWithResource
s {$sel:resourceId:AssociateBudgetWithResource' :: Text
resourceId = Text
a} :: AssociateBudgetWithResource)

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

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

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

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

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

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

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

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

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