{-# 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.LicenseManager.Types.ReceivedMetadata
-- 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.LicenseManager.Types.ReceivedMetadata where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LicenseManager.Types.AllowedOperation
import Amazonka.LicenseManager.Types.ReceivedStatus
import qualified Amazonka.Prelude as Prelude

-- | Metadata associated with received licenses and grants.
--
-- /See:/ 'newReceivedMetadata' smart constructor.
data ReceivedMetadata = ReceivedMetadata'
  { -- | Received status.
    ReceivedMetadata -> Maybe ReceivedStatus
receivedStatus :: Prelude.Maybe ReceivedStatus,
    -- | Allowed operations.
    ReceivedMetadata -> Maybe (NonEmpty AllowedOperation)
allowedOperations :: Prelude.Maybe (Prelude.NonEmpty AllowedOperation),
    -- | Received status reason.
    ReceivedMetadata -> Maybe Text
receivedStatusReason :: Prelude.Maybe Prelude.Text
  }
  deriving (ReceivedMetadata -> ReceivedMetadata -> Bool
(ReceivedMetadata -> ReceivedMetadata -> Bool)
-> (ReceivedMetadata -> ReceivedMetadata -> Bool)
-> Eq ReceivedMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReceivedMetadata -> ReceivedMetadata -> Bool
$c/= :: ReceivedMetadata -> ReceivedMetadata -> Bool
== :: ReceivedMetadata -> ReceivedMetadata -> Bool
$c== :: ReceivedMetadata -> ReceivedMetadata -> Bool
Prelude.Eq, ReadPrec [ReceivedMetadata]
ReadPrec ReceivedMetadata
Int -> ReadS ReceivedMetadata
ReadS [ReceivedMetadata]
(Int -> ReadS ReceivedMetadata)
-> ReadS [ReceivedMetadata]
-> ReadPrec ReceivedMetadata
-> ReadPrec [ReceivedMetadata]
-> Read ReceivedMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReceivedMetadata]
$creadListPrec :: ReadPrec [ReceivedMetadata]
readPrec :: ReadPrec ReceivedMetadata
$creadPrec :: ReadPrec ReceivedMetadata
readList :: ReadS [ReceivedMetadata]
$creadList :: ReadS [ReceivedMetadata]
readsPrec :: Int -> ReadS ReceivedMetadata
$creadsPrec :: Int -> ReadS ReceivedMetadata
Prelude.Read, Int -> ReceivedMetadata -> ShowS
[ReceivedMetadata] -> ShowS
ReceivedMetadata -> String
(Int -> ReceivedMetadata -> ShowS)
-> (ReceivedMetadata -> String)
-> ([ReceivedMetadata] -> ShowS)
-> Show ReceivedMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReceivedMetadata] -> ShowS
$cshowList :: [ReceivedMetadata] -> ShowS
show :: ReceivedMetadata -> String
$cshow :: ReceivedMetadata -> String
showsPrec :: Int -> ReceivedMetadata -> ShowS
$cshowsPrec :: Int -> ReceivedMetadata -> ShowS
Prelude.Show, (forall x. ReceivedMetadata -> Rep ReceivedMetadata x)
-> (forall x. Rep ReceivedMetadata x -> ReceivedMetadata)
-> Generic ReceivedMetadata
forall x. Rep ReceivedMetadata x -> ReceivedMetadata
forall x. ReceivedMetadata -> Rep ReceivedMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReceivedMetadata x -> ReceivedMetadata
$cfrom :: forall x. ReceivedMetadata -> Rep ReceivedMetadata x
Prelude.Generic)

-- |
-- Create a value of 'ReceivedMetadata' 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:
--
-- 'receivedStatus', 'receivedMetadata_receivedStatus' - Received status.
--
-- 'allowedOperations', 'receivedMetadata_allowedOperations' - Allowed operations.
--
-- 'receivedStatusReason', 'receivedMetadata_receivedStatusReason' - Received status reason.
newReceivedMetadata ::
  ReceivedMetadata
newReceivedMetadata :: ReceivedMetadata
newReceivedMetadata =
  ReceivedMetadata' :: Maybe ReceivedStatus
-> Maybe (NonEmpty AllowedOperation)
-> Maybe Text
-> ReceivedMetadata
ReceivedMetadata'
    { $sel:receivedStatus:ReceivedMetadata' :: Maybe ReceivedStatus
receivedStatus = Maybe ReceivedStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:allowedOperations:ReceivedMetadata' :: Maybe (NonEmpty AllowedOperation)
allowedOperations = Maybe (NonEmpty AllowedOperation)
forall a. Maybe a
Prelude.Nothing,
      $sel:receivedStatusReason:ReceivedMetadata' :: Maybe Text
receivedStatusReason = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Received status.
receivedMetadata_receivedStatus :: Lens.Lens' ReceivedMetadata (Prelude.Maybe ReceivedStatus)
receivedMetadata_receivedStatus :: (Maybe ReceivedStatus -> f (Maybe ReceivedStatus))
-> ReceivedMetadata -> f ReceivedMetadata
receivedMetadata_receivedStatus = (ReceivedMetadata -> Maybe ReceivedStatus)
-> (ReceivedMetadata -> Maybe ReceivedStatus -> ReceivedMetadata)
-> Lens
     ReceivedMetadata
     ReceivedMetadata
     (Maybe ReceivedStatus)
     (Maybe ReceivedStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReceivedMetadata' {Maybe ReceivedStatus
receivedStatus :: Maybe ReceivedStatus
$sel:receivedStatus:ReceivedMetadata' :: ReceivedMetadata -> Maybe ReceivedStatus
receivedStatus} -> Maybe ReceivedStatus
receivedStatus) (\s :: ReceivedMetadata
s@ReceivedMetadata' {} Maybe ReceivedStatus
a -> ReceivedMetadata
s {$sel:receivedStatus:ReceivedMetadata' :: Maybe ReceivedStatus
receivedStatus = Maybe ReceivedStatus
a} :: ReceivedMetadata)

-- | Allowed operations.
receivedMetadata_allowedOperations :: Lens.Lens' ReceivedMetadata (Prelude.Maybe (Prelude.NonEmpty AllowedOperation))
receivedMetadata_allowedOperations :: (Maybe (NonEmpty AllowedOperation)
 -> f (Maybe (NonEmpty AllowedOperation)))
-> ReceivedMetadata -> f ReceivedMetadata
receivedMetadata_allowedOperations = (ReceivedMetadata -> Maybe (NonEmpty AllowedOperation))
-> (ReceivedMetadata
    -> Maybe (NonEmpty AllowedOperation) -> ReceivedMetadata)
-> Lens
     ReceivedMetadata
     ReceivedMetadata
     (Maybe (NonEmpty AllowedOperation))
     (Maybe (NonEmpty AllowedOperation))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReceivedMetadata' {Maybe (NonEmpty AllowedOperation)
allowedOperations :: Maybe (NonEmpty AllowedOperation)
$sel:allowedOperations:ReceivedMetadata' :: ReceivedMetadata -> Maybe (NonEmpty AllowedOperation)
allowedOperations} -> Maybe (NonEmpty AllowedOperation)
allowedOperations) (\s :: ReceivedMetadata
s@ReceivedMetadata' {} Maybe (NonEmpty AllowedOperation)
a -> ReceivedMetadata
s {$sel:allowedOperations:ReceivedMetadata' :: Maybe (NonEmpty AllowedOperation)
allowedOperations = Maybe (NonEmpty AllowedOperation)
a} :: ReceivedMetadata) ((Maybe (NonEmpty AllowedOperation)
  -> f (Maybe (NonEmpty AllowedOperation)))
 -> ReceivedMetadata -> f ReceivedMetadata)
-> ((Maybe (NonEmpty AllowedOperation)
     -> f (Maybe (NonEmpty AllowedOperation)))
    -> Maybe (NonEmpty AllowedOperation)
    -> f (Maybe (NonEmpty AllowedOperation)))
-> (Maybe (NonEmpty AllowedOperation)
    -> f (Maybe (NonEmpty AllowedOperation)))
-> ReceivedMetadata
-> f ReceivedMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty AllowedOperation)
  (NonEmpty AllowedOperation)
  (NonEmpty AllowedOperation)
  (NonEmpty AllowedOperation)
-> Iso
     (Maybe (NonEmpty AllowedOperation))
     (Maybe (NonEmpty AllowedOperation))
     (Maybe (NonEmpty AllowedOperation))
     (Maybe (NonEmpty AllowedOperation))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty AllowedOperation)
  (NonEmpty AllowedOperation)
  (NonEmpty AllowedOperation)
  (NonEmpty AllowedOperation)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Received status reason.
receivedMetadata_receivedStatusReason :: Lens.Lens' ReceivedMetadata (Prelude.Maybe Prelude.Text)
receivedMetadata_receivedStatusReason :: (Maybe Text -> f (Maybe Text))
-> ReceivedMetadata -> f ReceivedMetadata
receivedMetadata_receivedStatusReason = (ReceivedMetadata -> Maybe Text)
-> (ReceivedMetadata -> Maybe Text -> ReceivedMetadata)
-> Lens ReceivedMetadata ReceivedMetadata (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReceivedMetadata' {Maybe Text
receivedStatusReason :: Maybe Text
$sel:receivedStatusReason:ReceivedMetadata' :: ReceivedMetadata -> Maybe Text
receivedStatusReason} -> Maybe Text
receivedStatusReason) (\s :: ReceivedMetadata
s@ReceivedMetadata' {} Maybe Text
a -> ReceivedMetadata
s {$sel:receivedStatusReason:ReceivedMetadata' :: Maybe Text
receivedStatusReason = Maybe Text
a} :: ReceivedMetadata)

instance Core.FromJSON ReceivedMetadata where
  parseJSON :: Value -> Parser ReceivedMetadata
parseJSON =
    String
-> (Object -> Parser ReceivedMetadata)
-> Value
-> Parser ReceivedMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReceivedMetadata"
      ( \Object
x ->
          Maybe ReceivedStatus
-> Maybe (NonEmpty AllowedOperation)
-> Maybe Text
-> ReceivedMetadata
ReceivedMetadata'
            (Maybe ReceivedStatus
 -> Maybe (NonEmpty AllowedOperation)
 -> Maybe Text
 -> ReceivedMetadata)
-> Parser (Maybe ReceivedStatus)
-> Parser
     (Maybe (NonEmpty AllowedOperation)
      -> Maybe Text -> ReceivedMetadata)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ReceivedStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReceivedStatus")
            Parser
  (Maybe (NonEmpty AllowedOperation)
   -> Maybe Text -> ReceivedMetadata)
-> Parser (Maybe (NonEmpty AllowedOperation))
-> Parser (Maybe Text -> ReceivedMetadata)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty AllowedOperation))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AllowedOperations")
            Parser (Maybe Text -> ReceivedMetadata)
-> Parser (Maybe Text) -> Parser ReceivedMetadata
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
"ReceivedStatusReason")
      )

instance Prelude.Hashable ReceivedMetadata

instance Prelude.NFData ReceivedMetadata