{-# 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-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 the current list of AWS services and a list of service
-- categories for each service. You then use service names and categories
-- in your CreateCase requests. Each AWS 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 AWS 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 or Enterprise Support plan to use the AWS
--     Support API.
--
-- -   If you call the AWS Support API from an account that does not have a
--     Business or Enterprise Support plan, the
--     @SubscriptionRequiredException@ error message appears. For
--     information about changing your support plan, see
--     <http://aws.amazon.com/premiumsupport/ AWS Support>.
module Amazonka.Support.DescribeServices
  ( -- * Creating a Request
    DescribeServices (..),
    newDescribeServices,

    -- * Request Lenses
    describeServices_serviceCodeList,
    describeServices_language,

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

    -- * Response Lenses
    describeServicesResponse_services,
    describeServicesResponse_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.Support.Types

-- | /See:/ 'newDescribeServices' smart constructor.
data DescribeServices = DescribeServices'
  { -- | A JSON-formatted list of service codes available for AWS services.
    DescribeServices -> Maybe [Text]
serviceCodeList :: Prelude.Maybe [Prelude.Text],
    -- | The ISO 639-1 code for the language in which AWS provides support. AWS
    -- Support currently supports English (\"en\") and Japanese (\"ja\").
    -- Language parameters must be passed explicitly for operations that take
    -- them.
    DescribeServices -> Maybe Text
language :: Prelude.Maybe Prelude.Text
  }
  deriving (DescribeServices -> DescribeServices -> Bool
(DescribeServices -> DescribeServices -> Bool)
-> (DescribeServices -> DescribeServices -> Bool)
-> Eq DescribeServices
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]
(Int -> ReadS DescribeServices)
-> ReadS [DescribeServices]
-> ReadPrec DescribeServices
-> ReadPrec [DescribeServices]
-> Read 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
(Int -> DescribeServices -> ShowS)
-> (DescribeServices -> String)
-> ([DescribeServices] -> ShowS)
-> Show DescribeServices
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. DescribeServices -> Rep DescribeServices x)
-> (forall x. Rep DescribeServices x -> DescribeServices)
-> Generic DescribeServices
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:
--
-- 'serviceCodeList', 'describeServices_serviceCodeList' - A JSON-formatted list of service codes available for AWS services.
--
-- 'language', 'describeServices_language' - The ISO 639-1 code for the language in which AWS provides support. AWS
-- Support currently supports English (\"en\") and Japanese (\"ja\").
-- Language parameters must be passed explicitly for operations that take
-- them.
newDescribeServices ::
  DescribeServices
newDescribeServices :: DescribeServices
newDescribeServices =
  DescribeServices' :: Maybe [Text] -> Maybe Text -> DescribeServices
DescribeServices'
    { $sel:serviceCodeList:DescribeServices' :: Maybe [Text]
serviceCodeList =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:language:DescribeServices' :: Maybe Text
language = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A JSON-formatted list of service codes available for AWS services.
describeServices_serviceCodeList :: Lens.Lens' DescribeServices (Prelude.Maybe [Prelude.Text])
describeServices_serviceCodeList :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeServices -> f DescribeServices
describeServices_serviceCodeList = (DescribeServices -> Maybe [Text])
-> (DescribeServices -> Maybe [Text] -> DescribeServices)
-> Lens
     DescribeServices DescribeServices (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeServices -> f DescribeServices)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeServices
-> f DescribeServices
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ISO 639-1 code for the language in which AWS provides support. AWS
-- Support currently supports English (\"en\") and Japanese (\"ja\").
-- Language parameters must be passed explicitly for operations that take
-- them.
describeServices_language :: Lens.Lens' DescribeServices (Prelude.Maybe Prelude.Text)
describeServices_language :: (Maybe Text -> f (Maybe Text))
-> DescribeServices -> f DescribeServices
describeServices_language = (DescribeServices -> Maybe Text)
-> (DescribeServices -> Maybe Text -> DescribeServices)
-> Lens DescribeServices DescribeServices (Maybe Text) (Maybe Text)
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)

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

instance Prelude.NFData DescribeServices

instance Core.ToHeaders DescribeServices where
  toHeaders :: DescribeServices -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeServices -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSSupport_20130415.DescribeServices" ::
                          Prelude.ByteString
                      ),
            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 DescribeServices where
  toJSON :: DescribeServices -> Value
toJSON DescribeServices' {Maybe [Text]
Maybe Text
language :: Maybe Text
serviceCodeList :: Maybe [Text]
$sel:language:DescribeServices' :: DescribeServices -> Maybe Text
$sel:serviceCodeList:DescribeServices' :: DescribeServices -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"serviceCodeList" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
serviceCodeList,
            (Text
"language" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
language
          ]
      )

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

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

-- | The list of AWS services returned by the DescribeServices operation.
--
-- /See:/ 'newDescribeServicesResponse' smart constructor.
data DescribeServicesResponse = DescribeServicesResponse'
  { -- | A JSON-formatted list of AWS services.
    DescribeServicesResponse -> Maybe [SupportService]
services :: Prelude.Maybe [SupportService],
    -- | The response's http status code.
    DescribeServicesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeServicesResponse -> DescribeServicesResponse -> Bool
(DescribeServicesResponse -> DescribeServicesResponse -> Bool)
-> (DescribeServicesResponse -> DescribeServicesResponse -> Bool)
-> Eq DescribeServicesResponse
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]
(Int -> ReadS DescribeServicesResponse)
-> ReadS [DescribeServicesResponse]
-> ReadPrec DescribeServicesResponse
-> ReadPrec [DescribeServicesResponse]
-> Read 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
(Int -> DescribeServicesResponse -> ShowS)
-> (DescribeServicesResponse -> String)
-> ([DescribeServicesResponse] -> ShowS)
-> Show DescribeServicesResponse
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.
 DescribeServicesResponse -> Rep DescribeServicesResponse x)
-> (forall x.
    Rep DescribeServicesResponse x -> DescribeServicesResponse)
-> Generic DescribeServicesResponse
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 AWS services.
--
-- 'httpStatus', 'describeServicesResponse_httpStatus' - The response's http status code.
newDescribeServicesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeServicesResponse
newDescribeServicesResponse :: Int -> DescribeServicesResponse
newDescribeServicesResponse Int
pHttpStatus_ =
  DescribeServicesResponse' :: Maybe [SupportService] -> Int -> DescribeServicesResponse
DescribeServicesResponse'
    { $sel:services:DescribeServicesResponse' :: Maybe [SupportService]
services =
        Maybe [SupportService]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeServicesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A JSON-formatted list of AWS services.
describeServicesResponse_services :: Lens.Lens' DescribeServicesResponse (Prelude.Maybe [SupportService])
describeServicesResponse_services :: (Maybe [SupportService] -> f (Maybe [SupportService]))
-> DescribeServicesResponse -> f DescribeServicesResponse
describeServicesResponse_services = (DescribeServicesResponse -> Maybe [SupportService])
-> (DescribeServicesResponse
    -> Maybe [SupportService] -> DescribeServicesResponse)
-> Lens
     DescribeServicesResponse
     DescribeServicesResponse
     (Maybe [SupportService])
     (Maybe [SupportService])
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) ((Maybe [SupportService] -> f (Maybe [SupportService]))
 -> DescribeServicesResponse -> f DescribeServicesResponse)
-> ((Maybe [SupportService] -> f (Maybe [SupportService]))
    -> Maybe [SupportService] -> f (Maybe [SupportService]))
-> (Maybe [SupportService] -> f (Maybe [SupportService]))
-> DescribeServicesResponse
-> f DescribeServicesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SupportService] [SupportService] [SupportService] [SupportService]
-> Iso
     (Maybe [SupportService])
     (Maybe [SupportService])
     (Maybe [SupportService])
     (Maybe [SupportService])
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
  [SupportService] [SupportService] [SupportService] [SupportService]
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 :: (Int -> f Int)
-> DescribeServicesResponse -> f DescribeServicesResponse
describeServicesResponse_httpStatus = (DescribeServicesResponse -> Int)
-> (DescribeServicesResponse -> Int -> DescribeServicesResponse)
-> Lens DescribeServicesResponse DescribeServicesResponse Int Int
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