{-# 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.DescribeFileSystemAssociations
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets the file system association information. This operation is only
-- supported for FSx File Gateways.
module Amazonka.StorageGateway.DescribeFileSystemAssociations
  ( -- * Creating a Request
    DescribeFileSystemAssociations (..),
    newDescribeFileSystemAssociations,

    -- * Request Lenses
    describeFileSystemAssociations_fileSystemAssociationARNList,

    -- * Destructuring the Response
    DescribeFileSystemAssociationsResponse (..),
    newDescribeFileSystemAssociationsResponse,

    -- * Response Lenses
    describeFileSystemAssociationsResponse_fileSystemAssociationInfoList,
    describeFileSystemAssociationsResponse_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

-- | /See:/ 'newDescribeFileSystemAssociations' smart constructor.
data DescribeFileSystemAssociations = DescribeFileSystemAssociations'
  { -- | An array containing the Amazon Resource Name (ARN) of each file system
    -- association to be described.
    DescribeFileSystemAssociations -> NonEmpty Text
fileSystemAssociationARNList :: Prelude.NonEmpty Prelude.Text
  }
  deriving (DescribeFileSystemAssociations
-> DescribeFileSystemAssociations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeFileSystemAssociations
-> DescribeFileSystemAssociations -> Bool
$c/= :: DescribeFileSystemAssociations
-> DescribeFileSystemAssociations -> Bool
== :: DescribeFileSystemAssociations
-> DescribeFileSystemAssociations -> Bool
$c== :: DescribeFileSystemAssociations
-> DescribeFileSystemAssociations -> Bool
Prelude.Eq, ReadPrec [DescribeFileSystemAssociations]
ReadPrec DescribeFileSystemAssociations
Int -> ReadS DescribeFileSystemAssociations
ReadS [DescribeFileSystemAssociations]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeFileSystemAssociations]
$creadListPrec :: ReadPrec [DescribeFileSystemAssociations]
readPrec :: ReadPrec DescribeFileSystemAssociations
$creadPrec :: ReadPrec DescribeFileSystemAssociations
readList :: ReadS [DescribeFileSystemAssociations]
$creadList :: ReadS [DescribeFileSystemAssociations]
readsPrec :: Int -> ReadS DescribeFileSystemAssociations
$creadsPrec :: Int -> ReadS DescribeFileSystemAssociations
Prelude.Read, Int -> DescribeFileSystemAssociations -> ShowS
[DescribeFileSystemAssociations] -> ShowS
DescribeFileSystemAssociations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeFileSystemAssociations] -> ShowS
$cshowList :: [DescribeFileSystemAssociations] -> ShowS
show :: DescribeFileSystemAssociations -> String
$cshow :: DescribeFileSystemAssociations -> String
showsPrec :: Int -> DescribeFileSystemAssociations -> ShowS
$cshowsPrec :: Int -> DescribeFileSystemAssociations -> ShowS
Prelude.Show, forall x.
Rep DescribeFileSystemAssociations x
-> DescribeFileSystemAssociations
forall x.
DescribeFileSystemAssociations
-> Rep DescribeFileSystemAssociations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeFileSystemAssociations x
-> DescribeFileSystemAssociations
$cfrom :: forall x.
DescribeFileSystemAssociations
-> Rep DescribeFileSystemAssociations x
Prelude.Generic)

-- |
-- Create a value of 'DescribeFileSystemAssociations' 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:
--
-- 'fileSystemAssociationARNList', 'describeFileSystemAssociations_fileSystemAssociationARNList' - An array containing the Amazon Resource Name (ARN) of each file system
-- association to be described.
newDescribeFileSystemAssociations ::
  -- | 'fileSystemAssociationARNList'
  Prelude.NonEmpty Prelude.Text ->
  DescribeFileSystemAssociations
newDescribeFileSystemAssociations :: NonEmpty Text -> DescribeFileSystemAssociations
newDescribeFileSystemAssociations
  NonEmpty Text
pFileSystemAssociationARNList_ =
    DescribeFileSystemAssociations'
      { $sel:fileSystemAssociationARNList:DescribeFileSystemAssociations' :: NonEmpty Text
fileSystemAssociationARNList =
          forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
            forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pFileSystemAssociationARNList_
      }

-- | An array containing the Amazon Resource Name (ARN) of each file system
-- association to be described.
describeFileSystemAssociations_fileSystemAssociationARNList :: Lens.Lens' DescribeFileSystemAssociations (Prelude.NonEmpty Prelude.Text)
describeFileSystemAssociations_fileSystemAssociationARNList :: Lens' DescribeFileSystemAssociations (NonEmpty Text)
describeFileSystemAssociations_fileSystemAssociationARNList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeFileSystemAssociations' {NonEmpty Text
fileSystemAssociationARNList :: NonEmpty Text
$sel:fileSystemAssociationARNList:DescribeFileSystemAssociations' :: DescribeFileSystemAssociations -> NonEmpty Text
fileSystemAssociationARNList} -> NonEmpty Text
fileSystemAssociationARNList) (\s :: DescribeFileSystemAssociations
s@DescribeFileSystemAssociations' {} NonEmpty Text
a -> DescribeFileSystemAssociations
s {$sel:fileSystemAssociationARNList:DescribeFileSystemAssociations' :: NonEmpty Text
fileSystemAssociationARNList = NonEmpty Text
a} :: DescribeFileSystemAssociations) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Core.AWSRequest
    DescribeFileSystemAssociations
  where
  type
    AWSResponse DescribeFileSystemAssociations =
      DescribeFileSystemAssociationsResponse
  request :: (Service -> Service)
-> DescribeFileSystemAssociations
-> Request DescribeFileSystemAssociations
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 DescribeFileSystemAssociations
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeFileSystemAssociations)))
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 [FileSystemAssociationInfo]
-> Int -> DescribeFileSystemAssociationsResponse
DescribeFileSystemAssociationsResponse'
            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
"FileSystemAssociationInfoList"
                            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
    DescribeFileSystemAssociations
  where
  hashWithSalt :: Int -> DescribeFileSystemAssociations -> Int
hashWithSalt
    Int
_salt
    DescribeFileSystemAssociations' {NonEmpty Text
fileSystemAssociationARNList :: NonEmpty Text
$sel:fileSystemAssociationARNList:DescribeFileSystemAssociations' :: DescribeFileSystemAssociations -> NonEmpty Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
fileSystemAssociationARNList

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

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

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

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

-- | /See:/ 'newDescribeFileSystemAssociationsResponse' smart constructor.
data DescribeFileSystemAssociationsResponse = DescribeFileSystemAssociationsResponse'
  { -- | An array containing the @FileSystemAssociationInfo@ data type of each
    -- file system association to be described.
    DescribeFileSystemAssociationsResponse
-> Maybe [FileSystemAssociationInfo]
fileSystemAssociationInfoList :: Prelude.Maybe [FileSystemAssociationInfo],
    -- | The response's http status code.
    DescribeFileSystemAssociationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeFileSystemAssociationsResponse
-> DescribeFileSystemAssociationsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeFileSystemAssociationsResponse
-> DescribeFileSystemAssociationsResponse -> Bool
$c/= :: DescribeFileSystemAssociationsResponse
-> DescribeFileSystemAssociationsResponse -> Bool
== :: DescribeFileSystemAssociationsResponse
-> DescribeFileSystemAssociationsResponse -> Bool
$c== :: DescribeFileSystemAssociationsResponse
-> DescribeFileSystemAssociationsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeFileSystemAssociationsResponse]
ReadPrec DescribeFileSystemAssociationsResponse
Int -> ReadS DescribeFileSystemAssociationsResponse
ReadS [DescribeFileSystemAssociationsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeFileSystemAssociationsResponse]
$creadListPrec :: ReadPrec [DescribeFileSystemAssociationsResponse]
readPrec :: ReadPrec DescribeFileSystemAssociationsResponse
$creadPrec :: ReadPrec DescribeFileSystemAssociationsResponse
readList :: ReadS [DescribeFileSystemAssociationsResponse]
$creadList :: ReadS [DescribeFileSystemAssociationsResponse]
readsPrec :: Int -> ReadS DescribeFileSystemAssociationsResponse
$creadsPrec :: Int -> ReadS DescribeFileSystemAssociationsResponse
Prelude.Read, Int -> DescribeFileSystemAssociationsResponse -> ShowS
[DescribeFileSystemAssociationsResponse] -> ShowS
DescribeFileSystemAssociationsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeFileSystemAssociationsResponse] -> ShowS
$cshowList :: [DescribeFileSystemAssociationsResponse] -> ShowS
show :: DescribeFileSystemAssociationsResponse -> String
$cshow :: DescribeFileSystemAssociationsResponse -> String
showsPrec :: Int -> DescribeFileSystemAssociationsResponse -> ShowS
$cshowsPrec :: Int -> DescribeFileSystemAssociationsResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeFileSystemAssociationsResponse x
-> DescribeFileSystemAssociationsResponse
forall x.
DescribeFileSystemAssociationsResponse
-> Rep DescribeFileSystemAssociationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeFileSystemAssociationsResponse x
-> DescribeFileSystemAssociationsResponse
$cfrom :: forall x.
DescribeFileSystemAssociationsResponse
-> Rep DescribeFileSystemAssociationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeFileSystemAssociationsResponse' 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:
--
-- 'fileSystemAssociationInfoList', 'describeFileSystemAssociationsResponse_fileSystemAssociationInfoList' - An array containing the @FileSystemAssociationInfo@ data type of each
-- file system association to be described.
--
-- 'httpStatus', 'describeFileSystemAssociationsResponse_httpStatus' - The response's http status code.
newDescribeFileSystemAssociationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeFileSystemAssociationsResponse
newDescribeFileSystemAssociationsResponse :: Int -> DescribeFileSystemAssociationsResponse
newDescribeFileSystemAssociationsResponse
  Int
pHttpStatus_ =
    DescribeFileSystemAssociationsResponse'
      { $sel:fileSystemAssociationInfoList:DescribeFileSystemAssociationsResponse' :: Maybe [FileSystemAssociationInfo]
fileSystemAssociationInfoList =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeFileSystemAssociationsResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | An array containing the @FileSystemAssociationInfo@ data type of each
-- file system association to be described.
describeFileSystemAssociationsResponse_fileSystemAssociationInfoList :: Lens.Lens' DescribeFileSystemAssociationsResponse (Prelude.Maybe [FileSystemAssociationInfo])
describeFileSystemAssociationsResponse_fileSystemAssociationInfoList :: Lens'
  DescribeFileSystemAssociationsResponse
  (Maybe [FileSystemAssociationInfo])
describeFileSystemAssociationsResponse_fileSystemAssociationInfoList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeFileSystemAssociationsResponse' {Maybe [FileSystemAssociationInfo]
fileSystemAssociationInfoList :: Maybe [FileSystemAssociationInfo]
$sel:fileSystemAssociationInfoList:DescribeFileSystemAssociationsResponse' :: DescribeFileSystemAssociationsResponse
-> Maybe [FileSystemAssociationInfo]
fileSystemAssociationInfoList} -> Maybe [FileSystemAssociationInfo]
fileSystemAssociationInfoList) (\s :: DescribeFileSystemAssociationsResponse
s@DescribeFileSystemAssociationsResponse' {} Maybe [FileSystemAssociationInfo]
a -> DescribeFileSystemAssociationsResponse
s {$sel:fileSystemAssociationInfoList:DescribeFileSystemAssociationsResponse' :: Maybe [FileSystemAssociationInfo]
fileSystemAssociationInfoList = Maybe [FileSystemAssociationInfo]
a} :: DescribeFileSystemAssociationsResponse) 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.
describeFileSystemAssociationsResponse_httpStatus :: Lens.Lens' DescribeFileSystemAssociationsResponse Prelude.Int
describeFileSystemAssociationsResponse_httpStatus :: Lens' DescribeFileSystemAssociationsResponse Int
describeFileSystemAssociationsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeFileSystemAssociationsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeFileSystemAssociationsResponse' :: DescribeFileSystemAssociationsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeFileSystemAssociationsResponse
s@DescribeFileSystemAssociationsResponse' {} Int
a -> DescribeFileSystemAssociationsResponse
s {$sel:httpStatus:DescribeFileSystemAssociationsResponse' :: Int
httpStatus = Int
a} :: DescribeFileSystemAssociationsResponse)

instance
  Prelude.NFData
    DescribeFileSystemAssociationsResponse
  where
  rnf :: DescribeFileSystemAssociationsResponse -> ()
rnf DescribeFileSystemAssociationsResponse' {Int
Maybe [FileSystemAssociationInfo]
httpStatus :: Int
fileSystemAssociationInfoList :: Maybe [FileSystemAssociationInfo]
$sel:httpStatus:DescribeFileSystemAssociationsResponse' :: DescribeFileSystemAssociationsResponse -> Int
$sel:fileSystemAssociationInfoList:DescribeFileSystemAssociationsResponse' :: DescribeFileSystemAssociationsResponse
-> Maybe [FileSystemAssociationInfo]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [FileSystemAssociationInfo]
fileSystemAssociationInfoList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus