{-# 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.ServiceCatalog.Types.PortfolioShareDetail
-- 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.ServiceCatalog.Types.PortfolioShareDetail where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.ServiceCatalog.Types.DescribePortfolioShareType

-- | Information about the portfolio share.
--
-- /See:/ 'newPortfolioShareDetail' smart constructor.
data PortfolioShareDetail = PortfolioShareDetail'
  { -- | The identifier of the recipient entity that received the portfolio
    -- share. The recipient entities can be one of the following:
    --
    -- 1. An external account.
    --
    -- 2. An organziation member account.
    --
    -- 3. An organzational unit (OU).
    --
    -- 4. The organization itself. (This shares with every account in the
    -- organization).
    PortfolioShareDetail -> Maybe Text
principalId :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether TagOptions sharing is enabled or disabled for the
    -- portfolio share.
    PortfolioShareDetail -> Maybe Bool
shareTagOptions :: Prelude.Maybe Prelude.Bool,
    -- | The type of the portfolio share.
    PortfolioShareDetail -> Maybe DescribePortfolioShareType
type' :: Prelude.Maybe DescribePortfolioShareType,
    -- | Indicates whether the shared portfolio is imported by the recipient
    -- account. If the recipient is in an organization node, the share is
    -- automatically imported, and the field is always set to true.
    PortfolioShareDetail -> Maybe Bool
accepted :: Prelude.Maybe Prelude.Bool
  }
  deriving (PortfolioShareDetail -> PortfolioShareDetail -> Bool
(PortfolioShareDetail -> PortfolioShareDetail -> Bool)
-> (PortfolioShareDetail -> PortfolioShareDetail -> Bool)
-> Eq PortfolioShareDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortfolioShareDetail -> PortfolioShareDetail -> Bool
$c/= :: PortfolioShareDetail -> PortfolioShareDetail -> Bool
== :: PortfolioShareDetail -> PortfolioShareDetail -> Bool
$c== :: PortfolioShareDetail -> PortfolioShareDetail -> Bool
Prelude.Eq, ReadPrec [PortfolioShareDetail]
ReadPrec PortfolioShareDetail
Int -> ReadS PortfolioShareDetail
ReadS [PortfolioShareDetail]
(Int -> ReadS PortfolioShareDetail)
-> ReadS [PortfolioShareDetail]
-> ReadPrec PortfolioShareDetail
-> ReadPrec [PortfolioShareDetail]
-> Read PortfolioShareDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PortfolioShareDetail]
$creadListPrec :: ReadPrec [PortfolioShareDetail]
readPrec :: ReadPrec PortfolioShareDetail
$creadPrec :: ReadPrec PortfolioShareDetail
readList :: ReadS [PortfolioShareDetail]
$creadList :: ReadS [PortfolioShareDetail]
readsPrec :: Int -> ReadS PortfolioShareDetail
$creadsPrec :: Int -> ReadS PortfolioShareDetail
Prelude.Read, Int -> PortfolioShareDetail -> ShowS
[PortfolioShareDetail] -> ShowS
PortfolioShareDetail -> String
(Int -> PortfolioShareDetail -> ShowS)
-> (PortfolioShareDetail -> String)
-> ([PortfolioShareDetail] -> ShowS)
-> Show PortfolioShareDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortfolioShareDetail] -> ShowS
$cshowList :: [PortfolioShareDetail] -> ShowS
show :: PortfolioShareDetail -> String
$cshow :: PortfolioShareDetail -> String
showsPrec :: Int -> PortfolioShareDetail -> ShowS
$cshowsPrec :: Int -> PortfolioShareDetail -> ShowS
Prelude.Show, (forall x. PortfolioShareDetail -> Rep PortfolioShareDetail x)
-> (forall x. Rep PortfolioShareDetail x -> PortfolioShareDetail)
-> Generic PortfolioShareDetail
forall x. Rep PortfolioShareDetail x -> PortfolioShareDetail
forall x. PortfolioShareDetail -> Rep PortfolioShareDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PortfolioShareDetail x -> PortfolioShareDetail
$cfrom :: forall x. PortfolioShareDetail -> Rep PortfolioShareDetail x
Prelude.Generic)

-- |
-- Create a value of 'PortfolioShareDetail' 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:
--
-- 'principalId', 'portfolioShareDetail_principalId' - The identifier of the recipient entity that received the portfolio
-- share. The recipient entities can be one of the following:
--
-- 1. An external account.
--
-- 2. An organziation member account.
--
-- 3. An organzational unit (OU).
--
-- 4. The organization itself. (This shares with every account in the
-- organization).
--
-- 'shareTagOptions', 'portfolioShareDetail_shareTagOptions' - Indicates whether TagOptions sharing is enabled or disabled for the
-- portfolio share.
--
-- 'type'', 'portfolioShareDetail_type' - The type of the portfolio share.
--
-- 'accepted', 'portfolioShareDetail_accepted' - Indicates whether the shared portfolio is imported by the recipient
-- account. If the recipient is in an organization node, the share is
-- automatically imported, and the field is always set to true.
newPortfolioShareDetail ::
  PortfolioShareDetail
newPortfolioShareDetail :: PortfolioShareDetail
newPortfolioShareDetail =
  PortfolioShareDetail' :: Maybe Text
-> Maybe Bool
-> Maybe DescribePortfolioShareType
-> Maybe Bool
-> PortfolioShareDetail
PortfolioShareDetail'
    { $sel:principalId:PortfolioShareDetail' :: Maybe Text
principalId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:shareTagOptions:PortfolioShareDetail' :: Maybe Bool
shareTagOptions = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:type':PortfolioShareDetail' :: Maybe DescribePortfolioShareType
type' = Maybe DescribePortfolioShareType
forall a. Maybe a
Prelude.Nothing,
      $sel:accepted:PortfolioShareDetail' :: Maybe Bool
accepted = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the recipient entity that received the portfolio
-- share. The recipient entities can be one of the following:
--
-- 1. An external account.
--
-- 2. An organziation member account.
--
-- 3. An organzational unit (OU).
--
-- 4. The organization itself. (This shares with every account in the
-- organization).
portfolioShareDetail_principalId :: Lens.Lens' PortfolioShareDetail (Prelude.Maybe Prelude.Text)
portfolioShareDetail_principalId :: (Maybe Text -> f (Maybe Text))
-> PortfolioShareDetail -> f PortfolioShareDetail
portfolioShareDetail_principalId = (PortfolioShareDetail -> Maybe Text)
-> (PortfolioShareDetail -> Maybe Text -> PortfolioShareDetail)
-> Lens
     PortfolioShareDetail PortfolioShareDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortfolioShareDetail' {Maybe Text
principalId :: Maybe Text
$sel:principalId:PortfolioShareDetail' :: PortfolioShareDetail -> Maybe Text
principalId} -> Maybe Text
principalId) (\s :: PortfolioShareDetail
s@PortfolioShareDetail' {} Maybe Text
a -> PortfolioShareDetail
s {$sel:principalId:PortfolioShareDetail' :: Maybe Text
principalId = Maybe Text
a} :: PortfolioShareDetail)

-- | Indicates whether TagOptions sharing is enabled or disabled for the
-- portfolio share.
portfolioShareDetail_shareTagOptions :: Lens.Lens' PortfolioShareDetail (Prelude.Maybe Prelude.Bool)
portfolioShareDetail_shareTagOptions :: (Maybe Bool -> f (Maybe Bool))
-> PortfolioShareDetail -> f PortfolioShareDetail
portfolioShareDetail_shareTagOptions = (PortfolioShareDetail -> Maybe Bool)
-> (PortfolioShareDetail -> Maybe Bool -> PortfolioShareDetail)
-> Lens
     PortfolioShareDetail PortfolioShareDetail (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortfolioShareDetail' {Maybe Bool
shareTagOptions :: Maybe Bool
$sel:shareTagOptions:PortfolioShareDetail' :: PortfolioShareDetail -> Maybe Bool
shareTagOptions} -> Maybe Bool
shareTagOptions) (\s :: PortfolioShareDetail
s@PortfolioShareDetail' {} Maybe Bool
a -> PortfolioShareDetail
s {$sel:shareTagOptions:PortfolioShareDetail' :: Maybe Bool
shareTagOptions = Maybe Bool
a} :: PortfolioShareDetail)

-- | The type of the portfolio share.
portfolioShareDetail_type :: Lens.Lens' PortfolioShareDetail (Prelude.Maybe DescribePortfolioShareType)
portfolioShareDetail_type :: (Maybe DescribePortfolioShareType
 -> f (Maybe DescribePortfolioShareType))
-> PortfolioShareDetail -> f PortfolioShareDetail
portfolioShareDetail_type = (PortfolioShareDetail -> Maybe DescribePortfolioShareType)
-> (PortfolioShareDetail
    -> Maybe DescribePortfolioShareType -> PortfolioShareDetail)
-> Lens
     PortfolioShareDetail
     PortfolioShareDetail
     (Maybe DescribePortfolioShareType)
     (Maybe DescribePortfolioShareType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortfolioShareDetail' {Maybe DescribePortfolioShareType
type' :: Maybe DescribePortfolioShareType
$sel:type':PortfolioShareDetail' :: PortfolioShareDetail -> Maybe DescribePortfolioShareType
type'} -> Maybe DescribePortfolioShareType
type') (\s :: PortfolioShareDetail
s@PortfolioShareDetail' {} Maybe DescribePortfolioShareType
a -> PortfolioShareDetail
s {$sel:type':PortfolioShareDetail' :: Maybe DescribePortfolioShareType
type' = Maybe DescribePortfolioShareType
a} :: PortfolioShareDetail)

-- | Indicates whether the shared portfolio is imported by the recipient
-- account. If the recipient is in an organization node, the share is
-- automatically imported, and the field is always set to true.
portfolioShareDetail_accepted :: Lens.Lens' PortfolioShareDetail (Prelude.Maybe Prelude.Bool)
portfolioShareDetail_accepted :: (Maybe Bool -> f (Maybe Bool))
-> PortfolioShareDetail -> f PortfolioShareDetail
portfolioShareDetail_accepted = (PortfolioShareDetail -> Maybe Bool)
-> (PortfolioShareDetail -> Maybe Bool -> PortfolioShareDetail)
-> Lens
     PortfolioShareDetail PortfolioShareDetail (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortfolioShareDetail' {Maybe Bool
accepted :: Maybe Bool
$sel:accepted:PortfolioShareDetail' :: PortfolioShareDetail -> Maybe Bool
accepted} -> Maybe Bool
accepted) (\s :: PortfolioShareDetail
s@PortfolioShareDetail' {} Maybe Bool
a -> PortfolioShareDetail
s {$sel:accepted:PortfolioShareDetail' :: Maybe Bool
accepted = Maybe Bool
a} :: PortfolioShareDetail)

instance Core.FromJSON PortfolioShareDetail where
  parseJSON :: Value -> Parser PortfolioShareDetail
parseJSON =
    String
-> (Object -> Parser PortfolioShareDetail)
-> Value
-> Parser PortfolioShareDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PortfolioShareDetail"
      ( \Object
x ->
          Maybe Text
-> Maybe Bool
-> Maybe DescribePortfolioShareType
-> Maybe Bool
-> PortfolioShareDetail
PortfolioShareDetail'
            (Maybe Text
 -> Maybe Bool
 -> Maybe DescribePortfolioShareType
 -> Maybe Bool
 -> PortfolioShareDetail)
-> Parser (Maybe Text)
-> Parser
     (Maybe Bool
      -> Maybe DescribePortfolioShareType
      -> Maybe Bool
      -> PortfolioShareDetail)
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
"PrincipalId")
            Parser
  (Maybe Bool
   -> Maybe DescribePortfolioShareType
   -> Maybe Bool
   -> PortfolioShareDetail)
-> Parser (Maybe Bool)
-> Parser
     (Maybe DescribePortfolioShareType
      -> Maybe Bool -> PortfolioShareDetail)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ShareTagOptions")
            Parser
  (Maybe DescribePortfolioShareType
   -> Maybe Bool -> PortfolioShareDetail)
-> Parser (Maybe DescribePortfolioShareType)
-> Parser (Maybe Bool -> PortfolioShareDetail)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DescribePortfolioShareType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Maybe Bool -> PortfolioShareDetail)
-> Parser (Maybe Bool) -> Parser PortfolioShareDetail
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Accepted")
      )

instance Prelude.Hashable PortfolioShareDetail

instance Prelude.NFData PortfolioShareDetail