{-# 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.CostExplorer.UpdateCostCategoryDefinition
-- 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)
--
-- Updates an existing Cost Category. Changes made to the Cost Category
-- rules will be used to categorize the current month’s expenses and future
-- expenses. This won’t change categorization for the previous months.
module Amazonka.CostExplorer.UpdateCostCategoryDefinition
  ( -- * Creating a Request
    UpdateCostCategoryDefinition (..),
    newUpdateCostCategoryDefinition,

    -- * Request Lenses
    updateCostCategoryDefinition_splitChargeRules,
    updateCostCategoryDefinition_defaultValue,
    updateCostCategoryDefinition_costCategoryArn,
    updateCostCategoryDefinition_ruleVersion,
    updateCostCategoryDefinition_rules,

    -- * Destructuring the Response
    UpdateCostCategoryDefinitionResponse (..),
    newUpdateCostCategoryDefinitionResponse,

    -- * Response Lenses
    updateCostCategoryDefinitionResponse_effectiveStart,
    updateCostCategoryDefinitionResponse_costCategoryArn,
    updateCostCategoryDefinitionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateCostCategoryDefinition' smart constructor.
data UpdateCostCategoryDefinition = UpdateCostCategoryDefinition'
  { -- | The split charge rules used to allocate your charges between your Cost
    -- Category values.
    UpdateCostCategoryDefinition
-> Maybe (NonEmpty CostCategorySplitChargeRule)
splitChargeRules :: Prelude.Maybe (Prelude.NonEmpty CostCategorySplitChargeRule),
    UpdateCostCategoryDefinition -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for your Cost Category.
    UpdateCostCategoryDefinition -> Text
costCategoryArn :: Prelude.Text,
    UpdateCostCategoryDefinition -> CostCategoryRuleVersion
ruleVersion :: CostCategoryRuleVersion,
    -- | The @Expression@ object used to categorize costs. For more information,
    -- see
    -- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategoryRule.html CostCategoryRule>
    -- .
    UpdateCostCategoryDefinition -> NonEmpty CostCategoryRule
rules :: Prelude.NonEmpty CostCategoryRule
  }
  deriving (UpdateCostCategoryDefinition
-> UpdateCostCategoryDefinition -> Bool
(UpdateCostCategoryDefinition
 -> UpdateCostCategoryDefinition -> Bool)
-> (UpdateCostCategoryDefinition
    -> UpdateCostCategoryDefinition -> Bool)
-> Eq UpdateCostCategoryDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateCostCategoryDefinition
-> UpdateCostCategoryDefinition -> Bool
$c/= :: UpdateCostCategoryDefinition
-> UpdateCostCategoryDefinition -> Bool
== :: UpdateCostCategoryDefinition
-> UpdateCostCategoryDefinition -> Bool
$c== :: UpdateCostCategoryDefinition
-> UpdateCostCategoryDefinition -> Bool
Prelude.Eq, ReadPrec [UpdateCostCategoryDefinition]
ReadPrec UpdateCostCategoryDefinition
Int -> ReadS UpdateCostCategoryDefinition
ReadS [UpdateCostCategoryDefinition]
(Int -> ReadS UpdateCostCategoryDefinition)
-> ReadS [UpdateCostCategoryDefinition]
-> ReadPrec UpdateCostCategoryDefinition
-> ReadPrec [UpdateCostCategoryDefinition]
-> Read UpdateCostCategoryDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateCostCategoryDefinition]
$creadListPrec :: ReadPrec [UpdateCostCategoryDefinition]
readPrec :: ReadPrec UpdateCostCategoryDefinition
$creadPrec :: ReadPrec UpdateCostCategoryDefinition
readList :: ReadS [UpdateCostCategoryDefinition]
$creadList :: ReadS [UpdateCostCategoryDefinition]
readsPrec :: Int -> ReadS UpdateCostCategoryDefinition
$creadsPrec :: Int -> ReadS UpdateCostCategoryDefinition
Prelude.Read, Int -> UpdateCostCategoryDefinition -> ShowS
[UpdateCostCategoryDefinition] -> ShowS
UpdateCostCategoryDefinition -> String
(Int -> UpdateCostCategoryDefinition -> ShowS)
-> (UpdateCostCategoryDefinition -> String)
-> ([UpdateCostCategoryDefinition] -> ShowS)
-> Show UpdateCostCategoryDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateCostCategoryDefinition] -> ShowS
$cshowList :: [UpdateCostCategoryDefinition] -> ShowS
show :: UpdateCostCategoryDefinition -> String
$cshow :: UpdateCostCategoryDefinition -> String
showsPrec :: Int -> UpdateCostCategoryDefinition -> ShowS
$cshowsPrec :: Int -> UpdateCostCategoryDefinition -> ShowS
Prelude.Show, (forall x.
 UpdateCostCategoryDefinition -> Rep UpdateCostCategoryDefinition x)
-> (forall x.
    Rep UpdateCostCategoryDefinition x -> UpdateCostCategoryDefinition)
-> Generic UpdateCostCategoryDefinition
forall x.
Rep UpdateCostCategoryDefinition x -> UpdateCostCategoryDefinition
forall x.
UpdateCostCategoryDefinition -> Rep UpdateCostCategoryDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateCostCategoryDefinition x -> UpdateCostCategoryDefinition
$cfrom :: forall x.
UpdateCostCategoryDefinition -> Rep UpdateCostCategoryDefinition x
Prelude.Generic)

-- |
-- Create a value of 'UpdateCostCategoryDefinition' 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:
--
-- 'splitChargeRules', 'updateCostCategoryDefinition_splitChargeRules' - The split charge rules used to allocate your charges between your Cost
-- Category values.
--
-- 'defaultValue', 'updateCostCategoryDefinition_defaultValue' - Undocumented member.
--
-- 'costCategoryArn', 'updateCostCategoryDefinition_costCategoryArn' - The unique identifier for your Cost Category.
--
-- 'ruleVersion', 'updateCostCategoryDefinition_ruleVersion' - Undocumented member.
--
-- 'rules', 'updateCostCategoryDefinition_rules' - The @Expression@ object used to categorize costs. For more information,
-- see
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategoryRule.html CostCategoryRule>
-- .
newUpdateCostCategoryDefinition ::
  -- | 'costCategoryArn'
  Prelude.Text ->
  -- | 'ruleVersion'
  CostCategoryRuleVersion ->
  -- | 'rules'
  Prelude.NonEmpty CostCategoryRule ->
  UpdateCostCategoryDefinition
newUpdateCostCategoryDefinition :: Text
-> CostCategoryRuleVersion
-> NonEmpty CostCategoryRule
-> UpdateCostCategoryDefinition
newUpdateCostCategoryDefinition
  Text
pCostCategoryArn_
  CostCategoryRuleVersion
pRuleVersion_
  NonEmpty CostCategoryRule
pRules_ =
    UpdateCostCategoryDefinition' :: Maybe (NonEmpty CostCategorySplitChargeRule)
-> Maybe Text
-> Text
-> CostCategoryRuleVersion
-> NonEmpty CostCategoryRule
-> UpdateCostCategoryDefinition
UpdateCostCategoryDefinition'
      { $sel:splitChargeRules:UpdateCostCategoryDefinition' :: Maybe (NonEmpty CostCategorySplitChargeRule)
splitChargeRules =
          Maybe (NonEmpty CostCategorySplitChargeRule)
forall a. Maybe a
Prelude.Nothing,
        $sel:defaultValue:UpdateCostCategoryDefinition' :: Maybe Text
defaultValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:costCategoryArn:UpdateCostCategoryDefinition' :: Text
costCategoryArn = Text
pCostCategoryArn_,
        $sel:ruleVersion:UpdateCostCategoryDefinition' :: CostCategoryRuleVersion
ruleVersion = CostCategoryRuleVersion
pRuleVersion_,
        $sel:rules:UpdateCostCategoryDefinition' :: NonEmpty CostCategoryRule
rules = Tagged
  (NonEmpty CostCategoryRule) (Identity (NonEmpty CostCategoryRule))
-> Tagged
     (NonEmpty CostCategoryRule) (Identity (NonEmpty CostCategoryRule))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty CostCategoryRule) (Identity (NonEmpty CostCategoryRule))
 -> Tagged
      (NonEmpty CostCategoryRule) (Identity (NonEmpty CostCategoryRule)))
-> NonEmpty CostCategoryRule -> NonEmpty CostCategoryRule
forall t b. AReview t b -> b -> t
Lens.# NonEmpty CostCategoryRule
pRules_
      }

