{-# 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.DevOpsGuru.UpdateResourceCollection
-- 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)
--
-- Updates the collection of resources that DevOps Guru analyzes. The one
-- type of AWS resource collection supported is AWS CloudFormation stacks.
-- DevOps Guru can be configured to analyze only the AWS resources that are
-- defined in the stacks. You can specify up to 500 AWS CloudFormation
-- stacks. This method also creates the IAM role required for you to use
-- DevOps Guru.
module Amazonka.DevOpsGuru.UpdateResourceCollection
  ( -- * Creating a Request
    UpdateResourceCollection (..),
    newUpdateResourceCollection,

    -- * Request Lenses
    updateResourceCollection_action,
    updateResourceCollection_resourceCollection,

    -- * Destructuring the Response
    UpdateResourceCollectionResponse (..),
    newUpdateResourceCollectionResponse,

    -- * Response Lenses
    updateResourceCollectionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateResourceCollection' smart constructor.
data UpdateResourceCollection = UpdateResourceCollection'
  { -- | Specifies if the resource collection in the request is added or deleted
    -- to the resource collection.
    UpdateResourceCollection -> UpdateResourceCollectionAction
action :: UpdateResourceCollectionAction,
    UpdateResourceCollection -> UpdateResourceCollectionFilter
resourceCollection :: UpdateResourceCollectionFilter
  }
  deriving (UpdateResourceCollection -> UpdateResourceCollection -> Bool
(UpdateResourceCollection -> UpdateResourceCollection -> Bool)
-> (UpdateResourceCollection -> UpdateResourceCollection -> Bool)
-> Eq UpdateResourceCollection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateResourceCollection -> UpdateResourceCollection -> Bool
$c/= :: UpdateResourceCollection -> UpdateResourceCollection -> Bool
== :: UpdateResourceCollection -> UpdateResourceCollection -> Bool
$c== :: UpdateResourceCollection -> UpdateResourceCollection -> Bool
Prelude.Eq, ReadPrec [UpdateResourceCollection]
ReadPrec UpdateResourceCollection
Int -> ReadS UpdateResourceCollection
ReadS [UpdateResourceCollection]
(Int -> ReadS UpdateResourceCollection)
-> ReadS [UpdateResourceCollection]
-> ReadPrec UpdateResourceCollection
-> ReadPrec [UpdateResourceCollection]
-> Read UpdateResourceCollection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateResourceCollection]
$creadListPrec :: ReadPrec [UpdateResourceCollection]
readPrec :: ReadPrec UpdateResourceCollection
$creadPrec :: ReadPrec UpdateResourceCollection
readList :: ReadS [UpdateResourceCollection]
$creadList :: ReadS [UpdateResourceCollection]
readsPrec :: Int -> ReadS UpdateResourceCollection
$creadsPrec :: Int -> ReadS UpdateResourceCollection
Prelude.Read, Int -> UpdateResourceCollection -> ShowS
[UpdateResourceCollection] -> ShowS
UpdateResourceCollection -> String
(Int -> UpdateResourceCollection -> ShowS)
-> (UpdateResourceCollection -> String)
-> ([UpdateResourceCollection] -> ShowS)
-> Show UpdateResourceCollection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateResourceCollection] -> ShowS
$cshowList :: [UpdateResourceCollection] -> ShowS
show :: UpdateResourceCollection -> String
$cshow :: UpdateResourceCollection -> String
showsPrec :: Int -> UpdateResourceCollection -> ShowS
$cshowsPrec :: Int -> UpdateResourceCollection -> ShowS
Prelude.Show, (forall x.
 UpdateResourceCollection -> Rep UpdateResourceCollection x)
-> (forall x.
    Rep UpdateResourceCollection x -> UpdateResourceCollection)
-> Generic UpdateResourceCollection
forall x.
Rep UpdateResourceCollection x -> UpdateResourceCollection
forall x.
UpdateResourceCollection -> Rep UpdateResourceCollection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateResourceCollection x -> UpdateResourceCollection
$cfrom :: forall x.
UpdateResourceCollection -> Rep UpdateResourceCollection x
Prelude.Generic)

-- |
-- Create a value of 'UpdateResourceCollection' 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:
--
-- 'action', 'updateResourceCollection_action' - Specifies if the resource collection in the request is added or deleted
-- to the resource collection.
--
-- 'resourceCollection', 'updateResourceCollection_resourceCollection' - Undocumented member.
newUpdateResourceCollection ::
  -- | 'action'
  UpdateResourceCollectionAction ->
  -- | 'resourceCollection'
  UpdateResourceCollectionFilter ->
  UpdateResourceCollection
newUpdateResourceCollection :: UpdateResourceCollectionAction
-> UpdateResourceCollectionFilter -> UpdateResourceCollection
newUpdateResourceCollection
  UpdateResourceCollectionAction
pAction_
  UpdateResourceCollectionFilter
pResourceCollection_ =
    UpdateResourceCollection' :: UpdateResourceCollectionAction
-> UpdateResourceCollectionFilter -> UpdateResourceCollection
UpdateResourceCollection'
      { $sel:action:UpdateResourceCollection' :: UpdateResourceCollectionAction
action = UpdateResourceCollectionAction
pAction_,
        $sel:resourceCollection:UpdateResourceCollection' :: UpdateResourceCollectionFilter
resourceCollection = UpdateResourceCollectionFilter
pResourceCollection_
      }

-- | Specifies if the resource collection in the request is added or deleted
-- to the resource collection.
updateResourceCollection_action :: Lens.Lens' UpdateResourceCollection UpdateResourceCollectionAction
updateResourceCollection_action :: (UpdateResourceCollectionAction
 -> f UpdateResourceCollectionAction)
-> UpdateResourceCollection -> f UpdateResourceCollection
updateResourceCollection_action = (UpdateResourceCollection -> UpdateResourceCollectionAction)
-> (UpdateResourceCollection
    -> UpdateResourceCollectionAction -> UpdateResourceCollection)
-> Lens
     UpdateResourceCollection
     UpdateResourceCollection
     UpdateResourceCollectionAction
     UpdateResourceCollectionAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResourceCollection' {UpdateResourceCollectionAction
action :: UpdateResourceCollectionAction
$sel:action:UpdateResourceCollection' :: UpdateResourceCollection -> UpdateResourceCollectionAction
action} -> UpdateResourceCollectionAction
action) (\s :: UpdateResourceCollection
s@UpdateResourceCollection' {} UpdateResourceCollectionAction
a -> UpdateResourceCollection
s {$sel:action:UpdateResourceCollection' :: UpdateResourceCollectionAction
action = UpdateResourceCollectionAction
a} :: UpdateResourceCollection)

-- | Undocumented member.
updateResourceCollection_resourceCollection :: Lens.Lens' UpdateResourceCollection UpdateResourceCollectionFilter
updateResourceCollection_resourceCollection :: (UpdateResourceCollectionFilter
 -> f UpdateResourceCollectionFilter)
-> UpdateResourceCollection -> f UpdateResourceCollection
updateResourceCollection_resourceCollection = (UpdateResourceCollection -> UpdateResourceCollectionFilter)
-> (UpdateResourceCollection
    -> UpdateResourceCollectionFilter -> UpdateResourceCollection)
-> Lens
     UpdateResourceCollection
     UpdateResourceCollection
     UpdateResourceCollectionFilter
     UpdateResourceCollectionFilter
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResourceCollection' {UpdateResourceCollectionFilter
resourceCollection :: UpdateResourceCollectionFilter
$sel:resourceCollection:UpdateResourceCollection' :: UpdateResourceCollection -> UpdateResourceCollectionFilter
resourceCollection} -> UpdateResourceCollectionFilter
resourceCollection) (\s :: UpdateResourceCollection
s@UpdateResourceCollection' {} UpdateResourceCollectionFilter
a -> UpdateResourceCollection
s {$sel:resourceCollection:UpdateResourceCollection' :: UpdateResourceCollectionFilter
resourceCollection = UpdateResourceCollectionFilter
a} :: UpdateResourceCollection)

instance Core.AWSRequest UpdateResourceCollection where
  type
    AWSResponse UpdateResourceCollection =
      UpdateResourceCollectionResponse
  request :: UpdateResourceCollection -> Request UpdateResourceCollection
request = Service
-> UpdateResourceCollection -> Request UpdateResourceCollection
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateResourceCollection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateResourceCollection)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateResourceCollection))
-> Logger
-> Service
-> Proxy UpdateResourceCollection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateResourceCollection)))
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 -> UpdateResourceCollectionResponse
UpdateResourceCollectionResponse'
            (Int -> UpdateResourceCollectionResponse)
-> Either String Int
-> Either String UpdateResourceCollectionResponse
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 UpdateResourceCollection

instance Prelude.NFData UpdateResourceCollection

instance Core.ToHeaders UpdateResourceCollection where
  toHeaders :: UpdateResourceCollection -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateResourceCollection -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateResourceCollection where
  toJSON :: UpdateResourceCollection -> Value
toJSON UpdateResourceCollection' {UpdateResourceCollectionAction
UpdateResourceCollectionFilter
resourceCollection :: UpdateResourceCollectionFilter
action :: UpdateResourceCollectionAction
$sel:resourceCollection:UpdateResourceCollection' :: UpdateResourceCollection -> UpdateResourceCollectionFilter
$sel:action:UpdateResourceCollection' :: UpdateResourceCollection -> UpdateResourceCollectionAction
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Action" Text -> UpdateResourceCollectionAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= UpdateResourceCollectionAction
action),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ResourceCollection" Text -> UpdateResourceCollectionFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= UpdateResourceCollectionFilter
resourceCollection)
          ]
      )

instance Core.ToPath UpdateResourceCollection where
  toPath :: UpdateResourceCollection -> ByteString
toPath = ByteString -> UpdateResourceCollection -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/resource-collections"

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

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

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

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

instance
  Prelude.NFData
    UpdateResourceCollectionResponse