{-# 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.IoT.CreatePolicy
-- 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)
--
-- Creates an IoT policy.
--
-- The created policy is the default version for the policy. This operation
-- creates a policy version with a version identifier of __1__ and sets
-- __1__ as the policy\'s default version.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions CreatePolicy>
-- action.
module Amazonka.IoT.CreatePolicy
  ( -- * Creating a Request
    CreatePolicy (..),
    newCreatePolicy,

    -- * Request Lenses
    createPolicy_tags,
    createPolicy_policyName,
    createPolicy_policyDocument,

    -- * Destructuring the Response
    CreatePolicyResponse (..),
    newCreatePolicyResponse,

    -- * Response Lenses
    createPolicyResponse_policyName,
    createPolicyResponse_policyDocument,
    createPolicyResponse_policyVersionId,
    createPolicyResponse_policyArn,
    createPolicyResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The input for the CreatePolicy operation.
--
-- /See:/ 'newCreatePolicy' smart constructor.
data CreatePolicy = CreatePolicy'
  { -- | Metadata which can be used to manage the policy.
    --
    -- For URI Request parameters use format: ...key1=value1&key2=value2...
    --
    -- For the CLI command-line parameter use format: &&tags
    -- \"key1=value1&key2=value2...\"
    --
    -- For the cli-input-json file use format: \"tags\":
    -- \"key1=value1&key2=value2...\"
    CreatePolicy -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The policy name.
    CreatePolicy -> Text
policyName :: Prelude.Text,
    -- | The JSON document that describes the policy. __policyDocument__ must
    -- have a minimum length of 1, with a maximum length of 2048, excluding
    -- whitespace.
    CreatePolicy -> Text
policyDocument :: Prelude.Text
  }
  deriving (CreatePolicy -> CreatePolicy -> Bool
(CreatePolicy -> CreatePolicy -> Bool)
-> (CreatePolicy -> CreatePolicy -> Bool) -> Eq CreatePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePolicy -> CreatePolicy -> Bool
$c/= :: CreatePolicy -> CreatePolicy -> Bool
== :: CreatePolicy -> CreatePolicy -> Bool
$c== :: CreatePolicy -> CreatePolicy -> Bool
Prelude.Eq, ReadPrec [CreatePolicy]
ReadPrec CreatePolicy
Int -> ReadS CreatePolicy
ReadS [CreatePolicy]
(Int -> ReadS CreatePolicy)
-> ReadS [CreatePolicy]
-> ReadPrec CreatePolicy
-> ReadPrec [CreatePolicy]
-> Read CreatePolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePolicy]
$creadListPrec :: ReadPrec [CreatePolicy]
readPrec :: ReadPrec CreatePolicy
$creadPrec :: ReadPrec CreatePolicy
readList :: ReadS [CreatePolicy]
$creadList :: ReadS [CreatePolicy]
readsPrec :: Int -> ReadS CreatePolicy
$creadsPrec :: Int -> ReadS CreatePolicy
Prelude.Read, Int -> CreatePolicy -> ShowS
[CreatePolicy] -> ShowS
CreatePolicy -> String
(Int -> CreatePolicy -> ShowS)
-> (CreatePolicy -> String)
-> ([CreatePolicy] -> ShowS)
-> Show CreatePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePolicy] -> ShowS
$cshowList :: [CreatePolicy] -> ShowS
show :: CreatePolicy -> String
$cshow :: CreatePolicy -> String
showsPrec :: Int -> CreatePolicy -> ShowS
$cshowsPrec :: Int -> CreatePolicy -> ShowS
Prelude.Show, (forall x. CreatePolicy -> Rep CreatePolicy x)
-> (forall x. Rep CreatePolicy x -> CreatePolicy)
-> Generic CreatePolicy
forall x. Rep CreatePolicy x -> CreatePolicy
forall x. CreatePolicy -> Rep CreatePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreatePolicy x -> CreatePolicy
$cfrom :: forall x. CreatePolicy -> Rep CreatePolicy x
Prelude.Generic)

-- |
-- Create a value of 'CreatePolicy' 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:
--
-- 'tags', 'createPolicy_tags' - Metadata which can be used to manage the policy.
--
-- For URI Request parameters use format: ...key1=value1&key2=value2...
--
-- For the CLI command-line parameter use format: &&tags
-- \"key1=value1&key2=value2...\"
--
-- For the cli-input-json file use format: \"tags\":
-- \"key1=value1&key2=value2...\"
--
-- 'policyName', 'createPolicy_policyName' - The policy name.
--
-- 'policyDocument', 'createPolicy_policyDocument' - The JSON document that describes the policy. __policyDocument__ must
-- have a minimum length of 1, with a maximum length of 2048, excluding
-- whitespace.
newCreatePolicy ::
  -- | 'policyName'
  Prelude.Text ->
  -- | 'policyDocument'
  Prelude.Text ->
  CreatePolicy
newCreatePolicy :: Text -> Text -> CreatePolicy
newCreatePolicy Text
pPolicyName_ Text
pPolicyDocument_ =
  CreatePolicy' :: Maybe [Tag] -> Text -> Text -> CreatePolicy
CreatePolicy'
    { $sel:tags:CreatePolicy' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:policyName:CreatePolicy' :: Text
policyName = Text
pPolicyName_,
      $sel:policyDocument:CreatePolicy' :: Text
policyDocument = Text
pPolicyDocument_
    }

-- | Metadata which can be used to manage the policy.
--
-- For URI Request parameters use format: ...key1=value1&key2=value2...
--
-- For the CLI command-line parameter use format: &&tags
-- \"key1=value1&key2=value2...\"
--
-- For the cli-input-json file use format: \"tags\":
-- \"key1=value1&key2=value2...\"
createPolicy_tags :: Lens.Lens' CreatePolicy (Prelude.Maybe [Tag])
createPolicy_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> CreatePolicy -> f CreatePolicy
createPolicy_tags = (CreatePolicy -> Maybe [Tag])
-> (CreatePolicy -> Maybe [Tag] -> CreatePolicy)
-> Lens CreatePolicy CreatePolicy (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicy' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreatePolicy' :: CreatePolicy -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreatePolicy
s@CreatePolicy' {} Maybe [Tag]
a -> CreatePolicy
s {$sel:tags:CreatePolicy' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreatePolicy) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreatePolicy -> f CreatePolicy)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreatePolicy
-> f CreatePolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The policy name.
createPolicy_policyName :: Lens.Lens' CreatePolicy Prelude.Text
createPolicy_policyName :: (Text -> f Text) -> CreatePolicy -> f CreatePolicy
createPolicy_policyName = (CreatePolicy -> Text)
-> (CreatePolicy -> Text -> CreatePolicy)
-> Lens CreatePolicy CreatePolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicy' {Text
policyName :: Text
$sel:policyName:CreatePolicy' :: CreatePolicy -> Text
policyName} -> Text
policyName) (\s :: CreatePolicy
s@CreatePolicy' {} Text
a -> CreatePolicy
s {$sel:policyName:CreatePolicy' :: Text
policyName = Text
a} :: CreatePolicy)

-- | The JSON document that describes the policy. __policyDocument__ must
-- have a minimum length of 1, with a maximum length of 2048, excluding
-- whitespace.
createPolicy_policyDocument :: Lens.Lens' CreatePolicy Prelude.Text
createPolicy_policyDocument :: (Text -> f Text) -> CreatePolicy -> f CreatePolicy
createPolicy_policyDocument = (CreatePolicy -> Text)
-> (CreatePolicy -> Text -> CreatePolicy)
-> Lens CreatePolicy CreatePolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicy' {Text
policyDocument :: Text
$sel:policyDocument:CreatePolicy' :: CreatePolicy -> Text
policyDocument} -> Text
policyDocument) (\s :: CreatePolicy
s@CreatePolicy' {} Text
a -> CreatePolicy
s {$sel:policyDocument:CreatePolicy' :: Text
policyDocument = Text
a} :: CreatePolicy)

instance Core.AWSRequest CreatePolicy where
  type AWSResponse CreatePolicy = CreatePolicyResponse
  request :: CreatePolicy -> Request CreatePolicy
request = Service -> CreatePolicy -> Request CreatePolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreatePolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreatePolicy)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreatePolicy))
-> Logger
-> Service
-> Proxy CreatePolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreatePolicy)))
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
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> CreatePolicyResponse
CreatePolicyResponse'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Int
 -> CreatePolicyResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Int -> CreatePolicyResponse)
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
"policyName")
            Either
  String
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Int -> CreatePolicyResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe Text -> Int -> CreatePolicyResponse)
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
"policyDocument")
            Either
  String (Maybe Text -> Maybe Text -> Int -> CreatePolicyResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreatePolicyResponse)
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
"policyVersionId")
            Either String (Maybe Text -> Int -> CreatePolicyResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreatePolicyResponse)
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
"policyArn")
            Either String (Int -> CreatePolicyResponse)
-> Either String Int -> Either String CreatePolicyResponse
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 CreatePolicy

instance Prelude.NFData CreatePolicy

instance Core.ToHeaders CreatePolicy where
  toHeaders :: CreatePolicy -> ResponseHeaders
toHeaders = ResponseHeaders -> CreatePolicy -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON CreatePolicy where
  toJSON :: CreatePolicy -> Value
toJSON CreatePolicy' {Maybe [Tag]
Text
policyDocument :: Text
policyName :: Text
tags :: Maybe [Tag]
$sel:policyDocument:CreatePolicy' :: CreatePolicy -> Text
$sel:policyName:CreatePolicy' :: CreatePolicy -> Text
$sel:tags:CreatePolicy' :: CreatePolicy -> Maybe [Tag]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            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)
          ]
      )

instance Core.ToPath CreatePolicy where
  toPath :: CreatePolicy -> ByteString
toPath CreatePolicy' {Maybe [Tag]
Text
policyDocument :: Text
policyName :: Text
tags :: Maybe [Tag]
$sel:policyDocument:CreatePolicy' :: CreatePolicy -> Text
$sel:policyName:CreatePolicy' :: CreatePolicy -> Text
$sel:tags:CreatePolicy' :: CreatePolicy -> Maybe [Tag]
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/policies/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
policyName]

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

-- | The output from the CreatePolicy operation.
--
-- /See:/ 'newCreatePolicyResponse' smart constructor.
data CreatePolicyResponse = CreatePolicyResponse'
  { -- | The policy name.
    CreatePolicyResponse -> Maybe Text
policyName :: Prelude.Maybe Prelude.Text,
    -- | The JSON document that describes the policy.
    CreatePolicyResponse -> Maybe Text
policyDocument :: Prelude.Maybe Prelude.Text,
    -- | The policy version ID.
    CreatePolicyResponse -> Maybe Text
policyVersionId :: Prelude.Maybe Prelude.Text,
    -- | The policy ARN.
    CreatePolicyResponse -> Maybe Text
policyArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreatePolicyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreatePolicyResponse -> CreatePolicyResponse -> Bool
(CreatePolicyResponse -> CreatePolicyResponse -> Bool)
-> (CreatePolicyResponse -> CreatePolicyResponse -> Bool)
-> Eq CreatePolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePolicyResponse -> CreatePolicyResponse -> Bool
$c/= :: CreatePolicyResponse -> CreatePolicyResponse -> Bool
== :: CreatePolicyResponse -> CreatePolicyResponse -> Bool
$c== :: CreatePolicyResponse -> CreatePolicyResponse -> Bool
Prelude.Eq, ReadPrec [CreatePolicyResponse]
ReadPrec CreatePolicyResponse
Int -> ReadS CreatePolicyResponse
ReadS [CreatePolicyResponse]
(Int -> ReadS CreatePolicyResponse)
-> ReadS [CreatePolicyResponse]
-> ReadPrec CreatePolicyResponse
-> ReadPrec [CreatePolicyResponse]
-> Read CreatePolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePolicyResponse]
$creadListPrec :: ReadPrec [CreatePolicyResponse]
readPrec :: ReadPrec CreatePolicyResponse
$creadPrec :: ReadPrec CreatePolicyResponse
readList :: ReadS [CreatePolicyResponse]
$creadList :: ReadS [CreatePolicyResponse]
readsPrec :: Int -> ReadS CreatePolicyResponse
$creadsPrec :: Int -> ReadS CreatePolicyResponse
Prelude.Read, Int -> CreatePolicyResponse -> ShowS
[CreatePolicyResponse] -> ShowS
CreatePolicyResponse -> String
(Int -> CreatePolicyResponse -> ShowS)
-> (CreatePolicyResponse -> String)
-> ([CreatePolicyResponse] -> ShowS)
-> Show CreatePolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePolicyResponse] -> ShowS
$cshowList :: [CreatePolicyResponse] -> ShowS
show :: CreatePolicyResponse -> String
$cshow :: CreatePolicyResponse -> String
showsPrec :: Int -> CreatePolicyResponse -> ShowS
$cshowsPrec :: Int -> CreatePolicyResponse -> ShowS
Prelude.Show, (forall x. CreatePolicyResponse -> Rep CreatePolicyResponse x)
-> (forall x. Rep CreatePolicyResponse x -> CreatePolicyResponse)
-> Generic CreatePolicyResponse
forall x. Rep CreatePolicyResponse x -> CreatePolicyResponse
forall x. CreatePolicyResponse -> Rep CreatePolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreatePolicyResponse x -> CreatePolicyResponse
$cfrom :: forall x. CreatePolicyResponse -> Rep CreatePolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreatePolicyResponse' 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:
--
-- 'policyName', 'createPolicyResponse_policyName' - The policy name.
--
-- 'policyDocument', 'createPolicyResponse_policyDocument' - The JSON document that describes the policy.
--
-- 'policyVersionId', 'createPolicyResponse_policyVersionId' - The policy version ID.
--
-- 'policyArn', 'createPolicyResponse_policyArn' - The policy ARN.
--
-- 'httpStatus', 'createPolicyResponse_httpStatus' - The response's http status code.
newCreatePolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreatePolicyResponse
newCreatePolicyResponse :: Int -> CreatePolicyResponse
newCreatePolicyResponse Int
pHttpStatus_ =
  CreatePolicyResponse' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> CreatePolicyResponse
CreatePolicyResponse'
    { $sel:policyName:CreatePolicyResponse' :: Maybe Text
policyName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:policyDocument:CreatePolicyResponse' :: Maybe Text
policyDocument = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:policyVersionId:CreatePolicyResponse' :: Maybe Text
policyVersionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:policyArn:CreatePolicyResponse' :: Maybe Text
policyArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreatePolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The policy name.
createPolicyResponse_policyName :: Lens.Lens' CreatePolicyResponse (Prelude.Maybe Prelude.Text)
createPolicyResponse_policyName :: (Maybe Text -> f (Maybe Text))
-> CreatePolicyResponse -> f CreatePolicyResponse
createPolicyResponse_policyName = (CreatePolicyResponse -> Maybe Text)
-> (CreatePolicyResponse -> Maybe Text -> CreatePolicyResponse)
-> Lens
     CreatePolicyResponse CreatePolicyResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicyResponse' {Maybe Text
policyName :: Maybe Text
$sel:policyName:CreatePolicyResponse' :: CreatePolicyResponse -> Maybe Text
policyName} -> Maybe Text
policyName) (\s :: CreatePolicyResponse
s@CreatePolicyResponse' {} Maybe Text
a -> CreatePolicyResponse
s {$sel:policyName:CreatePolicyResponse' :: Maybe Text
policyName = Maybe Text
a} :: CreatePolicyResponse)

-- | The JSON document that describes the policy.
createPolicyResponse_policyDocument :: Lens.Lens' CreatePolicyResponse (Prelude.Maybe Prelude.Text)
createPolicyResponse_policyDocument :: (Maybe Text -> f (Maybe Text))
-> CreatePolicyResponse -> f CreatePolicyResponse
createPolicyResponse_policyDocument = (CreatePolicyResponse -> Maybe Text)
-> (CreatePolicyResponse -> Maybe Text -> CreatePolicyResponse)
-> Lens
     CreatePolicyResponse CreatePolicyResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicyResponse' {Maybe Text
policyDocument :: Maybe Text
$sel:policyDocument:CreatePolicyResponse' :: CreatePolicyResponse -> Maybe Text
policyDocument} -> Maybe Text
policyDocument) (\s :: CreatePolicyResponse
s@CreatePolicyResponse' {} Maybe Text
a -> CreatePolicyResponse
s {$sel:policyDocument:CreatePolicyResponse' :: Maybe Text
policyDocument = Maybe Text
a} :: CreatePolicyResponse)

-- | The policy version ID.
createPolicyResponse_policyVersionId :: Lens.Lens' CreatePolicyResponse (Prelude.Maybe Prelude.Text)
createPolicyResponse_policyVersionId :: (Maybe Text -> f (Maybe Text))
-> CreatePolicyResponse -> f CreatePolicyResponse
createPolicyResponse_policyVersionId = (CreatePolicyResponse -> Maybe Text)
-> (CreatePolicyResponse -> Maybe Text -> CreatePolicyResponse)
-> Lens
     CreatePolicyResponse CreatePolicyResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicyResponse' {Maybe Text
policyVersionId :: Maybe Text
$sel:policyVersionId:CreatePolicyResponse' :: CreatePolicyResponse -> Maybe Text
policyVersionId} -> Maybe Text
policyVersionId) (\s :: CreatePolicyResponse
s@CreatePolicyResponse' {} Maybe Text
a -> CreatePolicyResponse
s {$sel:policyVersionId:CreatePolicyResponse' :: Maybe Text
policyVersionId = Maybe Text
a} :: CreatePolicyResponse)

-- | The policy ARN.
createPolicyResponse_policyArn :: Lens.Lens' CreatePolicyResponse (Prelude.Maybe Prelude.Text)
createPolicyResponse_policyArn :: (Maybe Text -> f (Maybe Text))
-> CreatePolicyResponse -> f CreatePolicyResponse
createPolicyResponse_policyArn = (CreatePolicyResponse -> Maybe Text)
-> (CreatePolicyResponse -> Maybe Text -> CreatePolicyResponse)
-> Lens
     CreatePolicyResponse CreatePolicyResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicyResponse' {Maybe Text
policyArn :: Maybe Text
$sel:policyArn:CreatePolicyResponse' :: CreatePolicyResponse -> Maybe Text
policyArn} -> Maybe Text
policyArn) (\s :: CreatePolicyResponse
s@CreatePolicyResponse' {} Maybe Text
a -> CreatePolicyResponse
s {$sel:policyArn:CreatePolicyResponse' :: Maybe Text
policyArn = Maybe Text
a} :: CreatePolicyResponse)

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

instance Prelude.NFData CreatePolicyResponse