{-# 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.Config.DescribeOrganizationConfigRules
-- 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)
--
-- Returns a list of organization config rules.
--
-- When you specify the limit and the next token, you receive a paginated
-- response. Limit and next token are not applicable if you specify
-- organization config rule names. It is only applicable, when you request
-- all the organization config rules.
--
-- This operation returns paginated results.
module Amazonka.Config.DescribeOrganizationConfigRules
  ( -- * Creating a Request
    DescribeOrganizationConfigRules (..),
    newDescribeOrganizationConfigRules,

    -- * Request Lenses
    describeOrganizationConfigRules_organizationConfigRuleNames,
    describeOrganizationConfigRules_nextToken,
    describeOrganizationConfigRules_limit,

    -- * Destructuring the Response
    DescribeOrganizationConfigRulesResponse (..),
    newDescribeOrganizationConfigRulesResponse,

    -- * Response Lenses
    describeOrganizationConfigRulesResponse_organizationConfigRules,
    describeOrganizationConfigRulesResponse_nextToken,
    describeOrganizationConfigRulesResponse_httpStatus,
  )
where

import Amazonka.Config.Types
import qualified Amazonka.Core as Core
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:/ 'newDescribeOrganizationConfigRules' smart constructor.
data DescribeOrganizationConfigRules = DescribeOrganizationConfigRules'
  { -- | The names of organization config rules for which you want details. If
    -- you do not specify any names, Config returns details for all your
    -- organization config rules.
    DescribeOrganizationConfigRules -> Maybe [Text]
organizationConfigRuleNames :: Prelude.Maybe [Prelude.Text],
    -- | The @nextToken@ string returned on a previous page that you use to get
    -- the next page of results in a paginated response.
    DescribeOrganizationConfigRules -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of organization config rules returned on each page.
    -- If you do no specify a number, Config uses the default. The default is
    -- 100.
    DescribeOrganizationConfigRules -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural
  }
  deriving (DescribeOrganizationConfigRules
-> DescribeOrganizationConfigRules -> Bool
(DescribeOrganizationConfigRules
 -> DescribeOrganizationConfigRules -> Bool)
-> (DescribeOrganizationConfigRules
    -> DescribeOrganizationConfigRules -> Bool)
-> Eq DescribeOrganizationConfigRules
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeOrganizationConfigRules
-> DescribeOrganizationConfigRules -> Bool
$c/= :: DescribeOrganizationConfigRules
-> DescribeOrganizationConfigRules -> Bool
== :: DescribeOrganizationConfigRules
-> DescribeOrganizationConfigRules -> Bool
$c== :: DescribeOrganizationConfigRules
-> DescribeOrganizationConfigRules -> Bool
Prelude.Eq, ReadPrec [DescribeOrganizationConfigRules]
ReadPrec DescribeOrganizationConfigRules
Int -> ReadS DescribeOrganizationConfigRules
ReadS [DescribeOrganizationConfigRules]
(Int -> ReadS DescribeOrganizationConfigRules)
-> ReadS [DescribeOrganizationConfigRules]
-> ReadPrec DescribeOrganizationConfigRules
-> ReadPrec [DescribeOrganizationConfigRules]
-> Read DescribeOrganizationConfigRules
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeOrganizationConfigRules]
$creadListPrec :: ReadPrec [DescribeOrganizationConfigRules]
readPrec :: ReadPrec DescribeOrganizationConfigRules
$creadPrec :: ReadPrec DescribeOrganizationConfigRules
readList :: ReadS [DescribeOrganizationConfigRules]
$creadList :: ReadS [DescribeOrganizationConfigRules]
readsPrec :: Int -> ReadS DescribeOrganizationConfigRules
$creadsPrec :: Int -> ReadS DescribeOrganizationConfigRules
Prelude.Read, Int -> DescribeOrganizationConfigRules -> ShowS
[DescribeOrganizationConfigRules] -> ShowS
DescribeOrganizationConfigRules -> String
(Int -> DescribeOrganizationConfigRules -> ShowS)
-> (DescribeOrganizationConfigRules -> String)
-> ([DescribeOrganizationConfigRules] -> ShowS)
-> Show DescribeOrganizationConfigRules
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeOrganizationConfigRules] -> ShowS
$cshowList :: [DescribeOrganizationConfigRules] -> ShowS
show :: DescribeOrganizationConfigRules -> String
$cshow :: DescribeOrganizationConfigRules -> String
showsPrec :: Int -> DescribeOrganizationConfigRules -> ShowS
$cshowsPrec :: Int -> DescribeOrganizationConfigRules -> ShowS
Prelude.Show, (forall x.
 DescribeOrganizationConfigRules
 -> Rep DescribeOrganizationConfigRules x)
-> (forall x.
    Rep DescribeOrganizationConfigRules x
    -> DescribeOrganizationConfigRules)
-> Generic DescribeOrganizationConfigRules
forall x.
Rep DescribeOrganizationConfigRules x
-> DescribeOrganizationConfigRules
forall x.
DescribeOrganizationConfigRules
-> Rep DescribeOrganizationConfigRules x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeOrganizationConfigRules x
-> DescribeOrganizationConfigRules
$cfrom :: forall x.
DescribeOrganizationConfigRules
-> Rep DescribeOrganizationConfigRules x
Prelude.Generic)

-- |
-- Create a value of 'DescribeOrganizationConfigRules' 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:
--
-- 'organizationConfigRuleNames', 'describeOrganizationConfigRules_organizationConfigRuleNames' - The names of organization config rules for which you want details. If
-- you do not specify any names, Config returns details for all your
-- organization config rules.
--
-- 'nextToken', 'describeOrganizationConfigRules_nextToken' - The @nextToken@ string returned on a previous page that you use to get
-- the next page of results in a paginated response.
--
-- 'limit', 'describeOrganizationConfigRules_limit' - The maximum number of organization config rules returned on each page.
-- If you do no specify a number, Config uses the default. The default is
-- 100.
newDescribeOrganizationConfigRules ::
  DescribeOrganizationConfigRules
newDescribeOrganizationConfigRules :: DescribeOrganizationConfigRules
newDescribeOrganizationConfigRules =
  DescribeOrganizationConfigRules' :: Maybe [Text]
-> Maybe Text -> Maybe Natural -> DescribeOrganizationConfigRules
DescribeOrganizationConfigRules'
    { $sel:organizationConfigRuleNames:DescribeOrganizationConfigRules' :: Maybe [Text]
organizationConfigRuleNames =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeOrganizationConfigRules' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeOrganizationConfigRules' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The names of organization config rules for which you want details. If
-- you do not specify any names, Config returns details for all your
-- organization config rules.
describeOrganizationConfigRules_organizationConfigRuleNames :: Lens.Lens' DescribeOrganizationConfigRules (Prelude.Maybe [Prelude.Text])
describeOrganizationConfigRules_organizationConfigRuleNames :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeOrganizationConfigRules
-> f DescribeOrganizationConfigRules
describeOrganizationConfigRules_organizationConfigRuleNames = (DescribeOrganizationConfigRules -> Maybe [Text])
-> (DescribeOrganizationConfigRules
    -> Maybe [Text] -> DescribeOrganizationConfigRules)
-> Lens
     DescribeOrganizationConfigRules
     DescribeOrganizationConfigRules
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeOrganizationConfigRules' {Maybe [Text]
organizationConfigRuleNames :: Maybe [Text]
$sel:organizationConfigRuleNames:DescribeOrganizationConfigRules' :: DescribeOrganizationConfigRules -> Maybe [Text]
organizationConfigRuleNames} -> Maybe [Text]
organizationConfigRuleNames) (\s :: DescribeOrganizationConfigRules
s@DescribeOrganizationConfigRules' {} Maybe [Text]
a -> DescribeOrganizationConfigRules
s {$sel:organizationConfigRuleNames:DescribeOrganizationConfigRules' :: Maybe [Text]
organizationConfigRuleNames = Maybe [Text]
a} :: DescribeOrganizationConfigRules) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeOrganizationConfigRules
 -> f DescribeOrganizationConfigRules)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeOrganizationConfigRules
-> f DescribeOrganizationConfigRules
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The @nextToken@ string returned on a previous page that you use to get
-- the next page of results in a paginated response.
describeOrganizationConfigRules_nextToken :: Lens.Lens' DescribeOrganizationConfigRules (Prelude.Maybe Prelude.Text)
describeOrganizationConfigRules_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeOrganizationConfigRules
-> f DescribeOrganizationConfigRules
describeOrganizationConfigRules_nextToken = (DescribeOrganizationConfigRules -> Maybe Text)
-> (DescribeOrganizationConfigRules
    -> Maybe Text -> DescribeOrganizationConfigRules)
-> Lens
     DescribeOrganizationConfigRules
     DescribeOrganizationConfigRules
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeOrganizationConfigRules' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeOrganizationConfigRules' :: DescribeOrganizationConfigRules -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeOrganizationConfigRules
s@DescribeOrganizationConfigRules' {} Maybe Text
a -> DescribeOrganizationConfigRules
s {$sel:nextToken:DescribeOrganizationConfigRules' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeOrganizationConfigRules)

-- | The maximum number of organization config rules returned on each page.
-- If you do no specify a number, Config uses the default. The default is
-- 100.
describeOrganizationConfigRules_limit :: Lens.Lens' DescribeOrganizationConfigRules (Prelude.Maybe Prelude.Natural)
describeOrganizationConfigRules_limit :: (Maybe Natural -> f (Maybe Natural))
-> DescribeOrganizationConfigRules
-> f DescribeOrganizationConfigRules
describeOrganizationConfigRules_limit = (DescribeOrganizationConfigRules -> Maybe Natural)
-> (DescribeOrganizationConfigRules
    -> Maybe Natural -> DescribeOrganizationConfigRules)
-> Lens
     DescribeOrganizationConfigRules
     DescribeOrganizationConfigRules
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeOrganizationConfigRules' {Maybe Natural
limit :: Maybe Natural
$sel:limit:DescribeOrganizationConfigRules' :: DescribeOrganizationConfigRules -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: DescribeOrganizationConfigRules
s@DescribeOrganizationConfigRules' {} Maybe Natural
a -> DescribeOrganizationConfigRules
s {$sel:limit:DescribeOrganizationConfigRules' :: Maybe Natural
limit = Maybe Natural
a} :: DescribeOrganizationConfigRules)

instance
  Core.AWSPager
    DescribeOrganizationConfigRules
  where
  page :: DescribeOrganizationConfigRules
-> AWSResponse DescribeOrganizationConfigRules
-> Maybe DescribeOrganizationConfigRules
page DescribeOrganizationConfigRules
rq AWSResponse DescribeOrganizationConfigRules
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeOrganizationConfigRules
DescribeOrganizationConfigRulesResponse
rs
            DescribeOrganizationConfigRulesResponse
-> Getting
     (First Text) DescribeOrganizationConfigRulesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeOrganizationConfigRulesResponse
-> Const (First Text) DescribeOrganizationConfigRulesResponse
Lens' DescribeOrganizationConfigRulesResponse (Maybe Text)
describeOrganizationConfigRulesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeOrganizationConfigRulesResponse
 -> Const (First Text) DescribeOrganizationConfigRulesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) DescribeOrganizationConfigRulesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeOrganizationConfigRules
forall a. Maybe a
Prelude.Nothing
    | Maybe [OrganizationConfigRule] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeOrganizationConfigRules
DescribeOrganizationConfigRulesResponse
rs
            DescribeOrganizationConfigRulesResponse
-> Getting
     (First [OrganizationConfigRule])
     DescribeOrganizationConfigRulesResponse
     [OrganizationConfigRule]
-> Maybe [OrganizationConfigRule]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [OrganizationConfigRule]
 -> Const
      (First [OrganizationConfigRule]) (Maybe [OrganizationConfigRule]))
-> DescribeOrganizationConfigRulesResponse
-> Const
     (First [OrganizationConfigRule])
     DescribeOrganizationConfigRulesResponse
Lens'
  DescribeOrganizationConfigRulesResponse
  (Maybe [OrganizationConfigRule])
describeOrganizationConfigRulesResponse_organizationConfigRules
              ((Maybe [OrganizationConfigRule]
  -> Const
       (First [OrganizationConfigRule]) (Maybe [OrganizationConfigRule]))
 -> DescribeOrganizationConfigRulesResponse
 -> Const
      (First [OrganizationConfigRule])
      DescribeOrganizationConfigRulesResponse)
-> (([OrganizationConfigRule]
     -> Const (First [OrganizationConfigRule]) [OrganizationConfigRule])
    -> Maybe [OrganizationConfigRule]
    -> Const
         (First [OrganizationConfigRule]) (Maybe [OrganizationConfigRule]))
-> Getting
     (First [OrganizationConfigRule])
     DescribeOrganizationConfigRulesResponse
     [OrganizationConfigRule]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([OrganizationConfigRule]
 -> Const (First [OrganizationConfigRule]) [OrganizationConfigRule])
-> Maybe [OrganizationConfigRule]
-> Const
     (First [OrganizationConfigRule]) (Maybe [OrganizationConfigRule])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeOrganizationConfigRules
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeOrganizationConfigRules
-> Maybe DescribeOrganizationConfigRules
forall a. a -> Maybe a
Prelude.Just (DescribeOrganizationConfigRules
 -> Maybe DescribeOrganizationConfigRules)
-> DescribeOrganizationConfigRules
-> Maybe DescribeOrganizationConfigRules
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeOrganizationConfigRules
rq
          DescribeOrganizationConfigRules
-> (DescribeOrganizationConfigRules
    -> DescribeOrganizationConfigRules)
-> DescribeOrganizationConfigRules
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeOrganizationConfigRules
-> Identity DescribeOrganizationConfigRules
Lens
  DescribeOrganizationConfigRules
  DescribeOrganizationConfigRules
  (Maybe Text)
  (Maybe Text)
describeOrganizationConfigRules_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeOrganizationConfigRules
 -> Identity DescribeOrganizationConfigRules)
-> Maybe Text
-> DescribeOrganizationConfigRules
-> DescribeOrganizationConfigRules
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeOrganizationConfigRules
DescribeOrganizationConfigRulesResponse
rs
          DescribeOrganizationConfigRulesResponse
-> Getting
     (First Text) DescribeOrganizationConfigRulesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeOrganizationConfigRulesResponse
-> Const (First Text) DescribeOrganizationConfigRulesResponse
Lens' DescribeOrganizationConfigRulesResponse (Maybe Text)
describeOrganizationConfigRulesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeOrganizationConfigRulesResponse
 -> Const (First Text) DescribeOrganizationConfigRulesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) DescribeOrganizationConfigRulesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance
  Core.AWSRequest
    DescribeOrganizationConfigRules
  where
  type
    AWSResponse DescribeOrganizationConfigRules =
      DescribeOrganizationConfigRulesResponse
  request :: DescribeOrganizationConfigRules
-> Request DescribeOrganizationConfigRules
request = Service
-> DescribeOrganizationConfigRules
-> Request DescribeOrganizationConfigRules
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeOrganizationConfigRules
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeOrganizationConfigRules)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeOrganizationConfigRules))
-> Logger
-> Service
-> Proxy DescribeOrganizationConfigRules
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeOrganizationConfigRules)))
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 ->
          Maybe [OrganizationConfigRule]
-> Maybe Text -> Int -> DescribeOrganizationConfigRulesResponse
DescribeOrganizationConfigRulesResponse'
            (Maybe [OrganizationConfigRule]
 -> Maybe Text -> Int -> DescribeOrganizationConfigRulesResponse)
-> Either String (Maybe [OrganizationConfigRule])
-> Either
     String
     (Maybe Text -> Int -> DescribeOrganizationConfigRulesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Either String (Maybe (Maybe [OrganizationConfigRule]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"OrganizationConfigRules"
                            Either String (Maybe (Maybe [OrganizationConfigRule]))
-> Maybe [OrganizationConfigRule]
-> Either String (Maybe [OrganizationConfigRule])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [OrganizationConfigRule]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String
  (Maybe Text -> Int -> DescribeOrganizationConfigRulesResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeOrganizationConfigRulesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> DescribeOrganizationConfigRulesResponse)
-> Either String Int
-> Either String DescribeOrganizationConfigRulesResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance
  Prelude.Hashable
    DescribeOrganizationConfigRules

instance
  Prelude.NFData
    DescribeOrganizationConfigRules

instance
  Core.ToHeaders
    DescribeOrganizationConfigRules
  where
  toHeaders :: DescribeOrganizationConfigRules -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DescribeOrganizationConfigRules -> 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
"StarlingDoveService.DescribeOrganizationConfigRules" ::
                          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 DescribeOrganizationConfigRules where
  toJSON :: DescribeOrganizationConfigRules -> Value
toJSON DescribeOrganizationConfigRules' {Maybe Natural
Maybe [Text]
Maybe Text
limit :: Maybe Natural
nextToken :: Maybe Text
organizationConfigRuleNames :: Maybe [Text]
$sel:limit:DescribeOrganizationConfigRules' :: DescribeOrganizationConfigRules -> Maybe Natural
$sel:nextToken:DescribeOrganizationConfigRules' :: DescribeOrganizationConfigRules -> Maybe Text
$sel:organizationConfigRuleNames:DescribeOrganizationConfigRules' :: DescribeOrganizationConfigRules -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OrganizationConfigRuleNames" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
organizationConfigRuleNames,
            (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"Limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit
          ]
      )

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

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

-- | /See:/ 'newDescribeOrganizationConfigRulesResponse' smart constructor.
data DescribeOrganizationConfigRulesResponse = DescribeOrganizationConfigRulesResponse'
  { -- | Returns a list of @OrganizationConfigRule@ objects.
    DescribeOrganizationConfigRulesResponse
-> Maybe [OrganizationConfigRule]
organizationConfigRules :: Prelude.Maybe [OrganizationConfigRule],
    -- | The @nextToken@ string returned on a previous page that you use to get
    -- the next page of results in a paginated response.
    DescribeOrganizationConfigRulesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeOrganizationConfigRulesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeOrganizationConfigRulesResponse
-> DescribeOrganizationConfigRulesResponse -> Bool
(DescribeOrganizationConfigRulesResponse
 -> DescribeOrganizationConfigRulesResponse -> Bool)
-> (DescribeOrganizationConfigRulesResponse
    -> DescribeOrganizationConfigRulesResponse -> Bool)
-> Eq DescribeOrganizationConfigRulesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeOrganizationConfigRulesResponse
-> DescribeOrganizationConfigRulesResponse -> Bool
$c/= :: DescribeOrganizationConfigRulesResponse
-> DescribeOrganizationConfigRulesResponse -> Bool
== :: DescribeOrganizationConfigRulesResponse
-> DescribeOrganizationConfigRulesResponse -> Bool
$c== :: DescribeOrganizationConfigRulesResponse
-> DescribeOrganizationConfigRulesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeOrganizationConfigRulesResponse]
ReadPrec DescribeOrganizationConfigRulesResponse
Int -> ReadS DescribeOrganizationConfigRulesResponse
ReadS [DescribeOrganizationConfigRulesResponse]
(Int -> ReadS DescribeOrganizationConfigRulesResponse)
-> ReadS [DescribeOrganizationConfigRulesResponse]
-> ReadPrec DescribeOrganizationConfigRulesResponse
-> ReadPrec [DescribeOrganizationConfigRulesResponse]
-> Read DescribeOrganizationConfigRulesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeOrganizationConfigRulesResponse]
$creadListPrec :: ReadPrec [DescribeOrganizationConfigRulesResponse]
readPrec :: ReadPrec DescribeOrganizationConfigRulesResponse
$creadPrec :: ReadPrec DescribeOrganizationConfigRulesResponse
readList :: ReadS [DescribeOrganizationConfigRulesResponse]
$creadList :: ReadS [DescribeOrganizationConfigRulesResponse]
readsPrec :: Int -> ReadS DescribeOrganizationConfigRulesResponse
$creadsPrec :: Int -> ReadS DescribeOrganizationConfigRulesResponse
Prelude.Read, Int -> DescribeOrganizationConfigRulesResponse -> ShowS
[DescribeOrganizationConfigRulesResponse] -> ShowS
DescribeOrganizationConfigRulesResponse -> String
(Int -> DescribeOrganizationConfigRulesResponse -> ShowS)
-> (DescribeOrganizationConfigRulesResponse -> String)
-> ([DescribeOrganizationConfigRulesResponse] -> ShowS)
-> Show DescribeOrganizationConfigRulesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeOrganizationConfigRulesResponse] -> ShowS
$cshowList :: [DescribeOrganizationConfigRulesResponse] -> ShowS
show :: DescribeOrganizationConfigRulesResponse -> String
$cshow :: DescribeOrganizationConfigRulesResponse -> String
showsPrec :: Int -> DescribeOrganizationConfigRulesResponse -> ShowS
$cshowsPrec :: Int -> DescribeOrganizationConfigRulesResponse -> ShowS
Prelude.Show, (forall x.
 DescribeOrganizationConfigRulesResponse
 -> Rep DescribeOrganizationConfigRulesResponse x)
-> (forall x.
    Rep DescribeOrganizationConfigRulesResponse x
    -> DescribeOrganizationConfigRulesResponse)
-> Generic DescribeOrganizationConfigRulesResponse
forall x.
Rep DescribeOrganizationConfigRulesResponse x
-> DescribeOrganizationConfigRulesResponse
forall x.
DescribeOrganizationConfigRulesResponse
-> Rep DescribeOrganizationConfigRulesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeOrganizationConfigRulesResponse x
-> DescribeOrganizationConfigRulesResponse
$cfrom :: forall x.
DescribeOrganizationConfigRulesResponse
-> Rep DescribeOrganizationConfigRulesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeOrganizationConfigRulesResponse' 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:
--
-- 'organizationConfigRules', 'describeOrganizationConfigRulesResponse_organizationConfigRules' - Returns a list of @OrganizationConfigRule@ objects.
--
-- 'nextToken', 'describeOrganizationConfigRulesResponse_nextToken' - The @nextToken@ string returned on a previous page that you use to get
-- the next page of results in a paginated response.
--
-- 'httpStatus', 'describeOrganizationConfigRulesResponse_httpStatus' - The response's http status code.
newDescribeOrganizationConfigRulesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeOrganizationConfigRulesResponse
newDescribeOrganizationConfigRulesResponse :: Int -> DescribeOrganizationConfigRulesResponse
newDescribeOrganizationConfigRulesResponse
  Int
pHttpStatus_ =
    DescribeOrganizationConfigRulesResponse' :: Maybe [OrganizationConfigRule]
-> Maybe Text -> Int -> DescribeOrganizationConfigRulesResponse
DescribeOrganizationConfigRulesResponse'
      { $sel:organizationConfigRules:DescribeOrganizationConfigRulesResponse' :: Maybe [OrganizationConfigRule]
organizationConfigRules =
          Maybe [OrganizationConfigRule]
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:DescribeOrganizationConfigRulesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeOrganizationConfigRulesResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | Returns a list of @OrganizationConfigRule@ objects.
describeOrganizationConfigRulesResponse_organizationConfigRules :: Lens.Lens' DescribeOrganizationConfigRulesResponse (Prelude.Maybe [OrganizationConfigRule])
describeOrganizationConfigRulesResponse_organizationConfigRules :: (Maybe [OrganizationConfigRule]
 -> f (Maybe [OrganizationConfigRule]))
-> DescribeOrganizationConfigRulesResponse
-> f DescribeOrganizationConfigRulesResponse
describeOrganizationConfigRulesResponse_organizationConfigRules = (DescribeOrganizationConfigRulesResponse
 -> Maybe [OrganizationConfigRule])
-> (DescribeOrganizationConfigRulesResponse
    -> Maybe [OrganizationConfigRule]
    -> DescribeOrganizationConfigRulesResponse)
-> Lens'
     DescribeOrganizationConfigRulesResponse
     (Maybe [OrganizationConfigRule])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeOrganizationConfigRulesResponse' {Maybe [OrganizationConfigRule]
organizationConfigRules :: Maybe [OrganizationConfigRule]
$sel:organizationConfigRules:DescribeOrganizationConfigRulesResponse' :: DescribeOrganizationConfigRulesResponse
-> Maybe [OrganizationConfigRule]
organizationConfigRules} -> Maybe [OrganizationConfigRule]
organizationConfigRules) (\s :: DescribeOrganizationConfigRulesResponse
s@DescribeOrganizationConfigRulesResponse' {} Maybe [OrganizationConfigRule]
a -> DescribeOrganizationConfigRulesResponse
s {$sel:organizationConfigRules:DescribeOrganizationConfigRulesResponse' :: Maybe [OrganizationConfigRule]
organizationConfigRules = Maybe [OrganizationConfigRule]
a} :: DescribeOrganizationConfigRulesResponse) ((Maybe [OrganizationConfigRule]
  -> f (Maybe [OrganizationConfigRule]))
 -> DescribeOrganizationConfigRulesResponse
 -> f DescribeOrganizationConfigRulesResponse)
-> ((Maybe [OrganizationConfigRule]
     -> f (Maybe [OrganizationConfigRule]))
    -> Maybe [OrganizationConfigRule]
    -> f (Maybe [OrganizationConfigRule]))
-> (Maybe [OrganizationConfigRule]
    -> f (Maybe [OrganizationConfigRule]))
-> DescribeOrganizationConfigRulesResponse
-> f DescribeOrganizationConfigRulesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [OrganizationConfigRule]
  [OrganizationConfigRule]
  [OrganizationConfigRule]
  [OrganizationConfigRule]
-> Iso
     (Maybe [OrganizationConfigRule])
     (Maybe [OrganizationConfigRule])
     (Maybe [OrganizationConfigRule])
     (Maybe [OrganizationConfigRule])
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 AnIso
  [OrganizationConfigRule]
  [OrganizationConfigRule]
  [OrganizationConfigRule]
  [OrganizationConfigRule]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The @nextToken@ string returned on a previous page that you use to get
-- the next page of results in a paginated response.
describeOrganizationConfigRulesResponse_nextToken :: Lens.Lens' DescribeOrganizationConfigRulesResponse (Prelude.Maybe Prelude.Text)
describeOrganizationConfigRulesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeOrganizationConfigRulesResponse
-> f DescribeOrganizationConfigRulesResponse
describeOrganizationConfigRulesResponse_nextToken = (DescribeOrganizationConfigRulesResponse -> Maybe Text)
-> (DescribeOrganizationConfigRulesResponse
    -> Maybe Text -> DescribeOrganizationConfigRulesResponse)
-> Lens' DescribeOrganizationConfigRulesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeOrganizationConfigRulesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeOrganizationConfigRulesResponse' :: DescribeOrganizationConfigRulesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeOrganizationConfigRulesResponse
s@DescribeOrganizationConfigRulesResponse' {} Maybe Text
a -> DescribeOrganizationConfigRulesResponse
s {$sel:nextToken:DescribeOrganizationConfigRulesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeOrganizationConfigRulesResponse)

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

instance
  Prelude.NFData
    DescribeOrganizationConfigRulesResponse