{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$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 :: Lens' StartReportCreation Text
startReportCreation_s3Bucket = 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 :: (Service -> Service)
-> StartReportCreation -> Request StartReportCreation
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 StartReportCreation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartReportCreation)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StartReportCreationResponse
StartReportCreationResponse'
            forall (f :: * -> *) a b. Functor 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 StartReportCreation where
  hashWithSalt :: Int -> StartReportCreation -> Int
hashWithSalt Int
_salt StartReportCreation' {Text
s3Bucket :: Text
$sel:s3Bucket:StartReportCreation' :: StartReportCreation -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3Bucket

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

instance Data.ToHeaders StartReportCreation where
  toHeaders :: StartReportCreation -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"ResourceGroupsTaggingAPI_20170126.StartReportCreation" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StartReportCreation where
  toJSON :: StartReportCreation -> Value
toJSON StartReportCreation' {Text
s3Bucket :: Text
$sel:s3Bucket:StartReportCreation' :: StartReportCreation -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"S3Bucket" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3Bucket)]
      )

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

instance Data.ToQuery StartReportCreation where
  toQuery :: StartReportCreation -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:httpStatus:StartReportCreationResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
startReportCreationResponse_httpStatus :: Lens.Lens' StartReportCreationResponse Prelude.Int
startReportCreationResponse_httpStatus :: Lens' StartReportCreationResponse Int
startReportCreationResponse_httpStatus = 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 where
  rnf :: StartReportCreationResponse -> ()
rnf StartReportCreationResponse' {Int
httpStatus :: Int
$sel:httpStatus:StartReportCreationResponse' :: StartReportCreationResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus