{-# 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.Lambda.AddLayerVersionPermission
-- 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)
--
-- Adds permissions to the resource-based policy of a version of an
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html Lambda layer>.
-- Use this action to grant layer usage permission to other accounts. You
-- can grant permission to a single account, all accounts in an
-- organization, or all Amazon Web Services accounts.
--
-- To revoke permission, call RemoveLayerVersionPermission with the
-- statement ID that you specified when you added it.
module Amazonka.Lambda.AddLayerVersionPermission
  ( -- * Creating a Request
    AddLayerVersionPermission (..),
    newAddLayerVersionPermission,

    -- * Request Lenses
    addLayerVersionPermission_revisionId,
    addLayerVersionPermission_organizationId,
    addLayerVersionPermission_layerName,
    addLayerVersionPermission_versionNumber,
    addLayerVersionPermission_statementId,
    addLayerVersionPermission_action,
    addLayerVersionPermission_principal,

    -- * Destructuring the Response
    AddLayerVersionPermissionResponse (..),
    newAddLayerVersionPermissionResponse,

    -- * Response Lenses
    addLayerVersionPermissionResponse_statement,
    addLayerVersionPermissionResponse_revisionId,
    addLayerVersionPermissionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Lambda.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

-- | /See:/ 'newAddLayerVersionPermission' smart constructor.
data AddLayerVersionPermission = AddLayerVersionPermission'
  { -- | Only update the policy if the revision ID matches the ID specified. Use
    -- this option to avoid modifying a policy that has changed since you last
    -- read it.
    AddLayerVersionPermission -> Maybe Text
revisionId :: Prelude.Maybe Prelude.Text,
    -- | With the principal set to @*@, grant permission to all accounts in the
    -- specified organization.
    AddLayerVersionPermission -> Maybe Text
organizationId :: Prelude.Maybe Prelude.Text,
    -- | The name or Amazon Resource Name (ARN) of the layer.
    AddLayerVersionPermission -> Text
layerName :: Prelude.Text,
    -- | The version number.
    AddLayerVersionPermission -> Integer
versionNumber :: Prelude.Integer,
    -- | An identifier that distinguishes the policy from others on the same
    -- layer version.
    AddLayerVersionPermission -> Text
statementId :: Prelude.Text,
    -- | The API action that grants access to the layer. For example,
    -- @lambda:GetLayerVersion@.
    AddLayerVersionPermission -> Text
action :: Prelude.Text,
    -- | An account ID, or @*@ to grant layer usage permission to all accounts in
    -- an organization, or all Amazon Web Services accounts (if
    -- @organizationId@ is not specified). For the last case, make sure that
    -- you really do want all Amazon Web Services accounts to have usage
    -- permission to this layer.
    AddLayerVersionPermission -> Text
principal :: Prelude.Text
  }
  deriving (AddLayerVersionPermission -> AddLayerVersionPermission -> Bool
(AddLayerVersionPermission -> AddLayerVersionPermission -> Bool)
-> (AddLayerVersionPermission -> AddLayerVersionPermission -> Bool)
-> Eq AddLayerVersionPermission
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddLayerVersionPermission -> AddLayerVersionPermission -> Bool
$c/= :: AddLayerVersionPermission -> AddLayerVersionPermission -> Bool
== :: AddLayerVersionPermission -> AddLayerVersionPermission -> Bool
$c== :: AddLayerVersionPermission -> AddLayerVersionPermission -> Bool
Prelude.Eq, ReadPrec [AddLayerVersionPermission]
ReadPrec AddLayerVersionPermission
Int -> ReadS AddLayerVersionPermission
ReadS [AddLayerVersionPermission]
(Int -> ReadS AddLayerVersionPermission)
-> ReadS [AddLayerVersionPermission]
-> ReadPrec AddLayerVersionPermission
-> ReadPrec [AddLayerVersionPermission]
-> Read AddLayerVersionPermission
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddLayerVersionPermission]
$creadListPrec :: ReadPrec [AddLayerVersionPermission]
readPrec :: ReadPrec AddLayerVersionPermission
$creadPrec :: ReadPrec AddLayerVersionPermission
readList :: ReadS [AddLayerVersionPermission]
$creadList :: ReadS [AddLayerVersionPermission]
readsPrec :: Int -> ReadS AddLayerVersionPermission
$creadsPrec :: Int -> ReadS AddLayerVersionPermission
Prelude.Read, Int -> AddLayerVersionPermission -> ShowS
[AddLayerVersionPermission] -> ShowS
AddLayerVersionPermission -> String
(Int -> AddLayerVersionPermission -> ShowS)
-> (AddLayerVersionPermission -> String)
-> ([AddLayerVersionPermission] -> ShowS)
-> Show AddLayerVersionPermission
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddLayerVersionPermission] -> ShowS
$cshowList :: [AddLayerVersionPermission] -> ShowS
show :: AddLayerVersionPermission -> String
$cshow :: AddLayerVersionPermission -> String
showsPrec :: Int -> AddLayerVersionPermission -> ShowS
$cshowsPrec :: Int -> AddLayerVersionPermission -> ShowS
Prelude.Show, (forall x.
 AddLayerVersionPermission -> Rep AddLayerVersionPermission x)
-> (forall x.
    Rep AddLayerVersionPermission x -> AddLayerVersionPermission)
-> Generic AddLayerVersionPermission
forall x.
Rep AddLayerVersionPermission x -> AddLayerVersionPermission
forall x.
AddLayerVersionPermission -> Rep AddLayerVersionPermission x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AddLayerVersionPermission x -> AddLayerVersionPermission
$cfrom :: forall x.
AddLayerVersionPermission -> Rep AddLayerVersionPermission x
Prelude.Generic)

-- |
-- Create a value of 'AddLayerVersionPermission' 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:
--
-- 'revisionId', 'addLayerVersionPermission_revisionId' - Only update the policy if the revision ID matches the ID specified. Use
-- this option to avoid modifying a policy that has changed since you last
-- read it.
--
-- 'organizationId', 'addLayerVersionPermission_organizationId' - With the principal set to @*@, grant permission to all accounts in the
-- specified organization.
--
-- 'layerName', 'addLayerVersionPermission_layerName' - The name or Amazon Resource Name (ARN) of the layer.
--
-- 'versionNumber', 'addLayerVersionPermission_versionNumber' - The version number.
--
-- 'statementId', 'addLayerVersionPermission_statementId' - An identifier that distinguishes the policy from others on the same
-- layer version.
--
-- 'action', 'addLayerVersionPermission_action' - The API action that grants access to the layer. For example,
-- @lambda:GetLayerVersion@.
--
-- 'principal', 'addLayerVersionPermission_principal' - An account ID, or @*@ to grant layer usage permission to all accounts in
-- an organization, or all Amazon Web Services accounts (if
-- @organizationId@ is not specified). For the last case, make sure that
-- you really do want all Amazon Web Services accounts to have usage
-- permission to this layer.
newAddLayerVersionPermission ::
  -- | 'layerName'
  Prelude.Text ->
  -- | 'versionNumber'
  Prelude.Integer ->
  -- | 'statementId'
  Prelude.Text ->
  -- | 'action'
  Prelude.Text ->
  -- | 'principal'
  Prelude.Text ->
  AddLayerVersionPermission
newAddLayerVersionPermission :: Text
-> Integer -> Text -> Text -> Text -> AddLayerVersionPermission
newAddLayerVersionPermission
  Text
pLayerName_
  Integer
pVersionNumber_
  Text
pStatementId_
  Text
pAction_
  Text
pPrincipal_ =
    AddLayerVersionPermission' :: Maybe Text
-> Maybe Text
-> Text
-> Integer
-> Text
-> Text
-> Text
-> AddLayerVersionPermission
AddLayerVersionPermission'
      { $sel:revisionId:AddLayerVersionPermission' :: Maybe Text
revisionId =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:organizationId:AddLayerVersionPermission' :: Maybe Text
organizationId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:layerName:AddLayerVersionPermission' :: Text
layerName = Text
pLayerName_,
        $sel:versionNumber:AddLayerVersionPermission' :: Integer
versionNumber = Integer
pVersionNumber_,
        $sel:statementId:AddLayerVersionPermission' :: Text
statementId = Text
pStatementId_,
        $sel:action:AddLayerVersionPermission' :: Text
action = Text
pAction_,
        $sel:principal:AddLayerVersionPermission' :: Text
principal = Text
pPrincipal_
      }

