{-# 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.WorkDocs.Types.Subscription
-- 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.WorkDocs.Types.Subscription where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkDocs.Types.SubscriptionProtocolType

-- | Describes a subscription.
--
-- /See:/ 'newSubscription' smart constructor.
data Subscription = Subscription'
  { -- | The protocol of the subscription.
    Subscription -> Maybe SubscriptionProtocolType
protocol :: Prelude.Maybe SubscriptionProtocolType,
    -- | The endpoint of the subscription.
    Subscription -> Maybe Text
endPoint :: Prelude.Maybe Prelude.Text,
    -- | The ID of the subscription.
    Subscription -> Maybe Text
subscriptionId :: Prelude.Maybe Prelude.Text
  }
  deriving (Subscription -> Subscription -> Bool
(Subscription -> Subscription -> Bool)
-> (Subscription -> Subscription -> Bool) -> Eq Subscription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Subscription -> Subscription -> Bool
$c/= :: Subscription -> Subscription -> Bool
== :: Subscription -> Subscription -> Bool
$c== :: Subscription -> Subscription -> Bool
Prelude.Eq, ReadPrec [Subscription]
ReadPrec Subscription
Int -> ReadS Subscription
ReadS [Subscription]
(Int -> ReadS Subscription)
-> ReadS [Subscription]
-> ReadPrec Subscription
-> ReadPrec [Subscription]
-> Read Subscription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Subscription]
$creadListPrec :: ReadPrec [Subscription]
readPrec :: ReadPrec Subscription
$creadPrec :: ReadPrec Subscription
readList :: ReadS [Subscription]
$creadList :: ReadS [Subscription]
readsPrec :: Int -> ReadS Subscription
$creadsPrec :: Int -> ReadS Subscription
Prelude.Read, Int -> Subscription -> ShowS
[Subscription] -> ShowS
Subscription -> String
(Int -> Subscription -> ShowS)
-> (Subscription -> String)
-> ([Subscription] -> ShowS)
-> Show Subscription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Subscription] -> ShowS
$cshowList :: [Subscription] -> ShowS
show :: Subscription -> String
$cshow :: Subscription -> String
showsPrec :: Int -> Subscription -> ShowS
$cshowsPrec :: Int -> Subscription -> ShowS
Prelude.Show, (forall x. Subscription -> Rep Subscription x)
-> (forall x. Rep Subscription x -> Subscription)
-> Generic Subscription
forall x. Rep Subscription x -> Subscription
forall x. Subscription -> Rep Subscription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Subscription x -> Subscription
$cfrom :: forall x. Subscription -> Rep Subscription x
Prelude.Generic)

-- |
-- Create a value of 'Subscription' 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:
--
-- 'protocol', 'subscription_protocol' - The protocol of the subscription.
--
-- 'endPoint', 'subscription_endPoint' - The endpoint of the subscription.
--
-- 'subscriptionId', 'subscription_subscriptionId' - The ID of the subscription.
newSubscription ::
  Subscription
newSubscription :: Subscription
newSubscription =
  Subscription' :: Maybe SubscriptionProtocolType
-> Maybe Text -> Maybe Text -> Subscription
Subscription'
    { $sel:protocol:Subscription' :: Maybe SubscriptionProtocolType
protocol = Maybe SubscriptionProtocolType
forall a. Maybe a
Prelude.Nothing,
      $sel:endPoint:Subscription' :: Maybe Text
endPoint = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subscriptionId:Subscription' :: Maybe Text
subscriptionId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The protocol of the subscription.
subscription_protocol :: Lens.Lens' Subscription (Prelude.Maybe SubscriptionProtocolType)
subscription_protocol :: (Maybe SubscriptionProtocolType
 -> f (Maybe SubscriptionProtocolType))
-> Subscription -> f Subscription
subscription_protocol = (Subscription -> Maybe SubscriptionProtocolType)
-> (Subscription -> Maybe SubscriptionProtocolType -> Subscription)
-> Lens
     Subscription
     Subscription
     (Maybe SubscriptionProtocolType)
     (Maybe SubscriptionProtocolType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscription' {Maybe SubscriptionProtocolType
protocol :: Maybe SubscriptionProtocolType
$sel:protocol:Subscription' :: Subscription -> Maybe SubscriptionProtocolType
protocol} -> Maybe SubscriptionProtocolType
protocol) (\s :: Subscription
s@Subscription' {} Maybe SubscriptionProtocolType
a -> Subscription
s {$sel:protocol:Subscription' :: Maybe SubscriptionProtocolType
protocol = Maybe SubscriptionProtocolType
a} :: Subscription)

-- | The endpoint of the subscription.
subscription_endPoint :: Lens.Lens' Subscription (Prelude.Maybe Prelude.Text)
subscription_endPoint :: (Maybe Text -> f (Maybe Text)) -> Subscription -> f Subscription
subscription_endPoint = (Subscription -> Maybe Text)
-> (Subscription -> Maybe Text -> Subscription)
-> Lens Subscription Subscription (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscription' {Maybe Text
endPoint :: Maybe Text
$sel:endPoint:Subscription' :: Subscription -> Maybe Text
endPoint} -> Maybe Text
endPoint) (\s :: Subscription
s@Subscription' {} Maybe Text
a -> Subscription
s {$sel:endPoint:Subscription' :: Maybe Text
endPoint = Maybe Text
a} :: Subscription)

-- | The ID of the subscription.
subscription_subscriptionId :: Lens.Lens' Subscription (Prelude.Maybe Prelude.Text)
subscription_subscriptionId :: (Maybe Text -> f (Maybe Text)) -> Subscription -> f Subscription
subscription_subscriptionId = (Subscription -> Maybe Text)
-> (Subscription -> Maybe Text -> Subscription)
-> Lens Subscription Subscription (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscription' {Maybe Text
subscriptionId :: Maybe Text
$sel:subscriptionId:Subscription' :: Subscription -> Maybe Text
subscriptionId} -> Maybe Text
subscriptionId) (\s :: Subscription
s@Subscription' {} Maybe Text
a -> Subscription
s {$sel:subscriptionId:Subscription' :: Maybe Text
subscriptionId = Maybe Text
a} :: Subscription)

instance Core.FromJSON Subscription where
  parseJSON :: Value -> Parser Subscription
parseJSON =
    String
-> (Object -> Parser Subscription) -> Value -> Parser Subscription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Subscription"
      ( \Object
x ->
          Maybe SubscriptionProtocolType
-> Maybe Text -> Maybe Text -> Subscription
Subscription'
            (Maybe SubscriptionProtocolType
 -> Maybe Text -> Maybe Text -> Subscription)
-> Parser (Maybe SubscriptionProtocolType)
-> Parser (Maybe Text -> Maybe Text -> Subscription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SubscriptionProtocolType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Protocol")
            Parser (Maybe Text -> Maybe Text -> Subscription)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Subscription)
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
"EndPoint")
            Parser (Maybe Text -> Subscription)
-> Parser (Maybe Text) -> Parser Subscription
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
"SubscriptionId")
      )

instance Prelude.Hashable Subscription

instance Prelude.NFData Subscription