{-# 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.GameLift.DeleteScript
-- 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)
--
-- Deletes a Realtime script. This operation permanently deletes the script
-- record. If script files were uploaded, they are also deleted (files
-- stored in an S3 bucket are not deleted).
--
-- To delete a script, specify the script ID. Before deleting a script, be
-- sure to terminate all fleets that are deployed with the script being
-- deleted. Fleet instances periodically check for script updates, and if
-- the script record no longer exists, the instance will go into an error
-- state and be unable to host game sessions.
--
-- __Learn more__
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/realtime-intro.html Amazon GameLift Realtime Servers>
--
-- __Related actions__
--
-- CreateScript | ListScripts | DescribeScript | UpdateScript |
-- DeleteScript |
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
module Amazonka.GameLift.DeleteScript
  ( -- * Creating a Request
    DeleteScript (..),
    newDeleteScript,

    -- * Request Lenses
    deleteScript_scriptId,

    -- * Destructuring the Response
    DeleteScriptResponse (..),
    newDeleteScriptResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GameLift.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:/ 'newDeleteScript' smart constructor.
data DeleteScript = DeleteScript'
  { -- | A unique identifier for the Realtime script to delete. You can use
    -- either the script ID or ARN value.
    DeleteScript -> Text
scriptId :: Prelude.Text
  }
  deriving (DeleteScript -> DeleteScript -> Bool
(DeleteScript -> DeleteScript -> Bool)
-> (DeleteScript -> DeleteScript -> Bool) -> Eq DeleteScript
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteScript -> DeleteScript -> Bool
$c/= :: DeleteScript -> DeleteScript -> Bool
== :: DeleteScript -> DeleteScript -> Bool
$c== :: DeleteScript -> DeleteScript -> Bool
Prelude.Eq, ReadPrec [DeleteScript]
ReadPrec DeleteScript
Int -> ReadS DeleteScript
ReadS [DeleteScript]
(Int -> ReadS DeleteScript)
-> ReadS [DeleteScript]
-> ReadPrec DeleteScript
-> ReadPrec [DeleteScript]
-> Read DeleteScript
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteScript]
$creadListPrec :: ReadPrec [DeleteScript]
readPrec :: ReadPrec DeleteScript
$creadPrec :: ReadPrec DeleteScript
readList :: ReadS [DeleteScript]
$creadList :: ReadS [DeleteScript]
readsPrec :: Int -> ReadS DeleteScript
$creadsPrec :: Int -> ReadS DeleteScript
Prelude.Read, Int -> DeleteScript -> ShowS
[DeleteScript] -> ShowS
DeleteScript -> String
(Int -> DeleteScript -> ShowS)
-> (DeleteScript -> String)
-> ([DeleteScript] -> ShowS)
-> Show DeleteScript
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteScript] -> ShowS
$cshowList :: [DeleteScript] -> ShowS
show :: DeleteScript -> String
$cshow :: DeleteScript -> String
showsPrec :: Int -> DeleteScript -> ShowS
$cshowsPrec :: Int -> DeleteScript -> ShowS
Prelude.Show, (forall x. DeleteScript -> Rep DeleteScript x)
-> (forall x. Rep DeleteScript x -> DeleteScript)
-> Generic DeleteScript
forall x. Rep DeleteScript x -> DeleteScript
forall x. DeleteScript -> Rep DeleteScript x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteScript x -> DeleteScript
$cfrom :: forall x. DeleteScript -> Rep DeleteScript x
Prelude.Generic)

-- |
-- Create a value of 'DeleteScript' 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:
--
-- 'scriptId', 'deleteScript_scriptId' - A unique identifier for the Realtime script to delete. You can use
-- either the script ID or ARN value.
newDeleteScript ::
  -- | 'scriptId'
  Prelude.Text ->
  DeleteScript
newDeleteScript :: Text -> DeleteScript
newDeleteScript Text
pScriptId_ =
  DeleteScript' :: Text -> DeleteScript
DeleteScript' {$sel:scriptId:DeleteScript' :: Text
scriptId = Text
pScriptId_}

-- | A unique identifier for the Realtime script to delete. You can use
-- either the script ID or ARN value.
deleteScript_scriptId :: Lens.Lens' DeleteScript Prelude.Text
deleteScript_scriptId :: (Text -> f Text) -> DeleteScript -> f DeleteScript
deleteScript_scriptId = (DeleteScript -> Text)
-> (DeleteScript -> Text -> DeleteScript)
-> Lens DeleteScript DeleteScript Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteScript' {Text
scriptId :: Text
$sel:scriptId:DeleteScript' :: DeleteScript -> Text
scriptId} -> Text
scriptId) (\s :: DeleteScript
s@DeleteScript' {} Text
a -> DeleteScript
s {$sel:scriptId:DeleteScript' :: Text
scriptId = Text
a} :: DeleteScript)

instance Core.AWSRequest DeleteScript where
  type AWSResponse DeleteScript = DeleteScriptResponse
  request :: DeleteScript -> Request DeleteScript
request = Service -> DeleteScript -> Request DeleteScript
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteScript
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteScript)))
response = AWSResponse DeleteScript
-> Logger
-> Service
-> Proxy DeleteScript
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteScript)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeleteScript
DeleteScriptResponse
DeleteScriptResponse'

instance Prelude.Hashable DeleteScript

instance Prelude.NFData DeleteScript

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

instance Core.ToJSON DeleteScript where
  toJSON :: DeleteScript -> Value
toJSON DeleteScript' {Text
scriptId :: Text
$sel:scriptId:DeleteScript' :: DeleteScript -> 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
"ScriptId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
scriptId)]
      )

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

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

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

-- |
-- Create a value of 'DeleteScriptResponse' 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.
newDeleteScriptResponse ::
  DeleteScriptResponse
newDeleteScriptResponse :: DeleteScriptResponse
newDeleteScriptResponse = DeleteScriptResponse
DeleteScriptResponse'

instance Prelude.NFData DeleteScriptResponse