{-# 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.CloudWatchLogs.Types.Destination
-- 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.CloudWatchLogs.Types.Destination where

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

-- | Represents a cross-account destination that receives subscription log
-- events.
--
-- /See:/ 'newDestination' smart constructor.
data Destination = Destination'
  { -- | The Amazon Resource Name (ARN) of the physical target where the log
    -- events are delivered (for example, a Kinesis stream).
    Destination -> Maybe Text
targetArn :: Prelude.Maybe Prelude.Text,
    -- | The creation time of the destination, expressed as the number of
    -- milliseconds after Jan 1, 1970 00:00:00 UTC.
    Destination -> Maybe Natural
creationTime :: Prelude.Maybe Prelude.Natural,
    -- | The ARN of this destination.
    Destination -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | An IAM policy document that governs which Amazon Web Services accounts
    -- can create subscription filters against this destination.
    Destination -> Maybe Text
accessPolicy :: Prelude.Maybe Prelude.Text,
    -- | The name of the destination.
    Destination -> Maybe Text
destinationName :: Prelude.Maybe Prelude.Text,
    -- | A role for impersonation, used when delivering log events to the target.
    Destination -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (Destination -> Destination -> Bool
(Destination -> Destination -> Bool)
-> (Destination -> Destination -> Bool) -> Eq Destination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Destination -> Destination -> Bool
$c/= :: Destination -> Destination -> Bool
== :: Destination -> Destination -> Bool
$c== :: Destination -> Destination -> Bool
Prelude.Eq, ReadPrec [Destination]
ReadPrec Destination
Int -> ReadS Destination
ReadS [Destination]
(Int -> ReadS Destination)
-> ReadS [Destination]
-> ReadPrec Destination
-> ReadPrec [Destination]
-> Read Destination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Destination]
$creadListPrec :: ReadPrec [Destination]
readPrec :: ReadPrec Destination
$creadPrec :: ReadPrec Destination
readList :: ReadS [Destination]
$creadList :: ReadS [Destination]
readsPrec :: Int -> ReadS Destination
$creadsPrec :: Int -> ReadS Destination
Prelude.Read, Int -> Destination -> ShowS
[Destination] -> ShowS
Destination -> String
(Int -> Destination -> ShowS)
-> (Destination -> String)
-> ([Destination] -> ShowS)
-> Show Destination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Destination] -> ShowS
$cshowList :: [Destination] -> ShowS
show :: Destination -> String
$cshow :: Destination -> String
showsPrec :: Int -> Destination -> ShowS
$cshowsPrec :: Int -> Destination -> ShowS
Prelude.Show, (forall x. Destination -> Rep Destination x)
-> (forall x. Rep Destination x -> Destination)
-> Generic Destination
forall x. Rep Destination x -> Destination
forall x. Destination -> Rep Destination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Destination x -> Destination
$cfrom :: forall x. Destination -> Rep Destination x
Prelude.Generic)

-- |
-- Create a value of 'Destination' 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:
--
-- 'targetArn', 'destination_targetArn' - The Amazon Resource Name (ARN) of the physical target where the log
-- events are delivered (for example, a Kinesis stream).
--
-- 'creationTime', 'destination_creationTime' - The creation time of the destination, expressed as the number of
-- milliseconds after Jan 1, 1970 00:00:00 UTC.
--
-- 'arn', 'destination_arn' - The ARN of this destination.
--
-- 'accessPolicy', 'destination_accessPolicy' - An IAM policy document that governs which Amazon Web Services accounts
-- can create subscription filters against this destination.
--
-- 'destinationName', 'destination_destinationName' - The name of the destination.
--
-- 'roleArn', 'destination_roleArn' - A role for impersonation, used when delivering log events to the target.
newDestination ::
  Destination
newDestination :: Destination
newDestination =
  Destination' :: Maybe Text
-> Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Destination
Destination'
    { $sel:targetArn:Destination' :: Maybe Text
targetArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:Destination' :: Maybe Natural
creationTime = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:Destination' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accessPolicy:Destination' :: Maybe Text
accessPolicy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationName:Destination' :: Maybe Text
destinationName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:Destination' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the physical target where the log
-- events are delivered (for example, a Kinesis stream).
destination_targetArn :: Lens.Lens' Destination (Prelude.Maybe Prelude.Text)
destination_targetArn :: (Maybe Text -> f (Maybe Text)) -> Destination -> f Destination
destination_targetArn = (Destination -> Maybe Text)
-> (Destination -> Maybe Text -> Destination)
-> Lens Destination Destination (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Destination' {Maybe Text
targetArn :: Maybe Text
$sel:targetArn:Destination' :: Destination -> Maybe Text
targetArn} -> Maybe Text
targetArn) (\s :: Destination
s@Destination' {} Maybe Text
a -> Destination
s {$sel:targetArn:Destination' :: Maybe Text
targetArn = Maybe Text
a} :: Destination)

