{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.BillingConductor.Types.AccountGrouping
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.BillingConductor.Types.AccountGrouping 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

-- | The set of accounts that will be under the billing group. The set of
-- accounts resemble the linked accounts in a consolidated family.
--
-- /See:/ 'newAccountGrouping' smart constructor.
data AccountGrouping = AccountGrouping'
  { -- | The account IDs that make up the billing group. Account IDs must be a
    -- part of the consolidated billing family, and not associated with another
    -- billing group.
    AccountGrouping -> NonEmpty Text
linkedAccountIds :: Prelude.NonEmpty Prelude.Text
  }
  deriving (AccountGrouping -> AccountGrouping -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountGrouping -> AccountGrouping -> Bool
$c/= :: AccountGrouping -> AccountGrouping -> Bool
== :: AccountGrouping -> AccountGrouping -> Bool
$c== :: AccountGrouping -> AccountGrouping -> Bool
Prelude.Eq, ReadPrec [AccountGrouping]
ReadPrec AccountGrouping
Int -> ReadS AccountGrouping
ReadS [AccountGrouping]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccountGrouping]
$creadListPrec :: ReadPrec [AccountGrouping]
readPrec :: ReadPrec AccountGrouping
$creadPrec :: ReadPrec AccountGrouping
readList :: ReadS [AccountGrouping]
$creadList :: ReadS [AccountGrouping]
readsPrec :: Int -> ReadS AccountGrouping
$creadsPrec :: Int -> ReadS AccountGrouping
Prelude.Read, Int -> AccountGrouping -> ShowS
[AccountGrouping] -> ShowS
AccountGrouping -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountGrouping] -> ShowS
$cshowList :: [AccountGrouping] -> ShowS
show :: AccountGrouping -> String
$cshow :: AccountGrouping -> String
showsPrec :: Int -> AccountGrouping -> ShowS
$cshowsPrec :: Int -> AccountGrouping -> ShowS
Prelude.Show, forall x. Rep AccountGrouping x -> AccountGrouping
forall x. AccountGrouping -> Rep AccountGrouping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountGrouping x -> AccountGrouping
$cfrom :: forall x. AccountGrouping -> Rep AccountGrouping x
Prelude.Generic)

-- |
-- Create a value of 'AccountGrouping' 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:
--
-- 'linkedAccountIds', 'accountGrouping_linkedAccountIds' - The account IDs that make up the billing group. Account IDs must be a
-- part of the consolidated billing family, and not associated with another
-- billing group.
newAccountGrouping ::
  -- | 'linkedAccountIds'
  Prelude.NonEmpty Prelude.Text ->
  AccountGrouping
newAccountGrouping :: NonEmpty Text -> AccountGrouping
newAccountGrouping NonEmpty Text
pLinkedAccountIds_ =
  AccountGrouping'
    { $sel:linkedAccountIds:AccountGrouping' :: NonEmpty Text
linkedAccountIds =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pLinkedAccountIds_
    }

-- | The account IDs that make up the billing group. Account IDs must be a
-- part of the consolidated billing family, and not associated with another
-- billing group.
accountGrouping_linkedAccountIds :: Lens.Lens' AccountGrouping (Prelude.NonEmpty Prelude.Text)
accountGrouping_linkedAccountIds :: Lens' AccountGrouping (NonEmpty Text)
accountGrouping_linkedAccountIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountGrouping' {NonEmpty Text
linkedAccountIds :: NonEmpty Text
$sel:linkedAccountIds:AccountGrouping' :: AccountGrouping -> NonEmpty Text
linkedAccountIds} -> NonEmpty Text
linkedAccountIds) (\s :: AccountGrouping
s@AccountGrouping' {} NonEmpty Text
a -> AccountGrouping
s {$sel:linkedAccountIds:AccountGrouping' :: NonEmpty Text
linkedAccountIds = NonEmpty Text
a} :: AccountGrouping) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable AccountGrouping where
  hashWithSalt :: Int -> AccountGrouping -> Int
hashWithSalt Int
_salt AccountGrouping' {NonEmpty Text
linkedAccountIds :: NonEmpty Text
$sel:linkedAccountIds:AccountGrouping' :: AccountGrouping -> NonEmpty Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
linkedAccountIds

instance Prelude.NFData AccountGrouping where
  rnf :: AccountGrouping -> ()
rnf AccountGrouping' {NonEmpty Text
linkedAccountIds :: NonEmpty Text
$sel:linkedAccountIds:AccountGrouping' :: AccountGrouping -> NonEmpty Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
linkedAccountIds

instance Data.ToJSON AccountGrouping where
  toJSON :: AccountGrouping -> Value
toJSON AccountGrouping' {NonEmpty Text
linkedAccountIds :: NonEmpty Text
$sel:linkedAccountIds:AccountGrouping' :: AccountGrouping -> NonEmpty Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"LinkedAccountIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
linkedAccountIds)
          ]
      )