{-# 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.SSOOIDC.StartDeviceAuthorization
-- 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)
--
-- Initiates device authorization by requesting a pair of verification
-- codes from the authorization service.
module Amazonka.SSOOIDC.StartDeviceAuthorization
  ( -- * Creating a Request
    StartDeviceAuthorization (..),
    newStartDeviceAuthorization,

    -- * Request Lenses
    startDeviceAuthorization_clientId,
    startDeviceAuthorization_clientSecret,
    startDeviceAuthorization_startUrl,

    -- * Destructuring the Response
    StartDeviceAuthorizationResponse (..),
    newStartDeviceAuthorizationResponse,

    -- * Response Lenses
    startDeviceAuthorizationResponse_userCode,
    startDeviceAuthorizationResponse_interval,
    startDeviceAuthorizationResponse_expiresIn,
    startDeviceAuthorizationResponse_verificationUri,
    startDeviceAuthorizationResponse_deviceCode,
    startDeviceAuthorizationResponse_verificationUriComplete,
    startDeviceAuthorizationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SSOOIDC.Types

-- | /See:/ 'newStartDeviceAuthorization' smart constructor.
data StartDeviceAuthorization = StartDeviceAuthorization'
  { -- | The unique identifier string for the client that is registered with AWS
    -- SSO. This value should come from the persisted result of the
    -- RegisterClient API operation.
    StartDeviceAuthorization -> Text
clientId :: Prelude.Text,
    -- | A secret string that is generated for the client. This value should come
    -- from the persisted result of the RegisterClient API operation.
    StartDeviceAuthorization -> Text
clientSecret :: Prelude.Text,
    -- | The URL for the AWS SSO user portal. For more information, see
    -- <https://docs.aws.amazon.com/singlesignon/latest/userguide/using-the-portal.html Using the User Portal>
    -- in the /AWS Single Sign-On User Guide/.
    StartDeviceAuthorization -> Text
startUrl :: Prelude.Text
  }
  deriving (StartDeviceAuthorization -> StartDeviceAuthorization -> Bool
(StartDeviceAuthorization -> StartDeviceAuthorization -> Bool)
-> (StartDeviceAuthorization -> StartDeviceAuthorization -> Bool)
-> Eq StartDeviceAuthorization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartDeviceAuthorization -> StartDeviceAuthorization -> Bool
$c/= :: StartDeviceAuthorization -> StartDeviceAuthorization -> Bool
== :: StartDeviceAuthorization -> StartDeviceAuthorization -> Bool
$c== :: StartDeviceAuthorization -> StartDeviceAuthorization -> Bool
Prelude.Eq, ReadPrec [StartDeviceAuthorization]
ReadPrec StartDeviceAuthorization
Int -> ReadS StartDeviceAuthorization
ReadS [StartDeviceAuthorization]
(Int -> ReadS StartDeviceAuthorization)
-> ReadS [StartDeviceAuthorization]
-> ReadPrec StartDeviceAuthorization
-> ReadPrec [StartDeviceAuthorization]
-> Read StartDeviceAuthorization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartDeviceAuthorization]
$creadListPrec :: ReadPrec [StartDeviceAuthorization]
readPrec :: ReadPrec StartDeviceAuthorization
$creadPrec :: ReadPrec StartDeviceAuthorization
readList :: ReadS [StartDeviceAuthorization]
$creadList :: ReadS [StartDeviceAuthorization]
readsPrec :: Int -> ReadS StartDeviceAuthorization
$creadsPrec :: Int -> ReadS StartDeviceAuthorization
Prelude.Read, Int -> StartDeviceAuthorization -> ShowS
[StartDeviceAuthorization] -> ShowS
StartDeviceAuthorization -> String
(Int -> StartDeviceAuthorization -> ShowS)
-> (StartDeviceAuthorization -> String)
-> ([StartDeviceAuthorization] -> ShowS)
-> Show StartDeviceAuthorization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartDeviceAuthorization] -> ShowS
$cshowList :: [StartDeviceAuthorization] -> ShowS
show :: StartDeviceAuthorization -> String
$cshow :: StartDeviceAuthorization -> String
showsPrec :: Int -> StartDeviceAuthorization -> ShowS
$cshowsPrec :: Int -> StartDeviceAuthorization -> ShowS
Prelude.Show, (forall x.
 StartDeviceAuthorization -> Rep StartDeviceAuthorization x)
-> (forall x.
    Rep StartDeviceAuthorization x -> StartDeviceAuthorization)
-> Generic StartDeviceAuthorization
forall x.
Rep StartDeviceAuthorization x -> StartDeviceAuthorization
forall x.
StartDeviceAuthorization -> Rep StartDeviceAuthorization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartDeviceAuthorization x -> StartDeviceAuthorization
$cfrom :: forall x.
StartDeviceAuthorization -> Rep StartDeviceAuthorization x
Prelude.Generic)

-- |
-- Create a value of 'StartDeviceAuthorization' 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:
--
-- 'clientId', 'startDeviceAuthorization_clientId' - The unique identifier string for the client that is registered with AWS
-- SSO. This value should come from the persisted result of the
-- RegisterClient API operation.
--
-- 'clientSecret', 'startDeviceAuthorization_clientSecret' - A secret string that is generated for the client. This value should come
-- from the persisted result of the RegisterClient API operation.
--
-- 'startUrl', 'startDeviceAuthorization_startUrl' - The URL for the AWS SSO user portal. For more information, see
-- <https://docs.aws.amazon.com/singlesignon/latest/userguide/using-the-portal.html Using the User Portal>
-- in the /AWS Single Sign-On User Guide/.
newStartDeviceAuthorization ::
  -- | 'clientId'
  Prelude.Text ->
  -- | 'clientSecret'
  Prelude.Text ->
  -- | 'startUrl'
  Prelude.Text ->
  StartDeviceAuthorization
newStartDeviceAuthorization :: Text -> Text -> Text -> StartDeviceAuthorization
newStartDeviceAuthorization
  Text
pClientId_
  Text
pClientSecret_
  Text
pStartUrl_ =
    StartDeviceAuthorization' :: Text -> Text -> Text -> StartDeviceAuthorization
StartDeviceAuthorization'
      { $sel:clientId:StartDeviceAuthorization' :: Text
clientId = Text
pClientId_,
        $sel:clientSecret:StartDeviceAuthorization' :: Text
clientSecret = Text
pClientSecret_,
        $sel:startUrl:StartDeviceAuthorization' :: Text
startUrl = Text
pStartUrl_
      }

-- | The unique identifier string for the client that is registered with AWS
-- SSO. This value should come from the persisted result of the
-- RegisterClient API operation.
startDeviceAuthorization_clientId :: Lens.Lens' StartDeviceAuthorization Prelude.Text
startDeviceAuthorization_clientId :: (Text -> f Text)
-> StartDeviceAuthorization -> f StartDeviceAuthorization
startDeviceAuthorization_clientId = (StartDeviceAuthorization -> Text)
-> (StartDeviceAuthorization -> Text -> StartDeviceAuthorization)
-> Lens StartDeviceAuthorization StartDeviceAuthorization Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDeviceAuthorization' {Text
clientId :: Text
$sel:clientId:StartDeviceAuthorization' :: StartDeviceAuthorization -> Text
clientId} -> Text
clientId) (\s :: StartDeviceAuthorization
s@StartDeviceAuthorization' {} Text
a -> StartDeviceAuthorization
s {$sel:clientId:StartDeviceAuthorization' :: Text
clientId = Text
a} :: StartDeviceAuthorization)

-- | A secret string that is generated for the client. This value should come
-- from the persisted result of the RegisterClient API operation.
startDeviceAuthorization_clientSecret :: Lens.Lens' StartDeviceAuthorization Prelude.Text
startDeviceAuthorization_clientSecret :: (Text -> f Text)
-> StartDeviceAuthorization -> f StartDeviceAuthorization
startDeviceAuthorization_clientSecret = (StartDeviceAuthorization -> Text)
-> (StartDeviceAuthorization -> Text -> StartDeviceAuthorization)
-> Lens StartDeviceAuthorization StartDeviceAuthorization Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDeviceAuthorization' {Text
clientSecret :: Text
$sel:clientSecret:StartDeviceAuthorization' :: StartDeviceAuthorization -> Text
clientSecret} -> Text
clientSecret) (\s :: StartDeviceAuthorization
s@StartDeviceAuthorization' {} Text
a -> StartDeviceAuthorization
s {$sel:clientSecret:StartDeviceAuthorization' :: Text
clientSecret = Text
a} :: StartDeviceAuthorization)

-- | The URL for the AWS SSO user portal. For more information, see
-- <https://docs.aws.amazon.com/singlesignon/latest/userguide/using-the-portal.html Using the User Portal>
-- in the /AWS Single Sign-On User Guide/.
startDeviceAuthorization_startUrl :: Lens.Lens' StartDeviceAuthorization Prelude.Text
startDeviceAuthorization_startUrl :: (Text -> f Text)
-> StartDeviceAuthorization -> f StartDeviceAuthorization
startDeviceAuthorization_startUrl = (StartDeviceAuthorization -> Text)
-> (StartDeviceAuthorization -> Text -> StartDeviceAuthorization)
-> Lens StartDeviceAuthorization StartDeviceAuthorization Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDeviceAuthorization' {Text
startUrl :: Text
$sel:startUrl:StartDeviceAuthorization' :: StartDeviceAuthorization -> Text
startUrl} -> Text
startUrl) (\s :: StartDeviceAuthorization
s@StartDeviceAuthorization' {} Text
a -> StartDeviceAuthorization
s {$sel:startUrl:StartDeviceAuthorization' :: Text
startUrl = Text
a} :: StartDeviceAuthorization)

instance Core.AWSRequest StartDeviceAuthorization where
  type
    AWSResponse StartDeviceAuthorization =
      StartDeviceAuthorizationResponse
  request :: StartDeviceAuthorization -> Request StartDeviceAuthorization
request = Service
-> StartDeviceAuthorization -> Request StartDeviceAuthorization
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartDeviceAuthorization
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartDeviceAuthorization)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StartDeviceAuthorization))
-> Logger
-> Service
-> Proxy StartDeviceAuthorization
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartDeviceAuthorization)))
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 Int
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> StartDeviceAuthorizationResponse
StartDeviceAuthorizationResponse'
            (Maybe Text
 -> Maybe Int
 -> Maybe Int
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Int
 -> StartDeviceAuthorizationResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Int
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> StartDeviceAuthorizationResponse)
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
"userCode")
            Either
  String
  (Maybe Int
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> StartDeviceAuthorizationResponse)
-> Either String (Maybe Int)
-> Either
     String
     (Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> StartDeviceAuthorizationResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Int)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"interval")
            Either
  String
  (Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> StartDeviceAuthorizationResponse)
-> Either String (Maybe Int)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> StartDeviceAuthorizationResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Int)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"expiresIn")
            Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> StartDeviceAuthorizationResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Int -> StartDeviceAuthorizationResponse)
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
"verificationUri")
            Either
  String
  (Maybe Text
   -> Maybe Text -> Int -> StartDeviceAuthorizationResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> StartDeviceAuthorizationResponse)
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
"deviceCode")
            Either
  String (Maybe Text -> Int -> StartDeviceAuthorizationResponse)
-> Either String (Maybe Text)
-> Either String (Int -> StartDeviceAuthorizationResponse)
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
"verificationUriComplete")
            Either String (Int -> StartDeviceAuthorizationResponse)
-> Either String Int
-> Either String StartDeviceAuthorizationResponse
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 StartDeviceAuthorization

instance Prelude.NFData StartDeviceAuthorization

instance Core.ToHeaders StartDeviceAuthorization where
  toHeaders :: StartDeviceAuthorization -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartDeviceAuthorization -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 StartDeviceAuthorization where
  toJSON :: StartDeviceAuthorization -> Value
toJSON StartDeviceAuthorization' {Text
startUrl :: Text
clientSecret :: Text
clientId :: Text
$sel:startUrl:StartDeviceAuthorization' :: StartDeviceAuthorization -> Text
$sel:clientSecret:StartDeviceAuthorization' :: StartDeviceAuthorization -> Text
$sel:clientId:StartDeviceAuthorization' :: StartDeviceAuthorization -> Text
..} =
    [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
"clientId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clientId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"clientSecret" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clientSecret),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"startUrl" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
startUrl)
          ]
      )

instance Core.ToPath StartDeviceAuthorization where
  toPath :: StartDeviceAuthorization -> ByteString
toPath = ByteString -> StartDeviceAuthorization -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/device_authorization"

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

-- | /See:/ 'newStartDeviceAuthorizationResponse' smart constructor.
data StartDeviceAuthorizationResponse = StartDeviceAuthorizationResponse'
  { -- | A one-time user verification code. This is needed to authorize an in-use
    -- device.
    StartDeviceAuthorizationResponse -> Maybe Text
userCode :: Prelude.Maybe Prelude.Text,
    -- | Indicates the number of seconds the client must wait between attempts
    -- when polling for a session.
    StartDeviceAuthorizationResponse -> Maybe Int
interval :: Prelude.Maybe Prelude.Int,
    -- | Indicates the number of seconds in which the verification code will
    -- become invalid.
    StartDeviceAuthorizationResponse -> Maybe Int
expiresIn :: Prelude.Maybe Prelude.Int,
    -- | The URI of the verification page that takes the @userCode@ to authorize
    -- the device.
    StartDeviceAuthorizationResponse -> Maybe Text
verificationUri :: Prelude.Maybe Prelude.Text,
    -- | The short-lived code that is used by the device when polling for a
    -- session token.
    StartDeviceAuthorizationResponse -> Maybe Text
deviceCode :: Prelude.Maybe Prelude.Text,
    -- | An alternate URL that the client can use to automatically launch a
    -- browser. This process skips the manual step in which the user visits the
    -- verification page and enters their code.
    StartDeviceAuthorizationResponse -> Maybe Text
verificationUriComplete :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    StartDeviceAuthorizationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartDeviceAuthorizationResponse
-> StartDeviceAuthorizationResponse -> Bool
(StartDeviceAuthorizationResponse
 -> StartDeviceAuthorizationResponse -> Bool)
-> (StartDeviceAuthorizationResponse
    -> StartDeviceAuthorizationResponse -> Bool)
-> Eq StartDeviceAuthorizationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartDeviceAuthorizationResponse
-> StartDeviceAuthorizationResponse -> Bool
$c/= :: StartDeviceAuthorizationResponse
-> StartDeviceAuthorizationResponse -> Bool
== :: StartDeviceAuthorizationResponse
-> StartDeviceAuthorizationResponse -> Bool
$c== :: StartDeviceAuthorizationResponse
-> StartDeviceAuthorizationResponse -> Bool
Prelude.Eq, ReadPrec [StartDeviceAuthorizationResponse]
ReadPrec StartDeviceAuthorizationResponse
Int -> ReadS StartDeviceAuthorizationResponse
ReadS [StartDeviceAuthorizationResponse]
(Int -> ReadS StartDeviceAuthorizationResponse)
-> ReadS [StartDeviceAuthorizationResponse]
-> ReadPrec StartDeviceAuthorizationResponse
-> ReadPrec [StartDeviceAuthorizationResponse]
-> Read StartDeviceAuthorizationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartDeviceAuthorizationResponse]
$creadListPrec :: ReadPrec [StartDeviceAuthorizationResponse]
readPrec :: ReadPrec StartDeviceAuthorizationResponse
$creadPrec :: ReadPrec StartDeviceAuthorizationResponse
readList :: ReadS [StartDeviceAuthorizationResponse]
$creadList :: ReadS [StartDeviceAuthorizationResponse]
readsPrec :: Int -> ReadS StartDeviceAuthorizationResponse
$creadsPrec :: Int -> ReadS StartDeviceAuthorizationResponse
Prelude.Read, Int -> StartDeviceAuthorizationResponse -> ShowS
[StartDeviceAuthorizationResponse] -> ShowS
StartDeviceAuthorizationResponse -> String
(Int -> StartDeviceAuthorizationResponse -> ShowS)
-> (StartDeviceAuthorizationResponse -> String)
-> ([StartDeviceAuthorizationResponse] -> ShowS)
-> Show StartDeviceAuthorizationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartDeviceAuthorizationResponse] -> ShowS
$cshowList :: [StartDeviceAuthorizationResponse] -> ShowS
show :: StartDeviceAuthorizationResponse -> String
$cshow :: StartDeviceAuthorizationResponse -> String
showsPrec :: Int -> StartDeviceAuthorizationResponse -> ShowS
$cshowsPrec :: Int -> StartDeviceAuthorizationResponse -> ShowS
Prelude.Show, (forall x.
 StartDeviceAuthorizationResponse
 -> Rep StartDeviceAuthorizationResponse x)
