{-# 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.Detective.StartMonitoringMember
-- 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)
--
-- Sends a request to enable data ingest for a member account that has a
-- status of @ACCEPTED_BUT_DISABLED@.
--
-- For valid member accounts, the status is updated as follows.
--
-- -   If Detective enabled the member account, then the new status is
--     @ENABLED@.
--
-- -   If Detective cannot enable the member account, the status remains
--     @ACCEPTED_BUT_DISABLED@.
module Amazonka.Detective.StartMonitoringMember
  ( -- * Creating a Request
    StartMonitoringMember (..),
    newStartMonitoringMember,

    -- * Request Lenses
    startMonitoringMember_graphArn,
    startMonitoringMember_accountId,

    -- * Destructuring the Response
    StartMonitoringMemberResponse (..),
    newStartMonitoringMemberResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Detective.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:/ 'newStartMonitoringMember' smart constructor.
data StartMonitoringMember = StartMonitoringMember'
  { -- | The ARN of the behavior graph.
    StartMonitoringMember -> Text
graphArn :: Prelude.Text,
    -- | The account ID of the member account to try to enable.
    --
    -- The account must be an invited member account with a status of
    -- @ACCEPTED_BUT_DISABLED@.
    StartMonitoringMember -> Text
accountId :: Prelude.Text
  }
  deriving (StartMonitoringMember -> StartMonitoringMember -> Bool
(StartMonitoringMember -> StartMonitoringMember -> Bool)
-> (StartMonitoringMember -> StartMonitoringMember -> Bool)
-> Eq StartMonitoringMember
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartMonitoringMember -> StartMonitoringMember -> Bool
$c/= :: StartMonitoringMember -> StartMonitoringMember -> Bool
== :: StartMonitoringMember -> StartMonitoringMember -> Bool
$c== :: StartMonitoringMember -> StartMonitoringMember -> Bool
Prelude.Eq, ReadPrec [StartMonitoringMember]
ReadPrec StartMonitoringMember
Int -> ReadS StartMonitoringMember
ReadS [StartMonitoringMember]
(Int -> ReadS StartMonitoringMember)
-> ReadS [StartMonitoringMember]
-> ReadPrec StartMonitoringMember
-> ReadPrec [StartMonitoringMember]
-> Read StartMonitoringMember
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartMonitoringMember]
$creadListPrec :: ReadPrec [StartMonitoringMember]
readPrec :: ReadPrec StartMonitoringMember
$creadPrec :: ReadPrec StartMonitoringMember
readList :: ReadS [StartMonitoringMember]
$creadList :: ReadS [StartMonitoringMember]
readsPrec :: Int -> ReadS StartMonitoringMember
$creadsPrec :: Int -> ReadS StartMonitoringMember
Prelude.Read, Int -> StartMonitoringMember -> ShowS
[StartMonitoringMember] -> ShowS
StartMonitoringMember -> String
(Int -> StartMonitoringMember -> ShowS)
-> (StartMonitoringMember -> String)
-> ([StartMonitoringMember] -> ShowS)
-> Show StartMonitoringMember
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartMonitoringMember] -> ShowS
$cshowList :: [StartMonitoringMember] -> ShowS
show :: StartMonitoringMember -> String
$cshow :: StartMonitoringMember -> String
showsPrec :: Int -> StartMonitoringMember -> ShowS
$cshowsPrec :: Int -> StartMonitoringMember -> ShowS
Prelude.Show, (forall x. StartMonitoringMember -> Rep StartMonitoringMember x)
-> (forall x. Rep StartMonitoringMember x -> StartMonitoringMember)
-> Generic StartMonitoringMember
forall x. Rep StartMonitoringMember x -> StartMonitoringMember
forall x. StartMonitoringMember -> Rep StartMonitoringMember x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartMonitoringMember x -> StartMonitoringMember
$cfrom :: forall x. StartMonitoringMember -> Rep StartMonitoringMember x
Prelude.Generic)

-- |
-- Create a value of 'StartMonitoringMember' 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:
--
-- 'graphArn', 'startMonitoringMember_graphArn' - The ARN of the behavior graph.
--
-- 'accountId', 'startMonitoringMember_accountId' - The account ID of the member account to try to enable.
--
-- The account must be an invited member account with a status of
-- @ACCEPTED_BUT_DISABLED@.
newStartMonitoringMember ::
  -- | 'graphArn'
  Prelude.Text ->
  -- | 'accountId'
  Prelude.Text ->
  StartMonitoringMember
newStartMonitoringMember :: Text -> Text -> StartMonitoringMember
newStartMonitoringMember Text
pGraphArn_ Text
pAccountId_ =
  StartMonitoringMember' :: Text -> Text -> StartMonitoringMember
StartMonitoringMember'
    { $sel:graphArn:StartMonitoringMember' :: Text
graphArn = Text
pGraphArn_,
      $sel:accountId:StartMonitoringMember' :: Text
accountId = Text
pAccountId_
    }

-- | The ARN of the behavior graph.
startMonitoringMember_graphArn :: Lens.Lens' StartMonitoringMember Prelude.Text
startMonitoringMember_graphArn :: (Text -> f Text)
-> StartMonitoringMember -> f StartMonitoringMember
startMonitoringMember_graphArn = (StartMonitoringMember -> Text)
-> (StartMonitoringMember -> Text -> StartMonitoringMember)
-> Lens StartMonitoringMember StartMonitoringMember Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartMonitoringMember' {Text
graphArn :: Text
$sel:graphArn:StartMonitoringMember' :: StartMonitoringMember -> Text
graphArn} -> Text
graphArn) (\s :: StartMonitoringMember
s@StartMonitoringMember' {} Text
a -> StartMonitoringMember
s {$sel:graphArn:StartMonitoringMember' :: Text
graphArn = Text
a} :: StartMonitoringMember)

-- | The account ID of the member account to try to enable.
--
-- The account must be an invited member account with a status of
-- @ACCEPTED_BUT_DISABLED@.
startMonitoringMember_accountId :: Lens.Lens' StartMonitoringMember Prelude.Text
startMonitoringMember_accountId :: (Text -> f Text)
-> StartMonitoringMember -> f StartMonitoringMember
startMonitoringMember_accountId = (StartMonitoringMember -> Text)
-> (StartMonitoringMember -> Text -> StartMonitoringMember)
-> Lens StartMonitoringMember StartMonitoringMember Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartMonitoringMember' {Text
accountId :: Text
$sel:accountId:StartMonitoringMember' :: StartMonitoringMember -> Text
accountId} -> Text
accountId) (\s :: StartMonitoringMember
s@StartMonitoringMember' {} Text
a -> StartMonitoringMember
s {$sel:accountId:StartMonitoringMember' :: Text
accountId = Text
a} :: StartMonitoringMember)

instance Core.AWSRequest StartMonitoringMember where
  type
    AWSResponse StartMonitoringMember =
      StartMonitoringMemberResponse
  request :: StartMonitoringMember -> Request StartMonitoringMember
request = Service -> StartMonitoringMember -> Request StartMonitoringMember
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartMonitoringMember
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartMonitoringMember)))
response =
    AWSResponse StartMonitoringMember
-> Logger
-> Service
-> Proxy StartMonitoringMember
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartMonitoringMember)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse StartMonitoringMember
StartMonitoringMemberResponse
StartMonitoringMemberResponse'

instance Prelude.Hashable StartMonitoringMember

instance Prelude.NFData StartMonitoringMember

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

instance Core.ToJSON StartMonitoringMember where
  toJSON :: StartMonitoringMember -> Value
toJSON StartMonitoringMember' {Text
accountId :: Text
graphArn :: Text
$sel:accountId:StartMonitoringMember' :: StartMonitoringMember -> Text
$sel:graphArn:StartMonitoringMember' :: StartMonitoringMember -> 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
"GraphArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
graphArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AccountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
accountId)
          ]
      )

instance Core.ToPath StartMonitoringMember where
  toPath :: StartMonitoringMember -> ByteString
toPath =
    ByteString -> StartMonitoringMember -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/graph/member/monitoringstate"

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

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

-- |
-- Create a value of 'StartMonitoringMemberResponse' 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.
newStartMonitoringMemberResponse ::
  StartMonitoringMemberResponse
newStartMonitoringMemberResponse :: StartMonitoringMemberResponse
newStartMonitoringMemberResponse =
  StartMonitoringMemberResponse
StartMonitoringMemberResponse'

instance Prelude.NFData StartMonitoringMemberResponse