packages feed

amazonka-guardduty-2.0: gen/Amazonka/GuardDuty/DescribeMalwareScans.hs

{-# 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.GuardDuty.DescribeMalwareScans
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of malware scans. Each member account can view the
-- malware scans for their own accounts. An administrator can view the
-- malware scans for all the member accounts.
--
-- This operation returns paginated results.
module Amazonka.GuardDuty.DescribeMalwareScans
  ( -- * Creating a Request
    DescribeMalwareScans (..),
    newDescribeMalwareScans,

    -- * Request Lenses
    describeMalwareScans_filterCriteria,
    describeMalwareScans_maxResults,
    describeMalwareScans_nextToken,
    describeMalwareScans_sortCriteria,
    describeMalwareScans_detectorId,

    -- * Destructuring the Response
    DescribeMalwareScansResponse (..),
    newDescribeMalwareScansResponse,

    -- * Response Lenses
    describeMalwareScansResponse_nextToken,
    describeMalwareScansResponse_httpStatus,
    describeMalwareScansResponse_scans,
  )
where

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

-- | /See:/ 'newDescribeMalwareScans' smart constructor.
data DescribeMalwareScans = DescribeMalwareScans'
  { -- | Represents the criteria to be used in the filter for describing scan
    -- entries.
    filterCriteria :: Prelude.Maybe FilterCriteria,
    -- | You can use this parameter to indicate the maximum number of items that
    -- you want in the response. The default value is 50. The maximum value is
    -- 50.
    maxResults :: Prelude.Maybe Prelude.Natural,
    -- | You can use this parameter when paginating results. Set the value of
    -- this parameter to null on your first call to the list action. For
    -- subsequent calls to the action, fill nextToken in the request with the
    -- value of NextToken from the previous response to continue listing data.
    nextToken :: Prelude.Maybe Prelude.Text,
    -- | Represents the criteria used for sorting scan entries.
    sortCriteria :: Prelude.Maybe SortCriteria,
    -- | The unique ID of the detector that the request is associated with.
    detectorId :: Prelude.Text
  }
  deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)

-- |
-- Create a value of 'DescribeMalwareScans' 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:
--
-- 'filterCriteria', 'describeMalwareScans_filterCriteria' - Represents the criteria to be used in the filter for describing scan
-- entries.
--
-- 'maxResults', 'describeMalwareScans_maxResults' - You can use this parameter to indicate the maximum number of items that
-- you want in the response. The default value is 50. The maximum value is
-- 50.
--
-- 'nextToken', 'describeMalwareScans_nextToken' - You can use this parameter when paginating results. Set the value of
-- this parameter to null on your first call to the list action. For
-- subsequent calls to the action, fill nextToken in the request with the
-- value of NextToken from the previous response to continue listing data.
--
-- 'sortCriteria', 'describeMalwareScans_sortCriteria' - Represents the criteria used for sorting scan entries.
--
-- 'detectorId', 'describeMalwareScans_detectorId' - The unique ID of the detector that the request is associated with.
newDescribeMalwareScans ::
  -- | 'detectorId'
  Prelude.Text ->
  DescribeMalwareScans
newDescribeMalwareScans pDetectorId_ =
  DescribeMalwareScans'
    { filterCriteria =
        Prelude.Nothing,
      maxResults = Prelude.Nothing,
      nextToken = Prelude.Nothing,
      sortCriteria = Prelude.Nothing,
      detectorId = pDetectorId_
    }

-- | Represents the criteria to be used in the filter for describing scan
-- entries.
describeMalwareScans_filterCriteria :: Lens.Lens' DescribeMalwareScans (Prelude.Maybe FilterCriteria)
describeMalwareScans_filterCriteria = Lens.lens (\DescribeMalwareScans' {filterCriteria} -> filterCriteria) (\s@DescribeMalwareScans' {} a -> s {filterCriteria = a} :: DescribeMalwareScans)

-- | You can use this parameter to indicate the maximum number of items that
-- you want in the response. The default value is 50. The maximum value is
-- 50.
describeMalwareScans_maxResults :: Lens.Lens' DescribeMalwareScans (Prelude.Maybe Prelude.Natural)
describeMalwareScans_maxResults = Lens.lens (\DescribeMalwareScans' {maxResults} -> maxResults) (\s@DescribeMalwareScans' {} a -> s {maxResults = a} :: DescribeMalwareScans)

-- | You can use this parameter when paginating results. Set the value of
-- this parameter to null on your first call to the list action. For
-- subsequent calls to the action, fill nextToken in the request with the
-- value of NextToken from the previous response to continue listing data.
describeMalwareScans_nextToken :: Lens.Lens' DescribeMalwareScans (Prelude.Maybe Prelude.Text)
describeMalwareScans_nextToken = Lens.lens (\DescribeMalwareScans' {nextToken} -> nextToken) (\s@DescribeMalwareScans' {} a -> s {nextToken = a} :: DescribeMalwareScans)

-- | Represents the criteria used for sorting scan entries.
describeMalwareScans_sortCriteria :: Lens.Lens' DescribeMalwareScans (Prelude.Maybe SortCriteria)
describeMalwareScans_sortCriteria = Lens.lens (\DescribeMalwareScans' {sortCriteria} -> sortCriteria) (\s@DescribeMalwareScans' {} a -> s {sortCriteria = a} :: DescribeMalwareScans)

-- | The unique ID of the detector that the request is associated with.
describeMalwareScans_detectorId :: Lens.Lens' DescribeMalwareScans Prelude.Text
describeMalwareScans_detectorId = Lens.lens (\DescribeMalwareScans' {detectorId} -> detectorId) (\s@DescribeMalwareScans' {} a -> s {detectorId = a} :: DescribeMalwareScans)

instance Core.AWSPager DescribeMalwareScans where
  page rq rs
    | Core.stop
        ( rs
            Lens.^? describeMalwareScansResponse_nextToken
            Prelude.. Lens._Just
        ) =
        Prelude.Nothing
    | Core.stop
        (rs Lens.^. describeMalwareScansResponse_scans) =
        Prelude.Nothing
    | Prelude.otherwise =
        Prelude.Just
          Prelude.$ rq
          Prelude.& describeMalwareScans_nextToken
          Lens..~ rs
          Lens.^? describeMalwareScansResponse_nextToken
          Prelude.. Lens._Just

instance Core.AWSRequest DescribeMalwareScans where
  type
    AWSResponse DescribeMalwareScans =
      DescribeMalwareScansResponse
  request overrides =
    Request.postJSON (overrides defaultService)
  response =
    Response.receiveJSON
      ( \s h x ->
          DescribeMalwareScansResponse'
            Prelude.<$> (x Data..?> "nextToken")
            Prelude.<*> (Prelude.pure (Prelude.fromEnum s))
            Prelude.<*> (x Data..?> "scans" Core..!@ Prelude.mempty)
      )

instance Prelude.Hashable DescribeMalwareScans where
  hashWithSalt _salt DescribeMalwareScans' {..} =
    _salt
      `Prelude.hashWithSalt` filterCriteria
      `Prelude.hashWithSalt` maxResults
      `Prelude.hashWithSalt` nextToken
      `Prelude.hashWithSalt` sortCriteria
      `Prelude.hashWithSalt` detectorId

instance Prelude.NFData DescribeMalwareScans where
  rnf DescribeMalwareScans' {..} =
    Prelude.rnf filterCriteria
      `Prelude.seq` Prelude.rnf maxResults
      `Prelude.seq` Prelude.rnf nextToken
      `Prelude.seq` Prelude.rnf sortCriteria
      `Prelude.seq` Prelude.rnf detectorId

instance Data.ToHeaders DescribeMalwareScans where
  toHeaders =
    Prelude.const
      ( Prelude.mconcat
          [ "Content-Type"
              Data.=# ( "application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DescribeMalwareScans where
  toJSON DescribeMalwareScans' {..} =
    Data.object
      ( Prelude.catMaybes
          [ ("filterCriteria" Data..=)
              Prelude.<$> filterCriteria,
            ("maxResults" Data..=) Prelude.<$> maxResults,
            ("nextToken" Data..=) Prelude.<$> nextToken,
            ("sortCriteria" Data..=) Prelude.<$> sortCriteria
          ]
      )

instance Data.ToPath DescribeMalwareScans where
  toPath DescribeMalwareScans' {..} =
    Prelude.mconcat
      [ "/detector/",
        Data.toBS detectorId,
        "/malware-scans"
      ]

instance Data.ToQuery DescribeMalwareScans where
  toQuery = Prelude.const Prelude.mempty

-- | /See:/ 'newDescribeMalwareScansResponse' smart constructor.
data DescribeMalwareScansResponse = DescribeMalwareScansResponse'
  { -- | The pagination parameter to be used on the next list operation to
    -- retrieve more items.
    nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    httpStatus :: Prelude.Int,
    -- | Contains information about malware scans.
    scans :: [Scan]
  }
  deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)

-- |
-- Create a value of 'DescribeMalwareScansResponse' 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:
--
-- 'nextToken', 'describeMalwareScansResponse_nextToken' - The pagination parameter to be used on the next list operation to
-- retrieve more items.
--
-- 'httpStatus', 'describeMalwareScansResponse_httpStatus' - The response's http status code.
--
-- 'scans', 'describeMalwareScansResponse_scans' - Contains information about malware scans.
newDescribeMalwareScansResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeMalwareScansResponse
newDescribeMalwareScansResponse pHttpStatus_ =
  DescribeMalwareScansResponse'
    { nextToken =
        Prelude.Nothing,
      httpStatus = pHttpStatus_,
      scans = Prelude.mempty
    }

-- | The pagination parameter to be used on the next list operation to
-- retrieve more items.
describeMalwareScansResponse_nextToken :: Lens.Lens' DescribeMalwareScansResponse (Prelude.Maybe Prelude.Text)
describeMalwareScansResponse_nextToken = Lens.lens (\DescribeMalwareScansResponse' {nextToken} -> nextToken) (\s@DescribeMalwareScansResponse' {} a -> s {nextToken = a} :: DescribeMalwareScansResponse)

-- | The response's http status code.
describeMalwareScansResponse_httpStatus :: Lens.Lens' DescribeMalwareScansResponse Prelude.Int
describeMalwareScansResponse_httpStatus = Lens.lens (\DescribeMalwareScansResponse' {httpStatus} -> httpStatus) (\s@DescribeMalwareScansResponse' {} a -> s {httpStatus = a} :: DescribeMalwareScansResponse)

-- | Contains information about malware scans.
describeMalwareScansResponse_scans :: Lens.Lens' DescribeMalwareScansResponse [Scan]
describeMalwareScansResponse_scans = Lens.lens (\DescribeMalwareScansResponse' {scans} -> scans) (\s@DescribeMalwareScansResponse' {} a -> s {scans = a} :: DescribeMalwareScansResponse) Prelude.. Lens.coerced

instance Prelude.NFData DescribeMalwareScansResponse where
  rnf DescribeMalwareScansResponse' {..} =
    Prelude.rnf nextToken
      `Prelude.seq` Prelude.rnf httpStatus
      `Prelude.seq` Prelude.rnf scans