-- | Only update the policy if the revision ID matches the ID specified. Use
-- this option to avoid modifying a policy that has changed since you last
-- read it.
addLayerVersionPermission_revisionId :: Lens.Lens' AddLayerVersionPermission (Prelude.Maybe Prelude.Text)
addLayerVersionPermission_revisionId :: (Maybe Text -> f (Maybe Text))
-> AddLayerVersionPermission -> f AddLayerVersionPermission
addLayerVersionPermission_revisionId = (AddLayerVersionPermission -> Maybe Text)
-> (AddLayerVersionPermission
    -> Maybe Text -> AddLayerVersionPermission)
-> Lens
     AddLayerVersionPermission
     AddLayerVersionPermission
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddLayerVersionPermission' {Maybe Text
revisionId :: Maybe Text
$sel:revisionId:AddLayerVersionPermission' :: AddLayerVersionPermission -> Maybe Text
revisionId} -> Maybe Text
revisionId) (\s :: AddLayerVersionPermission
s@AddLayerVersionPermission' {} Maybe Text
a -> AddLayerVersionPermission
s {$sel:revisionId:AddLayerVersionPermission' :: Maybe Text
revisionId = Maybe Text
a} :: AddLayerVersionPermission)

-- | With the principal set to @*@, grant permission to all accounts in the
-- specified organization.
addLayerVersionPermission_organizationId :: Lens.Lens' AddLayerVersionPermission (Prelude.Maybe Prelude.Text)
addLayerVersionPermission_organizationId :: (Maybe Text -> f (Maybe Text))
-> AddLayerVersionPermission -> f AddLayerVersionPermission
addLayerVersionPermission_organizationId = (AddLayerVersionPermission -> Maybe Text)
-> (AddLayerVersionPermission
    -> Maybe Text -> AddLayerVersionPermission)
-> Lens
     AddLayerVersionPermission
     AddLayerVersionPermission
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddLayerVersionPermission' {Maybe Text
organizationId :: Maybe Text
$sel:organizationId:AddLayerVersionPermission' :: AddLayerVersionPermission -> Maybe Text
organizationId} -> Maybe Text
organizationId) (\s :: AddLayerVersionPermission
s@AddLayerVersionPermission' {} Maybe Text
a -> AddLayerVersionPermission
s {$sel:organizationId:AddLayerVersionPermission' :: Maybe Text
organizationId = Maybe Text
a} :: AddLayerVersionPermission)

-- | The name or Amazon Resource Name (ARN) of the layer.
addLayerVersionPermission_layerName :: Lens.Lens' AddLayerVersionPermission Prelude.Text
addLayerVersionPermission_layerName :: (Text -> f Text)
-> AddLayerVersionPermission -> f AddLayerVersionPermission
addLayerVersionPermission_layerName = (AddLayerVersionPermission -> Text)
-> (AddLayerVersionPermission -> Text -> AddLayerVersionPermission)
-> Lens
     AddLayerVersionPermission AddLayerVersionPermission Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddLayerVersionPermission' {Text
layerName :: Text
$sel:layerName:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
layerName} -> Text
layerName) (\s :: AddLayerVersionPermission
s@AddLayerVersionPermission' {} Text
a -> AddLayerVersionPermission
s {$sel:layerName:AddLayerVersionPermission' :: Text
layerName = Text
a} :: AddLayerVersionPermission)

-- | The version number.
addLayerVersionPermission_versionNumber :: Lens.Lens' AddLayerVersionPermission Prelude.Integer
addLayerVersionPermission_versionNumber :: (Integer -> f Integer)
-> AddLayerVersionPermission -> f AddLayerVersionPermission
addLayerVersionPermission_versionNumber = (AddLayerVersionPermission -> Integer)
-> (AddLayerVersionPermission
    -> Integer -> AddLayerVersionPermission)
-> Lens
     AddLayerVersionPermission AddLayerVersionPermission Integer Integer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddLayerVersionPermission' {Integer
versionNumber :: Integer
$sel:versionNumber:AddLayerVersionPermission' :: AddLayerVersionPermission -> Integer
versionNumber} -> Integer
versionNumber) (\s :: AddLayerVersionPermission
s@AddLayerVersionPermission' {} Integer
a -> AddLayerVersionPermission
s {$sel:versionNumber:AddLayerVersionPermission' :: Integer
versionNumber = Integer
a} :: AddLayerVersionPermission)

-- | An identifier that distinguishes the policy from others on the same
-- layer version.
addLayerVersionPermission_statementId :: Lens.Lens' AddLayerVersionPermission Prelude.Text
addLayerVersionPermission_statementId :: (Text -> f Text)
-> AddLayerVersionPermission -> f AddLayerVersionPermission
addLayerVersionPermission_statementId = (AddLayerVersionPermission -> Text)
-> (AddLayerVersionPermission -> Text -> AddLayerVersionPermission)
-> Lens
     AddLayerVersionPermission AddLayerVersionPermission Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddLayerVersionPermission' {Text
statementId :: Text
$sel:statementId:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
statementId} -> Text
statementId) (\s :: AddLayerVersionPermission
s@AddLayerVersionPermission' {} Text
a -> AddLayerVersionPermission
s {$sel:statementId:AddLayerVersionPermission' :: Text
statementId = Text
a} :: AddLayerVersionPermission)

-- | The API action that grants access to the layer. For example,
-- @lambda:GetLayerVersion@.
addLayerVersionPermission_action :: Lens.Lens' AddLayerVersionPermission Prelude.Text
addLayerVersionPermission_action :: (Text -> f Text)
-> AddLayerVersionPermission -> f AddLayerVersionPermission
addLayerVersionPermission_action = (AddLayerVersionPermission -> Text)
-> (AddLayerVersionPermission -> Text -> AddLayerVersionPermission)
-> Lens
     AddLayerVersionPermission AddLayerVersionPermission Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddLayerVersionPermission' {Text
action :: Text
$sel:action:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
action} -> Text
action) (\s :: AddLayerVersionPermission
s@AddLayerVersionPermission' {} Text
a -> AddLayerVersionPermission
s {$sel:action:AddLayerVersionPermission' :: Text
action = Text
a} :: AddLayerVersionPermission)

-- | An account ID, or @*@ to grant layer usage permission to all accounts in
-- an organization, or all Amazon Web Services accounts (if
-- @organizationId@ is not specified). For the last case, make sure that
-- you really do want all Amazon Web Services accounts to have usage
-- permission to this layer.
addLayerVersionPermission_principal :: Lens.Lens' AddLayerVersionPermission Prelude.Text
addLayerVersionPermission_principal :: (Text -> f Text)
-> AddLayerVersionPermission -> f AddLayerVersionPermission
addLayerVersionPermission_principal = (AddLayerVersionPermission -> Text)
-> (AddLayerVersionPermission -> Text -> AddLayerVersionPermission)
-> Lens
     AddLayerVersionPermission AddLayerVersionPermission Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddLayerVersionPermission' {Text
principal :: Text
$sel:principal:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
principal} -> Text
principal) (\s :: AddLayerVersionPermission
s@AddLayerVersionPermission' {} Text
a -> AddLayerVersionPermission
s {$sel:principal:AddLayerVersionPermission' :: Text
principal = Text
a} :: AddLayerVersionPermission)

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

instance Prelude.NFData AddLayerVersionPermission

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

instance Core.ToJSON AddLayerVersionPermission where
  toJSON :: AddLayerVersionPermission -> Value
toJSON AddLayerVersionPermission' {Integer
Maybe Text
Text
principal :: Text
action :: Text
statementId :: Text
versionNumber :: Integer
layerName :: Text
organizationId :: Maybe Text
revisionId :: Maybe Text
$sel:principal:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
$sel:action:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
$sel:statementId:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
$sel:versionNumber:AddLayerVersionPermission' :: AddLayerVersionPermission -> Integer
$sel:layerName:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
$sel:organizationId:AddLayerVersionPermission' :: AddLayerVersionPermission -> Maybe Text
$sel:revisionId:AddLayerVersionPermission' :: AddLayerVersionPermission -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OrganizationId" 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
organizationId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StatementId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
statementId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Action" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
action),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Principal" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
principal)
          ]
      )

instance Core.ToPath AddLayerVersionPermission where
  toPath :: AddLayerVersionPermission -> ByteString
toPath AddLayerVersionPermission' {Integer
Maybe Text
Text
principal :: Text
action :: Text
statementId :: Text
versionNumber :: Integer
layerName :: Text
organizationId :: Maybe Text
revisionId :: Maybe Text
$sel:principal:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
$sel:action:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
$sel:statementId:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
$sel:versionNumber:AddLayerVersionPermission' :: AddLayerVersionPermission -> Integer
$sel:layerName:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
$sel:organizationId:AddLayerVersionPermission' :: AddLayerVersionPermission -> Maybe Text
$sel:revisionId:AddLayerVersionPermission' :: AddLayerVersionPermission -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2018-10-31/layers/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
layerName,
        ByteString
"/versions/",
        Integer -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Integer
versionNumber,
        ByteString
"/policy"
      ]

instance Core.ToQuery AddLayerVersionPermission where
  toQuery :: AddLayerVersionPermission -> QueryString
toQuery AddLayerVersionPermission' {Integer
Maybe Text
Text
principal :: Text
action :: Text
statementId :: Text
versionNumber :: Integer
layerName :: Text
organizationId :: Maybe Text
revisionId :: Maybe Text
$sel:principal:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
$sel:action:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
$sel:statementId:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
$sel:versionNumber:AddLayerVersionPermission' :: AddLayerVersionPermission -> Integer
$sel:layerName:AddLayerVersionPermission' :: AddLayerVersionPermission -> Text
$sel:organizationId:AddLayerVersionPermission' :: AddLayerVersionPermission -> Maybe Text
$sel:revisionId:AddLayerVersionPermission' :: AddLayerVersionPermission -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"RevisionId" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
revisionId]

-- | /See:/ 'newAddLayerVersionPermissionResponse' smart constructor.
data AddLayerVersionPermissionResponse = AddLayerVersionPermissionResponse'
  { -- | The permission statement.
    AddLayerVersionPermissionResponse -> Maybe Text
statement :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the current revision of the policy.
    AddLayerVersionPermissionResponse -> Maybe Text
revisionId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    AddLayerVersionPermissionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AddLayerVersionPermissionResponse
-> AddLayerVersionPermissionResponse -> Bool
(AddLayerVersionPermissionResponse
 -> AddLayerVersionPermissionResponse -> Bool)
-> (AddLayerVersionPermissionResponse
    -> AddLayerVersionPermissionResponse -> Bool)
-> Eq AddLayerVersionPermissionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddLayerVersionPermissionResponse
-> AddLayerVersionPermissionResponse -> Bool
$c/= :: AddLayerVersionPermissionResponse
-> AddLayerVersionPermissionResponse -> Bool
== :: AddLayerVersionPermissionResponse
-> AddLayerVersionPermissionResponse -> Bool
$c== :: AddLayerVersionPermissionResponse
-> AddLayerVersionPermissionResponse -> Bool
Prelude.Eq, ReadPrec [AddLayerVersionPermissionResponse]
ReadPrec AddLayerVersionPermissionResponse
Int -> ReadS AddLayerVersionPermissionResponse
ReadS [AddLayerVersionPermissionResponse]
(Int -> ReadS AddLayerVersionPermissionResponse)
-> ReadS [AddLayerVersionPermissionResponse]
-> ReadPrec AddLayerVersionPermissionResponse
-> ReadPrec [AddLayerVersionPermissionResponse]
-> Read AddLayerVersionPermissionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddLayerVersionPermissionResponse]
$creadListPrec :: ReadPrec [AddLayerVersionPermissionResponse]
readPrec :: ReadPrec AddLayerVersionPermissionResponse
$creadPrec :: ReadPrec AddLayerVersionPermissionResponse
readList :: ReadS [AddLayerVersionPermissionResponse]
$creadList :: ReadS [AddLayerVersionPermissionResponse]
readsPrec :: Int -> ReadS AddLayerVersionPermissionResponse
$creadsPrec :: Int -> ReadS AddLayerVersionPermissionResponse
Prelude.Read, Int -> AddLayerVersionPermissionResponse -> ShowS
[AddLayerVersionPermissionResponse] -> ShowS
AddLayerVersionPermissionResponse -> String
(Int -> AddLayerVersionPermissionResponse -> ShowS)
-> (AddLayerVersionPermissionResponse -> String)
-> ([AddLayerVersionPermissionResponse] -> ShowS)
-> Show AddLayerVersionPermissionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddLayerVersionPermissionResponse] -> ShowS
$cshowList :: [AddLayerVersionPermissionResponse] -> ShowS
show :: AddLayerVersionPermissionResponse -> String
$cshow :: AddLayerVersionPermissionResponse -> String
showsPrec :: Int -> AddLayerVersionPermissionResponse -> ShowS
$cshowsPrec :: Int -> AddLayerVersionPermissionResponse -> ShowS
Prelude.Show, (forall x.
 AddLayerVersionPermissionResponse
 -> Rep AddLayerVersionPermissionResponse x)
-> (forall x.
    Rep AddLayerVersionPermissionResponse x
    -> AddLayerVersionPermissionResponse)
-> Generic AddLayerVersionPermissionResponse
forall x.
Rep AddLayerVersionPermissionResponse x
-> AddLayerVersionPermissionResponse
forall x.
AddLayerVersionPermissionResponse
-> Rep AddLayerVersionPermissionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AddLayerVersionPermissionResponse x
-> AddLayerVersionPermissionResponse
$cfrom :: forall x.
AddLayerVersionPermissionResponse
-> Rep AddLayerVersionPermissionResponse x
Prelude.Generic)

-- |
-- Create a value of 'AddLayerVersionPermissionResponse' 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:
--
-- 'statement', 'addLayerVersionPermissionResponse_statement' - The permission statement.
--
-- 'revisionId', 'addLayerVersionPermissionResponse_revisionId' - A unique identifier for the current revision of the policy.
--
-- 'httpStatus', 'addLayerVersionPermissionResponse_httpStatus' - The response's http status code.
newAddLayerVersionPermissionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AddLayerVersionPermissionResponse
newAddLayerVersionPermissionResponse :: Int -> AddLayerVersionPermissionResponse
newAddLayerVersionPermissionResponse Int
pHttpStatus_ =
  AddLayerVersionPermissionResponse' :: Maybe Text
-> Maybe Text -> Int -> AddLayerVersionPermissionResponse
AddLayerVersionPermissionResponse'
    { $sel:statement:AddLayerVersionPermissionResponse' :: Maybe Text
statement =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:revisionId:AddLayerVersionPermissionResponse' :: Maybe Text
revisionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AddLayerVersionPermissionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The permission statement.
addLayerVersionPermissionResponse_statement :: Lens.Lens' AddLayerVersionPermissionResponse (Prelude.Maybe Prelude.Text)
addLayerVersionPermissionResponse_statement :: (Maybe Text -> f (Maybe Text))
-> AddLayerVersionPermissionResponse
-> f AddLayerVersionPermissionResponse
addLayerVersionPermissionResponse_statement = (AddLayerVersionPermissionResponse -> Maybe Text)
-> (AddLayerVersionPermissionResponse
    -> Maybe Text -> AddLayerVersionPermissionResponse)
-> Lens
     AddLayerVersionPermissionResponse
     AddLayerVersionPermissionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddLayerVersionPermissionResponse' {Maybe Text
statement :: Maybe Text
$sel:statement:AddLayerVersionPermissionResponse' :: AddLayerVersionPermissionResponse -> Maybe Text
statement} -> Maybe Text
statement) (\s :: AddLayerVersionPermissionResponse
s@AddLayerVersionPermissionResponse' {} Maybe Text
a -> AddLayerVersionPermissionResponse
s {$sel:statement:AddLayerVersionPermissionResponse' :: Maybe Text
statement = Maybe Text
a} :: AddLayerVersionPermissionResponse)

-- | A unique identifier for the current revision of the policy.
addLayerVersionPermissionResponse_revisionId :: Lens.Lens' AddLayerVersionPermissionResponse (Prelude.Maybe Prelude.Text)
addLayerVersionPermissionResponse_revisionId :: (Maybe Text -> f (Maybe Text))
-> AddLayerVersionPermissionResponse
-> f AddLayerVersionPermissionResponse
addLayerVersionPermissionResponse_revisionId = (AddLayerVersionPermissionResponse -> Maybe Text)
-> (AddLayerVersionPermissionResponse
    -> Maybe Text -> AddLayerVersionPermissionResponse)
-> Lens
     AddLayerVersionPermissionResponse
     AddLayerVersionPermissionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddLayerVersionPermissionResponse' {Maybe Text
revisionId :: Maybe Text
$sel:revisionId:AddLayerVersionPermissionResponse' :: AddLayerVersionPermissionResponse -> Maybe Text
revisionId} -> Maybe Text
revisionId) (\s :: AddLayerVersionPermissionResponse
s@AddLayerVersionPermissionResponse' {} Maybe Text
a -> AddLayerVersionPermissionResponse
s {$sel:revisionId:AddLayerVersionPermissionResponse' :: Maybe Text
revisionId = Maybe Text
a} :: AddLayerVersionPermissionResponse)

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

instance
  Prelude.NFData
    AddLayerVersionPermissionResponse