{-# 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.AppStream.CreateUsageReportSubscription
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a usage report subscription. Usage reports are generated daily.
module Amazonka.AppStream.CreateUsageReportSubscription
  ( -- * Creating a Request
    CreateUsageReportSubscription (..),
    newCreateUsageReportSubscription,

    -- * Destructuring the Response
    CreateUsageReportSubscriptionResponse (..),
    newCreateUsageReportSubscriptionResponse,

    -- * Response Lenses
    createUsageReportSubscriptionResponse_s3BucketName,
    createUsageReportSubscriptionResponse_schedule,
    createUsageReportSubscriptionResponse_httpStatus,
  )
where

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

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

instance
  Core.AWSRequest
    CreateUsageReportSubscription
  where
  type
    AWSResponse CreateUsageReportSubscription =
      CreateUsageReportSubscriptionResponse
  request :: (Service -> Service)
-> CreateUsageReportSubscription
-> Request CreateUsageReportSubscription
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 CreateUsageReportSubscription
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateUsageReportSubscription)))
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 Text
-> Maybe UsageReportSchedule
-> Int
-> CreateUsageReportSubscriptionResponse
CreateUsageReportSubscriptionResponse'
            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
"S3BucketName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Schedule")
            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
    CreateUsageReportSubscription
  where
  hashWithSalt :: Int -> CreateUsageReportSubscription -> Int
hashWithSalt Int
_salt CreateUsageReportSubscription
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData CreateUsageReportSubscription where
  rnf :: CreateUsageReportSubscription -> ()
rnf CreateUsageReportSubscription
_ = ()

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

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

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

-- | /See:/ 'newCreateUsageReportSubscriptionResponse' smart constructor.
data CreateUsageReportSubscriptionResponse = CreateUsageReportSubscriptionResponse'
  { -- | The Amazon S3 bucket where generated reports are stored.
    --
    -- If you enabled on-instance session scripts and Amazon S3 logging for
    -- your session script configuration, AppStream 2.0 created an S3 bucket to
    -- store the script output. The bucket is unique to your account and
    -- Region. When you enable usage reporting in this case, AppStream 2.0 uses
    -- the same bucket to store your usage reports. If you haven\'t already
    -- enabled on-instance session scripts, when you enable usage reports,
    -- AppStream 2.0 creates a new S3 bucket.
    CreateUsageReportSubscriptionResponse -> Maybe Text
s3BucketName :: Prelude.Maybe Prelude.Text,
    -- | The schedule for generating usage reports.
    CreateUsageReportSubscriptionResponse -> Maybe UsageReportSchedule
schedule :: Prelude.Maybe UsageReportSchedule,
    -- | The response's http status code.
    CreateUsageReportSubscriptionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateUsageReportSubscriptionResponse
-> CreateUsageReportSubscriptionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateUsageReportSubscriptionResponse
-> CreateUsageReportSubscriptionResponse -> Bool
$c/= :: CreateUsageReportSubscriptionResponse
-> CreateUsageReportSubscriptionResponse -> Bool
== :: CreateUsageReportSubscriptionResponse
-> CreateUsageReportSubscriptionResponse -> Bool
$c== :: CreateUsageReportSubscriptionResponse
-> CreateUsageReportSubscriptionResponse -> Bool
Prelude.Eq, ReadPrec [CreateUsageReportSubscriptionResponse]
ReadPrec CreateUsageReportSubscriptionResponse
Int -> ReadS CreateUsageReportSubscriptionResponse
ReadS [CreateUsageReportSubscriptionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateUsageReportSubscriptionResponse]
$creadListPrec :: ReadPrec [CreateUsageReportSubscriptionResponse]
readPrec :: ReadPrec CreateUsageReportSubscriptionResponse
$creadPrec :: ReadPrec CreateUsageReportSubscriptionResponse
readList :: ReadS [CreateUsageReportSubscriptionResponse]
$creadList :: ReadS [CreateUsageReportSubscriptionResponse]
readsPrec :: Int -> ReadS CreateUsageReportSubscriptionResponse
$creadsPrec :: Int -> ReadS CreateUsageReportSubscriptionResponse
Prelude.Read, Int -> CreateUsageReportSubscriptionResponse -> ShowS
[CreateUsageReportSubscriptionResponse] -> ShowS
CreateUsageReportSubscriptionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateUsageReportSubscriptionResponse] -> ShowS
$cshowList :: [CreateUsageReportSubscriptionResponse] -> ShowS
show :: CreateUsageReportSubscriptionResponse -> String
$cshow :: CreateUsageReportSubscriptionResponse -> String
showsPrec :: Int -> CreateUsageReportSubscriptionResponse -> ShowS
$cshowsPrec :: Int -> CreateUsageReportSubscriptionResponse -> ShowS
Prelude.Show, forall x.
Rep CreateUsageReportSubscriptionResponse x
-> CreateUsageReportSubscriptionResponse
forall x.
CreateUsageReportSubscriptionResponse
-> Rep CreateUsageReportSubscriptionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateUsageReportSubscriptionResponse x
-> CreateUsageReportSubscriptionResponse
$cfrom :: forall x.
CreateUsageReportSubscriptionResponse
-> Rep CreateUsageReportSubscriptionResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateUsageReportSubscriptionResponse' 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:
--
-- 's3BucketName', 'createUsageReportSubscriptionResponse_s3BucketName' - The Amazon S3 bucket where generated reports are stored.
--
-- If you enabled on-instance session scripts and Amazon S3 logging for
-- your session script configuration, AppStream 2.0 created an S3 bucket to
-- store the script output. The bucket is unique to your account and
-- Region. When you enable usage reporting in this case, AppStream 2.0 uses
-- the same bucket to store your usage reports. If you haven\'t already
-- enabled on-instance session scripts, when you enable usage reports,
-- AppStream 2.0 creates a new S3 bucket.
--
-- 'schedule', 'createUsageReportSubscriptionResponse_schedule' - The schedule for generating usage reports.
--
-- 'httpStatus', 'createUsageReportSubscriptionResponse_httpStatus' - The response's http status code.
newCreateUsageReportSubscriptionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateUsageReportSubscriptionResponse
newCreateUsageReportSubscriptionResponse :: Int -> CreateUsageReportSubscriptionResponse
newCreateUsageReportSubscriptionResponse Int
pHttpStatus_ =
  CreateUsageReportSubscriptionResponse'
    { $sel:s3BucketName:CreateUsageReportSubscriptionResponse' :: Maybe Text
s3BucketName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:schedule:CreateUsageReportSubscriptionResponse' :: Maybe UsageReportSchedule
schedule = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateUsageReportSubscriptionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon S3 bucket where generated reports are stored.
--
-- If you enabled on-instance session scripts and Amazon S3 logging for
-- your session script configuration, AppStream 2.0 created an S3 bucket to
-- store the script output. The bucket is unique to your account and
-- Region. When you enable usage reporting in this case, AppStream 2.0 uses
-- the same bucket to store your usage reports. If you haven\'t already
-- enabled on-instance session scripts, when you enable usage reports,
-- AppStream 2.0 creates a new S3 bucket.
createUsageReportSubscriptionResponse_s3BucketName :: Lens.Lens' CreateUsageReportSubscriptionResponse (Prelude.Maybe Prelude.Text)
createUsageReportSubscriptionResponse_s3BucketName :: Lens' CreateUsageReportSubscriptionResponse (Maybe Text)
createUsageReportSubscriptionResponse_s3BucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUsageReportSubscriptionResponse' {Maybe Text
s3BucketName :: Maybe Text
$sel:s3BucketName:CreateUsageReportSubscriptionResponse' :: CreateUsageReportSubscriptionResponse -> Maybe Text
s3BucketName} -> Maybe Text
s3BucketName) (\s :: CreateUsageReportSubscriptionResponse
s@CreateUsageReportSubscriptionResponse' {} Maybe Text
a -> CreateUsageReportSubscriptionResponse
s {$sel:s3BucketName:CreateUsageReportSubscriptionResponse' :: Maybe Text
s3BucketName = Maybe Text
a} :: CreateUsageReportSubscriptionResponse)

-- | The schedule for generating usage reports.
createUsageReportSubscriptionResponse_schedule :: Lens.Lens' CreateUsageReportSubscriptionResponse (Prelude.Maybe UsageReportSchedule)
createUsageReportSubscriptionResponse_schedule :: Lens'
  CreateUsageReportSubscriptionResponse (Maybe UsageReportSchedule)
createUsageReportSubscriptionResponse_schedule = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUsageReportSubscriptionResponse' {Maybe UsageReportSchedule
schedule :: Maybe UsageReportSchedule
$sel:schedule:CreateUsageReportSubscriptionResponse' :: CreateUsageReportSubscriptionResponse -> Maybe UsageReportSchedule
schedule} -> Maybe UsageReportSchedule
schedule) (\s :: CreateUsageReportSubscriptionResponse
s@CreateUsageReportSubscriptionResponse' {} Maybe UsageReportSchedule
a -> CreateUsageReportSubscriptionResponse
s {$sel:schedule:CreateUsageReportSubscriptionResponse' :: Maybe UsageReportSchedule
schedule = Maybe UsageReportSchedule
a} :: CreateUsageReportSubscriptionResponse)

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

instance
  Prelude.NFData
    CreateUsageReportSubscriptionResponse
  where
  rnf :: CreateUsageReportSubscriptionResponse -> ()
rnf CreateUsageReportSubscriptionResponse' {Int
Maybe Text
Maybe UsageReportSchedule
httpStatus :: Int
schedule :: Maybe UsageReportSchedule
s3BucketName :: Maybe Text
$sel:httpStatus:CreateUsageReportSubscriptionResponse' :: CreateUsageReportSubscriptionResponse -> Int
$sel:schedule:CreateUsageReportSubscriptionResponse' :: CreateUsageReportSubscriptionResponse -> Maybe UsageReportSchedule
$sel:s3BucketName:CreateUsageReportSubscriptionResponse' :: CreateUsageReportSubscriptionResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3BucketName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UsageReportSchedule
schedule
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus