{-# 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.DescribeElasticsearchDomain
-- 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 domain, including the domain ID, domain endpoint, and
-- domain ARN.
module Amazonka.ElasticSearch.DescribeElasticsearchDomain
  ( -- * Creating a Request
    DescribeElasticsearchDomain (..),
    newDescribeElasticsearchDomain,

    -- * Request Lenses
    describeElasticsearchDomain_domainName,

    -- * Destructuring the Response
    DescribeElasticsearchDomainResponse (..),
    newDescribeElasticsearchDomainResponse,

    -- * Response Lenses
    describeElasticsearchDomainResponse_httpStatus,
    describeElasticsearchDomainResponse_domainStatus,
  )
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 @DescribeElasticsearchDomain@
-- operation.
--
-- /See:/ 'newDescribeElasticsearchDomain' smart constructor.
data DescribeElasticsearchDomain = DescribeElasticsearchDomain'
  { -- | The name of the Elasticsearch domain for which you want information.
    DescribeElasticsearchDomain -> Text
domainName :: Prelude.Text
  }
  deriving (DescribeElasticsearchDomain -> DescribeElasticsearchDomain -> Bool
(DescribeElasticsearchDomain
 -> DescribeElasticsearchDomain -> Bool)
-> (DescribeElasticsearchDomain
    -> DescribeElasticsearchDomain -> Bool)
-> Eq DescribeElasticsearchDomain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeElasticsearchDomain -> DescribeElasticsearchDomain -> Bool
$c/= :: DescribeElasticsearchDomain -> DescribeElasticsearchDomain -> Bool
== :: DescribeElasticsearchDomain -> DescribeElasticsearchDomain -> Bool
$c== :: DescribeElasticsearchDomain -> DescribeElasticsearchDomain -> Bool
Prelude.Eq, ReadPrec [DescribeElasticsearchDomain]
ReadPrec DescribeElasticsearchDomain
Int -> ReadS DescribeElasticsearchDomain
ReadS [DescribeElasticsearchDomain]
(Int -> ReadS DescribeElasticsearchDomain)
-> ReadS [DescribeElasticsearchDomain]
-> ReadPrec DescribeElasticsearchDomain
-> ReadPrec [DescribeElasticsearchDomain]
-> Read DescribeElasticsearchDomain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeElasticsearchDomain]
$creadListPrec :: ReadPrec [DescribeElasticsearchDomain]
readPrec :: ReadPrec DescribeElasticsearchDomain
$creadPrec :: ReadPrec DescribeElasticsearchDomain
readList :: ReadS [DescribeElasticsearchDomain]
$creadList :: ReadS [DescribeElasticsearchDomain]
readsPrec :: Int -> ReadS DescribeElasticsearchDomain
$creadsPrec :: Int -> ReadS DescribeElasticsearchDomain
Prelude.Read, Int -> DescribeElasticsearchDomain -> ShowS
[DescribeElasticsearchDomain] -> ShowS
DescribeElasticsearchDomain -> String
(Int -> DescribeElasticsearchDomain -> ShowS)
-> (DescribeElasticsearchDomain -> String)
-> ([DescribeElasticsearchDomain] -> ShowS)
-> Show DescribeElasticsearchDomain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeElasticsearchDomain] -> ShowS
$cshowList :: [DescribeElasticsearchDomain] -> ShowS
show :: DescribeElasticsearchDomain -> String
$cshow :: DescribeElasticsearchDomain -> String
showsPrec :: Int -> DescribeElasticsearchDomain -> ShowS
$cshowsPrec :: Int -> DescribeElasticsearchDomain -> ShowS
Prelude.Show, (forall x.
 DescribeElasticsearchDomain -> Rep DescribeElasticsearchDomain x)
-> (forall x.
    Rep DescribeElasticsearchDomain x -> DescribeElasticsearchDomain)
-> Generic DescribeElasticsearchDomain
forall x.
Rep DescribeElasticsearchDomain x -> DescribeElasticsearchDomain
forall x.
DescribeElasticsearchDomain -> Rep DescribeElasticsearchDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeElasticsearchDomain x -> DescribeElasticsearchDomain
$cfrom :: forall x.
DescribeElasticsearchDomain -> Rep DescribeElasticsearchDomain x
Prelude.Generic)

-- |
-- Create a value of 'DescribeElasticsearchDomain' 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:
--
-- 'domainName', 'describeElasticsearchDomain_domainName' - The name of the Elasticsearch domain for which you want information.
newDescribeElasticsearchDomain ::
  -- | 'domainName'
  Prelude.Text ->
  DescribeElasticsearchDomain
newDescribeElasticsearchDomain :: Text -> DescribeElasticsearchDomain
newDescribeElasticsearchDomain Text
pDomainName_ =
  DescribeElasticsearchDomain' :: Text -> DescribeElasticsearchDomain
DescribeElasticsearchDomain'
    { $sel:domainName:DescribeElasticsearchDomain' :: Text
domainName =
        Text
pDomainName_
    }

-- | The name of the Elasticsearch domain for which you want information.
describeElasticsearchDomain_domainName :: Lens.Lens' DescribeElasticsearchDomain Prelude.Text
describeElasticsearchDomain_domainName :: (Text -> f Text)
-> DescribeElasticsearchDomain -> f DescribeElasticsearchDomain
describeElasticsearchDomain_domainName = (DescribeElasticsearchDomain -> Text)
-> (DescribeElasticsearchDomain
    -> Text -> DescribeElasticsearchDomain)
-> Lens
     DescribeElasticsearchDomain DescribeElasticsearchDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeElasticsearchDomain' {Text
domainName :: Text
$sel:domainName:DescribeElasticsearchDomain' :: DescribeElasticsearchDomain -> Text
domainName} -> Text
domainName) (\s :: DescribeElasticsearchDomain
s@DescribeElasticsearchDomain' {} Text
a -> DescribeElasticsearchDomain
s {$sel:domainName:DescribeElasticsearchDomain' :: Text
domainName = Text
a} :: DescribeElasticsearchDomain)

instance Core.AWSRequest DescribeElasticsearchDomain where
  type
    AWSResponse DescribeElasticsearchDomain =
      DescribeElasticsearchDomainResponse
  request :: DescribeElasticsearchDomain -> Request DescribeElasticsearchDomain
request = Service
-> DescribeElasticsearchDomain
-> Request DescribeElasticsearchDomain
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeElasticsearchDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeElasticsearchDomain)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeElasticsearchDomain))
-> Logger
-> Service
-> Proxy DescribeElasticsearchDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeElasticsearchDomain)))
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 -> DescribeElasticsearchDomainResponse
DescribeElasticsearchDomainResponse'
            (Int
 -> ElasticsearchDomainStatus
 -> DescribeElasticsearchDomainResponse)
-> Either String Int
-> Either
     String
     (ElasticsearchDomainStatus -> DescribeElasticsearchDomainResponse)
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 -> DescribeElasticsearchDomainResponse)
-> Either String ElasticsearchDomainStatus
-> Either String DescribeElasticsearchDomainResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String ElasticsearchDomainStatus
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"DomainStatus")
      )

instance Prelude.Hashable DescribeElasticsearchDomain

instance Prelude.NFData DescribeElasticsearchDomain

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

instance Core.ToPath DescribeElasticsearchDomain where
  toPath :: DescribeElasticsearchDomain -> ByteString
toPath DescribeElasticsearchDomain' {Text
domainName :: Text
$sel:domainName:DescribeElasticsearchDomain' :: DescribeElasticsearchDomain -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2015-01-01/es/domain/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
domainName]

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

-- | The result of a @DescribeElasticsearchDomain@ request. Contains the
-- status of the domain specified in the request.
--
-- /See:/ 'newDescribeElasticsearchDomainResponse' smart constructor.
data DescribeElasticsearchDomainResponse = DescribeElasticsearchDomainResponse'
  { -- | The response's http status code.
    DescribeElasticsearchDomainResponse -> Int
httpStatus :: Prelude.Int,
    -- | The current status of the Elasticsearch domain.
    DescribeElasticsearchDomainResponse -> ElasticsearchDomainStatus
domainStatus :: ElasticsearchDomainStatus
  }
  deriving (DescribeElasticsearchDomainResponse
-> DescribeElasticsearchDomainResponse -> Bool
(DescribeElasticsearchDomainResponse
 -> DescribeElasticsearchDomainResponse -> Bool)
-> (DescribeElasticsearchDomainResponse
    -> DescribeElasticsearchDomainResponse -> Bool)
-> Eq DescribeElasticsearchDomainResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeElasticsearchDomainResponse
-> DescribeElasticsearchDomainResponse -> Bool
$c/= :: DescribeElasticsearchDomainResponse
-> DescribeElasticsearchDomainResponse -> Bool
== :: DescribeElasticsearchDomainResponse
-> DescribeElasticsearchDomainResponse -> Bool
$c== :: DescribeElasticsearchDomainResponse
-> DescribeElasticsearchDomainResponse -> Bool
Prelude.Eq, ReadPrec [DescribeElasticsearchDomainResponse]
ReadPrec DescribeElasticsearchDomainResponse
Int -> ReadS DescribeElasticsearchDomainResponse
ReadS [DescribeElasticsearchDomainResponse]
(Int -> ReadS DescribeElasticsearchDomainResponse)
-> ReadS [DescribeElasticsearchDomainResponse]
-> ReadPrec DescribeElasticsearchDomainResponse
-> ReadPrec [DescribeElasticsearchDomainResponse]
-> Read DescribeElasticsearchDomainResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeElasticsearchDomainResponse]
$creadListPrec :: ReadPrec [DescribeElasticsearchDomainResponse]
readPrec :: ReadPrec DescribeElasticsearchDomainResponse
$creadPrec :: ReadPrec DescribeElasticsearchDomainResponse
readList :: ReadS [DescribeElasticsearchDomainResponse]
$creadList :: ReadS [DescribeElasticsearchDomainResponse]
readsPrec :: Int -> ReadS DescribeElasticsearchDomainResponse
$creadsPrec :: Int -> ReadS DescribeElasticsearchDomainResponse
Prelude.Read, Int -> DescribeElasticsearchDomainResponse -> ShowS
[DescribeElasticsearchDomainResponse] -> ShowS
DescribeElasticsearchDomainResponse -> String
(Int -> DescribeElasticsearchDomainResponse -> ShowS)
-> (DescribeElasticsearchDomainResponse -> String)
-> ([DescribeElasticsearchDomainResponse] -> ShowS)
-> Show DescribeElasticsearchDomainResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeElasticsearchDomainResponse] -> ShowS
$cshowList :: [DescribeElasticsearchDomainResponse] -> ShowS
show :: DescribeElasticsearchDomainResponse -> String
$cshow :: DescribeElasticsearchDomainResponse -> String
showsPrec :: Int -> DescribeElasticsearchDomainResponse -> ShowS
$cshowsPrec :: Int -> DescribeElasticsearchDomainResponse -> ShowS
Prelude.Show, (forall x.
 DescribeElasticsearchDomainResponse
 -> Rep DescribeElasticsearchDomainResponse x)
-> (forall x.
    Rep DescribeElasticsearchDomainResponse x
    -> DescribeElasticsearchDomainResponse)
-> Generic DescribeElasticsearchDomainResponse
forall x.
Rep DescribeElasticsearchDomainResponse x
-> DescribeElasticsearchDomainResponse
forall x.
DescribeElasticsearchDomainResponse
-> Rep DescribeElasticsearchDomainResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeElasticsearchDomainResponse x
-> DescribeElasticsearchDomainResponse
$cfrom :: forall x.
DescribeElasticsearchDomainResponse
-> Rep DescribeElasticsearchDomainResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeElasticsearchDomainResponse' 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', 'describeElasticsearchDomainResponse_httpStatus' - The response's http status code.
--
-- 'domainStatus', 'describeElasticsearchDomainResponse_domainStatus' - The current status of the Elasticsearch domain.
newDescribeElasticsearchDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'domainStatus'
  ElasticsearchDomainStatus ->
  DescribeElasticsearchDomainResponse
newDescribeElasticsearchDomainResponse :: Int
-> ElasticsearchDomainStatus -> DescribeElasticsearchDomainResponse
newDescribeElasticsearchDomainResponse
  Int
pHttpStatus_
  ElasticsearchDomainStatus
pDomainStatus_ =
    DescribeElasticsearchDomainResponse' :: Int
-> ElasticsearchDomainStatus -> DescribeElasticsearchDomainResponse
DescribeElasticsearchDomainResponse'
      { $sel:httpStatus:DescribeElasticsearchDomainResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:domainStatus:DescribeElasticsearchDomainResponse' :: ElasticsearchDomainStatus
domainStatus = ElasticsearchDomainStatus
pDomainStatus_
      }

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

-- | The current status of the Elasticsearch domain.
describeElasticsearchDomainResponse_domainStatus :: Lens.Lens' DescribeElasticsearchDomainResponse ElasticsearchDomainStatus
describeElasticsearchDomainResponse_domainStatus :: (ElasticsearchDomainStatus -> f ElasticsearchDomainStatus)
-> DescribeElasticsearchDomainResponse
-> f DescribeElasticsearchDomainResponse
describeElasticsearchDomainResponse_domainStatus = (DescribeElasticsearchDomainResponse -> ElasticsearchDomainStatus)
-> (DescribeElasticsearchDomainResponse
    -> ElasticsearchDomainStatus
    -> DescribeElasticsearchDomainResponse)
-> Lens
     DescribeElasticsearchDomainResponse
     DescribeElasticsearchDomainResponse
     ElasticsearchDomainStatus
     ElasticsearchDomainStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeElasticsearchDomainResponse' {ElasticsearchDomainStatus
domainStatus :: ElasticsearchDomainStatus
$sel:domainStatus:DescribeElasticsearchDomainResponse' :: DescribeElasticsearchDomainResponse -> ElasticsearchDomainStatus
domainStatus} -> ElasticsearchDomainStatus
domainStatus) (\s :: DescribeElasticsearchDomainResponse
s@DescribeElasticsearchDomainResponse' {} ElasticsearchDomainStatus
a -> DescribeElasticsearchDomainResponse
s {$sel:domainStatus:DescribeElasticsearchDomainResponse' :: ElasticsearchDomainStatus
domainStatus = ElasticsearchDomainStatus
a} :: DescribeElasticsearchDomainResponse)

instance
  Prelude.NFData
    DescribeElasticsearchDomainResponse