{-# 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.UpdateUpload
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates an uploaded test spec.
module Amazonka.DeviceFarm.UpdateUpload
  ( -- * Creating a Request
    UpdateUpload (..),
    newUpdateUpload,

    -- * Request Lenses
    updateUpload_contentType,
    updateUpload_editContent,
    updateUpload_name,
    updateUpload_arn,

    -- * Destructuring the Response
    UpdateUploadResponse (..),
    newUpdateUploadResponse,

    -- * Response Lenses
    updateUploadResponse_upload,
    updateUploadResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateUpload' smart constructor.
data UpdateUpload = UpdateUpload'
  { -- | The upload\'s content type (for example, @application\/x-yaml@).
    UpdateUpload -> Maybe Text
contentType :: Prelude.Maybe Prelude.Text,
    -- | Set to true if the YAML file has changed and must be updated. Otherwise,
    -- set to false.
    UpdateUpload -> Maybe Bool
editContent :: Prelude.Maybe Prelude.Bool,
    -- | The upload\'s test spec file name. The name must not contain any forward
    -- slashes (\/). The test spec file name must end with the @.yaml@ or
    -- @.yml@ file extension.
    UpdateUpload -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the uploaded test spec.
    UpdateUpload -> Text
arn :: Prelude.Text
  }
  deriving (UpdateUpload -> UpdateUpload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateUpload -> UpdateUpload -> Bool
$c/= :: UpdateUpload -> UpdateUpload -> Bool
== :: UpdateUpload -> UpdateUpload -> Bool
$c== :: UpdateUpload -> UpdateUpload -> Bool
Prelude.Eq, ReadPrec [UpdateUpload]
ReadPrec UpdateUpload
Int -> ReadS UpdateUpload
ReadS [UpdateUpload]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateUpload]
$creadListPrec :: ReadPrec [UpdateUpload]
readPrec :: ReadPrec UpdateUpload
$creadPrec :: ReadPrec UpdateUpload
readList :: ReadS [UpdateUpload]
$creadList :: ReadS [UpdateUpload]
readsPrec :: Int -> ReadS UpdateUpload
$creadsPrec :: Int -> ReadS UpdateUpload
Prelude.Read, Int -> UpdateUpload -> ShowS
[UpdateUpload] -> ShowS
UpdateUpload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateUpload] -> ShowS
$cshowList :: [UpdateUpload] -> ShowS
show :: UpdateUpload -> String
$cshow :: UpdateUpload -> String
showsPrec :: Int -> UpdateUpload -> ShowS
$cshowsPrec :: Int -> UpdateUpload -> ShowS
Prelude.Show, forall x. Rep UpdateUpload x -> UpdateUpload
forall x. UpdateUpload -> Rep UpdateUpload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateUpload x -> UpdateUpload
$cfrom :: forall x. UpdateUpload -> Rep UpdateUpload x
Prelude.Generic)

-- |
-- Create a value of 'UpdateUpload' 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:
--
-- 'contentType', 'updateUpload_contentType' - The upload\'s content type (for example, @application\/x-yaml@).
--
-- 'editContent', 'updateUpload_editContent' - Set to true if the YAML file has changed and must be updated. Otherwise,
-- set to false.
--
-- 'name', 'updateUpload_name' - The upload\'s test spec file name. The name must not contain any forward
-- slashes (\/). The test spec file name must end with the @.yaml@ or
-- @.yml@ file extension.
--
-- 'arn', 'updateUpload_arn' - The Amazon Resource Name (ARN) of the uploaded test spec.
newUpdateUpload ::
  -- | 'arn'
  Prelude.Text ->
  UpdateUpload
newUpdateUpload :: Text -> UpdateUpload
newUpdateUpload Text
pArn_ =
  UpdateUpload'
    { $sel:contentType:UpdateUpload' :: Maybe Text
contentType = forall a. Maybe a
Prelude.Nothing,
      $sel:editContent:UpdateUpload' :: Maybe Bool
editContent = forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateUpload' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:arn:UpdateUpload' :: Text
arn = Text
pArn_
    }

-- | The upload\'s content type (for example, @application\/x-yaml@).
updateUpload_contentType :: Lens.Lens' UpdateUpload (Prelude.Maybe Prelude.Text)
updateUpload_contentType :: Lens' UpdateUpload (Maybe Text)
updateUpload_contentType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUpload' {Maybe Text
contentType :: Maybe Text
$sel:contentType:UpdateUpload' :: UpdateUpload -> Maybe Text
contentType} -> Maybe Text
contentType) (\s :: UpdateUpload
s@UpdateUpload' {} Maybe Text
a -> UpdateUpload
s {$sel:contentType:UpdateUpload' :: Maybe Text
contentType = Maybe Text
a} :: UpdateUpload)

-- | Set to true if the YAML file has changed and must be updated. Otherwise,
-- set to false.
updateUpload_editContent :: Lens.Lens' UpdateUpload (Prelude.Maybe Prelude.Bool)
updateUpload_editContent :: Lens' UpdateUpload (Maybe Bool)
updateUpload_editContent = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUpload' {Maybe Bool
editContent :: Maybe Bool
$sel:editContent:UpdateUpload' :: UpdateUpload -> Maybe Bool
editContent} -> Maybe Bool
editContent) (\s :: UpdateUpload
s@UpdateUpload' {} Maybe Bool
a -> UpdateUpload
s {$sel:editContent:UpdateUpload' :: Maybe Bool
editContent = Maybe Bool
a} :: UpdateUpload)

-- | The upload\'s test spec file name. The name must not contain any forward
-- slashes (\/). The test spec file name must end with the @.yaml@ or
-- @.yml@ file extension.
updateUpload_name :: Lens.Lens' UpdateUpload (Prelude.Maybe Prelude.Text)
updateUpload_name :: Lens' UpdateUpload (Maybe Text)
updateUpload_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUpload' {Maybe Text
name :: Maybe Text
$sel:name:UpdateUpload' :: UpdateUpload -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateUpload
s@UpdateUpload' {} Maybe Text
a -> UpdateUpload
s {$sel:name:UpdateUpload' :: Maybe Text
name = Maybe Text
a} :: UpdateUpload)

-- | The Amazon Resource Name (ARN) of the uploaded test spec.
updateUpload_arn :: Lens.Lens' UpdateUpload Prelude.Text
updateUpload_arn :: Lens' UpdateUpload Text
updateUpload_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUpload' {Text
arn :: Text
$sel:arn:UpdateUpload' :: UpdateUpload -> Text
arn} -> Text
arn) (\s :: UpdateUpload
s@UpdateUpload' {} Text
a -> UpdateUpload
s {$sel:arn:UpdateUpload' :: Text
arn = Text
a} :: UpdateUpload)

instance Core.AWSRequest UpdateUpload where
  type AWSResponse UpdateUpload = UpdateUploadResponse
  request :: (Service -> Service) -> UpdateUpload -> Request UpdateUpload
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 UpdateUpload
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateUpload)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Upload -> Int -> UpdateUploadResponse
UpdateUploadResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"upload")
            forall (f :: * -> *) a b. Applicative f => 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 UpdateUpload where
  hashWithSalt :: Int -> UpdateUpload -> Int
hashWithSalt Int
_salt UpdateUpload' {Maybe Bool
Maybe Text
Text
arn :: Text
name :: Maybe Text
editContent :: Maybe Bool
contentType :: Maybe Text
$sel:arn:UpdateUpload' :: UpdateUpload -> Text
$sel:name:UpdateUpload' :: UpdateUpload -> Maybe Text
$sel:editContent:UpdateUpload' :: UpdateUpload -> Maybe Bool
$sel:contentType:UpdateUpload' :: UpdateUpload -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
contentType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
editContent
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

instance Prelude.NFData UpdateUpload where
  rnf :: UpdateUpload -> ()
rnf UpdateUpload' {Maybe Bool
Maybe Text
Text
arn :: Text
name :: Maybe Text
editContent :: Maybe Bool
contentType :: Maybe Text
$sel:arn:UpdateUpload' :: UpdateUpload -> Text
$sel:name:UpdateUpload' :: UpdateUpload -> Maybe Text
$sel:editContent:UpdateUpload' :: UpdateUpload -> Maybe Bool
$sel:contentType:UpdateUpload' :: UpdateUpload -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contentType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
editContent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn

instance Data.ToHeaders UpdateUpload where
  toHeaders :: UpdateUpload -> 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
"DeviceFarm_20150623.UpdateUpload" ::
                          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 UpdateUpload where
  toJSON :: UpdateUpload -> Value
toJSON UpdateUpload' {Maybe Bool
Maybe Text
Text
arn :: Text
name :: Maybe Text
editContent :: Maybe Bool
contentType :: Maybe Text
$sel:arn:UpdateUpload' :: UpdateUpload -> Text
$sel:name:UpdateUpload' :: UpdateUpload -> Maybe Text
$sel:editContent:UpdateUpload' :: UpdateUpload -> Maybe Bool
$sel:contentType:UpdateUpload' :: UpdateUpload -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"contentType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
contentType,
            (Key
"editContent" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
editContent,
            (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            forall a. a -> Maybe a
Prelude.Just (Key
"arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
arn)
          ]
      )

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

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

-- | /See:/ 'newUpdateUploadResponse' smart constructor.
data UpdateUploadResponse = UpdateUploadResponse'
  { -- | A test spec uploaded to Device Farm.
    UpdateUploadResponse -> Maybe Upload
upload :: Prelude.Maybe Upload,
    -- | The response's http status code.
    UpdateUploadResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateUploadResponse -> UpdateUploadResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateUploadResponse -> UpdateUploadResponse -> Bool
$c/= :: UpdateUploadResponse -> UpdateUploadResponse -> Bool
== :: UpdateUploadResponse -> UpdateUploadResponse -> Bool
$c== :: UpdateUploadResponse -> UpdateUploadResponse -> Bool
Prelude.Eq, Int -> UpdateUploadResponse -> ShowS
[UpdateUploadResponse] -> ShowS
UpdateUploadResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateUploadResponse] -> ShowS
$cshowList :: [UpdateUploadResponse] -> ShowS
show :: UpdateUploadResponse -> String
$cshow :: UpdateUploadResponse -> String
showsPrec :: Int -> UpdateUploadResponse -> ShowS
$cshowsPrec :: Int -> UpdateUploadResponse -> ShowS
Prelude.Show, forall x. Rep UpdateUploadResponse x -> UpdateUploadResponse
forall x. UpdateUploadResponse -> Rep UpdateUploadResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateUploadResponse x -> UpdateUploadResponse
$cfrom :: forall x. UpdateUploadResponse -> Rep UpdateUploadResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateUploadResponse' 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:
--
-- 'upload', 'updateUploadResponse_upload' - A test spec uploaded to Device Farm.
--
-- 'httpStatus', 'updateUploadResponse_httpStatus' - The response's http status code.
newUpdateUploadResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateUploadResponse
newUpdateUploadResponse :: Int -> UpdateUploadResponse
newUpdateUploadResponse Int
pHttpStatus_ =
  UpdateUploadResponse'
    { $sel:upload:UpdateUploadResponse' :: Maybe Upload
upload = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateUploadResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A test spec uploaded to Device Farm.
updateUploadResponse_upload :: Lens.Lens' UpdateUploadResponse (Prelude.Maybe Upload)
updateUploadResponse_upload :: Lens' UpdateUploadResponse (Maybe Upload)
updateUploadResponse_upload = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUploadResponse' {Maybe Upload
upload :: Maybe Upload
$sel:upload:UpdateUploadResponse' :: UpdateUploadResponse -> Maybe Upload
upload} -> Maybe Upload
upload) (\s :: UpdateUploadResponse
s@UpdateUploadResponse' {} Maybe Upload
a -> UpdateUploadResponse
s {$sel:upload:UpdateUploadResponse' :: Maybe Upload
upload = Maybe Upload
a} :: UpdateUploadResponse)

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

instance Prelude.NFData UpdateUploadResponse where
  rnf :: UpdateUploadResponse -> ()
rnf UpdateUploadResponse' {Int
Maybe Upload
httpStatus :: Int
upload :: Maybe Upload
$sel:httpStatus:UpdateUploadResponse' :: UpdateUploadResponse -> Int
$sel:upload:UpdateUploadResponse' :: UpdateUploadResponse -> Maybe Upload
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Upload
upload
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus