{-# 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.SecurityLake.GetDatalake
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the Amazon Security Lake configuration object for the
-- specified Amazon Web Services account ID. You can use the @GetDatalake@
-- API to know whether Security Lake is enabled for the current Region.
-- This API does not take input parameters.
module Amazonka.SecurityLake.GetDatalake
  ( -- * Creating a Request
    GetDatalake (..),
    newGetDatalake,

    -- * Destructuring the Response
    GetDatalakeResponse (..),
    newGetDatalakeResponse,

    -- * Response Lenses
    getDatalakeResponse_httpStatus,
    getDatalakeResponse_configurations,
  )
where

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

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

-- |
-- Create a value of 'GetDatalake' 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.
newGetDatalake ::
  GetDatalake
newGetDatalake :: GetDatalake
newGetDatalake = GetDatalake
GetDatalake'

instance Core.AWSRequest GetDatalake where
  type AWSResponse GetDatalake = GetDatalakeResponse
  request :: (Service -> Service) -> GetDatalake -> Request GetDatalake
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 GetDatalake
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDatalake)))
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 ->
          Int
-> HashMap Region LakeConfigurationResponse -> GetDatalakeResponse
GetDatalakeResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"configurations"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable GetDatalake where
  hashWithSalt :: Int -> GetDatalake -> Int
hashWithSalt Int
_salt GetDatalake
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData GetDatalake where
  rnf :: GetDatalake -> ()
rnf GetDatalake
_ = ()

instance Data.ToHeaders GetDatalake where
  toHeaders :: GetDatalake -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

-- | /See:/ 'newGetDatalakeResponse' smart constructor.
data GetDatalakeResponse = GetDatalakeResponse'
  { -- | The response's http status code.
    GetDatalakeResponse -> Int
httpStatus :: Prelude.Int,
    -- | Retrieves the Security Lake configuration object.
    GetDatalakeResponse -> HashMap Region LakeConfigurationResponse
configurations :: Prelude.HashMap Region LakeConfigurationResponse
  }
  deriving (GetDatalakeResponse -> GetDatalakeResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDatalakeResponse -> GetDatalakeResponse -> Bool
$c/= :: GetDatalakeResponse -> GetDatalakeResponse -> Bool
== :: GetDatalakeResponse -> GetDatalakeResponse -> Bool
$c== :: GetDatalakeResponse -> GetDatalakeResponse -> Bool
Prelude.Eq, ReadPrec [GetDatalakeResponse]
ReadPrec GetDatalakeResponse
Int -> ReadS GetDatalakeResponse
ReadS [GetDatalakeResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDatalakeResponse]
$creadListPrec :: ReadPrec [GetDatalakeResponse]
readPrec :: ReadPrec GetDatalakeResponse
$creadPrec :: ReadPrec GetDatalakeResponse
readList :: ReadS [GetDatalakeResponse]
$creadList :: ReadS [GetDatalakeResponse]
readsPrec :: Int -> ReadS GetDatalakeResponse
$creadsPrec :: Int -> ReadS GetDatalakeResponse
Prelude.Read, Int -> GetDatalakeResponse -> ShowS
[GetDatalakeResponse] -> ShowS
GetDatalakeResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDatalakeResponse] -> ShowS
$cshowList :: [GetDatalakeResponse] -> ShowS
show :: GetDatalakeResponse -> String
$cshow :: GetDatalakeResponse -> String
showsPrec :: Int -> GetDatalakeResponse -> ShowS
$cshowsPrec :: Int -> GetDatalakeResponse -> ShowS
Prelude.Show, forall x. Rep GetDatalakeResponse x -> GetDatalakeResponse
forall x. GetDatalakeResponse -> Rep GetDatalakeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDatalakeResponse x -> GetDatalakeResponse
$cfrom :: forall x. GetDatalakeResponse -> Rep GetDatalakeResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDatalakeResponse' 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', 'getDatalakeResponse_httpStatus' - The response's http status code.
--
-- 'configurations', 'getDatalakeResponse_configurations' - Retrieves the Security Lake configuration object.
newGetDatalakeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDatalakeResponse
newGetDatalakeResponse :: Int -> GetDatalakeResponse
newGetDatalakeResponse Int
pHttpStatus_ =
  GetDatalakeResponse'
    { $sel:httpStatus:GetDatalakeResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:configurations:GetDatalakeResponse' :: HashMap Region LakeConfigurationResponse
configurations = forall a. Monoid a => a
Prelude.mempty
    }

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

-- | Retrieves the Security Lake configuration object.
getDatalakeResponse_configurations :: Lens.Lens' GetDatalakeResponse (Prelude.HashMap Region LakeConfigurationResponse)
getDatalakeResponse_configurations :: Lens'
  GetDatalakeResponse (HashMap Region LakeConfigurationResponse)
getDatalakeResponse_configurations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDatalakeResponse' {HashMap Region LakeConfigurationResponse
configurations :: HashMap Region LakeConfigurationResponse
$sel:configurations:GetDatalakeResponse' :: GetDatalakeResponse -> HashMap Region LakeConfigurationResponse
configurations} -> HashMap Region LakeConfigurationResponse
configurations) (\s :: GetDatalakeResponse
s@GetDatalakeResponse' {} HashMap Region LakeConfigurationResponse
a -> GetDatalakeResponse
s {$sel:configurations:GetDatalakeResponse' :: HashMap Region LakeConfigurationResponse
configurations = HashMap Region LakeConfigurationResponse
a} :: GetDatalakeResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData GetDatalakeResponse where
  rnf :: GetDatalakeResponse -> ()
rnf GetDatalakeResponse' {Int
HashMap Region LakeConfigurationResponse
configurations :: HashMap Region LakeConfigurationResponse
httpStatus :: Int
$sel:configurations:GetDatalakeResponse' :: GetDatalakeResponse -> HashMap Region LakeConfigurationResponse
$sel:httpStatus:GetDatalakeResponse' :: GetDatalakeResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Region LakeConfigurationResponse
configurations