{-# 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.MacieV2.ListClassificationScopes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves a subset of information about the classification scope for an
-- account.
--
-- This operation returns paginated results.
module Amazonka.MacieV2.ListClassificationScopes
  ( -- * Creating a Request
    ListClassificationScopes (..),
    newListClassificationScopes,

    -- * Request Lenses
    listClassificationScopes_name,
    listClassificationScopes_nextToken,

    -- * Destructuring the Response
    ListClassificationScopesResponse (..),
    newListClassificationScopesResponse,

    -- * Response Lenses
    listClassificationScopesResponse_classificationScopes,
    listClassificationScopesResponse_nextToken,
    listClassificationScopesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListClassificationScopes' smart constructor.
data ListClassificationScopes = ListClassificationScopes'
  { -- | The name of the classification scope to retrieve the unique identifier
    -- for.
    ListClassificationScopes -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The nextToken string that specifies which page of results to return in a
    -- paginated response.
    ListClassificationScopes -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListClassificationScopes -> ListClassificationScopes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListClassificationScopes -> ListClassificationScopes -> Bool
$c/= :: ListClassificationScopes -> ListClassificationScopes -> Bool
== :: ListClassificationScopes -> ListClassificationScopes -> Bool
$c== :: ListClassificationScopes -> ListClassificationScopes -> Bool
Prelude.Eq, ReadPrec [ListClassificationScopes]
ReadPrec ListClassificationScopes
Int -> ReadS ListClassificationScopes
ReadS [ListClassificationScopes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListClassificationScopes]
$creadListPrec :: ReadPrec [ListClassificationScopes]
readPrec :: ReadPrec ListClassificationScopes
$creadPrec :: ReadPrec ListClassificationScopes
readList :: ReadS [ListClassificationScopes]
$creadList :: ReadS [ListClassificationScopes]
readsPrec :: Int -> ReadS ListClassificationScopes
$creadsPrec :: Int -> ReadS ListClassificationScopes
Prelude.Read, Int -> ListClassificationScopes -> ShowS
[ListClassificationScopes] -> ShowS
ListClassificationScopes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListClassificationScopes] -> ShowS
$cshowList :: [ListClassificationScopes] -> ShowS
show :: ListClassificationScopes -> String
$cshow :: ListClassificationScopes -> String
showsPrec :: Int -> ListClassificationScopes -> ShowS
$cshowsPrec :: Int -> ListClassificationScopes -> ShowS
Prelude.Show, forall x.
Rep ListClassificationScopes x -> ListClassificationScopes
forall x.
ListClassificationScopes -> Rep ListClassificationScopes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListClassificationScopes x -> ListClassificationScopes
$cfrom :: forall x.
ListClassificationScopes -> Rep ListClassificationScopes x
Prelude.Generic)

-- |
-- Create a value of 'ListClassificationScopes' 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:
--
-- 'name', 'listClassificationScopes_name' - The name of the classification scope to retrieve the unique identifier
-- for.
--
-- 'nextToken', 'listClassificationScopes_nextToken' - The nextToken string that specifies which page of results to return in a
-- paginated response.
newListClassificationScopes ::
  ListClassificationScopes
newListClassificationScopes :: ListClassificationScopes
newListClassificationScopes =
  ListClassificationScopes'
    { $sel:name:ListClassificationScopes' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListClassificationScopes' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the classification scope to retrieve the unique identifier
-- for.
listClassificationScopes_name :: Lens.Lens' ListClassificationScopes (Prelude.Maybe Prelude.Text)
listClassificationScopes_name :: Lens' ListClassificationScopes (Maybe Text)
listClassificationScopes_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListClassificationScopes' {Maybe Text
name :: Maybe Text
$sel:name:ListClassificationScopes' :: ListClassificationScopes -> Maybe Text
name} -> Maybe Text
name) (\s :: ListClassificationScopes
s@ListClassificationScopes' {} Maybe Text
a -> ListClassificationScopes
s {$sel:name:ListClassificationScopes' :: Maybe Text
name = Maybe Text
a} :: ListClassificationScopes)

-- | The nextToken string that specifies which page of results to return in a
-- paginated response.
listClassificationScopes_nextToken :: Lens.Lens' ListClassificationScopes (Prelude.Maybe Prelude.Text)
listClassificationScopes_nextToken :: Lens' ListClassificationScopes (Maybe Text)
listClassificationScopes_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListClassificationScopes' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListClassificationScopes' :: ListClassificationScopes -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListClassificationScopes
s@ListClassificationScopes' {} Maybe Text
a -> ListClassificationScopes
s {$sel:nextToken:ListClassificationScopes' :: Maybe Text
nextToken = Maybe Text
a} :: ListClassificationScopes)

instance Core.AWSPager ListClassificationScopes where
  page :: ListClassificationScopes
-> AWSResponse ListClassificationScopes
-> Maybe ListClassificationScopes
page ListClassificationScopes
rq AWSResponse ListClassificationScopes
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListClassificationScopes
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListClassificationScopesResponse (Maybe Text)
listClassificationScopesResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListClassificationScopes
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens'
  ListClassificationScopesResponse
  (Maybe [ClassificationScopeSummary])
listClassificationScopesResponse_classificationScopes
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListClassificationScopes
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListClassificationScopes (Maybe Text)
listClassificationScopes_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListClassificationScopes
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListClassificationScopesResponse (Maybe Text)
listClassificationScopesResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListClassificationScopes where
  type
    AWSResponse ListClassificationScopes =
      ListClassificationScopesResponse
  request :: (Service -> Service)
-> ListClassificationScopes -> Request ListClassificationScopes
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListClassificationScopes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListClassificationScopes)))
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 [ClassificationScopeSummary]
-> Maybe Text -> Int -> ListClassificationScopesResponse
ListClassificationScopesResponse'
            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
"classificationScopes"
                            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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextToken")
            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 ListClassificationScopes where
  hashWithSalt :: Int -> ListClassificationScopes -> Int
hashWithSalt Int
_salt ListClassificationScopes' {Maybe Text
nextToken :: Maybe Text
name :: Maybe Text
$sel:nextToken:ListClassificationScopes' :: ListClassificationScopes -> Maybe Text
$sel:name:ListClassificationScopes' :: ListClassificationScopes -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListClassificationScopes where
  rnf :: ListClassificationScopes -> ()
rnf ListClassificationScopes' {Maybe Text
nextToken :: Maybe Text
name :: Maybe Text
$sel:nextToken:ListClassificationScopes' :: ListClassificationScopes -> Maybe Text
$sel:name:ListClassificationScopes' :: ListClassificationScopes -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

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

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

instance Data.ToQuery ListClassificationScopes where
  toQuery :: ListClassificationScopes -> QueryString
toQuery ListClassificationScopes' {Maybe Text
nextToken :: Maybe Text
name :: Maybe Text
$sel:nextToken:ListClassificationScopes' :: ListClassificationScopes -> Maybe Text
$sel:name:ListClassificationScopes' :: ListClassificationScopes -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"name" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
name, ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken]

-- | /See:/ 'newListClassificationScopesResponse' smart constructor.
data ListClassificationScopesResponse = ListClassificationScopesResponse'
  { -- | An array that specifies the unique identifier and name of the
    -- classification scope for the account.
    ListClassificationScopesResponse
-> Maybe [ClassificationScopeSummary]
classificationScopes :: Prelude.Maybe [ClassificationScopeSummary],
    -- | The string to use in a subsequent request to get the next page of
    -- results in a paginated response. This value is null if there are no
    -- additional pages.
    ListClassificationScopesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListClassificationScopesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListClassificationScopesResponse
-> ListClassificationScopesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListClassificationScopesResponse
-> ListClassificationScopesResponse -> Bool
$c/= :: ListClassificationScopesResponse
-> ListClassificationScopesResponse -> Bool
== :: ListClassificationScopesResponse
-> ListClassificationScopesResponse -> Bool
$c== :: ListClassificationScopesResponse
-> ListClassificationScopesResponse -> Bool
Prelude.Eq, ReadPrec [ListClassificationScopesResponse]
ReadPrec ListClassificationScopesResponse
Int -> ReadS ListClassificationScopesResponse
ReadS [ListClassificationScopesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListClassificationScopesResponse]
$creadListPrec :: ReadPrec [ListClassificationScopesResponse]
readPrec :: ReadPrec ListClassificationScopesResponse
$creadPrec :: ReadPrec ListClassificationScopesResponse
readList :: ReadS [ListClassificationScopesResponse]
$creadList :: ReadS [ListClassificationScopesResponse]
readsPrec :: Int -> ReadS ListClassificationScopesResponse
$creadsPrec :: Int -> ReadS ListClassificationScopesResponse
Prelude.Read, Int -> ListClassificationScopesResponse -> ShowS
[ListClassificationScopesResponse] -> ShowS
ListClassificationScopesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListClassificationScopesResponse] -> ShowS
$cshowList :: [ListClassificationScopesResponse] -> ShowS
show :: ListClassificationScopesResponse -> String
$cshow :: ListClassificationScopesResponse -> String
showsPrec :: Int -> ListClassificationScopesResponse -> ShowS
$cshowsPrec :: Int -> ListClassificationScopesResponse -> ShowS
Prelude.Show, forall x.
Rep ListClassificationScopesResponse x
-> ListClassificationScopesResponse
forall x.
ListClassificationScopesResponse
-> Rep ListClassificationScopesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListClassificationScopesResponse x
-> ListClassificationScopesResponse
$cfrom :: forall x.
ListClassificationScopesResponse
-> Rep ListClassificationScopesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListClassificationScopesResponse' 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:
--
-- 'classificationScopes', 'listClassificationScopesResponse_classificationScopes' - An array that specifies the unique identifier and name of the
-- classification scope for the account.
--
-- 'nextToken', 'listClassificationScopesResponse_nextToken' - The string to use in a subsequent request to get the next page of
-- results in a paginated response. This value is null if there are no
-- additional pages.
--
-- 'httpStatus', 'listClassificationScopesResponse_httpStatus' - The response's http status code.
newListClassificationScopesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListClassificationScopesResponse
newListClassificationScopesResponse :: Int -> ListClassificationScopesResponse
newListClassificationScopesResponse Int
pHttpStatus_ =
  ListClassificationScopesResponse'
    { $sel:classificationScopes:ListClassificationScopesResponse' :: Maybe [ClassificationScopeSummary]
classificationScopes =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListClassificationScopesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListClassificationScopesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array that specifies the unique identifier and name of the
-- classification scope for the account.
listClassificationScopesResponse_classificationScopes :: Lens.Lens' ListClassificationScopesResponse (Prelude.Maybe [ClassificationScopeSummary])
listClassificationScopesResponse_classificationScopes :: Lens'
  ListClassificationScopesResponse
  (Maybe [ClassificationScopeSummary])
listClassificationScopesResponse_classificationScopes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListClassificationScopesResponse' {Maybe [ClassificationScopeSummary]
classificationScopes :: Maybe [ClassificationScopeSummary]
$sel:classificationScopes:ListClassificationScopesResponse' :: ListClassificationScopesResponse
-> Maybe [ClassificationScopeSummary]
classificationScopes} -> Maybe [ClassificationScopeSummary]
classificationScopes) (\s :: ListClassificationScopesResponse
s@ListClassificationScopesResponse' {} Maybe [ClassificationScopeSummary]
a -> ListClassificationScopesResponse
s {$sel:classificationScopes:ListClassificationScopesResponse' :: Maybe [ClassificationScopeSummary]
classificationScopes = Maybe [ClassificationScopeSummary]
a} :: ListClassificationScopesResponse) 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 string to use in a subsequent request to get the next page of
-- results in a paginated response. This value is null if there are no
-- additional pages.
listClassificationScopesResponse_nextToken :: Lens.Lens' ListClassificationScopesResponse (Prelude.Maybe Prelude.Text)
listClassificationScopesResponse_nextToken :: Lens' ListClassificationScopesResponse (Maybe Text)
listClassificationScopesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListClassificationScopesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListClassificationScopesResponse' :: ListClassificationScopesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListClassificationScopesResponse
s@ListClassificationScopesResponse' {} Maybe Text
a -> ListClassificationScopesResponse
s {$sel:nextToken:ListClassificationScopesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListClassificationScopesResponse)

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

instance
  Prelude.NFData
    ListClassificationScopesResponse
  where
  rnf :: ListClassificationScopesResponse -> ()
rnf ListClassificationScopesResponse' {Int
Maybe [ClassificationScopeSummary]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
classificationScopes :: Maybe [ClassificationScopeSummary]
$sel:httpStatus:ListClassificationScopesResponse' :: ListClassificationScopesResponse -> Int
$sel:nextToken:ListClassificationScopesResponse' :: ListClassificationScopesResponse -> Maybe Text
$sel:classificationScopes:ListClassificationScopesResponse' :: ListClassificationScopesResponse
-> Maybe [ClassificationScopeSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ClassificationScopeSummary]
classificationScopes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus