{-# 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.MediaConnect.Types.Messages
-- 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.MediaConnect.Types.Messages where

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

-- | Messages that provide the state of the flow.
--
-- /See:/ 'newMessages' smart constructor.
data Messages = Messages'
  { -- | A list of errors that might have been generated from processes on this
    -- flow.
    Messages -> [Text]
errors :: [Prelude.Text]
  }
  deriving (Messages -> Messages -> Bool
(Messages -> Messages -> Bool)
-> (Messages -> Messages -> Bool) -> Eq Messages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Messages -> Messages -> Bool
$c/= :: Messages -> Messages -> Bool
== :: Messages -> Messages -> Bool
$c== :: Messages -> Messages -> Bool
Prelude.Eq, ReadPrec [Messages]
ReadPrec Messages
Int -> ReadS Messages
ReadS [Messages]
(Int -> ReadS Messages)
-> ReadS [Messages]
-> ReadPrec Messages
-> ReadPrec [Messages]
-> Read Messages
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Messages]
$creadListPrec :: ReadPrec [Messages]
readPrec :: ReadPrec Messages
$creadPrec :: ReadPrec Messages
readList :: ReadS [Messages]
$creadList :: ReadS [Messages]
readsPrec :: Int -> ReadS Messages
$creadsPrec :: Int -> ReadS Messages
Prelude.Read, Int -> Messages -> ShowS
[Messages] -> ShowS
Messages -> String
(Int -> Messages -> ShowS)
-> (Messages -> String) -> ([Messages] -> ShowS) -> Show Messages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Messages] -> ShowS
$cshowList :: [Messages] -> ShowS
show :: Messages -> String
$cshow :: Messages -> String
showsPrec :: Int -> Messages -> ShowS
$cshowsPrec :: Int -> Messages -> ShowS
Prelude.Show, (forall x. Messages -> Rep Messages x)
-> (forall x. Rep Messages x -> Messages) -> Generic Messages
forall x. Rep Messages x -> Messages
forall x. Messages -> Rep Messages x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Messages x -> Messages
$cfrom :: forall x. Messages -> Rep Messages x
Prelude.Generic)

-- |
-- Create a value of 'Messages' 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:
--
-- 'errors', 'messages_errors' - A list of errors that might have been generated from processes on this
-- flow.
newMessages ::
  Messages
newMessages :: Messages
newMessages = Messages' :: [Text] -> Messages
Messages' {$sel:errors:Messages' :: [Text]
errors = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | A list of errors that might have been generated from processes on this
-- flow.
messages_errors :: Lens.Lens' Messages [Prelude.Text]
messages_errors :: ([Text] -> f [Text]) -> Messages -> f Messages
messages_errors = (Messages -> [Text])
-> (Messages -> [Text] -> Messages)
-> Lens Messages Messages [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Messages' {[Text]
errors :: [Text]
$sel:errors:Messages' :: Messages -> [Text]
errors} -> [Text]
errors) (\s :: Messages
s@Messages' {} [Text]
a -> Messages
s {$sel:errors:Messages' :: [Text]
errors = [Text]
a} :: Messages) (([Text] -> f [Text]) -> Messages -> f Messages)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> Messages
-> f Messages
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Messages where
  parseJSON :: Value -> Parser Messages
parseJSON =
    String -> (Object -> Parser Messages) -> Value -> Parser Messages
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Messages"
      ( \Object
x ->
          [Text] -> Messages
Messages'
            ([Text] -> Messages) -> Parser [Text] -> Parser Messages
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
"errors" Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Messages

instance Prelude.NFData Messages