{-# 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.XRay.PutTelemetryRecords
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Used by the Amazon Web Services X-Ray daemon to upload telemetry.
module Amazonka.XRay.PutTelemetryRecords
  ( -- * Creating a Request
    PutTelemetryRecords (..),
    newPutTelemetryRecords,

    -- * Request Lenses
    putTelemetryRecords_eC2InstanceId,
    putTelemetryRecords_hostname,
    putTelemetryRecords_resourceARN,
    putTelemetryRecords_telemetryRecords,

    -- * Destructuring the Response
    PutTelemetryRecordsResponse (..),
    newPutTelemetryRecordsResponse,

    -- * Response Lenses
    putTelemetryRecordsResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'PutTelemetryRecords' 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:
--
-- 'eC2InstanceId', 'putTelemetryRecords_eC2InstanceId' -
--
-- 'hostname', 'putTelemetryRecords_hostname' -
--
-- 'resourceARN', 'putTelemetryRecords_resourceARN' -
--
-- 'telemetryRecords', 'putTelemetryRecords_telemetryRecords' -
newPutTelemetryRecords ::
  PutTelemetryRecords
newPutTelemetryRecords :: PutTelemetryRecords
newPutTelemetryRecords =
  PutTelemetryRecords'
    { $sel:eC2InstanceId:PutTelemetryRecords' :: Maybe Text
eC2InstanceId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:hostname:PutTelemetryRecords' :: Maybe Text
hostname = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceARN:PutTelemetryRecords' :: Maybe Text
resourceARN = forall a. Maybe a
Prelude.Nothing,
      $sel:telemetryRecords:PutTelemetryRecords' :: [TelemetryRecord]
telemetryRecords = forall a. Monoid a => a
Prelude.mempty
    }

putTelemetryRecords_eC2InstanceId :: Lens.Lens' PutTelemetryRecords (Prelude.Maybe Prelude.Text)
putTelemetryRecords_eC2InstanceId :: Lens' PutTelemetryRecords (Maybe Text)
putTelemetryRecords_eC2InstanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTelemetryRecords' {Maybe Text
eC2InstanceId :: Maybe Text
$sel:eC2InstanceId:PutTelemetryRecords' :: PutTelemetryRecords -> Maybe Text
eC2InstanceId} -> Maybe Text
eC2InstanceId) (\s :: PutTelemetryRecords
s@PutTelemetryRecords' {} Maybe Text
a -> PutTelemetryRecords
s {$sel:eC2InstanceId:PutTelemetryRecords' :: Maybe Text
eC2InstanceId = Maybe Text
a} :: PutTelemetryRecords)

putTelemetryRecords_hostname :: Lens.Lens' PutTelemetryRecords (Prelude.Maybe Prelude.Text)
putTelemetryRecords_hostname :: Lens' PutTelemetryRecords (Maybe Text)
putTelemetryRecords_hostname = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTelemetryRecords' {Maybe Text
hostname :: Maybe Text
$sel:hostname:PutTelemetryRecords' :: PutTelemetryRecords -> Maybe Text
hostname} -> Maybe Text
hostname) (\s :: PutTelemetryRecords
s@PutTelemetryRecords' {} Maybe Text
a -> PutTelemetryRecords
s {$sel:hostname:PutTelemetryRecords' :: Maybe Text
hostname = Maybe Text
a} :: PutTelemetryRecords)

putTelemetryRecords_resourceARN :: Lens.Lens' PutTelemetryRecords (Prelude.Maybe Prelude.Text)
putTelemetryRecords_resourceARN :: Lens' PutTelemetryRecords (Maybe Text)
putTelemetryRecords_resourceARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTelemetryRecords' {Maybe Text
resourceARN :: Maybe Text
$sel:resourceARN:PutTelemetryRecords' :: PutTelemetryRecords -> Maybe Text
resourceARN} -> Maybe Text
resourceARN) (\s :: PutTelemetryRecords
s@PutTelemetryRecords' {} Maybe Text
a -> PutTelemetryRecords
s {$sel:resourceARN:PutTelemetryRecords' :: Maybe Text
resourceARN = Maybe Text
a} :: PutTelemetryRecords)

putTelemetryRecords_telemetryRecords :: Lens.Lens' PutTelemetryRecords [TelemetryRecord]
putTelemetryRecords_telemetryRecords :: Lens' PutTelemetryRecords [TelemetryRecord]
putTelemetryRecords_telemetryRecords = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTelemetryRecords' {[TelemetryRecord]
telemetryRecords :: [TelemetryRecord]
$sel:telemetryRecords:PutTelemetryRecords' :: PutTelemetryRecords -> [TelemetryRecord]
telemetryRecords} -> [TelemetryRecord]
telemetryRecords) (\s :: PutTelemetryRecords
s@PutTelemetryRecords' {} [TelemetryRecord]
a -> PutTelemetryRecords
s {$sel:telemetryRecords:PutTelemetryRecords' :: [TelemetryRecord]
telemetryRecords = [TelemetryRecord]
a} :: PutTelemetryRecords) 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 PutTelemetryRecords where
  type
    AWSResponse PutTelemetryRecords =
      PutTelemetryRecordsResponse
  request :: (Service -> Service)
-> PutTelemetryRecords -> Request PutTelemetryRecords
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 PutTelemetryRecords
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutTelemetryRecords)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutTelemetryRecordsResponse
PutTelemetryRecordsResponse'
            forall (f :: * -> *) a b. Functor 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 PutTelemetryRecords where
  hashWithSalt :: Int -> PutTelemetryRecords -> Int
hashWithSalt Int
_salt PutTelemetryRecords' {[TelemetryRecord]
Maybe Text
telemetryRecords :: [TelemetryRecord]
resourceARN :: Maybe Text
hostname :: Maybe Text
eC2InstanceId :: Maybe Text
$sel:telemetryRecords:PutTelemetryRecords' :: PutTelemetryRecords -> [TelemetryRecord]
$sel:resourceARN:PutTelemetryRecords' :: PutTelemetryRecords -> Maybe Text
$sel:hostname:PutTelemetryRecords' :: PutTelemetryRecords -> Maybe Text
$sel:eC2InstanceId:PutTelemetryRecords' :: PutTelemetryRecords -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
eC2InstanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hostname
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [TelemetryRecord]
telemetryRecords

instance Prelude.NFData PutTelemetryRecords where
  rnf :: PutTelemetryRecords -> ()
rnf PutTelemetryRecords' {[TelemetryRecord]
Maybe Text
telemetryRecords :: [TelemetryRecord]
resourceARN :: Maybe Text
hostname :: Maybe Text
eC2InstanceId :: Maybe Text
$sel:telemetryRecords:PutTelemetryRecords' :: PutTelemetryRecords -> [TelemetryRecord]
$sel:resourceARN:PutTelemetryRecords' :: PutTelemetryRecords -> Maybe Text
$sel:hostname:PutTelemetryRecords' :: PutTelemetryRecords -> Maybe Text
$sel:eC2InstanceId:PutTelemetryRecords' :: PutTelemetryRecords -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eC2InstanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hostname
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [TelemetryRecord]
telemetryRecords

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

instance Data.ToJSON PutTelemetryRecords where
  toJSON :: PutTelemetryRecords -> Value
toJSON PutTelemetryRecords' {[TelemetryRecord]
Maybe Text
telemetryRecords :: [TelemetryRecord]
resourceARN :: Maybe Text
hostname :: Maybe Text
eC2InstanceId :: Maybe Text
$sel:telemetryRecords:PutTelemetryRecords' :: PutTelemetryRecords -> [TelemetryRecord]
$sel:resourceARN:PutTelemetryRecords' :: PutTelemetryRecords -> Maybe Text
$sel:hostname:PutTelemetryRecords' :: PutTelemetryRecords -> Maybe Text
$sel:eC2InstanceId:PutTelemetryRecords' :: PutTelemetryRecords -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EC2InstanceId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
eC2InstanceId,
            (Key
"Hostname" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
hostname,
            (Key
"ResourceARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceARN,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"TelemetryRecords" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [TelemetryRecord]
telemetryRecords)
          ]
      )

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

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

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

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

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

instance Prelude.NFData PutTelemetryRecordsResponse where
  rnf :: PutTelemetryRecordsResponse -> ()
rnf PutTelemetryRecordsResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutTelemetryRecordsResponse' :: PutTelemetryRecordsResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus