{-# 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.StartReportCreation
-- 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)
--
-- Generates a report that lists all tagged resources in the accounts
-- across your organization and tells whether each resource is compliant
-- with the effective tag policy. Compliance data is refreshed daily. The
-- report is generated asynchronously.
--
-- The generated report is saved to the following location:
--
-- @s3:\/\/example-bucket\/AwsTagPolicies\/o-exampleorgid\/YYYY-MM-ddTHH:mm:ssZ\/report.csv@
--
-- You can call this operation only from the organization\'s management
-- account and from the us-east-1 Region.
module Amazonka.ResourceGroupsTagging.StartReportCreation
  ( -- * Creating a Request
    StartReportCreation (..),
    newStartReportCreation,

    -- * Request Lenses
    startReportCreation_s3Bucket,

    -- * Destructuring the Response
    StartReportCreationResponse (..),
    newStartReportCreationResponse,

    -- * Response Lenses
    startReportCreationResponse_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:/ 'newStartReportCreation' smart constructor.
data StartReportCreation = StartReportCreation'
  { -- | The name of the Amazon S3 bucket where the report will be stored; for
    -- example:
    --
    -- @awsexamplebucket@
    --
    -- For more information on S3 bucket requirements, including an example
    -- bucket policy, see the example S3 bucket policy on this page.
    StartReportCreation -> Text
s3Bucket :: Prelude.Text
  }
  deriving (StartReportCreation -> StartReportCreation -> Bool
(StartReportCreation -> StartReportCreation -> Bool)
-> (StartReportCreation -> StartReportCreation -> Bool)
-> Eq StartReportCreation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartReportCreation -> StartReportCreation -> Bool
$c/= :: StartReportCreation -> StartReportCreation -> Bool
== :: StartReportCreation -> StartReportCreation -> Bool
$c== :: StartReportCreation -> StartReportCreation -> Bool
Prelude.Eq, ReadPrec [StartReportCreation]
ReadPrec StartReportCreation
Int -> ReadS StartReportCreation
ReadS [StartReportCreation]
(Int -> ReadS StartReportCreation)
-> ReadS [StartReportCreation]
-> ReadPrec StartReportCreation
-> ReadPrec [StartReportCreation]
-> Read StartReportCreation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartReportCreation]
$creadListPrec :: ReadPrec [StartReportCreation]
readPrec :: ReadPrec StartReportCreation
$creadPrec :: ReadPrec StartReportCreation
readList :: ReadS [StartReportCreation]
$creadList :: ReadS [StartReportCreation]
readsPrec :: Int -> ReadS StartReportCreation
$creadsPrec :: Int -> ReadS StartReportCreation
Prelude.Read, Int -> StartReportCreation -> ShowS
[StartReportCreation] -> ShowS
StartReportCreation -> String
(Int -> StartReportCreation -> ShowS)
-> (StartReportCreation -> String)
-> ([StartReportCreation] -> ShowS)
-> Show StartReportCreation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartReportCreation] -> ShowS
$cshowList :: [StartReportCreation] -> ShowS
show :: StartReportCreation -> String
$cshow :: StartReportCreation -> String
showsPrec :: Int -> StartReportCreation -> ShowS
$cshowsPrec :: Int -> StartReportCreation -> ShowS
Prelude.Show, (forall x. StartReportCreation -> Rep StartReportCreation x)
-> (forall x. Rep StartReportCreation x -> StartReportCreation)
-> Generic StartReportCreation
forall x. Rep StartReportCreation x -> StartReportCreation
forall x. StartReportCreation -> Rep StartReportCreation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartReportCreation x -> StartReportCreation
$cfrom :: forall x. StartReportCreation -> Rep StartReportCreation x
Prelude.Generic)

-- |
-- Create a value of 'StartReportCreation' 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:
--
-- 's3Bucket', 'startReportCreation_s3Bucket' - The name of the Amazon S3 bucket where the report will be stored; for
-- example:
--
-- @awsexamplebucket@
--
-- For more information on S3 bucket requirements, including an example
-- bucket policy, see the example S3 bucket policy on this page.
newStartReportCreation ::
  -- | 's3Bucket'
  Prelude.Text ->
  StartReportCreation
newStartReportCreation :: Text -> StartReportCreation
newStartReportCreation Text
pS3Bucket_ =
  StartReportCreation' :: Text -> StartReportCreation
StartReportCreation' {$sel:s3Bucket:StartReportCreation' :: Text
s3Bucket = Text
pS3Bucket_}

-- | The name of the Amazon S3 bucket where the report will be stored; for
-- example:
--
-- @awsexamplebucket@
--
-- For more information on S3 bucket requirements, including an example
-- bucket policy, see the example S3 bucket policy on this page.
startReportCreation_s3Bucket :: Lens.Lens' StartReportCreation Prelude.Text
startReportCreation_s3Bucket :: (Text -> f Text) -> StartReportCreation -> f StartReportCreation
startReportCreation_s3Bucket = (StartReportCreation -> Text)
-> (StartReportCreation -> Text -> StartReportCreation)
-> Lens StartReportCreation StartReportCreation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartReportCreation' {Text
s3Bucket :: Text
$sel:s3Bucket:StartReportCreation' :: StartReportCreation -> Text
s3Bucket} -> Text
s3Bucket) (\s :: StartReportCreation
s@StartReportCreation' {} Text
a -> StartReportCreation
s {$sel:s3Bucket:StartReportCreation' :: Text
s3Bucket = Text
a} :: StartReportCreation)

instance Core.AWSRequest StartReportCreation where
  type
    AWSResponse StartReportCreation =
      StartReportCreationResponse
  request :: StartReportCreation -> Request StartReportCreation
request = Service -> StartReportCreation -> Request StartReportCreation
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartReportCreation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartReportCreation)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StartReportCreation))
-> Logger
-> Service
-> Proxy StartReportCreation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartReportCreation)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StartReportCreationResponse
StartReportCreationResponse'
            (Int -> StartReportCreationResponse)
-> Either String Int -> Either String StartReportCreationResponse
forall (f :: * -> *) a b. Functor 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 StartReportCreation

instance Prelude.NFData StartReportCreation

instance Core.ToHeaders StartReportCreation where
  toHeaders :: StartReportCreation -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartReportCreation -> 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.StartReportCreation" ::
                          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 StartReportCreation where
  toJSON :: StartReportCreation -> Value
toJSON StartReportCreation' {Text
s3Bucket :: Text
$sel:s3Bucket:StartReportCreation' :: StartReportCreation -> 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
"S3Bucket" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
s3Bucket)]
      )

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

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

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

-- |
-- Create a value of 'StartReportCreationResponse' 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:
--
-- 'httpStatus', 'startReportCreationResponse_httpStatus' - The response's http status code.
newStartReportCreationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartReportCreationResponse
newStartReportCreationResponse :: Int -> StartReportCreationResponse
newStartReportCreationResponse Int
pHttpStatus_ =
  StartReportCreationResponse' :: Int -> StartReportCreationResponse
StartReportCreationResponse'
    { $sel:httpStatus:StartReportCreationResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData StartReportCreationResponse