-- | The split charge rules used to allocate your charges between your Cost
-- Category values.
updateCostCategoryDefinition_splitChargeRules :: Lens.Lens' UpdateCostCategoryDefinition (Prelude.Maybe (Prelude.NonEmpty CostCategorySplitChargeRule))
updateCostCategoryDefinition_splitChargeRules :: (Maybe (NonEmpty CostCategorySplitChargeRule)
 -> f (Maybe (NonEmpty CostCategorySplitChargeRule)))
-> UpdateCostCategoryDefinition -> f UpdateCostCategoryDefinition
updateCostCategoryDefinition_splitChargeRules = (UpdateCostCategoryDefinition
 -> Maybe (NonEmpty CostCategorySplitChargeRule))
-> (UpdateCostCategoryDefinition
    -> Maybe (NonEmpty CostCategorySplitChargeRule)
    -> UpdateCostCategoryDefinition)
-> Lens
     UpdateCostCategoryDefinition
     UpdateCostCategoryDefinition
     (Maybe (NonEmpty CostCategorySplitChargeRule))
     (Maybe (NonEmpty CostCategorySplitChargeRule))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCostCategoryDefinition' {Maybe (NonEmpty CostCategorySplitChargeRule)
splitChargeRules :: Maybe (NonEmpty CostCategorySplitChargeRule)
$sel:splitChargeRules:UpdateCostCategoryDefinition' :: UpdateCostCategoryDefinition
-> Maybe (NonEmpty CostCategorySplitChargeRule)
splitChargeRules} -> Maybe (NonEmpty CostCategorySplitChargeRule)
splitChargeRules) (\s :: UpdateCostCategoryDefinition
s@UpdateCostCategoryDefinition' {} Maybe (NonEmpty CostCategorySplitChargeRule)
a -> UpdateCostCategoryDefinition
s {$sel:splitChargeRules:UpdateCostCategoryDefinition' :: Maybe (NonEmpty CostCategorySplitChargeRule)
splitChargeRules = Maybe (NonEmpty CostCategorySplitChargeRule)
a} :: UpdateCostCategoryDefinition) ((Maybe (NonEmpty CostCategorySplitChargeRule)
  -> f (Maybe (NonEmpty CostCategorySplitChargeRule)))
 -> UpdateCostCategoryDefinition -> f UpdateCostCategoryDefinition)
-> ((Maybe (NonEmpty CostCategorySplitChargeRule)
     -> f (Maybe (NonEmpty CostCategorySplitChargeRule)))
    -> Maybe (NonEmpty CostCategorySplitChargeRule)
    -> f (Maybe (NonEmpty CostCategorySplitChargeRule)))
-> (Maybe (NonEmpty CostCategorySplitChargeRule)
    -> f (Maybe (NonEmpty CostCategorySplitChargeRule)))
-> UpdateCostCategoryDefinition
-> f UpdateCostCategoryDefinition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty CostCategorySplitChargeRule)
  (NonEmpty CostCategorySplitChargeRule)
  (NonEmpty CostCategorySplitChargeRule)
  (NonEmpty CostCategorySplitChargeRule)
-> Iso
     (Maybe (NonEmpty CostCategorySplitChargeRule))
     (Maybe (NonEmpty CostCategorySplitChargeRule))
     (Maybe (NonEmpty CostCategorySplitChargeRule))
     (Maybe (NonEmpty CostCategorySplitChargeRule))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty CostCategorySplitChargeRule)
  (NonEmpty CostCategorySplitChargeRule)
  (NonEmpty CostCategorySplitChargeRule)
  (NonEmpty CostCategorySplitChargeRule)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
updateCostCategoryDefinition_defaultValue :: Lens.Lens' UpdateCostCategoryDefinition (Prelude.Maybe Prelude.Text)
updateCostCategoryDefinition_defaultValue :: (Maybe Text -> f (Maybe Text))
-> UpdateCostCategoryDefinition -> f UpdateCostCategoryDefinition
updateCostCategoryDefinition_defaultValue = (UpdateCostCategoryDefinition -> Maybe Text)
-> (UpdateCostCategoryDefinition
    -> Maybe Text -> UpdateCostCategoryDefinition)
-> Lens
     UpdateCostCategoryDefinition
     UpdateCostCategoryDefinition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCostCategoryDefinition' {Maybe Text
defaultValue :: Maybe Text
$sel:defaultValue:UpdateCostCategoryDefinition' :: UpdateCostCategoryDefinition -> Maybe Text
defaultValue} -> Maybe Text
defaultValue) (\s :: UpdateCostCategoryDefinition
s@UpdateCostCategoryDefinition' {} Maybe Text
a -> UpdateCostCategoryDefinition
s {$sel:defaultValue:UpdateCostCategoryDefinition' :: Maybe Text
defaultValue = Maybe Text
a} :: UpdateCostCategoryDefinition)

-- | The unique identifier for your Cost Category.
updateCostCategoryDefinition_costCategoryArn :: Lens.Lens' UpdateCostCategoryDefinition Prelude.Text
updateCostCategoryDefinition_costCategoryArn :: (Text -> f Text)
-> UpdateCostCategoryDefinition -> f UpdateCostCategoryDefinition
updateCostCategoryDefinition_costCategoryArn = (UpdateCostCategoryDefinition -> Text)
-> (UpdateCostCategoryDefinition
    -> Text -> UpdateCostCategoryDefinition)
-> Lens
     UpdateCostCategoryDefinition UpdateCostCategoryDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCostCategoryDefinition' {Text
costCategoryArn :: Text
$sel:costCategoryArn:UpdateCostCategoryDefinition' :: UpdateCostCategoryDefinition -> Text
costCategoryArn} -> Text
costCategoryArn) (\s :: UpdateCostCategoryDefinition
s@UpdateCostCategoryDefinition' {} Text
a -> UpdateCostCategoryDefinition
s {$sel:costCategoryArn:UpdateCostCategoryDefinition' :: Text
costCategoryArn = Text
a} :: UpdateCostCategoryDefinition)

-- | Undocumented member.
updateCostCategoryDefinition_ruleVersion :: Lens.Lens' UpdateCostCategoryDefinition CostCategoryRuleVersion
updateCostCategoryDefinition_ruleVersion :: (CostCategoryRuleVersion -> f CostCategoryRuleVersion)
-> UpdateCostCategoryDefinition -> f UpdateCostCategoryDefinition
updateCostCategoryDefinition_ruleVersion = (UpdateCostCategoryDefinition -> CostCategoryRuleVersion)
-> (UpdateCostCategoryDefinition
    -> CostCategoryRuleVersion -> UpdateCostCategoryDefinition)
-> Lens
     UpdateCostCategoryDefinition
     UpdateCostCategoryDefinition
     CostCategoryRuleVersion
     CostCategoryRuleVersion
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCostCategoryDefinition' {CostCategoryRuleVersion
ruleVersion :: CostCategoryRuleVersion
$sel:ruleVersion:UpdateCostCategoryDefinition' :: UpdateCostCategoryDefinition -> CostCategoryRuleVersion
ruleVersion} -> CostCategoryRuleVersion
ruleVersion) (\s :: UpdateCostCategoryDefinition
s@UpdateCostCategoryDefinition' {} CostCategoryRuleVersion
a -> UpdateCostCategoryDefinition
s {$sel:ruleVersion:UpdateCostCategoryDefinition' :: CostCategoryRuleVersion
ruleVersion = CostCategoryRuleVersion
a} :: UpdateCostCategoryDefinition)

-- | The @Expression@ object used to categorize costs. For more information,
-- see
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategoryRule.html CostCategoryRule>
-- .
updateCostCategoryDefinition_rules :: Lens.Lens' UpdateCostCategoryDefinition (Prelude.NonEmpty CostCategoryRule)
updateCostCategoryDefinition_rules :: (NonEmpty CostCategoryRule -> f (NonEmpty CostCategoryRule))
-> UpdateCostCategoryDefinition -> f UpdateCostCategoryDefinition
updateCostCategoryDefinition_rules = (UpdateCostCategoryDefinition -> NonEmpty CostCategoryRule)
-> (UpdateCostCategoryDefinition
    -> NonEmpty CostCategoryRule -> UpdateCostCategoryDefinition)
-> Lens
     UpdateCostCategoryDefinition
     UpdateCostCategoryDefinition
     (NonEmpty CostCategoryRule)
     (NonEmpty CostCategoryRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCostCategoryDefinition' {NonEmpty CostCategoryRule
rules :: NonEmpty CostCategoryRule
$sel:rules:UpdateCostCategoryDefinition' :: UpdateCostCategoryDefinition -> NonEmpty CostCategoryRule
rules} -> NonEmpty CostCategoryRule
rules) (\s :: UpdateCostCategoryDefinition
s@UpdateCostCategoryDefinition' {} NonEmpty CostCategoryRule
a -> UpdateCostCategoryDefinition
s {$sel:rules:UpdateCostCategoryDefinition' :: NonEmpty CostCategoryRule
rules = NonEmpty CostCategoryRule
a} :: UpdateCostCategoryDefinition) ((NonEmpty CostCategoryRule -> f (NonEmpty CostCategoryRule))
 -> UpdateCostCategoryDefinition -> f UpdateCostCategoryDefinition)
-> ((NonEmpty CostCategoryRule -> f (NonEmpty CostCategoryRule))
    -> NonEmpty CostCategoryRule -> f (NonEmpty CostCategoryRule))
-> (NonEmpty CostCategoryRule -> f (NonEmpty CostCategoryRule))
-> UpdateCostCategoryDefinition
-> f UpdateCostCategoryDefinition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty CostCategoryRule -> f (NonEmpty CostCategoryRule))
-> NonEmpty CostCategoryRule -> f (NonEmpty CostCategoryRule)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest UpdateCostCategoryDefinition where
  type
    AWSResponse UpdateCostCategoryDefinition =
      UpdateCostCategoryDefinitionResponse
  request :: UpdateCostCategoryDefinition
-> Request UpdateCostCategoryDefinition
request = Service
-> UpdateCostCategoryDefinition
-> Request UpdateCostCategoryDefinition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateCostCategoryDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateCostCategoryDefinition)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateCostCategoryDefinition))
-> Logger
-> Service
-> Proxy UpdateCostCategoryDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateCostCategoryDefinition)))
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 Text
-> Maybe Text -> Int -> UpdateCostCategoryDefinitionResponse
UpdateCostCategoryDefinitionResponse'
            (Maybe Text
 -> Maybe Text -> Int -> UpdateCostCategoryDefinitionResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> UpdateCostCategoryDefinitionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"EffectiveStart")
            Either
  String (Maybe Text -> Int -> UpdateCostCategoryDefinitionResponse)
-> Either String (Maybe Text)
-> Either String (Int -> UpdateCostCategoryDefinitionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"CostCategoryArn")
            Either String (Int -> UpdateCostCategoryDefinitionResponse)
-> Either String Int
-> Either String UpdateCostCategoryDefinitionResponse
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
    UpdateCostCategoryDefinition

instance Prelude.NFData UpdateCostCategoryDefinition

instance Core.ToHeaders UpdateCostCategoryDefinition where
  toHeaders :: UpdateCostCategoryDefinition -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateCostCategoryDefinition -> 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
"AWSInsightsIndexService.UpdateCostCategoryDefinition" ::
                          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 UpdateCostCategoryDefinition where
  toJSON :: UpdateCostCategoryDefinition -> Value
toJSON UpdateCostCategoryDefinition' {Maybe (NonEmpty CostCategorySplitChargeRule)
Maybe Text
NonEmpty CostCategoryRule
Text
CostCategoryRuleVersion
rules :: NonEmpty CostCategoryRule
ruleVersion :: CostCategoryRuleVersion
costCategoryArn :: Text
defaultValue :: Maybe Text
splitChargeRules :: Maybe (NonEmpty CostCategorySplitChargeRule)
$sel:rules:UpdateCostCategoryDefinition' :: UpdateCostCategoryDefinition -> NonEmpty CostCategoryRule
$sel:ruleVersion:UpdateCostCategoryDefinition' :: UpdateCostCategoryDefinition -> CostCategoryRuleVersion
$sel:costCategoryArn:UpdateCostCategoryDefinition' :: UpdateCostCategoryDefinition -> Text
$sel:defaultValue:UpdateCostCategoryDefinition' :: UpdateCostCategoryDefinition -> Maybe Text
$sel:splitChargeRules:UpdateCostCategoryDefinition' :: UpdateCostCategoryDefinition
-> Maybe (NonEmpty CostCategorySplitChargeRule)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SplitChargeRules" Text -> NonEmpty CostCategorySplitChargeRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty CostCategorySplitChargeRule -> Pair)
-> Maybe (NonEmpty CostCategorySplitChargeRule) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty CostCategorySplitChargeRule)
splitChargeRules,
            (Text
"DefaultValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
defaultValue,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CostCategoryArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
costCategoryArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RuleVersion" Text -> CostCategoryRuleVersion -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CostCategoryRuleVersion
ruleVersion),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Rules" Text -> NonEmpty CostCategoryRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty CostCategoryRule
rules)
          ]
      )

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

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

-- | /See:/ 'newUpdateCostCategoryDefinitionResponse' smart constructor.
data UpdateCostCategoryDefinitionResponse = UpdateCostCategoryDefinitionResponse'
  { -- | The Cost Category\'s effective start date.
    UpdateCostCategoryDefinitionResponse -> Maybe Text
effectiveStart :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for your Cost Category.
    UpdateCostCategoryDefinitionResponse -> Maybe Text
costCategoryArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    UpdateCostCategoryDefinitionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateCostCategoryDefinitionResponse
-> UpdateCostCategoryDefinitionResponse -> Bool
(UpdateCostCategoryDefinitionResponse
 -> UpdateCostCategoryDefinitionResponse -> Bool)
-> (UpdateCostCategoryDefinitionResponse
    -> UpdateCostCategoryDefinitionResponse -> Bool)
-> Eq UpdateCostCategoryDefinitionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateCostCategoryDefinitionResponse
-> UpdateCostCategoryDefinitionResponse -> Bool
$c/= :: UpdateCostCategoryDefinitionResponse
-> UpdateCostCategoryDefinitionResponse -> Bool
== :: UpdateCostCategoryDefinitionResponse
-> UpdateCostCategoryDefinitionResponse -> Bool
$c== :: UpdateCostCategoryDefinitionResponse
-> UpdateCostCategoryDefinitionResponse -> Bool
Prelude.Eq, ReadPrec [UpdateCostCategoryDefinitionResponse]
ReadPrec UpdateCostCategoryDefinitionResponse
Int -> ReadS UpdateCostCategoryDefinitionResponse
ReadS [UpdateCostCategoryDefinitionResponse]
(Int -> ReadS UpdateCostCategoryDefinitionResponse)
-> ReadS [UpdateCostCategoryDefinitionResponse]
-> ReadPrec UpdateCostCategoryDefinitionResponse
-> ReadPrec [UpdateCostCategoryDefinitionResponse]
-> Read UpdateCostCategoryDefinitionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateCostCategoryDefinitionResponse]
$creadListPrec :: ReadPrec [UpdateCostCategoryDefinitionResponse]
readPrec :: ReadPrec UpdateCostCategoryDefinitionResponse
$creadPrec :: ReadPrec UpdateCostCategoryDefinitionResponse
readList :: ReadS [UpdateCostCategoryDefinitionResponse]
$creadList :: ReadS [UpdateCostCategoryDefinitionResponse]
readsPrec :: Int -> ReadS UpdateCostCategoryDefinitionResponse
$creadsPrec :: Int -> ReadS UpdateCostCategoryDefinitionResponse
Prelude.Read, Int -> UpdateCostCategoryDefinitionResponse -> ShowS
[UpdateCostCategoryDefinitionResponse] -> ShowS
UpdateCostCategoryDefinitionResponse -> String
(Int -> UpdateCostCategoryDefinitionResponse -> ShowS)
-> (UpdateCostCategoryDefinitionResponse -> String)
-> ([UpdateCostCategoryDefinitionResponse] -> ShowS)
-> Show UpdateCostCategoryDefinitionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateCostCategoryDefinitionResponse] -> ShowS
$cshowList :: [UpdateCostCategoryDefinitionResponse] -> ShowS
show :: UpdateCostCategoryDefinitionResponse -> String
$cshow :: UpdateCostCategoryDefinitionResponse -> String
showsPrec :: Int -> UpdateCostCategoryDefinitionResponse -> ShowS
$cshowsPrec :: Int -> UpdateCostCategoryDefinitionResponse -> ShowS
Prelude.Show, (forall x.
 UpdateCostCategoryDefinitionResponse
 -> Rep UpdateCostCategoryDefinitionResponse x)
-> (forall x.
    Rep UpdateCostCategoryDefinitionResponse x
    -> UpdateCostCategoryDefinitionResponse)
