{-# 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.Outposts.UpdateSite
-- 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 the specified site.
module Amazonka.Outposts.UpdateSite
  ( -- * Creating a Request
    UpdateSite (..),
    newUpdateSite,

    -- * Request Lenses
    updateSite_description,
    updateSite_name,
    updateSite_notes,
    updateSite_siteId,

    -- * Destructuring the Response
    UpdateSiteResponse (..),
    newUpdateSiteResponse,

    -- * Response Lenses
    updateSiteResponse_site,
    updateSiteResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateSite' smart constructor.
data UpdateSite = UpdateSite'
  { UpdateSite -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    UpdateSite -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Notes about a site.
    UpdateSite -> Maybe Text
notes :: Prelude.Maybe Prelude.Text,
    -- | The ID or the Amazon Resource Name (ARN) of the site.
    UpdateSite -> Text
siteId :: Prelude.Text
  }
  deriving (UpdateSite -> UpdateSite -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSite -> UpdateSite -> Bool
$c/= :: UpdateSite -> UpdateSite -> Bool
== :: UpdateSite -> UpdateSite -> Bool
$c== :: UpdateSite -> UpdateSite -> Bool
Prelude.Eq, ReadPrec [UpdateSite]
ReadPrec UpdateSite
Int -> ReadS UpdateSite
ReadS [UpdateSite]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSite]
$creadListPrec :: ReadPrec [UpdateSite]
readPrec :: ReadPrec UpdateSite
$creadPrec :: ReadPrec UpdateSite
readList :: ReadS [UpdateSite]
$creadList :: ReadS [UpdateSite]
readsPrec :: Int -> ReadS UpdateSite
$creadsPrec :: Int -> ReadS UpdateSite
Prelude.Read, Int -> UpdateSite -> ShowS
[UpdateSite] -> ShowS
UpdateSite -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSite] -> ShowS
$cshowList :: [UpdateSite] -> ShowS
show :: UpdateSite -> String
$cshow :: UpdateSite -> String
showsPrec :: Int -> UpdateSite -> ShowS
$cshowsPrec :: Int -> UpdateSite -> ShowS
Prelude.Show, forall x. Rep UpdateSite x -> UpdateSite
forall x. UpdateSite -> Rep UpdateSite x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSite x -> UpdateSite
$cfrom :: forall x. UpdateSite -> Rep UpdateSite x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSite' 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:
--
-- 'description', 'updateSite_description' - Undocumented member.
--
-- 'name', 'updateSite_name' - Undocumented member.
--
-- 'notes', 'updateSite_notes' - Notes about a site.
--
-- 'siteId', 'updateSite_siteId' - The ID or the Amazon Resource Name (ARN) of the site.
newUpdateSite ::
  -- | 'siteId'
  Prelude.Text ->
  UpdateSite
newUpdateSite :: Text -> UpdateSite
newUpdateSite Text
pSiteId_ =
  UpdateSite'
    { $sel:description:UpdateSite' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateSite' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:notes:UpdateSite' :: Maybe Text
notes = forall a. Maybe a
Prelude.Nothing,
      $sel:siteId:UpdateSite' :: Text
siteId = Text
pSiteId_
    }

-- | Undocumented member.
updateSite_description :: Lens.Lens' UpdateSite (Prelude.Maybe Prelude.Text)
updateSite_description :: Lens' UpdateSite (Maybe Text)
updateSite_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSite' {Maybe Text
description :: Maybe Text
$sel:description:UpdateSite' :: UpdateSite -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateSite
s@UpdateSite' {} Maybe Text
a -> UpdateSite
s {$sel:description:UpdateSite' :: Maybe Text
description = Maybe Text
a} :: UpdateSite)

-- | Undocumented member.
updateSite_name :: Lens.Lens' UpdateSite (Prelude.Maybe Prelude.Text)
updateSite_name :: Lens' UpdateSite (Maybe Text)
updateSite_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSite' {Maybe Text
name :: Maybe Text
$sel:name:UpdateSite' :: UpdateSite -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateSite
s@UpdateSite' {} Maybe Text
a -> UpdateSite
s {$sel:name:UpdateSite' :: Maybe Text
name = Maybe Text
a} :: UpdateSite)

-- | Notes about a site.
updateSite_notes :: Lens.Lens' UpdateSite (Prelude.Maybe Prelude.Text)
updateSite_notes :: Lens' UpdateSite (Maybe Text)
updateSite_notes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSite' {Maybe Text
notes :: Maybe Text
$sel:notes:UpdateSite' :: UpdateSite -> Maybe Text
notes} -> Maybe Text
notes) (\s :: UpdateSite
s@UpdateSite' {} Maybe Text
a -> UpdateSite
s {$sel:notes:UpdateSite' :: Maybe Text
notes = Maybe Text
a} :: UpdateSite)

-- | The ID or the Amazon Resource Name (ARN) of the site.
updateSite_siteId :: Lens.Lens' UpdateSite Prelude.Text
updateSite_siteId :: Lens' UpdateSite Text
updateSite_siteId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSite' {Text
siteId :: Text
$sel:siteId:UpdateSite' :: UpdateSite -> Text
siteId} -> Text
siteId) (\s :: UpdateSite
s@UpdateSite' {} Text
a -> UpdateSite
s {$sel:siteId:UpdateSite' :: Text
siteId = Text
a} :: UpdateSite)

instance Core.AWSRequest UpdateSite where
  type AWSResponse UpdateSite = UpdateSiteResponse
  request :: (Service -> Service) -> UpdateSite -> Request UpdateSite
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateSite
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateSite)))
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 Site -> Int -> UpdateSiteResponse
UpdateSiteResponse'
            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
"Site")
            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 UpdateSite where
  hashWithSalt :: Int -> UpdateSite -> Int
hashWithSalt Int
_salt UpdateSite' {Maybe Text
Text
siteId :: Text
notes :: Maybe Text
name :: Maybe Text
description :: Maybe Text
$sel:siteId:UpdateSite' :: UpdateSite -> Text
$sel:notes:UpdateSite' :: UpdateSite -> Maybe Text
$sel:name:UpdateSite' :: UpdateSite -> Maybe Text
$sel:description:UpdateSite' :: UpdateSite -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
notes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
siteId

instance Prelude.NFData UpdateSite where
  rnf :: UpdateSite -> ()
rnf UpdateSite' {Maybe Text
Text
siteId :: Text
notes :: Maybe Text
name :: Maybe Text
description :: Maybe Text
$sel:siteId:UpdateSite' :: UpdateSite -> Text
$sel:notes:UpdateSite' :: UpdateSite -> Maybe Text
$sel:name:UpdateSite' :: UpdateSite -> Maybe Text
$sel:description:UpdateSite' :: UpdateSite -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      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 Maybe Text
notes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
siteId

instance Data.ToHeaders UpdateSite where
  toHeaders :: UpdateSite -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateSite where
  toJSON :: UpdateSite -> Value
toJSON UpdateSite' {Maybe Text
Text
siteId :: Text
notes :: Maybe Text
name :: Maybe Text
description :: Maybe Text
$sel:siteId:UpdateSite' :: UpdateSite -> Text
$sel:notes:UpdateSite' :: UpdateSite -> Maybe Text
$sel:name:UpdateSite' :: UpdateSite -> Maybe Text
$sel:description:UpdateSite' :: UpdateSite -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Description" 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
description,
            (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,
            (Key
"Notes" 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
notes
          ]
      )

instance Data.ToPath UpdateSite where
  toPath :: UpdateSite -> ByteString
toPath UpdateSite' {Maybe Text
Text
siteId :: Text
notes :: Maybe Text
name :: Maybe Text
description :: Maybe Text
$sel:siteId:UpdateSite' :: UpdateSite -> Text
$sel:notes:UpdateSite' :: UpdateSite -> Maybe Text
$sel:name:UpdateSite' :: UpdateSite -> Maybe Text
$sel:description:UpdateSite' :: UpdateSite -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/sites/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
siteId]

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

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

-- |
-- Create a value of 'UpdateSiteResponse' 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:
--
-- 'site', 'updateSiteResponse_site' - Undocumented member.
--
-- 'httpStatus', 'updateSiteResponse_httpStatus' - The response's http status code.
newUpdateSiteResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateSiteResponse
newUpdateSiteResponse :: Int -> UpdateSiteResponse
newUpdateSiteResponse Int
pHttpStatus_ =
  UpdateSiteResponse'
    { $sel:site:UpdateSiteResponse' :: Maybe Site
site = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateSiteResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
updateSiteResponse_site :: Lens.Lens' UpdateSiteResponse (Prelude.Maybe Site)
updateSiteResponse_site :: Lens' UpdateSiteResponse (Maybe Site)
updateSiteResponse_site = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSiteResponse' {Maybe Site
site :: Maybe Site
$sel:site:UpdateSiteResponse' :: UpdateSiteResponse -> Maybe Site
site} -> Maybe Site
site) (\s :: UpdateSiteResponse
s@UpdateSiteResponse' {} Maybe Site
a -> UpdateSiteResponse
s {$sel:site:UpdateSiteResponse' :: Maybe Site
site = Maybe Site
a} :: UpdateSiteResponse)

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

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