{-# 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.Discovery.DescribeConfigurations
-- 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)
--
-- Retrieves attributes for a list of configuration item IDs.
--
-- All of the supplied IDs must be for the same asset type from one of the
-- following:
--
-- -   server
--
-- -   application
--
-- -   process
--
-- -   connection
--
-- Output fields are specific to the asset type specified. For example, the
-- output for a /server/ configuration item includes a list of attributes
-- about the server, such as host name, operating system, number of network
-- cards, etc.
--
-- For a complete list of outputs for each asset type, see
-- <https://docs.aws.amazon.com/application-discovery/latest/userguide/discovery-api-queries.html#DescribeConfigurations Using the DescribeConfigurations Action>
-- in the /AWS Application Discovery Service User Guide/.
module Amazonka.Discovery.DescribeConfigurations
  ( -- * Creating a Request
    DescribeConfigurations (..),
    newDescribeConfigurations,

    -- * Request Lenses
    describeConfigurations_configurationIds,

    -- * Destructuring the Response
    DescribeConfigurationsResponse (..),
    newDescribeConfigurationsResponse,

    -- * Response Lenses
    describeConfigurationsResponse_configurations,
    describeConfigurationsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeConfigurations' smart constructor.
data DescribeConfigurations = DescribeConfigurations'
  { -- | One or more configuration IDs.
    DescribeConfigurations -> [Text]
configurationIds :: [Prelude.Text]
  }
  deriving (DescribeConfigurations -> DescribeConfigurations -> Bool
(DescribeConfigurations -> DescribeConfigurations -> Bool)
-> (DescribeConfigurations -> DescribeConfigurations -> Bool)
-> Eq DescribeConfigurations
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeConfigurations -> DescribeConfigurations -> Bool
$c/= :: DescribeConfigurations -> DescribeConfigurations -> Bool
== :: DescribeConfigurations -> DescribeConfigurations -> Bool
$c== :: DescribeConfigurations -> DescribeConfigurations -> Bool
Prelude.Eq, ReadPrec [DescribeConfigurations]
ReadPrec DescribeConfigurations
Int -> ReadS DescribeConfigurations
ReadS [DescribeConfigurations]
(Int -> ReadS DescribeConfigurations)
-> ReadS [DescribeConfigurations]
-> ReadPrec DescribeConfigurations
-> ReadPrec [DescribeConfigurations]
-> Read DescribeConfigurations
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeConfigurations]
$creadListPrec :: ReadPrec [DescribeConfigurations]
readPrec :: ReadPrec DescribeConfigurations
$creadPrec :: ReadPrec DescribeConfigurations
readList :: ReadS [DescribeConfigurations]
$creadList :: ReadS [DescribeConfigurations]
readsPrec :: Int -> ReadS DescribeConfigurations
$creadsPrec :: Int -> ReadS DescribeConfigurations
Prelude.Read, Int -> DescribeConfigurations -> ShowS
[DescribeConfigurations] -> ShowS
DescribeConfigurations -> String
(Int -> DescribeConfigurations -> ShowS)
-> (DescribeConfigurations -> String)
-> ([DescribeConfigurations] -> ShowS)
-> Show DescribeConfigurations
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeConfigurations] -> ShowS
$cshowList :: [DescribeConfigurations] -> ShowS
show :: DescribeConfigurations -> String
$cshow :: DescribeConfigurations -> String
showsPrec :: Int -> DescribeConfigurations -> ShowS
$cshowsPrec :: Int -> DescribeConfigurations -> ShowS
Prelude.Show, (forall x. DescribeConfigurations -> Rep DescribeConfigurations x)
-> (forall x.
    Rep DescribeConfigurations x -> DescribeConfigurations)
-> Generic DescribeConfigurations
forall x. Rep DescribeConfigurations x -> DescribeConfigurations
forall x. DescribeConfigurations -> Rep DescribeConfigurations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeConfigurations x -> DescribeConfigurations
$cfrom :: forall x. DescribeConfigurations -> Rep DescribeConfigurations x
Prelude.Generic)

-- |
-- Create a value of 'DescribeConfigurations' 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:
--
-- 'configurationIds', 'describeConfigurations_configurationIds' - One or more configuration IDs.
newDescribeConfigurations ::
  DescribeConfigurations
newDescribeConfigurations :: DescribeConfigurations
newDescribeConfigurations =
  DescribeConfigurations' :: [Text] -> DescribeConfigurations
DescribeConfigurations'
    { $sel:configurationIds:DescribeConfigurations' :: [Text]
configurationIds =
        [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | One or more configuration IDs.
describeConfigurations_configurationIds :: Lens.Lens' DescribeConfigurations [Prelude.Text]
describeConfigurations_configurationIds :: ([Text] -> f [Text])
-> DescribeConfigurations -> f DescribeConfigurations
describeConfigurations_configurationIds = (DescribeConfigurations -> [Text])
-> (DescribeConfigurations -> [Text] -> DescribeConfigurations)
-> Lens DescribeConfigurations DescribeConfigurations [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeConfigurations' {[Text]
configurationIds :: [Text]
$sel:configurationIds:DescribeConfigurations' :: DescribeConfigurations -> [Text]
configurationIds} -> [Text]
configurationIds) (\s :: DescribeConfigurations
s@DescribeConfigurations' {} [Text]
a -> DescribeConfigurations
s {$sel:configurationIds:DescribeConfigurations' :: [Text]
configurationIds = [Text]
a} :: DescribeConfigurations) (([Text] -> f [Text])
 -> DescribeConfigurations -> f DescribeConfigurations)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DescribeConfigurations
-> f DescribeConfigurations
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeConfigurations

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

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

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

-- | /See:/ 'newDescribeConfigurationsResponse' smart constructor.
data DescribeConfigurationsResponse = DescribeConfigurationsResponse'
  { -- | A key in the response map. The value is an array of data.
    DescribeConfigurationsResponse -> Maybe [HashMap Text Text]
configurations :: Prelude.Maybe [Prelude.HashMap Prelude.Text Prelude.Text],
    -- | The response's http status code.
    DescribeConfigurationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeConfigurationsResponse
-> DescribeConfigurationsResponse -> Bool
(DescribeConfigurationsResponse
 -> DescribeConfigurationsResponse -> Bool)
-> (DescribeConfigurationsResponse
    -> DescribeConfigurationsResponse -> Bool)
-> Eq DescribeConfigurationsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeConfigurationsResponse
-> DescribeConfigurationsResponse -> Bool
$c/= :: DescribeConfigurationsResponse
-> DescribeConfigurationsResponse -> Bool
== :: DescribeConfigurationsResponse
-> DescribeConfigurationsResponse -> Bool
$c== :: DescribeConfigurationsResponse
-> DescribeConfigurationsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeConfigurationsResponse]
ReadPrec DescribeConfigurationsResponse
Int -> ReadS DescribeConfigurationsResponse
ReadS [DescribeConfigurationsResponse]
(Int -> ReadS DescribeConfigurationsResponse)
-> ReadS [DescribeConfigurationsResponse]
-> ReadPrec DescribeConfigurationsResponse
-> ReadPrec [DescribeConfigurationsResponse]
-> Read DescribeConfigurationsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeConfigurationsResponse]
$creadListPrec :: ReadPrec [DescribeConfigurationsResponse]
readPrec :: ReadPrec DescribeConfigurationsResponse
$creadPrec :: ReadPrec DescribeConfigurationsResponse
readList :: ReadS [DescribeConfigurationsResponse]
$creadList :: ReadS [DescribeConfigurationsResponse]
readsPrec :: Int -> ReadS DescribeConfigurationsResponse
$creadsPrec :: Int -> ReadS DescribeConfigurationsResponse
Prelude.Read, Int -> DescribeConfigurationsResponse -> ShowS
[DescribeConfigurationsResponse] -> ShowS
DescribeConfigurationsResponse -> String
(Int -> DescribeConfigurationsResponse -> ShowS)
-> (DescribeConfigurationsResponse -> String)
-> ([DescribeConfigurationsResponse] -> ShowS)
-> Show DescribeConfigurationsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeConfigurationsResponse] -> ShowS
$cshowList :: [DescribeConfigurationsResponse] -> ShowS
show :: DescribeConfigurationsResponse -> String
$cshow :: DescribeConfigurationsResponse -> String
showsPrec :: Int -> DescribeConfigurationsResponse -> ShowS
$cshowsPrec :: Int -> DescribeConfigurationsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeConfigurationsResponse
 -> Rep DescribeConfigurationsResponse x)
-> (forall x.
    Rep DescribeConfigurationsResponse x
    -> DescribeConfigurationsResponse)
-> Generic DescribeConfigurationsResponse
forall x.
Rep DescribeConfigurationsResponse x
-> DescribeConfigurationsResponse
forall x.
DescribeConfigurationsResponse
-> Rep DescribeConfigurationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeConfigurationsResponse x
-> DescribeConfigurationsResponse
$cfrom :: forall x.
DescribeConfigurationsResponse
-> Rep DescribeConfigurationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeConfigurationsResponse' 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:
--
-- 'configurations', 'describeConfigurationsResponse_configurations' - A key in the response map. The value is an array of data.
--
-- 'httpStatus', 'describeConfigurationsResponse_httpStatus' - The response's http status code.
newDescribeConfigurationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeConfigurationsResponse
newDescribeConfigurationsResponse :: Int -> DescribeConfigurationsResponse
newDescribeConfigurationsResponse Int
pHttpStatus_ =
  DescribeConfigurationsResponse' :: Maybe [HashMap Text Text] -> Int -> DescribeConfigurationsResponse
DescribeConfigurationsResponse'
    { $sel:configurations:DescribeConfigurationsResponse' :: Maybe [HashMap Text Text]
configurations =
        Maybe [HashMap Text Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeConfigurationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A key in the response map. The value is an array of data.
describeConfigurationsResponse_configurations :: Lens.Lens' DescribeConfigurationsResponse (Prelude.Maybe [Prelude.HashMap Prelude.Text Prelude.Text])
describeConfigurationsResponse_configurations :: (Maybe [HashMap Text Text] -> f (Maybe [HashMap Text Text]))
-> DescribeConfigurationsResponse
-> f DescribeConfigurationsResponse
describeConfigurationsResponse_configurations = (DescribeConfigurationsResponse -> Maybe [HashMap Text Text])
-> (DescribeConfigurationsResponse
    -> Maybe [HashMap Text Text] -> DescribeConfigurationsResponse)
-> Lens
     DescribeConfigurationsResponse
     DescribeConfigurationsResponse
     (Maybe [HashMap Text Text])
     (Maybe [HashMap Text Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeConfigurationsResponse' {Maybe [HashMap Text Text]
configurations :: Maybe [HashMap Text Text]
$sel:configurations:DescribeConfigurationsResponse' :: DescribeConfigurationsResponse -> Maybe [HashMap Text Text]
configurations} -> Maybe [HashMap Text Text]
configurations) (\s :: DescribeConfigurationsResponse
s@DescribeConfigurationsResponse' {} Maybe [HashMap Text Text]
a -> DescribeConfigurationsResponse
s {$sel:configurations:DescribeConfigurationsResponse' :: Maybe [HashMap Text Text]
configurations = Maybe [HashMap Text Text]
a} :: DescribeConfigurationsResponse) ((Maybe [HashMap Text Text] -> f (Maybe [HashMap Text Text]))
 -> DescribeConfigurationsResponse
 -> f DescribeConfigurationsResponse)
-> ((Maybe [HashMap Text Text] -> f (Maybe [HashMap Text Text]))
    -> Maybe [HashMap Text Text] -> f (Maybe [HashMap Text Text]))
-> (Maybe [HashMap Text Text] -> f (Maybe [HashMap Text Text]))
-> DescribeConfigurationsResponse
-> f DescribeConfigurationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [HashMap Text Text]
  [HashMap Text Text]
  [HashMap Text Text]
  [HashMap Text Text]
-> Iso
     (Maybe [HashMap Text Text])
     (Maybe [HashMap Text Text])
     (Maybe [HashMap Text Text])
     (Maybe [HashMap Text 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
  [HashMap Text Text]
  [HashMap Text Text]
  [HashMap Text Text]
  [HashMap 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.
describeConfigurationsResponse_httpStatus :: Lens.Lens' DescribeConfigurationsResponse Prelude.Int
describeConfigurationsResponse_httpStatus :: (Int -> f Int)
-> DescribeConfigurationsResponse
-> f DescribeConfigurationsResponse
describeConfigurationsResponse_httpStatus = (DescribeConfigurationsResponse -> Int)
-> (DescribeConfigurationsResponse
    -> Int -> DescribeConfigurationsResponse)
-> Lens
     DescribeConfigurationsResponse
     DescribeConfigurationsResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeConfigurationsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeConfigurationsResponse' :: DescribeConfigurationsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeConfigurationsResponse
s@DescribeConfigurationsResponse' {} Int
a -> DescribeConfigurationsResponse
s {$sel:httpStatus:DescribeConfigurationsResponse' :: Int
httpStatus = Int
a} :: DescribeConfigurationsResponse)

instance
  Prelude.NFData
    DescribeConfigurationsResponse