{-# 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.DeviceFarm.DeleteRun
-- 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 the run, given the run ARN.
--
-- Deleting this resource does not stop an in-progress run.
module Amazonka.DeviceFarm.DeleteRun
  ( -- * Creating a Request
    DeleteRun (..),
    newDeleteRun,

    -- * Request Lenses
    deleteRun_arn,

    -- * Destructuring the Response
    DeleteRunResponse (..),
    newDeleteRunResponse,

    -- * Response Lenses
    deleteRunResponse_httpStatus,
  )
where

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

-- | Represents a request to the delete run operation.
--
-- /See:/ 'newDeleteRun' smart constructor.
data DeleteRun = DeleteRun'
  { -- | The Amazon Resource Name (ARN) for the run to delete.
    DeleteRun -> Text
arn :: Prelude.Text
  }
  deriving (DeleteRun -> DeleteRun -> Bool
(DeleteRun -> DeleteRun -> Bool)
-> (DeleteRun -> DeleteRun -> Bool) -> Eq DeleteRun
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteRun -> DeleteRun -> Bool
$c/= :: DeleteRun -> DeleteRun -> Bool
== :: DeleteRun -> DeleteRun -> Bool
$c== :: DeleteRun -> DeleteRun -> Bool
Prelude.Eq, ReadPrec [DeleteRun]
ReadPrec DeleteRun
Int -> ReadS DeleteRun
ReadS [DeleteRun]
(Int -> ReadS DeleteRun)
-> ReadS [DeleteRun]
-> ReadPrec DeleteRun
-> ReadPrec [DeleteRun]
-> Read DeleteRun
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteRun]
$creadListPrec :: ReadPrec [DeleteRun]
readPrec :: ReadPrec DeleteRun
$creadPrec :: ReadPrec DeleteRun
readList :: ReadS [DeleteRun]
$creadList :: ReadS [DeleteRun]
readsPrec :: Int -> ReadS DeleteRun
$creadsPrec :: Int -> ReadS DeleteRun
Prelude.Read, Int -> DeleteRun -> ShowS
[DeleteRun] -> ShowS
DeleteRun -> String
(Int -> DeleteRun -> ShowS)
-> (DeleteRun -> String)
-> ([DeleteRun] -> ShowS)
-> Show DeleteRun
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteRun] -> ShowS
$cshowList :: [DeleteRun] -> ShowS
show :: DeleteRun -> String
$cshow :: DeleteRun -> String
showsPrec :: Int -> DeleteRun -> ShowS
$cshowsPrec :: Int -> DeleteRun -> ShowS
Prelude.Show, (forall x. DeleteRun -> Rep DeleteRun x)
-> (forall x. Rep DeleteRun x -> DeleteRun) -> Generic DeleteRun
forall x. Rep DeleteRun x -> DeleteRun
forall x. DeleteRun -> Rep DeleteRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteRun x -> DeleteRun
$cfrom :: forall x. DeleteRun -> Rep DeleteRun x
Prelude.Generic)

-- |
-- Create a value of 'DeleteRun' 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:
--
-- 'arn', 'deleteRun_arn' - The Amazon Resource Name (ARN) for the run to delete.
newDeleteRun ::
  -- | 'arn'
  Prelude.Text ->
  DeleteRun
newDeleteRun :: Text -> DeleteRun
newDeleteRun Text
pArn_ = DeleteRun' :: Text -> DeleteRun
DeleteRun' {$sel:arn:DeleteRun' :: Text
arn = Text
pArn_}

-- | The Amazon Resource Name (ARN) for the run to delete.
deleteRun_arn :: Lens.Lens' DeleteRun Prelude.Text
deleteRun_arn :: (Text -> f Text) -> DeleteRun -> f DeleteRun
deleteRun_arn = (DeleteRun -> Text)
-> (DeleteRun -> Text -> DeleteRun)
-> Lens DeleteRun DeleteRun Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRun' {Text
arn :: Text
$sel:arn:DeleteRun' :: DeleteRun -> Text
arn} -> Text
arn) (\s :: DeleteRun
s@DeleteRun' {} Text
a -> DeleteRun
s {$sel:arn:DeleteRun' :: Text
arn = Text
a} :: DeleteRun)

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

instance Prelude.NFData DeleteRun

instance Core.ToHeaders DeleteRun where
  toHeaders :: DeleteRun -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteRun -> 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
"DeviceFarm_20150623.DeleteRun" ::
                          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 DeleteRun where
  toJSON :: DeleteRun -> Value
toJSON DeleteRun' {Text
arn :: Text
$sel:arn:DeleteRun' :: DeleteRun -> 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
"arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn)]
      )

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

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

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

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

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

instance Prelude.NFData DeleteRunResponse