-> (forall x.
    Rep StartDeviceAuthorizationResponse x
    -> StartDeviceAuthorizationResponse)
-> Generic StartDeviceAuthorizationResponse
forall x.
Rep StartDeviceAuthorizationResponse x
-> StartDeviceAuthorizationResponse
forall x.
StartDeviceAuthorizationResponse
-> Rep StartDeviceAuthorizationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartDeviceAuthorizationResponse x
-> StartDeviceAuthorizationResponse
$cfrom :: forall x.
StartDeviceAuthorizationResponse
-> Rep StartDeviceAuthorizationResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartDeviceAuthorizationResponse' 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:
--
-- 'userCode', 'startDeviceAuthorizationResponse_userCode' - A one-time user verification code. This is needed to authorize an in-use
-- device.
--
-- 'interval', 'startDeviceAuthorizationResponse_interval' - Indicates the number of seconds the client must wait between attempts
-- when polling for a session.
--
-- 'expiresIn', 'startDeviceAuthorizationResponse_expiresIn' - Indicates the number of seconds in which the verification code will
-- become invalid.
--
-- 'verificationUri', 'startDeviceAuthorizationResponse_verificationUri' - The URI of the verification page that takes the @userCode@ to authorize
-- the device.
--
-- 'deviceCode', 'startDeviceAuthorizationResponse_deviceCode' - The short-lived code that is used by the device when polling for a
-- session token.
--
-- 'verificationUriComplete', 'startDeviceAuthorizationResponse_verificationUriComplete' - An alternate URL that the client can use to automatically launch a
-- browser. This process skips the manual step in which the user visits the
-- verification page and enters their code.
--
-- 'httpStatus', 'startDeviceAuthorizationResponse_httpStatus' - The response's http status code.
newStartDeviceAuthorizationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartDeviceAuthorizationResponse
newStartDeviceAuthorizationResponse :: Int -> StartDeviceAuthorizationResponse
newStartDeviceAuthorizationResponse Int
pHttpStatus_ =
  StartDeviceAuthorizationResponse' :: Maybe Text
-> Maybe Int
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> StartDeviceAuthorizationResponse
StartDeviceAuthorizationResponse'
    { $sel:userCode:StartDeviceAuthorizationResponse' :: Maybe Text
userCode =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:interval:StartDeviceAuthorizationResponse' :: Maybe Int
interval = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:expiresIn:StartDeviceAuthorizationResponse' :: Maybe Int
expiresIn = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:verificationUri:StartDeviceAuthorizationResponse' :: Maybe Text
verificationUri = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceCode:StartDeviceAuthorizationResponse' :: Maybe Text
deviceCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:verificationUriComplete:StartDeviceAuthorizationResponse' :: Maybe Text
verificationUriComplete = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartDeviceAuthorizationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A one-time user verification code. This is needed to authorize an in-use
-- device.
startDeviceAuthorizationResponse_userCode :: Lens.Lens' StartDeviceAuthorizationResponse (Prelude.Maybe Prelude.Text)
startDeviceAuthorizationResponse_userCode :: (Maybe Text -> f (Maybe Text))
-> StartDeviceAuthorizationResponse
-> f StartDeviceAuthorizationResponse
startDeviceAuthorizationResponse_userCode = (StartDeviceAuthorizationResponse -> Maybe Text)
-> (StartDeviceAuthorizationResponse
    -> Maybe Text -> StartDeviceAuthorizationResponse)
-> Lens
     StartDeviceAuthorizationResponse
     StartDeviceAuthorizationResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDeviceAuthorizationResponse' {Maybe Text
userCode :: Maybe Text
$sel:userCode:StartDeviceAuthorizationResponse' :: StartDeviceAuthorizationResponse -> Maybe Text
userCode} -> Maybe Text
userCode) (\s :: StartDeviceAuthorizationResponse
s@StartDeviceAuthorizationResponse' {} Maybe Text
a -> StartDeviceAuthorizationResponse
s {$sel:userCode:StartDeviceAuthorizationResponse' :: Maybe Text
userCode = Maybe Text
a} :: StartDeviceAuthorizationResponse)

-- | Indicates the number of seconds the client must wait between attempts
-- when polling for a session.
startDeviceAuthorizationResponse_interval :: Lens.Lens' StartDeviceAuthorizationResponse (Prelude.Maybe Prelude.Int)
startDeviceAuthorizationResponse_interval :: (Maybe Int -> f (Maybe Int))
-> StartDeviceAuthorizationResponse
-> f StartDeviceAuthorizationResponse
startDeviceAuthorizationResponse_interval = (StartDeviceAuthorizationResponse -> Maybe Int)
-> (StartDeviceAuthorizationResponse
    -> Maybe Int -> StartDeviceAuthorizationResponse)
-> Lens
     StartDeviceAuthorizationResponse
     StartDeviceAuthorizationResponse
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDeviceAuthorizationResponse' {Maybe Int
interval :: Maybe Int
$sel:interval:StartDeviceAuthorizationResponse' :: StartDeviceAuthorizationResponse -> Maybe Int
interval} -> Maybe Int
interval) (\s :: StartDeviceAuthorizationResponse
s@StartDeviceAuthorizationResponse' {} Maybe Int
a -> StartDeviceAuthorizationResponse
s {$sel:interval:StartDeviceAuthorizationResponse' :: Maybe Int
interval = Maybe Int
a} :: StartDeviceAuthorizationResponse)

-- | Indicates the number of seconds in which the verification code will
-- become invalid.
startDeviceAuthorizationResponse_expiresIn :: Lens.Lens' StartDeviceAuthorizationResponse (Prelude.Maybe Prelude.Int)
startDeviceAuthorizationResponse_expiresIn :: (Maybe Int -> f (Maybe Int))
-> StartDeviceAuthorizationResponse
-> f StartDeviceAuthorizationResponse
startDeviceAuthorizationResponse_expiresIn = (StartDeviceAuthorizationResponse -> Maybe Int)
-> (StartDeviceAuthorizationResponse
    -> Maybe Int -> StartDeviceAuthorizationResponse)
-> Lens
     StartDeviceAuthorizationResponse
     StartDeviceAuthorizationResponse
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDeviceAuthorizationResponse' {Maybe Int
expiresIn :: Maybe Int
$sel:expiresIn:StartDeviceAuthorizationResponse' :: StartDeviceAuthorizationResponse -> Maybe Int
expiresIn} -> Maybe Int
expiresIn) (\s :: StartDeviceAuthorizationResponse
s@StartDeviceAuthorizationResponse' {} Maybe Int
a -> StartDeviceAuthorizationResponse
s {$sel:expiresIn:StartDeviceAuthorizationResponse' :: Maybe Int
expiresIn = Maybe Int
a} :: StartDeviceAuthorizationResponse)

-- | The URI of the verification page that takes the @userCode@ to authorize
-- the device.
startDeviceAuthorizationResponse_verificationUri :: Lens.Lens' StartDeviceAuthorizationResponse (Prelude.Maybe Prelude.Text)
startDeviceAuthorizationResponse_verificationUri :: (Maybe Text -> f (Maybe Text))
-> StartDeviceAuthorizationResponse
-> f StartDeviceAuthorizationResponse
startDeviceAuthorizationResponse_verificationUri = (StartDeviceAuthorizationResponse -> Maybe Text)
-> (StartDeviceAuthorizationResponse
    -> Maybe Text -> StartDeviceAuthorizationResponse)
-> Lens
     StartDeviceAuthorizationResponse
     StartDeviceAuthorizationResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDeviceAuthorizationResponse' {Maybe Text
verificationUri :: Maybe Text
$sel:verificationUri:StartDeviceAuthorizationResponse' :: StartDeviceAuthorizationResponse -> Maybe Text
verificationUri} -> Maybe Text
verificationUri) (\s :: StartDeviceAuthorizationResponse
s@StartDeviceAuthorizationResponse' {} Maybe Text
a -> StartDeviceAuthorizationResponse
s {$sel:verificationUri:StartDeviceAuthorizationResponse' :: Maybe Text
verificationUri = Maybe Text
a} :: StartDeviceAuthorizationResponse)

-- | The short-lived code that is used by the device when polling for a
-- session token.
startDeviceAuthorizationResponse_deviceCode :: Lens.Lens' StartDeviceAuthorizationResponse (Prelude.Maybe Prelude.Text)
startDeviceAuthorizationResponse_deviceCode :: (Maybe Text -> f (Maybe Text))
-> StartDeviceAuthorizationResponse
-> f StartDeviceAuthorizationResponse
startDeviceAuthorizationResponse_deviceCode = (StartDeviceAuthorizationResponse -> Maybe Text)
-> (StartDeviceAuthorizationResponse
    -> Maybe Text -> StartDeviceAuthorizationResponse)
-> Lens
     StartDeviceAuthorizationResponse
     StartDeviceAuthorizationResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDeviceAuthorizationResponse' {Maybe Text
deviceCode :: Maybe Text
$sel:deviceCode:StartDeviceAuthorizationResponse' :: StartDeviceAuthorizationResponse -> Maybe Text
deviceCode} -> Maybe Text
deviceCode) (\s :: StartDeviceAuthorizationResponse
s@StartDeviceAuthorizationResponse' {} Maybe Text
a -> StartDeviceAuthorizationResponse
s {$sel:deviceCode:StartDeviceAuthorizationResponse' :: Maybe Text
deviceCode = Maybe Text
a} :: StartDeviceAuthorizationResponse)

-- | An alternate URL that the client can use to automatically launch a
-- browser. This process skips the manual step in which the user visits the
-- verification page and enters their code.
startDeviceAuthorizationResponse_verificationUriComplete :: Lens.Lens' StartDeviceAuthorizationResponse (Prelude.Maybe Prelude.Text)
startDeviceAuthorizationResponse_verificationUriComplete :: (Maybe Text -> f (Maybe Text))
-> StartDeviceAuthorizationResponse
-> f StartDeviceAuthorizationResponse
startDeviceAuthorizationResponse_verificationUriComplete = (StartDeviceAuthorizationResponse -> Maybe Text)
-> (StartDeviceAuthorizationResponse
    -> Maybe Text -> StartDeviceAuthorizationResponse)
-> Lens
     StartDeviceAuthorizationResponse
     StartDeviceAuthorizationResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDeviceAuthorizationResponse' {Maybe Text
verificationUriComplete :: Maybe Text
$sel:verificationUriComplete:StartDeviceAuthorizationResponse' :: StartDeviceAuthorizationResponse -> Maybe Text
verificationUriComplete} -> Maybe Text
verificationUriComplete) (\s :: StartDeviceAuthorizationResponse
s@StartDeviceAuthorizationResponse' {} Maybe Text
a -> StartDeviceAuthorizationResponse
s {$sel:verificationUriComplete:StartDeviceAuthorizationResponse' :: Maybe Text
verificationUriComplete = Maybe Text
a} :: StartDeviceAuthorizationResponse)

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

instance
  Prelude.NFData
    StartDeviceAuthorizationResponse