{-# 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.CostAndUsageReport.PutReportDefinition
-- 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)
--
-- Creates a new report using the description that you provide.
module Amazonka.CostAndUsageReport.PutReportDefinition
  ( -- * Creating a Request
    PutReportDefinition (..),
    newPutReportDefinition,

    -- * Request Lenses
    putReportDefinition_reportDefinition,

    -- * Destructuring the Response
    PutReportDefinitionResponse (..),
    newPutReportDefinitionResponse,

    -- * Response Lenses
    putReportDefinitionResponse_httpStatus,
  )
where

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

-- | Creates a Cost and Usage Report.
--
-- /See:/ 'newPutReportDefinition' smart constructor.
data PutReportDefinition = PutReportDefinition'
  { -- | Represents the output of the PutReportDefinition operation. The content
    -- consists of the detailed metadata and data file information.
    PutReportDefinition -> ReportDefinition
reportDefinition :: ReportDefinition
  }
  deriving (PutReportDefinition -> PutReportDefinition -> Bool
(PutReportDefinition -> PutReportDefinition -> Bool)
-> (PutReportDefinition -> PutReportDefinition -> Bool)
-> Eq PutReportDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutReportDefinition -> PutReportDefinition -> Bool
$c/= :: PutReportDefinition -> PutReportDefinition -> Bool
== :: PutReportDefinition -> PutReportDefinition -> Bool
$c== :: PutReportDefinition -> PutReportDefinition -> Bool
Prelude.Eq, ReadPrec [PutReportDefinition]
ReadPrec PutReportDefinition
Int -> ReadS PutReportDefinition
ReadS [PutReportDefinition]
(Int -> ReadS PutReportDefinition)
-> ReadS [PutReportDefinition]
-> ReadPrec PutReportDefinition
-> ReadPrec [PutReportDefinition]
-> Read PutReportDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutReportDefinition]
$creadListPrec :: ReadPrec [PutReportDefinition]
readPrec :: ReadPrec PutReportDefinition
$creadPrec :: ReadPrec PutReportDefinition
readList :: ReadS [PutReportDefinition]
$creadList :: ReadS [PutReportDefinition]
readsPrec :: Int -> ReadS PutReportDefinition
$creadsPrec :: Int -> ReadS PutReportDefinition
Prelude.Read, Int -> PutReportDefinition -> ShowS
[PutReportDefinition] -> ShowS
PutReportDefinition -> String
(Int -> PutReportDefinition -> ShowS)
-> (PutReportDefinition -> String)
-> ([PutReportDefinition] -> ShowS)
-> Show PutReportDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutReportDefinition] -> ShowS
$cshowList :: [PutReportDefinition] -> ShowS
show :: PutReportDefinition -> String
$cshow :: PutReportDefinition -> String
showsPrec :: Int -> PutReportDefinition -> ShowS
$cshowsPrec :: Int -> PutReportDefinition -> ShowS
Prelude.Show, (forall x. PutReportDefinition -> Rep PutReportDefinition x)
-> (forall x. Rep PutReportDefinition x -> PutReportDefinition)
-> Generic PutReportDefinition
forall x. Rep PutReportDefinition x -> PutReportDefinition
forall x. PutReportDefinition -> Rep PutReportDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutReportDefinition x -> PutReportDefinition
$cfrom :: forall x. PutReportDefinition -> Rep PutReportDefinition x
Prelude.Generic)

-- |
-- Create a value of 'PutReportDefinition' 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:
--
-- 'reportDefinition', 'putReportDefinition_reportDefinition' - Represents the output of the PutReportDefinition operation. The content
-- consists of the detailed metadata and data file information.
newPutReportDefinition ::
  -- | 'reportDefinition'
  ReportDefinition ->
  PutReportDefinition
newPutReportDefinition :: ReportDefinition -> PutReportDefinition
newPutReportDefinition ReportDefinition
pReportDefinition_ =
  PutReportDefinition' :: ReportDefinition -> PutReportDefinition
PutReportDefinition'
    { $sel:reportDefinition:PutReportDefinition' :: ReportDefinition
reportDefinition =
        ReportDefinition
pReportDefinition_
    }

-- | Represents the output of the PutReportDefinition operation. The content
-- consists of the detailed metadata and data file information.
putReportDefinition_reportDefinition :: Lens.Lens' PutReportDefinition ReportDefinition
putReportDefinition_reportDefinition :: (ReportDefinition -> f ReportDefinition)
-> PutReportDefinition -> f PutReportDefinition
putReportDefinition_reportDefinition = (PutReportDefinition -> ReportDefinition)
-> (PutReportDefinition -> ReportDefinition -> PutReportDefinition)
-> Lens
     PutReportDefinition
     PutReportDefinition
     ReportDefinition
     ReportDefinition
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutReportDefinition' {ReportDefinition
reportDefinition :: ReportDefinition
$sel:reportDefinition:PutReportDefinition' :: PutReportDefinition -> ReportDefinition
reportDefinition} -> ReportDefinition
reportDefinition) (\s :: PutReportDefinition
s@PutReportDefinition' {} ReportDefinition
a -> PutReportDefinition
s {$sel:reportDefinition:PutReportDefinition' :: ReportDefinition
reportDefinition = ReportDefinition
a} :: PutReportDefinition)

instance Core.AWSRequest PutReportDefinition where
  type
    AWSResponse PutReportDefinition =
      PutReportDefinitionResponse
  request :: PutReportDefinition -> Request PutReportDefinition
request = Service -> PutReportDefinition -> Request PutReportDefinition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutReportDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutReportDefinition)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutReportDefinition))
-> Logger
-> Service
-> Proxy PutReportDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutReportDefinition)))
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 -> PutReportDefinitionResponse
PutReportDefinitionResponse'
            (Int -> PutReportDefinitionResponse)
-> Either String Int -> Either String PutReportDefinitionResponse
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 PutReportDefinition

instance Prelude.NFData PutReportDefinition

instance Core.ToHeaders PutReportDefinition where
  toHeaders :: PutReportDefinition -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutReportDefinition -> 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
"AWSOrigamiServiceGatewayService.PutReportDefinition" ::
                          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 PutReportDefinition where
  toJSON :: PutReportDefinition -> Value
toJSON PutReportDefinition' {ReportDefinition
reportDefinition :: ReportDefinition
$sel:reportDefinition:PutReportDefinition' :: PutReportDefinition -> ReportDefinition
..} =
    [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
"ReportDefinition" Text -> ReportDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ReportDefinition
reportDefinition)
          ]
      )

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

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

-- | If the action is successful, the service sends back an HTTP 200 response
-- with an empty HTTP body.
--
-- /See:/ 'newPutReportDefinitionResponse' smart constructor.
data PutReportDefinitionResponse = PutReportDefinitionResponse'
  { -- | The response's http status code.
    PutReportDefinitionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutReportDefinitionResponse -> PutReportDefinitionResponse -> Bool
(PutReportDefinitionResponse
 -> PutReportDefinitionResponse -> Bool)
-> (PutReportDefinitionResponse
    -> PutReportDefinitionResponse -> Bool)
-> Eq PutReportDefinitionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutReportDefinitionResponse -> PutReportDefinitionResponse -> Bool
$c/= :: PutReportDefinitionResponse -> PutReportDefinitionResponse -> Bool
== :: PutReportDefinitionResponse -> PutReportDefinitionResponse -> Bool
$c== :: PutReportDefinitionResponse -> PutReportDefinitionResponse -> Bool
Prelude.Eq, ReadPrec [PutReportDefinitionResponse]
ReadPrec PutReportDefinitionResponse
Int -> ReadS PutReportDefinitionResponse
ReadS [PutReportDefinitionResponse]
(Int -> ReadS PutReportDefinitionResponse)
-> ReadS [PutReportDefinitionResponse]
-> ReadPrec PutReportDefinitionResponse
-> ReadPrec [PutReportDefinitionResponse]
-> Read PutReportDefinitionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutReportDefinitionResponse]
$creadListPrec :: ReadPrec [PutReportDefinitionResponse]
readPrec :: ReadPrec PutReportDefinitionResponse
$creadPrec :: ReadPrec PutReportDefinitionResponse
readList :: ReadS [PutReportDefinitionResponse]
$creadList :: ReadS [PutReportDefinitionResponse]
readsPrec :: Int -> ReadS PutReportDefinitionResponse
$creadsPrec :: Int -> ReadS PutReportDefinitionResponse
Prelude.Read, Int -> PutReportDefinitionResponse -> ShowS
[PutReportDefinitionResponse] -> ShowS
PutReportDefinitionResponse -> String
(Int -> PutReportDefinitionResponse -> ShowS)
-> (PutReportDefinitionResponse -> String)
-> ([PutReportDefinitionResponse] -> ShowS)
-> Show PutReportDefinitionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutReportDefinitionResponse] -> ShowS
$cshowList :: [PutReportDefinitionResponse] -> ShowS
show :: PutReportDefinitionResponse -> String
$cshow :: PutReportDefinitionResponse -> String
showsPrec :: Int -> PutReportDefinitionResponse -> ShowS
$cshowsPrec :: Int -> PutReportDefinitionResponse -> ShowS
Prelude.Show, (forall x.
 PutReportDefinitionResponse -> Rep PutReportDefinitionResponse x)
-> (forall x.
    Rep PutReportDefinitionResponse x -> PutReportDefinitionResponse)
-> Generic PutReportDefinitionResponse
forall x.
Rep PutReportDefinitionResponse x -> PutReportDefinitionResponse
forall x.
PutReportDefinitionResponse -> Rep PutReportDefinitionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutReportDefinitionResponse x -> PutReportDefinitionResponse
$cfrom :: forall x.
PutReportDefinitionResponse -> Rep PutReportDefinitionResponse x
Prelude.Generic)

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

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

instance Prelude.NFData PutReportDefinitionResponse