{-# 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.Chime.Types.SipRuleTargetApplication
-- 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.Chime.Types.SipRuleTargetApplication where

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

-- | Target SIP media application and other details, such as priority and AWS
-- Region, to be specified in the SIP rule. Only one SIP rule per AWS
-- Region can be provided.
--
-- /See:/ 'newSipRuleTargetApplication' smart constructor.
data SipRuleTargetApplication = SipRuleTargetApplication'
  { -- | Priority of the SIP media application in the target list.
    SipRuleTargetApplication -> Maybe Natural
priority :: Prelude.Maybe Prelude.Natural,
    -- | The AWS Region of the target application.
    SipRuleTargetApplication -> Maybe Text
awsRegion :: Prelude.Maybe Prelude.Text,
    -- | The SIP media application ID.
    SipRuleTargetApplication -> Maybe Text
sipMediaApplicationId :: Prelude.Maybe Prelude.Text
  }
  deriving (SipRuleTargetApplication -> SipRuleTargetApplication -> Bool
(SipRuleTargetApplication -> SipRuleTargetApplication -> Bool)
-> (SipRuleTargetApplication -> SipRuleTargetApplication -> Bool)
-> Eq SipRuleTargetApplication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SipRuleTargetApplication -> SipRuleTargetApplication -> Bool
$c/= :: SipRuleTargetApplication -> SipRuleTargetApplication -> Bool
== :: SipRuleTargetApplication -> SipRuleTargetApplication -> Bool
$c== :: SipRuleTargetApplication -> SipRuleTargetApplication -> Bool
Prelude.Eq, ReadPrec [SipRuleTargetApplication]
ReadPrec SipRuleTargetApplication
Int -> ReadS SipRuleTargetApplication
ReadS [SipRuleTargetApplication]
(Int -> ReadS SipRuleTargetApplication)
-> ReadS [SipRuleTargetApplication]
-> ReadPrec SipRuleTargetApplication
-> ReadPrec [SipRuleTargetApplication]
-> Read SipRuleTargetApplication
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SipRuleTargetApplication]
$creadListPrec :: ReadPrec [SipRuleTargetApplication]
readPrec :: ReadPrec SipRuleTargetApplication
$creadPrec :: ReadPrec SipRuleTargetApplication
readList :: ReadS [SipRuleTargetApplication]
$creadList :: ReadS [SipRuleTargetApplication]
readsPrec :: Int -> ReadS SipRuleTargetApplication
$creadsPrec :: Int -> ReadS SipRuleTargetApplication
Prelude.Read, Int -> SipRuleTargetApplication -> ShowS
[SipRuleTargetApplication] -> ShowS
SipRuleTargetApplication -> String
(Int -> SipRuleTargetApplication -> ShowS)
-> (SipRuleTargetApplication -> String)
-> ([SipRuleTargetApplication] -> ShowS)
-> Show SipRuleTargetApplication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SipRuleTargetApplication] -> ShowS
$cshowList :: [SipRuleTargetApplication] -> ShowS
show :: SipRuleTargetApplication -> String
$cshow :: SipRuleTargetApplication -> String
showsPrec :: Int -> SipRuleTargetApplication -> ShowS
$cshowsPrec :: Int -> SipRuleTargetApplication -> ShowS
Prelude.Show, (forall x.
 SipRuleTargetApplication -> Rep SipRuleTargetApplication x)
-> (forall x.
    Rep SipRuleTargetApplication x -> SipRuleTargetApplication)
-> Generic SipRuleTargetApplication
forall x.
Rep SipRuleTargetApplication x -> SipRuleTargetApplication
forall x.
SipRuleTargetApplication -> Rep SipRuleTargetApplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SipRuleTargetApplication x -> SipRuleTargetApplication
$cfrom :: forall x.
SipRuleTargetApplication -> Rep SipRuleTargetApplication x
Prelude.Generic)

-- |
-- Create a value of 'SipRuleTargetApplication' 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:
--
-- 'priority', 'sipRuleTargetApplication_priority' - Priority of the SIP media application in the target list.
--
-- 'awsRegion', 'sipRuleTargetApplication_awsRegion' - The AWS Region of the target application.
--
-- 'sipMediaApplicationId', 'sipRuleTargetApplication_sipMediaApplicationId' - The SIP media application ID.
newSipRuleTargetApplication ::
  SipRuleTargetApplication
newSipRuleTargetApplication :: SipRuleTargetApplication
newSipRuleTargetApplication =
  SipRuleTargetApplication' :: Maybe Natural
-> Maybe Text -> Maybe Text -> SipRuleTargetApplication
SipRuleTargetApplication'
    { $sel:priority:SipRuleTargetApplication' :: Maybe Natural
priority =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:awsRegion:SipRuleTargetApplication' :: Maybe Text
awsRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sipMediaApplicationId:SipRuleTargetApplication' :: Maybe Text
sipMediaApplicationId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Priority of the SIP media application in the target list.
sipRuleTargetApplication_priority :: Lens.Lens' SipRuleTargetApplication (Prelude.Maybe Prelude.Natural)
sipRuleTargetApplication_priority :: (Maybe Natural -> f (Maybe Natural))
-> SipRuleTargetApplication -> f SipRuleTargetApplication
sipRuleTargetApplication_priority = (SipRuleTargetApplication -> Maybe Natural)
-> (SipRuleTargetApplication
    -> Maybe Natural -> SipRuleTargetApplication)
-> Lens
     SipRuleTargetApplication
     SipRuleTargetApplication
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SipRuleTargetApplication' {Maybe Natural
priority :: Maybe Natural
$sel:priority:SipRuleTargetApplication' :: SipRuleTargetApplication -> Maybe Natural
priority} -> Maybe Natural
priority) (\s :: SipRuleTargetApplication
s@SipRuleTargetApplication' {} Maybe Natural
a -> SipRuleTargetApplication
s {$sel:priority:SipRuleTargetApplication' :: Maybe Natural
priority = Maybe Natural
a} :: SipRuleTargetApplication)

-- | The AWS Region of the target application.
sipRuleTargetApplication_awsRegion :: Lens.Lens' SipRuleTargetApplication (Prelude.Maybe Prelude.Text)
sipRuleTargetApplication_awsRegion :: (Maybe Text -> f (Maybe Text))
-> SipRuleTargetApplication -> f SipRuleTargetApplication
sipRuleTargetApplication_awsRegion = (SipRuleTargetApplication -> Maybe Text)
-> (SipRuleTargetApplication
    -> Maybe Text -> SipRuleTargetApplication)
-> Lens
     SipRuleTargetApplication
     SipRuleTargetApplication
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SipRuleTargetApplication' {Maybe Text
awsRegion :: Maybe Text
$sel:awsRegion:SipRuleTargetApplication' :: SipRuleTargetApplication -> Maybe Text
awsRegion} -> Maybe Text
awsRegion) (\s :: SipRuleTargetApplication
s@SipRuleTargetApplication' {} Maybe Text
a -> SipRuleTargetApplication
s {$sel:awsRegion:SipRuleTargetApplication' :: Maybe Text
awsRegion = Maybe Text
a} :: SipRuleTargetApplication)

-- | The SIP media application ID.
sipRuleTargetApplication_sipMediaApplicationId :: Lens.Lens' SipRuleTargetApplication (Prelude.Maybe Prelude.Text)
sipRuleTargetApplication_sipMediaApplicationId :: (Maybe Text -> f (Maybe Text))
-> SipRuleTargetApplication -> f SipRuleTargetApplication
sipRuleTargetApplication_sipMediaApplicationId = (SipRuleTargetApplication -> Maybe Text)
-> (SipRuleTargetApplication
    -> Maybe Text -> SipRuleTargetApplication)
-> Lens
     SipRuleTargetApplication
     SipRuleTargetApplication
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SipRuleTargetApplication' {Maybe Text
sipMediaApplicationId :: Maybe Text
$sel:sipMediaApplicationId:SipRuleTargetApplication' :: SipRuleTargetApplication -> Maybe Text
sipMediaApplicationId} -> Maybe Text
sipMediaApplicationId) (\s :: SipRuleTargetApplication
s@SipRuleTargetApplication' {} Maybe Text
a -> SipRuleTargetApplication
s {$sel:sipMediaApplicationId:SipRuleTargetApplication' :: Maybe Text
sipMediaApplicationId = Maybe Text
a} :: SipRuleTargetApplication)

instance Core.FromJSON SipRuleTargetApplication where
  parseJSON :: Value -> Parser SipRuleTargetApplication
parseJSON =
    String
-> (Object -> Parser SipRuleTargetApplication)
-> Value
-> Parser SipRuleTargetApplication
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SipRuleTargetApplication"
      ( \Object
x ->
          Maybe Natural
-> Maybe Text -> Maybe Text -> SipRuleTargetApplication
SipRuleTargetApplication'
            (Maybe Natural
 -> Maybe Text -> Maybe Text -> SipRuleTargetApplication)
-> Parser (Maybe Natural)
-> Parser (Maybe Text -> Maybe Text -> SipRuleTargetApplication)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Priority")
            Parser (Maybe Text -> Maybe Text -> SipRuleTargetApplication)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> SipRuleTargetApplication)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AwsRegion")
            Parser (Maybe Text -> SipRuleTargetApplication)
-> Parser (Maybe Text) -> Parser SipRuleTargetApplication
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SipMediaApplicationId")
      )

instance Prelude.Hashable SipRuleTargetApplication

instance Prelude.NFData SipRuleTargetApplication

instance Core.ToJSON SipRuleTargetApplication where
  toJSON :: SipRuleTargetApplication -> Value
toJSON SipRuleTargetApplication' {Maybe Natural
Maybe Text
sipMediaApplicationId :: Maybe Text
awsRegion :: Maybe Text
priority :: Maybe Natural
$sel:sipMediaApplicationId:SipRuleTargetApplication' :: SipRuleTargetApplication -> Maybe Text
$sel:awsRegion:SipRuleTargetApplication' :: SipRuleTargetApplication -> Maybe Text
$sel:priority:SipRuleTargetApplication' :: SipRuleTargetApplication -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Priority" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
priority,
            (Text
"AwsRegion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
awsRegion,
            (Text
"SipMediaApplicationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sipMediaApplicationId
          ]
      )