{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.PutGroupConfiguration
-- 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)
--
-- Attaches a service configuration to the specified group. This occurs
-- asynchronously, and can take time to complete. You can use
-- GetGroupConfiguration to check the status of the update.
--
-- __Minimum permissions__
--
-- To run this command, you must have the following permissions:
--
-- -   @resource-groups:PutGroupConfiguration@
module Amazonka.ResourceGroups.PutGroupConfiguration
  ( -- * Creating a Request
    PutGroupConfiguration (..),
    newPutGroupConfiguration,

    -- * Request Lenses
    putGroupConfiguration_group,
    putGroupConfiguration_configuration,

    -- * Destructuring the Response
    PutGroupConfigurationResponse (..),
    newPutGroupConfigurationResponse,

    -- * Response Lenses
    putGroupConfigurationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import Amazonka.ResourceGroups.Types
import qualified Amazonka.Response as Response

-- | /See:/ 'newPutGroupConfiguration' smart constructor.
data PutGroupConfiguration = PutGroupConfiguration'
  { -- | The name or ARN of the resource group with the configuration that you
    -- want to update.
    PutGroupConfiguration -> Maybe Text
group' :: Prelude.Maybe Prelude.Text,
    -- | The new configuration to associate with the specified group. A
    -- configuration associates the resource group with an AWS service and
    -- specifies how the service can interact with the resources in the group.
    -- A configuration is an array of GroupConfigurationItem elements.
    --
    -- For information about the syntax of a service configuration, see
    -- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html Service configurations for resource groups>.
    --
    -- A resource group can contain either a @Configuration@ or a
    -- @ResourceQuery@, but not both.
    PutGroupConfiguration -> Maybe [GroupConfigurationItem]
configuration :: Prelude.Maybe [GroupConfigurationItem]
  }
  deriving (PutGroupConfiguration -> PutGroupConfiguration -> Bool
(PutGroupConfiguration -> PutGroupConfiguration -> Bool)
-> (PutGroupConfiguration -> PutGroupConfiguration -> Bool)
-> Eq PutGroupConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutGroupConfiguration -> PutGroupConfiguration -> Bool
$c/= :: PutGroupConfiguration -> PutGroupConfiguration -> Bool
== :: PutGroupConfiguration -> PutGroupConfiguration -> Bool
$c== :: PutGroupConfiguration -> PutGroupConfiguration -> Bool
Prelude.Eq, ReadPrec [PutGroupConfiguration]
ReadPrec PutGroupConfiguration
Int -> ReadS PutGroupConfiguration
ReadS [PutGroupConfiguration]
(Int -> ReadS PutGroupConfiguration)
-> ReadS [PutGroupConfiguration]
-> ReadPrec PutGroupConfiguration
-> ReadPrec [PutGroupConfiguration]
-> Read PutGroupConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutGroupConfiguration]
$creadListPrec :: ReadPrec [PutGroupConfiguration]
readPrec :: ReadPrec PutGroupConfiguration
$creadPrec :: ReadPrec PutGroupConfiguration
readList :: ReadS [PutGroupConfiguration]
$creadList :: ReadS [PutGroupConfiguration]
readsPrec :: Int -> ReadS PutGroupConfiguration
$creadsPrec :: Int -> ReadS PutGroupConfiguration
Prelude.Read, Int -> PutGroupConfiguration -> ShowS
[PutGroupConfiguration] -> ShowS
PutGroupConfiguration -> String
(Int -> PutGroupConfiguration -> ShowS)
-> (PutGroupConfiguration -> String)
-> ([PutGroupConfiguration] -> ShowS)
-> Show PutGroupConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutGroupConfiguration] -> ShowS
$cshowList :: [PutGroupConfiguration] -> ShowS
show :: PutGroupConfiguration -> String
$cshow :: PutGroupConfiguration -> String
showsPrec :: Int -> PutGroupConfiguration -> ShowS
$cshowsPrec :: Int -> PutGroupConfiguration -> ShowS
Prelude.Show, (forall x. PutGroupConfiguration -> Rep PutGroupConfiguration x)
-> (forall x. Rep PutGroupConfiguration x -> PutGroupConfiguration)
-> Generic PutGroupConfiguration
forall x. Rep PutGroupConfiguration x -> PutGroupConfiguration
forall x. PutGroupConfiguration -> Rep PutGroupConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutGroupConfiguration x -> PutGroupConfiguration
$cfrom :: forall x. PutGroupConfiguration -> Rep PutGroupConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'PutGroupConfiguration' 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:
--
-- 'group'', 'putGroupConfiguration_group' - The name or ARN of the resource group with the configuration that you
-- want to update.
--
-- 'configuration', 'putGroupConfiguration_configuration' - The new configuration to associate with the specified group. A
-- configuration associates the resource group with an AWS service and
-- specifies how the service can interact with the resources in the group.
-- A configuration is an array of GroupConfigurationItem elements.
--
-- For information about the syntax of a service configuration, see
-- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html Service configurations for resource groups>.
--
-- A resource group can contain either a @Configuration@ or a
-- @ResourceQuery@, but not both.
newPutGroupConfiguration ::
  PutGroupConfiguration
newPutGroupConfiguration :: PutGroupConfiguration
newPutGroupConfiguration =
  PutGroupConfiguration' :: Maybe Text
-> Maybe [GroupConfigurationItem] -> PutGroupConfiguration
PutGroupConfiguration'
    { $sel:group':PutGroupConfiguration' :: Maybe Text
group' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:configuration:PutGroupConfiguration' :: Maybe [GroupConfigurationItem]
configuration = Maybe [GroupConfigurationItem]
forall a. Maybe a
Prelude.Nothing
    }

-- | The name or ARN of the resource group with the configuration that you
-- want to update.
putGroupConfiguration_group :: Lens.Lens' PutGroupConfiguration (Prelude.Maybe Prelude.Text)
putGroupConfiguration_group :: (Maybe Text -> f (Maybe Text))
-> PutGroupConfiguration -> f PutGroupConfiguration
putGroupConfiguration_group = (PutGroupConfiguration -> Maybe Text)
-> (PutGroupConfiguration -> Maybe Text -> PutGroupConfiguration)
-> Lens
     PutGroupConfiguration
     PutGroupConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutGroupConfiguration' {Maybe Text
group' :: Maybe Text
$sel:group':PutGroupConfiguration' :: PutGroupConfiguration -> Maybe Text
group'} -> Maybe Text
group') (\s :: PutGroupConfiguration
s@PutGroupConfiguration' {} Maybe Text
a -> PutGroupConfiguration
s {$sel:group':PutGroupConfiguration' :: Maybe Text
group' = Maybe Text
a} :: PutGroupConfiguration)

-- | The new configuration to associate with the specified group. A
-- configuration associates the resource group with an AWS service and
-- specifies how the service can interact with the resources in the group.
-- A configuration is an array of GroupConfigurationItem elements.
--
-- For information about the syntax of a service configuration, see
-- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html Service configurations for resource groups>.
--
-- A resource group can contain either a @Configuration@ or a
-- @ResourceQuery@, but not both.
putGroupConfiguration_configuration :: Lens.Lens' PutGroupConfiguration (Prelude.Maybe [GroupConfigurationItem])
putGroupConfiguration_configuration :: (Maybe [GroupConfigurationItem]
 -> f (Maybe [GroupConfigurationItem]))
-> PutGroupConfiguration -> f PutGroupConfiguration
putGroupConfiguration_configuration = (PutGroupConfiguration -> Maybe [GroupConfigurationItem])
-> (PutGroupConfiguration
    -> Maybe [GroupConfigurationItem] -> PutGroupConfiguration)
-> Lens
     PutGroupConfiguration
     PutGroupConfiguration
     (Maybe [GroupConfigurationItem])
     (Maybe [GroupConfigurationItem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutGroupConfiguration' {Maybe [GroupConfigurationItem]
configuration :: Maybe [GroupConfigurationItem]
$sel:configuration:PutGroupConfiguration' :: PutGroupConfiguration -> Maybe [GroupConfigurationItem]
configuration} -> Maybe [GroupConfigurationItem]
configuration) (\s :: PutGroupConfiguration
s@PutGroupConfiguration' {} Maybe [GroupConfigurationItem]
a -> PutGroupConfiguration
s {$sel:configuration:PutGroupConfiguration' :: Maybe [GroupConfigurationItem]
configuration = Maybe [GroupConfigurationItem]
a} :: PutGroupConfiguration) ((Maybe [GroupConfigurationItem]
  -> f (Maybe [GroupConfigurationItem]))
 -> PutGroupConfiguration -> f PutGroupConfiguration)
-> ((Maybe [GroupConfigurationItem]
     -> f (Maybe [GroupConfigurationItem]))
    -> Maybe [GroupConfigurationItem]
    -> f (Maybe [GroupConfigurationItem]))
-> (Maybe [GroupConfigurationItem]
    -> f (Maybe [GroupConfigurationItem]))
-> PutGroupConfiguration
-> f PutGroupConfiguration
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.AWSRequest PutGroupConfiguration where
  type
    AWSResponse PutGroupConfiguration =
      PutGroupConfigurationResponse
  request :: PutGroupConfiguration -> Request PutGroupConfiguration
request = Service -> PutGroupConfiguration -> Request PutGroupConfiguration
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutGroupConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutGroupConfiguration)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutGroupConfiguration))
-> Logger
-> Service
-> Proxy PutGroupConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutGroupConfiguration)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutGroupConfigurationResponse
PutGroupConfigurationResponse'
            (Int -> PutGroupConfigurationResponse)
-> Either String Int -> Either String PutGroupConfigurationResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PutGroupConfiguration

instance Prelude.NFData PutGroupConfiguration

instance Core.ToHeaders PutGroupConfiguration where
  toHeaders :: PutGroupConfiguration -> ResponseHeaders
toHeaders = ResponseHeaders -> PutGroupConfiguration -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON PutGroupConfiguration where
  toJSON :: PutGroupConfiguration -> Value
toJSON PutGroupConfiguration' {Maybe [GroupConfigurationItem]
Maybe Text
configuration :: Maybe [GroupConfigurationItem]
group' :: Maybe Text
$sel:configuration:PutGroupConfiguration' :: PutGroupConfiguration -> Maybe [GroupConfigurationItem]
$sel:group':PutGroupConfiguration' :: PutGroupConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Group" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
group',
            (Text
"Configuration" Text -> [GroupConfigurationItem] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([GroupConfigurationItem] -> Pair)
-> Maybe [GroupConfigurationItem] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [GroupConfigurationItem]
configuration
          ]
      )

instance Core.ToPath PutGroupConfiguration where
  toPath :: PutGroupConfiguration -> ByteString
toPath = ByteString -> PutGroupConfiguration -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/put-group-configuration"

instance Core.ToQuery PutGroupConfiguration where
  toQuery :: PutGroupConfiguration -> QueryString
toQuery = QueryString -> PutGroupConfiguration -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newPutGroupConfigurationResponse' smart constructor.
data PutGroupConfigurationResponse = PutGroupConfigurationResponse'
  { -- | The response's http status code.
    PutGroupConfigurationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutGroupConfigurationResponse
-> PutGroupConfigurationResponse -> Bool
(PutGroupConfigurationResponse
 -> PutGroupConfigurationResponse -> Bool)
-> (PutGroupConfigurationResponse
    -> PutGroupConfigurationResponse -> Bool)
-> Eq PutGroupConfigurationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutGroupConfigurationResponse
-> PutGroupConfigurationResponse -> Bool
$c/= :: PutGroupConfigurationResponse
-> PutGroupConfigurationResponse -> Bool
== :: PutGroupConfigurationResponse
-> PutGroupConfigurationResponse -> Bool
$c== :: PutGroupConfigurationResponse
-> PutGroupConfigurationResponse -> Bool
Prelude.Eq, ReadPrec [PutGroupConfigurationResponse]
ReadPrec PutGroupConfigurationResponse
Int -> ReadS PutGroupConfigurationResponse
ReadS [PutGroupConfigurationResponse]
(Int -> ReadS PutGroupConfigurationResponse)
-> ReadS [PutGroupConfigurationResponse]
-> ReadPrec PutGroupConfigurationResponse
-> ReadPrec [PutGroupConfigurationResponse]
-> Read PutGroupConfigurationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutGroupConfigurationResponse]
$creadListPrec :: ReadPrec [PutGroupConfigurationResponse]
readPrec :: ReadPrec PutGroupConfigurationResponse
$creadPrec :: ReadPrec PutGroupConfigurationResponse
readList :: ReadS [PutGroupConfigurationResponse]
$creadList :: ReadS [PutGroupConfigurationResponse]
readsPrec :: Int -> ReadS PutGroupConfigurationResponse
$creadsPrec :: Int -> ReadS PutGroupConfigurationResponse
Prelude.Read, Int -> PutGroupConfigurationResponse -> ShowS
[PutGroupConfigurationResponse] -> ShowS
PutGroupConfigurationResponse -> String
(Int -> PutGroupConfigurationResponse -> ShowS)
-> (PutGroupConfigurationResponse -> String)
-> ([PutGroupConfigurationResponse] -> ShowS)
-> Show PutGroupConfigurationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutGroupConfigurationResponse] -> ShowS
$cshowList :: [PutGroupConfigurationResponse] -> ShowS
show :: PutGroupConfigurationResponse -> String
$cshow :: PutGroupConfigurationResponse -> String
showsPrec :: Int -> PutGroupConfigurationResponse -> ShowS
$cshowsPrec :: Int -> PutGroupConfigurationResponse -> ShowS
Prelude.Show, (forall x.
 PutGroupConfigurationResponse
 -> Rep PutGroupConfigurationResponse x)
-> (forall x.
    Rep PutGroupConfigurationResponse x
    -> PutGroupConfigurationResponse)
-> Generic PutGroupConfigurationResponse
forall x.
Rep PutGroupConfigurationResponse x
-> PutGroupConfigurationResponse
forall x.
PutGroupConfigurationResponse
-> Rep PutGroupConfigurationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutGroupConfigurationResponse x
-> PutGroupConfigurationResponse
$cfrom :: forall x.
PutGroupConfigurationResponse
-> Rep PutGroupConfigurationResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutGroupConfigurationResponse' 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:
--
-- 'httpStatus', 'putGroupConfigurationResponse_httpStatus' - The response's http status code.
newPutGroupConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutGroupConfigurationResponse
newPutGroupConfigurationResponse :: Int -> PutGroupConfigurationResponse
newPutGroupConfigurationResponse Int
pHttpStatus_ =
  PutGroupConfigurationResponse' :: Int -> PutGroupConfigurationResponse
PutGroupConfigurationResponse'
    { $sel:httpStatus:PutGroupConfigurationResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
putGroupConfigurationResponse_httpStatus :: Lens.Lens' PutGroupConfigurationResponse Prelude.Int
putGroupConfigurationResponse_httpStatus :: (Int -> f Int)
-> PutGroupConfigurationResponse -> f PutGroupConfigurationResponse
putGroupConfigurationResponse_httpStatus = (PutGroupConfigurationResponse -> Int)
-> (PutGroupConfigurationResponse
    -> Int -> PutGroupConfigurationResponse)
-> Lens
     PutGroupConfigurationResponse PutGroupConfigurationResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutGroupConfigurationResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutGroupConfigurationResponse' :: PutGroupConfigurationResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutGroupConfigurationResponse
s@PutGroupConfigurationResponse' {} Int
a -> PutGroupConfigurationResponse
s {$sel:httpStatus:PutGroupConfigurationResponse' :: Int
httpStatus = Int
a} :: PutGroupConfigurationResponse)

instance Prelude.NFData PutGroupConfigurationResponse