{-# 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.StorageGateway.ListLocalDisks
-- 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 a list of the gateway\'s local disks. To specify which gateway
-- to describe, you use the Amazon Resource Name (ARN) of the gateway in
-- the body of the request.
--
-- The request returns a list of all disks, specifying which are configured
-- as working storage, cache storage, or stored volume or not configured at
-- all. The response includes a @DiskStatus@ field. This field can have a
-- value of present (the disk is available to use), missing (the disk is no
-- longer connected to the gateway), or mismatch (the disk node is occupied
-- by a disk that has incorrect metadata or the disk content is corrupted).
module Amazonka.StorageGateway.ListLocalDisks
  ( -- * Creating a Request
    ListLocalDisks (..),
    newListLocalDisks,

    -- * Request Lenses
    listLocalDisks_gatewayARN,

    -- * Destructuring the Response
    ListLocalDisksResponse (..),
    newListLocalDisksResponse,

    -- * Response Lenses
    listLocalDisksResponse_gatewayARN,
    listLocalDisksResponse_disks,
    listLocalDisksResponse_httpStatus,
  )
where

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

-- | A JSON object containing the Amazon Resource Name (ARN) of the gateway.
--
-- /See:/ 'newListLocalDisks' smart constructor.
data ListLocalDisks = ListLocalDisks'
  { ListLocalDisks -> Text
gatewayARN :: Prelude.Text
  }
  deriving (ListLocalDisks -> ListLocalDisks -> Bool
(ListLocalDisks -> ListLocalDisks -> Bool)
-> (ListLocalDisks -> ListLocalDisks -> Bool) -> Eq ListLocalDisks
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListLocalDisks -> ListLocalDisks -> Bool
$c/= :: ListLocalDisks -> ListLocalDisks -> Bool
== :: ListLocalDisks -> ListLocalDisks -> Bool
$c== :: ListLocalDisks -> ListLocalDisks -> Bool
Prelude.Eq, ReadPrec [ListLocalDisks]
ReadPrec ListLocalDisks
Int -> ReadS ListLocalDisks
ReadS [ListLocalDisks]
(Int -> ReadS ListLocalDisks)
-> ReadS [ListLocalDisks]
-> ReadPrec ListLocalDisks
-> ReadPrec [ListLocalDisks]
-> Read ListLocalDisks
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListLocalDisks]
$creadListPrec :: ReadPrec [ListLocalDisks]
readPrec :: ReadPrec ListLocalDisks
$creadPrec :: ReadPrec ListLocalDisks
readList :: ReadS [ListLocalDisks]
$creadList :: ReadS [ListLocalDisks]
readsPrec :: Int -> ReadS ListLocalDisks
$creadsPrec :: Int -> ReadS ListLocalDisks
Prelude.Read, Int -> ListLocalDisks -> ShowS
[ListLocalDisks] -> ShowS
ListLocalDisks -> String
(Int -> ListLocalDisks -> ShowS)
-> (ListLocalDisks -> String)
-> ([ListLocalDisks] -> ShowS)
-> Show ListLocalDisks
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListLocalDisks] -> ShowS
$cshowList :: [ListLocalDisks] -> ShowS
show :: ListLocalDisks -> String
$cshow :: ListLocalDisks -> String
showsPrec :: Int -> ListLocalDisks -> ShowS
$cshowsPrec :: Int -> ListLocalDisks -> ShowS
Prelude.Show, (forall x. ListLocalDisks -> Rep ListLocalDisks x)
-> (forall x. Rep ListLocalDisks x -> ListLocalDisks)
-> Generic ListLocalDisks
forall x. Rep ListLocalDisks x -> ListLocalDisks
forall x. ListLocalDisks -> Rep ListLocalDisks x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListLocalDisks x -> ListLocalDisks
$cfrom :: forall x. ListLocalDisks -> Rep ListLocalDisks x
Prelude.Generic)

-- |
-- Create a value of 'ListLocalDisks' 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:
--
-- 'gatewayARN', 'listLocalDisks_gatewayARN' - Undocumented member.
newListLocalDisks ::
  -- | 'gatewayARN'
  Prelude.Text ->
  ListLocalDisks
newListLocalDisks :: Text -> ListLocalDisks
newListLocalDisks Text
pGatewayARN_ =
  ListLocalDisks' :: Text -> ListLocalDisks
ListLocalDisks' {$sel:gatewayARN:ListLocalDisks' :: Text
gatewayARN = Text
pGatewayARN_}

-- | Undocumented member.
listLocalDisks_gatewayARN :: Lens.Lens' ListLocalDisks Prelude.Text
listLocalDisks_gatewayARN :: (Text -> f Text) -> ListLocalDisks -> f ListLocalDisks
listLocalDisks_gatewayARN = (ListLocalDisks -> Text)
-> (ListLocalDisks -> Text -> ListLocalDisks)
-> Lens ListLocalDisks ListLocalDisks Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListLocalDisks' {Text
gatewayARN :: Text
$sel:gatewayARN:ListLocalDisks' :: ListLocalDisks -> Text
gatewayARN} -> Text
gatewayARN) (\s :: ListLocalDisks
s@ListLocalDisks' {} Text
a -> ListLocalDisks
s {$sel:gatewayARN:ListLocalDisks' :: Text
gatewayARN = Text
a} :: ListLocalDisks)

instance Core.AWSRequest ListLocalDisks where
  type
    AWSResponse ListLocalDisks =
      ListLocalDisksResponse
  request :: ListLocalDisks -> Request ListLocalDisks
request = Service -> ListLocalDisks -> Request ListLocalDisks
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListLocalDisks
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListLocalDisks)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListLocalDisks))
-> Logger
-> Service
-> Proxy ListLocalDisks
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListLocalDisks)))
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 Text -> Maybe [Disk] -> Int -> ListLocalDisksResponse
ListLocalDisksResponse'
            (Maybe Text -> Maybe [Disk] -> Int -> ListLocalDisksResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [Disk] -> Int -> ListLocalDisksResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GatewayARN")
            Either String (Maybe [Disk] -> Int -> ListLocalDisksResponse)
-> Either String (Maybe [Disk])
-> Either String (Int -> ListLocalDisksResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Disk]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Disks" Either String (Maybe (Maybe [Disk]))
-> Maybe [Disk] -> Either String (Maybe [Disk])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Disk]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListLocalDisksResponse)
-> Either String Int -> Either String ListLocalDisksResponse
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 ListLocalDisks

instance Prelude.NFData ListLocalDisks

instance Core.ToHeaders ListLocalDisks where
  toHeaders :: ListLocalDisks -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListLocalDisks -> 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
"StorageGateway_20130630.ListLocalDisks" ::
                          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 ListLocalDisks where
  toJSON :: ListLocalDisks -> Value
toJSON ListLocalDisks' {Text
gatewayARN :: Text
$sel:gatewayARN:ListLocalDisks' :: ListLocalDisks -> 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
"GatewayARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
gatewayARN)]
      )

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

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

-- | /See:/ 'newListLocalDisksResponse' smart constructor.
data ListLocalDisksResponse = ListLocalDisksResponse'
  { ListLocalDisksResponse -> Maybe Text
gatewayARN :: Prelude.Maybe Prelude.Text,
    -- | A JSON object containing the following fields:
    --
    -- -   ListLocalDisksOutput$Disks
    ListLocalDisksResponse -> Maybe [Disk]
disks :: Prelude.Maybe [Disk],
    -- | The response's http status code.
    ListLocalDisksResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListLocalDisksResponse -> ListLocalDisksResponse -> Bool
(ListLocalDisksResponse -> ListLocalDisksResponse -> Bool)
-> (ListLocalDisksResponse -> ListLocalDisksResponse -> Bool)
-> Eq ListLocalDisksResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListLocalDisksResponse -> ListLocalDisksResponse -> Bool
$c/= :: ListLocalDisksResponse -> ListLocalDisksResponse -> Bool
== :: ListLocalDisksResponse -> ListLocalDisksResponse -> Bool
$c== :: ListLocalDisksResponse -> ListLocalDisksResponse -> Bool
Prelude.Eq, ReadPrec [ListLocalDisksResponse]
ReadPrec ListLocalDisksResponse
Int -> ReadS ListLocalDisksResponse
ReadS [ListLocalDisksResponse]
(Int -> ReadS ListLocalDisksResponse)
-> ReadS [ListLocalDisksResponse]
-> ReadPrec ListLocalDisksResponse
-> ReadPrec [ListLocalDisksResponse]
-> Read ListLocalDisksResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListLocalDisksResponse]
$creadListPrec :: ReadPrec [ListLocalDisksResponse]
readPrec :: ReadPrec ListLocalDisksResponse
$creadPrec :: ReadPrec ListLocalDisksResponse
readList :: ReadS [ListLocalDisksResponse]
$creadList :: ReadS [ListLocalDisksResponse]
readsPrec :: Int -> ReadS ListLocalDisksResponse
$creadsPrec :: Int -> ReadS ListLocalDisksResponse
Prelude.Read, Int -> ListLocalDisksResponse -> ShowS
[ListLocalDisksResponse] -> ShowS
ListLocalDisksResponse -> String
(Int -> ListLocalDisksResponse -> ShowS)
-> (ListLocalDisksResponse -> String)
-> ([ListLocalDisksResponse] -> ShowS)
-> Show ListLocalDisksResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListLocalDisksResponse] -> ShowS
$cshowList :: [ListLocalDisksResponse] -> ShowS
show :: ListLocalDisksResponse -> String
$cshow :: ListLocalDisksResponse -> String
showsPrec :: Int -> ListLocalDisksResponse -> ShowS
$cshowsPrec :: Int -> ListLocalDisksResponse -> ShowS
Prelude.Show, (forall x. ListLocalDisksResponse -> Rep ListLocalDisksResponse x)
-> (forall x.
    Rep ListLocalDisksResponse x -> ListLocalDisksResponse)
-> Generic ListLocalDisksResponse
forall x. Rep ListLocalDisksResponse x -> ListLocalDisksResponse
forall x. ListLocalDisksResponse -> Rep ListLocalDisksResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListLocalDisksResponse x -> ListLocalDisksResponse
$cfrom :: forall x. ListLocalDisksResponse -> Rep ListLocalDisksResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListLocalDisksResponse' 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:
--
-- 'gatewayARN', 'listLocalDisksResponse_gatewayARN' - Undocumented member.
--
-- 'disks', 'listLocalDisksResponse_disks' - A JSON object containing the following fields:
--
-- -   ListLocalDisksOutput$Disks
--
-- 'httpStatus', 'listLocalDisksResponse_httpStatus' - The response's http status code.
newListLocalDisksResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListLocalDisksResponse
newListLocalDisksResponse :: Int -> ListLocalDisksResponse
newListLocalDisksResponse Int
pHttpStatus_ =
  ListLocalDisksResponse' :: Maybe Text -> Maybe [Disk] -> Int -> ListLocalDisksResponse
ListLocalDisksResponse'
    { $sel:gatewayARN:ListLocalDisksResponse' :: Maybe Text
gatewayARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:disks:ListLocalDisksResponse' :: Maybe [Disk]
disks = Maybe [Disk]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListLocalDisksResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
listLocalDisksResponse_gatewayARN :: Lens.Lens' ListLocalDisksResponse (Prelude.Maybe Prelude.Text)
listLocalDisksResponse_gatewayARN :: (Maybe Text -> f (Maybe Text))
-> ListLocalDisksResponse -> f ListLocalDisksResponse
listLocalDisksResponse_gatewayARN = (ListLocalDisksResponse -> Maybe Text)
-> (ListLocalDisksResponse -> Maybe Text -> ListLocalDisksResponse)
-> Lens
     ListLocalDisksResponse
     ListLocalDisksResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListLocalDisksResponse' {Maybe Text
gatewayARN :: Maybe Text
$sel:gatewayARN:ListLocalDisksResponse' :: ListLocalDisksResponse -> Maybe Text
gatewayARN} -> Maybe Text
gatewayARN) (\s :: ListLocalDisksResponse
s@ListLocalDisksResponse' {} Maybe Text
a -> ListLocalDisksResponse
s {$sel:gatewayARN:ListLocalDisksResponse' :: Maybe Text
gatewayARN = Maybe Text
a} :: ListLocalDisksResponse)

-- | A JSON object containing the following fields:
--
-- -   ListLocalDisksOutput$Disks
listLocalDisksResponse_disks :: Lens.Lens' ListLocalDisksResponse (Prelude.Maybe [Disk])
listLocalDisksResponse_disks :: (Maybe [Disk] -> f (Maybe [Disk]))
-> ListLocalDisksResponse -> f ListLocalDisksResponse
listLocalDisksResponse_disks = (ListLocalDisksResponse -> Maybe [Disk])
-> (ListLocalDisksResponse
    -> Maybe [Disk] -> ListLocalDisksResponse)
-> Lens
     ListLocalDisksResponse
     ListLocalDisksResponse
     (Maybe [Disk])
     (Maybe [Disk])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListLocalDisksResponse' {Maybe [Disk]
disks :: Maybe [Disk]
$sel:disks:ListLocalDisksResponse' :: ListLocalDisksResponse -> Maybe [Disk]
disks} -> Maybe [Disk]
disks) (\s :: ListLocalDisksResponse
s@ListLocalDisksResponse' {} Maybe [Disk]
a -> ListLocalDisksResponse
s {$sel:disks:ListLocalDisksResponse' :: Maybe [Disk]
disks = Maybe [Disk]
a} :: ListLocalDisksResponse) ((Maybe [Disk] -> f (Maybe [Disk]))
 -> ListLocalDisksResponse -> f ListLocalDisksResponse)
-> ((Maybe [Disk] -> f (Maybe [Disk]))
    -> Maybe [Disk] -> f (Maybe [Disk]))
-> (Maybe [Disk] -> f (Maybe [Disk]))
-> ListLocalDisksResponse
-> f ListLocalDisksResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Disk] [Disk] [Disk] [Disk]
-> Iso (Maybe [Disk]) (Maybe [Disk]) (Maybe [Disk]) (Maybe [Disk])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Disk] [Disk] [Disk] [Disk]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListLocalDisksResponse