{-# 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.Lightsail.GetDiskSnapshot
-- 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)
--
-- Returns information about a specific block storage disk snapshot.
module Amazonka.Lightsail.GetDiskSnapshot
  ( -- * Creating a Request
    GetDiskSnapshot (..),
    newGetDiskSnapshot,

    -- * Request Lenses
    getDiskSnapshot_diskSnapshotName,

    -- * Destructuring the Response
    GetDiskSnapshotResponse (..),
    newGetDiskSnapshotResponse,

    -- * Response Lenses
    getDiskSnapshotResponse_diskSnapshot,
    getDiskSnapshotResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetDiskSnapshot' smart constructor.
data GetDiskSnapshot = GetDiskSnapshot'
  { -- | The name of the disk snapshot (e.g., @my-disk-snapshot@).
    GetDiskSnapshot -> Text
diskSnapshotName :: Prelude.Text
  }
  deriving (GetDiskSnapshot -> GetDiskSnapshot -> Bool
(GetDiskSnapshot -> GetDiskSnapshot -> Bool)
-> (GetDiskSnapshot -> GetDiskSnapshot -> Bool)
-> Eq GetDiskSnapshot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDiskSnapshot -> GetDiskSnapshot -> Bool
$c/= :: GetDiskSnapshot -> GetDiskSnapshot -> Bool
== :: GetDiskSnapshot -> GetDiskSnapshot -> Bool
$c== :: GetDiskSnapshot -> GetDiskSnapshot -> Bool
Prelude.Eq, ReadPrec [GetDiskSnapshot]
ReadPrec GetDiskSnapshot
Int -> ReadS GetDiskSnapshot
ReadS [GetDiskSnapshot]
(Int -> ReadS GetDiskSnapshot)
-> ReadS [GetDiskSnapshot]
-> ReadPrec GetDiskSnapshot
-> ReadPrec [GetDiskSnapshot]
-> Read GetDiskSnapshot
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDiskSnapshot]
$creadListPrec :: ReadPrec [GetDiskSnapshot]
readPrec :: ReadPrec GetDiskSnapshot
$creadPrec :: ReadPrec GetDiskSnapshot
readList :: ReadS [GetDiskSnapshot]
$creadList :: ReadS [GetDiskSnapshot]
readsPrec :: Int -> ReadS GetDiskSnapshot
$creadsPrec :: Int -> ReadS GetDiskSnapshot
Prelude.Read, Int -> GetDiskSnapshot -> ShowS
[GetDiskSnapshot] -> ShowS
GetDiskSnapshot -> String
(Int -> GetDiskSnapshot -> ShowS)
-> (GetDiskSnapshot -> String)
-> ([GetDiskSnapshot] -> ShowS)
-> Show GetDiskSnapshot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDiskSnapshot] -> ShowS
$cshowList :: [GetDiskSnapshot] -> ShowS
show :: GetDiskSnapshot -> String
$cshow :: GetDiskSnapshot -> String
showsPrec :: Int -> GetDiskSnapshot -> ShowS
$cshowsPrec :: Int -> GetDiskSnapshot -> ShowS
Prelude.Show, (forall x. GetDiskSnapshot -> Rep GetDiskSnapshot x)
-> (forall x. Rep GetDiskSnapshot x -> GetDiskSnapshot)
-> Generic GetDiskSnapshot
forall x. Rep GetDiskSnapshot x -> GetDiskSnapshot
forall x. GetDiskSnapshot -> Rep GetDiskSnapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDiskSnapshot x -> GetDiskSnapshot
$cfrom :: forall x. GetDiskSnapshot -> Rep GetDiskSnapshot x
Prelude.Generic)

-- |
-- Create a value of 'GetDiskSnapshot' 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:
--
-- 'diskSnapshotName', 'getDiskSnapshot_diskSnapshotName' - The name of the disk snapshot (e.g., @my-disk-snapshot@).
newGetDiskSnapshot ::
  -- | 'diskSnapshotName'
  Prelude.Text ->
  GetDiskSnapshot
newGetDiskSnapshot :: Text -> GetDiskSnapshot
newGetDiskSnapshot Text
pDiskSnapshotName_ =
  GetDiskSnapshot' :: Text -> GetDiskSnapshot
GetDiskSnapshot'
    { $sel:diskSnapshotName:GetDiskSnapshot' :: Text
diskSnapshotName =
        Text
pDiskSnapshotName_
    }

-- | The name of the disk snapshot (e.g., @my-disk-snapshot@).
getDiskSnapshot_diskSnapshotName :: Lens.Lens' GetDiskSnapshot Prelude.Text
getDiskSnapshot_diskSnapshotName :: (Text -> f Text) -> GetDiskSnapshot -> f GetDiskSnapshot
getDiskSnapshot_diskSnapshotName = (GetDiskSnapshot -> Text)
-> (GetDiskSnapshot -> Text -> GetDiskSnapshot)
-> Lens GetDiskSnapshot GetDiskSnapshot Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDiskSnapshot' {Text
diskSnapshotName :: Text
$sel:diskSnapshotName:GetDiskSnapshot' :: GetDiskSnapshot -> Text
diskSnapshotName} -> Text
diskSnapshotName) (\s :: GetDiskSnapshot
s@GetDiskSnapshot' {} Text
a -> GetDiskSnapshot
s {$sel:diskSnapshotName:GetDiskSnapshot' :: Text
diskSnapshotName = Text
a} :: GetDiskSnapshot)

instance Core.AWSRequest GetDiskSnapshot where
  type
    AWSResponse GetDiskSnapshot =
      GetDiskSnapshotResponse
  request :: GetDiskSnapshot -> Request GetDiskSnapshot
request = Service -> GetDiskSnapshot -> Request GetDiskSnapshot
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDiskSnapshot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDiskSnapshot)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDiskSnapshot))
-> Logger
-> Service
-> Proxy GetDiskSnapshot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDiskSnapshot)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe DiskSnapshot -> Int -> GetDiskSnapshotResponse
GetDiskSnapshotResponse'
            (Maybe DiskSnapshot -> Int -> GetDiskSnapshotResponse)
-> Either String (Maybe DiskSnapshot)
-> Either String (Int -> GetDiskSnapshotResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DiskSnapshot)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"diskSnapshot")
            Either String (Int -> GetDiskSnapshotResponse)
-> Either String Int -> Either String GetDiskSnapshotResponse
forall (f :: * -> *) a b. Applicative f => 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 GetDiskSnapshot

instance Prelude.NFData GetDiskSnapshot

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

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

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

-- | /See:/ 'newGetDiskSnapshotResponse' smart constructor.
data GetDiskSnapshotResponse = GetDiskSnapshotResponse'
  { -- | An object containing information about the disk snapshot.
    GetDiskSnapshotResponse -> Maybe DiskSnapshot
diskSnapshot :: Prelude.Maybe DiskSnapshot,
    -- | The response's http status code.
    GetDiskSnapshotResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDiskSnapshotResponse -> GetDiskSnapshotResponse -> Bool
(GetDiskSnapshotResponse -> GetDiskSnapshotResponse -> Bool)
-> (GetDiskSnapshotResponse -> GetDiskSnapshotResponse -> Bool)
-> Eq GetDiskSnapshotResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDiskSnapshotResponse -> GetDiskSnapshotResponse -> Bool
$c/= :: GetDiskSnapshotResponse -> GetDiskSnapshotResponse -> Bool
== :: GetDiskSnapshotResponse -> GetDiskSnapshotResponse -> Bool
$c== :: GetDiskSnapshotResponse -> GetDiskSnapshotResponse -> Bool
Prelude.Eq, ReadPrec [GetDiskSnapshotResponse]
ReadPrec GetDiskSnapshotResponse
Int -> ReadS GetDiskSnapshotResponse
ReadS [GetDiskSnapshotResponse]
(Int -> ReadS GetDiskSnapshotResponse)
-> ReadS [GetDiskSnapshotResponse]
-> ReadPrec GetDiskSnapshotResponse
-> ReadPrec [GetDiskSnapshotResponse]
-> Read GetDiskSnapshotResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDiskSnapshotResponse]
$creadListPrec :: ReadPrec [GetDiskSnapshotResponse]
readPrec :: ReadPrec GetDiskSnapshotResponse
$creadPrec :: ReadPrec GetDiskSnapshotResponse
readList :: ReadS [GetDiskSnapshotResponse]
$creadList :: ReadS [GetDiskSnapshotResponse]
readsPrec :: Int -> ReadS GetDiskSnapshotResponse
$creadsPrec :: Int -> ReadS GetDiskSnapshotResponse
Prelude.Read, Int -> GetDiskSnapshotResponse -> ShowS
[GetDiskSnapshotResponse] -> ShowS
GetDiskSnapshotResponse -> String
(Int -> GetDiskSnapshotResponse -> ShowS)
-> (GetDiskSnapshotResponse -> String)
-> ([GetDiskSnapshotResponse] -> ShowS)
-> Show GetDiskSnapshotResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDiskSnapshotResponse] -> ShowS
$cshowList :: [GetDiskSnapshotResponse] -> ShowS
show :: GetDiskSnapshotResponse -> String
$cshow :: GetDiskSnapshotResponse -> String
showsPrec :: Int -> GetDiskSnapshotResponse -> ShowS
$cshowsPrec :: Int -> GetDiskSnapshotResponse -> ShowS
Prelude.Show, (forall x.
 GetDiskSnapshotResponse -> Rep GetDiskSnapshotResponse x)
-> (forall x.
    Rep GetDiskSnapshotResponse x -> GetDiskSnapshotResponse)
-> Generic GetDiskSnapshotResponse
forall x. Rep GetDiskSnapshotResponse x -> GetDiskSnapshotResponse
forall x. GetDiskSnapshotResponse -> Rep GetDiskSnapshotResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDiskSnapshotResponse x -> GetDiskSnapshotResponse
$cfrom :: forall x. GetDiskSnapshotResponse -> Rep GetDiskSnapshotResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDiskSnapshotResponse' 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:
--
-- 'diskSnapshot', 'getDiskSnapshotResponse_diskSnapshot' - An object containing information about the disk snapshot.
--
-- 'httpStatus', 'getDiskSnapshotResponse_httpStatus' - The response's http status code.
newGetDiskSnapshotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDiskSnapshotResponse
newGetDiskSnapshotResponse :: Int -> GetDiskSnapshotResponse
newGetDiskSnapshotResponse Int
pHttpStatus_ =
  GetDiskSnapshotResponse' :: Maybe DiskSnapshot -> Int -> GetDiskSnapshotResponse
GetDiskSnapshotResponse'
    { $sel:diskSnapshot:GetDiskSnapshotResponse' :: Maybe DiskSnapshot
diskSnapshot =
        Maybe DiskSnapshot
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDiskSnapshotResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object containing information about the disk snapshot.
getDiskSnapshotResponse_diskSnapshot :: Lens.Lens' GetDiskSnapshotResponse (Prelude.Maybe DiskSnapshot)
getDiskSnapshotResponse_diskSnapshot :: (Maybe DiskSnapshot -> f (Maybe DiskSnapshot))
-> GetDiskSnapshotResponse -> f GetDiskSnapshotResponse
getDiskSnapshotResponse_diskSnapshot = (GetDiskSnapshotResponse -> Maybe DiskSnapshot)
-> (GetDiskSnapshotResponse
    -> Maybe DiskSnapshot -> GetDiskSnapshotResponse)
-> Lens
     GetDiskSnapshotResponse
     GetDiskSnapshotResponse
     (Maybe DiskSnapshot)
     (Maybe DiskSnapshot)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDiskSnapshotResponse' {Maybe DiskSnapshot
diskSnapshot :: Maybe DiskSnapshot
$sel:diskSnapshot:GetDiskSnapshotResponse' :: GetDiskSnapshotResponse -> Maybe DiskSnapshot
diskSnapshot} -> Maybe DiskSnapshot
diskSnapshot) (\s :: GetDiskSnapshotResponse
s@GetDiskSnapshotResponse' {} Maybe DiskSnapshot
a -> GetDiskSnapshotResponse
s {$sel:diskSnapshot:GetDiskSnapshotResponse' :: Maybe DiskSnapshot
diskSnapshot = Maybe DiskSnapshot
a} :: GetDiskSnapshotResponse)

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

instance Prelude.NFData GetDiskSnapshotResponse