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

instance Prelude.NFData AssociateBudgetWithResource

instance Core.ToHeaders AssociateBudgetWithResource where
  toHeaders :: AssociateBudgetWithResource -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AssociateBudgetWithResource -> 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.AssociateBudgetWithResource" ::
                          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 AssociateBudgetWithResource where
  toJSON :: AssociateBudgetWithResource -> Value
toJSON AssociateBudgetWithResource' {Text
resourceId :: Text
budgetName :: Text
$sel:resourceId:AssociateBudgetWithResource' :: AssociateBudgetWithResource -> Text
$sel:budgetName:AssociateBudgetWithResource' :: AssociateBudgetWithResource -> 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
"BudgetName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
budgetName),
            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)
          ]
      )

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

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

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