-- | The creation time of the destination, expressed as the number of
-- milliseconds after Jan 1, 1970 00:00:00 UTC.
destination_creationTime :: Lens.Lens' Destination (Prelude.Maybe Prelude.Natural)
destination_creationTime :: (Maybe Natural -> f (Maybe Natural))
-> Destination -> f Destination
destination_creationTime = (Destination -> Maybe Natural)
-> (Destination -> Maybe Natural -> Destination)
-> Lens Destination Destination (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Destination' {Maybe Natural
creationTime :: Maybe Natural
$sel:creationTime:Destination' :: Destination -> Maybe Natural
creationTime} -> Maybe Natural
creationTime) (\s :: Destination
s@Destination' {} Maybe Natural
a -> Destination
s {$sel:creationTime:Destination' :: Maybe Natural
creationTime = Maybe Natural
a} :: Destination)

-- | The ARN of this destination.
destination_arn :: Lens.Lens' Destination (Prelude.Maybe Prelude.Text)
destination_arn :: (Maybe Text -> f (Maybe Text)) -> Destination -> f Destination
destination_arn = (Destination -> Maybe Text)
-> (Destination -> Maybe Text -> Destination)
-> Lens Destination Destination (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Destination' {Maybe Text
arn :: Maybe Text
$sel:arn:Destination' :: Destination -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Destination
s@Destination' {} Maybe Text
a -> Destination
s {$sel:arn:Destination' :: Maybe Text
arn = Maybe Text
a} :: Destination)

-- | An IAM policy document that governs which Amazon Web Services accounts
-- can create subscription filters against this destination.
destination_accessPolicy :: Lens.Lens' Destination (Prelude.Maybe Prelude.Text)
destination_accessPolicy :: (Maybe Text -> f (Maybe Text)) -> Destination -> f Destination
destination_accessPolicy = (Destination -> Maybe Text)
-> (Destination -> Maybe Text -> Destination)
-> Lens Destination Destination (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Destination' {Maybe Text
accessPolicy :: Maybe Text
$sel:accessPolicy:Destination' :: Destination -> Maybe Text
accessPolicy} -> Maybe Text
accessPolicy) (\s :: Destination
s@Destination' {} Maybe Text
a -> Destination
s {$sel:accessPolicy:Destination' :: Maybe Text
accessPolicy = Maybe Text
a} :: Destination)

-- | The name of the destination.
destination_destinationName :: Lens.Lens' Destination (Prelude.Maybe Prelude.Text)
destination_destinationName :: (Maybe Text -> f (Maybe Text)) -> Destination -> f Destination
destination_destinationName = (Destination -> Maybe Text)
-> (Destination -> Maybe Text -> Destination)
-> Lens Destination Destination (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Destination' {Maybe Text
destinationName :: Maybe Text
$sel:destinationName:Destination' :: Destination -> Maybe Text
destinationName} -> Maybe Text
destinationName) (\s :: Destination
s@Destination' {} Maybe Text
a -> Destination
s {$sel:destinationName:Destination' :: Maybe Text
destinationName = Maybe Text
a} :: Destination)

-- | A role for impersonation, used when delivering log events to the target.
destination_roleArn :: Lens.Lens' Destination (Prelude.Maybe Prelude.Text)
destination_roleArn :: (Maybe Text -> f (Maybe Text)) -> Destination -> f Destination
destination_roleArn = (Destination -> Maybe Text)
-> (Destination -> Maybe Text -> Destination)
-> Lens Destination Destination (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Destination' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:Destination' :: Destination -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: Destination
s@Destination' {} Maybe Text
a -> Destination
s {$sel:roleArn:Destination' :: Maybe Text
roleArn = Maybe Text
a} :: Destination)

instance Core.FromJSON Destination where
  parseJSON :: Value -> Parser Destination
parseJSON =
    String
-> (Object -> Parser Destination) -> Value -> Parser Destination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Destination"
      ( \Object
x ->
          Maybe Text
-> Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Destination
Destination'
            (Maybe Text
 -> Maybe Natural
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Destination)
-> Parser (Maybe Text)
-> Parser
     (Maybe Natural
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Destination)
forall (f :: * -> *) a b. Functor 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
"targetArn")
            Parser
  (Maybe Natural
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Destination)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> Destination)
forall (f :: * -> *) a b. Applicative f => 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
"creationTime")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> Destination)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Destination)
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
"arn")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Destination)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Destination)
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
"accessPolicy")
            Parser (Maybe Text -> Maybe Text -> Destination)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Destination)
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
"destinationName")
            Parser (Maybe Text -> Destination)
-> Parser (Maybe Text) -> Parser Destination
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
"roleArn")
      )

instance Prelude.Hashable Destination

instance Prelude.NFData Destination