-> Generic UpdateCostCategoryDefinitionResponse
forall x.
Rep UpdateCostCategoryDefinitionResponse x
-> UpdateCostCategoryDefinitionResponse
forall x.
UpdateCostCategoryDefinitionResponse
-> Rep UpdateCostCategoryDefinitionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateCostCategoryDefinitionResponse x
-> UpdateCostCategoryDefinitionResponse
$cfrom :: forall x.
UpdateCostCategoryDefinitionResponse
-> Rep UpdateCostCategoryDefinitionResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateCostCategoryDefinitionResponse' 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:
--
-- 'effectiveStart', 'updateCostCategoryDefinitionResponse_effectiveStart' - The Cost Category\'s effective start date.
--
-- 'costCategoryArn', 'updateCostCategoryDefinitionResponse_costCategoryArn' - The unique identifier for your Cost Category.
--
-- 'httpStatus', 'updateCostCategoryDefinitionResponse_httpStatus' - The response's http status code.
newUpdateCostCategoryDefinitionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateCostCategoryDefinitionResponse
newUpdateCostCategoryDefinitionResponse :: Int -> UpdateCostCategoryDefinitionResponse
newUpdateCostCategoryDefinitionResponse Int
pHttpStatus_ =
  UpdateCostCategoryDefinitionResponse' :: Maybe Text
-> Maybe Text -> Int -> UpdateCostCategoryDefinitionResponse
UpdateCostCategoryDefinitionResponse'
    { $sel:effectiveStart:UpdateCostCategoryDefinitionResponse' :: Maybe Text
effectiveStart =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:costCategoryArn:UpdateCostCategoryDefinitionResponse' :: Maybe Text
costCategoryArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateCostCategoryDefinitionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Cost Category\'s effective start date.
updateCostCategoryDefinitionResponse_effectiveStart :: Lens.Lens' UpdateCostCategoryDefinitionResponse (Prelude.Maybe Prelude.Text)
updateCostCategoryDefinitionResponse_effectiveStart :: (Maybe Text -> f (Maybe Text))
-> UpdateCostCategoryDefinitionResponse
-> f UpdateCostCategoryDefinitionResponse
updateCostCategoryDefinitionResponse_effectiveStart = (UpdateCostCategoryDefinitionResponse -> Maybe Text)
-> (UpdateCostCategoryDefinitionResponse
    -> Maybe Text -> UpdateCostCategoryDefinitionResponse)
-> Lens
     UpdateCostCategoryDefinitionResponse
     UpdateCostCategoryDefinitionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCostCategoryDefinitionResponse' {Maybe Text
effectiveStart :: Maybe Text
$sel:effectiveStart:UpdateCostCategoryDefinitionResponse' :: UpdateCostCategoryDefinitionResponse -> Maybe Text
effectiveStart} -> Maybe Text
effectiveStart) (\s :: UpdateCostCategoryDefinitionResponse
s@UpdateCostCategoryDefinitionResponse' {} Maybe Text
a -> UpdateCostCategoryDefinitionResponse
s {$sel:effectiveStart:UpdateCostCategoryDefinitionResponse' :: Maybe Text
effectiveStart = Maybe Text
a} :: UpdateCostCategoryDefinitionResponse)

-- | The unique identifier for your Cost Category.
updateCostCategoryDefinitionResponse_costCategoryArn :: Lens.Lens' UpdateCostCategoryDefinitionResponse (Prelude.Maybe Prelude.Text)
updateCostCategoryDefinitionResponse_costCategoryArn :: (Maybe Text -> f (Maybe Text))
-> UpdateCostCategoryDefinitionResponse
-> f UpdateCostCategoryDefinitionResponse
updateCostCategoryDefinitionResponse_costCategoryArn = (UpdateCostCategoryDefinitionResponse -> Maybe Text)
-> (UpdateCostCategoryDefinitionResponse
    -> Maybe Text -> UpdateCostCategoryDefinitionResponse)
-> Lens
     UpdateCostCategoryDefinitionResponse
     UpdateCostCategoryDefinitionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCostCategoryDefinitionResponse' {Maybe Text
costCategoryArn :: Maybe Text
$sel:costCategoryArn:UpdateCostCategoryDefinitionResponse' :: UpdateCostCategoryDefinitionResponse -> Maybe Text
costCategoryArn} -> Maybe Text
costCategoryArn) (\s :: UpdateCostCategoryDefinitionResponse
s@UpdateCostCategoryDefinitionResponse' {} Maybe Text
a -> UpdateCostCategoryDefinitionResponse
s {$sel:costCategoryArn:UpdateCostCategoryDefinitionResponse' :: Maybe Text
costCategoryArn = Maybe Text
a} :: UpdateCostCategoryDefinitionResponse)

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

instance
  Prelude.NFData
    UpdateCostCategoryDefinitionResponse