{-# 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.GetPartnerAccount
-- 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)
--
-- Gets information about a partner account. If @PartnerAccountId@ and
-- @PartnerType@ are @null@, returns all partner accounts.
module Amazonka.IoTWireless.GetPartnerAccount
  ( -- * Creating a Request
    GetPartnerAccount (..),
    newGetPartnerAccount,

    -- * Request Lenses
    getPartnerAccount_partnerAccountId,
    getPartnerAccount_partnerType,

    -- * Destructuring the Response
    GetPartnerAccountResponse (..),
    newGetPartnerAccountResponse,

    -- * Response Lenses
    getPartnerAccountResponse_sidewalk,
    getPartnerAccountResponse_accountLinked,
    getPartnerAccountResponse_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:/ 'newGetPartnerAccount' smart constructor.
data GetPartnerAccount = GetPartnerAccount'
  { -- | The partner account ID to disassociate from the AWS account.
    GetPartnerAccount -> Text
partnerAccountId :: Prelude.Text,
    -- | The partner type.
    GetPartnerAccount -> PartnerType
partnerType :: PartnerType
  }
  deriving (GetPartnerAccount -> GetPartnerAccount -> Bool
(GetPartnerAccount -> GetPartnerAccount -> Bool)
-> (GetPartnerAccount -> GetPartnerAccount -> Bool)
-> Eq GetPartnerAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPartnerAccount -> GetPartnerAccount -> Bool
$c/= :: GetPartnerAccount -> GetPartnerAccount -> Bool
== :: GetPartnerAccount -> GetPartnerAccount -> Bool
$c== :: GetPartnerAccount -> GetPartnerAccount -> Bool
Prelude.Eq, ReadPrec [GetPartnerAccount]
ReadPrec GetPartnerAccount
Int -> ReadS GetPartnerAccount
ReadS [GetPartnerAccount]
(Int -> ReadS GetPartnerAccount)
-> ReadS [GetPartnerAccount]
-> ReadPrec GetPartnerAccount
-> ReadPrec [GetPartnerAccount]
-> Read GetPartnerAccount
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPartnerAccount]
$creadListPrec :: ReadPrec [GetPartnerAccount]
readPrec :: ReadPrec GetPartnerAccount
$creadPrec :: ReadPrec GetPartnerAccount
readList :: ReadS [GetPartnerAccount]
$creadList :: ReadS [GetPartnerAccount]
readsPrec :: Int -> ReadS GetPartnerAccount
$creadsPrec :: Int -> ReadS GetPartnerAccount
Prelude.Read, Int -> GetPartnerAccount -> ShowS
[GetPartnerAccount] -> ShowS
GetPartnerAccount -> String
(Int -> GetPartnerAccount -> ShowS)
-> (GetPartnerAccount -> String)
-> ([GetPartnerAccount] -> ShowS)
-> Show GetPartnerAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPartnerAccount] -> ShowS
$cshowList :: [GetPartnerAccount] -> ShowS
show :: GetPartnerAccount -> String
$cshow :: GetPartnerAccount -> String
showsPrec :: Int -> GetPartnerAccount -> ShowS
$cshowsPrec :: Int -> GetPartnerAccount -> ShowS
Prelude.Show, (forall x. GetPartnerAccount -> Rep GetPartnerAccount x)
-> (forall x. Rep GetPartnerAccount x -> GetPartnerAccount)
-> Generic GetPartnerAccount
forall x. Rep GetPartnerAccount x -> GetPartnerAccount
forall x. GetPartnerAccount -> Rep GetPartnerAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPartnerAccount x -> GetPartnerAccount
$cfrom :: forall x. GetPartnerAccount -> Rep GetPartnerAccount x
Prelude.Generic)

-- |
-- Create a value of 'GetPartnerAccount' 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:
--
-- 'partnerAccountId', 'getPartnerAccount_partnerAccountId' - The partner account ID to disassociate from the AWS account.
--
-- 'partnerType', 'getPartnerAccount_partnerType' - The partner type.
newGetPartnerAccount ::
  -- | 'partnerAccountId'
  Prelude.Text ->
  -- | 'partnerType'
  PartnerType ->
  GetPartnerAccount
newGetPartnerAccount :: Text -> PartnerType -> GetPartnerAccount
newGetPartnerAccount Text
pPartnerAccountId_ PartnerType
pPartnerType_ =
  GetPartnerAccount' :: Text -> PartnerType -> GetPartnerAccount
GetPartnerAccount'
    { $sel:partnerAccountId:GetPartnerAccount' :: Text
partnerAccountId =
        Text
pPartnerAccountId_,
      $sel:partnerType:GetPartnerAccount' :: PartnerType
partnerType = PartnerType
pPartnerType_
    }

