{-# 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.Greengrass.GetServiceRoleForAccount
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the service role that is attached to your account.
module Amazonka.Greengrass.GetServiceRoleForAccount
  ( -- * Creating a Request
    GetServiceRoleForAccount (..),
    newGetServiceRoleForAccount,

    -- * Destructuring the Response
    GetServiceRoleForAccountResponse (..),
    newGetServiceRoleForAccountResponse,

    -- * Response Lenses
    getServiceRoleForAccountResponse_associatedAt,
    getServiceRoleForAccountResponse_roleArn,
    getServiceRoleForAccountResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'GetServiceRoleForAccount' 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.
newGetServiceRoleForAccount ::
  GetServiceRoleForAccount
newGetServiceRoleForAccount :: GetServiceRoleForAccount
newGetServiceRoleForAccount =
  GetServiceRoleForAccount
GetServiceRoleForAccount'

instance Core.AWSRequest GetServiceRoleForAccount where
  type
    AWSResponse GetServiceRoleForAccount =
      GetServiceRoleForAccountResponse
  request :: (Service -> Service)
-> GetServiceRoleForAccount -> Request GetServiceRoleForAccount
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetServiceRoleForAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetServiceRoleForAccount)))
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 Text -> Maybe Text -> Int -> GetServiceRoleForAccountResponse
GetServiceRoleForAccountResponse'
            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
"AssociatedAt")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"RoleArn")
            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 GetServiceRoleForAccount where
  hashWithSalt :: Int -> GetServiceRoleForAccount -> Int
hashWithSalt Int
_salt GetServiceRoleForAccount
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData GetServiceRoleForAccount where
  rnf :: GetServiceRoleForAccount -> ()
rnf GetServiceRoleForAccount
_ = ()

instance Data.ToHeaders GetServiceRoleForAccount where
  toHeaders :: GetServiceRoleForAccount -> 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.ToPath GetServiceRoleForAccount where
  toPath :: GetServiceRoleForAccount -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/greengrass/servicerole"

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

-- | /See:/ 'newGetServiceRoleForAccountResponse' smart constructor.
data GetServiceRoleForAccountResponse = GetServiceRoleForAccountResponse'
  { -- | The time when the service role was associated with the account.
    GetServiceRoleForAccountResponse -> Maybe Text
associatedAt :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the role which is associated with the account.
    GetServiceRoleForAccountResponse -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetServiceRoleForAccountResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetServiceRoleForAccountResponse
-> GetServiceRoleForAccountResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetServiceRoleForAccountResponse
-> GetServiceRoleForAccountResponse -> Bool
$c/= :: GetServiceRoleForAccountResponse
-> GetServiceRoleForAccountResponse -> Bool
== :: GetServiceRoleForAccountResponse
-> GetServiceRoleForAccountResponse -> Bool
$c== :: GetServiceRoleForAccountResponse
-> GetServiceRoleForAccountResponse -> Bool
Prelude.Eq, ReadPrec [GetServiceRoleForAccountResponse]
ReadPrec GetServiceRoleForAccountResponse
Int -> ReadS GetServiceRoleForAccountResponse
ReadS [GetServiceRoleForAccountResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetServiceRoleForAccountResponse]
$creadListPrec :: ReadPrec [GetServiceRoleForAccountResponse]
readPrec :: ReadPrec GetServiceRoleForAccountResponse
$creadPrec :: ReadPrec GetServiceRoleForAccountResponse
readList :: ReadS [GetServiceRoleForAccountResponse]
$creadList :: ReadS [GetServiceRoleForAccountResponse]
readsPrec :: Int -> ReadS GetServiceRoleForAccountResponse
$creadsPrec :: Int -> ReadS GetServiceRoleForAccountResponse
Prelude.Read, Int -> GetServiceRoleForAccountResponse -> ShowS
[GetServiceRoleForAccountResponse] -> ShowS
GetServiceRoleForAccountResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetServiceRoleForAccountResponse] -> ShowS
$cshowList :: [GetServiceRoleForAccountResponse] -> ShowS
show :: GetServiceRoleForAccountResponse -> String
$cshow :: GetServiceRoleForAccountResponse -> String
showsPrec :: Int -> GetServiceRoleForAccountResponse -> ShowS
$cshowsPrec :: Int -> GetServiceRoleForAccountResponse -> ShowS
Prelude.Show, forall x.
Rep GetServiceRoleForAccountResponse x
-> GetServiceRoleForAccountResponse
forall x.
GetServiceRoleForAccountResponse
-> Rep GetServiceRoleForAccountResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetServiceRoleForAccountResponse x
-> GetServiceRoleForAccountResponse
$cfrom :: forall x.
GetServiceRoleForAccountResponse
-> Rep GetServiceRoleForAccountResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetServiceRoleForAccountResponse' 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:
--
-- 'associatedAt', 'getServiceRoleForAccountResponse_associatedAt' - The time when the service role was associated with the account.
--
-- 'roleArn', 'getServiceRoleForAccountResponse_roleArn' - The ARN of the role which is associated with the account.
--
-- 'httpStatus', 'getServiceRoleForAccountResponse_httpStatus' - The response's http status code.
newGetServiceRoleForAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetServiceRoleForAccountResponse
newGetServiceRoleForAccountResponse :: Int -> GetServiceRoleForAccountResponse
newGetServiceRoleForAccountResponse Int
pHttpStatus_ =
  GetServiceRoleForAccountResponse'
    { $sel:associatedAt:GetServiceRoleForAccountResponse' :: Maybe Text
associatedAt =
        forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:GetServiceRoleForAccountResponse' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetServiceRoleForAccountResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The time when the service role was associated with the account.
getServiceRoleForAccountResponse_associatedAt :: Lens.Lens' GetServiceRoleForAccountResponse (Prelude.Maybe Prelude.Text)
getServiceRoleForAccountResponse_associatedAt :: Lens' GetServiceRoleForAccountResponse (Maybe Text)
getServiceRoleForAccountResponse_associatedAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceRoleForAccountResponse' {Maybe Text
associatedAt :: Maybe Text
$sel:associatedAt:GetServiceRoleForAccountResponse' :: GetServiceRoleForAccountResponse -> Maybe Text
associatedAt} -> Maybe Text
associatedAt) (\s :: GetServiceRoleForAccountResponse
s@GetServiceRoleForAccountResponse' {} Maybe Text
a -> GetServiceRoleForAccountResponse
s {$sel:associatedAt:GetServiceRoleForAccountResponse' :: Maybe Text
associatedAt = Maybe Text
a} :: GetServiceRoleForAccountResponse)

-- | The ARN of the role which is associated with the account.
getServiceRoleForAccountResponse_roleArn :: Lens.Lens' GetServiceRoleForAccountResponse (Prelude.Maybe Prelude.Text)
getServiceRoleForAccountResponse_roleArn :: Lens' GetServiceRoleForAccountResponse (Maybe Text)
getServiceRoleForAccountResponse_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceRoleForAccountResponse' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:GetServiceRoleForAccountResponse' :: GetServiceRoleForAccountResponse -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: GetServiceRoleForAccountResponse
s@GetServiceRoleForAccountResponse' {} Maybe Text
a -> GetServiceRoleForAccountResponse
s {$sel:roleArn:GetServiceRoleForAccountResponse' :: Maybe Text
roleArn = Maybe Text
a} :: GetServiceRoleForAccountResponse)

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

instance
  Prelude.NFData
    GetServiceRoleForAccountResponse
  where
  rnf :: GetServiceRoleForAccountResponse -> ()
rnf GetServiceRoleForAccountResponse' {Int
Maybe Text
httpStatus :: Int
roleArn :: Maybe Text
associatedAt :: Maybe Text
$sel:httpStatus:GetServiceRoleForAccountResponse' :: GetServiceRoleForAccountResponse -> Int
$sel:roleArn:GetServiceRoleForAccountResponse' :: GetServiceRoleForAccountResponse -> Maybe Text
$sel:associatedAt:GetServiceRoleForAccountResponse' :: GetServiceRoleForAccountResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
associatedAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus