{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$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 :: Lens' ListVolumeInitiators Text
listVolumeInitiators_volumeARN = 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 :: (Service -> Service)
-> ListVolumeInitiators -> Request ListVolumeInitiators
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 ListVolumeInitiators
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListVolumeInitiators)))
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 [Text] -> Int -> ListVolumeInitiatorsResponse
ListVolumeInitiatorsResponse'
            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
"Initiators" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 ListVolumeInitiators where
  hashWithSalt :: Int -> ListVolumeInitiators -> Int
hashWithSalt Int
_salt ListVolumeInitiators' {Text
volumeARN :: Text
$sel:volumeARN:ListVolumeInitiators' :: ListVolumeInitiators -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
volumeARN

instance Prelude.NFData ListVolumeInitiators where
  rnf :: ListVolumeInitiators -> ()
rnf ListVolumeInitiators' {Text
volumeARN :: Text
$sel:volumeARN:ListVolumeInitiators' :: ListVolumeInitiators -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
volumeARN

instance Data.ToHeaders ListVolumeInitiators where
  toHeaders :: ListVolumeInitiators -> 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
"StorageGateway_20130630.ListVolumeInitiators" ::
                          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 ListVolumeInitiators where
  toJSON :: ListVolumeInitiators -> Value
toJSON ListVolumeInitiators' {Text
volumeARN :: Text
$sel:volumeARN:ListVolumeInitiators' :: ListVolumeInitiators -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"VolumeARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
volumeARN)]
      )

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

instance Data.ToQuery ListVolumeInitiators where
  toQuery :: ListVolumeInitiators -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:initiators:ListVolumeInitiatorsResponse' :: Maybe [Text]
initiators =
        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 :: Lens' ListVolumeInitiatorsResponse (Maybe [Text])
listVolumeInitiatorsResponse_initiators = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' ListVolumeInitiatorsResponse Int
listVolumeInitiatorsResponse_httpStatus = 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 where
  rnf :: ListVolumeInitiatorsResponse -> ()
rnf ListVolumeInitiatorsResponse' {Int
Maybe [Text]
httpStatus :: Int
initiators :: Maybe [Text]
$sel:httpStatus:ListVolumeInitiatorsResponse' :: ListVolumeInitiatorsResponse -> Int
$sel:initiators:ListVolumeInitiatorsResponse' :: ListVolumeInitiatorsResponse -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
initiators
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus