{-# 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.ListDomainNames
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the name of all Elasticsearch domains owned by the current
-- user\'s account.
module Amazonka.ElasticSearch.ListDomainNames
  ( -- * Creating a Request
    ListDomainNames (..),
    newListDomainNames,

    -- * Request Lenses
    listDomainNames_engineType,

    -- * Destructuring the Response
    ListDomainNamesResponse (..),
    newListDomainNamesResponse,

    -- * Response Lenses
    listDomainNamesResponse_domainNames,
    listDomainNamesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElasticSearch.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Container for the parameters to the @ListDomainNames@ operation.
--
-- /See:/ 'newListDomainNames' smart constructor.
data ListDomainNames = ListDomainNames'
  { -- | Optional parameter to filter the output by domain engine type.
    -- Acceptable values are \'Elasticsearch\' and \'OpenSearch\'.
    ListDomainNames -> Maybe EngineType
engineType :: Prelude.Maybe EngineType
  }
  deriving (ListDomainNames -> ListDomainNames -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDomainNames -> ListDomainNames -> Bool
$c/= :: ListDomainNames -> ListDomainNames -> Bool
== :: ListDomainNames -> ListDomainNames -> Bool
$c== :: ListDomainNames -> ListDomainNames -> Bool
Prelude.Eq, ReadPrec [ListDomainNames]
ReadPrec ListDomainNames
Int -> ReadS ListDomainNames
ReadS [ListDomainNames]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDomainNames]
$creadListPrec :: ReadPrec [ListDomainNames]
readPrec :: ReadPrec ListDomainNames
$creadPrec :: ReadPrec ListDomainNames
readList :: ReadS [ListDomainNames]
$creadList :: ReadS [ListDomainNames]
readsPrec :: Int -> ReadS ListDomainNames
$creadsPrec :: Int -> ReadS ListDomainNames
Prelude.Read, Int -> ListDomainNames -> ShowS
[ListDomainNames] -> ShowS
ListDomainNames -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDomainNames] -> ShowS
$cshowList :: [ListDomainNames] -> ShowS
show :: ListDomainNames -> String
$cshow :: ListDomainNames -> String
showsPrec :: Int -> ListDomainNames -> ShowS
$cshowsPrec :: Int -> ListDomainNames -> ShowS
Prelude.Show, forall x. Rep ListDomainNames x -> ListDomainNames
forall x. ListDomainNames -> Rep ListDomainNames x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDomainNames x -> ListDomainNames
$cfrom :: forall x. ListDomainNames -> Rep ListDomainNames x
Prelude.Generic)

-- |
-- Create a value of 'ListDomainNames' 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:
--
-- 'engineType', 'listDomainNames_engineType' - Optional parameter to filter the output by domain engine type.
-- Acceptable values are \'Elasticsearch\' and \'OpenSearch\'.
newListDomainNames ::
  ListDomainNames
newListDomainNames :: ListDomainNames
newListDomainNames =
  ListDomainNames' {$sel:engineType:ListDomainNames' :: Maybe EngineType
engineType = forall a. Maybe a
Prelude.Nothing}

-- | Optional parameter to filter the output by domain engine type.
-- Acceptable values are \'Elasticsearch\' and \'OpenSearch\'.
listDomainNames_engineType :: Lens.Lens' ListDomainNames (Prelude.Maybe EngineType)
listDomainNames_engineType :: Lens' ListDomainNames (Maybe EngineType)
listDomainNames_engineType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDomainNames' {Maybe EngineType
engineType :: Maybe EngineType
$sel:engineType:ListDomainNames' :: ListDomainNames -> Maybe EngineType
engineType} -> Maybe EngineType
engineType) (\s :: ListDomainNames
s@ListDomainNames' {} Maybe EngineType
a -> ListDomainNames
s {$sel:engineType:ListDomainNames' :: Maybe EngineType
engineType = Maybe EngineType
a} :: ListDomainNames)

instance Core.AWSRequest ListDomainNames where
  type
    AWSResponse ListDomainNames =
      ListDomainNamesResponse
  request :: (Service -> Service) -> ListDomainNames -> Request ListDomainNames
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListDomainNames
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDomainNames)))
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 [DomainInfo] -> Int -> ListDomainNamesResponse
ListDomainNamesResponse'
            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
"DomainNames" 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 ListDomainNames where
  hashWithSalt :: Int -> ListDomainNames -> Int
hashWithSalt Int
_salt ListDomainNames' {Maybe EngineType
engineType :: Maybe EngineType
$sel:engineType:ListDomainNames' :: ListDomainNames -> Maybe EngineType
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EngineType
engineType

instance Prelude.NFData ListDomainNames where
  rnf :: ListDomainNames -> ()
rnf ListDomainNames' {Maybe EngineType
engineType :: Maybe EngineType
$sel:engineType:ListDomainNames' :: ListDomainNames -> Maybe EngineType
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe EngineType
engineType

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

instance Data.ToPath ListDomainNames where
  toPath :: ListDomainNames -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/2015-01-01/domain"

instance Data.ToQuery ListDomainNames where
  toQuery :: ListDomainNames -> QueryString
toQuery ListDomainNames' {Maybe EngineType
engineType :: Maybe EngineType
$sel:engineType:ListDomainNames' :: ListDomainNames -> Maybe EngineType
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"engineType" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe EngineType
engineType]

-- | The result of a @ListDomainNames@ operation. Contains the names of all
-- domains owned by this account and their respective engine types.
--
-- /See:/ 'newListDomainNamesResponse' smart constructor.
data ListDomainNamesResponse = ListDomainNamesResponse'
  { -- | List of domain names and respective engine types.
    ListDomainNamesResponse -> Maybe [DomainInfo]
domainNames :: Prelude.Maybe [DomainInfo],
    -- | The response's http status code.
    ListDomainNamesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDomainNamesResponse -> ListDomainNamesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDomainNamesResponse -> ListDomainNamesResponse -> Bool
$c/= :: ListDomainNamesResponse -> ListDomainNamesResponse -> Bool
== :: ListDomainNamesResponse -> ListDomainNamesResponse -> Bool
$c== :: ListDomainNamesResponse -> ListDomainNamesResponse -> Bool
Prelude.Eq, ReadPrec [ListDomainNamesResponse]
ReadPrec ListDomainNamesResponse
Int -> ReadS ListDomainNamesResponse
ReadS [ListDomainNamesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDomainNamesResponse]
$creadListPrec :: ReadPrec [ListDomainNamesResponse]
readPrec :: ReadPrec ListDomainNamesResponse
$creadPrec :: ReadPrec ListDomainNamesResponse
readList :: ReadS [ListDomainNamesResponse]
$creadList :: ReadS [ListDomainNamesResponse]
readsPrec :: Int -> ReadS ListDomainNamesResponse
$creadsPrec :: Int -> ReadS ListDomainNamesResponse
Prelude.Read, Int -> ListDomainNamesResponse -> ShowS
[ListDomainNamesResponse] -> ShowS
ListDomainNamesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDomainNamesResponse] -> ShowS
$cshowList :: [ListDomainNamesResponse] -> ShowS
show :: ListDomainNamesResponse -> String
$cshow :: ListDomainNamesResponse -> String
showsPrec :: Int -> ListDomainNamesResponse -> ShowS
$cshowsPrec :: Int -> ListDomainNamesResponse -> ShowS
Prelude.Show, forall x. Rep ListDomainNamesResponse x -> ListDomainNamesResponse
forall x. ListDomainNamesResponse -> Rep ListDomainNamesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDomainNamesResponse x -> ListDomainNamesResponse
$cfrom :: forall x. ListDomainNamesResponse -> Rep ListDomainNamesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDomainNamesResponse' 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', 'listDomainNamesResponse_domainNames' - List of domain names and respective engine types.
--
-- 'httpStatus', 'listDomainNamesResponse_httpStatus' - The response's http status code.
newListDomainNamesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDomainNamesResponse
newListDomainNamesResponse :: Int -> ListDomainNamesResponse
newListDomainNamesResponse Int
pHttpStatus_ =
  ListDomainNamesResponse'
    { $sel:domainNames:ListDomainNamesResponse' :: Maybe [DomainInfo]
domainNames =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDomainNamesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | List of domain names and respective engine types.
listDomainNamesResponse_domainNames :: Lens.Lens' ListDomainNamesResponse (Prelude.Maybe [DomainInfo])
listDomainNamesResponse_domainNames :: Lens' ListDomainNamesResponse (Maybe [DomainInfo])
listDomainNamesResponse_domainNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDomainNamesResponse' {Maybe [DomainInfo]
domainNames :: Maybe [DomainInfo]
$sel:domainNames:ListDomainNamesResponse' :: ListDomainNamesResponse -> Maybe [DomainInfo]
domainNames} -> Maybe [DomainInfo]
domainNames) (\s :: ListDomainNamesResponse
s@ListDomainNamesResponse' {} Maybe [DomainInfo]
a -> ListDomainNamesResponse
s {$sel:domainNames:ListDomainNamesResponse' :: Maybe [DomainInfo]
domainNames = Maybe [DomainInfo]
a} :: ListDomainNamesResponse) 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.
listDomainNamesResponse_httpStatus :: Lens.Lens' ListDomainNamesResponse Prelude.Int
listDomainNamesResponse_httpStatus :: Lens' ListDomainNamesResponse Int
listDomainNamesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDomainNamesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListDomainNamesResponse' :: ListDomainNamesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListDomainNamesResponse
s@ListDomainNamesResponse' {} Int
a -> ListDomainNamesResponse
s {$sel:httpStatus:ListDomainNamesResponse' :: Int
httpStatus = Int
a} :: ListDomainNamesResponse)

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