{-# 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.GetPoliciesStats
-- 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 statistical information about your OpenSearch Serverless access
-- policies, security configurations, and security policies.
module Amazonka.OpenSearchServerless.GetPoliciesStats
  ( -- * Creating a Request
    GetPoliciesStats (..),
    newGetPoliciesStats,

    -- * Destructuring the Response
    GetPoliciesStatsResponse (..),
    newGetPoliciesStatsResponse,

    -- * Response Lenses
    getPoliciesStatsResponse_accessPolicyStats,
    getPoliciesStatsResponse_securityConfigStats,
    getPoliciesStatsResponse_securityPolicyStats,
    getPoliciesStatsResponse_totalPolicyCount,
    getPoliciesStatsResponse_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:/ 'newGetPoliciesStats' smart constructor.
data GetPoliciesStats = GetPoliciesStats'
  {
  }
  deriving (GetPoliciesStats -> GetPoliciesStats -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPoliciesStats -> GetPoliciesStats -> Bool
$c/= :: GetPoliciesStats -> GetPoliciesStats -> Bool
== :: GetPoliciesStats -> GetPoliciesStats -> Bool
$c== :: GetPoliciesStats -> GetPoliciesStats -> Bool
Prelude.Eq, ReadPrec [GetPoliciesStats]
ReadPrec GetPoliciesStats
Int -> ReadS GetPoliciesStats
ReadS [GetPoliciesStats]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPoliciesStats]
$creadListPrec :: ReadPrec [GetPoliciesStats]
readPrec :: ReadPrec GetPoliciesStats
$creadPrec :: ReadPrec GetPoliciesStats
readList :: ReadS [GetPoliciesStats]
$creadList :: ReadS [GetPoliciesStats]
readsPrec :: Int -> ReadS GetPoliciesStats
$creadsPrec :: Int -> ReadS GetPoliciesStats
Prelude.Read, Int -> GetPoliciesStats -> ShowS
[GetPoliciesStats] -> ShowS
GetPoliciesStats -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPoliciesStats] -> ShowS
$cshowList :: [GetPoliciesStats] -> ShowS
show :: GetPoliciesStats -> String
$cshow :: GetPoliciesStats -> String
showsPrec :: Int -> GetPoliciesStats -> ShowS
$cshowsPrec :: Int -> GetPoliciesStats -> ShowS
Prelude.Show, forall x. Rep GetPoliciesStats x -> GetPoliciesStats
forall x. GetPoliciesStats -> Rep GetPoliciesStats x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPoliciesStats x -> GetPoliciesStats
$cfrom :: forall x. GetPoliciesStats -> Rep GetPoliciesStats x
Prelude.Generic)

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

instance Core.AWSRequest GetPoliciesStats where
  type
    AWSResponse GetPoliciesStats =
      GetPoliciesStatsResponse
  request :: (Service -> Service)
-> GetPoliciesStats -> Request GetPoliciesStats
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 GetPoliciesStats
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetPoliciesStats)))
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 AccessPolicyStats
-> Maybe SecurityConfigStats
-> Maybe SecurityPolicyStats
-> Maybe Integer
-> Int
-> GetPoliciesStatsResponse
GetPoliciesStatsResponse'
            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
"AccessPolicyStats")
            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
"SecurityConfigStats")
            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
"SecurityPolicyStats")
            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
"TotalPolicyCount")
            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 GetPoliciesStats where
  hashWithSalt :: Int -> GetPoliciesStats -> Int
hashWithSalt Int
_salt GetPoliciesStats
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

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

instance Data.ToHeaders GetPoliciesStats where
  toHeaders :: GetPoliciesStats -> 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.GetPoliciesStats" ::
                          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 GetPoliciesStats where
  toJSON :: GetPoliciesStats -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

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

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

-- | /See:/ 'newGetPoliciesStatsResponse' smart constructor.
data GetPoliciesStatsResponse = GetPoliciesStatsResponse'
  { -- | Information about the data access policies in your account.
    GetPoliciesStatsResponse -> Maybe AccessPolicyStats
accessPolicyStats :: Prelude.Maybe AccessPolicyStats,
    -- | Information about the security configurations in your account.
    GetPoliciesStatsResponse -> Maybe SecurityConfigStats
securityConfigStats :: Prelude.Maybe SecurityConfigStats,
    -- | Information about the security policies in your account.
    GetPoliciesStatsResponse -> Maybe SecurityPolicyStats
securityPolicyStats :: Prelude.Maybe SecurityPolicyStats,
    -- | The total number of OpenSearch Serverless security policies and
    -- configurations in your account.
    GetPoliciesStatsResponse -> Maybe Integer
totalPolicyCount :: Prelude.Maybe Prelude.Integer,
    -- | The response's http status code.
    GetPoliciesStatsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetPoliciesStatsResponse -> GetPoliciesStatsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPoliciesStatsResponse -> GetPoliciesStatsResponse -> Bool
$c/= :: GetPoliciesStatsResponse -> GetPoliciesStatsResponse -> Bool
== :: GetPoliciesStatsResponse -> GetPoliciesStatsResponse -> Bool
$c== :: GetPoliciesStatsResponse -> GetPoliciesStatsResponse -> Bool
Prelude.Eq, ReadPrec [GetPoliciesStatsResponse]
ReadPrec GetPoliciesStatsResponse
Int -> ReadS GetPoliciesStatsResponse
ReadS [GetPoliciesStatsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPoliciesStatsResponse]
$creadListPrec :: ReadPrec [GetPoliciesStatsResponse]
readPrec :: ReadPrec GetPoliciesStatsResponse
$creadPrec :: ReadPrec GetPoliciesStatsResponse
readList :: ReadS [GetPoliciesStatsResponse]
$creadList :: ReadS [GetPoliciesStatsResponse]
readsPrec :: Int -> ReadS GetPoliciesStatsResponse
$creadsPrec :: Int -> ReadS GetPoliciesStatsResponse
Prelude.Read, Int -> GetPoliciesStatsResponse -> ShowS
[GetPoliciesStatsResponse] -> ShowS
GetPoliciesStatsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPoliciesStatsResponse] -> ShowS
$cshowList :: [GetPoliciesStatsResponse] -> ShowS
show :: GetPoliciesStatsResponse -> String
$cshow :: GetPoliciesStatsResponse -> String
showsPrec :: Int -> GetPoliciesStatsResponse -> ShowS
$cshowsPrec :: Int -> GetPoliciesStatsResponse -> ShowS
Prelude.Show, forall x.
Rep GetPoliciesStatsResponse x -> GetPoliciesStatsResponse
forall x.
GetPoliciesStatsResponse -> Rep GetPoliciesStatsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetPoliciesStatsResponse x -> GetPoliciesStatsResponse
$cfrom :: forall x.
GetPoliciesStatsResponse -> Rep GetPoliciesStatsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetPoliciesStatsResponse' 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:
--
-- 'accessPolicyStats', 'getPoliciesStatsResponse_accessPolicyStats' - Information about the data access policies in your account.
--
-- 'securityConfigStats', 'getPoliciesStatsResponse_securityConfigStats' - Information about the security configurations in your account.
--
-- 'securityPolicyStats', 'getPoliciesStatsResponse_securityPolicyStats' - Information about the security policies in your account.
--
-- 'totalPolicyCount', 'getPoliciesStatsResponse_totalPolicyCount' - The total number of OpenSearch Serverless security policies and
-- configurations in your account.
--
-- 'httpStatus', 'getPoliciesStatsResponse_httpStatus' - The response's http status code.
newGetPoliciesStatsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetPoliciesStatsResponse
newGetPoliciesStatsResponse :: Int -> GetPoliciesStatsResponse
newGetPoliciesStatsResponse Int
pHttpStatus_ =
  GetPoliciesStatsResponse'
    { $sel:accessPolicyStats:GetPoliciesStatsResponse' :: Maybe AccessPolicyStats
accessPolicyStats =
        forall a. Maybe a
Prelude.Nothing,
      $sel:securityConfigStats:GetPoliciesStatsResponse' :: Maybe SecurityConfigStats
securityConfigStats = forall a. Maybe a
Prelude.Nothing,
      $sel:securityPolicyStats:GetPoliciesStatsResponse' :: Maybe SecurityPolicyStats
securityPolicyStats = forall a. Maybe a
Prelude.Nothing,
      $sel:totalPolicyCount:GetPoliciesStatsResponse' :: Maybe Integer
totalPolicyCount = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetPoliciesStatsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the data access policies in your account.
getPoliciesStatsResponse_accessPolicyStats :: Lens.Lens' GetPoliciesStatsResponse (Prelude.Maybe AccessPolicyStats)
getPoliciesStatsResponse_accessPolicyStats :: Lens' GetPoliciesStatsResponse (Maybe AccessPolicyStats)
getPoliciesStatsResponse_accessPolicyStats = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPoliciesStatsResponse' {Maybe AccessPolicyStats
accessPolicyStats :: Maybe AccessPolicyStats
$sel:accessPolicyStats:GetPoliciesStatsResponse' :: GetPoliciesStatsResponse -> Maybe AccessPolicyStats
accessPolicyStats} -> Maybe AccessPolicyStats
accessPolicyStats) (\s :: GetPoliciesStatsResponse
s@GetPoliciesStatsResponse' {} Maybe AccessPolicyStats
a -> GetPoliciesStatsResponse
s {$sel:accessPolicyStats:GetPoliciesStatsResponse' :: Maybe AccessPolicyStats
accessPolicyStats = Maybe AccessPolicyStats
a} :: GetPoliciesStatsResponse)

-- | Information about the security configurations in your account.
getPoliciesStatsResponse_securityConfigStats :: Lens.Lens' GetPoliciesStatsResponse (Prelude.Maybe SecurityConfigStats)
getPoliciesStatsResponse_securityConfigStats :: Lens' GetPoliciesStatsResponse (Maybe SecurityConfigStats)
getPoliciesStatsResponse_securityConfigStats = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPoliciesStatsResponse' {Maybe SecurityConfigStats
securityConfigStats :: Maybe SecurityConfigStats
$sel:securityConfigStats:GetPoliciesStatsResponse' :: GetPoliciesStatsResponse -> Maybe SecurityConfigStats
securityConfigStats} -> Maybe SecurityConfigStats
securityConfigStats) (\s :: GetPoliciesStatsResponse
s@GetPoliciesStatsResponse' {} Maybe SecurityConfigStats
a -> GetPoliciesStatsResponse
s {$sel:securityConfigStats:GetPoliciesStatsResponse' :: Maybe SecurityConfigStats
securityConfigStats = Maybe SecurityConfigStats
a} :: GetPoliciesStatsResponse)

-- | Information about the security policies in your account.
getPoliciesStatsResponse_securityPolicyStats :: Lens.Lens' GetPoliciesStatsResponse (Prelude.Maybe SecurityPolicyStats)
getPoliciesStatsResponse_securityPolicyStats :: Lens' GetPoliciesStatsResponse (Maybe SecurityPolicyStats)
getPoliciesStatsResponse_securityPolicyStats = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPoliciesStatsResponse' {Maybe SecurityPolicyStats
securityPolicyStats :: Maybe SecurityPolicyStats
$sel:securityPolicyStats:GetPoliciesStatsResponse' :: GetPoliciesStatsResponse -> Maybe SecurityPolicyStats
securityPolicyStats} -> Maybe SecurityPolicyStats
securityPolicyStats) (\s :: GetPoliciesStatsResponse
s@GetPoliciesStatsResponse' {} Maybe SecurityPolicyStats
a -> GetPoliciesStatsResponse
s {$sel:securityPolicyStats:GetPoliciesStatsResponse' :: Maybe SecurityPolicyStats
securityPolicyStats = Maybe SecurityPolicyStats
a} :: GetPoliciesStatsResponse)

-- | The total number of OpenSearch Serverless security policies and
-- configurations in your account.
getPoliciesStatsResponse_totalPolicyCount :: Lens.Lens' GetPoliciesStatsResponse (Prelude.Maybe Prelude.Integer)
getPoliciesStatsResponse_totalPolicyCount :: Lens' GetPoliciesStatsResponse (Maybe Integer)
getPoliciesStatsResponse_totalPolicyCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPoliciesStatsResponse' {Maybe Integer
totalPolicyCount :: Maybe Integer
$sel:totalPolicyCount:GetPoliciesStatsResponse' :: GetPoliciesStatsResponse -> Maybe Integer
totalPolicyCount} -> Maybe Integer
totalPolicyCount) (\s :: GetPoliciesStatsResponse
s@GetPoliciesStatsResponse' {} Maybe Integer
a -> GetPoliciesStatsResponse
s {$sel:totalPolicyCount:GetPoliciesStatsResponse' :: Maybe Integer
totalPolicyCount = Maybe Integer
a} :: GetPoliciesStatsResponse)

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

instance Prelude.NFData GetPoliciesStatsResponse where
  rnf :: GetPoliciesStatsResponse -> ()
rnf GetPoliciesStatsResponse' {Int
Maybe Integer
Maybe AccessPolicyStats
Maybe SecurityConfigStats
Maybe SecurityPolicyStats
httpStatus :: Int
totalPolicyCount :: Maybe Integer
securityPolicyStats :: Maybe SecurityPolicyStats
securityConfigStats :: Maybe SecurityConfigStats
accessPolicyStats :: Maybe AccessPolicyStats
$sel:httpStatus:GetPoliciesStatsResponse' :: GetPoliciesStatsResponse -> Int
$sel:totalPolicyCount:GetPoliciesStatsResponse' :: GetPoliciesStatsResponse -> Maybe Integer
$sel:securityPolicyStats:GetPoliciesStatsResponse' :: GetPoliciesStatsResponse -> Maybe SecurityPolicyStats
$sel:securityConfigStats:GetPoliciesStatsResponse' :: GetPoliciesStatsResponse -> Maybe SecurityConfigStats
$sel:accessPolicyStats:GetPoliciesStatsResponse' :: GetPoliciesStatsResponse -> Maybe AccessPolicyStats
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AccessPolicyStats
accessPolicyStats
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SecurityConfigStats
securityConfigStats
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SecurityPolicyStats
securityPolicyStats
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
totalPolicyCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus