{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.GlobalAccelerator.Types.CidrAuthorizationContext
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GlobalAccelerator.Types.CidrAuthorizationContext 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

-- | Provides authorization for Amazon to bring a specific IP address range
-- to a specific Amazon Web Services account using bring your own IP
-- addresses (BYOIP).
--
-- For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/using-byoip.html Bring your own IP addresses (BYOIP)>
-- in the /Global Accelerator Developer Guide/.
--
-- /See:/ 'newCidrAuthorizationContext' smart constructor.
data CidrAuthorizationContext = CidrAuthorizationContext'
  { -- | The plain-text authorization message for the prefix and account.
    CidrAuthorizationContext -> Text
message :: Prelude.Text,
    -- | The signed authorization message for the prefix and account.
    CidrAuthorizationContext -> Text
signature :: Prelude.Text
  }
  deriving (CidrAuthorizationContext -> CidrAuthorizationContext -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CidrAuthorizationContext -> CidrAuthorizationContext -> Bool
$c/= :: CidrAuthorizationContext -> CidrAuthorizationContext -> Bool
== :: CidrAuthorizationContext -> CidrAuthorizationContext -> Bool
$c== :: CidrAuthorizationContext -> CidrAuthorizationContext -> Bool
Prelude.Eq, ReadPrec [CidrAuthorizationContext]
ReadPrec CidrAuthorizationContext
Int -> ReadS CidrAuthorizationContext
ReadS [CidrAuthorizationContext]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CidrAuthorizationContext]
$creadListPrec :: ReadPrec [CidrAuthorizationContext]
readPrec :: ReadPrec CidrAuthorizationContext
$creadPrec :: ReadPrec CidrAuthorizationContext
readList :: ReadS [CidrAuthorizationContext]
$creadList :: ReadS [CidrAuthorizationContext]
readsPrec :: Int -> ReadS CidrAuthorizationContext
$creadsPrec :: Int -> ReadS CidrAuthorizationContext
Prelude.Read, Int -> CidrAuthorizationContext -> ShowS
[CidrAuthorizationContext] -> ShowS
CidrAuthorizationContext -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CidrAuthorizationContext] -> ShowS
$cshowList :: [CidrAuthorizationContext] -> ShowS
show :: CidrAuthorizationContext -> String
$cshow :: CidrAuthorizationContext -> String
showsPrec :: Int -> CidrAuthorizationContext -> ShowS
$cshowsPrec :: Int -> CidrAuthorizationContext -> ShowS
Prelude.Show, forall x.
Rep CidrAuthorizationContext x -> CidrAuthorizationContext
forall x.
CidrAuthorizationContext -> Rep CidrAuthorizationContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CidrAuthorizationContext x -> CidrAuthorizationContext
$cfrom :: forall x.
CidrAuthorizationContext -> Rep CidrAuthorizationContext x
Prelude.Generic)

-- |
-- Create a value of 'CidrAuthorizationContext' 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:
--
-- 'message', 'cidrAuthorizationContext_message' - The plain-text authorization message for the prefix and account.
--
-- 'signature', 'cidrAuthorizationContext_signature' - The signed authorization message for the prefix and account.
newCidrAuthorizationContext ::
  -- | 'message'
  Prelude.Text ->
  -- | 'signature'
  Prelude.Text ->
  CidrAuthorizationContext
newCidrAuthorizationContext :: Text -> Text -> CidrAuthorizationContext
newCidrAuthorizationContext Text
pMessage_ Text
pSignature_ =
  CidrAuthorizationContext'
    { $sel:message:CidrAuthorizationContext' :: Text
message = Text
pMessage_,
      $sel:signature:CidrAuthorizationContext' :: Text
signature = Text
pSignature_
    }

-- | The plain-text authorization message for the prefix and account.
cidrAuthorizationContext_message :: Lens.Lens' CidrAuthorizationContext Prelude.Text
cidrAuthorizationContext_message :: Lens' CidrAuthorizationContext Text
cidrAuthorizationContext_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CidrAuthorizationContext' {Text
message :: Text
$sel:message:CidrAuthorizationContext' :: CidrAuthorizationContext -> Text
message} -> Text
message) (\s :: CidrAuthorizationContext
s@CidrAuthorizationContext' {} Text
a -> CidrAuthorizationContext
s {$sel:message:CidrAuthorizationContext' :: Text
message = Text
a} :: CidrAuthorizationContext)

-- | The signed authorization message for the prefix and account.
cidrAuthorizationContext_signature :: Lens.Lens' CidrAuthorizationContext Prelude.Text
cidrAuthorizationContext_signature :: Lens' CidrAuthorizationContext Text
cidrAuthorizationContext_signature = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CidrAuthorizationContext' {Text
signature :: Text
$sel:signature:CidrAuthorizationContext' :: CidrAuthorizationContext -> Text
signature} -> Text
signature) (\s :: CidrAuthorizationContext
s@CidrAuthorizationContext' {} Text
a -> CidrAuthorizationContext
s {$sel:signature:CidrAuthorizationContext' :: Text
signature = Text
a} :: CidrAuthorizationContext)

instance Prelude.Hashable CidrAuthorizationContext where
  hashWithSalt :: Int -> CidrAuthorizationContext -> Int
hashWithSalt Int
_salt CidrAuthorizationContext' {Text
signature :: Text
message :: Text
$sel:signature:CidrAuthorizationContext' :: CidrAuthorizationContext -> Text
$sel:message:CidrAuthorizationContext' :: CidrAuthorizationContext -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
signature

instance Prelude.NFData CidrAuthorizationContext where
  rnf :: CidrAuthorizationContext -> ()
rnf CidrAuthorizationContext' {Text
signature :: Text
message :: Text
$sel:signature:CidrAuthorizationContext' :: CidrAuthorizationContext -> Text
$sel:message:CidrAuthorizationContext' :: CidrAuthorizationContext -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
message
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
signature

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