{-# 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.CloudWatchLogs.DescribeLogGroups
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the specified log groups. You can list all your log groups or
-- filter the results by prefix. The results are ASCII-sorted by log group
-- name.
--
-- CloudWatch Logs doesn’t support IAM policies that control access to the
-- @DescribeLogGroups@ action by using the
-- @aws:ResourceTag\/@/@key-name@/@ @ condition key. Other CloudWatch Logs
-- actions do support the use of the @aws:ResourceTag\/@/@key-name@/@ @
-- condition key to control access. For more information about using tags
-- to control access, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html Controlling access to Amazon Web Services resources using tags>.
--
-- If you are using CloudWatch cross-account observability, you can use
-- this operation in a monitoring account and view data from the linked
-- source accounts. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html CloudWatch cross-account observability>.
--
-- This operation returns paginated results.
module Amazonka.CloudWatchLogs.DescribeLogGroups
  ( -- * Creating a Request
    DescribeLogGroups (..),
    newDescribeLogGroups,

    -- * Request Lenses
    describeLogGroups_accountIdentifiers,
    describeLogGroups_includeLinkedAccounts,
    describeLogGroups_limit,
    describeLogGroups_logGroupNamePattern,
    describeLogGroups_logGroupNamePrefix,
    describeLogGroups_nextToken,

    -- * Destructuring the Response
    DescribeLogGroupsResponse (..),
    newDescribeLogGroupsResponse,

    -- * Response Lenses
    describeLogGroupsResponse_logGroups,
    describeLogGroupsResponse_nextToken,
    describeLogGroupsResponse_httpStatus,
  )
where

import Amazonka.CloudWatchLogs.Types
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

-- | /See:/ 'newDescribeLogGroups' smart constructor.
data DescribeLogGroups = DescribeLogGroups'
  { -- | When @includeLinkedAccounts@ is set to @True@, use this parameter to
    -- specify the list of accounts to search. You can specify as many as 20
    -- account IDs in the array.
    DescribeLogGroups -> Maybe [Text]
accountIdentifiers :: Prelude.Maybe [Prelude.Text],
    -- | If you are using a monitoring account, set this to @True@ to have the
    -- operation return log groups in the accounts listed in
    -- @accountIdentifiers@.
    --
    -- If this parameter is set to @true@ and @accountIdentifiers@ contains a
    -- null value, the operation returns all log groups in the monitoring
    -- account and all log groups in all source accounts that are linked to the
    -- monitoring account.
    --
    -- If you specify @includeLinkedAccounts@ in your request, then
    -- @metricFilterCount@, @retentionInDays@, and @storedBytes@ are not
    -- included in the response.
    DescribeLogGroups -> Maybe Bool
includeLinkedAccounts :: Prelude.Maybe Prelude.Bool,
    -- | The maximum number of items returned. If you don\'t specify a value, the
    -- default is up to 50 items.
    DescribeLogGroups -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | If you specify a string for this parameter, the operation returns only
    -- log groups that have names that match the string based on a
    -- case-sensitive substring search. For example, if you specify @Foo@, log
    -- groups named @FooBar@, @aws\/Foo@, and @GroupFoo@ would match, but
    -- @foo@, @F\/o\/o@ and @Froo@ would not match.
    --
    -- @logGroupNamePattern@ and @logGroupNamePrefix@ are mutually exclusive.
    -- Only one of these parameters can be passed.
    DescribeLogGroups -> Maybe Text
logGroupNamePattern :: Prelude.Maybe Prelude.Text,
    -- | The prefix to match.
    --
    -- @logGroupNamePrefix@ and @logGroupNamePattern@ are mutually exclusive.
    -- Only one of these parameters can be passed.
    DescribeLogGroups -> Maybe Text
logGroupNamePrefix :: Prelude.Maybe Prelude.Text,
    -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    DescribeLogGroups -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (DescribeLogGroups -> DescribeLogGroups -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLogGroups -> DescribeLogGroups -> Bool
$c/= :: DescribeLogGroups -> DescribeLogGroups -> Bool
== :: DescribeLogGroups -> DescribeLogGroups -> Bool
$c== :: DescribeLogGroups -> DescribeLogGroups -> Bool
Prelude.Eq, ReadPrec [DescribeLogGroups]
ReadPrec DescribeLogGroups
Int -> ReadS DescribeLogGroups
ReadS [DescribeLogGroups]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLogGroups]
$creadListPrec :: ReadPrec [DescribeLogGroups]
readPrec :: ReadPrec DescribeLogGroups
$creadPrec :: ReadPrec DescribeLogGroups
readList :: ReadS [DescribeLogGroups]
$creadList :: ReadS [DescribeLogGroups]
readsPrec :: Int -> ReadS DescribeLogGroups
$creadsPrec :: Int -> ReadS DescribeLogGroups
Prelude.Read, Int -> DescribeLogGroups -> ShowS
[DescribeLogGroups] -> ShowS
DescribeLogGroups -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLogGroups] -> ShowS
$cshowList :: [DescribeLogGroups] -> ShowS
show :: DescribeLogGroups -> String
$cshow :: DescribeLogGroups -> String
showsPrec :: Int -> DescribeLogGroups -> ShowS
$cshowsPrec :: Int -> DescribeLogGroups -> ShowS
Prelude.Show, forall x. Rep DescribeLogGroups x -> DescribeLogGroups
forall x. DescribeLogGroups -> Rep DescribeLogGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeLogGroups x -> DescribeLogGroups
$cfrom :: forall x. DescribeLogGroups -> Rep DescribeLogGroups x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLogGroups' 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:
--
-- 'accountIdentifiers', 'describeLogGroups_accountIdentifiers' - When @includeLinkedAccounts@ is set to @True@, use this parameter to
-- specify the list of accounts to search. You can specify as many as 20
-- account IDs in the array.
--
-- 'includeLinkedAccounts', 'describeLogGroups_includeLinkedAccounts' - If you are using a monitoring account, set this to @True@ to have the
-- operation return log groups in the accounts listed in
-- @accountIdentifiers@.
--
-- If this parameter is set to @true@ and @accountIdentifiers@ contains a
-- null value, the operation returns all log groups in the monitoring
-- account and all log groups in all source accounts that are linked to the
-- monitoring account.
--
-- If you specify @includeLinkedAccounts@ in your request, then
-- @metricFilterCount@, @retentionInDays@, and @storedBytes@ are not
-- included in the response.
--
-- 'limit', 'describeLogGroups_limit' - The maximum number of items returned. If you don\'t specify a value, the
-- default is up to 50 items.
--
-- 'logGroupNamePattern', 'describeLogGroups_logGroupNamePattern' - If you specify a string for this parameter, the operation returns only
-- log groups that have names that match the string based on a
-- case-sensitive substring search. For example, if you specify @Foo@, log
-- groups named @FooBar@, @aws\/Foo@, and @GroupFoo@ would match, but
-- @foo@, @F\/o\/o@ and @Froo@ would not match.
--
-- @logGroupNamePattern@ and @logGroupNamePrefix@ are mutually exclusive.
-- Only one of these parameters can be passed.
--
-- 'logGroupNamePrefix', 'describeLogGroups_logGroupNamePrefix' - The prefix to match.
--
-- @logGroupNamePrefix@ and @logGroupNamePattern@ are mutually exclusive.
-- Only one of these parameters can be passed.
--
-- 'nextToken', 'describeLogGroups_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
newDescribeLogGroups ::
  DescribeLogGroups
newDescribeLogGroups :: DescribeLogGroups
newDescribeLogGroups =
  DescribeLogGroups'
    { $sel:accountIdentifiers:DescribeLogGroups' :: Maybe [Text]
accountIdentifiers =
        forall a. Maybe a
Prelude.Nothing,
      $sel:includeLinkedAccounts:DescribeLogGroups' :: Maybe Bool
includeLinkedAccounts = forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeLogGroups' :: Maybe Natural
limit = forall a. Maybe a
Prelude.Nothing,
      $sel:logGroupNamePattern:DescribeLogGroups' :: Maybe Text
logGroupNamePattern = forall a. Maybe a
Prelude.Nothing,
      $sel:logGroupNamePrefix:DescribeLogGroups' :: Maybe Text
logGroupNamePrefix = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeLogGroups' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | When @includeLinkedAccounts@ is set to @True@, use this parameter to
-- specify the list of accounts to search. You can specify as many as 20
-- account IDs in the array.
describeLogGroups_accountIdentifiers :: Lens.Lens' DescribeLogGroups (Prelude.Maybe [Prelude.Text])
describeLogGroups_accountIdentifiers :: Lens' DescribeLogGroups (Maybe [Text])
describeLogGroups_accountIdentifiers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogGroups' {Maybe [Text]
accountIdentifiers :: Maybe [Text]
$sel:accountIdentifiers:DescribeLogGroups' :: DescribeLogGroups -> Maybe [Text]
accountIdentifiers} -> Maybe [Text]
accountIdentifiers) (\s :: DescribeLogGroups
s@DescribeLogGroups' {} Maybe [Text]
a -> DescribeLogGroups
s {$sel:accountIdentifiers:DescribeLogGroups' :: Maybe [Text]
accountIdentifiers = Maybe [Text]
a} :: DescribeLogGroups) 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

-- | If you are using a monitoring account, set this to @True@ to have the
-- operation return log groups in the accounts listed in
-- @accountIdentifiers@.
--
-- If this parameter is set to @true@ and @accountIdentifiers@ contains a
-- null value, the operation returns all log groups in the monitoring
-- account and all log groups in all source accounts that are linked to the
-- monitoring account.
--
-- If you specify @includeLinkedAccounts@ in your request, then
-- @metricFilterCount@, @retentionInDays@, and @storedBytes@ are not
-- included in the response.
describeLogGroups_includeLinkedAccounts :: Lens.Lens' DescribeLogGroups (Prelude.Maybe Prelude.Bool)
describeLogGroups_includeLinkedAccounts :: Lens' DescribeLogGroups (Maybe Bool)
describeLogGroups_includeLinkedAccounts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogGroups' {Maybe Bool
includeLinkedAccounts :: Maybe Bool
$sel:includeLinkedAccounts:DescribeLogGroups' :: DescribeLogGroups -> Maybe Bool
includeLinkedAccounts} -> Maybe Bool
includeLinkedAccounts) (\s :: DescribeLogGroups
s@DescribeLogGroups' {} Maybe Bool
a -> DescribeLogGroups
s {$sel:includeLinkedAccounts:DescribeLogGroups' :: Maybe Bool
includeLinkedAccounts = Maybe Bool
a} :: DescribeLogGroups)

