{-# 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.QuickSight.DescribeIpRestriction
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Provides a summary and status of IP rules.
module Amazonka.QuickSight.DescribeIpRestriction
  ( -- * Creating a Request
    DescribeIpRestriction (..),
    newDescribeIpRestriction,

    -- * Request Lenses
    describeIpRestriction_awsAccountId,

    -- * Destructuring the Response
    DescribeIpRestrictionResponse (..),
    newDescribeIpRestrictionResponse,

    -- * Response Lenses
    describeIpRestrictionResponse_awsAccountId,
    describeIpRestrictionResponse_enabled,
    describeIpRestrictionResponse_ipRestrictionRuleMap,
    describeIpRestrictionResponse_requestId,
    describeIpRestrictionResponse_status,
  )
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 Amazonka.QuickSight.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeIpRestriction' smart constructor.
data DescribeIpRestriction = DescribeIpRestriction'
  { -- | The ID of the Amazon Web Services account that contains the IP rules.
    DescribeIpRestriction -> Text
awsAccountId :: Prelude.Text
  }
  deriving (DescribeIpRestriction -> DescribeIpRestriction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeIpRestriction -> DescribeIpRestriction -> Bool
$c/= :: DescribeIpRestriction -> DescribeIpRestriction -> Bool
== :: DescribeIpRestriction -> DescribeIpRestriction -> Bool
$c== :: DescribeIpRestriction -> DescribeIpRestriction -> Bool
Prelude.Eq, ReadPrec [DescribeIpRestriction]
ReadPrec DescribeIpRestriction
Int -> ReadS DescribeIpRestriction
ReadS [DescribeIpRestriction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeIpRestriction]
$creadListPrec :: ReadPrec [DescribeIpRestriction]
readPrec :: ReadPrec DescribeIpRestriction
$creadPrec :: ReadPrec DescribeIpRestriction
readList :: ReadS [DescribeIpRestriction]
$creadList :: ReadS [DescribeIpRestriction]
readsPrec :: Int -> ReadS DescribeIpRestriction
$creadsPrec :: Int -> ReadS DescribeIpRestriction
Prelude.Read, Int -> DescribeIpRestriction -> ShowS
[DescribeIpRestriction] -> ShowS
DescribeIpRestriction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeIpRestriction] -> ShowS
$cshowList :: [DescribeIpRestriction] -> ShowS
show :: DescribeIpRestriction -> String
$cshow :: DescribeIpRestriction -> String
showsPrec :: Int -> DescribeIpRestriction -> ShowS
$cshowsPrec :: Int -> DescribeIpRestriction -> ShowS
Prelude.Show, forall x. Rep DescribeIpRestriction x -> DescribeIpRestriction
forall x. DescribeIpRestriction -> Rep DescribeIpRestriction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeIpRestriction x -> DescribeIpRestriction
$cfrom :: forall x. DescribeIpRestriction -> Rep DescribeIpRestriction x
Prelude.Generic)

-- |
-- Create a value of 'DescribeIpRestriction' 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:
--
-- 'awsAccountId', 'describeIpRestriction_awsAccountId' - The ID of the Amazon Web Services account that contains the IP rules.
newDescribeIpRestriction ::
  -- | 'awsAccountId'
  Prelude.Text ->
  DescribeIpRestriction
newDescribeIpRestriction :: Text -> DescribeIpRestriction
newDescribeIpRestriction Text
pAwsAccountId_ =
  DescribeIpRestriction'
    { $sel:awsAccountId:DescribeIpRestriction' :: Text
awsAccountId =
        Text
pAwsAccountId_
    }

-- | The ID of the Amazon Web Services account that contains the IP rules.
describeIpRestriction_awsAccountId :: Lens.Lens' DescribeIpRestriction Prelude.Text
describeIpRestriction_awsAccountId :: Lens' DescribeIpRestriction Text
describeIpRestriction_awsAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeIpRestriction' {Text
awsAccountId :: Text
$sel:awsAccountId:DescribeIpRestriction' :: DescribeIpRestriction -> Text
awsAccountId} -> Text
awsAccountId) (\s :: DescribeIpRestriction
s@DescribeIpRestriction' {} Text
a -> DescribeIpRestriction
s {$sel:awsAccountId:DescribeIpRestriction' :: Text
awsAccountId = Text
a} :: DescribeIpRestriction)

instance Core.AWSRequest DescribeIpRestriction where
  type
    AWSResponse DescribeIpRestriction =
      DescribeIpRestrictionResponse
  request :: (Service -> Service)
-> DescribeIpRestriction -> Request DescribeIpRestriction
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 DescribeIpRestriction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeIpRestriction)))
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 Text
-> Maybe Bool
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Int
-> DescribeIpRestrictionResponse
DescribeIpRestrictionResponse'
            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
"AwsAccountId")
            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
"Enabled")
            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
"IpRestrictionRuleMap"
                            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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"RequestId")
            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 DescribeIpRestriction where
  hashWithSalt :: Int -> DescribeIpRestriction -> Int
hashWithSalt Int
_salt DescribeIpRestriction' {Text
awsAccountId :: Text
$sel:awsAccountId:DescribeIpRestriction' :: DescribeIpRestriction -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
awsAccountId

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

instance Data.ToHeaders DescribeIpRestriction where
  toHeaders :: DescribeIpRestriction -> 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.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath DescribeIpRestriction where
  toPath :: DescribeIpRestriction -> ByteString
toPath DescribeIpRestriction' {Text
awsAccountId :: Text
$sel:awsAccountId:DescribeIpRestriction' :: DescribeIpRestriction -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
awsAccountId,
        ByteString
"/ip-restriction"
      ]

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

-- | /See:/ 'newDescribeIpRestrictionResponse' smart constructor.
data DescribeIpRestrictionResponse = DescribeIpRestrictionResponse'
  { -- | The ID of the Amazon Web Services account that contains the IP rules.
    DescribeIpRestrictionResponse -> Maybe Text
awsAccountId :: Prelude.Maybe Prelude.Text,
    -- | A value that specifies whether IP rules are turned on.
    DescribeIpRestrictionResponse -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | A map that describes the IP rules with CIDR range and description.
    DescribeIpRestrictionResponse -> Maybe (HashMap Text Text)
ipRestrictionRuleMap :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The Amazon Web Services request ID for this operation.
    DescribeIpRestrictionResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The HTTP status of the request.
    DescribeIpRestrictionResponse -> Int
status :: Prelude.Int
  }
  deriving (DescribeIpRestrictionResponse
-> DescribeIpRestrictionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeIpRestrictionResponse
-> DescribeIpRestrictionResponse -> Bool
$c/= :: DescribeIpRestrictionResponse
-> DescribeIpRestrictionResponse -> Bool
== :: DescribeIpRestrictionResponse
-> DescribeIpRestrictionResponse -> Bool
$c== :: DescribeIpRestrictionResponse
-> DescribeIpRestrictionResponse -> Bool
Prelude.Eq, ReadPrec [DescribeIpRestrictionResponse]
ReadPrec DescribeIpRestrictionResponse
Int -> ReadS DescribeIpRestrictionResponse
ReadS [DescribeIpRestrictionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeIpRestrictionResponse]
$creadListPrec :: ReadPrec [DescribeIpRestrictionResponse]
readPrec :: ReadPrec DescribeIpRestrictionResponse
$creadPrec :: ReadPrec DescribeIpRestrictionResponse
readList :: ReadS [DescribeIpRestrictionResponse]
$creadList :: ReadS [DescribeIpRestrictionResponse]
readsPrec :: Int -> ReadS DescribeIpRestrictionResponse
$creadsPrec :: Int -> ReadS DescribeIpRestrictionResponse
Prelude.Read, Int -> DescribeIpRestrictionResponse -> ShowS
[DescribeIpRestrictionResponse] -> ShowS
DescribeIpRestrictionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeIpRestrictionResponse] -> ShowS
$cshowList :: [DescribeIpRestrictionResponse] -> ShowS
show :: DescribeIpRestrictionResponse -> String
$cshow :: DescribeIpRestrictionResponse -> String
showsPrec :: Int -> DescribeIpRestrictionResponse -> ShowS
$cshowsPrec :: Int -> DescribeIpRestrictionResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeIpRestrictionResponse x
-> DescribeIpRestrictionResponse
forall x.
DescribeIpRestrictionResponse
-> Rep DescribeIpRestrictionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeIpRestrictionResponse x
-> DescribeIpRestrictionResponse
$cfrom :: forall x.
DescribeIpRestrictionResponse
-> Rep DescribeIpRestrictionResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeIpRestrictionResponse' 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:
--
-- 'awsAccountId', 'describeIpRestrictionResponse_awsAccountId' - The ID of the Amazon Web Services account that contains the IP rules.
--
-- 'enabled', 'describeIpRestrictionResponse_enabled' - A value that specifies whether IP rules are turned on.
--
-- 'ipRestrictionRuleMap', 'describeIpRestrictionResponse_ipRestrictionRuleMap' - A map that describes the IP rules with CIDR range and description.
--
-- 'requestId', 'describeIpRestrictionResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'status', 'describeIpRestrictionResponse_status' - The HTTP status of the request.
newDescribeIpRestrictionResponse ::
  -- | 'status'
  Prelude.Int ->
  DescribeIpRestrictionResponse
newDescribeIpRestrictionResponse :: Int -> DescribeIpRestrictionResponse
newDescribeIpRestrictionResponse Int
pStatus_ =
  DescribeIpRestrictionResponse'
    { $sel:awsAccountId:DescribeIpRestrictionResponse' :: Maybe Text
awsAccountId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:DescribeIpRestrictionResponse' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
      $sel:ipRestrictionRuleMap:DescribeIpRestrictionResponse' :: Maybe (HashMap Text Text)
ipRestrictionRuleMap = forall a. Maybe a
Prelude.Nothing,
      $sel:requestId:DescribeIpRestrictionResponse' :: Maybe Text
requestId = forall a. Maybe a
Prelude.Nothing,
      $sel:status:DescribeIpRestrictionResponse' :: Int
status = Int
pStatus_
    }

-- | The ID of the Amazon Web Services account that contains the IP rules.
describeIpRestrictionResponse_awsAccountId :: Lens.Lens' DescribeIpRestrictionResponse (Prelude.Maybe Prelude.Text)
describeIpRestrictionResponse_awsAccountId :: Lens' DescribeIpRestrictionResponse (Maybe Text)
describeIpRestrictionResponse_awsAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeIpRestrictionResponse' {Maybe Text
awsAccountId :: Maybe Text
$sel:awsAccountId:DescribeIpRestrictionResponse' :: DescribeIpRestrictionResponse -> Maybe Text
awsAccountId} -> Maybe Text
awsAccountId) (\s :: DescribeIpRestrictionResponse
s@DescribeIpRestrictionResponse' {} Maybe Text
a -> DescribeIpRestrictionResponse
s {$sel:awsAccountId:DescribeIpRestrictionResponse' :: Maybe Text
awsAccountId = Maybe Text
a} :: DescribeIpRestrictionResponse)

-- | A value that specifies whether IP rules are turned on.
describeIpRestrictionResponse_enabled :: Lens.Lens' DescribeIpRestrictionResponse (Prelude.Maybe Prelude.Bool)
describeIpRestrictionResponse_enabled :: Lens' DescribeIpRestrictionResponse (Maybe Bool)
describeIpRestrictionResponse_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeIpRestrictionResponse' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:DescribeIpRestrictionResponse' :: DescribeIpRestrictionResponse -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: DescribeIpRestrictionResponse
s@DescribeIpRestrictionResponse' {} Maybe Bool
a -> DescribeIpRestrictionResponse
s {$sel:enabled:DescribeIpRestrictionResponse' :: Maybe Bool
enabled = Maybe Bool
a} :: DescribeIpRestrictionResponse)

-- | A map that describes the IP rules with CIDR range and description.
describeIpRestrictionResponse_ipRestrictionRuleMap :: Lens.Lens' DescribeIpRestrictionResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
describeIpRestrictionResponse_ipRestrictionRuleMap :: Lens' DescribeIpRestrictionResponse (Maybe (HashMap Text Text))
describeIpRestrictionResponse_ipRestrictionRuleMap = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeIpRestrictionResponse' {Maybe (HashMap Text Text)
ipRestrictionRuleMap :: Maybe (HashMap Text Text)
$sel:ipRestrictionRuleMap:DescribeIpRestrictionResponse' :: DescribeIpRestrictionResponse -> Maybe (HashMap Text Text)
ipRestrictionRuleMap} -> Maybe (HashMap Text Text)
ipRestrictionRuleMap) (\s :: DescribeIpRestrictionResponse
s@DescribeIpRestrictionResponse' {} Maybe (HashMap Text Text)
a -> DescribeIpRestrictionResponse
s {$sel:ipRestrictionRuleMap:DescribeIpRestrictionResponse' :: Maybe (HashMap Text Text)
ipRestrictionRuleMap = Maybe (HashMap Text Text)
a} :: DescribeIpRestrictionResponse) 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 Amazon Web Services request ID for this operation.
describeIpRestrictionResponse_requestId :: Lens.Lens' DescribeIpRestrictionResponse (Prelude.Maybe Prelude.Text)
describeIpRestrictionResponse_requestId :: Lens' DescribeIpRestrictionResponse (Maybe Text)
describeIpRestrictionResponse_requestId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeIpRestrictionResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:DescribeIpRestrictionResponse' :: DescribeIpRestrictionResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: DescribeIpRestrictionResponse
s@DescribeIpRestrictionResponse' {} Maybe Text
a -> DescribeIpRestrictionResponse
s {$sel:requestId:DescribeIpRestrictionResponse' :: Maybe Text
requestId = Maybe Text
a} :: DescribeIpRestrictionResponse)

-- | The HTTP status of the request.
describeIpRestrictionResponse_status :: Lens.Lens' DescribeIpRestrictionResponse Prelude.Int
describeIpRestrictionResponse_status :: Lens' DescribeIpRestrictionResponse Int
describeIpRestrictionResponse_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeIpRestrictionResponse' {Int
status :: Int
$sel:status:DescribeIpRestrictionResponse' :: DescribeIpRestrictionResponse -> Int
status} -> Int
status) (\s :: DescribeIpRestrictionResponse
s@DescribeIpRestrictionResponse' {} Int
a -> DescribeIpRestrictionResponse
s {$sel:status:DescribeIpRestrictionResponse' :: Int
status = Int
a} :: DescribeIpRestrictionResponse)

instance Prelude.NFData DescribeIpRestrictionResponse where
  rnf :: DescribeIpRestrictionResponse -> ()
rnf DescribeIpRestrictionResponse' {Int
Maybe Bool
Maybe Text
Maybe (HashMap Text Text)
status :: Int
requestId :: Maybe Text
ipRestrictionRuleMap :: Maybe (HashMap Text Text)
enabled :: Maybe Bool
awsAccountId :: Maybe Text
$sel:status:DescribeIpRestrictionResponse' :: DescribeIpRestrictionResponse -> Int
$sel:requestId:DescribeIpRestrictionResponse' :: DescribeIpRestrictionResponse -> Maybe Text
$sel:ipRestrictionRuleMap:DescribeIpRestrictionResponse' :: DescribeIpRestrictionResponse -> Maybe (HashMap Text Text)
$sel:enabled:DescribeIpRestrictionResponse' :: DescribeIpRestrictionResponse -> Maybe Bool
$sel:awsAccountId:DescribeIpRestrictionResponse' :: DescribeIpRestrictionResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
awsAccountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
ipRestrictionRuleMap
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
requestId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
status