{-# 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.Grant
-- 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.Grant where

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

-- | Describes a grant.
--
-- /See:/ 'newGrant' smart constructor.
data Grant = Grant'
  { -- | Grant status reason.
    Grant -> Maybe Text
statusReason :: Prelude.Maybe Prelude.Text,
    -- | Amazon Resource Name (ARN) of the grant.
    Grant -> Text
grantArn :: Prelude.Text,
    -- | Grant name.
    Grant -> Text
grantName :: Prelude.Text,
    -- | Parent ARN.
    Grant -> Text
parentArn :: Prelude.Text,
    -- | License ARN.
    Grant -> Text
licenseArn :: Prelude.Text,
    -- | The grantee principal ARN.
    Grant -> Text
granteePrincipalArn :: Prelude.Text,
    -- | Home Region of the grant.
    Grant -> Text
homeRegion :: Prelude.Text,
    -- | Grant status.
    Grant -> GrantStatus
grantStatus :: GrantStatus,
    -- | Grant version.
    Grant -> Text
version :: Prelude.Text,
    -- | Granted operations.
    Grant -> NonEmpty AllowedOperation
grantedOperations :: Prelude.NonEmpty AllowedOperation
  }
  deriving (Grant -> Grant -> Bool
(Grant -> Grant -> Bool) -> (Grant -> Grant -> Bool) -> Eq Grant
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Grant -> Grant -> Bool
$c/= :: Grant -> Grant -> Bool
== :: Grant -> Grant -> Bool
$c== :: Grant -> Grant -> Bool
Prelude.Eq, ReadPrec [Grant]
ReadPrec Grant
Int -> ReadS Grant
ReadS [Grant]
(Int -> ReadS Grant)
-> ReadS [Grant]
-> ReadPrec Grant
-> ReadPrec [Grant]
-> Read Grant
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Grant]
$creadListPrec :: ReadPrec [Grant]
readPrec :: ReadPrec Grant
$creadPrec :: ReadPrec Grant
readList :: ReadS [Grant]
$creadList :: ReadS [Grant]
readsPrec :: Int -> ReadS Grant
$creadsPrec :: Int -> ReadS Grant
Prelude.Read, Int -> Grant -> ShowS
[Grant] -> ShowS
Grant -> String
(Int -> Grant -> ShowS)
-> (Grant -> String) -> ([Grant] -> ShowS) -> Show Grant
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Grant] -> ShowS
$cshowList :: [Grant] -> ShowS
show :: Grant -> String
$cshow :: Grant -> String
showsPrec :: Int -> Grant -> ShowS
$cshowsPrec :: Int -> Grant -> ShowS
Prelude.Show, (forall x. Grant -> Rep Grant x)
-> (forall x. Rep Grant x -> Grant) -> Generic Grant
forall x. Rep Grant x -> Grant
forall x. Grant -> Rep Grant x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Grant x -> Grant
$cfrom :: forall x. Grant -> Rep Grant x
Prelude.Generic)

-- |
-- Create a value of 'Grant' 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:
--
-- 'statusReason', 'grant_statusReason' - Grant status reason.
--
-- 'grantArn', 'grant_grantArn' - Amazon Resource Name (ARN) of the grant.
--
-- 'grantName', 'grant_grantName' - Grant name.
--
-- 'parentArn', 'grant_parentArn' - Parent ARN.
--
-- 'licenseArn', 'grant_licenseArn' - License ARN.
--
-- 'granteePrincipalArn', 'grant_granteePrincipalArn' - The grantee principal ARN.
--
-- 'homeRegion', 'grant_homeRegion' - Home Region of the grant.
--
-- 'grantStatus', 'grant_grantStatus' - Grant status.
--
-- 'version', 'grant_version' - Grant version.
--
-- 'grantedOperations', 'grant_grantedOperations' - Granted operations.
newGrant ::
  -- | 'grantArn'
  Prelude.Text ->
  -- | 'grantName'
  Prelude.Text ->
  -- | 'parentArn'
  Prelude.Text ->
  -- | 'licenseArn'
  Prelude.Text ->
  -- | 'granteePrincipalArn'
  Prelude.Text ->
  -- | 'homeRegion'
  Prelude.Text ->
  -- | 'grantStatus'
  GrantStatus ->
  -- | 'version'
  Prelude.Text ->
  -- | 'grantedOperations'
  Prelude.NonEmpty AllowedOperation ->
  Grant
newGrant :: Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> GrantStatus
-> Text
-> NonEmpty AllowedOperation
-> Grant
newGrant
  Text
pGrantArn_
  Text
pGrantName_
  Text
pParentArn_
  Text
pLicenseArn_
  Text
pGranteePrincipalArn_
  Text
pHomeRegion_
  GrantStatus
pGrantStatus_
  Text
pVersion_
  NonEmpty AllowedOperation
pGrantedOperations_ =
    Grant' :: Maybe Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> GrantStatus
-> Text
-> NonEmpty AllowedOperation
-> Grant
Grant'
      { $sel:statusReason:Grant' :: Maybe Text
statusReason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:grantArn:Grant' :: Text
grantArn = Text
pGrantArn_,
        $sel:grantName:Grant' :: Text
grantName = Text
pGrantName_,
        $sel:parentArn:Grant' :: Text
parentArn = Text
pParentArn_,
        $sel:licenseArn:Grant' :: Text
licenseArn = Text
pLicenseArn_,
        $sel:granteePrincipalArn:Grant' :: Text
granteePrincipalArn = Text
pGranteePrincipalArn_,
        $sel:homeRegion:Grant' :: Text
homeRegion = Text
pHomeRegion_,
        $sel:grantStatus:Grant' :: GrantStatus
grantStatus = GrantStatus
pGrantStatus_,
        $sel:version:Grant' :: Text
version = Text
pVersion_,
        $sel:grantedOperations:Grant' :: NonEmpty AllowedOperation
grantedOperations =
          Tagged
  (NonEmpty AllowedOperation) (Identity (NonEmpty AllowedOperation))
-> Tagged
     (NonEmpty AllowedOperation) (Identity (NonEmpty AllowedOperation))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty AllowedOperation) (Identity (NonEmpty AllowedOperation))
 -> Tagged
      (NonEmpty AllowedOperation) (Identity (NonEmpty AllowedOperation)))
-> NonEmpty AllowedOperation -> NonEmpty AllowedOperation
forall t b. AReview t b -> b -> t
Lens.# NonEmpty AllowedOperation
pGrantedOperations_
      }

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

-- | Amazon Resource Name (ARN) of the grant.
grant_grantArn :: Lens.Lens' Grant Prelude.Text
grant_grantArn :: (Text -> f Text) -> Grant -> f Grant
grant_grantArn = (Grant -> Text)
-> (Grant -> Text -> Grant) -> Lens Grant Grant Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grant' {Text
grantArn :: Text
$sel:grantArn:Grant' :: Grant -> Text
grantArn} -> Text
grantArn) (\s :: Grant
s@Grant' {} Text
a -> Grant
s {$sel:grantArn:Grant' :: Text
grantArn = Text
a} :: Grant)

-- | Grant name.
grant_grantName :: Lens.Lens' Grant Prelude.Text
grant_grantName :: (Text -> f Text) -> Grant -> f Grant
grant_grantName = (Grant -> Text)
-> (Grant -> Text -> Grant) -> Lens Grant Grant Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grant' {Text
grantName :: Text
$sel:grantName:Grant' :: Grant -> Text
grantName} -> Text
grantName) (\s :: Grant
s@Grant' {} Text
a -> Grant
s {$sel:grantName:Grant' :: Text
grantName = Text
a} :: Grant)

-- | Parent ARN.
grant_parentArn :: Lens.Lens' Grant Prelude.Text
grant_parentArn :: (Text -> f Text) -> Grant -> f Grant
grant_parentArn = (Grant -> Text)
-> (Grant -> Text -> Grant) -> Lens Grant Grant Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grant' {Text
parentArn :: Text
$sel:parentArn:Grant' :: Grant -> Text
parentArn} -> Text
parentArn) (\s :: Grant
s@Grant' {} Text
a -> Grant
s {$sel:parentArn:Grant' :: Text
parentArn = Text
a} :: Grant)

-- | License ARN.
grant_licenseArn :: Lens.Lens' Grant Prelude.Text
grant_licenseArn :: (Text -> f Text) -> Grant -> f Grant
grant_licenseArn = (Grant -> Text)
-> (Grant -> Text -> Grant) -> Lens Grant Grant Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grant' {Text
licenseArn :: Text
$sel:licenseArn:Grant' :: Grant -> Text
licenseArn} -> Text
licenseArn) (\s :: Grant
s@Grant' {} Text
a -> Grant
s {$sel:licenseArn:Grant' :: Text
licenseArn = Text
a} :: Grant)

-- | The grantee principal ARN.
grant_granteePrincipalArn :: Lens.Lens' Grant Prelude.Text
grant_granteePrincipalArn :: (Text -> f Text) -> Grant -> f Grant
grant_granteePrincipalArn = (Grant -> Text)
-> (Grant -> Text -> Grant) -> Lens Grant Grant Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grant' {Text
granteePrincipalArn :: Text
$sel:granteePrincipalArn:Grant' :: Grant -> Text
granteePrincipalArn} -> Text
granteePrincipalArn) (\s :: Grant
s@Grant' {} Text
a -> Grant
s {$sel:granteePrincipalArn:Grant' :: Text
granteePrincipalArn = Text
a} :: Grant)

-- | Home Region of the grant.
grant_homeRegion :: Lens.Lens' Grant Prelude.Text
grant_homeRegion :: (Text -> f Text) -> Grant -> f Grant
grant_homeRegion = (Grant -> Text)
-> (Grant -> Text -> Grant) -> Lens Grant Grant Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grant' {Text
homeRegion :: Text
$sel:homeRegion:Grant' :: Grant -> Text
homeRegion} -> Text
homeRegion) (\s :: Grant
s@Grant' {} Text
a -> Grant
s {$sel:homeRegion:Grant' :: Text
homeRegion = Text
a} :: Grant)

-- | Grant status.
grant_grantStatus :: Lens.Lens' Grant GrantStatus
grant_grantStatus :: (GrantStatus -> f GrantStatus) -> Grant -> f Grant
grant_grantStatus = (Grant -> GrantStatus)
-> (Grant -> GrantStatus -> Grant)
-> Lens Grant Grant GrantStatus GrantStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grant' {GrantStatus
grantStatus :: GrantStatus
$sel:grantStatus:Grant' :: Grant -> GrantStatus
grantStatus} -> GrantStatus
grantStatus) (\s :: Grant
s@Grant' {} GrantStatus
a -> Grant
s {$sel:grantStatus:Grant' :: GrantStatus
grantStatus = GrantStatus
a} :: Grant)

-- | Grant version.
grant_version :: Lens.Lens' Grant Prelude.Text
grant_version :: (Text -> f Text) -> Grant -> f Grant
grant_version = (Grant -> Text)
-> (Grant -> Text -> Grant) -> Lens Grant Grant Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grant' {Text
version :: Text
$sel:version:Grant' :: Grant -> Text
version} -> Text
version) (\s :: Grant
s@Grant' {} Text
a -> Grant
s {$sel:version:Grant' :: Text
version = Text
a} :: Grant)

-- | Granted operations.
grant_grantedOperations :: Lens.Lens' Grant (Prelude.NonEmpty AllowedOperation)
grant_grantedOperations :: (NonEmpty AllowedOperation -> f (NonEmpty AllowedOperation))
-> Grant -> f Grant
grant_grantedOperations = (Grant -> NonEmpty AllowedOperation)
-> (Grant -> NonEmpty AllowedOperation -> Grant)
-> Lens
     Grant Grant (NonEmpty AllowedOperation) (NonEmpty AllowedOperation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grant' {NonEmpty AllowedOperation
grantedOperations :: NonEmpty AllowedOperation
$sel:grantedOperations:Grant' :: Grant -> NonEmpty AllowedOperation
grantedOperations} -> NonEmpty AllowedOperation
grantedOperations) (\s :: Grant
s@Grant' {} NonEmpty AllowedOperation
a -> Grant
s {$sel:grantedOperations:Grant' :: NonEmpty AllowedOperation
grantedOperations = NonEmpty AllowedOperation
a} :: Grant) ((NonEmpty AllowedOperation -> f (NonEmpty AllowedOperation))
 -> Grant -> f Grant)
-> ((NonEmpty AllowedOperation -> f (NonEmpty AllowedOperation))
    -> NonEmpty AllowedOperation -> f (NonEmpty AllowedOperation))
-> (NonEmpty AllowedOperation -> f (NonEmpty AllowedOperation))
-> Grant
-> f Grant
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty AllowedOperation -> f (NonEmpty AllowedOperation))
-> NonEmpty AllowedOperation -> f (NonEmpty AllowedOperation)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Grant where
  parseJSON :: Value -> Parser Grant
parseJSON =
    String -> (Object -> Parser Grant) -> Value -> Parser Grant
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Grant"
      ( \Object
x ->
          Maybe Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> GrantStatus
-> Text
-> NonEmpty AllowedOperation
-> Grant
Grant'
            (Maybe Text
 -> Text
 -> Text
 -> Text
 -> Text
 -> Text
 -> Text
 -> GrantStatus
 -> Text
 -> NonEmpty AllowedOperation
 -> Grant)
-> Parser (Maybe Text)
-> Parser
     (Text
      -> Text
      -> Text
      -> Text
      -> Text
      -> Text
      -> GrantStatus
      -> Text
      -> NonEmpty AllowedOperation
      -> Grant)
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
"StatusReason")
            Parser
  (Text
   -> Text
   -> Text
   -> Text
   -> Text
   -> Text
   -> GrantStatus
   -> Text
   -> NonEmpty AllowedOperation
   -> Grant)
-> Parser Text
-> Parser
     (Text
      -> Text
      -> Text
      -> Text
      -> Text
      -> GrantStatus
      -> Text
      -> NonEmpty AllowedOperation
      -> Grant)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"GrantArn")
            Parser
  (Text
   -> Text
   -> Text
   -> Text
   -> Text
   -> GrantStatus
   -> Text
   -> NonEmpty AllowedOperation
   -> Grant)
-> Parser Text
-> Parser
     (Text
      -> Text
      -> Text
      -> Text
      -> GrantStatus
      -> Text
      -> NonEmpty AllowedOperation
      -> Grant)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"GrantName")
            Parser
  (Text
   -> Text
   -> Text
   -> Text
   -> GrantStatus
   -> Text
   -> NonEmpty AllowedOperation
   -> Grant)
-> Parser Text
-> Parser
     (Text
      -> Text
      -> Text
      -> GrantStatus
      -> Text
      -> NonEmpty AllowedOperation
      -> Grant)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ParentArn")
            Parser
  (Text
   -> Text
   -> Text
   -> GrantStatus
   -> Text
   -> NonEmpty AllowedOperation
   -> Grant)
-> Parser Text
-> Parser
     (Text
      -> Text
      -> GrantStatus
      -> Text
      -> NonEmpty AllowedOperation
      -> Grant)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"LicenseArn")
            Parser
  (Text
   -> Text
   -> GrantStatus
   -> Text
   -> NonEmpty AllowedOperation
   -> Grant)
-> Parser Text
-> Parser
     (Text -> GrantStatus -> Text -> NonEmpty AllowedOperation -> Grant)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"GranteePrincipalArn")
            Parser
  (Text -> GrantStatus -> Text -> NonEmpty AllowedOperation -> Grant)
-> Parser Text
-> Parser
     (GrantStatus -> Text -> NonEmpty AllowedOperation -> Grant)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"HomeRegion")
            Parser (GrantStatus -> Text -> NonEmpty AllowedOperation -> Grant)
-> Parser GrantStatus
-> Parser (Text -> NonEmpty AllowedOperation -> Grant)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser GrantStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"GrantStatus")
            Parser (Text -> NonEmpty AllowedOperation -> Grant)
-> Parser Text -> Parser (NonEmpty AllowedOperation -> Grant)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Version")
            Parser (NonEmpty AllowedOperation -> Grant)
-> Parser (NonEmpty AllowedOperation) -> Parser Grant
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty AllowedOperation)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"GrantedOperations")
      )

instance Prelude.Hashable Grant

instance Prelude.NFData Grant