-- | The partner account ID to disassociate from the AWS account.
getPartnerAccount_partnerAccountId :: Lens.Lens' GetPartnerAccount Prelude.Text
getPartnerAccount_partnerAccountId :: (Text -> f Text) -> GetPartnerAccount -> f GetPartnerAccount
getPartnerAccount_partnerAccountId = (GetPartnerAccount -> Text)
-> (GetPartnerAccount -> Text -> GetPartnerAccount)
-> Lens GetPartnerAccount GetPartnerAccount Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartnerAccount' {Text
partnerAccountId :: Text
$sel:partnerAccountId:GetPartnerAccount' :: GetPartnerAccount -> Text
partnerAccountId} -> Text
partnerAccountId) (\s :: GetPartnerAccount
s@GetPartnerAccount' {} Text
a -> GetPartnerAccount
s {$sel:partnerAccountId:GetPartnerAccount' :: Text
partnerAccountId = Text
a} :: GetPartnerAccount)

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

instance Core.AWSRequest GetPartnerAccount where
  type
    AWSResponse GetPartnerAccount =
      GetPartnerAccountResponse
  request :: GetPartnerAccount -> Request GetPartnerAccount
request = Service -> GetPartnerAccount -> Request GetPartnerAccount
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetPartnerAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetPartnerAccount)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetPartnerAccount))
-> Logger
-> Service
-> Proxy GetPartnerAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetPartnerAccount)))
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 SidewalkAccountInfoWithFingerprint
-> Maybe Bool -> Int -> GetPartnerAccountResponse
GetPartnerAccountResponse'
            (Maybe SidewalkAccountInfoWithFingerprint
 -> Maybe Bool -> Int -> GetPartnerAccountResponse)
-> Either String (Maybe SidewalkAccountInfoWithFingerprint)
-> Either String (Maybe Bool -> Int -> GetPartnerAccountResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Either String (Maybe SidewalkAccountInfoWithFingerprint)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Sidewalk")
            Either String (Maybe Bool -> Int -> GetPartnerAccountResponse)
-> Either String (Maybe Bool)
-> Either String (Int -> GetPartnerAccountResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AccountLinked")
            Either String (Int -> GetPartnerAccountResponse)
-> Either String Int -> Either String GetPartnerAccountResponse
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 GetPartnerAccount

instance Prelude.NFData GetPartnerAccount

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

instance Core.ToPath GetPartnerAccount where
  toPath :: GetPartnerAccount -> ByteString
toPath GetPartnerAccount' {Text
PartnerType
partnerType :: PartnerType
partnerAccountId :: Text
$sel:partnerType:GetPartnerAccount' :: GetPartnerAccount -> PartnerType
$sel:partnerAccountId:GetPartnerAccount' :: GetPartnerAccount -> Text
..} =
    [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 GetPartnerAccount where
  toQuery :: GetPartnerAccount -> QueryString
toQuery GetPartnerAccount' {Text
PartnerType
partnerType :: PartnerType
partnerAccountId :: Text
$sel:partnerType:GetPartnerAccount' :: GetPartnerAccount -> PartnerType
$sel:partnerAccountId:GetPartnerAccount' :: GetPartnerAccount -> Text
..} =
    [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:/ 'newGetPartnerAccountResponse' smart constructor.
data GetPartnerAccountResponse = GetPartnerAccountResponse'
  { -- | The Sidewalk account credentials.
    GetPartnerAccountResponse
-> Maybe SidewalkAccountInfoWithFingerprint
sidewalk :: Prelude.Maybe SidewalkAccountInfoWithFingerprint,
    -- | Whether the partner account is linked to the AWS account.
    GetPartnerAccountResponse -> Maybe Bool
accountLinked :: Prelude.Maybe Prelude.Bool,
    -- | The response's http status code.
    GetPartnerAccountResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetPartnerAccountResponse -> GetPartnerAccountResponse -> Bool
(GetPartnerAccountResponse -> GetPartnerAccountResponse -> Bool)
-> (GetPartnerAccountResponse -> GetPartnerAccountResponse -> Bool)
-> Eq GetPartnerAccountResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPartnerAccountResponse -> GetPartnerAccountResponse -> Bool
$c/= :: GetPartnerAccountResponse -> GetPartnerAccountResponse -> Bool
== :: GetPartnerAccountResponse -> GetPartnerAccountResponse -> Bool
$c== :: GetPartnerAccountResponse -> GetPartnerAccountResponse -> Bool
Prelude.Eq, Int -> GetPartnerAccountResponse -> ShowS
[GetPartnerAccountResponse] -> ShowS
GetPartnerAccountResponse -> String
(Int -> GetPartnerAccountResponse -> ShowS)
-> (GetPartnerAccountResponse -> String)
-> ([GetPartnerAccountResponse] -> ShowS)
-> Show GetPartnerAccountResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPartnerAccountResponse] -> ShowS
$cshowList :: [GetPartnerAccountResponse] -> ShowS
show :: GetPartnerAccountResponse -> String
$cshow :: GetPartnerAccountResponse -> String
showsPrec :: Int -> GetPartnerAccountResponse -> ShowS
$cshowsPrec :: Int -> GetPartnerAccountResponse -> ShowS
Prelude.Show, (forall x.
 GetPartnerAccountResponse -> Rep GetPartnerAccountResponse x)
-> (forall x.
    Rep GetPartnerAccountResponse x -> GetPartnerAccountResponse)
-> Generic GetPartnerAccountResponse
forall x.
Rep GetPartnerAccountResponse x -> GetPartnerAccountResponse
forall x.
GetPartnerAccountResponse -> Rep GetPartnerAccountResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetPartnerAccountResponse x -> GetPartnerAccountResponse
$cfrom :: forall x.
GetPartnerAccountResponse -> Rep GetPartnerAccountResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetPartnerAccountResponse' 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', 'getPartnerAccountResponse_sidewalk' - The Sidewalk account credentials.
--
-- 'accountLinked', 'getPartnerAccountResponse_accountLinked' - Whether the partner account is linked to the AWS account.
--
-- 'httpStatus', 'getPartnerAccountResponse_httpStatus' - The response's http status code.
newGetPartnerAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetPartnerAccountResponse
newGetPartnerAccountResponse :: Int -> GetPartnerAccountResponse
newGetPartnerAccountResponse Int
pHttpStatus_ =
  GetPartnerAccountResponse' :: Maybe SidewalkAccountInfoWithFingerprint
-> Maybe Bool -> Int -> GetPartnerAccountResponse
GetPartnerAccountResponse'
    { $sel:sidewalk:GetPartnerAccountResponse' :: Maybe SidewalkAccountInfoWithFingerprint
sidewalk =
        Maybe SidewalkAccountInfoWithFingerprint
forall a. Maybe a
Prelude.Nothing,
      $sel:accountLinked:GetPartnerAccountResponse' :: Maybe Bool
accountLinked = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetPartnerAccountResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Sidewalk account credentials.
getPartnerAccountResponse_sidewalk :: Lens.Lens' GetPartnerAccountResponse (Prelude.Maybe SidewalkAccountInfoWithFingerprint)
getPartnerAccountResponse_sidewalk :: (Maybe SidewalkAccountInfoWithFingerprint
 -> f (Maybe SidewalkAccountInfoWithFingerprint))
-> GetPartnerAccountResponse -> f GetPartnerAccountResponse
getPartnerAccountResponse_sidewalk = (GetPartnerAccountResponse
 -> Maybe SidewalkAccountInfoWithFingerprint)
-> (GetPartnerAccountResponse
    -> Maybe SidewalkAccountInfoWithFingerprint
    -> GetPartnerAccountResponse)
-> Lens
     GetPartnerAccountResponse
     GetPartnerAccountResponse
     (Maybe SidewalkAccountInfoWithFingerprint)
     (Maybe SidewalkAccountInfoWithFingerprint)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartnerAccountResponse' {Maybe SidewalkAccountInfoWithFingerprint
sidewalk :: Maybe SidewalkAccountInfoWithFingerprint
$sel:sidewalk:GetPartnerAccountResponse' :: GetPartnerAccountResponse
-> Maybe SidewalkAccountInfoWithFingerprint
sidewalk} -> Maybe SidewalkAccountInfoWithFingerprint
sidewalk) (\s :: GetPartnerAccountResponse
s@GetPartnerAccountResponse' {} Maybe SidewalkAccountInfoWithFingerprint
a -> GetPartnerAccountResponse
s {$sel:sidewalk:GetPartnerAccountResponse' :: Maybe SidewalkAccountInfoWithFingerprint
sidewalk = Maybe SidewalkAccountInfoWithFingerprint
a} :: GetPartnerAccountResponse)

-- | Whether the partner account is linked to the AWS account.
getPartnerAccountResponse_accountLinked :: Lens.Lens' GetPartnerAccountResponse (Prelude.Maybe Prelude.Bool)
getPartnerAccountResponse_accountLinked :: (Maybe Bool -> f (Maybe Bool))
-> GetPartnerAccountResponse -> f GetPartnerAccountResponse
getPartnerAccountResponse_accountLinked = (GetPartnerAccountResponse -> Maybe Bool)
-> (GetPartnerAccountResponse
    -> Maybe Bool -> GetPartnerAccountResponse)
-> Lens
     GetPartnerAccountResponse
     GetPartnerAccountResponse
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPartnerAccountResponse' {Maybe Bool
accountLinked :: Maybe Bool
$sel:accountLinked:GetPartnerAccountResponse' :: GetPartnerAccountResponse -> Maybe Bool
accountLinked} -> Maybe Bool
accountLinked) (\s :: GetPartnerAccountResponse
s@GetPartnerAccountResponse' {} Maybe Bool
a -> GetPartnerAccountResponse
s {$sel:accountLinked:GetPartnerAccountResponse' :: Maybe Bool
accountLinked = Maybe Bool
a} :: GetPartnerAccountResponse)

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

instance Prelude.NFData GetPartnerAccountResponse