{-# 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.ResourceGroupsTagging.DescribeReportCreation
-- 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)
--
-- Describes the status of the @StartReportCreation@ operation.
--
-- You can call this operation only from the organization\'s management
-- account and from the us-east-1 Region.
module Amazonka.ResourceGroupsTagging.DescribeReportCreation
  ( -- * Creating a Request
    DescribeReportCreation (..),
    newDescribeReportCreation,

    -- * Destructuring the Response
    DescribeReportCreationResponse (..),
    newDescribeReportCreationResponse,

    -- * Response Lenses
    describeReportCreationResponse_status,
    describeReportCreationResponse_s3Location,
    describeReportCreationResponse_errorMessage,
    describeReportCreationResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeReportCreation' smart constructor.
data DescribeReportCreation = DescribeReportCreation'
  {
  }
  deriving (DescribeReportCreation -> DescribeReportCreation -> Bool
(DescribeReportCreation -> DescribeReportCreation -> Bool)
-> (DescribeReportCreation -> DescribeReportCreation -> Bool)
-> Eq DescribeReportCreation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeReportCreation -> DescribeReportCreation -> Bool
$c/= :: DescribeReportCreation -> DescribeReportCreation -> Bool
== :: DescribeReportCreation -> DescribeReportCreation -> Bool
$c== :: DescribeReportCreation -> DescribeReportCreation -> Bool
Prelude.Eq, ReadPrec [DescribeReportCreation]
ReadPrec DescribeReportCreation
Int -> ReadS DescribeReportCreation
ReadS [DescribeReportCreation]
(Int -> ReadS DescribeReportCreation)
-> ReadS [DescribeReportCreation]
-> ReadPrec DescribeReportCreation
-> ReadPrec [DescribeReportCreation]
-> Read DescribeReportCreation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeReportCreation]
$creadListPrec :: ReadPrec [DescribeReportCreation]
readPrec :: ReadPrec DescribeReportCreation
$creadPrec :: ReadPrec DescribeReportCreation
readList :: ReadS [DescribeReportCreation]
$creadList :: ReadS [DescribeReportCreation]
readsPrec :: Int -> ReadS DescribeReportCreation
$creadsPrec :: Int -> ReadS DescribeReportCreation
Prelude.Read, Int -> DescribeReportCreation -> ShowS
[DescribeReportCreation] -> ShowS
DescribeReportCreation -> String
(Int -> DescribeReportCreation -> ShowS)
-> (DescribeReportCreation -> String)
-> ([DescribeReportCreation] -> ShowS)
-> Show DescribeReportCreation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeReportCreation] -> ShowS
$cshowList :: [DescribeReportCreation] -> ShowS
show :: DescribeReportCreation -> String
$cshow :: DescribeReportCreation -> String
showsPrec :: Int -> DescribeReportCreation -> ShowS
$cshowsPrec :: Int -> DescribeReportCreation -> ShowS
Prelude.Show, (forall x. DescribeReportCreation -> Rep DescribeReportCreation x)
-> (forall x.
    Rep DescribeReportCreation x -> DescribeReportCreation)
-> Generic DescribeReportCreation
forall x. Rep DescribeReportCreation x -> DescribeReportCreation
forall x. DescribeReportCreation -> Rep DescribeReportCreation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeReportCreation x -> DescribeReportCreation
$cfrom :: forall x. DescribeReportCreation -> Rep DescribeReportCreation x
Prelude.Generic)

-- |
-- Create a value of 'DescribeReportCreation' 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.
newDescribeReportCreation ::
  DescribeReportCreation
newDescribeReportCreation :: DescribeReportCreation
newDescribeReportCreation = DescribeReportCreation
DescribeReportCreation'

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

instance Prelude.NFData DescribeReportCreation

instance Core.ToHeaders DescribeReportCreation where
  toHeaders :: DescribeReportCreation -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeReportCreation -> 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
"ResourceGroupsTaggingAPI_20170126.DescribeReportCreation" ::
                          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 DescribeReportCreation where
  toJSON :: DescribeReportCreation -> Value
toJSON = Value -> DescribeReportCreation -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

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

-- | /See:/ 'newDescribeReportCreationResponse' smart constructor.
data DescribeReportCreationResponse = DescribeReportCreationResponse'
  { -- | Reports the status of the operation.
    --
    -- The operation status can be one of the following:
    --
    -- -   @RUNNING@ - Report creation is in progress.
    --
    -- -   @SUCCEEDED@ - Report creation is complete. You can open the report
    --     from the Amazon S3 bucket that you specified when you ran
    --     @StartReportCreation@.
    --
    -- -   @FAILED@ - Report creation timed out or the Amazon S3 bucket is not
    --     accessible.
    --
    -- -   @NO REPORT@ - No report was generated in the last 90 days.
    DescribeReportCreationResponse -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The path to the Amazon S3 bucket where the report was stored on
    -- creation.
    DescribeReportCreationResponse -> Maybe Text
s3Location :: Prelude.Maybe Prelude.Text,
    -- | Details of the common errors that all operations return.
    DescribeReportCreationResponse -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeReportCreationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeReportCreationResponse
-> DescribeReportCreationResponse -> Bool
(DescribeReportCreationResponse
 -> DescribeReportCreationResponse -> Bool)
-> (DescribeReportCreationResponse
    -> DescribeReportCreationResponse -> Bool)
-> Eq DescribeReportCreationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeReportCreationResponse
-> DescribeReportCreationResponse -> Bool
$c/= :: DescribeReportCreationResponse
-> DescribeReportCreationResponse -> Bool
== :: DescribeReportCreationResponse
-> DescribeReportCreationResponse -> Bool
$c== :: DescribeReportCreationResponse
-> DescribeReportCreationResponse -> Bool
Prelude.Eq, ReadPrec [DescribeReportCreationResponse]
ReadPrec DescribeReportCreationResponse
Int -> ReadS DescribeReportCreationResponse
ReadS [DescribeReportCreationResponse]
(Int -> ReadS DescribeReportCreationResponse)
-> ReadS [DescribeReportCreationResponse]
-> ReadPrec DescribeReportCreationResponse
-> ReadPrec [DescribeReportCreationResponse]
-> Read DescribeReportCreationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeReportCreationResponse]
$creadListPrec :: ReadPrec [DescribeReportCreationResponse]
readPrec :: ReadPrec DescribeReportCreationResponse
$creadPrec :: ReadPrec DescribeReportCreationResponse
readList :: ReadS [DescribeReportCreationResponse]
$creadList :: ReadS [DescribeReportCreationResponse]
readsPrec :: Int -> ReadS DescribeReportCreationResponse
$creadsPrec :: Int -> ReadS DescribeReportCreationResponse
Prelude.Read, Int -> DescribeReportCreationResponse -> ShowS
[DescribeReportCreationResponse] -> ShowS
DescribeReportCreationResponse -> String
(Int -> DescribeReportCreationResponse -> ShowS)
-> (DescribeReportCreationResponse -> String)
-> ([DescribeReportCreationResponse] -> ShowS)
-> Show DescribeReportCreationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeReportCreationResponse] -> ShowS
$cshowList :: [DescribeReportCreationResponse] -> ShowS
show :: DescribeReportCreationResponse -> String
$cshow :: DescribeReportCreationResponse -> String
showsPrec :: Int -> DescribeReportCreationResponse -> ShowS
$cshowsPrec :: Int -> DescribeReportCreationResponse -> ShowS
Prelude.Show, (forall x.
 DescribeReportCreationResponse
 -> Rep DescribeReportCreationResponse x)
-> (forall x.
    Rep DescribeReportCreationResponse x
    -> DescribeReportCreationResponse)
-> Generic DescribeReportCreationResponse
forall x.
Rep DescribeReportCreationResponse x
-> DescribeReportCreationResponse
forall x.
DescribeReportCreationResponse
-> Rep DescribeReportCreationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeReportCreationResponse x
-> DescribeReportCreationResponse
$cfrom :: forall x.
DescribeReportCreationResponse
-> Rep DescribeReportCreationResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeReportCreationResponse' 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:
--
-- 'status', 'describeReportCreationResponse_status' - Reports the status of the operation.
--
-- The operation status can be one of the following:
--
-- -   @RUNNING@ - Report creation is in progress.
--
-- -   @SUCCEEDED@ - Report creation is complete. You can open the report
--     from the Amazon S3 bucket that you specified when you ran
--     @StartReportCreation@.
--
-- -   @FAILED@ - Report creation timed out or the Amazon S3 bucket is not
--     accessible.
--
-- -   @NO REPORT@ - No report was generated in the last 90 days.
--
-- 's3Location', 'describeReportCreationResponse_s3Location' - The path to the Amazon S3 bucket where the report was stored on
-- creation.
--
-- 'errorMessage', 'describeReportCreationResponse_errorMessage' - Details of the common errors that all operations return.
--
-- 'httpStatus', 'describeReportCreationResponse_httpStatus' - The response's http status code.
newDescribeReportCreationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeReportCreationResponse
newDescribeReportCreationResponse :: Int -> DescribeReportCreationResponse
newDescribeReportCreationResponse Int
pHttpStatus_ =
  DescribeReportCreationResponse' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> DescribeReportCreationResponse
DescribeReportCreationResponse'
    { $sel:status:DescribeReportCreationResponse' :: Maybe Text
status =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Location:DescribeReportCreationResponse' :: Maybe Text
s3Location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:DescribeReportCreationResponse' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeReportCreationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Reports the status of the operation.
--
-- The operation status can be one of the following:
--
-- -   @RUNNING@ - Report creation is in progress.
--
-- -   @SUCCEEDED@ - Report creation is complete. You can open the report
--     from the Amazon S3 bucket that you specified when you ran
--     @StartReportCreation@.
--
-- -   @FAILED@ - Report creation timed out or the Amazon S3 bucket is not
--     accessible.
--
-- -   @NO REPORT@ - No report was generated in the last 90 days.
describeReportCreationResponse_status :: Lens.Lens' DescribeReportCreationResponse (Prelude.Maybe Prelude.Text)
describeReportCreationResponse_status :: (Maybe Text -> f (Maybe Text))
-> DescribeReportCreationResponse
-> f DescribeReportCreationResponse
describeReportCreationResponse_status = (DescribeReportCreationResponse -> Maybe Text)
-> (DescribeReportCreationResponse
    -> Maybe Text -> DescribeReportCreationResponse)
-> Lens
     DescribeReportCreationResponse
     DescribeReportCreationResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeReportCreationResponse' {Maybe Text
status :: Maybe Text
$sel:status:DescribeReportCreationResponse' :: DescribeReportCreationResponse -> Maybe Text
status} -> Maybe Text
status) (\s :: DescribeReportCreationResponse
s@DescribeReportCreationResponse' {} Maybe Text
a -> DescribeReportCreationResponse
s {$sel:status:DescribeReportCreationResponse' :: Maybe Text
status = Maybe Text
a} :: DescribeReportCreationResponse)

-- | The path to the Amazon S3 bucket where the report was stored on
-- creation.
describeReportCreationResponse_s3Location :: Lens.Lens' DescribeReportCreationResponse (Prelude.Maybe Prelude.Text)
describeReportCreationResponse_s3Location :: (Maybe Text -> f (Maybe Text))
-> DescribeReportCreationResponse
-> f DescribeReportCreationResponse
describeReportCreationResponse_s3Location = (DescribeReportCreationResponse -> Maybe Text)
-> (DescribeReportCreationResponse
    -> Maybe Text -> DescribeReportCreationResponse)
-> Lens
     DescribeReportCreationResponse
     DescribeReportCreationResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeReportCreationResponse' {Maybe Text
s3Location :: Maybe Text
$sel:s3Location:DescribeReportCreationResponse' :: DescribeReportCreationResponse -> Maybe Text
s3Location} -> Maybe Text
s3Location) (\s :: DescribeReportCreationResponse
s@DescribeReportCreationResponse' {} Maybe Text
a -> DescribeReportCreationResponse
s {$sel:s3Location:DescribeReportCreationResponse' :: Maybe Text
s3Location = Maybe Text
a} :: DescribeReportCreationResponse)

-- | Details of the common errors that all operations return.
describeReportCreationResponse_errorMessage :: Lens.Lens' DescribeReportCreationResponse (Prelude.Maybe Prelude.Text)
describeReportCreationResponse_errorMessage :: (Maybe Text -> f (Maybe Text))
-> DescribeReportCreationResponse
-> f DescribeReportCreationResponse
describeReportCreationResponse_errorMessage = (DescribeReportCreationResponse -> Maybe Text)
-> (DescribeReportCreationResponse
    -> Maybe Text -> DescribeReportCreationResponse)
-> Lens
     DescribeReportCreationResponse
     DescribeReportCreationResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeReportCreationResponse' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:DescribeReportCreationResponse' :: DescribeReportCreationResponse -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: DescribeReportCreationResponse
s@DescribeReportCreationResponse' {} Maybe Text
a -> DescribeReportCreationResponse
s {$sel:errorMessage:DescribeReportCreationResponse' :: Maybe Text
errorMessage = Maybe Text
a} :: DescribeReportCreationResponse)

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

instance
  Prelude.NFData
    DescribeReportCreationResponse