{-# 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.Inspector.GetTelemetryMetadata
-- 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)
--
-- Information about the data that is collected for the specified
-- assessment run.
module Amazonka.Inspector.GetTelemetryMetadata
  ( -- * Creating a Request
    GetTelemetryMetadata (..),
    newGetTelemetryMetadata,

    -- * Request Lenses
    getTelemetryMetadata_assessmentRunArn,

    -- * Destructuring the Response
    GetTelemetryMetadataResponse (..),
    newGetTelemetryMetadataResponse,

    -- * Response Lenses
    getTelemetryMetadataResponse_httpStatus,
    getTelemetryMetadataResponse_telemetryMetadata,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Inspector.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:/ 'newGetTelemetryMetadata' smart constructor.
data GetTelemetryMetadata = GetTelemetryMetadata'
  { -- | The ARN that specifies the assessment run that has the telemetry data
    -- that you want to obtain.
    GetTelemetryMetadata -> Text
assessmentRunArn :: Prelude.Text
  }
  deriving (GetTelemetryMetadata -> GetTelemetryMetadata -> Bool
(GetTelemetryMetadata -> GetTelemetryMetadata -> Bool)
-> (GetTelemetryMetadata -> GetTelemetryMetadata -> Bool)
-> Eq GetTelemetryMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTelemetryMetadata -> GetTelemetryMetadata -> Bool
$c/= :: GetTelemetryMetadata -> GetTelemetryMetadata -> Bool
== :: GetTelemetryMetadata -> GetTelemetryMetadata -> Bool
$c== :: GetTelemetryMetadata -> GetTelemetryMetadata -> Bool
Prelude.Eq, ReadPrec [GetTelemetryMetadata]
ReadPrec GetTelemetryMetadata
Int -> ReadS GetTelemetryMetadata
ReadS [GetTelemetryMetadata]
(Int -> ReadS GetTelemetryMetadata)
-> ReadS [GetTelemetryMetadata]
-> ReadPrec GetTelemetryMetadata
-> ReadPrec [GetTelemetryMetadata]
-> Read GetTelemetryMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTelemetryMetadata]
$creadListPrec :: ReadPrec [GetTelemetryMetadata]
readPrec :: ReadPrec GetTelemetryMetadata
$creadPrec :: ReadPrec GetTelemetryMetadata
readList :: ReadS [GetTelemetryMetadata]
$creadList :: ReadS [GetTelemetryMetadata]
readsPrec :: Int -> ReadS GetTelemetryMetadata
$creadsPrec :: Int -> ReadS GetTelemetryMetadata
Prelude.Read, Int -> GetTelemetryMetadata -> ShowS
[GetTelemetryMetadata] -> ShowS
GetTelemetryMetadata -> String
(Int -> GetTelemetryMetadata -> ShowS)
-> (GetTelemetryMetadata -> String)
-> ([GetTelemetryMetadata] -> ShowS)
-> Show GetTelemetryMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTelemetryMetadata] -> ShowS
$cshowList :: [GetTelemetryMetadata] -> ShowS
show :: GetTelemetryMetadata -> String
$cshow :: GetTelemetryMetadata -> String
showsPrec :: Int -> GetTelemetryMetadata -> ShowS
$cshowsPrec :: Int -> GetTelemetryMetadata -> ShowS
Prelude.Show, (forall x. GetTelemetryMetadata -> Rep GetTelemetryMetadata x)
-> (forall x. Rep GetTelemetryMetadata x -> GetTelemetryMetadata)
-> Generic GetTelemetryMetadata
forall x. Rep GetTelemetryMetadata x -> GetTelemetryMetadata
forall x. GetTelemetryMetadata -> Rep GetTelemetryMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetTelemetryMetadata x -> GetTelemetryMetadata
$cfrom :: forall x. GetTelemetryMetadata -> Rep GetTelemetryMetadata x
Prelude.Generic)

-- |
-- Create a value of 'GetTelemetryMetadata' 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:
--
-- 'assessmentRunArn', 'getTelemetryMetadata_assessmentRunArn' - The ARN that specifies the assessment run that has the telemetry data
-- that you want to obtain.
newGetTelemetryMetadata ::
  -- | 'assessmentRunArn'
  Prelude.Text ->
  GetTelemetryMetadata
newGetTelemetryMetadata :: Text -> GetTelemetryMetadata
newGetTelemetryMetadata Text
pAssessmentRunArn_ =
  GetTelemetryMetadata' :: Text -> GetTelemetryMetadata
GetTelemetryMetadata'
    { $sel:assessmentRunArn:GetTelemetryMetadata' :: Text
assessmentRunArn =
        Text
pAssessmentRunArn_
    }

-- | The ARN that specifies the assessment run that has the telemetry data
-- that you want to obtain.
getTelemetryMetadata_assessmentRunArn :: Lens.Lens' GetTelemetryMetadata Prelude.Text
getTelemetryMetadata_assessmentRunArn :: (Text -> f Text) -> GetTelemetryMetadata -> f GetTelemetryMetadata
getTelemetryMetadata_assessmentRunArn = (GetTelemetryMetadata -> Text)
-> (GetTelemetryMetadata -> Text -> GetTelemetryMetadata)
-> Lens GetTelemetryMetadata GetTelemetryMetadata Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTelemetryMetadata' {Text
assessmentRunArn :: Text
$sel:assessmentRunArn:GetTelemetryMetadata' :: GetTelemetryMetadata -> Text
assessmentRunArn} -> Text
assessmentRunArn) (\s :: GetTelemetryMetadata
s@GetTelemetryMetadata' {} Text
a -> GetTelemetryMetadata
s {$sel:assessmentRunArn:GetTelemetryMetadata' :: Text
assessmentRunArn = Text
a} :: GetTelemetryMetadata)

instance Core.AWSRequest GetTelemetryMetadata where
  type
    AWSResponse GetTelemetryMetadata =
      GetTelemetryMetadataResponse
  request :: GetTelemetryMetadata -> Request GetTelemetryMetadata
request = Service -> GetTelemetryMetadata -> Request GetTelemetryMetadata
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetTelemetryMetadata
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetTelemetryMetadata)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetTelemetryMetadata))
-> Logger
-> Service
-> Proxy GetTelemetryMetadata
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetTelemetryMetadata)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> [TelemetryMetadata] -> GetTelemetryMetadataResponse
GetTelemetryMetadataResponse'
            (Int -> [TelemetryMetadata] -> GetTelemetryMetadataResponse)
-> Either String Int
-> Either
     String ([TelemetryMetadata] -> GetTelemetryMetadataResponse)
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))
            Either String ([TelemetryMetadata] -> GetTelemetryMetadataResponse)
-> Either String [TelemetryMetadata]
-> Either String GetTelemetryMetadataResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe [TelemetryMetadata])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"telemetryMetadata"
                            Either String (Maybe [TelemetryMetadata])
-> [TelemetryMetadata] -> Either String [TelemetryMetadata]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [TelemetryMetadata]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable GetTelemetryMetadata

instance Prelude.NFData GetTelemetryMetadata

instance Core.ToHeaders GetTelemetryMetadata where
  toHeaders :: GetTelemetryMetadata -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetTelemetryMetadata -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"InspectorService.GetTelemetryMetadata" ::
                          Prelude.ByteString
                      ),
            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 GetTelemetryMetadata where
  toJSON :: GetTelemetryMetadata -> Value
toJSON GetTelemetryMetadata' {Text
assessmentRunArn :: Text
$sel:assessmentRunArn:GetTelemetryMetadata' :: GetTelemetryMetadata -> 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
"assessmentRunArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
assessmentRunArn)
          ]
      )

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

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

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

-- |
-- Create a value of 'GetTelemetryMetadataResponse' 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', 'getTelemetryMetadataResponse_httpStatus' - The response's http status code.
--
-- 'telemetryMetadata', 'getTelemetryMetadataResponse_telemetryMetadata' - Telemetry details.
newGetTelemetryMetadataResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetTelemetryMetadataResponse
newGetTelemetryMetadataResponse :: Int -> GetTelemetryMetadataResponse
newGetTelemetryMetadataResponse Int
pHttpStatus_ =
  GetTelemetryMetadataResponse' :: Int -> [TelemetryMetadata] -> GetTelemetryMetadataResponse
GetTelemetryMetadataResponse'
    { $sel:httpStatus:GetTelemetryMetadataResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:telemetryMetadata:GetTelemetryMetadataResponse' :: [TelemetryMetadata]
telemetryMetadata = [TelemetryMetadata]
forall a. Monoid a => a
Prelude.mempty
    }

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

-- | Telemetry details.
getTelemetryMetadataResponse_telemetryMetadata :: Lens.Lens' GetTelemetryMetadataResponse [TelemetryMetadata]
getTelemetryMetadataResponse_telemetryMetadata :: ([TelemetryMetadata] -> f [TelemetryMetadata])
-> GetTelemetryMetadataResponse -> f GetTelemetryMetadataResponse
getTelemetryMetadataResponse_telemetryMetadata = (GetTelemetryMetadataResponse -> [TelemetryMetadata])
-> (GetTelemetryMetadataResponse
    -> [TelemetryMetadata] -> GetTelemetryMetadataResponse)
-> Lens
     GetTelemetryMetadataResponse
     GetTelemetryMetadataResponse
     [TelemetryMetadata]
     [TelemetryMetadata]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTelemetryMetadataResponse' {[TelemetryMetadata]
telemetryMetadata :: [TelemetryMetadata]
$sel:telemetryMetadata:GetTelemetryMetadataResponse' :: GetTelemetryMetadataResponse -> [TelemetryMetadata]
telemetryMetadata} -> [TelemetryMetadata]
telemetryMetadata) (\s :: GetTelemetryMetadataResponse
s@GetTelemetryMetadataResponse' {} [TelemetryMetadata]
a -> GetTelemetryMetadataResponse
s {$sel:telemetryMetadata:GetTelemetryMetadataResponse' :: [TelemetryMetadata]
telemetryMetadata = [TelemetryMetadata]
a} :: GetTelemetryMetadataResponse) (([TelemetryMetadata] -> f [TelemetryMetadata])
 -> GetTelemetryMetadataResponse -> f GetTelemetryMetadataResponse)
-> (([TelemetryMetadata] -> f [TelemetryMetadata])
    -> [TelemetryMetadata] -> f [TelemetryMetadata])
-> ([TelemetryMetadata] -> f [TelemetryMetadata])
-> GetTelemetryMetadataResponse
-> f GetTelemetryMetadataResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([TelemetryMetadata] -> f [TelemetryMetadata])
-> [TelemetryMetadata] -> f [TelemetryMetadata]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData GetTelemetryMetadataResponse