{-# 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.ElasticSearch.DescribeElasticsearchDomains
-- 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 domain configuration information about the specified
-- Elasticsearch domains, including the domain ID, domain endpoint, and
-- domain ARN.
module Amazonka.ElasticSearch.DescribeElasticsearchDomains
  ( -- * Creating a Request
    DescribeElasticsearchDomains (..),
    newDescribeElasticsearchDomains,

    -- * Request Lenses
    describeElasticsearchDomains_domainNames,

    -- * Destructuring the Response
    DescribeElasticsearchDomainsResponse (..),
    newDescribeElasticsearchDomainsResponse,

    -- * Response Lenses
    describeElasticsearchDomainsResponse_httpStatus,
    describeElasticsearchDomainsResponse_domainStatusList,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ElasticSearch.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

-- | Container for the parameters to the @DescribeElasticsearchDomains@
-- operation. By default, the API returns the status of all Elasticsearch
-- domains.
--
-- /See:/ 'newDescribeElasticsearchDomains' smart constructor.
data DescribeElasticsearchDomains = DescribeElasticsearchDomains'
  { -- | The Elasticsearch domains for which you want information.
    DescribeElasticsearchDomains -> [Text]
domainNames :: [Prelude.Text]
  }
  deriving (DescribeElasticsearchDomains
-> DescribeElasticsearchDomains -> Bool
(DescribeElasticsearchDomains
 -> DescribeElasticsearchDomains -> Bool)
-> (DescribeElasticsearchDomains
    -> DescribeElasticsearchDomains -> Bool)
-> Eq DescribeElasticsearchDomains
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeElasticsearchDomains
-> DescribeElasticsearchDomains -> Bool
$c/= :: DescribeElasticsearchDomains
-> DescribeElasticsearchDomains -> Bool
== :: DescribeElasticsearchDomains
-> DescribeElasticsearchDomains -> Bool
$c== :: DescribeElasticsearchDomains
-> DescribeElasticsearchDomains -> Bool
Prelude.Eq, ReadPrec [DescribeElasticsearchDomains]
ReadPrec DescribeElasticsearchDomains
Int -> ReadS DescribeElasticsearchDomains
ReadS [DescribeElasticsearchDomains]
(Int -> ReadS DescribeElasticsearchDomains)
-> ReadS [DescribeElasticsearchDomains]
-> ReadPrec DescribeElasticsearchDomains
-> ReadPrec [DescribeElasticsearchDomains]
-> Read DescribeElasticsearchDomains
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeElasticsearchDomains]
$creadListPrec :: ReadPrec [DescribeElasticsearchDomains]
readPrec :: ReadPrec DescribeElasticsearchDomains
$creadPrec :: ReadPrec DescribeElasticsearchDomains
readList :: ReadS [DescribeElasticsearchDomains]
$creadList :: ReadS [DescribeElasticsearchDomains]
readsPrec :: Int -> ReadS DescribeElasticsearchDomains
$creadsPrec :: Int -> ReadS DescribeElasticsearchDomains
Prelude.Read, Int -> DescribeElasticsearchDomains -> ShowS
[DescribeElasticsearchDomains] -> ShowS
DescribeElasticsearchDomains -> String
(Int -> DescribeElasticsearchDomains -> ShowS)
-> (DescribeElasticsearchDomains -> String)
-> ([DescribeElasticsearchDomains] -> ShowS)
-> Show DescribeElasticsearchDomains
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeElasticsearchDomains] -> ShowS
$cshowList :: [DescribeElasticsearchDomains] -> ShowS
show :: DescribeElasticsearchDomains -> String
$cshow :: DescribeElasticsearchDomains -> String
showsPrec :: Int -> DescribeElasticsearchDomains -> ShowS
$cshowsPrec :: Int -> DescribeElasticsearchDomains -> ShowS
Prelude.Show, (forall x.
 DescribeElasticsearchDomains -> Rep DescribeElasticsearchDomains x)
-> (forall x.
    Rep DescribeElasticsearchDomains x -> DescribeElasticsearchDomains)
-> Generic DescribeElasticsearchDomains
forall x.
Rep DescribeElasticsearchDomains x -> DescribeElasticsearchDomains
forall x.
DescribeElasticsearchDomains -> Rep DescribeElasticsearchDomains x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeElasticsearchDomains x -> DescribeElasticsearchDomains
$cfrom :: forall x.
DescribeElasticsearchDomains -> Rep DescribeElasticsearchDomains x
Prelude.Generic)

-- |
-- Create a value of 'DescribeElasticsearchDomains' 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:
--
-- 'domainNames', 'describeElasticsearchDomains_domainNames' - The Elasticsearch domains for which you want information.
newDescribeElasticsearchDomains ::
  DescribeElasticsearchDomains
newDescribeElasticsearchDomains :: DescribeElasticsearchDomains
newDescribeElasticsearchDomains =
  DescribeElasticsearchDomains' :: [Text] -> DescribeElasticsearchDomains
DescribeElasticsearchDomains'
    { $sel:domainNames:DescribeElasticsearchDomains' :: [Text]
domainNames =
        [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The Elasticsearch domains for which you want information.
describeElasticsearchDomains_domainNames :: Lens.Lens' DescribeElasticsearchDomains [Prelude.Text]
describeElasticsearchDomains_domainNames :: ([Text] -> f [Text])
-> DescribeElasticsearchDomains -> f DescribeElasticsearchDomains
describeElasticsearchDomains_domainNames = (DescribeElasticsearchDomains -> [Text])
-> (DescribeElasticsearchDomains
    -> [Text] -> DescribeElasticsearchDomains)
-> Lens
     DescribeElasticsearchDomains
     DescribeElasticsearchDomains
     [Text]
     [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeElasticsearchDomains' {[Text]
domainNames :: [Text]
$sel:domainNames:DescribeElasticsearchDomains' :: DescribeElasticsearchDomains -> [Text]
domainNames} -> [Text]
domainNames) (\s :: DescribeElasticsearchDomains
s@DescribeElasticsearchDomains' {} [Text]
a -> DescribeElasticsearchDomains
s {$sel:domainNames:DescribeElasticsearchDomains' :: [Text]
domainNames = [Text]
a} :: DescribeElasticsearchDomains) (([Text] -> f [Text])
 -> DescribeElasticsearchDomains -> f DescribeElasticsearchDomains)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DescribeElasticsearchDomains
-> f DescribeElasticsearchDomains
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 DescribeElasticsearchDomains where
  type
    AWSResponse DescribeElasticsearchDomains =
      DescribeElasticsearchDomainsResponse
  request :: DescribeElasticsearchDomains
-> Request DescribeElasticsearchDomains
request = Service
-> DescribeElasticsearchDomains
-> Request DescribeElasticsearchDomains
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeElasticsearchDomains
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeElasticsearchDomains)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeElasticsearchDomains))
-> Logger
-> Service
-> Proxy DescribeElasticsearchDomains
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeElasticsearchDomains)))
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 ->
          Int
-> [ElasticsearchDomainStatus]
-> DescribeElasticsearchDomainsResponse
DescribeElasticsearchDomainsResponse'
            (Int
 -> [ElasticsearchDomainStatus]
 -> DescribeElasticsearchDomainsResponse)
-> Either String Int
-> Either
     String
     ([ElasticsearchDomainStatus]
      -> DescribeElasticsearchDomainsResponse)
forall (f :: * -> *) a b. Functor 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))
            Either
  String
  ([ElasticsearchDomainStatus]
   -> DescribeElasticsearchDomainsResponse)
-> Either String [ElasticsearchDomainStatus]
-> Either String DescribeElasticsearchDomainsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe [ElasticsearchDomainStatus])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DomainStatusList"
                            Either String (Maybe [ElasticsearchDomainStatus])
-> [ElasticsearchDomainStatus]
-> Either String [ElasticsearchDomainStatus]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [ElasticsearchDomainStatus]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance
  Prelude.Hashable
    DescribeElasticsearchDomains

instance Prelude.NFData DescribeElasticsearchDomains

instance Core.ToHeaders DescribeElasticsearchDomains where
  toHeaders :: DescribeElasticsearchDomains -> ResponseHeaders
toHeaders = ResponseHeaders -> DescribeElasticsearchDomains -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON DescribeElasticsearchDomains where
  toJSON :: DescribeElasticsearchDomains -> Value
toJSON DescribeElasticsearchDomains' {[Text]
domainNames :: [Text]
$sel:domainNames:DescribeElasticsearchDomains' :: DescribeElasticsearchDomains -> [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
"DomainNames" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
domainNames)]
      )

instance Core.ToPath DescribeElasticsearchDomains where
  toPath :: DescribeElasticsearchDomains -> ByteString
toPath = ByteString -> DescribeElasticsearchDomains -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/2015-01-01/es/domain-info"

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

-- | The result of a @DescribeElasticsearchDomains@ request. Contains the
-- status of the specified domains or all domains owned by the account.
--
-- /See:/ 'newDescribeElasticsearchDomainsResponse' smart constructor.
data DescribeElasticsearchDomainsResponse = DescribeElasticsearchDomainsResponse'
  { -- | The response's http status code.
    DescribeElasticsearchDomainsResponse -> Int
httpStatus :: Prelude.Int,
    -- | The status of the domains requested in the
    -- @DescribeElasticsearchDomains@ request.
    DescribeElasticsearchDomainsResponse -> [ElasticsearchDomainStatus]
domainStatusList :: [ElasticsearchDomainStatus]
  }
  deriving (DescribeElasticsearchDomainsResponse
-> DescribeElasticsearchDomainsResponse -> Bool
(DescribeElasticsearchDomainsResponse
 -> DescribeElasticsearchDomainsResponse -> Bool)
-> (DescribeElasticsearchDomainsResponse
    -> DescribeElasticsearchDomainsResponse -> Bool)
-> Eq DescribeElasticsearchDomainsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeElasticsearchDomainsResponse
-> DescribeElasticsearchDomainsResponse -> Bool
$c/= :: DescribeElasticsearchDomainsResponse
-> DescribeElasticsearchDomainsResponse -> Bool
== :: DescribeElasticsearchDomainsResponse
-> DescribeElasticsearchDomainsResponse -> Bool
$c== :: DescribeElasticsearchDomainsResponse
-> DescribeElasticsearchDomainsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeElasticsearchDomainsResponse]
ReadPrec DescribeElasticsearchDomainsResponse
Int -> ReadS DescribeElasticsearchDomainsResponse
ReadS [DescribeElasticsearchDomainsResponse]
(Int -> ReadS DescribeElasticsearchDomainsResponse)
-> ReadS [DescribeElasticsearchDomainsResponse]
-> ReadPrec DescribeElasticsearchDomainsResponse
-> ReadPrec [DescribeElasticsearchDomainsResponse]
-> Read DescribeElasticsearchDomainsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeElasticsearchDomainsResponse]
$creadListPrec :: ReadPrec [DescribeElasticsearchDomainsResponse]
readPrec :: ReadPrec DescribeElasticsearchDomainsResponse
$creadPrec :: ReadPrec DescribeElasticsearchDomainsResponse
readList :: ReadS [DescribeElasticsearchDomainsResponse]
$creadList :: ReadS [DescribeElasticsearchDomainsResponse]
readsPrec :: Int -> ReadS DescribeElasticsearchDomainsResponse
$creadsPrec :: Int -> ReadS DescribeElasticsearchDomainsResponse
Prelude.Read, Int -> DescribeElasticsearchDomainsResponse -> ShowS
[DescribeElasticsearchDomainsResponse] -> ShowS
DescribeElasticsearchDomainsResponse -> String
(Int -> DescribeElasticsearchDomainsResponse -> ShowS)
-> (DescribeElasticsearchDomainsResponse -> String)
-> ([DescribeElasticsearchDomainsResponse] -> ShowS)
-> Show DescribeElasticsearchDomainsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeElasticsearchDomainsResponse] -> ShowS
$cshowList :: [DescribeElasticsearchDomainsResponse] -> ShowS
show :: DescribeElasticsearchDomainsResponse -> String
$cshow :: DescribeElasticsearchDomainsResponse -> String
showsPrec :: Int -> DescribeElasticsearchDomainsResponse -> ShowS
$cshowsPrec :: Int -> DescribeElasticsearchDomainsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeElasticsearchDomainsResponse
 -> Rep DescribeElasticsearchDomainsResponse x)
-> (forall x.
    Rep DescribeElasticsearchDomainsResponse x
    -> DescribeElasticsearchDomainsResponse)
-> Generic DescribeElasticsearchDomainsResponse
forall x.
Rep DescribeElasticsearchDomainsResponse x
-> DescribeElasticsearchDomainsResponse
forall x.
DescribeElasticsearchDomainsResponse
-> Rep DescribeElasticsearchDomainsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeElasticsearchDomainsResponse x
-> DescribeElasticsearchDomainsResponse
$cfrom :: forall x.
DescribeElasticsearchDomainsResponse
-> Rep DescribeElasticsearchDomainsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeElasticsearchDomainsResponse' 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:
--
-- 'httpStatus', 'describeElasticsearchDomainsResponse_httpStatus' - The response's http status code.
--
-- 'domainStatusList', 'describeElasticsearchDomainsResponse_domainStatusList' - The status of the domains requested in the
-- @DescribeElasticsearchDomains@ request.
newDescribeElasticsearchDomainsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeElasticsearchDomainsResponse
newDescribeElasticsearchDomainsResponse :: Int -> DescribeElasticsearchDomainsResponse
newDescribeElasticsearchDomainsResponse Int
pHttpStatus_ =
  DescribeElasticsearchDomainsResponse' :: Int
-> [ElasticsearchDomainStatus]
-> DescribeElasticsearchDomainsResponse
DescribeElasticsearchDomainsResponse'
    { $sel:httpStatus:DescribeElasticsearchDomainsResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:domainStatusList:DescribeElasticsearchDomainsResponse' :: [ElasticsearchDomainStatus]
domainStatusList = [ElasticsearchDomainStatus]
forall a. Monoid a => a
Prelude.mempty
    }

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

-- | The status of the domains requested in the
-- @DescribeElasticsearchDomains@ request.
describeElasticsearchDomainsResponse_domainStatusList :: Lens.Lens' DescribeElasticsearchDomainsResponse [ElasticsearchDomainStatus]
describeElasticsearchDomainsResponse_domainStatusList :: ([ElasticsearchDomainStatus] -> f [ElasticsearchDomainStatus])
-> DescribeElasticsearchDomainsResponse
-> f DescribeElasticsearchDomainsResponse
describeElasticsearchDomainsResponse_domainStatusList = (DescribeElasticsearchDomainsResponse
 -> [ElasticsearchDomainStatus])
-> (DescribeElasticsearchDomainsResponse
    -> [ElasticsearchDomainStatus]
    -> DescribeElasticsearchDomainsResponse)
-> Lens
     DescribeElasticsearchDomainsResponse
     DescribeElasticsearchDomainsResponse
     [ElasticsearchDomainStatus]
     [ElasticsearchDomainStatus]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeElasticsearchDomainsResponse' {[ElasticsearchDomainStatus]
domainStatusList :: [ElasticsearchDomainStatus]
$sel:domainStatusList:DescribeElasticsearchDomainsResponse' :: DescribeElasticsearchDomainsResponse -> [ElasticsearchDomainStatus]
domainStatusList} -> [ElasticsearchDomainStatus]
domainStatusList) (\s :: DescribeElasticsearchDomainsResponse
s@DescribeElasticsearchDomainsResponse' {} [ElasticsearchDomainStatus]
a -> DescribeElasticsearchDomainsResponse
s {$sel:domainStatusList:DescribeElasticsearchDomainsResponse' :: [ElasticsearchDomainStatus]
domainStatusList = [ElasticsearchDomainStatus]
a} :: DescribeElasticsearchDomainsResponse) (([ElasticsearchDomainStatus] -> f [ElasticsearchDomainStatus])
 -> DescribeElasticsearchDomainsResponse
 -> f DescribeElasticsearchDomainsResponse)
-> (([ElasticsearchDomainStatus] -> f [ElasticsearchDomainStatus])
    -> [ElasticsearchDomainStatus] -> f [ElasticsearchDomainStatus])
-> ([ElasticsearchDomainStatus] -> f [ElasticsearchDomainStatus])
-> DescribeElasticsearchDomainsResponse
-> f DescribeElasticsearchDomainsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ElasticsearchDomainStatus] -> f [ElasticsearchDomainStatus])
-> [ElasticsearchDomainStatus] -> f [ElasticsearchDomainStatus]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.NFData
    DescribeElasticsearchDomainsResponse