{-# 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.Support.DescribeServices
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the current list of Amazon Web Services services and a list of
-- service categories for each service. You then use service names and
-- categories in your CreateCase requests. Each Amazon Web Services service
-- has its own set of categories.
--
-- The service codes and category codes correspond to the values that
-- appear in the __Service__ and __Category__ lists on the Amazon Web
-- Services Support Center
-- <https://console.aws.amazon.com/support/home#/case/create Create Case>
-- page. The values in those fields don\'t necessarily match the service
-- codes and categories returned by the @DescribeServices@ operation.
-- Always use the service codes and categories that the @DescribeServices@
-- operation returns, so that you have the most recent set of service and
-- category codes.
--
-- -   You must have a Business, Enterprise On-Ramp, or Enterprise Support
--     plan to use the Amazon Web Services Support API.
--
-- -   If you call the Amazon Web Services Support API from an account that
--     doesn\'t have a Business, Enterprise On-Ramp, or Enterprise Support
--     plan, the @SubscriptionRequiredException@ error message appears. For
--     information about changing your support plan, see
--     <http://aws.amazon.com/premiumsupport/ Amazon Web Services Support>.
module Amazonka.Support.DescribeServices
  ( -- * Creating a Request
    DescribeServices (..),
    newDescribeServices,

    -- * Request Lenses
    describeServices_language,
    describeServices_serviceCodeList,

    -- * Destructuring the Response
    DescribeServicesResponse (..),
    newDescribeServicesResponse,

    -- * Response Lenses
    describeServicesResponse_services,
    describeServicesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeServices' smart constructor.
data DescribeServices = DescribeServices'
  { -- | The language in which Amazon Web Services Support handles the case.
    -- Amazon Web Services Support currently supports English (\"en\") and
    -- Japanese (\"ja\"). You must specify the ISO 639-1 code for the
    -- @language@ parameter if you want support in that language.
    DescribeServices -> Maybe Text
language :: Prelude.Maybe Prelude.Text,
    -- | A JSON-formatted list of service codes available for Amazon Web Services
    -- services.
    DescribeServices -> Maybe [Text]
serviceCodeList :: Prelude.Maybe [Prelude.Text]
  }
  deriving (DescribeServices -> DescribeServices -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeServices -> DescribeServices -> Bool
$c/= :: DescribeServices -> DescribeServices -> Bool
== :: DescribeServices -> DescribeServices -> Bool
$c== :: DescribeServices -> DescribeServices -> Bool
Prelude.Eq, ReadPrec [DescribeServices]
ReadPrec DescribeServices
Int -> ReadS DescribeServices
ReadS [DescribeServices]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeServices]
$creadListPrec :: ReadPrec [DescribeServices]
readPrec :: ReadPrec DescribeServices
$creadPrec :: ReadPrec DescribeServices
readList :: ReadS [DescribeServices]
$creadList :: ReadS [DescribeServices]
readsPrec :: Int -> ReadS DescribeServices
$creadsPrec :: Int -> ReadS DescribeServices
Prelude.Read, Int -> DescribeServices -> ShowS
[DescribeServices] -> ShowS
DescribeServices -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeServices] -> ShowS
$cshowList :: [DescribeServices] -> ShowS
show :: DescribeServices -> String
$cshow :: DescribeServices -> String
showsPrec :: Int -> DescribeServices -> ShowS
$cshowsPrec :: Int -> DescribeServices -> ShowS
Prelude.Show, forall x. Rep DescribeServices x -> DescribeServices
forall x. DescribeServices -> Rep DescribeServices x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeServices x -> DescribeServices
$cfrom :: forall x. DescribeServices -> Rep DescribeServices x
Prelude.Generic)

-- |
-- Create a value of 'DescribeServices' 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:
--
-- 'language', 'describeServices_language' - The language in which Amazon Web Services Support handles the case.
-- Amazon Web Services Support currently supports English (\"en\") and
-- Japanese (\"ja\"). You must specify the ISO 639-1 code for the
-- @language@ parameter if you want support in that language.
--
-- 'serviceCodeList', 'describeServices_serviceCodeList' - A JSON-formatted list of service codes available for Amazon Web Services
-- services.
newDescribeServices ::
  DescribeServices
newDescribeServices :: DescribeServices
newDescribeServices =
  DescribeServices'
    { $sel:language:DescribeServices' :: Maybe Text
language = forall a. Maybe a
Prelude.Nothing,
      $sel:serviceCodeList:DescribeServices' :: Maybe [Text]
serviceCodeList = forall a. Maybe a
Prelude.Nothing
    }

-- | The language in which Amazon Web Services Support handles the case.
-- Amazon Web Services Support currently supports English (\"en\") and
-- Japanese (\"ja\"). You must specify the ISO 639-1 code for the
-- @language@ parameter if you want support in that language.
describeServices_language :: Lens.Lens' DescribeServices (Prelude.Maybe Prelude.Text)
describeServices_language :: Lens' DescribeServices (Maybe Text)
describeServices_language = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeServices' {Maybe Text
language :: Maybe Text
$sel:language:DescribeServices' :: DescribeServices -> Maybe Text
language} -> Maybe Text
language) (\s :: DescribeServices
s@DescribeServices' {} Maybe Text
a -> DescribeServices
s {$sel:language:DescribeServices' :: Maybe Text
language = Maybe Text
a} :: DescribeServices)

-- | A JSON-formatted list of service codes available for Amazon Web Services
-- services.
describeServices_serviceCodeList :: Lens.Lens' DescribeServices (Prelude.Maybe [Prelude.Text])
describeServices_serviceCodeList :: Lens' DescribeServices (Maybe [Text])
describeServices_serviceCodeList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeServices' {Maybe [Text]
serviceCodeList :: Maybe [Text]
$sel:serviceCodeList:DescribeServices' :: DescribeServices -> Maybe [Text]
serviceCodeList} -> Maybe [Text]
serviceCodeList) (\s :: DescribeServices
s@DescribeServices' {} Maybe [Text]
a -> DescribeServices
s {$sel:serviceCodeList:DescribeServices' :: Maybe [Text]
serviceCodeList = Maybe [Text]
a} :: DescribeServices) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest DescribeServices where
  type
    AWSResponse DescribeServices =
      DescribeServicesResponse
  request :: (Service -> Service)
-> DescribeServices -> Request DescribeServices
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeServices
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeServices)))
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 [SupportService] -> Int -> DescribeServicesResponse
DescribeServicesResponse'
            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
"services" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 DescribeServices where
  hashWithSalt :: Int -> DescribeServices -> Int
hashWithSalt Int
_salt DescribeServices' {Maybe [Text]
Maybe Text
serviceCodeList :: Maybe [Text]
language :: Maybe Text
$sel:serviceCodeList:DescribeServices' :: DescribeServices -> Maybe [Text]
$sel:language:DescribeServices' :: DescribeServices -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
language
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
serviceCodeList

instance Prelude.NFData DescribeServices where
  rnf :: DescribeServices -> ()
rnf DescribeServices' {Maybe [Text]
Maybe Text
serviceCodeList :: Maybe [Text]
language :: Maybe Text
$sel:serviceCodeList:DescribeServices' :: DescribeServices -> Maybe [Text]
$sel:language:DescribeServices' :: DescribeServices -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
language
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
serviceCodeList

instance Data.ToHeaders DescribeServices where
  toHeaders :: DescribeServices -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSSupport_20130415.DescribeServices" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DescribeServices where
  toJSON :: DescribeServices -> Value
toJSON DescribeServices' {Maybe [Text]
Maybe Text
serviceCodeList :: Maybe [Text]
language :: Maybe Text
$sel:serviceCodeList:DescribeServices' :: DescribeServices -> Maybe [Text]
$sel:language:DescribeServices' :: DescribeServices -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"language" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
language,
            (Key
"serviceCodeList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
serviceCodeList
          ]
      )

instance Data.ToPath DescribeServices where
  toPath :: DescribeServices -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | The list of Amazon Web Services services returned by the
-- DescribeServices operation.
--
-- /See:/ 'newDescribeServicesResponse' smart constructor.
data DescribeServicesResponse = DescribeServicesResponse'
  { -- | A JSON-formatted list of Amazon Web Services services.
    DescribeServicesResponse -> Maybe [SupportService]
services :: Prelude.Maybe [SupportService],
    -- | The response's http status code.
    DescribeServicesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeServicesResponse -> DescribeServicesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeServicesResponse -> DescribeServicesResponse -> Bool
$c/= :: DescribeServicesResponse -> DescribeServicesResponse -> Bool
== :: DescribeServicesResponse -> DescribeServicesResponse -> Bool
$c== :: DescribeServicesResponse -> DescribeServicesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeServicesResponse]
ReadPrec DescribeServicesResponse
Int -> ReadS DescribeServicesResponse
ReadS [DescribeServicesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeServicesResponse]
$creadListPrec :: ReadPrec [DescribeServicesResponse]
readPrec :: ReadPrec DescribeServicesResponse
$creadPrec :: ReadPrec DescribeServicesResponse
readList :: ReadS [DescribeServicesResponse]
$creadList :: ReadS [DescribeServicesResponse]
readsPrec :: Int -> ReadS DescribeServicesResponse
$creadsPrec :: Int -> ReadS DescribeServicesResponse
Prelude.Read, Int -> DescribeServicesResponse -> ShowS
[DescribeServicesResponse] -> ShowS
DescribeServicesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeServicesResponse] -> ShowS
$cshowList :: [DescribeServicesResponse] -> ShowS
show :: DescribeServicesResponse -> String
$cshow :: DescribeServicesResponse -> String
showsPrec :: Int -> DescribeServicesResponse -> ShowS
$cshowsPrec :: Int -> DescribeServicesResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeServicesResponse x -> DescribeServicesResponse
forall x.
DescribeServicesResponse -> Rep DescribeServicesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeServicesResponse x -> DescribeServicesResponse
$cfrom :: forall x.
DescribeServicesResponse -> Rep DescribeServicesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeServicesResponse' 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:
--
-- 'services', 'describeServicesResponse_services' - A JSON-formatted list of Amazon Web Services services.
--
-- 'httpStatus', 'describeServicesResponse_httpStatus' - The response's http status code.
newDescribeServicesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeServicesResponse
newDescribeServicesResponse :: Int -> DescribeServicesResponse
newDescribeServicesResponse Int
pHttpStatus_ =
  DescribeServicesResponse'
    { $sel:services:DescribeServicesResponse' :: Maybe [SupportService]
services =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeServicesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A JSON-formatted list of Amazon Web Services services.
describeServicesResponse_services :: Lens.Lens' DescribeServicesResponse (Prelude.Maybe [SupportService])
describeServicesResponse_services :: Lens' DescribeServicesResponse (Maybe [SupportService])
describeServicesResponse_services = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeServicesResponse' {Maybe [SupportService]
services :: Maybe [SupportService]
$sel:services:DescribeServicesResponse' :: DescribeServicesResponse -> Maybe [SupportService]
services} -> Maybe [SupportService]
services) (\s :: DescribeServicesResponse
s@DescribeServicesResponse' {} Maybe [SupportService]
a -> DescribeServicesResponse
s {$sel:services:DescribeServicesResponse' :: Maybe [SupportService]
services = Maybe [SupportService]
a} :: DescribeServicesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeServicesResponse where
  rnf :: DescribeServicesResponse -> ()
rnf DescribeServicesResponse' {Int
Maybe [SupportService]
httpStatus :: Int
services :: Maybe [SupportService]
$sel:httpStatus:DescribeServicesResponse' :: DescribeServicesResponse -> Int
$sel:services:DescribeServicesResponse' :: DescribeServicesResponse -> Maybe [SupportService]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [SupportService]
services
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus