{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ServiceCatalog.Types.PortfolioShareDetail where

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

-- | Information about the portfolio share.
--
-- /See:/ 'newPortfolioShareDetail' smart constructor.
data PortfolioShareDetail = 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 -> Maybe Bool
accepted :: Prelude.Maybe Prelude.Bool,
    -- | The identifier of the recipient entity that received the portfolio
    -- share. The recipient entity 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 if @Principal@ sharing is enabled or disabled for the
    -- portfolio share.
    PortfolioShareDetail -> Maybe Bool
sharePrincipals :: Prelude.Maybe Prelude.Bool,
    -- | 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
  }
  deriving (PortfolioShareDetail -> PortfolioShareDetail -> Bool
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]
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
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. 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:
--
-- '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.
--
-- 'principalId', 'portfolioShareDetail_principalId' - The identifier of the recipient entity that received the portfolio
-- share. The recipient entity 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).
--
-- 'sharePrincipals', 'portfolioShareDetail_sharePrincipals' - Indicates if @Principal@ sharing is enabled or disabled for the
-- portfolio share.
--
-- 'shareTagOptions', 'portfolioShareDetail_shareTagOptions' - Indicates whether TagOptions sharing is enabled or disabled for the
-- portfolio share.
--
-- 'type'', 'portfolioShareDetail_type' - The type of the portfolio share.
newPortfolioShareDetail ::
  PortfolioShareDetail
newPortfolioShareDetail :: PortfolioShareDetail
newPortfolioShareDetail =
  PortfolioShareDetail'
    { $sel:accepted:PortfolioShareDetail' :: Maybe Bool
accepted = forall a. Maybe a
Prelude.Nothing,
      $sel:principalId:PortfolioShareDetail' :: Maybe Text
principalId = forall a. Maybe a
Prelude.Nothing,
      $sel:sharePrincipals:PortfolioShareDetail' :: Maybe Bool
sharePrincipals = forall a. Maybe a
Prelude.Nothing,
      $sel:shareTagOptions:PortfolioShareDetail' :: Maybe Bool
shareTagOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:type':PortfolioShareDetail' :: Maybe DescribePortfolioShareType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' PortfolioShareDetail (Maybe Bool)
portfolioShareDetail_accepted = 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)

-- | The identifier of the recipient entity that received the portfolio
-- share. The recipient entity 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 :: Lens' PortfolioShareDetail (Maybe Text)
portfolioShareDetail_principalId = 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 if @Principal@ sharing is enabled or disabled for the
-- portfolio share.
portfolioShareDetail_sharePrincipals :: Lens.Lens' PortfolioShareDetail (Prelude.Maybe Prelude.Bool)
portfolioShareDetail_sharePrincipals :: Lens' PortfolioShareDetail (Maybe Bool)
portfolioShareDetail_sharePrincipals = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortfolioShareDetail' {Maybe Bool
sharePrincipals :: Maybe Bool
$sel:sharePrincipals:PortfolioShareDetail' :: PortfolioShareDetail -> Maybe Bool
sharePrincipals} -> Maybe Bool
sharePrincipals) (\s :: PortfolioShareDetail
s@PortfolioShareDetail' {} Maybe Bool
a -> PortfolioShareDetail
s {$sel:sharePrincipals:PortfolioShareDetail' :: Maybe Bool
sharePrincipals = Maybe Bool
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 :: Lens' PortfolioShareDetail (Maybe Bool)
portfolioShareDetail_shareTagOptions = 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 :: Lens' PortfolioShareDetail (Maybe DescribePortfolioShareType)
portfolioShareDetail_type = 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)

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

instance Prelude.Hashable PortfolioShareDetail where
  hashWithSalt :: Int -> PortfolioShareDetail -> Int
hashWithSalt Int
_salt PortfolioShareDetail' {Maybe Bool
Maybe Text
Maybe DescribePortfolioShareType
type' :: Maybe DescribePortfolioShareType
shareTagOptions :: Maybe Bool
sharePrincipals :: Maybe Bool
principalId :: Maybe Text
accepted :: Maybe Bool
$sel:type':PortfolioShareDetail' :: PortfolioShareDetail -> Maybe DescribePortfolioShareType
$sel:shareTagOptions:PortfolioShareDetail' :: PortfolioShareDetail -> Maybe Bool
$sel:sharePrincipals:PortfolioShareDetail' :: PortfolioShareDetail -> Maybe Bool
$sel:principalId:PortfolioShareDetail' :: PortfolioShareDetail -> Maybe Text
$sel:accepted:PortfolioShareDetail' :: PortfolioShareDetail -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
accepted
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
principalId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
sharePrincipals
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
shareTagOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DescribePortfolioShareType
type'

instance Prelude.NFData PortfolioShareDetail where
  rnf :: PortfolioShareDetail -> ()
rnf PortfolioShareDetail' {Maybe Bool
Maybe Text
Maybe DescribePortfolioShareType
type' :: Maybe DescribePortfolioShareType
shareTagOptions :: Maybe Bool
sharePrincipals :: Maybe Bool
principalId :: Maybe Text
accepted :: Maybe Bool
$sel:type':PortfolioShareDetail' :: PortfolioShareDetail -> Maybe DescribePortfolioShareType
$sel:shareTagOptions:PortfolioShareDetail' :: PortfolioShareDetail -> Maybe Bool
$sel:sharePrincipals:PortfolioShareDetail' :: PortfolioShareDetail -> Maybe Bool
$sel:principalId:PortfolioShareDetail' :: PortfolioShareDetail -> Maybe Text
$sel:accepted:PortfolioShareDetail' :: PortfolioShareDetail -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
accepted
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
principalId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
sharePrincipals
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
shareTagOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DescribePortfolioShareType
type'