{-# 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.AuditManager.GetServicesInScope
-- 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)
--
-- Returns a list of the in-scope Amazon Web Services services for the
-- specified assessment.
module Amazonka.AuditManager.GetServicesInScope
  ( -- * Creating a Request
    GetServicesInScope (..),
    newGetServicesInScope,

    -- * Destructuring the Response
    GetServicesInScopeResponse (..),
    newGetServicesInScopeResponse,

    -- * Response Lenses
    getServicesInScopeResponse_serviceMetadata,
    getServicesInScopeResponse_httpStatus,
  )
where

import Amazonka.AuditManager.Types
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

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

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

instance Core.AWSRequest GetServicesInScope where
  type
    AWSResponse GetServicesInScope =
      GetServicesInScopeResponse
  request :: GetServicesInScope -> Request GetServicesInScope
request = Service -> GetServicesInScope -> Request GetServicesInScope
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetServicesInScope
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetServicesInScope)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetServicesInScope))
-> Logger
-> Service
-> Proxy GetServicesInScope
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetServicesInScope)))
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 [ServiceMetadata] -> Int -> GetServicesInScopeResponse
GetServicesInScopeResponse'
            (Maybe [ServiceMetadata] -> Int -> GetServicesInScopeResponse)
-> Either String (Maybe [ServiceMetadata])
-> Either String (Int -> GetServicesInScopeResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Key -> Either String (Maybe (Maybe [ServiceMetadata]))
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"serviceMetadata"
                            Either String (Maybe (Maybe [ServiceMetadata]))
-> Maybe [ServiceMetadata]
-> Either String (Maybe [ServiceMetadata])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ServiceMetadata]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> GetServicesInScopeResponse)
-> Either String Int -> Either String GetServicesInScopeResponse
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 GetServicesInScope

instance Prelude.NFData GetServicesInScope

instance Core.ToHeaders GetServicesInScope where
  toHeaders :: GetServicesInScope -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetServicesInScope -> 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.ToPath GetServicesInScope where
  toPath :: GetServicesInScope -> ByteString
toPath = ByteString -> GetServicesInScope -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/services"

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

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

-- |
-- Create a value of 'GetServicesInScopeResponse' 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:
--
-- 'serviceMetadata', 'getServicesInScopeResponse_serviceMetadata' - The metadata associated with the Amazon Web Service.
--
-- 'httpStatus', 'getServicesInScopeResponse_httpStatus' - The response's http status code.
newGetServicesInScopeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetServicesInScopeResponse
newGetServicesInScopeResponse :: Int -> GetServicesInScopeResponse
newGetServicesInScopeResponse Int
pHttpStatus_ =
  GetServicesInScopeResponse' :: Maybe [ServiceMetadata] -> Int -> GetServicesInScopeResponse
GetServicesInScopeResponse'
    { $sel:serviceMetadata:GetServicesInScopeResponse' :: Maybe [ServiceMetadata]
serviceMetadata =
        Maybe [ServiceMetadata]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetServicesInScopeResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The metadata associated with the Amazon Web Service.
getServicesInScopeResponse_serviceMetadata :: Lens.Lens' GetServicesInScopeResponse (Prelude.Maybe [ServiceMetadata])
getServicesInScopeResponse_serviceMetadata :: (Maybe [ServiceMetadata] -> f (Maybe [ServiceMetadata]))
-> GetServicesInScopeResponse -> f GetServicesInScopeResponse
getServicesInScopeResponse_serviceMetadata = (GetServicesInScopeResponse -> Maybe [ServiceMetadata])
-> (GetServicesInScopeResponse
    -> Maybe [ServiceMetadata] -> GetServicesInScopeResponse)
-> Lens
     GetServicesInScopeResponse
     GetServicesInScopeResponse
     (Maybe [ServiceMetadata])
     (Maybe [ServiceMetadata])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServicesInScopeResponse' {Maybe [ServiceMetadata]
serviceMetadata :: Maybe [ServiceMetadata]
$sel:serviceMetadata:GetServicesInScopeResponse' :: GetServicesInScopeResponse -> Maybe [ServiceMetadata]
serviceMetadata} -> Maybe [ServiceMetadata]
serviceMetadata) (\s :: GetServicesInScopeResponse
s@GetServicesInScopeResponse' {} Maybe [ServiceMetadata]
a -> GetServicesInScopeResponse
s {$sel:serviceMetadata:GetServicesInScopeResponse' :: Maybe [ServiceMetadata]
serviceMetadata = Maybe [ServiceMetadata]
a} :: GetServicesInScopeResponse) ((Maybe [ServiceMetadata] -> f (Maybe [ServiceMetadata]))
 -> GetServicesInScopeResponse -> f GetServicesInScopeResponse)
-> ((Maybe [ServiceMetadata] -> f (Maybe [ServiceMetadata]))
    -> Maybe [ServiceMetadata] -> f (Maybe [ServiceMetadata]))
-> (Maybe [ServiceMetadata] -> f (Maybe [ServiceMetadata]))
-> GetServicesInScopeResponse
-> f GetServicesInScopeResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ServiceMetadata]
  [ServiceMetadata]
  [ServiceMetadata]
  [ServiceMetadata]
-> Iso
     (Maybe [ServiceMetadata])
     (Maybe [ServiceMetadata])
     (Maybe [ServiceMetadata])
     (Maybe [ServiceMetadata])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ServiceMetadata]
  [ServiceMetadata]
  [ServiceMetadata]
  [ServiceMetadata]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetServicesInScopeResponse