{-# 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.Discovery.StartDataCollectionByAgentIds
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Instructs the specified agents or connectors to start collecting data.
module Amazonka.Discovery.StartDataCollectionByAgentIds
  ( -- * Creating a Request
    StartDataCollectionByAgentIds (..),
    newStartDataCollectionByAgentIds,

    -- * Request Lenses
    startDataCollectionByAgentIds_agentIds,

    -- * Destructuring the Response
    StartDataCollectionByAgentIdsResponse (..),
    newStartDataCollectionByAgentIdsResponse,

    -- * Response Lenses
    startDataCollectionByAgentIdsResponse_agentsConfigurationStatus,
    startDataCollectionByAgentIdsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Discovery.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newStartDataCollectionByAgentIds' smart constructor.
data StartDataCollectionByAgentIds = StartDataCollectionByAgentIds'
  { -- | The IDs of the agents or connectors from which to start collecting data.
    -- If you send a request to an agent\/connector ID that you do not have
    -- permission to contact, according to your Amazon Web Services account,
    -- the service does not throw an exception. Instead, it returns the error
    -- in the /Description/ field. If you send a request to multiple
    -- agents\/connectors and you do not have permission to contact some of
    -- those agents\/connectors, the system does not throw an exception.
    -- Instead, the system shows @Failed@ in the /Description/ field.
    StartDataCollectionByAgentIds -> [Text]
agentIds :: [Prelude.Text]
  }
  deriving (StartDataCollectionByAgentIds
-> StartDataCollectionByAgentIds -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartDataCollectionByAgentIds
-> StartDataCollectionByAgentIds -> Bool
$c/= :: StartDataCollectionByAgentIds
-> StartDataCollectionByAgentIds -> Bool
== :: StartDataCollectionByAgentIds
-> StartDataCollectionByAgentIds -> Bool
$c== :: StartDataCollectionByAgentIds
-> StartDataCollectionByAgentIds -> Bool
Prelude.Eq, ReadPrec [StartDataCollectionByAgentIds]
ReadPrec StartDataCollectionByAgentIds
Int -> ReadS StartDataCollectionByAgentIds
ReadS [StartDataCollectionByAgentIds]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartDataCollectionByAgentIds]
$creadListPrec :: ReadPrec [StartDataCollectionByAgentIds]
readPrec :: ReadPrec StartDataCollectionByAgentIds
$creadPrec :: ReadPrec StartDataCollectionByAgentIds
readList :: ReadS [StartDataCollectionByAgentIds]
$creadList :: ReadS [StartDataCollectionByAgentIds]
readsPrec :: Int -> ReadS StartDataCollectionByAgentIds
$creadsPrec :: Int -> ReadS StartDataCollectionByAgentIds
Prelude.Read, Int -> StartDataCollectionByAgentIds -> ShowS
[StartDataCollectionByAgentIds] -> ShowS
StartDataCollectionByAgentIds -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartDataCollectionByAgentIds] -> ShowS
$cshowList :: [StartDataCollectionByAgentIds] -> ShowS
show :: StartDataCollectionByAgentIds -> String
$cshow :: StartDataCollectionByAgentIds -> String
showsPrec :: Int -> StartDataCollectionByAgentIds -> ShowS
$cshowsPrec :: Int -> StartDataCollectionByAgentIds -> ShowS
Prelude.Show, forall x.
Rep StartDataCollectionByAgentIds x
-> StartDataCollectionByAgentIds
forall x.
StartDataCollectionByAgentIds
-> Rep StartDataCollectionByAgentIds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartDataCollectionByAgentIds x
-> StartDataCollectionByAgentIds
$cfrom :: forall x.
StartDataCollectionByAgentIds
-> Rep StartDataCollectionByAgentIds x
Prelude.Generic)

-- |
-- Create a value of 'StartDataCollectionByAgentIds' 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:
--
-- 'agentIds', 'startDataCollectionByAgentIds_agentIds' - The IDs of the agents or connectors from which to start collecting data.
-- If you send a request to an agent\/connector ID that you do not have
-- permission to contact, according to your Amazon Web Services account,
-- the service does not throw an exception. Instead, it returns the error
-- in the /Description/ field. If you send a request to multiple
-- agents\/connectors and you do not have permission to contact some of
-- those agents\/connectors, the system does not throw an exception.
-- Instead, the system shows @Failed@ in the /Description/ field.
newStartDataCollectionByAgentIds ::
  StartDataCollectionByAgentIds
newStartDataCollectionByAgentIds :: StartDataCollectionByAgentIds
newStartDataCollectionByAgentIds =
  StartDataCollectionByAgentIds'
    { $sel:agentIds:StartDataCollectionByAgentIds' :: [Text]
agentIds =
        forall a. Monoid a => a
Prelude.mempty
    }

-- | The IDs of the agents or connectors from which to start collecting data.
-- If you send a request to an agent\/connector ID that you do not have
-- permission to contact, according to your Amazon Web Services account,
-- the service does not throw an exception. Instead, it returns the error
-- in the /Description/ field. If you send a request to multiple
-- agents\/connectors and you do not have permission to contact some of
-- those agents\/connectors, the system does not throw an exception.
-- Instead, the system shows @Failed@ in the /Description/ field.
startDataCollectionByAgentIds_agentIds :: Lens.Lens' StartDataCollectionByAgentIds [Prelude.Text]
startDataCollectionByAgentIds_agentIds :: Lens' StartDataCollectionByAgentIds [Text]
startDataCollectionByAgentIds_agentIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDataCollectionByAgentIds' {[Text]
agentIds :: [Text]
$sel:agentIds:StartDataCollectionByAgentIds' :: StartDataCollectionByAgentIds -> [Text]
agentIds} -> [Text]
agentIds) (\s :: StartDataCollectionByAgentIds
s@StartDataCollectionByAgentIds' {} [Text]
a -> StartDataCollectionByAgentIds
s {$sel:agentIds:StartDataCollectionByAgentIds' :: [Text]
agentIds = [Text]
a} :: StartDataCollectionByAgentIds) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Core.AWSRequest
    StartDataCollectionByAgentIds
  where
  type
    AWSResponse StartDataCollectionByAgentIds =
      StartDataCollectionByAgentIdsResponse
  request :: (Service -> Service)
-> StartDataCollectionByAgentIds
-> Request StartDataCollectionByAgentIds
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StartDataCollectionByAgentIds
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartDataCollectionByAgentIds)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [AgentConfigurationStatus]
-> Int -> StartDataCollectionByAgentIdsResponse
StartDataCollectionByAgentIdsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"agentsConfigurationStatus"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    StartDataCollectionByAgentIds
  where
  hashWithSalt :: Int -> StartDataCollectionByAgentIds -> Int
hashWithSalt Int
_salt StartDataCollectionByAgentIds' {[Text]
agentIds :: [Text]
$sel:agentIds:StartDataCollectionByAgentIds' :: StartDataCollectionByAgentIds -> [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
agentIds

instance Prelude.NFData StartDataCollectionByAgentIds where
  rnf :: StartDataCollectionByAgentIds -> ()
rnf StartDataCollectionByAgentIds' {[Text]
agentIds :: [Text]
$sel:agentIds:StartDataCollectionByAgentIds' :: StartDataCollectionByAgentIds -> [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf [Text]
agentIds

instance Data.ToHeaders StartDataCollectionByAgentIds where
  toHeaders :: StartDataCollectionByAgentIds -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSPoseidonService_V2015_11_01.StartDataCollectionByAgentIds" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StartDataCollectionByAgentIds where
  toJSON :: StartDataCollectionByAgentIds -> Value
toJSON StartDataCollectionByAgentIds' {[Text]
agentIds :: [Text]
$sel:agentIds:StartDataCollectionByAgentIds' :: StartDataCollectionByAgentIds -> [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"agentIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
agentIds)]
      )

instance Data.ToPath StartDataCollectionByAgentIds where
  toPath :: StartDataCollectionByAgentIds -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newStartDataCollectionByAgentIdsResponse' smart constructor.
data StartDataCollectionByAgentIdsResponse = StartDataCollectionByAgentIdsResponse'
  { -- | Information about agents or the connector that were instructed to start
    -- collecting data. Information includes the agent\/connector ID, a
    -- description of the operation performed, and whether the agent\/connector
    -- configuration was updated.
    StartDataCollectionByAgentIdsResponse
-> Maybe [AgentConfigurationStatus]
agentsConfigurationStatus :: Prelude.Maybe [AgentConfigurationStatus],
    -- | The response's http status code.
    StartDataCollectionByAgentIdsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartDataCollectionByAgentIdsResponse
-> StartDataCollectionByAgentIdsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartDataCollectionByAgentIdsResponse
-> StartDataCollectionByAgentIdsResponse -> Bool
$c/= :: StartDataCollectionByAgentIdsResponse
-> StartDataCollectionByAgentIdsResponse -> Bool
== :: StartDataCollectionByAgentIdsResponse
-> StartDataCollectionByAgentIdsResponse -> Bool
$c== :: StartDataCollectionByAgentIdsResponse
-> StartDataCollectionByAgentIdsResponse -> Bool
Prelude.Eq, ReadPrec [StartDataCollectionByAgentIdsResponse]
ReadPrec StartDataCollectionByAgentIdsResponse
Int -> ReadS StartDataCollectionByAgentIdsResponse
ReadS [StartDataCollectionByAgentIdsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartDataCollectionByAgentIdsResponse]
$creadListPrec :: ReadPrec [StartDataCollectionByAgentIdsResponse]
readPrec :: ReadPrec StartDataCollectionByAgentIdsResponse
$creadPrec :: ReadPrec StartDataCollectionByAgentIdsResponse
readList :: ReadS [StartDataCollectionByAgentIdsResponse]
$creadList :: ReadS [StartDataCollectionByAgentIdsResponse]
readsPrec :: Int -> ReadS StartDataCollectionByAgentIdsResponse
$creadsPrec :: Int -> ReadS StartDataCollectionByAgentIdsResponse
Prelude.Read, Int -> StartDataCollectionByAgentIdsResponse -> ShowS
[StartDataCollectionByAgentIdsResponse] -> ShowS
StartDataCollectionByAgentIdsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartDataCollectionByAgentIdsResponse] -> ShowS
$cshowList :: [StartDataCollectionByAgentIdsResponse] -> ShowS
show :: StartDataCollectionByAgentIdsResponse -> String
$cshow :: StartDataCollectionByAgentIdsResponse -> String
showsPrec :: Int -> StartDataCollectionByAgentIdsResponse -> ShowS
$cshowsPrec :: Int -> StartDataCollectionByAgentIdsResponse -> ShowS
Prelude.Show, forall x.
Rep StartDataCollectionByAgentIdsResponse x
-> StartDataCollectionByAgentIdsResponse
forall x.
StartDataCollectionByAgentIdsResponse
-> Rep StartDataCollectionByAgentIdsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartDataCollectionByAgentIdsResponse x
-> StartDataCollectionByAgentIdsResponse
$cfrom :: forall x.
StartDataCollectionByAgentIdsResponse
-> Rep StartDataCollectionByAgentIdsResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartDataCollectionByAgentIdsResponse' 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:
--
-- 'agentsConfigurationStatus', 'startDataCollectionByAgentIdsResponse_agentsConfigurationStatus' - Information about agents or the connector that were instructed to start
-- collecting data. Information includes the agent\/connector ID, a
-- description of the operation performed, and whether the agent\/connector
-- configuration was updated.
--
-- 'httpStatus', 'startDataCollectionByAgentIdsResponse_httpStatus' - The response's http status code.
newStartDataCollectionByAgentIdsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartDataCollectionByAgentIdsResponse
newStartDataCollectionByAgentIdsResponse :: Int -> StartDataCollectionByAgentIdsResponse
newStartDataCollectionByAgentIdsResponse Int
pHttpStatus_ =
  StartDataCollectionByAgentIdsResponse'
    { $sel:agentsConfigurationStatus:StartDataCollectionByAgentIdsResponse' :: Maybe [AgentConfigurationStatus]
agentsConfigurationStatus =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartDataCollectionByAgentIdsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about agents or the connector that were instructed to start
-- collecting data. Information includes the agent\/connector ID, a
-- description of the operation performed, and whether the agent\/connector
-- configuration was updated.
startDataCollectionByAgentIdsResponse_agentsConfigurationStatus :: Lens.Lens' StartDataCollectionByAgentIdsResponse (Prelude.Maybe [AgentConfigurationStatus])
startDataCollectionByAgentIdsResponse_agentsConfigurationStatus :: Lens'
  StartDataCollectionByAgentIdsResponse
  (Maybe [AgentConfigurationStatus])
startDataCollectionByAgentIdsResponse_agentsConfigurationStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDataCollectionByAgentIdsResponse' {Maybe [AgentConfigurationStatus]
agentsConfigurationStatus :: Maybe [AgentConfigurationStatus]
$sel:agentsConfigurationStatus:StartDataCollectionByAgentIdsResponse' :: StartDataCollectionByAgentIdsResponse
-> Maybe [AgentConfigurationStatus]
agentsConfigurationStatus} -> Maybe [AgentConfigurationStatus]
agentsConfigurationStatus) (\s :: StartDataCollectionByAgentIdsResponse
s@StartDataCollectionByAgentIdsResponse' {} Maybe [AgentConfigurationStatus]
a -> StartDataCollectionByAgentIdsResponse
s {$sel:agentsConfigurationStatus:StartDataCollectionByAgentIdsResponse' :: Maybe [AgentConfigurationStatus]
agentsConfigurationStatus = Maybe [AgentConfigurationStatus]
a} :: StartDataCollectionByAgentIdsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    StartDataCollectionByAgentIdsResponse
  where
  rnf :: StartDataCollectionByAgentIdsResponse -> ()
rnf StartDataCollectionByAgentIdsResponse' {Int
Maybe [AgentConfigurationStatus]
httpStatus :: Int
agentsConfigurationStatus :: Maybe [AgentConfigurationStatus]
$sel:httpStatus:StartDataCollectionByAgentIdsResponse' :: StartDataCollectionByAgentIdsResponse -> Int
$sel:agentsConfigurationStatus:StartDataCollectionByAgentIdsResponse' :: StartDataCollectionByAgentIdsResponse
-> Maybe [AgentConfigurationStatus]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AgentConfigurationStatus]
agentsConfigurationStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus