{-# 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.UpdateProject
-- 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)
--
-- Modifies the specified project name, given the project ARN and a new
-- name.
module Amazonka.DeviceFarm.UpdateProject
  ( -- * Creating a Request
    UpdateProject (..),
    newUpdateProject,

    -- * Request Lenses
    updateProject_name,
    updateProject_defaultJobTimeoutMinutes,
    updateProject_arn,

    -- * Destructuring the Response
    UpdateProjectResponse (..),
    newUpdateProjectResponse,

    -- * Response Lenses
    updateProjectResponse_project,
    updateProjectResponse_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 update project operation.
--
-- /See:/ 'newUpdateProject' smart constructor.
data UpdateProject = UpdateProject'
  { -- | A string that represents the new name of the project that you are
    -- updating.
    UpdateProject -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The number of minutes a test run in the project executes before it times
    -- out.
    UpdateProject -> Maybe Int
defaultJobTimeoutMinutes :: Prelude.Maybe Prelude.Int,
    -- | The Amazon Resource Name (ARN) of the project whose name to update.
    UpdateProject -> Text
arn :: Prelude.Text
  }
  deriving (UpdateProject -> UpdateProject -> Bool
(UpdateProject -> UpdateProject -> Bool)
-> (UpdateProject -> UpdateProject -> Bool) -> Eq UpdateProject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateProject -> UpdateProject -> Bool
$c/= :: UpdateProject -> UpdateProject -> Bool
== :: UpdateProject -> UpdateProject -> Bool
$c== :: UpdateProject -> UpdateProject -> Bool
Prelude.Eq, ReadPrec [UpdateProject]
ReadPrec UpdateProject
Int -> ReadS UpdateProject
ReadS [UpdateProject]
(Int -> ReadS UpdateProject)
-> ReadS [UpdateProject]
-> ReadPrec UpdateProject
-> ReadPrec [UpdateProject]
-> Read UpdateProject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateProject]
$creadListPrec :: ReadPrec [UpdateProject]
readPrec :: ReadPrec UpdateProject
$creadPrec :: ReadPrec UpdateProject
readList :: ReadS [UpdateProject]
$creadList :: ReadS [UpdateProject]
readsPrec :: Int -> ReadS UpdateProject
$creadsPrec :: Int -> ReadS UpdateProject
Prelude.Read, Int -> UpdateProject -> ShowS
[UpdateProject] -> ShowS
UpdateProject -> String
(Int -> UpdateProject -> ShowS)
-> (UpdateProject -> String)
-> ([UpdateProject] -> ShowS)
-> Show UpdateProject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateProject] -> ShowS
$cshowList :: [UpdateProject] -> ShowS
show :: UpdateProject -> String
$cshow :: UpdateProject -> String
showsPrec :: Int -> UpdateProject -> ShowS
$cshowsPrec :: Int -> UpdateProject -> ShowS
Prelude.Show, (forall x. UpdateProject -> Rep UpdateProject x)
-> (forall x. Rep UpdateProject x -> UpdateProject)
-> Generic UpdateProject
forall x. Rep UpdateProject x -> UpdateProject
forall x. UpdateProject -> Rep UpdateProject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateProject x -> UpdateProject
$cfrom :: forall x. UpdateProject -> Rep UpdateProject x
Prelude.Generic)

-- |
-- Create a value of 'UpdateProject' 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:
--
-- 'name', 'updateProject_name' - A string that represents the new name of the project that you are
-- updating.
--
-- 'defaultJobTimeoutMinutes', 'updateProject_defaultJobTimeoutMinutes' - The number of minutes a test run in the project executes before it times
-- out.
--
-- 'arn', 'updateProject_arn' - The Amazon Resource Name (ARN) of the project whose name to update.
newUpdateProject ::
  -- | 'arn'
  Prelude.Text ->
  UpdateProject
newUpdateProject :: Text -> UpdateProject
newUpdateProject Text
pArn_ =
  UpdateProject' :: Maybe Text -> Maybe Int -> Text -> UpdateProject
UpdateProject'
    { $sel:name:UpdateProject' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultJobTimeoutMinutes:UpdateProject' :: Maybe Int
defaultJobTimeoutMinutes = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:UpdateProject' :: Text
arn = Text
pArn_
    }

-- | A string that represents the new name of the project that you are
-- updating.
updateProject_name :: Lens.Lens' UpdateProject (Prelude.Maybe Prelude.Text)
updateProject_name :: (Maybe Text -> f (Maybe Text)) -> UpdateProject -> f UpdateProject
updateProject_name = (UpdateProject -> Maybe Text)
-> (UpdateProject -> Maybe Text -> UpdateProject)
-> Lens UpdateProject UpdateProject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProject' {Maybe Text
name :: Maybe Text
$sel:name:UpdateProject' :: UpdateProject -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateProject
s@UpdateProject' {} Maybe Text
a -> UpdateProject
s {$sel:name:UpdateProject' :: Maybe Text
name = Maybe Text
a} :: UpdateProject)

-- | The number of minutes a test run in the project executes before it times
-- out.
updateProject_defaultJobTimeoutMinutes :: Lens.Lens' UpdateProject (Prelude.Maybe Prelude.Int)
updateProject_defaultJobTimeoutMinutes :: (Maybe Int -> f (Maybe Int)) -> UpdateProject -> f UpdateProject
updateProject_defaultJobTimeoutMinutes = (UpdateProject -> Maybe Int)
-> (UpdateProject -> Maybe Int -> UpdateProject)
-> Lens UpdateProject UpdateProject (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProject' {Maybe Int
defaultJobTimeoutMinutes :: Maybe Int
$sel:defaultJobTimeoutMinutes:UpdateProject' :: UpdateProject -> Maybe Int
defaultJobTimeoutMinutes} -> Maybe Int
defaultJobTimeoutMinutes) (\s :: UpdateProject
s@UpdateProject' {} Maybe Int
a -> UpdateProject
s {$sel:defaultJobTimeoutMinutes:UpdateProject' :: Maybe Int
defaultJobTimeoutMinutes = Maybe Int
a} :: UpdateProject)

-- | The Amazon Resource Name (ARN) of the project whose name to update.
updateProject_arn :: Lens.Lens' UpdateProject Prelude.Text
updateProject_arn :: (Text -> f Text) -> UpdateProject -> f UpdateProject
updateProject_arn = (UpdateProject -> Text)
-> (UpdateProject -> Text -> UpdateProject)
-> Lens UpdateProject UpdateProject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProject' {Text
arn :: Text
$sel:arn:UpdateProject' :: UpdateProject -> Text
arn} -> Text
arn) (\s :: UpdateProject
s@UpdateProject' {} Text
a -> UpdateProject
s {$sel:arn:UpdateProject' :: Text
arn = Text
a} :: UpdateProject)

instance Core.AWSRequest UpdateProject where
  type
    AWSResponse UpdateProject =
      UpdateProjectResponse
  request :: UpdateProject -> Request UpdateProject
request = Service -> UpdateProject -> Request UpdateProject
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateProject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateProject)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateProject))
-> Logger
-> Service
-> Proxy UpdateProject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateProject)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Project -> Int -> UpdateProjectResponse
UpdateProjectResponse'
            (Maybe Project -> Int -> UpdateProjectResponse)
-> Either String (Maybe Project)
-> Either String (Int -> UpdateProjectResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Project)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"project")
            Either String (Int -> UpdateProjectResponse)
-> Either String Int -> Either String UpdateProjectResponse
forall (f :: * -> *) a b. Applicative f => 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 UpdateProject

instance Prelude.NFData UpdateProject

instance Core.ToHeaders UpdateProject where
  toHeaders :: UpdateProject -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateProject -> 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.UpdateProject" ::
                          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 UpdateProject where
  toJSON :: UpdateProject -> Value
toJSON UpdateProject' {Maybe Int
Maybe Text
Text
arn :: Text
defaultJobTimeoutMinutes :: Maybe Int
name :: Maybe Text
$sel:arn:UpdateProject' :: UpdateProject -> Text
$sel:defaultJobTimeoutMinutes:UpdateProject' :: UpdateProject -> Maybe Int
$sel:name:UpdateProject' :: UpdateProject -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Text
"defaultJobTimeoutMinutes" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
defaultJobTimeoutMinutes,
            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 UpdateProject where
  toPath :: UpdateProject -> ByteString
toPath = ByteString -> UpdateProject -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'UpdateProjectResponse' 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:
--
-- 'project', 'updateProjectResponse_project' - The project to update.
--
-- 'httpStatus', 'updateProjectResponse_httpStatus' - The response's http status code.
newUpdateProjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateProjectResponse
newUpdateProjectResponse :: Int -> UpdateProjectResponse
newUpdateProjectResponse Int
pHttpStatus_ =
  UpdateProjectResponse' :: Maybe Project -> Int -> UpdateProjectResponse
UpdateProjectResponse'
    { $sel:project:UpdateProjectResponse' :: Maybe Project
project = Maybe Project
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateProjectResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The project to update.
updateProjectResponse_project :: Lens.Lens' UpdateProjectResponse (Prelude.Maybe Project)
updateProjectResponse_project :: (Maybe Project -> f (Maybe Project))
-> UpdateProjectResponse -> f UpdateProjectResponse
updateProjectResponse_project = (UpdateProjectResponse -> Maybe Project)
-> (UpdateProjectResponse
    -> Maybe Project -> UpdateProjectResponse)
-> Lens
     UpdateProjectResponse
     UpdateProjectResponse
     (Maybe Project)
     (Maybe Project)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProjectResponse' {Maybe Project
project :: Maybe Project
$sel:project:UpdateProjectResponse' :: UpdateProjectResponse -> Maybe Project
project} -> Maybe Project
project) (\s :: UpdateProjectResponse
s@UpdateProjectResponse' {} Maybe Project
a -> UpdateProjectResponse
s {$sel:project:UpdateProjectResponse' :: Maybe Project
project = Maybe Project
a} :: UpdateProjectResponse)

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

instance Prelude.NFData UpdateProjectResponse