{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GlobalAccelerator.Types.CidrAuthorizationContext where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides authorization for Amazon to bring a specific IP address range
-- to a specific AWS 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 /AWS 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
(CidrAuthorizationContext -> CidrAuthorizationContext -> Bool)
-> (CidrAuthorizationContext -> CidrAuthorizationContext -> Bool)
-> Eq CidrAuthorizationContext
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]
(Int -> ReadS CidrAuthorizationContext)
-> ReadS [CidrAuthorizationContext]
-> ReadPrec CidrAuthorizationContext
-> ReadPrec [CidrAuthorizationContext]
-> Read 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
(Int -> CidrAuthorizationContext -> ShowS)
-> (CidrAuthorizationContext -> String)
-> ([CidrAuthorizationContext] -> ShowS)
-> Show CidrAuthorizationContext
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.
 CidrAuthorizationContext -> Rep CidrAuthorizationContext x)
-> (forall x.
    Rep CidrAuthorizationContext x -> CidrAuthorizationContext)
-> Generic CidrAuthorizationContext
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' :: Text -> Text -> CidrAuthorizationContext
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 :: (Text -> f Text)
-> CidrAuthorizationContext -> f CidrAuthorizationContext
cidrAuthorizationContext_message = (CidrAuthorizationContext -> Text)
-> (CidrAuthorizationContext -> Text -> CidrAuthorizationContext)
-> Lens CidrAuthorizationContext CidrAuthorizationContext Text Text
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 :: (Text -> f Text)
-> CidrAuthorizationContext -> f CidrAuthorizationContext
cidrAuthorizationContext_signature = (CidrAuthorizationContext -> Text)
-> (CidrAuthorizationContext -> Text -> CidrAuthorizationContext)
-> Lens CidrAuthorizationContext CidrAuthorizationContext Text Text
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

instance Prelude.NFData CidrAuthorizationContext

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Message" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
message),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Signature" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
signature)
          ]
      )