{-# 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.CreateCostCategoryDefinition
-- 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)
--
-- Creates a new Cost Category with the requested name and rules.
module Amazonka.CostExplorer.CreateCostCategoryDefinition
  ( -- * Creating a Request
    CreateCostCategoryDefinition (..),
    newCreateCostCategoryDefinition,

    -- * Request Lenses
    createCostCategoryDefinition_splitChargeRules,
    createCostCategoryDefinition_defaultValue,
    createCostCategoryDefinition_name,
    createCostCategoryDefinition_ruleVersion,
    createCostCategoryDefinition_rules,

    -- * Destructuring the Response
    CreateCostCategoryDefinitionResponse (..),
    newCreateCostCategoryDefinitionResponse,

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

-- |
-- Create a value of 'CreateCostCategoryDefinition' 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', 'createCostCategoryDefinition_splitChargeRules' - The split charge rules used to allocate your charges between your Cost
-- Category values.
--
-- 'defaultValue', 'createCostCategoryDefinition_defaultValue' - Undocumented member.
--
-- 'name', 'createCostCategoryDefinition_name' - Undocumented member.
--
-- 'ruleVersion', 'createCostCategoryDefinition_ruleVersion' - Undocumented member.
--
-- 'rules', 'createCostCategoryDefinition_rules' - The Cost Category rules used to categorize costs. For more information,
-- see
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategoryRule.html CostCategoryRule>.
newCreateCostCategoryDefinition ::
  -- | 'name'
  Prelude.Text ->
  -- | 'ruleVersion'
  CostCategoryRuleVersion ->
  -- | 'rules'
  Prelude.NonEmpty CostCategoryRule ->
  CreateCostCategoryDefinition
newCreateCostCategoryDefinition :: Text
-> CostCategoryRuleVersion
-> NonEmpty CostCategoryRule
-> CreateCostCategoryDefinition
newCreateCostCategoryDefinition
  Text
pName_
  CostCategoryRuleVersion
pRuleVersion_
  NonEmpty CostCategoryRule
pRules_ =
    CreateCostCategoryDefinition' :: Maybe (NonEmpty CostCategorySplitChargeRule)
-> Maybe Text
-> Text
-> CostCategoryRuleVersion
-> NonEmpty CostCategoryRule
-> CreateCostCategoryDefinition
CreateCostCategoryDefinition'
      { $sel:splitChargeRules:CreateCostCategoryDefinition' :: Maybe (NonEmpty CostCategorySplitChargeRule)
splitChargeRules =
          Maybe (NonEmpty CostCategorySplitChargeRule)
forall a. Maybe a
Prelude.Nothing,
        $sel:defaultValue:CreateCostCategoryDefinition' :: Maybe Text
defaultValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:name:CreateCostCategoryDefinition' :: Text
name = Text
pName_,
        $sel:ruleVersion:CreateCostCategoryDefinition' :: CostCategoryRuleVersion
ruleVersion = CostCategoryRuleVersion
pRuleVersion_,
        $sel:rules:CreateCostCategoryDefinition' :: 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.
createCostCategoryDefinition_splitChargeRules :: Lens.Lens' CreateCostCategoryDefinition (Prelude.Maybe (Prelude.NonEmpty CostCategorySplitChargeRule))
createCostCategoryDefinition_splitChargeRules :: (Maybe (NonEmpty CostCategorySplitChargeRule)
 -> f (Maybe (NonEmpty CostCategorySplitChargeRule)))
-> CreateCostCategoryDefinition -> f CreateCostCategoryDefinition
createCostCategoryDefinition_splitChargeRules = (CreateCostCategoryDefinition
 -> Maybe (NonEmpty CostCategorySplitChargeRule))
-> (CreateCostCategoryDefinition
    -> Maybe (NonEmpty CostCategorySplitChargeRule)
    -> CreateCostCategoryDefinition)
-> Lens
     CreateCostCategoryDefinition
     CreateCostCategoryDefinition
     (Maybe (NonEmpty CostCategorySplitChargeRule))
     (Maybe (NonEmpty CostCategorySplitChargeRule))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCostCategoryDefinition' {Maybe (NonEmpty CostCategorySplitChargeRule)
splitChargeRules :: Maybe (NonEmpty CostCategorySplitChargeRule)
$sel:splitChargeRules:CreateCostCategoryDefinition' :: CreateCostCategoryDefinition
-> Maybe (NonEmpty CostCategorySplitChargeRule)
splitChargeRules} -> Maybe (NonEmpty CostCategorySplitChargeRule)
splitChargeRules) (\s :: CreateCostCategoryDefinition
s@CreateCostCategoryDefinition' {} Maybe (NonEmpty CostCategorySplitChargeRule)
a -> CreateCostCategoryDefinition
s {$sel:splitChargeRules:CreateCostCategoryDefinition' :: Maybe (NonEmpty CostCategorySplitChargeRule)
splitChargeRules = Maybe (NonEmpty CostCategorySplitChargeRule)
a} :: CreateCostCategoryDefinition) ((Maybe (NonEmpty CostCategorySplitChargeRule)
  -> f (Maybe (NonEmpty CostCategorySplitChargeRule)))
 -> CreateCostCategoryDefinition -> f CreateCostCategoryDefinition)
-> ((Maybe (NonEmpty CostCategorySplitChargeRule)
     -> f (Maybe (NonEmpty CostCategorySplitChargeRule)))
    -> Maybe (NonEmpty CostCategorySplitChargeRule)
    -> f (Maybe (NonEmpty CostCategorySplitChargeRule)))
-> (Maybe (NonEmpty CostCategorySplitChargeRule)
    -> f (Maybe (NonEmpty CostCategorySplitChargeRule)))
-> CreateCostCategoryDefinition
-> f CreateCostCategoryDefinition
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.
createCostCategoryDefinition_defaultValue :: Lens.Lens' CreateCostCategoryDefinition (Prelude.Maybe Prelude.Text)
createCostCategoryDefinition_defaultValue :: (Maybe Text -> f (Maybe Text))
-> CreateCostCategoryDefinition -> f CreateCostCategoryDefinition
createCostCategoryDefinition_defaultValue = (CreateCostCategoryDefinition -> Maybe Text)
-> (CreateCostCategoryDefinition
    -> Maybe Text -> CreateCostCategoryDefinition)
-> Lens
     CreateCostCategoryDefinition
     CreateCostCategoryDefinition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCostCategoryDefinition' {Maybe Text
defaultValue :: Maybe Text
$sel:defaultValue:CreateCostCategoryDefinition' :: CreateCostCategoryDefinition -> Maybe Text
defaultValue} -> Maybe Text
defaultValue) (\s :: CreateCostCategoryDefinition
s@CreateCostCategoryDefinition' {} Maybe Text
a -> CreateCostCategoryDefinition
s {$sel:defaultValue:CreateCostCategoryDefinition' :: Maybe Text
defaultValue = Maybe Text
a} :: CreateCostCategoryDefinition)

-- | Undocumented member.
createCostCategoryDefinition_name :: Lens.Lens' CreateCostCategoryDefinition Prelude.Text
createCostCategoryDefinition_name :: (Text -> f Text)
-> CreateCostCategoryDefinition -> f CreateCostCategoryDefinition
createCostCategoryDefinition_name = (CreateCostCategoryDefinition -> Text)
-> (CreateCostCategoryDefinition
    -> Text -> CreateCostCategoryDefinition)
-> Lens
     CreateCostCategoryDefinition CreateCostCategoryDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCostCategoryDefinition' {Text
name :: Text
$sel:name:CreateCostCategoryDefinition' :: CreateCostCategoryDefinition -> Text
name} -> Text
name) (\s :: CreateCostCategoryDefinition
s@CreateCostCategoryDefinition' {} Text
a -> CreateCostCategoryDefinition
s {$sel:name:CreateCostCategoryDefinition' :: Text
name = Text
a} :: CreateCostCategoryDefinition)

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

-- | The Cost Category rules used to categorize costs. For more information,
-- see
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategoryRule.html CostCategoryRule>.
createCostCategoryDefinition_rules :: Lens.Lens' CreateCostCategoryDefinition (Prelude.NonEmpty CostCategoryRule)
createCostCategoryDefinition_rules :: (NonEmpty CostCategoryRule -> f (NonEmpty CostCategoryRule))
-> CreateCostCategoryDefinition -> f CreateCostCategoryDefinition
createCostCategoryDefinition_rules = (CreateCostCategoryDefinition -> NonEmpty CostCategoryRule)
-> (CreateCostCategoryDefinition
    -> NonEmpty CostCategoryRule -> CreateCostCategoryDefinition)
-> Lens
     CreateCostCategoryDefinition
     CreateCostCategoryDefinition
     (NonEmpty CostCategoryRule)
     (NonEmpty CostCategoryRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCostCategoryDefinition' {NonEmpty CostCategoryRule
rules :: NonEmpty CostCategoryRule
$sel:rules:CreateCostCategoryDefinition' :: CreateCostCategoryDefinition -> NonEmpty CostCategoryRule
rules} -> NonEmpty CostCategoryRule
rules) (\s :: CreateCostCategoryDefinition
s@CreateCostCategoryDefinition' {} NonEmpty CostCategoryRule
a -> CreateCostCategoryDefinition
s {$sel:rules:CreateCostCategoryDefinition' :: NonEmpty CostCategoryRule
rules = NonEmpty CostCategoryRule
a} :: CreateCostCategoryDefinition) ((NonEmpty CostCategoryRule -> f (NonEmpty CostCategoryRule))
 -> CreateCostCategoryDefinition -> f CreateCostCategoryDefinition)
-> ((NonEmpty CostCategoryRule -> f (NonEmpty CostCategoryRule))
    -> NonEmpty CostCategoryRule -> f (NonEmpty CostCategoryRule))
-> (NonEmpty CostCategoryRule -> f (NonEmpty CostCategoryRule))
-> CreateCostCategoryDefinition
-> f CreateCostCategoryDefinition
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 CreateCostCategoryDefinition where
  type
    AWSResponse CreateCostCategoryDefinition =
      CreateCostCategoryDefinitionResponse
  request :: CreateCostCategoryDefinition
-> Request CreateCostCategoryDefinition
request = Service
-> CreateCostCategoryDefinition
-> Request CreateCostCategoryDefinition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateCostCategoryDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateCostCategoryDefinition)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateCostCategoryDefinition))
-> Logger
-> Service
-> Proxy CreateCostCategoryDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateCostCategoryDefinition)))
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 -> CreateCostCategoryDefinitionResponse
CreateCostCategoryDefinitionResponse'
            (Maybe Text
 -> Maybe Text -> Int -> CreateCostCategoryDefinitionResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> CreateCostCategoryDefinitionResponse)
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 -> CreateCostCategoryDefinitionResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateCostCategoryDefinitionResponse)
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 -> CreateCostCategoryDefinitionResponse)
-> Either String Int
-> Either String CreateCostCategoryDefinitionResponse
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
    CreateCostCategoryDefinition

instance Prelude.NFData CreateCostCategoryDefinition

instance Core.ToHeaders CreateCostCategoryDefinition where
  toHeaders :: CreateCostCategoryDefinition -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateCostCategoryDefinition -> 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.CreateCostCategoryDefinition" ::
                          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 CreateCostCategoryDefinition where
  toJSON :: CreateCostCategoryDefinition -> Value
toJSON CreateCostCategoryDefinition' {Maybe (NonEmpty CostCategorySplitChargeRule)
Maybe Text
NonEmpty CostCategoryRule
Text
CostCategoryRuleVersion
rules :: NonEmpty CostCategoryRule
ruleVersion :: CostCategoryRuleVersion
name :: Text
defaultValue :: Maybe Text
splitChargeRules :: Maybe (NonEmpty CostCategorySplitChargeRule)
$sel:rules:CreateCostCategoryDefinition' :: CreateCostCategoryDefinition -> NonEmpty CostCategoryRule
$sel:ruleVersion:CreateCostCategoryDefinition' :: CreateCostCategoryDefinition -> CostCategoryRuleVersion
$sel:name:CreateCostCategoryDefinition' :: CreateCostCategoryDefinition -> Text
$sel:defaultValue:CreateCostCategoryDefinition' :: CreateCostCategoryDefinition -> Maybe Text
$sel:splitChargeRules:CreateCostCategoryDefinition' :: CreateCostCategoryDefinition
-> 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
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            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 CreateCostCategoryDefinition where
  toPath :: CreateCostCategoryDefinition -> ByteString
toPath = ByteString -> CreateCostCategoryDefinition -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'CreateCostCategoryDefinitionResponse' 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', 'createCostCategoryDefinitionResponse_effectiveStart' - The Cost Category\'s effective start date.
--
-- 'costCategoryArn', 'createCostCategoryDefinitionResponse_costCategoryArn' - The unique identifier for your newly created Cost Category.
--
-- 'httpStatus', 'createCostCategoryDefinitionResponse_httpStatus' - The response's http status code.
newCreateCostCategoryDefinitionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateCostCategoryDefinitionResponse
newCreateCostCategoryDefinitionResponse :: Int -> CreateCostCategoryDefinitionResponse
newCreateCostCategoryDefinitionResponse Int
pHttpStatus_ =
  CreateCostCategoryDefinitionResponse' :: Maybe Text
-> Maybe Text -> Int -> CreateCostCategoryDefinitionResponse
CreateCostCategoryDefinitionResponse'
    { $sel:effectiveStart:CreateCostCategoryDefinitionResponse' :: Maybe Text
effectiveStart =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:costCategoryArn:CreateCostCategoryDefinitionResponse' :: Maybe Text
costCategoryArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateCostCategoryDefinitionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

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

instance
  Prelude.NFData
    CreateCostCategoryDefinitionResponse