{-# 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.IoTWireless.UpdatePartnerAccount
-- 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)
--
-- Updates properties of a partner account.
module Amazonka.IoTWireless.UpdatePartnerAccount
  ( -- * Creating a Request
    UpdatePartnerAccount (..),
    newUpdatePartnerAccount,

    -- * Request Lenses
    updatePartnerAccount_sidewalk,
    updatePartnerAccount_partnerAccountId,
    updatePartnerAccount_partnerType,

    -- * Destructuring the Response
    UpdatePartnerAccountResponse (..),
    newUpdatePartnerAccountResponse,

    -- * Response Lenses
    updatePartnerAccountResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTWireless.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:/ 'newUpdatePartnerAccount' smart constructor.
data UpdatePartnerAccount = UpdatePartnerAccount'
  { -- | The Sidewalk account credentials.
    UpdatePartnerAccount -> SidewalkUpdateAccount
sidewalk :: SidewalkUpdateAccount,
    -- | The ID of the partner account to update.
    UpdatePartnerAccount -> Text
partnerAccountId :: Prelude.Text,
    -- | The partner type.
    UpdatePartnerAccount -> PartnerType
partnerType :: PartnerType
  }
  deriving (UpdatePartnerAccount -> UpdatePartnerAccount -> Bool
(UpdatePartnerAccount -> UpdatePartnerAccount -> Bool)
-> (UpdatePartnerAccount -> UpdatePartnerAccount -> Bool)
-> Eq UpdatePartnerAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePartnerAccount -> UpdatePartnerAccount -> Bool
$c/= :: UpdatePartnerAccount -> UpdatePartnerAccount -> Bool
== :: UpdatePartnerAccount -> UpdatePartnerAccount -> Bool
$c== :: UpdatePartnerAccount -> UpdatePartnerAccount -> Bool
Prelude.Eq, Int -> UpdatePartnerAccount -> ShowS
[UpdatePartnerAccount] -> ShowS
UpdatePartnerAccount -> String
(Int -> UpdatePartnerAccount -> ShowS)
-> (UpdatePartnerAccount -> String)
-> ([UpdatePartnerAccount] -> ShowS)
-> Show UpdatePartnerAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePartnerAccount] -> ShowS
$cshowList :: [UpdatePartnerAccount] -> ShowS
show :: UpdatePartnerAccount -> String
$cshow :: UpdatePartnerAccount -> String
showsPrec :: Int -> UpdatePartnerAccount -> ShowS
$cshowsPrec :: Int -> UpdatePartnerAccount -> ShowS
Prelude.Show, (forall x. UpdatePartnerAccount -> Rep UpdatePartnerAccount x)
-> (forall x. Rep UpdatePartnerAccount x -> UpdatePartnerAccount)
-> Generic UpdatePartnerAccount
forall x. Rep UpdatePartnerAccount x -> UpdatePartnerAccount
forall x. UpdatePartnerAccount -> Rep UpdatePartnerAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdatePartnerAccount x -> UpdatePartnerAccount
$cfrom :: forall x. UpdatePartnerAccount -> Rep UpdatePartnerAccount x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePartnerAccount' 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:
--
-- 'sidewalk', 'updatePartnerAccount_sidewalk' - The Sidewalk account credentials.
--
-- 'partnerAccountId', 'updatePartnerAccount_partnerAccountId' - The ID of the partner account to update.
--
-- 'partnerType', 'updatePartnerAccount_partnerType' - The partner type.
newUpdatePartnerAccount ::
  -- | 'sidewalk'
  SidewalkUpdateAccount ->
  -- | 'partnerAccountId'
  Prelude.Text ->
  -- | 'partnerType'
  PartnerType ->
  UpdatePartnerAccount
newUpdatePartnerAccount :: SidewalkUpdateAccount
-> Text -> PartnerType -> UpdatePartnerAccount
newUpdatePartnerAccount
  SidewalkUpdateAccount
pSidewalk_
  Text
pPartnerAccountId_
  PartnerType
pPartnerType_ =
    UpdatePartnerAccount' :: SidewalkUpdateAccount
-> Text -> PartnerType -> UpdatePartnerAccount
UpdatePartnerAccount'
      { $sel:sidewalk:UpdatePartnerAccount' :: SidewalkUpdateAccount
sidewalk = SidewalkUpdateAccount
pSidewalk_,
        $sel:partnerAccountId:UpdatePartnerAccount' :: Text
partnerAccountId = Text
pPartnerAccountId_,
        $sel:partnerType:UpdatePartnerAccount' :: PartnerType
partnerType = PartnerType
pPartnerType_
      }

-- | The Sidewalk account credentials.
updatePartnerAccount_sidewalk :: Lens.Lens' UpdatePartnerAccount SidewalkUpdateAccount
updatePartnerAccount_sidewalk :: (SidewalkUpdateAccount -> f SidewalkUpdateAccount)
-> UpdatePartnerAccount -> f UpdatePartnerAccount
updatePartnerAccount_sidewalk = (UpdatePartnerAccount -> SidewalkUpdateAccount)
-> (UpdatePartnerAccount
    -> SidewalkUpdateAccount -> UpdatePartnerAccount)
-> Lens
     UpdatePartnerAccount
     UpdatePartnerAccount
     SidewalkUpdateAccount
     SidewalkUpdateAccount
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePartnerAccount' {SidewalkUpdateAccount
sidewalk :: SidewalkUpdateAccount
$sel:sidewalk:UpdatePartnerAccount' :: UpdatePartnerAccount -> SidewalkUpdateAccount
sidewalk} -> SidewalkUpdateAccount
sidewalk) (\s :: UpdatePartnerAccount
s@UpdatePartnerAccount' {} SidewalkUpdateAccount
a -> UpdatePartnerAccount
s {$sel:sidewalk:UpdatePartnerAccount' :: SidewalkUpdateAccount
sidewalk = SidewalkUpdateAccount
a} :: UpdatePartnerAccount)

-- | The ID of the partner account to update.
updatePartnerAccount_partnerAccountId :: Lens.Lens' UpdatePartnerAccount Prelude.Text
updatePartnerAccount_partnerAccountId :: (Text -> f Text) -> UpdatePartnerAccount -> f UpdatePartnerAccount
updatePartnerAccount_partnerAccountId = (UpdatePartnerAccount -> Text)
-> (UpdatePartnerAccount -> Text -> UpdatePartnerAccount)
-> Lens UpdatePartnerAccount UpdatePartnerAccount Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePartnerAccount' {Text
partnerAccountId :: Text
$sel:partnerAccountId:UpdatePartnerAccount' :: UpdatePartnerAccount -> Text
partnerAccountId} -> Text
partnerAccountId) (\s :: UpdatePartnerAccount
s@UpdatePartnerAccount' {} Text
a -> UpdatePartnerAccount
s {$sel:partnerAccountId:UpdatePartnerAccount' :: Text
partnerAccountId = Text
a} :: UpdatePartnerAccount)

-- | The partner type.
updatePartnerAccount_partnerType :: Lens.Lens' UpdatePartnerAccount PartnerType
updatePartnerAccount_partnerType :: (PartnerType -> f PartnerType)
-> UpdatePartnerAccount -> f UpdatePartnerAccount
updatePartnerAccount_partnerType = (UpdatePartnerAccount -> PartnerType)
-> (UpdatePartnerAccount -> PartnerType -> UpdatePartnerAccount)
-> Lens
     UpdatePartnerAccount UpdatePartnerAccount PartnerType PartnerType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePartnerAccount' {PartnerType
partnerType :: PartnerType
$sel:partnerType:UpdatePartnerAccount' :: UpdatePartnerAccount -> PartnerType
partnerType} -> PartnerType
partnerType) (\s :: UpdatePartnerAccount
s@UpdatePartnerAccount' {} PartnerType
a -> UpdatePartnerAccount
s {$sel:partnerType:UpdatePartnerAccount' :: PartnerType
partnerType = PartnerType
a} :: UpdatePartnerAccount)

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

instance Prelude.NFData UpdatePartnerAccount

instance Core.ToHeaders UpdatePartnerAccount where
  toHeaders :: UpdatePartnerAccount -> ResponseHeaders
toHeaders = ResponseHeaders -> UpdatePartnerAccount -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON UpdatePartnerAccount where
  toJSON :: UpdatePartnerAccount -> Value
toJSON UpdatePartnerAccount' {Text
PartnerType
SidewalkUpdateAccount
partnerType :: PartnerType
partnerAccountId :: Text
sidewalk :: SidewalkUpdateAccount
$sel:partnerType:UpdatePartnerAccount' :: UpdatePartnerAccount -> PartnerType
$sel:partnerAccountId:UpdatePartnerAccount' :: UpdatePartnerAccount -> Text
$sel:sidewalk:UpdatePartnerAccount' :: UpdatePartnerAccount -> SidewalkUpdateAccount
..} =
    [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
"Sidewalk" Text -> SidewalkUpdateAccount -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SidewalkUpdateAccount
sidewalk)]
      )

instance Core.ToPath UpdatePartnerAccount where
  toPath :: UpdatePartnerAccount -> ByteString
toPath UpdatePartnerAccount' {Text
PartnerType
SidewalkUpdateAccount
partnerType :: PartnerType
partnerAccountId :: Text
sidewalk :: SidewalkUpdateAccount
$sel:partnerType:UpdatePartnerAccount' :: UpdatePartnerAccount -> PartnerType
$sel:partnerAccountId:UpdatePartnerAccount' :: UpdatePartnerAccount -> Text
$sel:sidewalk:UpdatePartnerAccount' :: UpdatePartnerAccount -> SidewalkUpdateAccount
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/partner-accounts/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
partnerAccountId]

instance Core.ToQuery UpdatePartnerAccount where
  toQuery :: UpdatePartnerAccount -> QueryString
toQuery UpdatePartnerAccount' {Text
PartnerType
SidewalkUpdateAccount
partnerType :: PartnerType
partnerAccountId :: Text
sidewalk :: SidewalkUpdateAccount
$sel:partnerType:UpdatePartnerAccount' :: UpdatePartnerAccount -> PartnerType
$sel:partnerAccountId:UpdatePartnerAccount' :: UpdatePartnerAccount -> Text
$sel:sidewalk:UpdatePartnerAccount' :: UpdatePartnerAccount -> SidewalkUpdateAccount
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"partnerType" ByteString -> PartnerType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: PartnerType
partnerType]

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

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

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

instance Prelude.NFData UpdatePartnerAccountResponse