{-# 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.BillingConductor.DisassociateAccounts
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes the specified list of account IDs from the given billing group.
module Amazonka.BillingConductor.DisassociateAccounts
  ( -- * Creating a Request
    DisassociateAccounts (..),
    newDisassociateAccounts,

    -- * Request Lenses
    disassociateAccounts_arn,
    disassociateAccounts_accountIds,

    -- * Destructuring the Response
    DisassociateAccountsResponse (..),
    newDisassociateAccountsResponse,

    -- * Response Lenses
    disassociateAccountsResponse_arn,
    disassociateAccountsResponse_httpStatus,
  )
where

import Amazonka.BillingConductor.Types
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

-- | /See:/ 'newDisassociateAccounts' smart constructor.
data DisassociateAccounts = DisassociateAccounts'
  { -- | The Amazon Resource Name (ARN) of the billing group that the array of
    -- account IDs will disassociate from.
    DisassociateAccounts -> Text
arn :: Prelude.Text,
    -- | The array of account IDs to disassociate.
    DisassociateAccounts -> NonEmpty Text
accountIds :: Prelude.NonEmpty Prelude.Text
  }
  deriving (DisassociateAccounts -> DisassociateAccounts -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateAccounts -> DisassociateAccounts -> Bool
$c/= :: DisassociateAccounts -> DisassociateAccounts -> Bool
== :: DisassociateAccounts -> DisassociateAccounts -> Bool
$c== :: DisassociateAccounts -> DisassociateAccounts -> Bool
Prelude.Eq, ReadPrec [DisassociateAccounts]
ReadPrec DisassociateAccounts
Int -> ReadS DisassociateAccounts
ReadS [DisassociateAccounts]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateAccounts]
$creadListPrec :: ReadPrec [DisassociateAccounts]
readPrec :: ReadPrec DisassociateAccounts
$creadPrec :: ReadPrec DisassociateAccounts
readList :: ReadS [DisassociateAccounts]
$creadList :: ReadS [DisassociateAccounts]
readsPrec :: Int -> ReadS DisassociateAccounts
$creadsPrec :: Int -> ReadS DisassociateAccounts
Prelude.Read, Int -> DisassociateAccounts -> ShowS
[DisassociateAccounts] -> ShowS
DisassociateAccounts -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateAccounts] -> ShowS
$cshowList :: [DisassociateAccounts] -> ShowS
show :: DisassociateAccounts -> String
$cshow :: DisassociateAccounts -> String
showsPrec :: Int -> DisassociateAccounts -> ShowS
$cshowsPrec :: Int -> DisassociateAccounts -> ShowS
Prelude.Show, forall x. Rep DisassociateAccounts x -> DisassociateAccounts
forall x. DisassociateAccounts -> Rep DisassociateAccounts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateAccounts x -> DisassociateAccounts
$cfrom :: forall x. DisassociateAccounts -> Rep DisassociateAccounts x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateAccounts' 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:
--
-- 'arn', 'disassociateAccounts_arn' - The Amazon Resource Name (ARN) of the billing group that the array of
-- account IDs will disassociate from.
--
-- 'accountIds', 'disassociateAccounts_accountIds' - The array of account IDs to disassociate.
newDisassociateAccounts ::
  -- | 'arn'
  Prelude.Text ->
  -- | 'accountIds'
  Prelude.NonEmpty Prelude.Text ->
  DisassociateAccounts
newDisassociateAccounts :: Text -> NonEmpty Text -> DisassociateAccounts
newDisassociateAccounts Text
pArn_ NonEmpty Text
pAccountIds_ =
  DisassociateAccounts'
    { $sel:arn:DisassociateAccounts' :: Text
arn = Text
pArn_,
      $sel:accountIds:DisassociateAccounts' :: NonEmpty Text
accountIds = 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
pAccountIds_
    }

-- | The Amazon Resource Name (ARN) of the billing group that the array of
-- account IDs will disassociate from.
disassociateAccounts_arn :: Lens.Lens' DisassociateAccounts Prelude.Text
disassociateAccounts_arn :: Lens' DisassociateAccounts Text
disassociateAccounts_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateAccounts' {Text
arn :: Text
$sel:arn:DisassociateAccounts' :: DisassociateAccounts -> Text
arn} -> Text
arn) (\s :: DisassociateAccounts
s@DisassociateAccounts' {} Text
a -> DisassociateAccounts
s {$sel:arn:DisassociateAccounts' :: Text
arn = Text
a} :: DisassociateAccounts)

-- | The array of account IDs to disassociate.
disassociateAccounts_accountIds :: Lens.Lens' DisassociateAccounts (Prelude.NonEmpty Prelude.Text)
disassociateAccounts_accountIds :: Lens' DisassociateAccounts (NonEmpty Text)
disassociateAccounts_accountIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateAccounts' {NonEmpty Text
accountIds :: NonEmpty Text
$sel:accountIds:DisassociateAccounts' :: DisassociateAccounts -> NonEmpty Text
accountIds} -> NonEmpty Text
accountIds) (\s :: DisassociateAccounts
s@DisassociateAccounts' {} NonEmpty Text
a -> DisassociateAccounts
s {$sel:accountIds:DisassociateAccounts' :: NonEmpty Text
accountIds = NonEmpty Text
a} :: DisassociateAccounts) 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 Core.AWSRequest DisassociateAccounts where
  type
    AWSResponse DisassociateAccounts =
      DisassociateAccountsResponse
  request :: (Service -> Service)
-> DisassociateAccounts -> Request DisassociateAccounts
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 DisassociateAccounts
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateAccounts)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> DisassociateAccountsResponse
DisassociateAccountsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Arn")
            forall (f :: * -> *) a b. Applicative f => 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 DisassociateAccounts where
  hashWithSalt :: Int -> DisassociateAccounts -> Int
hashWithSalt Int
_salt DisassociateAccounts' {NonEmpty Text
Text
accountIds :: NonEmpty Text
arn :: Text
$sel:accountIds:DisassociateAccounts' :: DisassociateAccounts -> NonEmpty Text
$sel:arn:DisassociateAccounts' :: DisassociateAccounts -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
accountIds

instance Prelude.NFData DisassociateAccounts where
  rnf :: DisassociateAccounts -> ()
rnf DisassociateAccounts' {NonEmpty Text
Text
accountIds :: NonEmpty Text
arn :: Text
$sel:accountIds:DisassociateAccounts' :: DisassociateAccounts -> NonEmpty Text
$sel:arn:DisassociateAccounts' :: DisassociateAccounts -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
accountIds

instance Data.ToHeaders DisassociateAccounts where
  toHeaders :: DisassociateAccounts -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

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

-- | /See:/ 'newDisassociateAccountsResponse' smart constructor.
data DisassociateAccountsResponse = DisassociateAccountsResponse'
  { -- | The Amazon Resource Name (ARN) of the billing group that the array of
    -- account IDs is disassociated from.
    DisassociateAccountsResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DisassociateAccountsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DisassociateAccountsResponse
-> DisassociateAccountsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateAccountsResponse
-> DisassociateAccountsResponse -> Bool
$c/= :: DisassociateAccountsResponse
-> DisassociateAccountsResponse -> Bool
== :: DisassociateAccountsResponse
-> DisassociateAccountsResponse -> Bool
$c== :: DisassociateAccountsResponse
-> DisassociateAccountsResponse -> Bool
Prelude.Eq, ReadPrec [DisassociateAccountsResponse]
ReadPrec DisassociateAccountsResponse
Int -> ReadS DisassociateAccountsResponse
ReadS [DisassociateAccountsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateAccountsResponse]
$creadListPrec :: ReadPrec [DisassociateAccountsResponse]
readPrec :: ReadPrec DisassociateAccountsResponse
$creadPrec :: ReadPrec DisassociateAccountsResponse
readList :: ReadS [DisassociateAccountsResponse]
$creadList :: ReadS [DisassociateAccountsResponse]
readsPrec :: Int -> ReadS DisassociateAccountsResponse
$creadsPrec :: Int -> ReadS DisassociateAccountsResponse
Prelude.Read, Int -> DisassociateAccountsResponse -> ShowS
[DisassociateAccountsResponse] -> ShowS
DisassociateAccountsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateAccountsResponse] -> ShowS
$cshowList :: [DisassociateAccountsResponse] -> ShowS
show :: DisassociateAccountsResponse -> String
$cshow :: DisassociateAccountsResponse -> String
showsPrec :: Int -> DisassociateAccountsResponse -> ShowS
$cshowsPrec :: Int -> DisassociateAccountsResponse -> ShowS
Prelude.Show, forall x.
Rep DisassociateAccountsResponse x -> DisassociateAccountsResponse
forall x.
DisassociateAccountsResponse -> Rep DisassociateAccountsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateAccountsResponse x -> DisassociateAccountsResponse
$cfrom :: forall x.
DisassociateAccountsResponse -> Rep DisassociateAccountsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateAccountsResponse' 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:
--
-- 'arn', 'disassociateAccountsResponse_arn' - The Amazon Resource Name (ARN) of the billing group that the array of
-- account IDs is disassociated from.
--
-- 'httpStatus', 'disassociateAccountsResponse_httpStatus' - The response's http status code.
newDisassociateAccountsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateAccountsResponse
newDisassociateAccountsResponse :: Int -> DisassociateAccountsResponse
newDisassociateAccountsResponse Int
pHttpStatus_ =
  DisassociateAccountsResponse'
    { $sel:arn:DisassociateAccountsResponse' :: Maybe Text
arn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisassociateAccountsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the billing group that the array of
-- account IDs is disassociated from.
disassociateAccountsResponse_arn :: Lens.Lens' DisassociateAccountsResponse (Prelude.Maybe Prelude.Text)
disassociateAccountsResponse_arn :: Lens' DisassociateAccountsResponse (Maybe Text)
disassociateAccountsResponse_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateAccountsResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:DisassociateAccountsResponse' :: DisassociateAccountsResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: DisassociateAccountsResponse
s@DisassociateAccountsResponse' {} Maybe Text
a -> DisassociateAccountsResponse
s {$sel:arn:DisassociateAccountsResponse' :: Maybe Text
arn = Maybe Text
a} :: DisassociateAccountsResponse)

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

instance Prelude.NFData DisassociateAccountsResponse where
  rnf :: DisassociateAccountsResponse -> ()
rnf DisassociateAccountsResponse' {Int
Maybe Text
httpStatus :: Int
arn :: Maybe Text
$sel:httpStatus:DisassociateAccountsResponse' :: DisassociateAccountsResponse -> Int
$sel:arn:DisassociateAccountsResponse' :: DisassociateAccountsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus