{-# 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.AccessAnalyzer.ValidatePolicy
-- 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)
--
-- Requests the validation of a policy and returns a list of findings. The
-- findings help you identify issues and provide actionable recommendations
-- to resolve the issue and enable you to author functional policies that
-- meet security best practices.
--
-- This operation returns paginated results.
module Amazonka.AccessAnalyzer.ValidatePolicy
  ( -- * Creating a Request
    ValidatePolicy (..),
    newValidatePolicy,

    -- * Request Lenses
    validatePolicy_locale,
    validatePolicy_nextToken,
    validatePolicy_maxResults,
    validatePolicy_policyDocument,
    validatePolicy_policyType,

    -- * Destructuring the Response
    ValidatePolicyResponse (..),
    newValidatePolicyResponse,

    -- * Response Lenses
    validatePolicyResponse_nextToken,
    validatePolicyResponse_httpStatus,
    validatePolicyResponse_findings,
  )
where

import Amazonka.AccessAnalyzer.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:/ 'newValidatePolicy' smart constructor.
data ValidatePolicy = ValidatePolicy'
  { -- | The locale to use for localizing the findings.
    ValidatePolicy -> Maybe Locale
locale :: Prelude.Maybe Locale,
    -- | A token used for pagination of results returned.
    ValidatePolicy -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return in the response.
    ValidatePolicy -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | The JSON policy document to use as the content for the policy.
    ValidatePolicy -> Text
policyDocument :: Prelude.Text,
    -- | The type of policy to validate. Identity policies grant permissions to
    -- IAM principals. Identity policies include managed and inline policies
    -- for IAM roles, users, and groups. They also include service-control
    -- policies (SCPs) that are attached to an Amazon Web Services
    -- organization, organizational unit (OU), or an account.
    --
    -- Resource policies grant permissions on Amazon Web Services resources.
    -- Resource policies include trust policies for IAM roles and bucket
    -- policies for Amazon S3 buckets. You can provide a generic input such as
    -- identity policy or resource policy or a specific input such as managed
    -- policy or Amazon S3 bucket policy.
    ValidatePolicy -> PolicyType
policyType :: PolicyType
  }
  deriving (ValidatePolicy -> ValidatePolicy -> Bool
(ValidatePolicy -> ValidatePolicy -> Bool)
-> (ValidatePolicy -> ValidatePolicy -> Bool) -> Eq ValidatePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ValidatePolicy -> ValidatePolicy -> Bool
$c/= :: ValidatePolicy -> ValidatePolicy -> Bool
== :: ValidatePolicy -> ValidatePolicy -> Bool
$c== :: ValidatePolicy -> ValidatePolicy -> Bool
Prelude.Eq, ReadPrec [ValidatePolicy]
ReadPrec ValidatePolicy
Int -> ReadS ValidatePolicy
ReadS [ValidatePolicy]
(Int -> ReadS ValidatePolicy)
-> ReadS [ValidatePolicy]
-> ReadPrec ValidatePolicy
-> ReadPrec [ValidatePolicy]
-> Read ValidatePolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ValidatePolicy]
$creadListPrec :: ReadPrec [ValidatePolicy]
readPrec :: ReadPrec ValidatePolicy
$creadPrec :: ReadPrec ValidatePolicy
readList :: ReadS [ValidatePolicy]
$creadList :: ReadS [ValidatePolicy]
readsPrec :: Int -> ReadS ValidatePolicy
$creadsPrec :: Int -> ReadS ValidatePolicy
Prelude.Read, Int -> ValidatePolicy -> ShowS
[ValidatePolicy] -> ShowS
ValidatePolicy -> String
(Int -> ValidatePolicy -> ShowS)
-> (ValidatePolicy -> String)
-> ([ValidatePolicy] -> ShowS)
-> Show ValidatePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ValidatePolicy] -> ShowS
$cshowList :: [ValidatePolicy] -> ShowS
show :: ValidatePolicy -> String
$cshow :: ValidatePolicy -> String
showsPrec :: Int -> ValidatePolicy -> ShowS
$cshowsPrec :: Int -> ValidatePolicy -> ShowS
Prelude.Show, (forall x. ValidatePolicy -> Rep ValidatePolicy x)
-> (forall x. Rep ValidatePolicy x -> ValidatePolicy)
-> Generic ValidatePolicy
forall x. Rep ValidatePolicy x -> ValidatePolicy
forall x. ValidatePolicy -> Rep ValidatePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ValidatePolicy x -> ValidatePolicy
$cfrom :: forall x. ValidatePolicy -> Rep ValidatePolicy x
Prelude.Generic)

-- |
-- Create a value of 'ValidatePolicy' 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:
--
-- 'locale', 'validatePolicy_locale' - The locale to use for localizing the findings.
--
-- 'nextToken', 'validatePolicy_nextToken' - A token used for pagination of results returned.
--
-- 'maxResults', 'validatePolicy_maxResults' - The maximum number of results to return in the response.
--
-- 'policyDocument', 'validatePolicy_policyDocument' - The JSON policy document to use as the content for the policy.
--
-- 'policyType', 'validatePolicy_policyType' - The type of policy to validate. Identity policies grant permissions to
-- IAM principals. Identity policies include managed and inline policies
-- for IAM roles, users, and groups. They also include service-control
-- policies (SCPs) that are attached to an Amazon Web Services
-- organization, organizational unit (OU), or an account.
--
-- Resource policies grant permissions on Amazon Web Services resources.
-- Resource policies include trust policies for IAM roles and bucket
-- policies for Amazon S3 buckets. You can provide a generic input such as
-- identity policy or resource policy or a specific input such as managed
-- policy or Amazon S3 bucket policy.
newValidatePolicy ::
  -- | 'policyDocument'
  Prelude.Text ->
  -- | 'policyType'
  PolicyType ->
  ValidatePolicy
newValidatePolicy :: Text -> PolicyType -> ValidatePolicy
newValidatePolicy Text
pPolicyDocument_ PolicyType
pPolicyType_ =
  ValidatePolicy' :: Maybe Locale
-> Maybe Text -> Maybe Int -> Text -> PolicyType -> ValidatePolicy
ValidatePolicy'
    { $sel:locale:ValidatePolicy' :: Maybe Locale
locale = Maybe Locale
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ValidatePolicy' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ValidatePolicy' :: Maybe Int
maxResults = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:policyDocument:ValidatePolicy' :: Text
policyDocument = Text
pPolicyDocument_,
      $sel:policyType:ValidatePolicy' :: PolicyType
policyType = PolicyType
pPolicyType_
    }

-- | The locale to use for localizing the findings.
validatePolicy_locale :: Lens.Lens' ValidatePolicy (Prelude.Maybe Locale)
validatePolicy_locale :: (Maybe Locale -> f (Maybe Locale))
-> ValidatePolicy -> f ValidatePolicy
validatePolicy_locale = (ValidatePolicy -> Maybe Locale)
-> (ValidatePolicy -> Maybe Locale -> ValidatePolicy)
-> Lens ValidatePolicy ValidatePolicy (Maybe Locale) (Maybe Locale)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidatePolicy' {Maybe Locale
locale :: Maybe Locale
$sel:locale:ValidatePolicy' :: ValidatePolicy -> Maybe Locale
locale} -> Maybe Locale
locale) (\s :: ValidatePolicy
s@ValidatePolicy' {} Maybe Locale
a -> ValidatePolicy
s {$sel:locale:ValidatePolicy' :: Maybe Locale
locale = Maybe Locale
a} :: ValidatePolicy)

-- | A token used for pagination of results returned.
validatePolicy_nextToken :: Lens.Lens' ValidatePolicy (Prelude.Maybe Prelude.Text)
validatePolicy_nextToken :: (Maybe Text -> f (Maybe Text))
-> ValidatePolicy -> f ValidatePolicy
validatePolicy_nextToken = (ValidatePolicy -> Maybe Text)
-> (ValidatePolicy -> Maybe Text -> ValidatePolicy)
-> Lens ValidatePolicy ValidatePolicy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidatePolicy' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ValidatePolicy' :: ValidatePolicy -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ValidatePolicy
s@ValidatePolicy' {} Maybe Text
a -> ValidatePolicy
s {$sel:nextToken:ValidatePolicy' :: Maybe Text
nextToken = Maybe Text
a} :: ValidatePolicy)

-- | The maximum number of results to return in the response.
validatePolicy_maxResults :: Lens.Lens' ValidatePolicy (Prelude.Maybe Prelude.Int)
validatePolicy_maxResults :: (Maybe Int -> f (Maybe Int)) -> ValidatePolicy -> f ValidatePolicy
validatePolicy_maxResults = (ValidatePolicy -> Maybe Int)
-> (ValidatePolicy -> Maybe Int -> ValidatePolicy)
-> Lens ValidatePolicy ValidatePolicy (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidatePolicy' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:ValidatePolicy' :: ValidatePolicy -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: ValidatePolicy
s@ValidatePolicy' {} Maybe Int
a -> ValidatePolicy
s {$sel:maxResults:ValidatePolicy' :: Maybe Int
maxResults = Maybe Int
a} :: ValidatePolicy)

-- | The JSON policy document to use as the content for the policy.
validatePolicy_policyDocument :: Lens.Lens' ValidatePolicy Prelude.Text
validatePolicy_policyDocument :: (Text -> f Text) -> ValidatePolicy -> f ValidatePolicy
validatePolicy_policyDocument = (ValidatePolicy -> Text)
-> (ValidatePolicy -> Text -> ValidatePolicy)
-> Lens ValidatePolicy ValidatePolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidatePolicy' {Text
policyDocument :: Text
$sel:policyDocument:ValidatePolicy' :: ValidatePolicy -> Text
policyDocument} -> Text
policyDocument) (\s :: ValidatePolicy
s@ValidatePolicy' {} Text
a -> ValidatePolicy
s {$sel:policyDocument:ValidatePolicy' :: Text
policyDocument = Text
a} :: ValidatePolicy)

-- | The type of policy to validate. Identity policies grant permissions to
-- IAM principals. Identity policies include managed and inline policies
-- for IAM roles, users, and groups. They also include service-control
-- policies (SCPs) that are attached to an Amazon Web Services
-- organization, organizational unit (OU), or an account.
--
-- Resource policies grant permissions on Amazon Web Services resources.
-- Resource policies include trust policies for IAM roles and bucket
-- policies for Amazon S3 buckets. You can provide a generic input such as
-- identity policy or resource policy or a specific input such as managed
-- policy or Amazon S3 bucket policy.
validatePolicy_policyType :: Lens.Lens' ValidatePolicy PolicyType
validatePolicy_policyType :: (PolicyType -> f PolicyType) -> ValidatePolicy -> f ValidatePolicy
validatePolicy_policyType = (ValidatePolicy -> PolicyType)
-> (ValidatePolicy -> PolicyType -> ValidatePolicy)
-> Lens ValidatePolicy ValidatePolicy PolicyType PolicyType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidatePolicy' {PolicyType
policyType :: PolicyType
$sel:policyType:ValidatePolicy' :: ValidatePolicy -> PolicyType
policyType} -> PolicyType
policyType) (\s :: ValidatePolicy
s@ValidatePolicy' {} PolicyType
a -> ValidatePolicy
s {$sel:policyType:ValidatePolicy' :: PolicyType
policyType = PolicyType
a} :: ValidatePolicy)

instance Core.AWSPager ValidatePolicy where
  page :: ValidatePolicy
-> AWSResponse ValidatePolicy -> Maybe ValidatePolicy
page ValidatePolicy
rq AWSResponse ValidatePolicy
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ValidatePolicy
ValidatePolicyResponse
rs
            ValidatePolicyResponse
-> Getting (First Text) ValidatePolicyResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ValidatePolicyResponse
-> Const (First Text) ValidatePolicyResponse
Lens' ValidatePolicyResponse (Maybe Text)
validatePolicyResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ValidatePolicyResponse
 -> Const (First Text) ValidatePolicyResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ValidatePolicyResponse 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 ValidatePolicy
forall a. Maybe a
Prelude.Nothing
    | [ValidatePolicyFinding] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        (AWSResponse ValidatePolicy
ValidatePolicyResponse
rs ValidatePolicyResponse
-> Getting
     [ValidatePolicyFinding]
     ValidatePolicyResponse
     [ValidatePolicyFinding]
-> [ValidatePolicyFinding]
forall s a. s -> Getting a s a -> a
Lens.^. Getting
  [ValidatePolicyFinding]
  ValidatePolicyResponse
  [ValidatePolicyFinding]
Lens' ValidatePolicyResponse [ValidatePolicyFinding]
validatePolicyResponse_findings) =
      Maybe ValidatePolicy
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ValidatePolicy -> Maybe ValidatePolicy
forall a. a -> Maybe a
Prelude.Just (ValidatePolicy -> Maybe ValidatePolicy)
-> ValidatePolicy -> Maybe ValidatePolicy
forall a b. (a -> b) -> a -> b
Prelude.$
        ValidatePolicy
rq
          ValidatePolicy
-> (ValidatePolicy -> ValidatePolicy) -> ValidatePolicy
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ValidatePolicy -> Identity ValidatePolicy
Lens ValidatePolicy ValidatePolicy (Maybe Text) (Maybe Text)
validatePolicy_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ValidatePolicy -> Identity ValidatePolicy)
-> Maybe Text -> ValidatePolicy -> ValidatePolicy
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ValidatePolicy
ValidatePolicyResponse
rs
          ValidatePolicyResponse
-> Getting (First Text) ValidatePolicyResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ValidatePolicyResponse
-> Const (First Text) ValidatePolicyResponse
Lens' ValidatePolicyResponse (Maybe Text)
validatePolicyResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ValidatePolicyResponse
 -> Const (First Text) ValidatePolicyResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ValidatePolicyResponse 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 ValidatePolicy where
  type
    AWSResponse ValidatePolicy =
      ValidatePolicyResponse
  request :: ValidatePolicy -> Request ValidatePolicy
request = Service -> ValidatePolicy -> Request ValidatePolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ValidatePolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ValidatePolicy)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ValidatePolicy))
-> Logger
-> Service
-> Proxy ValidatePolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ValidatePolicy)))
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 Text
-> Int -> [ValidatePolicyFinding] -> ValidatePolicyResponse
ValidatePolicyResponse'
            (Maybe Text
 -> Int -> [ValidatePolicyFinding] -> ValidatePolicyResponse)
-> Either String (Maybe Text)
-> Either
     String (Int -> [ValidatePolicyFinding] -> ValidatePolicyResponse)
forall (f :: * -> *) a b. Functor 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 -> [ValidatePolicyFinding] -> ValidatePolicyResponse)
-> Either String Int
-> Either
     String ([ValidatePolicyFinding] -> ValidatePolicyResponse)
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))
            Either String ([ValidatePolicyFinding] -> ValidatePolicyResponse)
-> Either String [ValidatePolicyFinding]
-> Either String ValidatePolicyResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [ValidatePolicyFinding])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"findings" Either String (Maybe [ValidatePolicyFinding])
-> [ValidatePolicyFinding] -> Either String [ValidatePolicyFinding]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [ValidatePolicyFinding]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ValidatePolicy

instance Prelude.NFData ValidatePolicy

instance Core.ToHeaders ValidatePolicy where
  toHeaders :: ValidatePolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ValidatePolicy -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 ValidatePolicy where
  toJSON :: ValidatePolicy -> Value
toJSON ValidatePolicy' {Maybe Int
Maybe Text
Maybe Locale
Text
PolicyType
policyType :: PolicyType
policyDocument :: Text
maxResults :: Maybe Int
nextToken :: Maybe Text
locale :: Maybe Locale
$sel:policyType:ValidatePolicy' :: ValidatePolicy -> PolicyType
$sel:policyDocument:ValidatePolicy' :: ValidatePolicy -> Text
$sel:maxResults:ValidatePolicy' :: ValidatePolicy -> Maybe Int
$sel:nextToken:ValidatePolicy' :: ValidatePolicy -> Maybe Text
$sel:locale:ValidatePolicy' :: ValidatePolicy -> Maybe Locale
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"locale" Text -> Locale -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Locale -> Pair) -> Maybe Locale -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Locale
locale,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"policyDocument" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
policyDocument),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"policyType" Text -> PolicyType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PolicyType
policyType)
          ]
      )

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

instance Core.ToQuery ValidatePolicy where
  toQuery :: ValidatePolicy -> QueryString
toQuery ValidatePolicy' {Maybe Int
Maybe Text
Maybe Locale
Text
PolicyType
policyType :: PolicyType
policyDocument :: Text
maxResults :: Maybe Int
nextToken :: Maybe Text
locale :: Maybe Locale
$sel:policyType:ValidatePolicy' :: ValidatePolicy -> PolicyType
$sel:policyDocument:ValidatePolicy' :: ValidatePolicy -> Text
$sel:maxResults:ValidatePolicy' :: ValidatePolicy -> Maybe Int
$sel:nextToken:ValidatePolicy' :: ValidatePolicy -> Maybe Text
$sel:locale:ValidatePolicy' :: ValidatePolicy -> Maybe Locale
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"nextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"maxResults" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
maxResults
      ]

-- | /See:/ 'newValidatePolicyResponse' smart constructor.
data ValidatePolicyResponse = ValidatePolicyResponse'
  { -- | A token used for pagination of results returned.
    ValidatePolicyResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ValidatePolicyResponse -> Int
httpStatus :: Prelude.Int,
    -- | The list of findings in a policy returned by IAM Access Analyzer based
    -- on its suite of policy checks.
    ValidatePolicyResponse -> [ValidatePolicyFinding]
findings :: [ValidatePolicyFinding]
  }
  deriving (ValidatePolicyResponse -> ValidatePolicyResponse -> Bool
(ValidatePolicyResponse -> ValidatePolicyResponse -> Bool)
-> (ValidatePolicyResponse -> ValidatePolicyResponse -> Bool)
-> Eq ValidatePolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ValidatePolicyResponse -> ValidatePolicyResponse -> Bool
$c/= :: ValidatePolicyResponse -> ValidatePolicyResponse -> Bool
== :: ValidatePolicyResponse -> ValidatePolicyResponse -> Bool
$c== :: ValidatePolicyResponse -> ValidatePolicyResponse -> Bool
Prelude.Eq, ReadPrec [ValidatePolicyResponse]
ReadPrec ValidatePolicyResponse
Int -> ReadS ValidatePolicyResponse
ReadS [ValidatePolicyResponse]
(Int -> ReadS ValidatePolicyResponse)
-> ReadS [ValidatePolicyResponse]
-> ReadPrec ValidatePolicyResponse
-> ReadPrec [ValidatePolicyResponse]
-> Read ValidatePolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ValidatePolicyResponse]
$creadListPrec :: ReadPrec [ValidatePolicyResponse]
readPrec :: ReadPrec ValidatePolicyResponse
$creadPrec :: ReadPrec ValidatePolicyResponse
readList :: ReadS [ValidatePolicyResponse]
$creadList :: ReadS [ValidatePolicyResponse]
readsPrec :: Int -> ReadS ValidatePolicyResponse
$creadsPrec :: Int -> ReadS ValidatePolicyResponse
Prelude.Read, Int -> ValidatePolicyResponse -> ShowS
[ValidatePolicyResponse] -> ShowS
ValidatePolicyResponse -> String
(Int -> ValidatePolicyResponse -> ShowS)
-> (ValidatePolicyResponse -> String)
-> ([ValidatePolicyResponse] -> ShowS)
-> Show ValidatePolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ValidatePolicyResponse] -> ShowS
$cshowList :: [ValidatePolicyResponse] -> ShowS
show :: ValidatePolicyResponse -> String
$cshow :: ValidatePolicyResponse -> String
showsPrec :: Int -> ValidatePolicyResponse -> ShowS
$cshowsPrec :: Int -> ValidatePolicyResponse -> ShowS
Prelude.Show, (forall x. ValidatePolicyResponse -> Rep ValidatePolicyResponse x)
-> (forall x.
    Rep ValidatePolicyResponse x -> ValidatePolicyResponse)
-> Generic ValidatePolicyResponse
forall x. Rep ValidatePolicyResponse x -> ValidatePolicyResponse
forall x. ValidatePolicyResponse -> Rep ValidatePolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ValidatePolicyResponse x -> ValidatePolicyResponse
$cfrom :: forall x. ValidatePolicyResponse -> Rep ValidatePolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'ValidatePolicyResponse' 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', 'validatePolicyResponse_nextToken' - A token used for pagination of results returned.
--
-- 'httpStatus', 'validatePolicyResponse_httpStatus' - The response's http status code.
--
-- 'findings', 'validatePolicyResponse_findings' - The list of findings in a policy returned by IAM Access Analyzer based
-- on its suite of policy checks.
newValidatePolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ValidatePolicyResponse
newValidatePolicyResponse :: Int -> ValidatePolicyResponse
newValidatePolicyResponse Int
pHttpStatus_ =
  ValidatePolicyResponse' :: Maybe Text
-> Int -> [ValidatePolicyFinding] -> ValidatePolicyResponse
ValidatePolicyResponse'
    { $sel:nextToken:ValidatePolicyResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ValidatePolicyResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:findings:ValidatePolicyResponse' :: [ValidatePolicyFinding]
findings = [ValidatePolicyFinding]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A token used for pagination of results returned.
validatePolicyResponse_nextToken :: Lens.Lens' ValidatePolicyResponse (Prelude.Maybe Prelude.Text)
validatePolicyResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ValidatePolicyResponse -> f ValidatePolicyResponse
validatePolicyResponse_nextToken = (ValidatePolicyResponse -> Maybe Text)
-> (ValidatePolicyResponse -> Maybe Text -> ValidatePolicyResponse)
-> Lens' ValidatePolicyResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidatePolicyResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ValidatePolicyResponse' :: ValidatePolicyResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ValidatePolicyResponse
s@ValidatePolicyResponse' {} Maybe Text
a -> ValidatePolicyResponse
s {$sel:nextToken:ValidatePolicyResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ValidatePolicyResponse)

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

-- | The list of findings in a policy returned by IAM Access Analyzer based
-- on its suite of policy checks.
validatePolicyResponse_findings :: Lens.Lens' ValidatePolicyResponse [ValidatePolicyFinding]
validatePolicyResponse_findings :: ([ValidatePolicyFinding] -> f [ValidatePolicyFinding])
-> ValidatePolicyResponse -> f ValidatePolicyResponse
validatePolicyResponse_findings = (ValidatePolicyResponse -> [ValidatePolicyFinding])
-> (ValidatePolicyResponse
    -> [ValidatePolicyFinding] -> ValidatePolicyResponse)
-> Lens' ValidatePolicyResponse [ValidatePolicyFinding]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidatePolicyResponse' {[ValidatePolicyFinding]
findings :: [ValidatePolicyFinding]
$sel:findings:ValidatePolicyResponse' :: ValidatePolicyResponse -> [ValidatePolicyFinding]
findings} -> [ValidatePolicyFinding]
findings) (\s :: ValidatePolicyResponse
s@ValidatePolicyResponse' {} [ValidatePolicyFinding]
a -> ValidatePolicyResponse
s {$sel:findings:ValidatePolicyResponse' :: [ValidatePolicyFinding]
findings = [ValidatePolicyFinding]
a} :: ValidatePolicyResponse) (([ValidatePolicyFinding] -> f [ValidatePolicyFinding])
 -> ValidatePolicyResponse -> f ValidatePolicyResponse)
-> (([ValidatePolicyFinding] -> f [ValidatePolicyFinding])
    -> [ValidatePolicyFinding] -> f [ValidatePolicyFinding])
-> ([ValidatePolicyFinding] -> f [ValidatePolicyFinding])
-> ValidatePolicyResponse
-> f ValidatePolicyResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ValidatePolicyFinding] -> f [ValidatePolicyFinding])
-> [ValidatePolicyFinding] -> f [ValidatePolicyFinding]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ValidatePolicyResponse