-- | The maximum number of items returned. If you don\'t specify a value, the
-- default is up to 50 items.
describeLogGroups_limit :: Lens.Lens' DescribeLogGroups (Prelude.Maybe Prelude.Natural)
describeLogGroups_limit :: Lens' DescribeLogGroups (Maybe Natural)
describeLogGroups_limit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogGroups' {Maybe Natural
limit :: Maybe Natural
$sel:limit:DescribeLogGroups' :: DescribeLogGroups -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: DescribeLogGroups
s@DescribeLogGroups' {} Maybe Natural
a -> DescribeLogGroups
s {$sel:limit:DescribeLogGroups' :: Maybe Natural
limit = Maybe Natural
a} :: DescribeLogGroups)

-- | If you specify a string for this parameter, the operation returns only
-- log groups that have names that match the string based on a
-- case-sensitive substring search. For example, if you specify @Foo@, log
-- groups named @FooBar@, @aws\/Foo@, and @GroupFoo@ would match, but
-- @foo@, @F\/o\/o@ and @Froo@ would not match.
--
-- @logGroupNamePattern@ and @logGroupNamePrefix@ are mutually exclusive.
-- Only one of these parameters can be passed.
describeLogGroups_logGroupNamePattern :: Lens.Lens' DescribeLogGroups (Prelude.Maybe Prelude.Text)
describeLogGroups_logGroupNamePattern :: Lens' DescribeLogGroups (Maybe Text)
describeLogGroups_logGroupNamePattern = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogGroups' {Maybe Text
logGroupNamePattern :: Maybe Text
$sel:logGroupNamePattern:DescribeLogGroups' :: DescribeLogGroups -> Maybe Text
logGroupNamePattern} -> Maybe Text
logGroupNamePattern) (\s :: DescribeLogGroups
s@DescribeLogGroups' {} Maybe Text
a -> DescribeLogGroups
s {$sel:logGroupNamePattern:DescribeLogGroups' :: Maybe Text
logGroupNamePattern = Maybe Text
a} :: DescribeLogGroups)

-- | The prefix to match.
--
-- @logGroupNamePrefix@ and @logGroupNamePattern@ are mutually exclusive.
-- Only one of these parameters can be passed.
describeLogGroups_logGroupNamePrefix :: Lens.Lens' DescribeLogGroups (Prelude.Maybe Prelude.Text)
describeLogGroups_logGroupNamePrefix :: Lens' DescribeLogGroups (Maybe Text)
describeLogGroups_logGroupNamePrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogGroups' {Maybe Text
logGroupNamePrefix :: Maybe Text
$sel:logGroupNamePrefix:DescribeLogGroups' :: DescribeLogGroups -> Maybe Text
logGroupNamePrefix} -> Maybe Text
logGroupNamePrefix) (\s :: DescribeLogGroups
s@DescribeLogGroups' {} Maybe Text
a -> DescribeLogGroups
s {$sel:logGroupNamePrefix:DescribeLogGroups' :: Maybe Text
logGroupNamePrefix = Maybe Text
a} :: DescribeLogGroups)

-- | The token for the next set of items to return. (You received this token
-- from a previous call.)
describeLogGroups_nextToken :: Lens.Lens' DescribeLogGroups (Prelude.Maybe Prelude.Text)
describeLogGroups_nextToken :: Lens' DescribeLogGroups (Maybe Text)
describeLogGroups_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogGroups' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeLogGroups' :: DescribeLogGroups -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeLogGroups
s@DescribeLogGroups' {} Maybe Text
a -> DescribeLogGroups
s {$sel:nextToken:DescribeLogGroups' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeLogGroups)

instance Core.AWSPager DescribeLogGroups where
  page :: DescribeLogGroups
-> AWSResponse DescribeLogGroups -> Maybe DescribeLogGroups
page DescribeLogGroups
rq AWSResponse DescribeLogGroups
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeLogGroups
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeLogGroupsResponse (Maybe Text)
describeLogGroupsResponse_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 DescribeLogGroups
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeLogGroupsResponse (Maybe [LogGroup])
describeLogGroupsResponse_logGroups
            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.$ DescribeLogGroups
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' DescribeLogGroups (Maybe Text)
describeLogGroups_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeLogGroups
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeLogGroupsResponse (Maybe Text)
describeLogGroupsResponse_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 DescribeLogGroups where
  type
    AWSResponse DescribeLogGroups =
      DescribeLogGroupsResponse
  request :: (Service -> Service)
-> DescribeLogGroups -> Request DescribeLogGroups
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 DescribeLogGroups
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeLogGroups)))
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 [LogGroup] -> Maybe Text -> Int -> DescribeLogGroupsResponse
DescribeLogGroupsResponse'
            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
"logGroups" 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 DescribeLogGroups where
  hashWithSalt :: Int -> DescribeLogGroups -> Int
hashWithSalt Int
_salt DescribeLogGroups' {Maybe Bool
Maybe Natural
Maybe [Text]
Maybe Text
nextToken :: Maybe Text
logGroupNamePrefix :: Maybe Text
logGroupNamePattern :: Maybe Text
limit :: Maybe Natural
includeLinkedAccounts :: Maybe Bool
accountIdentifiers :: Maybe [Text]
$sel:nextToken:DescribeLogGroups' :: DescribeLogGroups -> Maybe Text
$sel:logGroupNamePrefix:DescribeLogGroups' :: DescribeLogGroups -> Maybe Text
$sel:logGroupNamePattern:DescribeLogGroups' :: DescribeLogGroups -> Maybe Text
$sel:limit:DescribeLogGroups' :: DescribeLogGroups -> Maybe Natural
$sel:includeLinkedAccounts:DescribeLogGroups' :: DescribeLogGroups -> Maybe Bool
$sel:accountIdentifiers:DescribeLogGroups' :: DescribeLogGroups -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
accountIdentifiers
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
includeLinkedAccounts
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
limit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logGroupNamePattern
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logGroupNamePrefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData DescribeLogGroups where
  rnf :: DescribeLogGroups -> ()
rnf DescribeLogGroups' {Maybe Bool
Maybe Natural
Maybe [Text]
Maybe Text
nextToken :: Maybe Text
logGroupNamePrefix :: Maybe Text
logGroupNamePattern :: Maybe Text
limit :: Maybe Natural
includeLinkedAccounts :: Maybe Bool
accountIdentifiers :: Maybe [Text]
$sel:nextToken:DescribeLogGroups' :: DescribeLogGroups -> Maybe Text
$sel:logGroupNamePrefix:DescribeLogGroups' :: DescribeLogGroups -> Maybe Text
$sel:logGroupNamePattern:DescribeLogGroups' :: DescribeLogGroups -> Maybe Text
$sel:limit:DescribeLogGroups' :: DescribeLogGroups -> Maybe Natural
$sel:includeLinkedAccounts:DescribeLogGroups' :: DescribeLogGroups -> Maybe Bool
$sel:accountIdentifiers:DescribeLogGroups' :: DescribeLogGroups -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
accountIdentifiers
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
includeLinkedAccounts
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
limit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
logGroupNamePattern
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
logGroupNamePrefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

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

instance Data.ToJSON DescribeLogGroups where
  toJSON :: DescribeLogGroups -> Value
toJSON DescribeLogGroups' {Maybe Bool
Maybe Natural
Maybe [Text]
Maybe Text
nextToken :: Maybe Text
logGroupNamePrefix :: Maybe Text
logGroupNamePattern :: Maybe Text
limit :: Maybe Natural
includeLinkedAccounts :: Maybe Bool
accountIdentifiers :: Maybe [Text]
$sel:nextToken:DescribeLogGroups' :: DescribeLogGroups -> Maybe Text
$sel:logGroupNamePrefix:DescribeLogGroups' :: DescribeLogGroups -> Maybe Text
$sel:logGroupNamePattern:DescribeLogGroups' :: DescribeLogGroups -> Maybe Text
$sel:limit:DescribeLogGroups' :: DescribeLogGroups -> Maybe Natural
$sel:includeLinkedAccounts:DescribeLogGroups' :: DescribeLogGroups -> Maybe Bool
$sel:accountIdentifiers:DescribeLogGroups' :: DescribeLogGroups -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"accountIdentifiers" 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]
accountIdentifiers,
            (Key
"includeLinkedAccounts" 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 Bool
includeLinkedAccounts,
            (Key
"limit" 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
limit,
            (Key
"logGroupNamePattern" 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
logGroupNamePattern,
            (Key
"logGroupNamePrefix" 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
logGroupNamePrefix,
            (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 DescribeLogGroups where
  toPath :: DescribeLogGroups -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDescribeLogGroupsResponse' smart constructor.
data DescribeLogGroupsResponse = DescribeLogGroupsResponse'
  { -- | The log groups.
    --
    -- If the @retentionInDays@ value is not included for a log group, then
    -- that log group\'s events do not expire.
    DescribeLogGroupsResponse -> Maybe [LogGroup]
logGroups :: Prelude.Maybe [LogGroup],
    DescribeLogGroupsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeLogGroupsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeLogGroupsResponse -> DescribeLogGroupsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLogGroupsResponse -> DescribeLogGroupsResponse -> Bool
$c/= :: DescribeLogGroupsResponse -> DescribeLogGroupsResponse -> Bool
== :: DescribeLogGroupsResponse -> DescribeLogGroupsResponse -> Bool
$c== :: DescribeLogGroupsResponse -> DescribeLogGroupsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeLogGroupsResponse]
ReadPrec DescribeLogGroupsResponse
Int -> ReadS DescribeLogGroupsResponse
ReadS [DescribeLogGroupsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLogGroupsResponse]
$creadListPrec :: ReadPrec [DescribeLogGroupsResponse]
readPrec :: ReadPrec DescribeLogGroupsResponse
$creadPrec :: ReadPrec DescribeLogGroupsResponse
readList :: ReadS [DescribeLogGroupsResponse]
$creadList :: ReadS [DescribeLogGroupsResponse]
readsPrec :: Int -> ReadS DescribeLogGroupsResponse
$creadsPrec :: Int -> ReadS DescribeLogGroupsResponse
Prelude.Read, Int -> DescribeLogGroupsResponse -> ShowS
[DescribeLogGroupsResponse] -> ShowS
DescribeLogGroupsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLogGroupsResponse] -> ShowS
$cshowList :: [DescribeLogGroupsResponse] -> ShowS
show :: DescribeLogGroupsResponse -> String
$cshow :: DescribeLogGroupsResponse -> String
showsPrec :: Int -> DescribeLogGroupsResponse -> ShowS
$cshowsPrec :: Int -> DescribeLogGroupsResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeLogGroupsResponse x -> DescribeLogGroupsResponse
forall x.
DescribeLogGroupsResponse -> Rep DescribeLogGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeLogGroupsResponse x -> DescribeLogGroupsResponse
$cfrom :: forall x.
DescribeLogGroupsResponse -> Rep DescribeLogGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLogGroupsResponse' 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:
--
-- 'logGroups', 'describeLogGroupsResponse_logGroups' - The log groups.
--
-- If the @retentionInDays@ value is not included for a log group, then
-- that log group\'s events do not expire.
--
-- 'nextToken', 'describeLogGroupsResponse_nextToken' - Undocumented member.
--
-- 'httpStatus', 'describeLogGroupsResponse_httpStatus' - The response's http status code.
newDescribeLogGroupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeLogGroupsResponse
newDescribeLogGroupsResponse :: Int -> DescribeLogGroupsResponse
newDescribeLogGroupsResponse Int
pHttpStatus_ =
  DescribeLogGroupsResponse'
    { $sel:logGroups:DescribeLogGroupsResponse' :: Maybe [LogGroup]
logGroups =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeLogGroupsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeLogGroupsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The log groups.
--
-- If the @retentionInDays@ value is not included for a log group, then
-- that log group\'s events do not expire.
describeLogGroupsResponse_logGroups :: Lens.Lens' DescribeLogGroupsResponse (Prelude.Maybe [LogGroup])
describeLogGroupsResponse_logGroups :: Lens' DescribeLogGroupsResponse (Maybe [LogGroup])
describeLogGroupsResponse_logGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogGroupsResponse' {Maybe [LogGroup]
logGroups :: Maybe [LogGroup]
$sel:logGroups:DescribeLogGroupsResponse' :: DescribeLogGroupsResponse -> Maybe [LogGroup]
logGroups} -> Maybe [LogGroup]
logGroups) (\s :: DescribeLogGroupsResponse
s@DescribeLogGroupsResponse' {} Maybe [LogGroup]
a -> DescribeLogGroupsResponse
s {$sel:logGroups:DescribeLogGroupsResponse' :: Maybe [LogGroup]
logGroups = Maybe [LogGroup]
a} :: DescribeLogGroupsResponse) 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

-- | Undocumented member.
describeLogGroupsResponse_nextToken :: Lens.Lens' DescribeLogGroupsResponse (Prelude.Maybe Prelude.Text)
describeLogGroupsResponse_nextToken :: Lens' DescribeLogGroupsResponse (Maybe Text)
describeLogGroupsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogGroupsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeLogGroupsResponse' :: DescribeLogGroupsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeLogGroupsResponse
s@DescribeLogGroupsResponse' {} Maybe Text
a -> DescribeLogGroupsResponse
s {$sel:nextToken:DescribeLogGroupsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeLogGroupsResponse)

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

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