{-# 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.FSx.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 name of an Amazon FSx for OpenZFS snapshot.
module Amazonka.FSx.UpdateSnapshot
  ( -- * Creating a Request
    UpdateSnapshot (..),
    newUpdateSnapshot,

    -- * Request Lenses
    updateSnapshot_clientRequestToken,
    updateSnapshot_name,
    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.FSx.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'
  { UpdateSnapshot -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the snapshot to update.
    UpdateSnapshot -> Text
name :: Prelude.Text,
    -- | The ID of the snapshot that you want to update, in the format
    -- @fsvolsnap-0123456789abcdef0@.
    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:
--
-- 'clientRequestToken', 'updateSnapshot_clientRequestToken' - Undocumented member.
--
-- 'name', 'updateSnapshot_name' - The name of the snapshot to update.
--
-- 'snapshotId', 'updateSnapshot_snapshotId' - The ID of the snapshot that you want to update, in the format
-- @fsvolsnap-0123456789abcdef0@.
newUpdateSnapshot ::
  -- | 'name'
  Prelude.Text ->
  -- | 'snapshotId'
  Prelude.Text ->
  UpdateSnapshot
newUpdateSnapshot :: Text -> Text -> UpdateSnapshot
newUpdateSnapshot Text
pName_ Text
pSnapshotId_ =
  UpdateSnapshot'
    { $sel:clientRequestToken:UpdateSnapshot' :: Maybe Text
clientRequestToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateSnapshot' :: Text
name = Text
pName_,
      $sel:snapshotId:UpdateSnapshot' :: Text
snapshotId = Text
pSnapshotId_
    }

-- | Undocumented member.
updateSnapshot_clientRequestToken :: Lens.Lens' UpdateSnapshot (Prelude.Maybe Prelude.Text)
updateSnapshot_clientRequestToken :: Lens' UpdateSnapshot (Maybe Text)
updateSnapshot_clientRequestToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSnapshot' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:UpdateSnapshot' :: UpdateSnapshot -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: UpdateSnapshot
s@UpdateSnapshot' {} Maybe Text
a -> UpdateSnapshot
s {$sel:clientRequestToken:UpdateSnapshot' :: Maybe Text
clientRequestToken = Maybe Text
a} :: UpdateSnapshot)

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

-- | The ID of the snapshot that you want to update, in the format
-- @fsvolsnap-0123456789abcdef0@.
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.postJSON (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 Snapshot -> 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
name :: Text
clientRequestToken :: Maybe Text
$sel:snapshotId:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:name:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:clientRequestToken:UpdateSnapshot' :: UpdateSnapshot -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientRequestToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      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
name :: Text
clientRequestToken :: Maybe Text
$sel:snapshotId:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:name:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:clientRequestToken:UpdateSnapshot' :: UpdateSnapshot -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientRequestToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      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
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSSimbaAPIService_v20180301.UpdateSnapshot" ::
                          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 UpdateSnapshot where
  toJSON :: UpdateSnapshot -> Value
toJSON UpdateSnapshot' {Maybe Text
Text
snapshotId :: Text
name :: Text
clientRequestToken :: Maybe Text
$sel:snapshotId:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:name:UpdateSnapshot' :: UpdateSnapshot -> Text
$sel:clientRequestToken:UpdateSnapshot' :: UpdateSnapshot -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ClientRequestToken" 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
clientRequestToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"SnapshotId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
snapshotId)
          ]
      )

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

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'
  { -- | Returned after a successful @UpdateSnapshot@ operation, describing the
    -- snapshot that you updated.
    UpdateSnapshotResponse -> Maybe Snapshot
snapshot :: Prelude.Maybe Snapshot,
    -- | 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' - Returned after a successful @UpdateSnapshot@ operation, describing the
-- snapshot that you updated.
--
-- '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 Snapshot
snapshot = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateSnapshotResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Returned after a successful @UpdateSnapshot@ operation, describing the
-- snapshot that you updated.
updateSnapshotResponse_snapshot :: Lens.Lens' UpdateSnapshotResponse (Prelude.Maybe Snapshot)
updateSnapshotResponse_snapshot :: Lens' UpdateSnapshotResponse (Maybe Snapshot)
updateSnapshotResponse_snapshot = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSnapshotResponse' {Maybe Snapshot
snapshot :: Maybe Snapshot
$sel:snapshot:UpdateSnapshotResponse' :: UpdateSnapshotResponse -> Maybe Snapshot
snapshot} -> Maybe Snapshot
snapshot) (\s :: UpdateSnapshotResponse
s@UpdateSnapshotResponse' {} Maybe Snapshot
a -> UpdateSnapshotResponse
s {$sel:snapshot:UpdateSnapshotResponse' :: Maybe Snapshot
snapshot = Maybe Snapshot
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 Snapshot
httpStatus :: Int
snapshot :: Maybe Snapshot
$sel:httpStatus:UpdateSnapshotResponse' :: UpdateSnapshotResponse -> Int
$sel:snapshot:UpdateSnapshotResponse' :: UpdateSnapshotResponse -> Maybe Snapshot
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Snapshot
snapshot
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus