{-# 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.GetCompatibleElasticsearchVersions
-- 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 a list of upgrade compatible Elastisearch versions. You can
-- optionally pass a @ @@DomainName@@ @ to get all upgrade compatible
-- Elasticsearch versions for that specific domain.
module Amazonka.ElasticSearch.GetCompatibleElasticsearchVersions
  ( -- * Creating a Request
    GetCompatibleElasticsearchVersions (..),
    newGetCompatibleElasticsearchVersions,

    -- * Request Lenses
    getCompatibleElasticsearchVersions_domainName,

    -- * Destructuring the Response
    GetCompatibleElasticsearchVersionsResponse (..),
    newGetCompatibleElasticsearchVersionsResponse,

    -- * Response Lenses
    getCompatibleElasticsearchVersionsResponse_compatibleElasticsearchVersions,
    getCompatibleElasticsearchVersionsResponse_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 request parameters to
-- @ @@GetCompatibleElasticsearchVersions@@ @ operation.
--
-- /See:/ 'newGetCompatibleElasticsearchVersions' smart constructor.
data GetCompatibleElasticsearchVersions = GetCompatibleElasticsearchVersions'
  { GetCompatibleElasticsearchVersions -> Maybe Text
domainName :: Prelude.Maybe Prelude.Text
  }
  deriving (GetCompatibleElasticsearchVersions
-> GetCompatibleElasticsearchVersions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCompatibleElasticsearchVersions
-> GetCompatibleElasticsearchVersions -> Bool
$c/= :: GetCompatibleElasticsearchVersions
-> GetCompatibleElasticsearchVersions -> Bool
== :: GetCompatibleElasticsearchVersions
-> GetCompatibleElasticsearchVersions -> Bool
$c== :: GetCompatibleElasticsearchVersions
-> GetCompatibleElasticsearchVersions -> Bool
Prelude.Eq, ReadPrec [GetCompatibleElasticsearchVersions]
ReadPrec GetCompatibleElasticsearchVersions
Int -> ReadS GetCompatibleElasticsearchVersions
ReadS [GetCompatibleElasticsearchVersions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCompatibleElasticsearchVersions]
$creadListPrec :: ReadPrec [GetCompatibleElasticsearchVersions]
readPrec :: ReadPrec GetCompatibleElasticsearchVersions
$creadPrec :: ReadPrec GetCompatibleElasticsearchVersions
readList :: ReadS [GetCompatibleElasticsearchVersions]
$creadList :: ReadS [GetCompatibleElasticsearchVersions]
readsPrec :: Int -> ReadS GetCompatibleElasticsearchVersions
$creadsPrec :: Int -> ReadS GetCompatibleElasticsearchVersions
Prelude.Read, Int -> GetCompatibleElasticsearchVersions -> ShowS
[GetCompatibleElasticsearchVersions] -> ShowS
GetCompatibleElasticsearchVersions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCompatibleElasticsearchVersions] -> ShowS
$cshowList :: [GetCompatibleElasticsearchVersions] -> ShowS
show :: GetCompatibleElasticsearchVersions -> String
$cshow :: GetCompatibleElasticsearchVersions -> String
showsPrec :: Int -> GetCompatibleElasticsearchVersions -> ShowS
$cshowsPrec :: Int -> GetCompatibleElasticsearchVersions -> ShowS
Prelude.Show, forall x.
Rep GetCompatibleElasticsearchVersions x
-> GetCompatibleElasticsearchVersions
forall x.
GetCompatibleElasticsearchVersions
-> Rep GetCompatibleElasticsearchVersions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetCompatibleElasticsearchVersions x
-> GetCompatibleElasticsearchVersions
$cfrom :: forall x.
GetCompatibleElasticsearchVersions
-> Rep GetCompatibleElasticsearchVersions x
Prelude.Generic)

-- |
-- Create a value of 'GetCompatibleElasticsearchVersions' 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', 'getCompatibleElasticsearchVersions_domainName' - Undocumented member.
newGetCompatibleElasticsearchVersions ::
  GetCompatibleElasticsearchVersions
newGetCompatibleElasticsearchVersions :: GetCompatibleElasticsearchVersions
newGetCompatibleElasticsearchVersions =
  GetCompatibleElasticsearchVersions'
    { $sel:domainName:GetCompatibleElasticsearchVersions' :: Maybe Text
domainName =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
getCompatibleElasticsearchVersions_domainName :: Lens.Lens' GetCompatibleElasticsearchVersions (Prelude.Maybe Prelude.Text)
getCompatibleElasticsearchVersions_domainName :: Lens' GetCompatibleElasticsearchVersions (Maybe Text)
getCompatibleElasticsearchVersions_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCompatibleElasticsearchVersions' {Maybe Text
domainName :: Maybe Text
$sel:domainName:GetCompatibleElasticsearchVersions' :: GetCompatibleElasticsearchVersions -> Maybe Text
domainName} -> Maybe Text
domainName) (\s :: GetCompatibleElasticsearchVersions
s@GetCompatibleElasticsearchVersions' {} Maybe Text
a -> GetCompatibleElasticsearchVersions
s {$sel:domainName:GetCompatibleElasticsearchVersions' :: Maybe Text
domainName = Maybe Text
a} :: GetCompatibleElasticsearchVersions)

instance
  Core.AWSRequest
    GetCompatibleElasticsearchVersions
  where
  type
    AWSResponse GetCompatibleElasticsearchVersions =
      GetCompatibleElasticsearchVersionsResponse
  request :: (Service -> Service)
-> GetCompatibleElasticsearchVersions
-> Request GetCompatibleElasticsearchVersions
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 GetCompatibleElasticsearchVersions
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse GetCompatibleElasticsearchVersions)))
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 [CompatibleVersionsMap]
-> Int -> GetCompatibleElasticsearchVersionsResponse
GetCompatibleElasticsearchVersionsResponse'
            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
"CompatibleElasticsearchVersions"
                            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
    GetCompatibleElasticsearchVersions
  where
  hashWithSalt :: Int -> GetCompatibleElasticsearchVersions -> Int
hashWithSalt
    Int
_salt
    GetCompatibleElasticsearchVersions' {Maybe Text
domainName :: Maybe Text
$sel:domainName:GetCompatibleElasticsearchVersions' :: GetCompatibleElasticsearchVersions -> Maybe Text
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
domainName

instance
  Prelude.NFData
    GetCompatibleElasticsearchVersions
  where
  rnf :: GetCompatibleElasticsearchVersions -> ()
rnf GetCompatibleElasticsearchVersions' {Maybe Text
domainName :: Maybe Text
$sel:domainName:GetCompatibleElasticsearchVersions' :: GetCompatibleElasticsearchVersions -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
domainName

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

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

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

-- | Container for response returned by
-- @ @@GetCompatibleElasticsearchVersions@@ @ operation.
--
-- /See:/ 'newGetCompatibleElasticsearchVersionsResponse' smart constructor.
data GetCompatibleElasticsearchVersionsResponse = GetCompatibleElasticsearchVersionsResponse'
  { -- | A map of compatible Elasticsearch versions returned as part of the
    -- @ @@GetCompatibleElasticsearchVersions@@ @ operation.
    GetCompatibleElasticsearchVersionsResponse
-> Maybe [CompatibleVersionsMap]
compatibleElasticsearchVersions :: Prelude.Maybe [CompatibleVersionsMap],
    -- | The response's http status code.
    GetCompatibleElasticsearchVersionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetCompatibleElasticsearchVersionsResponse
-> GetCompatibleElasticsearchVersionsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCompatibleElasticsearchVersionsResponse
-> GetCompatibleElasticsearchVersionsResponse -> Bool
$c/= :: GetCompatibleElasticsearchVersionsResponse
-> GetCompatibleElasticsearchVersionsResponse -> Bool
== :: GetCompatibleElasticsearchVersionsResponse
-> GetCompatibleElasticsearchVersionsResponse -> Bool
$c== :: GetCompatibleElasticsearchVersionsResponse
-> GetCompatibleElasticsearchVersionsResponse -> Bool
Prelude.Eq, ReadPrec [GetCompatibleElasticsearchVersionsResponse]
ReadPrec GetCompatibleElasticsearchVersionsResponse
Int -> ReadS GetCompatibleElasticsearchVersionsResponse
ReadS [GetCompatibleElasticsearchVersionsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCompatibleElasticsearchVersionsResponse]
$creadListPrec :: ReadPrec [GetCompatibleElasticsearchVersionsResponse]
readPrec :: ReadPrec GetCompatibleElasticsearchVersionsResponse
$creadPrec :: ReadPrec GetCompatibleElasticsearchVersionsResponse
readList :: ReadS [GetCompatibleElasticsearchVersionsResponse]
$creadList :: ReadS [GetCompatibleElasticsearchVersionsResponse]
readsPrec :: Int -> ReadS GetCompatibleElasticsearchVersionsResponse
$creadsPrec :: Int -> ReadS GetCompatibleElasticsearchVersionsResponse
Prelude.Read, Int -> GetCompatibleElasticsearchVersionsResponse -> ShowS
[GetCompatibleElasticsearchVersionsResponse] -> ShowS
GetCompatibleElasticsearchVersionsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCompatibleElasticsearchVersionsResponse] -> ShowS
$cshowList :: [GetCompatibleElasticsearchVersionsResponse] -> ShowS
show :: GetCompatibleElasticsearchVersionsResponse -> String
$cshow :: GetCompatibleElasticsearchVersionsResponse -> String
showsPrec :: Int -> GetCompatibleElasticsearchVersionsResponse -> ShowS
$cshowsPrec :: Int -> GetCompatibleElasticsearchVersionsResponse -> ShowS
Prelude.Show, forall x.
Rep GetCompatibleElasticsearchVersionsResponse x
-> GetCompatibleElasticsearchVersionsResponse
forall x.
GetCompatibleElasticsearchVersionsResponse
-> Rep GetCompatibleElasticsearchVersionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetCompatibleElasticsearchVersionsResponse x
-> GetCompatibleElasticsearchVersionsResponse
$cfrom :: forall x.
GetCompatibleElasticsearchVersionsResponse
-> Rep GetCompatibleElasticsearchVersionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetCompatibleElasticsearchVersionsResponse' 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:
--
-- 'compatibleElasticsearchVersions', 'getCompatibleElasticsearchVersionsResponse_compatibleElasticsearchVersions' - A map of compatible Elasticsearch versions returned as part of the
-- @ @@GetCompatibleElasticsearchVersions@@ @ operation.
--
-- 'httpStatus', 'getCompatibleElasticsearchVersionsResponse_httpStatus' - The response's http status code.
newGetCompatibleElasticsearchVersionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetCompatibleElasticsearchVersionsResponse
newGetCompatibleElasticsearchVersionsResponse :: Int -> GetCompatibleElasticsearchVersionsResponse
newGetCompatibleElasticsearchVersionsResponse
  Int
pHttpStatus_ =
    GetCompatibleElasticsearchVersionsResponse'
      { $sel:compatibleElasticsearchVersions:GetCompatibleElasticsearchVersionsResponse' :: Maybe [CompatibleVersionsMap]
compatibleElasticsearchVersions =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:GetCompatibleElasticsearchVersionsResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | A map of compatible Elasticsearch versions returned as part of the
-- @ @@GetCompatibleElasticsearchVersions@@ @ operation.
getCompatibleElasticsearchVersionsResponse_compatibleElasticsearchVersions :: Lens.Lens' GetCompatibleElasticsearchVersionsResponse (Prelude.Maybe [CompatibleVersionsMap])
getCompatibleElasticsearchVersionsResponse_compatibleElasticsearchVersions :: Lens'
  GetCompatibleElasticsearchVersionsResponse
  (Maybe [CompatibleVersionsMap])
getCompatibleElasticsearchVersionsResponse_compatibleElasticsearchVersions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCompatibleElasticsearchVersionsResponse' {Maybe [CompatibleVersionsMap]
compatibleElasticsearchVersions :: Maybe [CompatibleVersionsMap]
$sel:compatibleElasticsearchVersions:GetCompatibleElasticsearchVersionsResponse' :: GetCompatibleElasticsearchVersionsResponse
-> Maybe [CompatibleVersionsMap]
compatibleElasticsearchVersions} -> Maybe [CompatibleVersionsMap]
compatibleElasticsearchVersions) (\s :: GetCompatibleElasticsearchVersionsResponse
s@GetCompatibleElasticsearchVersionsResponse' {} Maybe [CompatibleVersionsMap]
a -> GetCompatibleElasticsearchVersionsResponse
s {$sel:compatibleElasticsearchVersions:GetCompatibleElasticsearchVersionsResponse' :: Maybe [CompatibleVersionsMap]
compatibleElasticsearchVersions = Maybe [CompatibleVersionsMap]
a} :: GetCompatibleElasticsearchVersionsResponse) 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.
getCompatibleElasticsearchVersionsResponse_httpStatus :: Lens.Lens' GetCompatibleElasticsearchVersionsResponse Prelude.Int
getCompatibleElasticsearchVersionsResponse_httpStatus :: Lens' GetCompatibleElasticsearchVersionsResponse Int
getCompatibleElasticsearchVersionsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCompatibleElasticsearchVersionsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetCompatibleElasticsearchVersionsResponse' :: GetCompatibleElasticsearchVersionsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetCompatibleElasticsearchVersionsResponse
s@GetCompatibleElasticsearchVersionsResponse' {} Int
a -> GetCompatibleElasticsearchVersionsResponse
s {$sel:httpStatus:GetCompatibleElasticsearchVersionsResponse' :: Int
httpStatus = Int
a} :: GetCompatibleElasticsearchVersionsResponse)

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