{-# 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.ListVolumeInitiators
-- 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)
--
-- Lists iSCSI initiators that are connected to a volume. You can use this
-- operation to determine whether a volume is being used or not. This
-- operation is only supported in the cached volume and stored volume
-- gateway types.
module Amazonka.StorageGateway.ListVolumeInitiators
  ( -- * Creating a Request
    ListVolumeInitiators (..),
    newListVolumeInitiators,

    -- * Request Lenses
    listVolumeInitiators_volumeARN,

    -- * Destructuring the Response
    ListVolumeInitiatorsResponse (..),
    newListVolumeInitiatorsResponse,

    -- * Response Lenses
    listVolumeInitiatorsResponse_initiators,
    listVolumeInitiatorsResponse_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

-- | ListVolumeInitiatorsInput
--
-- /See:/ 'newListVolumeInitiators' smart constructor.
data ListVolumeInitiators = ListVolumeInitiators'
  { -- | The Amazon Resource Name (ARN) of the volume. Use the ListVolumes
    -- operation to return a list of gateway volumes for the gateway.
    ListVolumeInitiators -> Text
volumeARN :: Prelude.Text
  }
  deriving (ListVolumeInitiators -> ListVolumeInitiators -> Bool
(ListVolumeInitiators -> ListVolumeInitiators -> Bool)
-> (ListVolumeInitiators -> ListVolumeInitiators -> Bool)
-> Eq ListVolumeInitiators
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListVolumeInitiators -> ListVolumeInitiators -> Bool
$c/= :: ListVolumeInitiators -> ListVolumeInitiators -> Bool
== :: ListVolumeInitiators -> ListVolumeInitiators -> Bool
$c== :: ListVolumeInitiators -> ListVolumeInitiators -> Bool
Prelude.Eq, ReadPrec [ListVolumeInitiators]
ReadPrec ListVolumeInitiators
Int -> ReadS ListVolumeInitiators
ReadS [ListVolumeInitiators]
(Int -> ReadS ListVolumeInitiators)
-> ReadS [ListVolumeInitiators]
-> ReadPrec ListVolumeInitiators
-> ReadPrec [ListVolumeInitiators]
-> Read ListVolumeInitiators
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListVolumeInitiators]
$creadListPrec :: ReadPrec [ListVolumeInitiators]
readPrec :: ReadPrec ListVolumeInitiators
$creadPrec :: ReadPrec ListVolumeInitiators
readList :: ReadS [ListVolumeInitiators]
$creadList :: ReadS [ListVolumeInitiators]
readsPrec :: Int -> ReadS ListVolumeInitiators
$creadsPrec :: Int -> ReadS ListVolumeInitiators
Prelude.Read, Int -> ListVolumeInitiators -> ShowS
[ListVolumeInitiators] -> ShowS
ListVolumeInitiators -> String
(Int -> ListVolumeInitiators -> ShowS)
-> (ListVolumeInitiators -> String)
-> ([ListVolumeInitiators] -> ShowS)
-> Show ListVolumeInitiators
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListVolumeInitiators] -> ShowS
$cshowList :: [ListVolumeInitiators] -> ShowS
show :: ListVolumeInitiators -> String
$cshow :: ListVolumeInitiators -> String
showsPrec :: Int -> ListVolumeInitiators -> ShowS
$cshowsPrec :: Int -> ListVolumeInitiators -> ShowS
Prelude.Show, (forall x. ListVolumeInitiators -> Rep ListVolumeInitiators x)
-> (forall x. Rep ListVolumeInitiators x -> ListVolumeInitiators)
-> Generic ListVolumeInitiators
forall x. Rep ListVolumeInitiators x -> ListVolumeInitiators
forall x. ListVolumeInitiators -> Rep ListVolumeInitiators x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListVolumeInitiators x -> ListVolumeInitiators
$cfrom :: forall x. ListVolumeInitiators -> Rep ListVolumeInitiators x
Prelude.Generic)

-- |
-- Create a value of 'ListVolumeInitiators' 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:
--
-- 'volumeARN', 'listVolumeInitiators_volumeARN' - The Amazon Resource Name (ARN) of the volume. Use the ListVolumes
-- operation to return a list of gateway volumes for the gateway.
newListVolumeInitiators ::
  -- | 'volumeARN'
  Prelude.Text ->
  ListVolumeInitiators
newListVolumeInitiators :: Text -> ListVolumeInitiators
newListVolumeInitiators Text
pVolumeARN_ =
  ListVolumeInitiators' :: Text -> ListVolumeInitiators
ListVolumeInitiators' {$sel:volumeARN:ListVolumeInitiators' :: Text
volumeARN = Text
pVolumeARN_}

-- | The Amazon Resource Name (ARN) of the volume. Use the ListVolumes
-- operation to return a list of gateway volumes for the gateway.
listVolumeInitiators_volumeARN :: Lens.Lens' ListVolumeInitiators Prelude.Text
listVolumeInitiators_volumeARN :: (Text -> f Text) -> ListVolumeInitiators -> f ListVolumeInitiators
listVolumeInitiators_volumeARN = (ListVolumeInitiators -> Text)
-> (ListVolumeInitiators -> Text -> ListVolumeInitiators)
-> Lens ListVolumeInitiators ListVolumeInitiators Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListVolumeInitiators' {Text
volumeARN :: Text
$sel:volumeARN:ListVolumeInitiators' :: ListVolumeInitiators -> Text
volumeARN} -> Text
volumeARN) (\s :: ListVolumeInitiators
s@ListVolumeInitiators' {} Text
a -> ListVolumeInitiators
s {$sel:volumeARN:ListVolumeInitiators' :: Text
volumeARN = Text
a} :: ListVolumeInitiators)

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

instance Prelude.NFData ListVolumeInitiators

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

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

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

-- | ListVolumeInitiatorsOutput
--
-- /See:/ 'newListVolumeInitiatorsResponse' smart constructor.
data ListVolumeInitiatorsResponse = ListVolumeInitiatorsResponse'
  { -- | The host names and port numbers of all iSCSI initiators that are
    -- connected to the gateway.
    ListVolumeInitiatorsResponse -> Maybe [Text]
initiators :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    ListVolumeInitiatorsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListVolumeInitiatorsResponse
-> ListVolumeInitiatorsResponse -> Bool
(ListVolumeInitiatorsResponse
 -> ListVolumeInitiatorsResponse -> Bool)
-> (ListVolumeInitiatorsResponse
    -> ListVolumeInitiatorsResponse -> Bool)
-> Eq ListVolumeInitiatorsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListVolumeInitiatorsResponse
-> ListVolumeInitiatorsResponse -> Bool
$c/= :: ListVolumeInitiatorsResponse
-> ListVolumeInitiatorsResponse -> Bool
== :: ListVolumeInitiatorsResponse
-> ListVolumeInitiatorsResponse -> Bool
$c== :: ListVolumeInitiatorsResponse
-> ListVolumeInitiatorsResponse -> Bool
Prelude.Eq, ReadPrec [ListVolumeInitiatorsResponse]
ReadPrec ListVolumeInitiatorsResponse
Int -> ReadS ListVolumeInitiatorsResponse
ReadS [ListVolumeInitiatorsResponse]
(Int -> ReadS ListVolumeInitiatorsResponse)
-> ReadS [ListVolumeInitiatorsResponse]
-> ReadPrec ListVolumeInitiatorsResponse
-> ReadPrec [ListVolumeInitiatorsResponse]
-> Read ListVolumeInitiatorsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListVolumeInitiatorsResponse]
$creadListPrec :: ReadPrec [ListVolumeInitiatorsResponse]
readPrec :: ReadPrec ListVolumeInitiatorsResponse
$creadPrec :: ReadPrec ListVolumeInitiatorsResponse
readList :: ReadS [ListVolumeInitiatorsResponse]
$creadList :: ReadS [ListVolumeInitiatorsResponse]
readsPrec :: Int -> ReadS ListVolumeInitiatorsResponse
$creadsPrec :: Int -> ReadS ListVolumeInitiatorsResponse
Prelude.Read, Int -> ListVolumeInitiatorsResponse -> ShowS
[ListVolumeInitiatorsResponse] -> ShowS
ListVolumeInitiatorsResponse -> String
(Int -> ListVolumeInitiatorsResponse -> ShowS)
-> (ListVolumeInitiatorsResponse -> String)
-> ([ListVolumeInitiatorsResponse] -> ShowS)
-> Show ListVolumeInitiatorsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListVolumeInitiatorsResponse] -> ShowS
$cshowList :: [ListVolumeInitiatorsResponse] -> ShowS
show :: ListVolumeInitiatorsResponse -> String
$cshow :: ListVolumeInitiatorsResponse -> String
showsPrec :: Int -> ListVolumeInitiatorsResponse -> ShowS
$cshowsPrec :: Int -> ListVolumeInitiatorsResponse -> ShowS
Prelude.Show, (forall x.
 ListVolumeInitiatorsResponse -> Rep ListVolumeInitiatorsResponse x)
-> (forall x.
    Rep ListVolumeInitiatorsResponse x -> ListVolumeInitiatorsResponse)
-> Generic ListVolumeInitiatorsResponse
forall x.
Rep ListVolumeInitiatorsResponse x -> ListVolumeInitiatorsResponse
forall x.
ListVolumeInitiatorsResponse -> Rep ListVolumeInitiatorsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListVolumeInitiatorsResponse x -> ListVolumeInitiatorsResponse
$cfrom :: forall x.
ListVolumeInitiatorsResponse -> Rep ListVolumeInitiatorsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListVolumeInitiatorsResponse' 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:
--
-- 'initiators', 'listVolumeInitiatorsResponse_initiators' - The host names and port numbers of all iSCSI initiators that are
-- connected to the gateway.
--
-- 'httpStatus', 'listVolumeInitiatorsResponse_httpStatus' - The response's http status code.
newListVolumeInitiatorsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListVolumeInitiatorsResponse
newListVolumeInitiatorsResponse :: Int -> ListVolumeInitiatorsResponse
newListVolumeInitiatorsResponse Int
pHttpStatus_ =
  ListVolumeInitiatorsResponse' :: Maybe [Text] -> Int -> ListVolumeInitiatorsResponse
ListVolumeInitiatorsResponse'
    { $sel:initiators:ListVolumeInitiatorsResponse' :: Maybe [Text]
initiators =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListVolumeInitiatorsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The host names and port numbers of all iSCSI initiators that are
-- connected to the gateway.
listVolumeInitiatorsResponse_initiators :: Lens.Lens' ListVolumeInitiatorsResponse (Prelude.Maybe [Prelude.Text])
listVolumeInitiatorsResponse_initiators :: (Maybe [Text] -> f (Maybe [Text]))
-> ListVolumeInitiatorsResponse -> f ListVolumeInitiatorsResponse
listVolumeInitiatorsResponse_initiators = (ListVolumeInitiatorsResponse -> Maybe [Text])
-> (ListVolumeInitiatorsResponse
    -> Maybe [Text] -> ListVolumeInitiatorsResponse)
-> Lens
     ListVolumeInitiatorsResponse
     ListVolumeInitiatorsResponse
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListVolumeInitiatorsResponse' {Maybe [Text]
initiators :: Maybe [Text]
$sel:initiators:ListVolumeInitiatorsResponse' :: ListVolumeInitiatorsResponse -> Maybe [Text]
initiators} -> Maybe [Text]
initiators) (\s :: ListVolumeInitiatorsResponse
s@ListVolumeInitiatorsResponse' {} Maybe [Text]
a -> ListVolumeInitiatorsResponse
s {$sel:initiators:ListVolumeInitiatorsResponse' :: Maybe [Text]
initiators = Maybe [Text]
a} :: ListVolumeInitiatorsResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListVolumeInitiatorsResponse -> f ListVolumeInitiatorsResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListVolumeInitiatorsResponse
-> f ListVolumeInitiatorsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListVolumeInitiatorsResponse