{-# 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.Lightsail.GetContainerServices
-- 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 information about one or more of your Amazon Lightsail container
-- services.
module Amazonka.Lightsail.GetContainerServices
  ( -- * Creating a Request
    GetContainerServices (..),
    newGetContainerServices,

    -- * Request Lenses
    getContainerServices_serviceName,

    -- * Destructuring the Response
    GetContainerServicesResponse (..),
    newGetContainerServicesResponse,

    -- * Response Lenses
    getContainerServicesResponse_containerServices,
    getContainerServicesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetContainerServices' smart constructor.
data GetContainerServices = GetContainerServices'
  { -- | The name of the container service for which to return information.
    --
    -- When omitted, the response includes all of your container services in
    -- the Amazon Web Services Region where the request is made.
    GetContainerServices -> Maybe Text
serviceName :: Prelude.Maybe Prelude.Text
  }
  deriving (GetContainerServices -> GetContainerServices -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContainerServices -> GetContainerServices -> Bool
$c/= :: GetContainerServices -> GetContainerServices -> Bool
== :: GetContainerServices -> GetContainerServices -> Bool
$c== :: GetContainerServices -> GetContainerServices -> Bool
Prelude.Eq, ReadPrec [GetContainerServices]
ReadPrec GetContainerServices
Int -> ReadS GetContainerServices
ReadS [GetContainerServices]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContainerServices]
$creadListPrec :: ReadPrec [GetContainerServices]
readPrec :: ReadPrec GetContainerServices
$creadPrec :: ReadPrec GetContainerServices
readList :: ReadS [GetContainerServices]
$creadList :: ReadS [GetContainerServices]
readsPrec :: Int -> ReadS GetContainerServices
$creadsPrec :: Int -> ReadS GetContainerServices
Prelude.Read, Int -> GetContainerServices -> ShowS
[GetContainerServices] -> ShowS
GetContainerServices -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContainerServices] -> ShowS
$cshowList :: [GetContainerServices] -> ShowS
show :: GetContainerServices -> String
$cshow :: GetContainerServices -> String
showsPrec :: Int -> GetContainerServices -> ShowS
$cshowsPrec :: Int -> GetContainerServices -> ShowS
Prelude.Show, forall x. Rep GetContainerServices x -> GetContainerServices
forall x. GetContainerServices -> Rep GetContainerServices x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetContainerServices x -> GetContainerServices
$cfrom :: forall x. GetContainerServices -> Rep GetContainerServices x
Prelude.Generic)

-- |
-- Create a value of 'GetContainerServices' 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:
--
-- 'serviceName', 'getContainerServices_serviceName' - The name of the container service for which to return information.
--
-- When omitted, the response includes all of your container services in
-- the Amazon Web Services Region where the request is made.
newGetContainerServices ::
  GetContainerServices
newGetContainerServices :: GetContainerServices
newGetContainerServices =
  GetContainerServices'
    { $sel:serviceName:GetContainerServices' :: Maybe Text
serviceName =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the container service for which to return information.
--
-- When omitted, the response includes all of your container services in
-- the Amazon Web Services Region where the request is made.
getContainerServices_serviceName :: Lens.Lens' GetContainerServices (Prelude.Maybe Prelude.Text)
getContainerServices_serviceName :: Lens' GetContainerServices (Maybe Text)
getContainerServices_serviceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerServices' {Maybe Text
serviceName :: Maybe Text
$sel:serviceName:GetContainerServices' :: GetContainerServices -> Maybe Text
serviceName} -> Maybe Text
serviceName) (\s :: GetContainerServices
s@GetContainerServices' {} Maybe Text
a -> GetContainerServices
s {$sel:serviceName:GetContainerServices' :: Maybe Text
serviceName = Maybe Text
a} :: GetContainerServices)

instance Core.AWSRequest GetContainerServices where
  type
    AWSResponse GetContainerServices =
      GetContainerServicesResponse
  request :: (Service -> Service)
-> GetContainerServices -> Request GetContainerServices
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 GetContainerServices
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetContainerServices)))
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 [ContainerService] -> Int -> GetContainerServicesResponse
GetContainerServicesResponse'
            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
"containerServices"
                            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 GetContainerServices where
  hashWithSalt :: Int -> GetContainerServices -> Int
hashWithSalt Int
_salt GetContainerServices' {Maybe Text
serviceName :: Maybe Text
$sel:serviceName:GetContainerServices' :: GetContainerServices -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
serviceName

instance Prelude.NFData GetContainerServices where
  rnf :: GetContainerServices -> ()
rnf GetContainerServices' {Maybe Text
serviceName :: Maybe Text
$sel:serviceName:GetContainerServices' :: GetContainerServices -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
serviceName

instance Data.ToHeaders GetContainerServices where
  toHeaders :: GetContainerServices -> 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
"Lightsail_20161128.GetContainerServices" ::
                          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 GetContainerServices where
  toJSON :: GetContainerServices -> Value
toJSON GetContainerServices' {Maybe Text
serviceName :: Maybe Text
$sel:serviceName:GetContainerServices' :: GetContainerServices -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"serviceName" 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
serviceName]
      )

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

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

-- | /See:/ 'newGetContainerServicesResponse' smart constructor.
data GetContainerServicesResponse = GetContainerServicesResponse'
  { -- | An array of objects that describe one or more container services.
    GetContainerServicesResponse -> Maybe [ContainerService]
containerServices :: Prelude.Maybe [ContainerService],
    -- | The response's http status code.
    GetContainerServicesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetContainerServicesResponse
-> GetContainerServicesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContainerServicesResponse
-> GetContainerServicesResponse -> Bool
$c/= :: GetContainerServicesResponse
-> GetContainerServicesResponse -> Bool
== :: GetContainerServicesResponse
-> GetContainerServicesResponse -> Bool
$c== :: GetContainerServicesResponse
-> GetContainerServicesResponse -> Bool
Prelude.Eq, ReadPrec [GetContainerServicesResponse]
ReadPrec GetContainerServicesResponse
Int -> ReadS GetContainerServicesResponse
ReadS [GetContainerServicesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContainerServicesResponse]
$creadListPrec :: ReadPrec [GetContainerServicesResponse]
readPrec :: ReadPrec GetContainerServicesResponse
$creadPrec :: ReadPrec GetContainerServicesResponse
readList :: ReadS [GetContainerServicesResponse]
$creadList :: ReadS [GetContainerServicesResponse]
readsPrec :: Int -> ReadS GetContainerServicesResponse
$creadsPrec :: Int -> ReadS GetContainerServicesResponse
Prelude.Read, Int -> GetContainerServicesResponse -> ShowS
[GetContainerServicesResponse] -> ShowS
GetContainerServicesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContainerServicesResponse] -> ShowS
$cshowList :: [GetContainerServicesResponse] -> ShowS
show :: GetContainerServicesResponse -> String
$cshow :: GetContainerServicesResponse -> String
showsPrec :: Int -> GetContainerServicesResponse -> ShowS
$cshowsPrec :: Int -> GetContainerServicesResponse -> ShowS
Prelude.Show, forall x.
Rep GetContainerServicesResponse x -> GetContainerServicesResponse
forall x.
GetContainerServicesResponse -> Rep GetContainerServicesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetContainerServicesResponse x -> GetContainerServicesResponse
$cfrom :: forall x.
GetContainerServicesResponse -> Rep GetContainerServicesResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetContainerServicesResponse' 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:
--
-- 'containerServices', 'getContainerServicesResponse_containerServices' - An array of objects that describe one or more container services.
--
-- 'httpStatus', 'getContainerServicesResponse_httpStatus' - The response's http status code.
newGetContainerServicesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetContainerServicesResponse
newGetContainerServicesResponse :: Int -> GetContainerServicesResponse
newGetContainerServicesResponse Int
pHttpStatus_ =
  GetContainerServicesResponse'
    { $sel:containerServices:GetContainerServicesResponse' :: Maybe [ContainerService]
containerServices =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetContainerServicesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe one or more container services.
getContainerServicesResponse_containerServices :: Lens.Lens' GetContainerServicesResponse (Prelude.Maybe [ContainerService])
getContainerServicesResponse_containerServices :: Lens' GetContainerServicesResponse (Maybe [ContainerService])
getContainerServicesResponse_containerServices = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerServicesResponse' {Maybe [ContainerService]
containerServices :: Maybe [ContainerService]
$sel:containerServices:GetContainerServicesResponse' :: GetContainerServicesResponse -> Maybe [ContainerService]
containerServices} -> Maybe [ContainerService]
containerServices) (\s :: GetContainerServicesResponse
s@GetContainerServicesResponse' {} Maybe [ContainerService]
a -> GetContainerServicesResponse
s {$sel:containerServices:GetContainerServicesResponse' :: Maybe [ContainerService]
containerServices = Maybe [ContainerService]
a} :: GetContainerServicesResponse) 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.
getContainerServicesResponse_httpStatus :: Lens.Lens' GetContainerServicesResponse Prelude.Int
getContainerServicesResponse_httpStatus :: Lens' GetContainerServicesResponse Int
getContainerServicesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerServicesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetContainerServicesResponse' :: GetContainerServicesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetContainerServicesResponse
s@GetContainerServicesResponse' {} Int
a -> GetContainerServicesResponse
s {$sel:httpStatus:GetContainerServicesResponse' :: Int
httpStatus = Int
a} :: GetContainerServicesResponse)

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