{-# 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.OpenSearchServerless.GetSecurityConfig
-- 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 information about an OpenSearch Serverless security
-- configuration. For more information, see
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/serverless-saml.html SAML authentication for Amazon OpenSearch Serverless>.
module Amazonka.OpenSearchServerless.GetSecurityConfig
  ( -- * Creating a Request
    GetSecurityConfig (..),
    newGetSecurityConfig,

    -- * Request Lenses
    getSecurityConfig_id,

    -- * Destructuring the Response
    GetSecurityConfigResponse (..),
    newGetSecurityConfigResponse,

    -- * Response Lenses
    getSecurityConfigResponse_securityConfigDetail,
    getSecurityConfigResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetSecurityConfig' smart constructor.
data GetSecurityConfig = GetSecurityConfig'
  { -- | The unique identifier of the security configuration.
    GetSecurityConfig -> Text
id :: Prelude.Text
  }
  deriving (GetSecurityConfig -> GetSecurityConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSecurityConfig -> GetSecurityConfig -> Bool
$c/= :: GetSecurityConfig -> GetSecurityConfig -> Bool
== :: GetSecurityConfig -> GetSecurityConfig -> Bool
$c== :: GetSecurityConfig -> GetSecurityConfig -> Bool
Prelude.Eq, ReadPrec [GetSecurityConfig]
ReadPrec GetSecurityConfig
Int -> ReadS GetSecurityConfig
ReadS [GetSecurityConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSecurityConfig]
$creadListPrec :: ReadPrec [GetSecurityConfig]
readPrec :: ReadPrec GetSecurityConfig
$creadPrec :: ReadPrec GetSecurityConfig
readList :: ReadS [GetSecurityConfig]
$creadList :: ReadS [GetSecurityConfig]
readsPrec :: Int -> ReadS GetSecurityConfig
$creadsPrec :: Int -> ReadS GetSecurityConfig
Prelude.Read, Int -> GetSecurityConfig -> ShowS
[GetSecurityConfig] -> ShowS
GetSecurityConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSecurityConfig] -> ShowS
$cshowList :: [GetSecurityConfig] -> ShowS
show :: GetSecurityConfig -> String
$cshow :: GetSecurityConfig -> String
showsPrec :: Int -> GetSecurityConfig -> ShowS
$cshowsPrec :: Int -> GetSecurityConfig -> ShowS
Prelude.Show, forall x. Rep GetSecurityConfig x -> GetSecurityConfig
forall x. GetSecurityConfig -> Rep GetSecurityConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSecurityConfig x -> GetSecurityConfig
$cfrom :: forall x. GetSecurityConfig -> Rep GetSecurityConfig x
Prelude.Generic)

-- |
-- Create a value of 'GetSecurityConfig' 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:
--
-- 'id', 'getSecurityConfig_id' - The unique identifier of the security configuration.
newGetSecurityConfig ::
  -- | 'id'
  Prelude.Text ->
  GetSecurityConfig
newGetSecurityConfig :: Text -> GetSecurityConfig
newGetSecurityConfig Text
pId_ =
  GetSecurityConfig' {$sel:id:GetSecurityConfig' :: Text
id = Text
pId_}

-- | The unique identifier of the security configuration.
getSecurityConfig_id :: Lens.Lens' GetSecurityConfig Prelude.Text
getSecurityConfig_id :: Lens' GetSecurityConfig Text
getSecurityConfig_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSecurityConfig' {Text
id :: Text
$sel:id:GetSecurityConfig' :: GetSecurityConfig -> Text
id} -> Text
id) (\s :: GetSecurityConfig
s@GetSecurityConfig' {} Text
a -> GetSecurityConfig
s {$sel:id:GetSecurityConfig' :: Text
id = Text
a} :: GetSecurityConfig)

instance Core.AWSRequest GetSecurityConfig where
  type
    AWSResponse GetSecurityConfig =
      GetSecurityConfigResponse
  request :: (Service -> Service)
-> GetSecurityConfig -> Request GetSecurityConfig
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetSecurityConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetSecurityConfig)))
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 SecurityConfigDetail -> Int -> GetSecurityConfigResponse
GetSecurityConfigResponse'
            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
"securityConfigDetail")
            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 GetSecurityConfig where
  hashWithSalt :: Int -> GetSecurityConfig -> Int
hashWithSalt Int
_salt GetSecurityConfig' {Text
id :: Text
$sel:id:GetSecurityConfig' :: GetSecurityConfig -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

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

instance Data.ToHeaders GetSecurityConfig where
  toHeaders :: GetSecurityConfig -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"OpenSearchServerless.GetSecurityConfig" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetSecurityConfig where
  toJSON :: GetSecurityConfig -> Value
toJSON GetSecurityConfig' {Text
id :: Text
$sel:id:GetSecurityConfig' :: GetSecurityConfig -> Text
..} =
    [Pair] -> Value
Data.object
      (forall a. [Maybe a] -> [a]
Prelude.catMaybes [forall a. a -> Maybe a
Prelude.Just (Key
"id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id)])

instance Data.ToPath GetSecurityConfig where
  toPath :: GetSecurityConfig -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newGetSecurityConfigResponse' smart constructor.
data GetSecurityConfigResponse = GetSecurityConfigResponse'
  { -- | Details of the requested security configuration.
    GetSecurityConfigResponse -> Maybe SecurityConfigDetail
securityConfigDetail :: Prelude.Maybe SecurityConfigDetail,
    -- | The response's http status code.
    GetSecurityConfigResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetSecurityConfigResponse -> GetSecurityConfigResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSecurityConfigResponse -> GetSecurityConfigResponse -> Bool
$c/= :: GetSecurityConfigResponse -> GetSecurityConfigResponse -> Bool
== :: GetSecurityConfigResponse -> GetSecurityConfigResponse -> Bool
$c== :: GetSecurityConfigResponse -> GetSecurityConfigResponse -> Bool
Prelude.Eq, ReadPrec [GetSecurityConfigResponse]
ReadPrec GetSecurityConfigResponse
Int -> ReadS GetSecurityConfigResponse
ReadS [GetSecurityConfigResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSecurityConfigResponse]
$creadListPrec :: ReadPrec [GetSecurityConfigResponse]
readPrec :: ReadPrec GetSecurityConfigResponse
$creadPrec :: ReadPrec GetSecurityConfigResponse
readList :: ReadS [GetSecurityConfigResponse]
$creadList :: ReadS [GetSecurityConfigResponse]
readsPrec :: Int -> ReadS GetSecurityConfigResponse
$creadsPrec :: Int -> ReadS GetSecurityConfigResponse
Prelude.Read, Int -> GetSecurityConfigResponse -> ShowS
[GetSecurityConfigResponse] -> ShowS
GetSecurityConfigResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSecurityConfigResponse] -> ShowS
$cshowList :: [GetSecurityConfigResponse] -> ShowS
show :: GetSecurityConfigResponse -> String
$cshow :: GetSecurityConfigResponse -> String
showsPrec :: Int -> GetSecurityConfigResponse -> ShowS
$cshowsPrec :: Int -> GetSecurityConfigResponse -> ShowS
Prelude.Show, forall x.
Rep GetSecurityConfigResponse x -> GetSecurityConfigResponse
forall x.
GetSecurityConfigResponse -> Rep GetSecurityConfigResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetSecurityConfigResponse x -> GetSecurityConfigResponse
$cfrom :: forall x.
GetSecurityConfigResponse -> Rep GetSecurityConfigResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetSecurityConfigResponse' 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:
--
-- 'securityConfigDetail', 'getSecurityConfigResponse_securityConfigDetail' - Details of the requested security configuration.
--
-- 'httpStatus', 'getSecurityConfigResponse_httpStatus' - The response's http status code.
newGetSecurityConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSecurityConfigResponse
newGetSecurityConfigResponse :: Int -> GetSecurityConfigResponse
newGetSecurityConfigResponse Int
pHttpStatus_ =
  GetSecurityConfigResponse'
    { $sel:securityConfigDetail:GetSecurityConfigResponse' :: Maybe SecurityConfigDetail
securityConfigDetail =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSecurityConfigResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Details of the requested security configuration.
getSecurityConfigResponse_securityConfigDetail :: Lens.Lens' GetSecurityConfigResponse (Prelude.Maybe SecurityConfigDetail)
getSecurityConfigResponse_securityConfigDetail :: Lens' GetSecurityConfigResponse (Maybe SecurityConfigDetail)
getSecurityConfigResponse_securityConfigDetail = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSecurityConfigResponse' {Maybe SecurityConfigDetail
securityConfigDetail :: Maybe SecurityConfigDetail
$sel:securityConfigDetail:GetSecurityConfigResponse' :: GetSecurityConfigResponse -> Maybe SecurityConfigDetail
securityConfigDetail} -> Maybe SecurityConfigDetail
securityConfigDetail) (\s :: GetSecurityConfigResponse
s@GetSecurityConfigResponse' {} Maybe SecurityConfigDetail
a -> GetSecurityConfigResponse
s {$sel:securityConfigDetail:GetSecurityConfigResponse' :: Maybe SecurityConfigDetail
securityConfigDetail = Maybe SecurityConfigDetail
a} :: GetSecurityConfigResponse)

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

instance Prelude.NFData GetSecurityConfigResponse where
  rnf :: GetSecurityConfigResponse -> ()
rnf GetSecurityConfigResponse' {Int
Maybe SecurityConfigDetail
httpStatus :: Int
securityConfigDetail :: Maybe SecurityConfigDetail
$sel:httpStatus:GetSecurityConfigResponse' :: GetSecurityConfigResponse -> Int
$sel:securityConfigDetail:GetSecurityConfigResponse' :: GetSecurityConfigResponse -> Maybe SecurityConfigDetail
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SecurityConfigDetail
securityConfigDetail
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus