{-# 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.MacieV2.UpdateMemberSession
-- 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)
--
-- Enables an Amazon Macie administrator to suspend or re-enable a member
-- account.
module Amazonka.MacieV2.UpdateMemberSession
  ( -- * Creating a Request
    UpdateMemberSession (..),
    newUpdateMemberSession,

    -- * Request Lenses
    updateMemberSession_id,
    updateMemberSession_status,

    -- * Destructuring the Response
    UpdateMemberSessionResponse (..),
    newUpdateMemberSessionResponse,

    -- * Response Lenses
    updateMemberSessionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateMemberSession' smart constructor.
data UpdateMemberSession = UpdateMemberSession'
  { -- | The unique identifier for the Amazon Macie resource or account that the
    -- request applies to.
    UpdateMemberSession -> Text
id :: Prelude.Text,
    -- | Specifies the new status for the account. Valid values are: ENABLED,
    -- resume all Amazon Macie activities for the account; and, PAUSED, suspend
    -- all Macie activities for the account.
    UpdateMemberSession -> MacieStatus
status :: MacieStatus
  }
  deriving (UpdateMemberSession -> UpdateMemberSession -> Bool
(UpdateMemberSession -> UpdateMemberSession -> Bool)
-> (UpdateMemberSession -> UpdateMemberSession -> Bool)
-> Eq UpdateMemberSession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateMemberSession -> UpdateMemberSession -> Bool
$c/= :: UpdateMemberSession -> UpdateMemberSession -> Bool
== :: UpdateMemberSession -> UpdateMemberSession -> Bool
$c== :: UpdateMemberSession -> UpdateMemberSession -> Bool
Prelude.Eq, ReadPrec [UpdateMemberSession]
ReadPrec UpdateMemberSession
Int -> ReadS UpdateMemberSession
ReadS [UpdateMemberSession]
(Int -> ReadS UpdateMemberSession)
-> ReadS [UpdateMemberSession]
-> ReadPrec UpdateMemberSession
-> ReadPrec [UpdateMemberSession]
-> Read UpdateMemberSession
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateMemberSession]
$creadListPrec :: ReadPrec [UpdateMemberSession]
readPrec :: ReadPrec UpdateMemberSession
$creadPrec :: ReadPrec UpdateMemberSession
readList :: ReadS [UpdateMemberSession]
$creadList :: ReadS [UpdateMemberSession]
readsPrec :: Int -> ReadS UpdateMemberSession
$creadsPrec :: Int -> ReadS UpdateMemberSession
Prelude.Read, Int -> UpdateMemberSession -> ShowS
[UpdateMemberSession] -> ShowS
UpdateMemberSession -> String
(Int -> UpdateMemberSession -> ShowS)
-> (UpdateMemberSession -> String)
-> ([UpdateMemberSession] -> ShowS)
-> Show UpdateMemberSession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateMemberSession] -> ShowS
$cshowList :: [UpdateMemberSession] -> ShowS
show :: UpdateMemberSession -> String
$cshow :: UpdateMemberSession -> String
showsPrec :: Int -> UpdateMemberSession -> ShowS
$cshowsPrec :: Int -> UpdateMemberSession -> ShowS
Prelude.Show, (forall x. UpdateMemberSession -> Rep UpdateMemberSession x)
-> (forall x. Rep UpdateMemberSession x -> UpdateMemberSession)
-> Generic UpdateMemberSession
forall x. Rep UpdateMemberSession x -> UpdateMemberSession
forall x. UpdateMemberSession -> Rep UpdateMemberSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateMemberSession x -> UpdateMemberSession
$cfrom :: forall x. UpdateMemberSession -> Rep UpdateMemberSession x
Prelude.Generic)

-- |
-- Create a value of 'UpdateMemberSession' 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:
--
-- 'id', 'updateMemberSession_id' - The unique identifier for the Amazon Macie resource or account that the
-- request applies to.
--
-- 'status', 'updateMemberSession_status' - Specifies the new status for the account. Valid values are: ENABLED,
-- resume all Amazon Macie activities for the account; and, PAUSED, suspend
-- all Macie activities for the account.
newUpdateMemberSession ::
  -- | 'id'
  Prelude.Text ->
  -- | 'status'
  MacieStatus ->
  UpdateMemberSession
newUpdateMemberSession :: Text -> MacieStatus -> UpdateMemberSession
newUpdateMemberSession Text
pId_ MacieStatus
pStatus_ =
  UpdateMemberSession' :: Text -> MacieStatus -> UpdateMemberSession
UpdateMemberSession' {$sel:id:UpdateMemberSession' :: Text
id = Text
pId_, $sel:status:UpdateMemberSession' :: MacieStatus
status = MacieStatus
pStatus_}

-- | The unique identifier for the Amazon Macie resource or account that the
-- request applies to.
updateMemberSession_id :: Lens.Lens' UpdateMemberSession Prelude.Text
updateMemberSession_id :: (Text -> f Text) -> UpdateMemberSession -> f UpdateMemberSession
updateMemberSession_id = (UpdateMemberSession -> Text)
-> (UpdateMemberSession -> Text -> UpdateMemberSession)
-> Lens UpdateMemberSession UpdateMemberSession Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMemberSession' {Text
id :: Text
$sel:id:UpdateMemberSession' :: UpdateMemberSession -> Text
id} -> Text
id) (\s :: UpdateMemberSession
s@UpdateMemberSession' {} Text
a -> UpdateMemberSession
s {$sel:id:UpdateMemberSession' :: Text
id = Text
a} :: UpdateMemberSession)

-- | Specifies the new status for the account. Valid values are: ENABLED,
-- resume all Amazon Macie activities for the account; and, PAUSED, suspend
-- all Macie activities for the account.
updateMemberSession_status :: Lens.Lens' UpdateMemberSession MacieStatus
updateMemberSession_status :: (MacieStatus -> f MacieStatus)
-> UpdateMemberSession -> f UpdateMemberSession
updateMemberSession_status = (UpdateMemberSession -> MacieStatus)
-> (UpdateMemberSession -> MacieStatus -> UpdateMemberSession)
-> Lens
     UpdateMemberSession UpdateMemberSession MacieStatus MacieStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMemberSession' {MacieStatus
status :: MacieStatus
$sel:status:UpdateMemberSession' :: UpdateMemberSession -> MacieStatus
status} -> MacieStatus
status) (\s :: UpdateMemberSession
s@UpdateMemberSession' {} MacieStatus
a -> UpdateMemberSession
s {$sel:status:UpdateMemberSession' :: MacieStatus
status = MacieStatus
a} :: UpdateMemberSession)

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

instance Prelude.NFData UpdateMemberSession

instance Core.ToHeaders UpdateMemberSession where
  toHeaders :: UpdateMemberSession -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateMemberSession -> 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 UpdateMemberSession where
  toJSON :: UpdateMemberSession -> Value
toJSON UpdateMemberSession' {Text
MacieStatus
status :: MacieStatus
id :: Text
$sel:status:UpdateMemberSession' :: UpdateMemberSession -> MacieStatus
$sel:id:UpdateMemberSession' :: UpdateMemberSession -> Text
..} =
    [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
"status" Text -> MacieStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= MacieStatus
status)]
      )

instance Core.ToPath UpdateMemberSession where
  toPath :: UpdateMemberSession -> ByteString
toPath UpdateMemberSession' {Text
MacieStatus
status :: MacieStatus
id :: Text
$sel:status:UpdateMemberSession' :: UpdateMemberSession -> MacieStatus
$sel:id:UpdateMemberSession' :: UpdateMemberSession -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/macie/members/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id]

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

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

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

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

instance Prelude.NFData UpdateMemberSessionResponse