{-# 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.AssociateFleet
-- 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)
--
-- Associates the specified fleet with the specified stack.
module Amazonka.AppStream.AssociateFleet
  ( -- * Creating a Request
    AssociateFleet (..),
    newAssociateFleet,

    -- * Request Lenses
    associateFleet_fleetName,
    associateFleet_stackName,

    -- * Destructuring the Response
    AssociateFleetResponse (..),
    newAssociateFleetResponse,

    -- * Response Lenses
    associateFleetResponse_httpStatus,
  )
where

import Amazonka.AppStream.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:/ 'newAssociateFleet' smart constructor.
data AssociateFleet = AssociateFleet'
  { -- | The name of the fleet.
    AssociateFleet -> Text
fleetName :: Prelude.Text,
    -- | The name of the stack.
    AssociateFleet -> Text
stackName :: Prelude.Text
  }
  deriving (AssociateFleet -> AssociateFleet -> Bool
(AssociateFleet -> AssociateFleet -> Bool)
-> (AssociateFleet -> AssociateFleet -> Bool) -> Eq AssociateFleet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateFleet -> AssociateFleet -> Bool
$c/= :: AssociateFleet -> AssociateFleet -> Bool
== :: AssociateFleet -> AssociateFleet -> Bool
$c== :: AssociateFleet -> AssociateFleet -> Bool
Prelude.Eq, ReadPrec [AssociateFleet]
ReadPrec AssociateFleet
Int -> ReadS AssociateFleet
ReadS [AssociateFleet]
(Int -> ReadS AssociateFleet)
-> ReadS [AssociateFleet]
-> ReadPrec AssociateFleet
-> ReadPrec [AssociateFleet]
-> Read AssociateFleet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateFleet]
$creadListPrec :: ReadPrec [AssociateFleet]
readPrec :: ReadPrec AssociateFleet
$creadPrec :: ReadPrec AssociateFleet
readList :: ReadS [AssociateFleet]
$creadList :: ReadS [AssociateFleet]
readsPrec :: Int -> ReadS AssociateFleet
$creadsPrec :: Int -> ReadS AssociateFleet
Prelude.Read, Int -> AssociateFleet -> ShowS
[AssociateFleet] -> ShowS
AssociateFleet -> String
(Int -> AssociateFleet -> ShowS)
-> (AssociateFleet -> String)
-> ([AssociateFleet] -> ShowS)
-> Show AssociateFleet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateFleet] -> ShowS
$cshowList :: [AssociateFleet] -> ShowS
show :: AssociateFleet -> String
$cshow :: AssociateFleet -> String
showsPrec :: Int -> AssociateFleet -> ShowS
$cshowsPrec :: Int -> AssociateFleet -> ShowS
Prelude.Show, (forall x. AssociateFleet -> Rep AssociateFleet x)
-> (forall x. Rep AssociateFleet x -> AssociateFleet)
-> Generic AssociateFleet
forall x. Rep AssociateFleet x -> AssociateFleet
forall x. AssociateFleet -> Rep AssociateFleet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateFleet x -> AssociateFleet
$cfrom :: forall x. AssociateFleet -> Rep AssociateFleet x
Prelude.Generic)

-- |
-- Create a value of 'AssociateFleet' 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:
--
-- 'fleetName', 'associateFleet_fleetName' - The name of the fleet.
--
-- 'stackName', 'associateFleet_stackName' - The name of the stack.
newAssociateFleet ::
  -- | 'fleetName'
  Prelude.Text ->
  -- | 'stackName'
  Prelude.Text ->
  AssociateFleet
newAssociateFleet :: Text -> Text -> AssociateFleet
newAssociateFleet Text
pFleetName_ Text
pStackName_ =
  AssociateFleet' :: Text -> Text -> AssociateFleet
AssociateFleet'
    { $sel:fleetName:AssociateFleet' :: Text
fleetName = Text
pFleetName_,
      $sel:stackName:AssociateFleet' :: Text
stackName = Text
pStackName_
    }

-- | The name of the fleet.
associateFleet_fleetName :: Lens.Lens' AssociateFleet Prelude.Text
associateFleet_fleetName :: (Text -> f Text) -> AssociateFleet -> f AssociateFleet
associateFleet_fleetName = (AssociateFleet -> Text)
-> (AssociateFleet -> Text -> AssociateFleet)
-> Lens AssociateFleet AssociateFleet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateFleet' {Text
fleetName :: Text
$sel:fleetName:AssociateFleet' :: AssociateFleet -> Text
fleetName} -> Text
fleetName) (\s :: AssociateFleet
s@AssociateFleet' {} Text
a -> AssociateFleet
s {$sel:fleetName:AssociateFleet' :: Text
fleetName = Text
a} :: AssociateFleet)

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

instance Core.AWSRequest AssociateFleet where
  type
    AWSResponse AssociateFleet =
      AssociateFleetResponse
  request :: AssociateFleet -> Request AssociateFleet
request = Service -> AssociateFleet -> Request AssociateFleet
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateFleet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AssociateFleet)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AssociateFleet))
-> Logger
-> Service
-> Proxy AssociateFleet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AssociateFleet)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AssociateFleetResponse
AssociateFleetResponse'
            (Int -> AssociateFleetResponse)
-> Either String Int -> Either String AssociateFleetResponse
forall (f :: * -> *) a b. Functor 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 AssociateFleet

instance Prelude.NFData AssociateFleet

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

instance Core.ToJSON AssociateFleet where
  toJSON :: AssociateFleet -> Value
toJSON AssociateFleet' {Text
stackName :: Text
fleetName :: Text
$sel:stackName:AssociateFleet' :: AssociateFleet -> Text
$sel:fleetName:AssociateFleet' :: AssociateFleet -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FleetName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fleetName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StackName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
stackName)
          ]
      )

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

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

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

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

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

instance Prelude.NFData AssociateFleetResponse