{-# 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.AppStream.AssociateApplicationToEntitlement
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates an application to entitle.
module Amazonka.AppStream.AssociateApplicationToEntitlement
  ( -- * Creating a Request
    AssociateApplicationToEntitlement (..),
    newAssociateApplicationToEntitlement,

    -- * Request Lenses
    associateApplicationToEntitlement_stackName,
    associateApplicationToEntitlement_entitlementName,
    associateApplicationToEntitlement_applicationIdentifier,

    -- * Destructuring the Response
    AssociateApplicationToEntitlementResponse (..),
    newAssociateApplicationToEntitlementResponse,

    -- * Response Lenses
    associateApplicationToEntitlementResponse_httpStatus,
  )
where

import Amazonka.AppStream.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newAssociateApplicationToEntitlement' smart constructor.
data AssociateApplicationToEntitlement = AssociateApplicationToEntitlement'
  { -- | The name of the stack.
    AssociateApplicationToEntitlement -> Text
stackName :: Prelude.Text,
    -- | The name of the entitlement.
    AssociateApplicationToEntitlement -> Text
entitlementName :: Prelude.Text,
    -- | The identifier of the application.
    AssociateApplicationToEntitlement -> Text
applicationIdentifier :: Prelude.Text
  }
  deriving (AssociateApplicationToEntitlement
-> AssociateApplicationToEntitlement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateApplicationToEntitlement
-> AssociateApplicationToEntitlement -> Bool
$c/= :: AssociateApplicationToEntitlement
-> AssociateApplicationToEntitlement -> Bool
== :: AssociateApplicationToEntitlement
-> AssociateApplicationToEntitlement -> Bool
$c== :: AssociateApplicationToEntitlement
-> AssociateApplicationToEntitlement -> Bool
Prelude.Eq, ReadPrec [AssociateApplicationToEntitlement]
ReadPrec AssociateApplicationToEntitlement
Int -> ReadS AssociateApplicationToEntitlement
ReadS [AssociateApplicationToEntitlement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateApplicationToEntitlement]
$creadListPrec :: ReadPrec [AssociateApplicationToEntitlement]
readPrec :: ReadPrec AssociateApplicationToEntitlement
$creadPrec :: ReadPrec AssociateApplicationToEntitlement
readList :: ReadS [AssociateApplicationToEntitlement]
$creadList :: ReadS [AssociateApplicationToEntitlement]
readsPrec :: Int -> ReadS AssociateApplicationToEntitlement
$creadsPrec :: Int -> ReadS AssociateApplicationToEntitlement
Prelude.Read, Int -> AssociateApplicationToEntitlement -> ShowS
[AssociateApplicationToEntitlement] -> ShowS
AssociateApplicationToEntitlement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateApplicationToEntitlement] -> ShowS
$cshowList :: [AssociateApplicationToEntitlement] -> ShowS
show :: AssociateApplicationToEntitlement -> String
$cshow :: AssociateApplicationToEntitlement -> String
showsPrec :: Int -> AssociateApplicationToEntitlement -> ShowS
$cshowsPrec :: Int -> AssociateApplicationToEntitlement -> ShowS
Prelude.Show, forall x.
Rep AssociateApplicationToEntitlement x
-> AssociateApplicationToEntitlement
forall x.
AssociateApplicationToEntitlement
-> Rep AssociateApplicationToEntitlement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateApplicationToEntitlement x
-> AssociateApplicationToEntitlement
$cfrom :: forall x.
AssociateApplicationToEntitlement
-> Rep AssociateApplicationToEntitlement x
Prelude.Generic)

-- |
-- Create a value of 'AssociateApplicationToEntitlement' 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:
--
-- 'stackName', 'associateApplicationToEntitlement_stackName' - The name of the stack.
--
-- 'entitlementName', 'associateApplicationToEntitlement_entitlementName' - The name of the entitlement.
--
-- 'applicationIdentifier', 'associateApplicationToEntitlement_applicationIdentifier' - The identifier of the application.
newAssociateApplicationToEntitlement ::
  -- | 'stackName'
  Prelude.Text ->
  -- | 'entitlementName'
  Prelude.Text ->
  -- | 'applicationIdentifier'
  Prelude.Text ->
  AssociateApplicationToEntitlement
newAssociateApplicationToEntitlement :: Text -> Text -> Text -> AssociateApplicationToEntitlement
newAssociateApplicationToEntitlement
  Text
pStackName_
  Text
pEntitlementName_
  Text
pApplicationIdentifier_ =
    AssociateApplicationToEntitlement'
      { $sel:stackName:AssociateApplicationToEntitlement' :: Text
stackName =
          Text
pStackName_,
        $sel:entitlementName:AssociateApplicationToEntitlement' :: Text
entitlementName = Text
pEntitlementName_,
        $sel:applicationIdentifier:AssociateApplicationToEntitlement' :: Text
applicationIdentifier =
          Text
pApplicationIdentifier_
      }

-- | The name of the stack.
associateApplicationToEntitlement_stackName :: Lens.Lens' AssociateApplicationToEntitlement Prelude.Text
associateApplicationToEntitlement_stackName :: Lens' AssociateApplicationToEntitlement Text
associateApplicationToEntitlement_stackName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateApplicationToEntitlement' {Text
stackName :: Text
$sel:stackName:AssociateApplicationToEntitlement' :: AssociateApplicationToEntitlement -> Text
stackName} -> Text
stackName) (\s :: AssociateApplicationToEntitlement
s@AssociateApplicationToEntitlement' {} Text
a -> AssociateApplicationToEntitlement
s {$sel:stackName:AssociateApplicationToEntitlement' :: Text
stackName = Text
a} :: AssociateApplicationToEntitlement)

-- | The name of the entitlement.
associateApplicationToEntitlement_entitlementName :: Lens.Lens' AssociateApplicationToEntitlement Prelude.Text
associateApplicationToEntitlement_entitlementName :: Lens' AssociateApplicationToEntitlement Text
associateApplicationToEntitlement_entitlementName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateApplicationToEntitlement' {Text
entitlementName :: Text
$sel:entitlementName:AssociateApplicationToEntitlement' :: AssociateApplicationToEntitlement -> Text
entitlementName} -> Text
entitlementName) (\s :: AssociateApplicationToEntitlement
s@AssociateApplicationToEntitlement' {} Text
a -> AssociateApplicationToEntitlement
s {$sel:entitlementName:AssociateApplicationToEntitlement' :: Text
entitlementName = Text
a} :: AssociateApplicationToEntitlement)

-- | The identifier of the application.
associateApplicationToEntitlement_applicationIdentifier :: Lens.Lens' AssociateApplicationToEntitlement Prelude.Text
associateApplicationToEntitlement_applicationIdentifier :: Lens' AssociateApplicationToEntitlement Text
associateApplicationToEntitlement_applicationIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateApplicationToEntitlement' {Text
applicationIdentifier :: Text
$sel:applicationIdentifier:AssociateApplicationToEntitlement' :: AssociateApplicationToEntitlement -> Text
applicationIdentifier} -> Text
applicationIdentifier) (\s :: AssociateApplicationToEntitlement
s@AssociateApplicationToEntitlement' {} Text
a -> AssociateApplicationToEntitlement
s {$sel:applicationIdentifier:AssociateApplicationToEntitlement' :: Text
applicationIdentifier = Text
a} :: AssociateApplicationToEntitlement)

instance
  Core.AWSRequest
    AssociateApplicationToEntitlement
  where
  type
    AWSResponse AssociateApplicationToEntitlement =
      AssociateApplicationToEntitlementResponse
  request :: (Service -> Service)
-> AssociateApplicationToEntitlement
-> Request AssociateApplicationToEntitlement
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AssociateApplicationToEntitlement
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociateApplicationToEntitlement)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AssociateApplicationToEntitlementResponse
AssociateApplicationToEntitlementResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    AssociateApplicationToEntitlement
  where
  hashWithSalt :: Int -> AssociateApplicationToEntitlement -> Int
hashWithSalt
    Int
_salt
    AssociateApplicationToEntitlement' {Text
applicationIdentifier :: Text
entitlementName :: Text
stackName :: Text
$sel:applicationIdentifier:AssociateApplicationToEntitlement' :: AssociateApplicationToEntitlement -> Text
$sel:entitlementName:AssociateApplicationToEntitlement' :: AssociateApplicationToEntitlement -> Text
$sel:stackName:AssociateApplicationToEntitlement' :: AssociateApplicationToEntitlement -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stackName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
entitlementName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationIdentifier

instance
  Prelude.NFData
    AssociateApplicationToEntitlement
  where
  rnf :: AssociateApplicationToEntitlement -> ()
rnf AssociateApplicationToEntitlement' {Text
applicationIdentifier :: Text
entitlementName :: Text
stackName :: Text
$sel:applicationIdentifier:AssociateApplicationToEntitlement' :: AssociateApplicationToEntitlement -> Text
$sel:entitlementName:AssociateApplicationToEntitlement' :: AssociateApplicationToEntitlement -> Text
$sel:stackName:AssociateApplicationToEntitlement' :: AssociateApplicationToEntitlement -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
stackName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
entitlementName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
applicationIdentifier

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

instance
  Data.ToJSON
    AssociateApplicationToEntitlement
  where
  toJSON :: AssociateApplicationToEntitlement -> Value
toJSON AssociateApplicationToEntitlement' {Text
applicationIdentifier :: Text
entitlementName :: Text
stackName :: Text
$sel:applicationIdentifier:AssociateApplicationToEntitlement' :: AssociateApplicationToEntitlement -> Text
$sel:entitlementName:AssociateApplicationToEntitlement' :: AssociateApplicationToEntitlement -> Text
$sel:stackName:AssociateApplicationToEntitlement' :: AssociateApplicationToEntitlement -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"StackName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
stackName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"EntitlementName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
entitlementName),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"ApplicationIdentifier"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
applicationIdentifier
              )
          ]
      )

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

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

-- | /See:/ 'newAssociateApplicationToEntitlementResponse' smart constructor.
data AssociateApplicationToEntitlementResponse = AssociateApplicationToEntitlementResponse'
  { -- | The response's http status code.
    AssociateApplicationToEntitlementResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AssociateApplicationToEntitlementResponse
-> AssociateApplicationToEntitlementResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateApplicationToEntitlementResponse
-> AssociateApplicationToEntitlementResponse -> Bool
$c/= :: AssociateApplicationToEntitlementResponse
-> AssociateApplicationToEntitlementResponse -> Bool
== :: AssociateApplicationToEntitlementResponse
-> AssociateApplicationToEntitlementResponse -> Bool
$c== :: AssociateApplicationToEntitlementResponse
-> AssociateApplicationToEntitlementResponse -> Bool
Prelude.Eq, ReadPrec [AssociateApplicationToEntitlementResponse]
ReadPrec AssociateApplicationToEntitlementResponse
Int -> ReadS AssociateApplicationToEntitlementResponse
ReadS [AssociateApplicationToEntitlementResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateApplicationToEntitlementResponse]
$creadListPrec :: ReadPrec [AssociateApplicationToEntitlementResponse]
readPrec :: ReadPrec AssociateApplicationToEntitlementResponse
$creadPrec :: ReadPrec AssociateApplicationToEntitlementResponse
readList :: ReadS [AssociateApplicationToEntitlementResponse]
$creadList :: ReadS [AssociateApplicationToEntitlementResponse]
readsPrec :: Int -> ReadS AssociateApplicationToEntitlementResponse
$creadsPrec :: Int -> ReadS AssociateApplicationToEntitlementResponse
Prelude.Read, Int -> AssociateApplicationToEntitlementResponse -> ShowS
[AssociateApplicationToEntitlementResponse] -> ShowS
AssociateApplicationToEntitlementResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateApplicationToEntitlementResponse] -> ShowS
$cshowList :: [AssociateApplicationToEntitlementResponse] -> ShowS
show :: AssociateApplicationToEntitlementResponse -> String
$cshow :: AssociateApplicationToEntitlementResponse -> String
showsPrec :: Int -> AssociateApplicationToEntitlementResponse -> ShowS
$cshowsPrec :: Int -> AssociateApplicationToEntitlementResponse -> ShowS
Prelude.Show, forall x.
Rep AssociateApplicationToEntitlementResponse x
-> AssociateApplicationToEntitlementResponse
forall x.
AssociateApplicationToEntitlementResponse
-> Rep AssociateApplicationToEntitlementResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateApplicationToEntitlementResponse x
-> AssociateApplicationToEntitlementResponse
$cfrom :: forall x.
AssociateApplicationToEntitlementResponse
-> Rep AssociateApplicationToEntitlementResponse x
Prelude.Generic)

-- |
-- Create a value of 'AssociateApplicationToEntitlementResponse' 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:
--
-- 'httpStatus', 'associateApplicationToEntitlementResponse_httpStatus' - The response's http status code.
newAssociateApplicationToEntitlementResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AssociateApplicationToEntitlementResponse
newAssociateApplicationToEntitlementResponse :: Int -> AssociateApplicationToEntitlementResponse
newAssociateApplicationToEntitlementResponse
  Int
pHttpStatus_ =
    AssociateApplicationToEntitlementResponse'
      { $sel:httpStatus:AssociateApplicationToEntitlementResponse' :: Int
httpStatus =
          Int
pHttpStatus_
      }

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

instance
  Prelude.NFData
    AssociateApplicationToEntitlementResponse
  where
  rnf :: AssociateApplicationToEntitlementResponse -> ()
rnf AssociateApplicationToEntitlementResponse' {Int
httpStatus :: Int
$sel:httpStatus:AssociateApplicationToEntitlementResponse' :: AssociateApplicationToEntitlementResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus