{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudWatchLogs.Types.Destination 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

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

-- | 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 :: Lens' Destination (Maybe Text)
destination_accessPolicy = 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 ARN of this destination.
destination_arn :: Lens.Lens' Destination (Prelude.Maybe Prelude.Text)
destination_arn :: Lens' Destination (Maybe Text)
destination_arn = 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)

-- | 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 :: Lens' Destination (Maybe Natural)
destination_creationTime = 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 name of the destination.
destination_destinationName :: Lens.Lens' Destination (Prelude.Maybe Prelude.Text)
destination_destinationName :: Lens' Destination (Maybe Text)
destination_destinationName = 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 :: Lens' Destination (Maybe Text)
destination_roleArn = 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)

-- | 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 :: Lens' Destination (Maybe Text)
destination_targetArn = 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)

instance Data.FromJSON Destination where
  parseJSON :: Value -> Parser Destination
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Destination"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Destination
Destination'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"accessPolicy")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"creationTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"destinationName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"roleArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"targetArn")
      )

instance Prelude.Hashable Destination where
  hashWithSalt :: Int -> Destination -> Int
hashWithSalt Int
_salt Destination' {Maybe Natural
Maybe Text
targetArn :: Maybe Text
roleArn :: Maybe Text
destinationName :: Maybe Text
creationTime :: Maybe Natural
arn :: Maybe Text
accessPolicy :: Maybe Text
$sel:targetArn:Destination' :: Destination -> Maybe Text
$sel:roleArn:Destination' :: Destination -> Maybe Text
$sel:destinationName:Destination' :: Destination -> Maybe Text
$sel:creationTime:Destination' :: Destination -> Maybe Natural
$sel:arn:Destination' :: Destination -> Maybe Text
$sel:accessPolicy:Destination' :: Destination -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accessPolicy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destinationName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetArn

instance Prelude.NFData Destination where
  rnf :: Destination -> ()
rnf Destination' {Maybe Natural
Maybe Text
targetArn :: Maybe Text
roleArn :: Maybe Text
destinationName :: Maybe Text
creationTime :: Maybe Natural
arn :: Maybe Text
accessPolicy :: Maybe Text
$sel:targetArn:Destination' :: Destination -> Maybe Text
$sel:roleArn:Destination' :: Destination -> Maybe Text
$sel:destinationName:Destination' :: Destination -> Maybe Text
$sel:creationTime:Destination' :: Destination -> Maybe Natural
$sel:arn:Destination' :: Destination -> Maybe Text
$sel:accessPolicy:Destination' :: Destination -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accessPolicy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destinationName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetArn