{-# 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 #-}
module Amazonka.BillingConductor.AssociateAccounts
(
AssociateAccounts (..),
newAssociateAccounts,
associateAccounts_arn,
associateAccounts_accountIds,
AssociateAccountsResponse (..),
newAssociateAccountsResponse,
associateAccountsResponse_arn,
associateAccountsResponse_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
data AssociateAccounts = AssociateAccounts'
{
AssociateAccounts -> Text
arn :: Prelude.Text,
AssociateAccounts -> NonEmpty Text
accountIds :: Prelude.NonEmpty Prelude.Text
}
deriving (AssociateAccounts -> AssociateAccounts -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateAccounts -> AssociateAccounts -> Bool
$c/= :: AssociateAccounts -> AssociateAccounts -> Bool
== :: AssociateAccounts -> AssociateAccounts -> Bool
$c== :: AssociateAccounts -> AssociateAccounts -> Bool
Prelude.Eq, ReadPrec [AssociateAccounts]
ReadPrec AssociateAccounts
Int -> ReadS AssociateAccounts
ReadS [AssociateAccounts]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateAccounts]
$creadListPrec :: ReadPrec [AssociateAccounts]
readPrec :: ReadPrec AssociateAccounts
$creadPrec :: ReadPrec AssociateAccounts
readList :: ReadS [AssociateAccounts]
$creadList :: ReadS [AssociateAccounts]
readsPrec :: Int -> ReadS AssociateAccounts
$creadsPrec :: Int -> ReadS AssociateAccounts
Prelude.Read, Int -> AssociateAccounts -> ShowS
[AssociateAccounts] -> ShowS
AssociateAccounts -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateAccounts] -> ShowS
$cshowList :: [AssociateAccounts] -> ShowS
show :: AssociateAccounts -> String
$cshow :: AssociateAccounts -> String
showsPrec :: Int -> AssociateAccounts -> ShowS
$cshowsPrec :: Int -> AssociateAccounts -> ShowS
Prelude.Show, forall x. Rep AssociateAccounts x -> AssociateAccounts
forall x. AssociateAccounts -> Rep AssociateAccounts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateAccounts x -> AssociateAccounts
$cfrom :: forall x. AssociateAccounts -> Rep AssociateAccounts x
Prelude.Generic)
newAssociateAccounts ::
Prelude.Text ->
Prelude.NonEmpty Prelude.Text ->
AssociateAccounts
newAssociateAccounts :: Text -> NonEmpty Text -> AssociateAccounts
newAssociateAccounts Text
pArn_ NonEmpty Text
pAccountIds_ =
AssociateAccounts'
{ $sel:arn:AssociateAccounts' :: Text
arn = Text
pArn_,
$sel:accountIds:AssociateAccounts' :: 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_
}
associateAccounts_arn :: Lens.Lens' AssociateAccounts Prelude.Text
associateAccounts_arn :: Lens' AssociateAccounts Text
associateAccounts_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAccounts' {Text
arn :: Text
$sel:arn:AssociateAccounts' :: AssociateAccounts -> Text
arn} -> Text
arn) (\s :: AssociateAccounts
s@AssociateAccounts' {} Text
a -> AssociateAccounts
s {$sel:arn:AssociateAccounts' :: Text
arn = Text
a} :: AssociateAccounts)
associateAccounts_accountIds :: Lens.Lens' AssociateAccounts (Prelude.NonEmpty Prelude.Text)
associateAccounts_accountIds :: Lens' AssociateAccounts (NonEmpty Text)
associateAccounts_accountIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAccounts' {NonEmpty Text
accountIds :: NonEmpty Text
$sel:accountIds:AssociateAccounts' :: AssociateAccounts -> NonEmpty Text
accountIds} -> NonEmpty Text
accountIds) (\s :: AssociateAccounts
s@AssociateAccounts' {} NonEmpty Text
a -> AssociateAccounts
s {$sel:accountIds:AssociateAccounts' :: NonEmpty Text
accountIds = NonEmpty Text
a} :: AssociateAccounts) 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 AssociateAccounts where
type
AWSResponse AssociateAccounts =
AssociateAccountsResponse
request :: (Service -> Service)
-> AssociateAccounts -> Request AssociateAccounts
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 AssociateAccounts
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse AssociateAccounts)))
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 -> AssociateAccountsResponse
AssociateAccountsResponse'
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 AssociateAccounts where
hashWithSalt :: Int -> AssociateAccounts -> Int
hashWithSalt Int
_salt AssociateAccounts' {NonEmpty Text
Text
accountIds :: NonEmpty Text
arn :: Text
$sel:accountIds:AssociateAccounts' :: AssociateAccounts -> NonEmpty Text
$sel:arn:AssociateAccounts' :: AssociateAccounts -> 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 AssociateAccounts where
rnf :: AssociateAccounts -> ()
rnf AssociateAccounts' {NonEmpty Text
Text
accountIds :: NonEmpty Text
arn :: Text
$sel:accountIds:AssociateAccounts' :: AssociateAccounts -> NonEmpty Text
$sel:arn:AssociateAccounts' :: AssociateAccounts -> 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 AssociateAccounts where
toHeaders :: AssociateAccounts -> 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 AssociateAccounts where
toJSON :: AssociateAccounts -> Value
toJSON AssociateAccounts' {NonEmpty Text
Text
accountIds :: NonEmpty Text
arn :: Text
$sel:accountIds:AssociateAccounts' :: AssociateAccounts -> NonEmpty Text
$sel:arn:AssociateAccounts' :: AssociateAccounts -> 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 AssociateAccounts where
toPath :: AssociateAccounts -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/associate-accounts"
instance Data.ToQuery AssociateAccounts where
toQuery :: AssociateAccounts -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data AssociateAccountsResponse = AssociateAccountsResponse'
{
AssociateAccountsResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
AssociateAccountsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (AssociateAccountsResponse -> AssociateAccountsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateAccountsResponse -> AssociateAccountsResponse -> Bool
$c/= :: AssociateAccountsResponse -> AssociateAccountsResponse -> Bool
== :: AssociateAccountsResponse -> AssociateAccountsResponse -> Bool
$c== :: AssociateAccountsResponse -> AssociateAccountsResponse -> Bool
Prelude.Eq, ReadPrec [AssociateAccountsResponse]
ReadPrec AssociateAccountsResponse
Int -> ReadS AssociateAccountsResponse
ReadS [AssociateAccountsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateAccountsResponse]
$creadListPrec :: ReadPrec [AssociateAccountsResponse]
readPrec :: ReadPrec AssociateAccountsResponse
$creadPrec :: ReadPrec AssociateAccountsResponse
readList :: ReadS [AssociateAccountsResponse]
$creadList :: ReadS [AssociateAccountsResponse]
readsPrec :: Int -> ReadS AssociateAccountsResponse
$creadsPrec :: Int -> ReadS AssociateAccountsResponse
Prelude.Read, Int -> AssociateAccountsResponse -> ShowS
[AssociateAccountsResponse] -> ShowS
AssociateAccountsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateAccountsResponse] -> ShowS
$cshowList :: [AssociateAccountsResponse] -> ShowS
show :: AssociateAccountsResponse -> String
$cshow :: AssociateAccountsResponse -> String
showsPrec :: Int -> AssociateAccountsResponse -> ShowS
$cshowsPrec :: Int -> AssociateAccountsResponse -> ShowS
Prelude.Show, forall x.
Rep AssociateAccountsResponse x -> AssociateAccountsResponse
forall x.
AssociateAccountsResponse -> Rep AssociateAccountsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateAccountsResponse x -> AssociateAccountsResponse
$cfrom :: forall x.
AssociateAccountsResponse -> Rep AssociateAccountsResponse x
Prelude.Generic)
newAssociateAccountsResponse ::
Prelude.Int ->
AssociateAccountsResponse
newAssociateAccountsResponse :: Int -> AssociateAccountsResponse
newAssociateAccountsResponse Int
pHttpStatus_ =
AssociateAccountsResponse'
{ $sel:arn:AssociateAccountsResponse' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:AssociateAccountsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
associateAccountsResponse_arn :: Lens.Lens' AssociateAccountsResponse (Prelude.Maybe Prelude.Text)
associateAccountsResponse_arn :: Lens' AssociateAccountsResponse (Maybe Text)
associateAccountsResponse_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAccountsResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:AssociateAccountsResponse' :: AssociateAccountsResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: AssociateAccountsResponse
s@AssociateAccountsResponse' {} Maybe Text
a -> AssociateAccountsResponse
s {$sel:arn:AssociateAccountsResponse' :: Maybe Text
arn = Maybe Text
a} :: AssociateAccountsResponse)
associateAccountsResponse_httpStatus :: Lens.Lens' AssociateAccountsResponse Prelude.Int
associateAccountsResponse_httpStatus :: Lens' AssociateAccountsResponse Int
associateAccountsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAccountsResponse' {Int
httpStatus :: Int
$sel:httpStatus:AssociateAccountsResponse' :: AssociateAccountsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AssociateAccountsResponse
s@AssociateAccountsResponse' {} Int
a -> AssociateAccountsResponse
s {$sel:httpStatus:AssociateAccountsResponse' :: Int
httpStatus = Int
a} :: AssociateAccountsResponse)
instance Prelude.NFData AssociateAccountsResponse where
rnf :: AssociateAccountsResponse -> ()
rnf AssociateAccountsResponse' {Int
Maybe Text
httpStatus :: Int
arn :: Maybe Text
$sel:httpStatus:AssociateAccountsResponse' :: AssociateAccountsResponse -> Int
$sel:arn:AssociateAccountsResponse' :: AssociateAccountsResponse -> 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