{-# 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.GetServiceProfile
-- 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 service profile.
module Amazonka.IoTWireless.GetServiceProfile
  ( -- * Creating a Request
    GetServiceProfile (..),
    newGetServiceProfile,

    -- * Request Lenses
    getServiceProfile_id,

    -- * Destructuring the Response
    GetServiceProfileResponse (..),
    newGetServiceProfileResponse,

    -- * Response Lenses
    getServiceProfileResponse_arn,
    getServiceProfileResponse_loRaWAN,
    getServiceProfileResponse_name,
    getServiceProfileResponse_id,
    getServiceProfileResponse_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:/ 'newGetServiceProfile' smart constructor.
data GetServiceProfile = GetServiceProfile'
  { -- | The ID of the resource to get.
    GetServiceProfile -> Text
id :: Prelude.Text
  }
  deriving (GetServiceProfile -> GetServiceProfile -> Bool
(GetServiceProfile -> GetServiceProfile -> Bool)
-> (GetServiceProfile -> GetServiceProfile -> Bool)
-> Eq GetServiceProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetServiceProfile -> GetServiceProfile -> Bool
$c/= :: GetServiceProfile -> GetServiceProfile -> Bool
== :: GetServiceProfile -> GetServiceProfile -> Bool
$c== :: GetServiceProfile -> GetServiceProfile -> Bool
Prelude.Eq, ReadPrec [GetServiceProfile]
ReadPrec GetServiceProfile
Int -> ReadS GetServiceProfile
ReadS [GetServiceProfile]
(Int -> ReadS GetServiceProfile)
-> ReadS [GetServiceProfile]
-> ReadPrec GetServiceProfile
-> ReadPrec [GetServiceProfile]
-> Read GetServiceProfile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetServiceProfile]
$creadListPrec :: ReadPrec [GetServiceProfile]
readPrec :: ReadPrec GetServiceProfile
$creadPrec :: ReadPrec GetServiceProfile
readList :: ReadS [GetServiceProfile]
$creadList :: ReadS [GetServiceProfile]
readsPrec :: Int -> ReadS GetServiceProfile
$creadsPrec :: Int -> ReadS GetServiceProfile
Prelude.Read, Int -> GetServiceProfile -> ShowS
[GetServiceProfile] -> ShowS
GetServiceProfile -> String
(Int -> GetServiceProfile -> ShowS)
-> (GetServiceProfile -> String)
-> ([GetServiceProfile] -> ShowS)
-> Show GetServiceProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetServiceProfile] -> ShowS
$cshowList :: [GetServiceProfile] -> ShowS
show :: GetServiceProfile -> String
$cshow :: GetServiceProfile -> String
showsPrec :: Int -> GetServiceProfile -> ShowS
$cshowsPrec :: Int -> GetServiceProfile -> ShowS
Prelude.Show, (forall x. GetServiceProfile -> Rep GetServiceProfile x)
-> (forall x. Rep GetServiceProfile x -> GetServiceProfile)
-> Generic GetServiceProfile
forall x. Rep GetServiceProfile x -> GetServiceProfile
forall x. GetServiceProfile -> Rep GetServiceProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetServiceProfile x -> GetServiceProfile
$cfrom :: forall x. GetServiceProfile -> Rep GetServiceProfile x
Prelude.Generic)

-- |
-- Create a value of 'GetServiceProfile' 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:
--
-- 'id', 'getServiceProfile_id' - The ID of the resource to get.
newGetServiceProfile ::
  -- | 'id'
  Prelude.Text ->
  GetServiceProfile
newGetServiceProfile :: Text -> GetServiceProfile
newGetServiceProfile Text
pId_ =
  GetServiceProfile' :: Text -> GetServiceProfile
GetServiceProfile' {$sel:id:GetServiceProfile' :: Text
id = Text
pId_}

-- | The ID of the resource to get.
getServiceProfile_id :: Lens.Lens' GetServiceProfile Prelude.Text
getServiceProfile_id :: (Text -> f Text) -> GetServiceProfile -> f GetServiceProfile
getServiceProfile_id = (GetServiceProfile -> Text)
-> (GetServiceProfile -> Text -> GetServiceProfile)
-> Lens GetServiceProfile GetServiceProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceProfile' {Text
id :: Text
$sel:id:GetServiceProfile' :: GetServiceProfile -> Text
id} -> Text
id) (\s :: GetServiceProfile
s@GetServiceProfile' {} Text
a -> GetServiceProfile
s {$sel:id:GetServiceProfile' :: Text
id = Text
a} :: GetServiceProfile)

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

instance Prelude.NFData GetServiceProfile

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

instance Core.ToPath GetServiceProfile where
  toPath :: GetServiceProfile -> ByteString
toPath GetServiceProfile' {Text
id :: Text
$sel:id:GetServiceProfile' :: GetServiceProfile -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/service-profiles/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id]

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

-- | /See:/ 'newGetServiceProfileResponse' smart constructor.
data GetServiceProfileResponse = GetServiceProfileResponse'
  { -- | The Amazon Resource Name of the resource.
    GetServiceProfileResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | Information about the service profile.
    GetServiceProfileResponse -> Maybe LoRaWANGetServiceProfileInfo
loRaWAN :: Prelude.Maybe LoRaWANGetServiceProfileInfo,
    -- | The name of the resource.
    GetServiceProfileResponse -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ID of the service profile.
    GetServiceProfileResponse -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetServiceProfileResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetServiceProfileResponse -> GetServiceProfileResponse -> Bool
(GetServiceProfileResponse -> GetServiceProfileResponse -> Bool)
-> (GetServiceProfileResponse -> GetServiceProfileResponse -> Bool)
-> Eq GetServiceProfileResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetServiceProfileResponse -> GetServiceProfileResponse -> Bool
$c/= :: GetServiceProfileResponse -> GetServiceProfileResponse -> Bool
== :: GetServiceProfileResponse -> GetServiceProfileResponse -> Bool
$c== :: GetServiceProfileResponse -> GetServiceProfileResponse -> Bool
Prelude.Eq, ReadPrec [GetServiceProfileResponse]
ReadPrec GetServiceProfileResponse
Int -> ReadS GetServiceProfileResponse
ReadS [GetServiceProfileResponse]
(Int -> ReadS GetServiceProfileResponse)
-> ReadS [GetServiceProfileResponse]
-> ReadPrec GetServiceProfileResponse
-> ReadPrec [GetServiceProfileResponse]
-> Read GetServiceProfileResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetServiceProfileResponse]
$creadListPrec :: ReadPrec [GetServiceProfileResponse]
readPrec :: ReadPrec GetServiceProfileResponse
$creadPrec :: ReadPrec GetServiceProfileResponse
readList :: ReadS [GetServiceProfileResponse]
$creadList :: ReadS [GetServiceProfileResponse]
readsPrec :: Int -> ReadS GetServiceProfileResponse
$creadsPrec :: Int -> ReadS GetServiceProfileResponse
Prelude.Read, Int -> GetServiceProfileResponse -> ShowS
[GetServiceProfileResponse] -> ShowS
GetServiceProfileResponse -> String
(Int -> GetServiceProfileResponse -> ShowS)
-> (GetServiceProfileResponse -> String)
-> ([GetServiceProfileResponse] -> ShowS)
-> Show GetServiceProfileResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetServiceProfileResponse] -> ShowS
$cshowList :: [GetServiceProfileResponse] -> ShowS
show :: GetServiceProfileResponse -> String
$cshow :: GetServiceProfileResponse -> String
showsPrec :: Int -> GetServiceProfileResponse -> ShowS
$cshowsPrec :: Int -> GetServiceProfileResponse -> ShowS
Prelude.Show, (forall x.
 GetServiceProfileResponse -> Rep GetServiceProfileResponse x)
-> (forall x.
    Rep GetServiceProfileResponse x -> GetServiceProfileResponse)
-> Generic GetServiceProfileResponse
forall x.
Rep GetServiceProfileResponse x -> GetServiceProfileResponse
forall x.
GetServiceProfileResponse -> Rep GetServiceProfileResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetServiceProfileResponse x -> GetServiceProfileResponse
$cfrom :: forall x.
GetServiceProfileResponse -> Rep GetServiceProfileResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetServiceProfileResponse' 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:
--
-- 'arn', 'getServiceProfileResponse_arn' - The Amazon Resource Name of the resource.
--
-- 'loRaWAN', 'getServiceProfileResponse_loRaWAN' - Information about the service profile.
--
-- 'name', 'getServiceProfileResponse_name' - The name of the resource.
--
-- 'id', 'getServiceProfileResponse_id' - The ID of the service profile.
--
-- 'httpStatus', 'getServiceProfileResponse_httpStatus' - The response's http status code.
newGetServiceProfileResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetServiceProfileResponse
newGetServiceProfileResponse :: Int -> GetServiceProfileResponse
newGetServiceProfileResponse Int
pHttpStatus_ =
  GetServiceProfileResponse' :: Maybe Text
-> Maybe LoRaWANGetServiceProfileInfo
-> Maybe Text
-> Maybe Text
-> Int
-> GetServiceProfileResponse
GetServiceProfileResponse'
    { $sel:arn:GetServiceProfileResponse' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:loRaWAN:GetServiceProfileResponse' :: Maybe LoRaWANGetServiceProfileInfo
loRaWAN = Maybe LoRaWANGetServiceProfileInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetServiceProfileResponse' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:GetServiceProfileResponse' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetServiceProfileResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name of the resource.
getServiceProfileResponse_arn :: Lens.Lens' GetServiceProfileResponse (Prelude.Maybe Prelude.Text)
getServiceProfileResponse_arn :: (Maybe Text -> f (Maybe Text))
-> GetServiceProfileResponse -> f GetServiceProfileResponse
getServiceProfileResponse_arn = (GetServiceProfileResponse -> Maybe Text)
-> (GetServiceProfileResponse
    -> Maybe Text -> GetServiceProfileResponse)
-> Lens
     GetServiceProfileResponse
     GetServiceProfileResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceProfileResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:GetServiceProfileResponse' :: GetServiceProfileResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: GetServiceProfileResponse
s@GetServiceProfileResponse' {} Maybe Text
a -> GetServiceProfileResponse
s {$sel:arn:GetServiceProfileResponse' :: Maybe Text
arn = Maybe Text
a} :: GetServiceProfileResponse)

-- | Information about the service profile.
getServiceProfileResponse_loRaWAN :: Lens.Lens' GetServiceProfileResponse (Prelude.Maybe LoRaWANGetServiceProfileInfo)
getServiceProfileResponse_loRaWAN :: (Maybe LoRaWANGetServiceProfileInfo
 -> f (Maybe LoRaWANGetServiceProfileInfo))
-> GetServiceProfileResponse -> f GetServiceProfileResponse
getServiceProfileResponse_loRaWAN = (GetServiceProfileResponse -> Maybe LoRaWANGetServiceProfileInfo)
-> (GetServiceProfileResponse
    -> Maybe LoRaWANGetServiceProfileInfo -> GetServiceProfileResponse)
-> Lens
     GetServiceProfileResponse
     GetServiceProfileResponse
     (Maybe LoRaWANGetServiceProfileInfo)
     (Maybe LoRaWANGetServiceProfileInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceProfileResponse' {Maybe LoRaWANGetServiceProfileInfo
loRaWAN :: Maybe LoRaWANGetServiceProfileInfo
$sel:loRaWAN:GetServiceProfileResponse' :: GetServiceProfileResponse -> Maybe LoRaWANGetServiceProfileInfo
loRaWAN} -> Maybe LoRaWANGetServiceProfileInfo
loRaWAN) (\s :: GetServiceProfileResponse
s@GetServiceProfileResponse' {} Maybe LoRaWANGetServiceProfileInfo
a -> GetServiceProfileResponse
s {$sel:loRaWAN:GetServiceProfileResponse' :: Maybe LoRaWANGetServiceProfileInfo
loRaWAN = Maybe LoRaWANGetServiceProfileInfo
a} :: GetServiceProfileResponse)

-- | The name of the resource.
getServiceProfileResponse_name :: Lens.Lens' GetServiceProfileResponse (Prelude.Maybe Prelude.Text)
getServiceProfileResponse_name :: (Maybe Text -> f (Maybe Text))
-> GetServiceProfileResponse -> f GetServiceProfileResponse
getServiceProfileResponse_name = (GetServiceProfileResponse -> Maybe Text)
-> (GetServiceProfileResponse
    -> Maybe Text -> GetServiceProfileResponse)
-> Lens
     GetServiceProfileResponse
     GetServiceProfileResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceProfileResponse' {Maybe Text
name :: Maybe Text
$sel:name:GetServiceProfileResponse' :: GetServiceProfileResponse -> Maybe Text
name} -> Maybe Text
name) (\s :: GetServiceProfileResponse
s@GetServiceProfileResponse' {} Maybe Text
a -> GetServiceProfileResponse
s {$sel:name:GetServiceProfileResponse' :: Maybe Text
name = Maybe Text
a} :: GetServiceProfileResponse)

-- | The ID of the service profile.
getServiceProfileResponse_id :: Lens.Lens' GetServiceProfileResponse (Prelude.Maybe Prelude.Text)
getServiceProfileResponse_id :: (Maybe Text -> f (Maybe Text))
-> GetServiceProfileResponse -> f GetServiceProfileResponse
getServiceProfileResponse_id = (GetServiceProfileResponse -> Maybe Text)
-> (GetServiceProfileResponse
    -> Maybe Text -> GetServiceProfileResponse)
-> Lens
     GetServiceProfileResponse
     GetServiceProfileResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceProfileResponse' {Maybe Text
id :: Maybe Text
$sel:id:GetServiceProfileResponse' :: GetServiceProfileResponse -> Maybe Text
id} -> Maybe Text
id) (\s :: GetServiceProfileResponse
s@GetServiceProfileResponse' {} Maybe Text
a -> GetServiceProfileResponse
s {$sel:id:GetServiceProfileResponse' :: Maybe Text
id = Maybe Text
a} :: GetServiceProfileResponse)

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

instance Prelude.NFData GetServiceProfileResponse