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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.S3Destination
import qualified Amazonka.Prelude as Prelude

-- | Describes the location of the updated firmware.
--
-- /See:/ 'newDestination' smart constructor.
data Destination = Destination'
  { -- | Describes the location in S3 of the updated firmware.
    Destination -> Maybe S3Destination
s3Destination :: Prelude.Maybe S3Destination
  }
  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:
--
-- 's3Destination', 'destination_s3Destination' - Describes the location in S3 of the updated firmware.
newDestination ::
  Destination
newDestination :: Destination
newDestination =
  Destination' {$sel:s3Destination:Destination' :: Maybe S3Destination
s3Destination = forall a. Maybe a
Prelude.Nothing}

-- | Describes the location in S3 of the updated firmware.
destination_s3Destination :: Lens.Lens' Destination (Prelude.Maybe S3Destination)
destination_s3Destination :: Lens' Destination (Maybe S3Destination)
destination_s3Destination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Destination' {Maybe S3Destination
s3Destination :: Maybe S3Destination
$sel:s3Destination:Destination' :: Destination -> Maybe S3Destination
s3Destination} -> Maybe S3Destination
s3Destination) (\s :: Destination
s@Destination' {} Maybe S3Destination
a -> Destination
s {$sel:s3Destination:Destination' :: Maybe S3Destination
s3Destination = Maybe S3Destination
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 S3Destination -> 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
"s3Destination")
      )

instance Prelude.Hashable Destination where
  hashWithSalt :: Int -> Destination -> Int
hashWithSalt Int
_salt Destination' {Maybe S3Destination
s3Destination :: Maybe S3Destination
$sel:s3Destination:Destination' :: Destination -> Maybe S3Destination
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3Destination
s3Destination

instance Prelude.NFData Destination where
  rnf :: Destination -> ()
rnf Destination' {Maybe S3Destination
s3Destination :: Maybe S3Destination
$sel:s3Destination:Destination' :: Destination -> Maybe S3Destination
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe S3Destination
s3Destination

instance Data.ToJSON Destination where
  toJSON :: Destination -> Value
toJSON Destination' {Maybe S3Destination
s3Destination :: Maybe S3Destination
$sel:s3Destination:Destination' :: Destination -> Maybe S3Destination
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"s3Destination" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3Destination
s3Destination
          ]
      )