{-# 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.GamesParks.ExportSnapshot
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Exports a game configuration snapshot.
module Amazonka.GamesParks.ExportSnapshot
  ( -- * Creating a Request
    ExportSnapshot (..),
    newExportSnapshot,

    -- * Request Lenses
    exportSnapshot_gameName,
    exportSnapshot_snapshotId,

    -- * Destructuring the Response
    ExportSnapshotResponse (..),
    newExportSnapshotResponse,

    -- * Response Lenses
    exportSnapshotResponse_s3Url,
    exportSnapshotResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GamesParks.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newExportSnapshot' smart constructor.
data ExportSnapshot = ExportSnapshot'
  { -- | The name of the game.
    ExportSnapshot -> Text
gameName :: Prelude.Text,
    -- | The identifier of the snapshot to export.
    ExportSnapshot -> Text
snapshotId :: Prelude.Text
  }
  deriving (ExportSnapshot -> ExportSnapshot -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportSnapshot -> ExportSnapshot -> Bool
$c/= :: ExportSnapshot -> ExportSnapshot -> Bool
== :: ExportSnapshot -> ExportSnapshot -> Bool
$c== :: ExportSnapshot -> ExportSnapshot -> Bool
Prelude.Eq, ReadPrec [ExportSnapshot]
ReadPrec ExportSnapshot
Int -> ReadS ExportSnapshot
ReadS [ExportSnapshot]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExportSnapshot]
$creadListPrec :: ReadPrec [ExportSnapshot]
readPrec :: ReadPrec ExportSnapshot
$creadPrec :: ReadPrec ExportSnapshot
readList :: ReadS [ExportSnapshot]
$creadList :: ReadS [ExportSnapshot]
readsPrec :: Int -> ReadS ExportSnapshot
$creadsPrec :: Int -> ReadS ExportSnapshot
Prelude.Read, Int -> ExportSnapshot -> ShowS
[ExportSnapshot] -> ShowS
ExportSnapshot -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportSnapshot] -> ShowS
$cshowList :: [ExportSnapshot] -> ShowS
show :: ExportSnapshot -> String
$cshow :: ExportSnapshot -> String
showsPrec :: Int -> ExportSnapshot -> ShowS
$cshowsPrec :: Int -> ExportSnapshot -> ShowS
Prelude.Show, forall x. Rep ExportSnapshot x -> ExportSnapshot
forall x. ExportSnapshot -> Rep ExportSnapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExportSnapshot x -> ExportSnapshot
$cfrom :: forall x. ExportSnapshot -> Rep ExportSnapshot x
Prelude.Generic)

-- |
-- Create a value of 'ExportSnapshot' 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:
--
-- 'gameName', 'exportSnapshot_gameName' - The name of the game.
--
-- 'snapshotId', 'exportSnapshot_snapshotId' - The identifier of the snapshot to export.
newExportSnapshot ::
  -- | 'gameName'
  Prelude.Text ->
  -- | 'snapshotId'
  Prelude.Text ->
  ExportSnapshot
newExportSnapshot :: Text -> Text -> ExportSnapshot
newExportSnapshot Text
pGameName_ Text
pSnapshotId_ =
  ExportSnapshot'
    { $sel:gameName:ExportSnapshot' :: Text
gameName = Text
pGameName_,
      $sel:snapshotId:ExportSnapshot' :: Text
snapshotId = Text
pSnapshotId_
    }

-- | The name of the game.
exportSnapshot_gameName :: Lens.Lens' ExportSnapshot Prelude.Text
exportSnapshot_gameName :: Lens' ExportSnapshot Text
exportSnapshot_gameName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportSnapshot' {Text
gameName :: Text
$sel:gameName:ExportSnapshot' :: ExportSnapshot -> Text
gameName} -> Text
gameName) (\s :: ExportSnapshot
s@ExportSnapshot' {} Text
a -> ExportSnapshot
s {$sel:gameName:ExportSnapshot' :: Text
gameName = Text
a} :: ExportSnapshot)

-- | The identifier of the snapshot to export.
exportSnapshot_snapshotId :: Lens.Lens' ExportSnapshot Prelude.Text
exportSnapshot_snapshotId :: Lens' ExportSnapshot Text
exportSnapshot_snapshotId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportSnapshot' {Text
snapshotId :: Text
$sel:snapshotId:ExportSnapshot' :: ExportSnapshot -> Text
snapshotId} -> Text
snapshotId) (\s :: ExportSnapshot
s@ExportSnapshot' {} Text
a -> ExportSnapshot
s {$sel:snapshotId:ExportSnapshot' :: Text
snapshotId = Text
a} :: ExportSnapshot)

instance Core.AWSRequest ExportSnapshot where
  type
    AWSResponse ExportSnapshot =
      ExportSnapshotResponse
  request :: (Service -> Service) -> ExportSnapshot -> Request ExportSnapshot
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ExportSnapshot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ExportSnapshot)))
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 -> Int -> ExportSnapshotResponse
ExportSnapshotResponse'
            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
"S3Url")
            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 ExportSnapshot where
  hashWithSalt :: Int -> ExportSnapshot -> Int
hashWithSalt Int
_salt ExportSnapshot' {Text
snapshotId :: Text
gameName :: Text
$sel:snapshotId:ExportSnapshot' :: ExportSnapshot -> Text
$sel:gameName:ExportSnapshot' :: ExportSnapshot -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gameName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
snapshotId

instance Prelude.NFData ExportSnapshot where
  rnf :: ExportSnapshot -> ()
rnf ExportSnapshot' {Text
snapshotId :: Text
gameName :: Text
$sel:snapshotId:ExportSnapshot' :: ExportSnapshot -> Text
$sel:gameName:ExportSnapshot' :: ExportSnapshot -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
gameName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
snapshotId

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

instance Data.ToPath ExportSnapshot where
  toPath :: ExportSnapshot -> ByteString
toPath ExportSnapshot' {Text
snapshotId :: Text
gameName :: Text
$sel:snapshotId:ExportSnapshot' :: ExportSnapshot -> Text
$sel:gameName:ExportSnapshot' :: ExportSnapshot -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/game/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
gameName,
        ByteString
"/snapshot/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
snapshotId,
        ByteString
"/export"
      ]

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

-- | /See:/ 'newExportSnapshotResponse' smart constructor.
data ExportSnapshotResponse = ExportSnapshotResponse'
  { -- | The presigned URL for the snapshot data.
    --
    -- This URL will be available for 10 minutes, and can be used to download
    -- the snapshot content. If the URL expires, a new one can be requested
    -- using the same operation.
    ExportSnapshotResponse -> Maybe Text
s3Url :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ExportSnapshotResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ExportSnapshotResponse -> ExportSnapshotResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportSnapshotResponse -> ExportSnapshotResponse -> Bool
$c/= :: ExportSnapshotResponse -> ExportSnapshotResponse -> Bool
== :: ExportSnapshotResponse -> ExportSnapshotResponse -> Bool
$c== :: ExportSnapshotResponse -> ExportSnapshotResponse -> Bool
Prelude.Eq, ReadPrec [ExportSnapshotResponse]
ReadPrec ExportSnapshotResponse
Int -> ReadS ExportSnapshotResponse
ReadS [ExportSnapshotResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExportSnapshotResponse]
$creadListPrec :: ReadPrec [ExportSnapshotResponse]
readPrec :: ReadPrec ExportSnapshotResponse
$creadPrec :: ReadPrec ExportSnapshotResponse
readList :: ReadS [ExportSnapshotResponse]
$creadList :: ReadS [ExportSnapshotResponse]
readsPrec :: Int -> ReadS ExportSnapshotResponse
$creadsPrec :: Int -> ReadS ExportSnapshotResponse
Prelude.Read, Int -> ExportSnapshotResponse -> ShowS
[ExportSnapshotResponse] -> ShowS
ExportSnapshotResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportSnapshotResponse] -> ShowS
$cshowList :: [ExportSnapshotResponse] -> ShowS
show :: ExportSnapshotResponse -> String
$cshow :: ExportSnapshotResponse -> String
showsPrec :: Int -> ExportSnapshotResponse -> ShowS
$cshowsPrec :: Int -> ExportSnapshotResponse -> ShowS
Prelude.Show, forall x. Rep ExportSnapshotResponse x -> ExportSnapshotResponse
forall x. ExportSnapshotResponse -> Rep ExportSnapshotResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExportSnapshotResponse x -> ExportSnapshotResponse
$cfrom :: forall x. ExportSnapshotResponse -> Rep ExportSnapshotResponse x
Prelude.Generic)

-- |
-- Create a value of 'ExportSnapshotResponse' 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:
--
-- 's3Url', 'exportSnapshotResponse_s3Url' - The presigned URL for the snapshot data.
--
-- This URL will be available for 10 minutes, and can be used to download
-- the snapshot content. If the URL expires, a new one can be requested
-- using the same operation.
--
-- 'httpStatus', 'exportSnapshotResponse_httpStatus' - The response's http status code.
newExportSnapshotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ExportSnapshotResponse
newExportSnapshotResponse :: Int -> ExportSnapshotResponse
newExportSnapshotResponse Int
pHttpStatus_ =
  ExportSnapshotResponse'
    { $sel:s3Url:ExportSnapshotResponse' :: Maybe Text
s3Url = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ExportSnapshotResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The presigned URL for the snapshot data.
--
-- This URL will be available for 10 minutes, and can be used to download
-- the snapshot content. If the URL expires, a new one can be requested
-- using the same operation.
exportSnapshotResponse_s3Url :: Lens.Lens' ExportSnapshotResponse (Prelude.Maybe Prelude.Text)
exportSnapshotResponse_s3Url :: Lens' ExportSnapshotResponse (Maybe Text)
exportSnapshotResponse_s3Url = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportSnapshotResponse' {Maybe Text
s3Url :: Maybe Text
$sel:s3Url:ExportSnapshotResponse' :: ExportSnapshotResponse -> Maybe Text
s3Url} -> Maybe Text
s3Url) (\s :: ExportSnapshotResponse
s@ExportSnapshotResponse' {} Maybe Text
a -> ExportSnapshotResponse
s {$sel:s3Url:ExportSnapshotResponse' :: Maybe Text
s3Url = Maybe Text
a} :: ExportSnapshotResponse)

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

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