{-# 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.Synthetics.ListGroupResources
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This operation returns a list of the ARNs of the canaries that are
-- associated with the specified group.
module Amazonka.Synthetics.ListGroupResources
  ( -- * Creating a Request
    ListGroupResources (..),
    newListGroupResources,

    -- * Request Lenses
    listGroupResources_maxResults,
    listGroupResources_nextToken,
    listGroupResources_groupIdentifier,

    -- * Destructuring the Response
    ListGroupResourcesResponse (..),
    newListGroupResourcesResponse,

    -- * Response Lenses
    listGroupResourcesResponse_nextToken,
    listGroupResourcesResponse_resources,
    listGroupResourcesResponse_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.Synthetics.Types

-- | /See:/ 'newListGroupResources' smart constructor.
data ListGroupResources = ListGroupResources'
  { -- | Specify this parameter to limit how many canary ARNs are returned each
    -- time you use the @ListGroupResources@ operation. If you omit this
    -- parameter, the default of 20 is used.
    ListGroupResources -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A token that indicates that there is more data available. You can use
    -- this token in a subsequent operation to retrieve the next set of
    -- results.
    ListGroupResources -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Specifies the group to return information for. You can specify the group
    -- name, the ARN, or the group ID as the @GroupIdentifier@.
    ListGroupResources -> Text
groupIdentifier :: Prelude.Text
  }
  deriving (ListGroupResources -> ListGroupResources -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGroupResources -> ListGroupResources -> Bool
$c/= :: ListGroupResources -> ListGroupResources -> Bool
== :: ListGroupResources -> ListGroupResources -> Bool
$c== :: ListGroupResources -> ListGroupResources -> Bool
Prelude.Eq, ReadPrec [ListGroupResources]
ReadPrec ListGroupResources
Int -> ReadS ListGroupResources
ReadS [ListGroupResources]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListGroupResources]
$creadListPrec :: ReadPrec [ListGroupResources]
readPrec :: ReadPrec ListGroupResources
$creadPrec :: ReadPrec ListGroupResources
readList :: ReadS [ListGroupResources]
$creadList :: ReadS [ListGroupResources]
readsPrec :: Int -> ReadS ListGroupResources
$creadsPrec :: Int -> ReadS ListGroupResources
Prelude.Read, Int -> ListGroupResources -> ShowS
[ListGroupResources] -> ShowS
ListGroupResources -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGroupResources] -> ShowS
$cshowList :: [ListGroupResources] -> ShowS
show :: ListGroupResources -> String
$cshow :: ListGroupResources -> String
showsPrec :: Int -> ListGroupResources -> ShowS
$cshowsPrec :: Int -> ListGroupResources -> ShowS
Prelude.Show, forall x. Rep ListGroupResources x -> ListGroupResources
forall x. ListGroupResources -> Rep ListGroupResources x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListGroupResources x -> ListGroupResources
$cfrom :: forall x. ListGroupResources -> Rep ListGroupResources x
Prelude.Generic)

-- |
-- Create a value of 'ListGroupResources' 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:
--
-- 'maxResults', 'listGroupResources_maxResults' - Specify this parameter to limit how many canary ARNs are returned each
-- time you use the @ListGroupResources@ operation. If you omit this
-- parameter, the default of 20 is used.
--
-- 'nextToken', 'listGroupResources_nextToken' - A token that indicates that there is more data available. You can use
-- this token in a subsequent operation to retrieve the next set of
-- results.
--
-- 'groupIdentifier', 'listGroupResources_groupIdentifier' - Specifies the group to return information for. You can specify the group
-- name, the ARN, or the group ID as the @GroupIdentifier@.
newListGroupResources ::
  -- | 'groupIdentifier'
  Prelude.Text ->
  ListGroupResources
newListGroupResources :: Text -> ListGroupResources
newListGroupResources Text
pGroupIdentifier_ =
  ListGroupResources'
    { $sel:maxResults:ListGroupResources' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListGroupResources' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:groupIdentifier:ListGroupResources' :: Text
groupIdentifier = Text
pGroupIdentifier_
    }

-- | Specify this parameter to limit how many canary ARNs are returned each
-- time you use the @ListGroupResources@ operation. If you omit this
-- parameter, the default of 20 is used.
listGroupResources_maxResults :: Lens.Lens' ListGroupResources (Prelude.Maybe Prelude.Natural)
listGroupResources_maxResults :: Lens' ListGroupResources (Maybe Natural)
listGroupResources_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroupResources' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListGroupResources' :: ListGroupResources -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListGroupResources
s@ListGroupResources' {} Maybe Natural
a -> ListGroupResources
s {$sel:maxResults:ListGroupResources' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListGroupResources)

-- | A token that indicates that there is more data available. You can use
-- this token in a subsequent operation to retrieve the next set of
-- results.
listGroupResources_nextToken :: Lens.Lens' ListGroupResources (Prelude.Maybe Prelude.Text)
listGroupResources_nextToken :: Lens' ListGroupResources (Maybe Text)
listGroupResources_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroupResources' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListGroupResources' :: ListGroupResources -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListGroupResources
s@ListGroupResources' {} Maybe Text
a -> ListGroupResources
s {$sel:nextToken:ListGroupResources' :: Maybe Text
nextToken = Maybe Text
a} :: ListGroupResources)

-- | Specifies the group to return information for. You can specify the group
-- name, the ARN, or the group ID as the @GroupIdentifier@.
listGroupResources_groupIdentifier :: Lens.Lens' ListGroupResources Prelude.Text
listGroupResources_groupIdentifier :: Lens' ListGroupResources Text
listGroupResources_groupIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroupResources' {Text
groupIdentifier :: Text
$sel:groupIdentifier:ListGroupResources' :: ListGroupResources -> Text
groupIdentifier} -> Text
groupIdentifier) (\s :: ListGroupResources
s@ListGroupResources' {} Text
a -> ListGroupResources
s {$sel:groupIdentifier:ListGroupResources' :: Text
groupIdentifier = Text
a} :: ListGroupResources)

instance Core.AWSRequest ListGroupResources where
  type
    AWSResponse ListGroupResources =
      ListGroupResourcesResponse
  request :: (Service -> Service)
-> ListGroupResources -> Request ListGroupResources
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 ListGroupResources
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListGroupResources)))
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 Text -> Maybe [Text] -> Int -> ListGroupResourcesResponse
ListGroupResourcesResponse'
            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
"NextToken")
            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
"Resources" 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 ListGroupResources where
  hashWithSalt :: Int -> ListGroupResources -> Int
hashWithSalt Int
_salt ListGroupResources' {Maybe Natural
Maybe Text
Text
groupIdentifier :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:groupIdentifier:ListGroupResources' :: ListGroupResources -> Text
$sel:nextToken:ListGroupResources' :: ListGroupResources -> Maybe Text
$sel:maxResults:ListGroupResources' :: ListGroupResources -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
groupIdentifier

instance Prelude.NFData ListGroupResources where
  rnf :: ListGroupResources -> ()
rnf ListGroupResources' {Maybe Natural
Maybe Text
Text
groupIdentifier :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:groupIdentifier:ListGroupResources' :: ListGroupResources -> Text
$sel:nextToken:ListGroupResources' :: ListGroupResources -> Maybe Text
$sel:maxResults:ListGroupResources' :: ListGroupResources -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      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 Text
groupIdentifier

instance Data.ToHeaders ListGroupResources where
  toHeaders :: ListGroupResources -> 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.ToJSON ListGroupResources where
  toJSON :: ListGroupResources -> Value
toJSON ListGroupResources' {Maybe Natural
Maybe Text
Text
groupIdentifier :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:groupIdentifier:ListGroupResources' :: ListGroupResources -> Text
$sel:nextToken:ListGroupResources' :: ListGroupResources -> Maybe Text
$sel:maxResults:ListGroupResources' :: ListGroupResources -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxResults" 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 Natural
maxResults,
            (Key
"NextToken" 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
nextToken
          ]
      )

instance Data.ToPath ListGroupResources where
  toPath :: ListGroupResources -> ByteString
toPath ListGroupResources' {Maybe Natural
Maybe Text
Text
groupIdentifier :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:groupIdentifier:ListGroupResources' :: ListGroupResources -> Text
$sel:nextToken:ListGroupResources' :: ListGroupResources -> Maybe Text
$sel:maxResults:ListGroupResources' :: ListGroupResources -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/group/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
groupIdentifier, ByteString
"/resources"]

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

-- | /See:/ 'newListGroupResourcesResponse' smart constructor.
data ListGroupResourcesResponse = ListGroupResourcesResponse'
  { -- | A token that indicates that there is more data available. You can use
    -- this token in a subsequent @ListGroupResources@ operation to retrieve
    -- the next set of results.
    ListGroupResourcesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of ARNs. These ARNs are for the canaries that are associated
    -- with the group.
    ListGroupResourcesResponse -> Maybe [Text]
resources :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    ListGroupResourcesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListGroupResourcesResponse -> ListGroupResourcesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGroupResourcesResponse -> ListGroupResourcesResponse -> Bool
$c/= :: ListGroupResourcesResponse -> ListGroupResourcesResponse -> Bool
== :: ListGroupResourcesResponse -> ListGroupResourcesResponse -> Bool
$c== :: ListGroupResourcesResponse -> ListGroupResourcesResponse -> Bool
Prelude.Eq, ReadPrec [ListGroupResourcesResponse]
ReadPrec ListGroupResourcesResponse
Int -> ReadS ListGroupResourcesResponse
ReadS [ListGroupResourcesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListGroupResourcesResponse]
$creadListPrec :: ReadPrec [ListGroupResourcesResponse]
readPrec :: ReadPrec ListGroupResourcesResponse
$creadPrec :: ReadPrec ListGroupResourcesResponse
readList :: ReadS [ListGroupResourcesResponse]
$creadList :: ReadS [ListGroupResourcesResponse]
readsPrec :: Int -> ReadS ListGroupResourcesResponse
$creadsPrec :: Int -> ReadS ListGroupResourcesResponse
Prelude.Read, Int -> ListGroupResourcesResponse -> ShowS
[ListGroupResourcesResponse] -> ShowS
ListGroupResourcesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGroupResourcesResponse] -> ShowS
$cshowList :: [ListGroupResourcesResponse] -> ShowS
show :: ListGroupResourcesResponse -> String
$cshow :: ListGroupResourcesResponse -> String
showsPrec :: Int -> ListGroupResourcesResponse -> ShowS
$cshowsPrec :: Int -> ListGroupResourcesResponse -> ShowS
Prelude.Show, forall x.
Rep ListGroupResourcesResponse x -> ListGroupResourcesResponse
forall x.
ListGroupResourcesResponse -> Rep ListGroupResourcesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListGroupResourcesResponse x -> ListGroupResourcesResponse
$cfrom :: forall x.
ListGroupResourcesResponse -> Rep ListGroupResourcesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListGroupResourcesResponse' 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', 'listGroupResourcesResponse_nextToken' - A token that indicates that there is more data available. You can use
-- this token in a subsequent @ListGroupResources@ operation to retrieve
-- the next set of results.
--
-- 'resources', 'listGroupResourcesResponse_resources' - An array of ARNs. These ARNs are for the canaries that are associated
-- with the group.
--
-- 'httpStatus', 'listGroupResourcesResponse_httpStatus' - The response's http status code.
newListGroupResourcesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListGroupResourcesResponse
newListGroupResourcesResponse :: Int -> ListGroupResourcesResponse
newListGroupResourcesResponse Int
pHttpStatus_ =
  ListGroupResourcesResponse'
    { $sel:nextToken:ListGroupResourcesResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:resources:ListGroupResourcesResponse' :: Maybe [Text]
resources = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListGroupResourcesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A token that indicates that there is more data available. You can use
-- this token in a subsequent @ListGroupResources@ operation to retrieve
-- the next set of results.
listGroupResourcesResponse_nextToken :: Lens.Lens' ListGroupResourcesResponse (Prelude.Maybe Prelude.Text)
listGroupResourcesResponse_nextToken :: Lens' ListGroupResourcesResponse (Maybe Text)
listGroupResourcesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroupResourcesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListGroupResourcesResponse' :: ListGroupResourcesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListGroupResourcesResponse
s@ListGroupResourcesResponse' {} Maybe Text
a -> ListGroupResourcesResponse
s {$sel:nextToken:ListGroupResourcesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListGroupResourcesResponse)

-- | An array of ARNs. These ARNs are for the canaries that are associated
-- with the group.
listGroupResourcesResponse_resources :: Lens.Lens' ListGroupResourcesResponse (Prelude.Maybe [Prelude.Text])
listGroupResourcesResponse_resources :: Lens' ListGroupResourcesResponse (Maybe [Text])
listGroupResourcesResponse_resources = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroupResourcesResponse' {Maybe [Text]
resources :: Maybe [Text]
$sel:resources:ListGroupResourcesResponse' :: ListGroupResourcesResponse -> Maybe [Text]
resources} -> Maybe [Text]
resources) (\s :: ListGroupResourcesResponse
s@ListGroupResourcesResponse' {} Maybe [Text]
a -> ListGroupResourcesResponse
s {$sel:resources:ListGroupResourcesResponse' :: Maybe [Text]
resources = Maybe [Text]
a} :: ListGroupResourcesResponse) 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.
listGroupResourcesResponse_httpStatus :: Lens.Lens' ListGroupResourcesResponse Prelude.Int
listGroupResourcesResponse_httpStatus :: Lens' ListGroupResourcesResponse Int
listGroupResourcesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroupResourcesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListGroupResourcesResponse' :: ListGroupResourcesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListGroupResourcesResponse
s@ListGroupResourcesResponse' {} Int
a -> ListGroupResourcesResponse
s {$sel:httpStatus:ListGroupResourcesResponse' :: Int
httpStatus = Int
a} :: ListGroupResourcesResponse)

instance Prelude.NFData ListGroupResourcesResponse where
  rnf :: ListGroupResourcesResponse -> ()
rnf ListGroupResourcesResponse' {Int
Maybe [Text]
Maybe Text
httpStatus :: Int
resources :: Maybe [Text]
nextToken :: Maybe Text
$sel:httpStatus:ListGroupResourcesResponse' :: ListGroupResourcesResponse -> Int
$sel:resources:ListGroupResourcesResponse' :: ListGroupResourcesResponse -> Maybe [Text]
$sel:nextToken:ListGroupResourcesResponse' :: ListGroupResourcesResponse -> Maybe Text
..} =
    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 Maybe [Text]
resources
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus