{-# 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.UpdateSnapshot
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the metadata of a GameSparks snapshot.
module Amazonka.GamesParks.UpdateSnapshot
  ( -- * Creating a Request
    UpdateSnapshot (..),
    newUpdateSnapshot,

    -- * Request Lenses
    updateSnapshot_description,
    updateSnapshot_gameName,
    updateSnapshot_snapshotId,

    -- * Destructuring the Response
    UpdateSnapshotResponse (..),
    newUpdateSnapshotResponse,

    -- * Response Lenses
    updateSnapshotResponse_snapshot,
    updateSnapshotResponse_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:/ 'newUpdateSnapshot' smart constructor.
data UpdateSnapshot = UpdateSnapshot'
  { -- | The description of the snapshot.
    UpdateSnapshot -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the game.
    UpdateSnapshot -> Text
gameName :: Prelude.Text,
    -- | The identifier of the snapshot.
    UpdateSnapshot -> Text
snapshotId :: Prelude.Text
  }
  deriving (UpdateSnapshot -> UpdateSnapshot -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSnapshot -> UpdateSnapshot -> Bool
$c/= :: UpdateSnapshot -> UpdateSnapshot -> Bool
== :: UpdateSnapshot -> UpdateSnapshot -> Bool
$c== :: UpdateSnapshot -> UpdateSnapshot -> Bool
Prelude.Eq, ReadPrec [UpdateSnapshot]
ReadPrec UpdateSnapshot
Int -> ReadS UpdateSnapshot
ReadS [UpdateSnapshot]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSnapshot]
$creadListPrec :: ReadPrec [UpdateSnapshot]
readPrec :: ReadPrec UpdateSnapshot
$creadPrec :: ReadPrec UpdateSnapshot
readList :: ReadS [UpdateSnapshot]
$creadList :: ReadS [UpdateSnapshot]
readsPrec :: Int -> ReadS UpdateSnapshot
$creadsPrec :: Int -> ReadS UpdateSnapshot
Prelude.Read, Int -> UpdateSnapshot -> ShowS
[UpdateSnapshot] -> ShowS
UpdateSnapshot -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSnapshot] -> ShowS
$cshowList :: [UpdateSnapshot] -> ShowS
show :: UpdateSnapshot -> String
$cshow :: UpdateSnapshot -> String
showsPrec :: Int -> UpdateSnapshot -> ShowS
$cshowsPrec :: Int -> UpdateSnapshot -> ShowS
Prelude.Show, forall x. Rep UpdateSnapshot x -> UpdateSnapshot
forall x. UpdateSnapshot -> Rep UpdateSnapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSnapshot x -> UpdateSnapshot
$cfrom :: forall x. UpdateSnapshot -> Rep UpdateSnapshot x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSnapshot' 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:
--
-- 'description', 'updateSnapshot_description' - The description of the snapshot.
--
-- 'gameName', 'updateSnapshot_gameName' - The name of the game.
--
-- 'snapshotId', 'updateSnapshot_snapshotId' - The identifier of the snapshot.
newUpdateSnapshot ::
  -- | 'gameName'
  Prelude.Text ->
  -- | 'snapshotId'
  Prelude.Text ->
  UpdateSnapshot
newUpdateSnapshot :: Text -> Text -> UpdateSnapshot
newUpdateSnapshot Text
pGameName_ Text
pSnapshotId_ =
  UpdateSnapshot'
    { $sel:description:UpdateSnapshot' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:gameName:UpdateSnapshot' :: Text
gameName = Text
pGameName_,
      $sel:snapshotId:UpdateSnapshot' :: Text
snapshotId = Text
pSnapshotId_
    }

-- | The description of the snapshot.
updateSnapshot_description :: Lens.Lens' UpdateSnapshot (Prelude.Maybe Prelude.Text)
updateSnapshot_description :: Lens' UpdateSnapshot (Maybe Text)
updateSnapshot_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSnapshot' {Maybe Text
description :: Maybe Text
$sel:description:UpdateSnapshot' :: UpdateSnapshot -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateSnapshot
s@UpdateSnapshot' {} Maybe Text
a -> UpdateSnapshot
s {$sel:description:UpdateSnapshot' :: Maybe Text
description = Maybe Text
a} :: UpdateSnapshot)

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

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

instance Core.AWSRequest UpdateSnapshot where
  type
    AWSResponse UpdateSnapshot =
      UpdateSnapshotResponse
  request :: (Service -> Service) -> UpdateSnapshot -> Request UpdateSnapshot
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateSnapshot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateSnapshot)))
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 SnapshotDetails -> Int -> UpdateSnapshotResponse
UpdateSnapshotResponse'
            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
"Snapshot")
            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 UpdateSnapshot where
  hashWithSalt :: Int -> UpdateSnapshot -> Int
hashWithSalt Int
_salt UpdateSnapshot' {Maybe Text
Text
snapshotId :: Text
gameName :: Text
description :: Maybe Text
$sel:snapshotId:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:gameName:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:description:UpdateSnapshot' :: UpdateSnapshot -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      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 UpdateSnapshot where
  rnf :: UpdateSnapshot -> ()
rnf UpdateSnapshot' {Maybe Text
Text
snapshotId :: Text
gameName :: Text
description :: Maybe Text
$sel:snapshotId:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:gameName:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:description:UpdateSnapshot' :: UpdateSnapshot -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 UpdateSnapshot where
  toHeaders :: UpdateSnapshot -> 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.ToJSON UpdateSnapshot where
  toJSON :: UpdateSnapshot -> Value
toJSON UpdateSnapshot' {Maybe Text
Text
snapshotId :: Text
gameName :: Text
description :: Maybe Text
$sel:snapshotId:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:gameName:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:description:UpdateSnapshot' :: UpdateSnapshot -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description]
      )

instance Data.ToPath UpdateSnapshot where
  toPath :: UpdateSnapshot -> ByteString
toPath UpdateSnapshot' {Maybe Text
Text
snapshotId :: Text
gameName :: Text
description :: Maybe Text
$sel:snapshotId:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:gameName:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:description:UpdateSnapshot' :: UpdateSnapshot -> Maybe 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
      ]

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

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

-- |
-- Create a value of 'UpdateSnapshotResponse' 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:
--
-- 'snapshot', 'updateSnapshotResponse_snapshot' - Properties that provide details of the updated snapshot.
--
-- 'httpStatus', 'updateSnapshotResponse_httpStatus' - The response's http status code.
newUpdateSnapshotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateSnapshotResponse
newUpdateSnapshotResponse :: Int -> UpdateSnapshotResponse
newUpdateSnapshotResponse Int
pHttpStatus_ =
  UpdateSnapshotResponse'
    { $sel:snapshot:UpdateSnapshotResponse' :: Maybe SnapshotDetails
snapshot = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateSnapshotResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Properties that provide details of the updated snapshot.
updateSnapshotResponse_snapshot :: Lens.Lens' UpdateSnapshotResponse (Prelude.Maybe SnapshotDetails)
updateSnapshotResponse_snapshot :: Lens' UpdateSnapshotResponse (Maybe SnapshotDetails)
updateSnapshotResponse_snapshot = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSnapshotResponse' {Maybe SnapshotDetails
snapshot :: Maybe SnapshotDetails
$sel:snapshot:UpdateSnapshotResponse' :: UpdateSnapshotResponse -> Maybe SnapshotDetails
snapshot} -> Maybe SnapshotDetails
snapshot) (\s :: UpdateSnapshotResponse
s@UpdateSnapshotResponse' {} Maybe SnapshotDetails
a -> UpdateSnapshotResponse
s {$sel:snapshot:UpdateSnapshotResponse' :: Maybe SnapshotDetails
snapshot = Maybe SnapshotDetails
a} :: UpdateSnapshotResponse)

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

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