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

import Amazonka.CloudTrail.Types.DestinationType
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

-- | Contains information about the service where CloudTrail delivers events.
--
-- /See:/ 'newDestination' smart constructor.
data Destination = Destination'
  { -- | The type of destination for events arriving from a channel. For
    -- service-linked channels, the value is @AWS_SERVICE@.
    Destination -> DestinationType
type' :: DestinationType,
    -- | For service-linked channels, the value is the name of the Amazon Web
    -- Services service.
    Destination -> Text
location :: 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:
--
-- 'type'', 'destination_type' - The type of destination for events arriving from a channel. For
-- service-linked channels, the value is @AWS_SERVICE@.
--
-- 'location', 'destination_location' - For service-linked channels, the value is the name of the Amazon Web
-- Services service.
newDestination ::
  -- | 'type''
  DestinationType ->
  -- | 'location'
  Prelude.Text ->
  Destination
newDestination :: DestinationType -> Text -> Destination
newDestination DestinationType
pType_ Text
pLocation_ =
  Destination' {$sel:type':Destination' :: DestinationType
type' = DestinationType
pType_, $sel:location:Destination' :: Text
location = Text
pLocation_}

-- | The type of destination for events arriving from a channel. For
-- service-linked channels, the value is @AWS_SERVICE@.
destination_type :: Lens.Lens' Destination DestinationType
destination_type :: Lens' Destination DestinationType
destination_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Destination' {DestinationType
type' :: DestinationType
$sel:type':Destination' :: Destination -> DestinationType
type'} -> DestinationType
type') (\s :: Destination
s@Destination' {} DestinationType
a -> Destination
s {$sel:type':Destination' :: DestinationType
type' = DestinationType
a} :: Destination)

-- | For service-linked channels, the value is the name of the Amazon Web
-- Services service.
destination_location :: Lens.Lens' Destination Prelude.Text
destination_location :: Lens' Destination Text
destination_location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Destination' {Text
location :: Text
$sel:location:Destination' :: Destination -> Text
location} -> Text
location) (\s :: Destination
s@Destination' {} Text
a -> Destination
s {$sel:location:Destination' :: Text
location = 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 ->
          DestinationType -> 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 a
Data..: Key
"Type")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Location")
      )

instance Prelude.Hashable Destination where
  hashWithSalt :: Int -> Destination -> Int
hashWithSalt Int
_salt Destination' {Text
DestinationType
location :: Text
type' :: DestinationType
$sel:location:Destination' :: Destination -> Text
$sel:type':Destination' :: Destination -> DestinationType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DestinationType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
location

instance Prelude.NFData Destination where
  rnf :: Destination -> ()
rnf Destination' {Text
DestinationType
location :: Text
type' :: DestinationType
$sel:location:Destination' :: Destination -> Text
$sel:type':Destination' :: Destination -> DestinationType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf DestinationType
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
location