{-# 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.ResourceGroups.Types.GroupConfiguration
-- 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.ResourceGroups.Types.GroupConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.ResourceGroups.Types.GroupConfigurationItem
import Amazonka.ResourceGroups.Types.GroupConfigurationStatus

-- | A service configuration associated with a resource group. The
-- configuration options are determined by the AWS service that defines the
-- @Type@, and specifies which resources can be included in the group. You
-- can add a service configuration when you create the group by using
-- CreateGroup, or later by using the PutGroupConfiguration operation. For
-- details about group service configuration syntax, see
-- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html Service configurations for resource groups>.
--
-- /See:/ 'newGroupConfiguration' smart constructor.
data GroupConfiguration = GroupConfiguration'
  { -- | The current status of an attempt to update the group configuration.
    GroupConfiguration -> Maybe GroupConfigurationStatus
status :: Prelude.Maybe GroupConfigurationStatus,
    -- | If present, the reason why a request to update the group configuration
    -- failed.
    GroupConfiguration -> Maybe Text
failureReason :: Prelude.Maybe Prelude.Text,
    -- | If present, the new configuration that is in the process of being
    -- applied to the group.
    GroupConfiguration -> Maybe [GroupConfigurationItem]
proposedConfiguration :: Prelude.Maybe [GroupConfigurationItem],
    -- | The configuration currently associated with the group and in effect.
    GroupConfiguration -> Maybe [GroupConfigurationItem]
configuration :: Prelude.Maybe [GroupConfigurationItem]
  }
  deriving (GroupConfiguration -> GroupConfiguration -> Bool
(GroupConfiguration -> GroupConfiguration -> Bool)
-> (GroupConfiguration -> GroupConfiguration -> Bool)
-> Eq GroupConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GroupConfiguration -> GroupConfiguration -> Bool
$c/= :: GroupConfiguration -> GroupConfiguration -> Bool
== :: GroupConfiguration -> GroupConfiguration -> Bool
$c== :: GroupConfiguration -> GroupConfiguration -> Bool
Prelude.Eq, ReadPrec [GroupConfiguration]
ReadPrec GroupConfiguration
Int -> ReadS GroupConfiguration
ReadS [GroupConfiguration]
(Int -> ReadS GroupConfiguration)
-> ReadS [GroupConfiguration]
-> ReadPrec GroupConfiguration
-> ReadPrec [GroupConfiguration]
-> Read GroupConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GroupConfiguration]
$creadListPrec :: ReadPrec [GroupConfiguration]
readPrec :: ReadPrec GroupConfiguration
$creadPrec :: ReadPrec GroupConfiguration
readList :: ReadS [GroupConfiguration]
$creadList :: ReadS [GroupConfiguration]
readsPrec :: Int -> ReadS GroupConfiguration
$creadsPrec :: Int -> ReadS GroupConfiguration
Prelude.Read, Int -> GroupConfiguration -> ShowS
[GroupConfiguration] -> ShowS
GroupConfiguration -> String
(Int -> GroupConfiguration -> ShowS)
-> (GroupConfiguration -> String)
-> ([GroupConfiguration] -> ShowS)
-> Show GroupConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GroupConfiguration] -> ShowS
$cshowList :: [GroupConfiguration] -> ShowS
show :: GroupConfiguration -> String
$cshow :: GroupConfiguration -> String
showsPrec :: Int -> GroupConfiguration -> ShowS
$cshowsPrec :: Int -> GroupConfiguration -> ShowS
Prelude.Show, (forall x. GroupConfiguration -> Rep GroupConfiguration x)
-> (forall x. Rep GroupConfiguration x -> GroupConfiguration)
-> Generic GroupConfiguration
forall x. Rep GroupConfiguration x -> GroupConfiguration
forall x. GroupConfiguration -> Rep GroupConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GroupConfiguration x -> GroupConfiguration
$cfrom :: forall x. GroupConfiguration -> Rep GroupConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'GroupConfiguration' 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:
--
-- 'status', 'groupConfiguration_status' - The current status of an attempt to update the group configuration.
--
-- 'failureReason', 'groupConfiguration_failureReason' - If present, the reason why a request to update the group configuration
-- failed.
--
-- 'proposedConfiguration', 'groupConfiguration_proposedConfiguration' - If present, the new configuration that is in the process of being
-- applied to the group.
--
-- 'configuration', 'groupConfiguration_configuration' - The configuration currently associated with the group and in effect.
newGroupConfiguration ::
  GroupConfiguration
newGroupConfiguration :: GroupConfiguration
newGroupConfiguration =
  GroupConfiguration' :: Maybe GroupConfigurationStatus
-> Maybe Text
-> Maybe [GroupConfigurationItem]
-> Maybe [GroupConfigurationItem]
-> GroupConfiguration
GroupConfiguration'
    { $sel:status:GroupConfiguration' :: Maybe GroupConfigurationStatus
status = Maybe GroupConfigurationStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:failureReason:GroupConfiguration' :: Maybe Text
failureReason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:proposedConfiguration:GroupConfiguration' :: Maybe [GroupConfigurationItem]
proposedConfiguration = Maybe [GroupConfigurationItem]
forall a. Maybe a
Prelude.Nothing,
      $sel:configuration:GroupConfiguration' :: Maybe [GroupConfigurationItem]
configuration = Maybe [GroupConfigurationItem]
forall a. Maybe a
Prelude.Nothing
    }

-- | The current status of an attempt to update the group configuration.
groupConfiguration_status :: Lens.Lens' GroupConfiguration (Prelude.Maybe GroupConfigurationStatus)
groupConfiguration_status :: (Maybe GroupConfigurationStatus
 -> f (Maybe GroupConfigurationStatus))
-> GroupConfiguration -> f GroupConfiguration
groupConfiguration_status = (GroupConfiguration -> Maybe GroupConfigurationStatus)
-> (GroupConfiguration
    -> Maybe GroupConfigurationStatus -> GroupConfiguration)
-> Lens
     GroupConfiguration
     GroupConfiguration
     (Maybe GroupConfigurationStatus)
     (Maybe GroupConfigurationStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupConfiguration' {Maybe GroupConfigurationStatus
status :: Maybe GroupConfigurationStatus
$sel:status:GroupConfiguration' :: GroupConfiguration -> Maybe GroupConfigurationStatus
status} -> Maybe GroupConfigurationStatus
status) (\s :: GroupConfiguration
s@GroupConfiguration' {} Maybe GroupConfigurationStatus
a -> GroupConfiguration
s {$sel:status:GroupConfiguration' :: Maybe GroupConfigurationStatus
status = Maybe GroupConfigurationStatus
a} :: GroupConfiguration)

-- | If present, the reason why a request to update the group configuration
-- failed.
groupConfiguration_failureReason :: Lens.Lens' GroupConfiguration (Prelude.Maybe Prelude.Text)
groupConfiguration_failureReason :: (Maybe Text -> f (Maybe Text))
-> GroupConfiguration -> f GroupConfiguration
groupConfiguration_failureReason = (GroupConfiguration -> Maybe Text)
-> (GroupConfiguration -> Maybe Text -> GroupConfiguration)
-> Lens
     GroupConfiguration GroupConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupConfiguration' {Maybe Text
failureReason :: Maybe Text
$sel:failureReason:GroupConfiguration' :: GroupConfiguration -> Maybe Text
failureReason} -> Maybe Text
failureReason) (\s :: GroupConfiguration
s@GroupConfiguration' {} Maybe Text
a -> GroupConfiguration
s {$sel:failureReason:GroupConfiguration' :: Maybe Text
failureReason = Maybe Text
a} :: GroupConfiguration)

-- | If present, the new configuration that is in the process of being
-- applied to the group.
groupConfiguration_proposedConfiguration :: Lens.Lens' GroupConfiguration (Prelude.Maybe [GroupConfigurationItem])
groupConfiguration_proposedConfiguration :: (Maybe [GroupConfigurationItem]
 -> f (Maybe [GroupConfigurationItem]))
-> GroupConfiguration -> f GroupConfiguration
groupConfiguration_proposedConfiguration = (GroupConfiguration -> Maybe [GroupConfigurationItem])
-> (GroupConfiguration
    -> Maybe [GroupConfigurationItem] -> GroupConfiguration)
-> Lens
     GroupConfiguration
     GroupConfiguration
     (Maybe [GroupConfigurationItem])
     (Maybe [GroupConfigurationItem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupConfiguration' {Maybe [GroupConfigurationItem]
proposedConfiguration :: Maybe [GroupConfigurationItem]
$sel:proposedConfiguration:GroupConfiguration' :: GroupConfiguration -> Maybe [GroupConfigurationItem]
proposedConfiguration} -> Maybe [GroupConfigurationItem]
proposedConfiguration) (\s :: GroupConfiguration
s@GroupConfiguration' {} Maybe [GroupConfigurationItem]
a -> GroupConfiguration
s {$sel:proposedConfiguration:GroupConfiguration' :: Maybe [GroupConfigurationItem]
proposedConfiguration = Maybe [GroupConfigurationItem]
a} :: GroupConfiguration) ((Maybe [GroupConfigurationItem]
  -> f (Maybe [GroupConfigurationItem]))
 -> GroupConfiguration -> f GroupConfiguration)
-> ((Maybe [GroupConfigurationItem]
     -> f (Maybe [GroupConfigurationItem]))
    -> Maybe [GroupConfigurationItem]
    -> f (Maybe [GroupConfigurationItem]))
-> (Maybe [GroupConfigurationItem]
    -> f (Maybe [GroupConfigurationItem]))
-> GroupConfiguration
-> f GroupConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GroupConfigurationItem]
  [GroupConfigurationItem]
  [GroupConfigurationItem]
  [GroupConfigurationItem]
-> Iso
     (Maybe [GroupConfigurationItem])
     (Maybe [GroupConfigurationItem])
     (Maybe [GroupConfigurationItem])
     (Maybe [GroupConfigurationItem])
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
  [GroupConfigurationItem]
  [GroupConfigurationItem]
  [GroupConfigurationItem]
  [GroupConfigurationItem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The configuration currently associated with the group and in effect.
groupConfiguration_configuration :: Lens.Lens' GroupConfiguration (Prelude.Maybe [GroupConfigurationItem])
groupConfiguration_configuration :: (Maybe [GroupConfigurationItem]
 -> f (Maybe [GroupConfigurationItem]))
-> GroupConfiguration -> f GroupConfiguration
groupConfiguration_configuration = (GroupConfiguration -> Maybe [GroupConfigurationItem])
-> (GroupConfiguration
    -> Maybe [GroupConfigurationItem] -> GroupConfiguration)
-> Lens
     GroupConfiguration
     GroupConfiguration
     (Maybe [GroupConfigurationItem])
     (Maybe [GroupConfigurationItem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupConfiguration' {Maybe [GroupConfigurationItem]
configuration :: Maybe [GroupConfigurationItem]
$sel:configuration:GroupConfiguration' :: GroupConfiguration -> Maybe [GroupConfigurationItem]
configuration} -> Maybe [GroupConfigurationItem]
configuration) (\s :: GroupConfiguration
s@GroupConfiguration' {} Maybe [GroupConfigurationItem]
a -> GroupConfiguration
s {$sel:configuration:GroupConfiguration' :: Maybe [GroupConfigurationItem]
configuration = Maybe [GroupConfigurationItem]
a} :: GroupConfiguration) ((Maybe [GroupConfigurationItem]
  -> f (Maybe [GroupConfigurationItem]))
 -> GroupConfiguration -> f GroupConfiguration)
-> ((Maybe [GroupConfigurationItem]
     -> f (Maybe [GroupConfigurationItem]))
    -> Maybe [GroupConfigurationItem]
    -> f (Maybe [GroupConfigurationItem]))
-> (Maybe [GroupConfigurationItem]
    -> f (Maybe [GroupConfigurationItem]))
-> GroupConfiguration
-> f GroupConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GroupConfigurationItem]
  [GroupConfigurationItem]
  [GroupConfigurationItem]
  [GroupConfigurationItem]
-> Iso
     (Maybe [GroupConfigurationItem])
     (Maybe [GroupConfigurationItem])
     (Maybe [GroupConfigurationItem])
     (Maybe [GroupConfigurationItem])
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
  [GroupConfigurationItem]
  [GroupConfigurationItem]
  [GroupConfigurationItem]
  [GroupConfigurationItem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON GroupConfiguration where
  parseJSON :: Value -> Parser GroupConfiguration
parseJSON =
    String
-> (Object -> Parser GroupConfiguration)
-> Value
-> Parser GroupConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GroupConfiguration"
      ( \Object
x ->
          Maybe GroupConfigurationStatus
-> Maybe Text
-> Maybe [GroupConfigurationItem]
-> Maybe [GroupConfigurationItem]
-> GroupConfiguration
GroupConfiguration'
            (Maybe GroupConfigurationStatus
 -> Maybe Text
 -> Maybe [GroupConfigurationItem]
 -> Maybe [GroupConfigurationItem]
 -> GroupConfiguration)
-> Parser (Maybe GroupConfigurationStatus)
-> Parser
     (Maybe Text
      -> Maybe [GroupConfigurationItem]
      -> Maybe [GroupConfigurationItem]
      -> GroupConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe GroupConfigurationStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe Text
   -> Maybe [GroupConfigurationItem]
   -> Maybe [GroupConfigurationItem]
   -> GroupConfiguration)
-> Parser (Maybe Text)
-> Parser
     (Maybe [GroupConfigurationItem]
      -> Maybe [GroupConfigurationItem] -> GroupConfiguration)
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
"FailureReason")
            Parser
  (Maybe [GroupConfigurationItem]
   -> Maybe [GroupConfigurationItem] -> GroupConfiguration)
-> Parser (Maybe [GroupConfigurationItem])
-> Parser (Maybe [GroupConfigurationItem] -> GroupConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [GroupConfigurationItem]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ProposedConfiguration"
                            Parser (Maybe (Maybe [GroupConfigurationItem]))
-> Maybe [GroupConfigurationItem]
-> Parser (Maybe [GroupConfigurationItem])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [GroupConfigurationItem]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [GroupConfigurationItem] -> GroupConfiguration)
-> Parser (Maybe [GroupConfigurationItem])
-> Parser GroupConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [GroupConfigurationItem]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Configuration" Parser (Maybe (Maybe [GroupConfigurationItem]))
-> Maybe [GroupConfigurationItem]
-> Parser (Maybe [GroupConfigurationItem])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [GroupConfigurationItem]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable GroupConfiguration

instance Prelude.NFData GroupConfiguration