{-# 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.Organizations.DescribeCreateAccountStatus
-- 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)
--
-- Retrieves the current status of an asynchronous request to create an
-- account.
--
-- This operation can be called only from the organization\'s management
-- account or by a member account that is a delegated administrator for an
-- AWS service.
module Amazonka.Organizations.DescribeCreateAccountStatus
  ( -- * Creating a Request
    DescribeCreateAccountStatus (..),
    newDescribeCreateAccountStatus,

    -- * Request Lenses
    describeCreateAccountStatus_createAccountRequestId,

    -- * Destructuring the Response
    DescribeCreateAccountStatusResponse (..),
    newDescribeCreateAccountStatusResponse,

    -- * Response Lenses
    describeCreateAccountStatusResponse_createAccountStatus,
    describeCreateAccountStatusResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeCreateAccountStatus' smart constructor.
data DescribeCreateAccountStatus = DescribeCreateAccountStatus'
  { -- | Specifies the @Id@ value that uniquely identifies the @CreateAccount@
    -- request. You can get the value from the @CreateAccountStatus.Id@
    -- response in an earlier CreateAccount request, or from the
    -- ListCreateAccountStatus operation.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for a create account
    -- request ID string requires \"car-\" followed by from 8 to 32 lowercase
    -- letters or digits.
    DescribeCreateAccountStatus -> Text
createAccountRequestId :: Prelude.Text
  }
  deriving (DescribeCreateAccountStatus -> DescribeCreateAccountStatus -> Bool
(DescribeCreateAccountStatus
 -> DescribeCreateAccountStatus -> Bool)
-> (DescribeCreateAccountStatus
    -> DescribeCreateAccountStatus -> Bool)
-> Eq DescribeCreateAccountStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCreateAccountStatus -> DescribeCreateAccountStatus -> Bool
$c/= :: DescribeCreateAccountStatus -> DescribeCreateAccountStatus -> Bool
== :: DescribeCreateAccountStatus -> DescribeCreateAccountStatus -> Bool
$c== :: DescribeCreateAccountStatus -> DescribeCreateAccountStatus -> Bool
Prelude.Eq, ReadPrec [DescribeCreateAccountStatus]
ReadPrec DescribeCreateAccountStatus
Int -> ReadS DescribeCreateAccountStatus
ReadS [DescribeCreateAccountStatus]
(Int -> ReadS DescribeCreateAccountStatus)
-> ReadS [DescribeCreateAccountStatus]
-> ReadPrec DescribeCreateAccountStatus
-> ReadPrec [DescribeCreateAccountStatus]
-> Read DescribeCreateAccountStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCreateAccountStatus]
$creadListPrec :: ReadPrec [DescribeCreateAccountStatus]
readPrec :: ReadPrec DescribeCreateAccountStatus
$creadPrec :: ReadPrec DescribeCreateAccountStatus
readList :: ReadS [DescribeCreateAccountStatus]
$creadList :: ReadS [DescribeCreateAccountStatus]
readsPrec :: Int -> ReadS DescribeCreateAccountStatus
$creadsPrec :: Int -> ReadS DescribeCreateAccountStatus
Prelude.Read, Int -> DescribeCreateAccountStatus -> ShowS
[DescribeCreateAccountStatus] -> ShowS
DescribeCreateAccountStatus -> String
(Int -> DescribeCreateAccountStatus -> ShowS)
-> (DescribeCreateAccountStatus -> String)
-> ([DescribeCreateAccountStatus] -> ShowS)
-> Show DescribeCreateAccountStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCreateAccountStatus] -> ShowS
$cshowList :: [DescribeCreateAccountStatus] -> ShowS
show :: DescribeCreateAccountStatus -> String
$cshow :: DescribeCreateAccountStatus -> String
showsPrec :: Int -> DescribeCreateAccountStatus -> ShowS
$cshowsPrec :: Int -> DescribeCreateAccountStatus -> ShowS
Prelude.Show, (forall x.
 DescribeCreateAccountStatus -> Rep DescribeCreateAccountStatus x)
-> (forall x.
    Rep DescribeCreateAccountStatus x -> DescribeCreateAccountStatus)
-> Generic DescribeCreateAccountStatus
forall x.
Rep DescribeCreateAccountStatus x -> DescribeCreateAccountStatus
forall x.
DescribeCreateAccountStatus -> Rep DescribeCreateAccountStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeCreateAccountStatus x -> DescribeCreateAccountStatus
$cfrom :: forall x.
DescribeCreateAccountStatus -> Rep DescribeCreateAccountStatus x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCreateAccountStatus' 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:
--
-- 'createAccountRequestId', 'describeCreateAccountStatus_createAccountRequestId' - Specifies the @Id@ value that uniquely identifies the @CreateAccount@
-- request. You can get the value from the @CreateAccountStatus.Id@
-- response in an earlier CreateAccount request, or from the
-- ListCreateAccountStatus operation.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a create account
-- request ID string requires \"car-\" followed by from 8 to 32 lowercase
-- letters or digits.
newDescribeCreateAccountStatus ::
  -- | 'createAccountRequestId'
  Prelude.Text ->
  DescribeCreateAccountStatus
newDescribeCreateAccountStatus :: Text -> DescribeCreateAccountStatus
newDescribeCreateAccountStatus
  Text
pCreateAccountRequestId_ =
    DescribeCreateAccountStatus' :: Text -> DescribeCreateAccountStatus
DescribeCreateAccountStatus'
      { $sel:createAccountRequestId:DescribeCreateAccountStatus' :: Text
createAccountRequestId =
          Text
pCreateAccountRequestId_
      }

-- | Specifies the @Id@ value that uniquely identifies the @CreateAccount@
-- request. You can get the value from the @CreateAccountStatus.Id@
-- response in an earlier CreateAccount request, or from the
-- ListCreateAccountStatus operation.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a create account
-- request ID string requires \"car-\" followed by from 8 to 32 lowercase
-- letters or digits.
describeCreateAccountStatus_createAccountRequestId :: Lens.Lens' DescribeCreateAccountStatus Prelude.Text
describeCreateAccountStatus_createAccountRequestId :: (Text -> f Text)
-> DescribeCreateAccountStatus -> f DescribeCreateAccountStatus
describeCreateAccountStatus_createAccountRequestId = (DescribeCreateAccountStatus -> Text)
-> (DescribeCreateAccountStatus
    -> Text -> DescribeCreateAccountStatus)
-> Lens
     DescribeCreateAccountStatus DescribeCreateAccountStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCreateAccountStatus' {Text
createAccountRequestId :: Text
$sel:createAccountRequestId:DescribeCreateAccountStatus' :: DescribeCreateAccountStatus -> Text
createAccountRequestId} -> Text
createAccountRequestId) (\s :: DescribeCreateAccountStatus
s@DescribeCreateAccountStatus' {} Text
a -> DescribeCreateAccountStatus
s {$sel:createAccountRequestId:DescribeCreateAccountStatus' :: Text
createAccountRequestId = Text
a} :: DescribeCreateAccountStatus)

instance Core.AWSRequest DescribeCreateAccountStatus where
  type
    AWSResponse DescribeCreateAccountStatus =
      DescribeCreateAccountStatusResponse
  request :: DescribeCreateAccountStatus -> Request DescribeCreateAccountStatus
request = Service
-> DescribeCreateAccountStatus
-> Request DescribeCreateAccountStatus
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeCreateAccountStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeCreateAccountStatus)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeCreateAccountStatus))
-> Logger
-> Service
-> Proxy DescribeCreateAccountStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeCreateAccountStatus)))
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 CreateAccountStatus
-> Int -> DescribeCreateAccountStatusResponse
DescribeCreateAccountStatusResponse'
            (Maybe CreateAccountStatus
 -> Int -> DescribeCreateAccountStatusResponse)
-> Either String (Maybe CreateAccountStatus)
-> Either String (Int -> DescribeCreateAccountStatusResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe CreateAccountStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"CreateAccountStatus")
            Either String (Int -> DescribeCreateAccountStatusResponse)
-> Either String Int
-> Either String DescribeCreateAccountStatusResponse
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 DescribeCreateAccountStatus

instance Prelude.NFData DescribeCreateAccountStatus

instance Core.ToHeaders DescribeCreateAccountStatus where
  toHeaders :: DescribeCreateAccountStatus -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeCreateAccountStatus -> 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
"AWSOrganizationsV20161128.DescribeCreateAccountStatus" ::
                          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 DescribeCreateAccountStatus where
  toJSON :: DescribeCreateAccountStatus -> Value
toJSON DescribeCreateAccountStatus' {Text
createAccountRequestId :: Text
$sel:createAccountRequestId:DescribeCreateAccountStatus' :: DescribeCreateAccountStatus -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"CreateAccountRequestId"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
createAccountRequestId
              )
          ]
      )

instance Core.ToPath DescribeCreateAccountStatus where
  toPath :: DescribeCreateAccountStatus -> ByteString
toPath = ByteString -> DescribeCreateAccountStatus -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDescribeCreateAccountStatusResponse' smart constructor.
data DescribeCreateAccountStatusResponse = DescribeCreateAccountStatusResponse'
  { -- | A structure that contains the current status of an account creation
    -- request.
    DescribeCreateAccountStatusResponse -> Maybe CreateAccountStatus
createAccountStatus :: Prelude.Maybe CreateAccountStatus,
    -- | The response's http status code.
    DescribeCreateAccountStatusResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeCreateAccountStatusResponse
-> DescribeCreateAccountStatusResponse -> Bool
(DescribeCreateAccountStatusResponse
 -> DescribeCreateAccountStatusResponse -> Bool)
-> (DescribeCreateAccountStatusResponse
    -> DescribeCreateAccountStatusResponse -> Bool)
-> Eq DescribeCreateAccountStatusResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCreateAccountStatusResponse
-> DescribeCreateAccountStatusResponse -> Bool
$c/= :: DescribeCreateAccountStatusResponse
-> DescribeCreateAccountStatusResponse -> Bool
== :: DescribeCreateAccountStatusResponse
-> DescribeCreateAccountStatusResponse -> Bool
$c== :: DescribeCreateAccountStatusResponse
-> DescribeCreateAccountStatusResponse -> Bool
Prelude.Eq, Int -> DescribeCreateAccountStatusResponse -> ShowS
[DescribeCreateAccountStatusResponse] -> ShowS
DescribeCreateAccountStatusResponse -> String
(Int -> DescribeCreateAccountStatusResponse -> ShowS)
-> (DescribeCreateAccountStatusResponse -> String)
-> ([DescribeCreateAccountStatusResponse] -> ShowS)
-> Show DescribeCreateAccountStatusResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCreateAccountStatusResponse] -> ShowS
$cshowList :: [DescribeCreateAccountStatusResponse] -> ShowS
show :: DescribeCreateAccountStatusResponse -> String
$cshow :: DescribeCreateAccountStatusResponse -> String
showsPrec :: Int -> DescribeCreateAccountStatusResponse -> ShowS
$cshowsPrec :: Int -> DescribeCreateAccountStatusResponse -> ShowS
Prelude.Show, (forall x.
 DescribeCreateAccountStatusResponse
 -> Rep DescribeCreateAccountStatusResponse x)
-> (forall x.
    Rep DescribeCreateAccountStatusResponse x
    -> DescribeCreateAccountStatusResponse)
-> Generic DescribeCreateAccountStatusResponse
forall x.
Rep DescribeCreateAccountStatusResponse x
-> DescribeCreateAccountStatusResponse
forall x.
DescribeCreateAccountStatusResponse
-> Rep DescribeCreateAccountStatusResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeCreateAccountStatusResponse x
-> DescribeCreateAccountStatusResponse
$cfrom :: forall x.
DescribeCreateAccountStatusResponse
-> Rep DescribeCreateAccountStatusResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCreateAccountStatusResponse' 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:
--
-- 'createAccountStatus', 'describeCreateAccountStatusResponse_createAccountStatus' - A structure that contains the current status of an account creation
-- request.
--
-- 'httpStatus', 'describeCreateAccountStatusResponse_httpStatus' - The response's http status code.
newDescribeCreateAccountStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeCreateAccountStatusResponse
newDescribeCreateAccountStatusResponse :: Int -> DescribeCreateAccountStatusResponse
newDescribeCreateAccountStatusResponse Int
pHttpStatus_ =
  DescribeCreateAccountStatusResponse' :: Maybe CreateAccountStatus
-> Int -> DescribeCreateAccountStatusResponse
DescribeCreateAccountStatusResponse'
    { $sel:createAccountStatus:DescribeCreateAccountStatusResponse' :: Maybe CreateAccountStatus
createAccountStatus =
        Maybe CreateAccountStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeCreateAccountStatusResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A structure that contains the current status of an account creation
-- request.
describeCreateAccountStatusResponse_createAccountStatus :: Lens.Lens' DescribeCreateAccountStatusResponse (Prelude.Maybe CreateAccountStatus)
describeCreateAccountStatusResponse_createAccountStatus :: (Maybe CreateAccountStatus -> f (Maybe CreateAccountStatus))
-> DescribeCreateAccountStatusResponse
-> f DescribeCreateAccountStatusResponse
describeCreateAccountStatusResponse_createAccountStatus = (DescribeCreateAccountStatusResponse -> Maybe CreateAccountStatus)
-> (DescribeCreateAccountStatusResponse
    -> Maybe CreateAccountStatus
    -> DescribeCreateAccountStatusResponse)
-> Lens
     DescribeCreateAccountStatusResponse
     DescribeCreateAccountStatusResponse
     (Maybe CreateAccountStatus)
     (Maybe CreateAccountStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCreateAccountStatusResponse' {Maybe CreateAccountStatus
createAccountStatus :: Maybe CreateAccountStatus
$sel:createAccountStatus:DescribeCreateAccountStatusResponse' :: DescribeCreateAccountStatusResponse -> Maybe CreateAccountStatus
createAccountStatus} -> Maybe CreateAccountStatus
createAccountStatus) (\s :: DescribeCreateAccountStatusResponse
s@DescribeCreateAccountStatusResponse' {} Maybe CreateAccountStatus
a -> DescribeCreateAccountStatusResponse
s {$sel:createAccountStatus:DescribeCreateAccountStatusResponse' :: Maybe CreateAccountStatus
createAccountStatus = Maybe CreateAccountStatus
a} :: DescribeCreateAccountStatusResponse)

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

instance
  Prelude.NFData
    DescribeCreateAccountStatusResponse