{-# 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.Account.GetContactInformation
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the primary contact information of an Amazon Web Services
-- account.
--
-- For complete details about how to use the primary contact operations,
-- see
-- <https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-update-contact.html Update the primary and alternate contact information>.
module Amazonka.Account.GetContactInformation
  ( -- * Creating a Request
    GetContactInformation (..),
    newGetContactInformation,

    -- * Request Lenses
    getContactInformation_accountId,

    -- * Destructuring the Response
    GetContactInformationResponse (..),
    newGetContactInformationResponse,

    -- * Response Lenses
    getContactInformationResponse_contactInformation,
    getContactInformationResponse_httpStatus,
  )
where

import Amazonka.Account.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:/ 'newGetContactInformation' smart constructor.
data GetContactInformation = GetContactInformation'
  { -- | Specifies the 12-digit account ID number of the Amazon Web Services
    -- account that you want to access or modify with this operation. If you
    -- don\'t specify this parameter, it defaults to the Amazon Web Services
    -- account of the identity used to call the operation. To use this
    -- parameter, the caller must be an identity in the
    -- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html#account organization\'s management account>
    -- or a delegated administrator account. The specified account ID must also
    -- be a member account in the same organization. The organization must have
    -- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_support-all-features.html all features enabled>,
    -- and the organization must have
    -- <https://docs.aws.amazon.com/organizations/latest/userguide/using-orgs-trusted-access.html trusted access>
    -- enabled for the Account Management service, and optionally a
    -- <https://docs.aws.amazon.com/organizations/latest/userguide/using-orgs-delegated-admin.html delegated admin>
    -- account assigned.
    --
    -- The management account can\'t specify its own @AccountId@. It must call
    -- the operation in standalone context by not including the @AccountId@
    -- parameter.
    --
    -- To call this operation on an account that is not a member of an
    -- organization, don\'t specify this parameter. Instead, call the operation
    -- using an identity belonging to the account whose contacts you wish to
    -- retrieve or modify.
    GetContactInformation -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text
  }
  deriving (GetContactInformation -> GetContactInformation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContactInformation -> GetContactInformation -> Bool
$c/= :: GetContactInformation -> GetContactInformation -> Bool
== :: GetContactInformation -> GetContactInformation -> Bool
$c== :: GetContactInformation -> GetContactInformation -> Bool
Prelude.Eq, ReadPrec [GetContactInformation]
ReadPrec GetContactInformation
Int -> ReadS GetContactInformation
ReadS [GetContactInformation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContactInformation]
$creadListPrec :: ReadPrec [GetContactInformation]
readPrec :: ReadPrec GetContactInformation
$creadPrec :: ReadPrec GetContactInformation
readList :: ReadS [GetContactInformation]
$creadList :: ReadS [GetContactInformation]
readsPrec :: Int -> ReadS GetContactInformation
$creadsPrec :: Int -> ReadS GetContactInformation
Prelude.Read, Int -> GetContactInformation -> ShowS
[GetContactInformation] -> ShowS
GetContactInformation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContactInformation] -> ShowS
$cshowList :: [GetContactInformation] -> ShowS
show :: GetContactInformation -> String
$cshow :: GetContactInformation -> String
showsPrec :: Int -> GetContactInformation -> ShowS
$cshowsPrec :: Int -> GetContactInformation -> ShowS
Prelude.Show, forall x. Rep GetContactInformation x -> GetContactInformation
forall x. GetContactInformation -> Rep GetContactInformation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetContactInformation x -> GetContactInformation
$cfrom :: forall x. GetContactInformation -> Rep GetContactInformation x
Prelude.Generic)

-- |
-- Create a value of 'GetContactInformation' 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:
--
-- 'accountId', 'getContactInformation_accountId' - Specifies the 12-digit account ID number of the Amazon Web Services
-- account that you want to access or modify with this operation. If you
-- don\'t specify this parameter, it defaults to the Amazon Web Services
-- account of the identity used to call the operation. To use this
-- parameter, the caller must be an identity in the
-- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html#account organization\'s management account>
-- or a delegated administrator account. The specified account ID must also
-- be a member account in the same organization. The organization must have
-- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_support-all-features.html all features enabled>,
-- and the organization must have
-- <https://docs.aws.amazon.com/organizations/latest/userguide/using-orgs-trusted-access.html trusted access>
-- enabled for the Account Management service, and optionally a
-- <https://docs.aws.amazon.com/organizations/latest/userguide/using-orgs-delegated-admin.html delegated admin>
-- account assigned.
--
-- The management account can\'t specify its own @AccountId@. It must call
-- the operation in standalone context by not including the @AccountId@
-- parameter.
--
-- To call this operation on an account that is not a member of an
-- organization, don\'t specify this parameter. Instead, call the operation
-- using an identity belonging to the account whose contacts you wish to
-- retrieve or modify.
newGetContactInformation ::
  GetContactInformation
newGetContactInformation :: GetContactInformation
newGetContactInformation =
  GetContactInformation' {$sel:accountId:GetContactInformation' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing}

-- | Specifies the 12-digit account ID number of the Amazon Web Services
-- account that you want to access or modify with this operation. If you
-- don\'t specify this parameter, it defaults to the Amazon Web Services
-- account of the identity used to call the operation. To use this
-- parameter, the caller must be an identity in the
-- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html#account organization\'s management account>
-- or a delegated administrator account. The specified account ID must also
-- be a member account in the same organization. The organization must have
-- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_support-all-features.html all features enabled>,
-- and the organization must have
-- <https://docs.aws.amazon.com/organizations/latest/userguide/using-orgs-trusted-access.html trusted access>
-- enabled for the Account Management service, and optionally a
-- <https://docs.aws.amazon.com/organizations/latest/userguide/using-orgs-delegated-admin.html delegated admin>
-- account assigned.
--
-- The management account can\'t specify its own @AccountId@. It must call
-- the operation in standalone context by not including the @AccountId@
-- parameter.
--
-- To call this operation on an account that is not a member of an
-- organization, don\'t specify this parameter. Instead, call the operation
-- using an identity belonging to the account whose contacts you wish to
-- retrieve or modify.
getContactInformation_accountId :: Lens.Lens' GetContactInformation (Prelude.Maybe Prelude.Text)
getContactInformation_accountId :: Lens' GetContactInformation (Maybe Text)
getContactInformation_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContactInformation' {Maybe Text
accountId :: Maybe Text
$sel:accountId:GetContactInformation' :: GetContactInformation -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: GetContactInformation
s@GetContactInformation' {} Maybe Text
a -> GetContactInformation
s {$sel:accountId:GetContactInformation' :: Maybe Text
accountId = Maybe Text
a} :: GetContactInformation)

instance Core.AWSRequest GetContactInformation where
  type
    AWSResponse GetContactInformation =
      GetContactInformationResponse
  request :: (Service -> Service)
-> GetContactInformation -> Request GetContactInformation
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 GetContactInformation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetContactInformation)))
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 ContactInformation -> Int -> GetContactInformationResponse
GetContactInformationResponse'
            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
"ContactInformation")
            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 GetContactInformation where
  hashWithSalt :: Int -> GetContactInformation -> Int
hashWithSalt Int
_salt GetContactInformation' {Maybe Text
accountId :: Maybe Text
$sel:accountId:GetContactInformation' :: GetContactInformation -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId

instance Prelude.NFData GetContactInformation where
  rnf :: GetContactInformation -> ()
rnf GetContactInformation' {Maybe Text
accountId :: Maybe Text
$sel:accountId:GetContactInformation' :: GetContactInformation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId

instance Data.ToHeaders GetContactInformation where
  toHeaders :: GetContactInformation -> 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 GetContactInformation where
  toJSON :: GetContactInformation -> Value
toJSON GetContactInformation' {Maybe Text
accountId :: Maybe Text
$sel:accountId:GetContactInformation' :: GetContactInformation -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"AccountId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
accountId]
      )

instance Data.ToPath GetContactInformation where
  toPath :: GetContactInformation -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/getContactInformation"

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

-- | /See:/ 'newGetContactInformationResponse' smart constructor.
data GetContactInformationResponse = GetContactInformationResponse'
  { -- | Contains the details of the primary contact information associated with
    -- an Amazon Web Services account.
    GetContactInformationResponse -> Maybe ContactInformation
contactInformation :: Prelude.Maybe ContactInformation,
    -- | The response's http status code.
    GetContactInformationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetContactInformationResponse
-> GetContactInformationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContactInformationResponse
-> GetContactInformationResponse -> Bool
$c/= :: GetContactInformationResponse
-> GetContactInformationResponse -> Bool
== :: GetContactInformationResponse
-> GetContactInformationResponse -> Bool
$c== :: GetContactInformationResponse
-> GetContactInformationResponse -> Bool
Prelude.Eq, Int -> GetContactInformationResponse -> ShowS
[GetContactInformationResponse] -> ShowS
GetContactInformationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContactInformationResponse] -> ShowS
$cshowList :: [GetContactInformationResponse] -> ShowS
show :: GetContactInformationResponse -> String
$cshow :: GetContactInformationResponse -> String
showsPrec :: Int -> GetContactInformationResponse -> ShowS
$cshowsPrec :: Int -> GetContactInformationResponse -> ShowS
Prelude.Show, forall x.
Rep GetContactInformationResponse x
-> GetContactInformationResponse
forall x.
GetContactInformationResponse
-> Rep GetContactInformationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetContactInformationResponse x
-> GetContactInformationResponse
$cfrom :: forall x.
GetContactInformationResponse
-> Rep GetContactInformationResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetContactInformationResponse' 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:
--
-- 'contactInformation', 'getContactInformationResponse_contactInformation' - Contains the details of the primary contact information associated with
-- an Amazon Web Services account.
--
-- 'httpStatus', 'getContactInformationResponse_httpStatus' - The response's http status code.
newGetContactInformationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetContactInformationResponse
newGetContactInformationResponse :: Int -> GetContactInformationResponse
newGetContactInformationResponse Int
pHttpStatus_ =
  GetContactInformationResponse'
    { $sel:contactInformation:GetContactInformationResponse' :: Maybe ContactInformation
contactInformation =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetContactInformationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Contains the details of the primary contact information associated with
-- an Amazon Web Services account.
getContactInformationResponse_contactInformation :: Lens.Lens' GetContactInformationResponse (Prelude.Maybe ContactInformation)
getContactInformationResponse_contactInformation :: Lens' GetContactInformationResponse (Maybe ContactInformation)
getContactInformationResponse_contactInformation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContactInformationResponse' {Maybe ContactInformation
contactInformation :: Maybe ContactInformation
$sel:contactInformation:GetContactInformationResponse' :: GetContactInformationResponse -> Maybe ContactInformation
contactInformation} -> Maybe ContactInformation
contactInformation) (\s :: GetContactInformationResponse
s@GetContactInformationResponse' {} Maybe ContactInformation
a -> GetContactInformationResponse
s {$sel:contactInformation:GetContactInformationResponse' :: Maybe ContactInformation
contactInformation = Maybe ContactInformation
a} :: GetContactInformationResponse)

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

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