{-# 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.OpenSearch.ListDomainNames
-- 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 the names of all domains owned by the current user\'s account.
module Amazonka.OpenSearch.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.Lens as Lens
import Amazonka.OpenSearch.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
(ListDomainNames -> ListDomainNames -> Bool)
-> (ListDomainNames -> ListDomainNames -> Bool)
-> Eq ListDomainNames
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]
(Int -> ReadS ListDomainNames)
-> ReadS [ListDomainNames]
-> ReadPrec ListDomainNames
-> ReadPrec [ListDomainNames]
-> Read 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
(Int -> ListDomainNames -> ShowS)
-> (ListDomainNames -> String)
-> ([ListDomainNames] -> ShowS)
-> Show ListDomainNames
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. ListDomainNames -> Rep ListDomainNames x)
-> (forall x. Rep ListDomainNames x -> ListDomainNames)
-> Generic ListDomainNames
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' :: Maybe EngineType -> ListDomainNames
ListDomainNames' {$sel:engineType:ListDomainNames' :: Maybe EngineType
engineType = Maybe 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 :: (Maybe EngineType -> f (Maybe EngineType))
-> ListDomainNames -> f ListDomainNames
listDomainNames_engineType = (ListDomainNames -> Maybe EngineType)
-> (ListDomainNames -> Maybe EngineType -> ListDomainNames)
-> Lens
     ListDomainNames
     ListDomainNames
     (Maybe EngineType)
     (Maybe 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 :: ListDomainNames -> Request ListDomainNames
request = Service -> ListDomainNames -> Request ListDomainNames
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListDomainNames
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDomainNames)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListDomainNames))
-> Logger
-> Service
-> Proxy ListDomainNames
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDomainNames)))
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 [DomainInfo] -> Int -> ListDomainNamesResponse
ListDomainNamesResponse'
            (Maybe [DomainInfo] -> Int -> ListDomainNamesResponse)
-> Either String (Maybe [DomainInfo])
-> Either String (Int -> ListDomainNamesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe (Maybe [DomainInfo]))
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"DomainNames" Either String (Maybe (Maybe [DomainInfo]))
-> Maybe [DomainInfo] -> Either String (Maybe [DomainInfo])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [DomainInfo]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListDomainNamesResponse)
-> Either String Int -> Either String ListDomainNamesResponse
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 ListDomainNames

instance Prelude.NFData ListDomainNames

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

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

instance Core.ToQuery ListDomainNames where
  toQuery :: ListDomainNames -> QueryString
toQuery ListDomainNames' {Maybe EngineType
engineType :: Maybe EngineType
$sel:engineType:ListDomainNames' :: ListDomainNames -> Maybe EngineType
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"engineType" ByteString -> Maybe EngineType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(ListDomainNamesResponse -> ListDomainNamesResponse -> Bool)
-> (ListDomainNamesResponse -> ListDomainNamesResponse -> Bool)
-> Eq ListDomainNamesResponse
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]
(Int -> ReadS ListDomainNamesResponse)
-> ReadS [ListDomainNamesResponse]
-> ReadPrec ListDomainNamesResponse
-> ReadPrec [ListDomainNamesResponse]
-> Read 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
(Int -> ListDomainNamesResponse -> ShowS)
-> (ListDomainNamesResponse -> String)
-> ([ListDomainNamesResponse] -> ShowS)
-> Show ListDomainNamesResponse
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.
 ListDomainNamesResponse -> Rep ListDomainNamesResponse x)
-> (forall x.
    Rep ListDomainNamesResponse x -> ListDomainNamesResponse)
-> Generic ListDomainNamesResponse
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' :: Maybe [DomainInfo] -> Int -> ListDomainNamesResponse
ListDomainNamesResponse'
    { $sel:domainNames:ListDomainNamesResponse' :: Maybe [DomainInfo]
domainNames =
        Maybe [DomainInfo]
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 :: (Maybe [DomainInfo] -> f (Maybe [DomainInfo]))
-> ListDomainNamesResponse -> f ListDomainNamesResponse
listDomainNamesResponse_domainNames = (ListDomainNamesResponse -> Maybe [DomainInfo])
-> (ListDomainNamesResponse
    -> Maybe [DomainInfo] -> ListDomainNamesResponse)
-> Lens
     ListDomainNamesResponse
     ListDomainNamesResponse
     (Maybe [DomainInfo])
     (Maybe [DomainInfo])
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) ((Maybe [DomainInfo] -> f (Maybe [DomainInfo]))
 -> ListDomainNamesResponse -> f ListDomainNamesResponse)
-> ((Maybe [DomainInfo] -> f (Maybe [DomainInfo]))
    -> Maybe [DomainInfo] -> f (Maybe [DomainInfo]))
-> (Maybe [DomainInfo] -> f (Maybe [DomainInfo]))
-> ListDomainNamesResponse
-> f ListDomainNamesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [DomainInfo] [DomainInfo] [DomainInfo] [DomainInfo]
-> Iso
     (Maybe [DomainInfo])
     (Maybe [DomainInfo])
     (Maybe [DomainInfo])
     (Maybe [DomainInfo])
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 [DomainInfo] [DomainInfo] [DomainInfo] [DomainInfo]
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 :: (Int -> f Int)
-> ListDomainNamesResponse -> f ListDomainNamesResponse
listDomainNamesResponse_httpStatus = (ListDomainNamesResponse -> Int)
-> (ListDomainNamesResponse -> Int -> ListDomainNamesResponse)
-> Lens ListDomainNamesResponse ListDomainNamesResponse Int Int
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