{-# 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.OpsWorks.DescribeOperatingSystems
-- 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)
--
-- Describes the operating systems that are supported by AWS OpsWorks
-- Stacks.
module Amazonka.OpsWorks.DescribeOperatingSystems
  ( -- * Creating a Request
    DescribeOperatingSystems (..),
    newDescribeOperatingSystems,

    -- * Destructuring the Response
    DescribeOperatingSystemsResponse (..),
    newDescribeOperatingSystemsResponse,

    -- * Response Lenses
    describeOperatingSystemsResponse_operatingSystems,
    describeOperatingSystemsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorks.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

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

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

instance Prelude.NFData DescribeOperatingSystems

instance Core.ToHeaders DescribeOperatingSystems where
  toHeaders :: DescribeOperatingSystems -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeOperatingSystems -> 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
"OpsWorks_20130218.DescribeOperatingSystems" ::
                          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 DescribeOperatingSystems where
  toJSON :: DescribeOperatingSystems -> Value
toJSON = Value -> DescribeOperatingSystems -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

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

-- | The response to a @DescribeOperatingSystems@ request.
--
-- /See:/ 'newDescribeOperatingSystemsResponse' smart constructor.
data DescribeOperatingSystemsResponse = DescribeOperatingSystemsResponse'
  { -- | Contains information in response to a @DescribeOperatingSystems@
    -- request.
    DescribeOperatingSystemsResponse -> Maybe [OperatingSystem]
operatingSystems :: Prelude.Maybe [OperatingSystem],
    -- | The response's http status code.
    DescribeOperatingSystemsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeOperatingSystemsResponse
-> DescribeOperatingSystemsResponse -> Bool
(DescribeOperatingSystemsResponse
 -> DescribeOperatingSystemsResponse -> Bool)
-> (DescribeOperatingSystemsResponse
    -> DescribeOperatingSystemsResponse -> Bool)
-> Eq DescribeOperatingSystemsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeOperatingSystemsResponse
-> DescribeOperatingSystemsResponse -> Bool
$c/= :: DescribeOperatingSystemsResponse
-> DescribeOperatingSystemsResponse -> Bool
== :: DescribeOperatingSystemsResponse
-> DescribeOperatingSystemsResponse -> Bool
$c== :: DescribeOperatingSystemsResponse
-> DescribeOperatingSystemsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeOperatingSystemsResponse]
ReadPrec DescribeOperatingSystemsResponse
Int -> ReadS DescribeOperatingSystemsResponse
ReadS [DescribeOperatingSystemsResponse]
(Int -> ReadS DescribeOperatingSystemsResponse)
-> ReadS [DescribeOperatingSystemsResponse]
-> ReadPrec DescribeOperatingSystemsResponse
-> ReadPrec [DescribeOperatingSystemsResponse]
-> Read DescribeOperatingSystemsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeOperatingSystemsResponse]
$creadListPrec :: ReadPrec [DescribeOperatingSystemsResponse]
readPrec :: ReadPrec DescribeOperatingSystemsResponse
$creadPrec :: ReadPrec DescribeOperatingSystemsResponse
readList :: ReadS [DescribeOperatingSystemsResponse]
$creadList :: ReadS [DescribeOperatingSystemsResponse]
readsPrec :: Int -> ReadS DescribeOperatingSystemsResponse
$creadsPrec :: Int -> ReadS DescribeOperatingSystemsResponse
Prelude.Read, Int -> DescribeOperatingSystemsResponse -> ShowS
[DescribeOperatingSystemsResponse] -> ShowS
DescribeOperatingSystemsResponse -> String
(Int -> DescribeOperatingSystemsResponse -> ShowS)
-> (DescribeOperatingSystemsResponse -> String)
-> ([DescribeOperatingSystemsResponse] -> ShowS)
-> Show DescribeOperatingSystemsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeOperatingSystemsResponse] -> ShowS
$cshowList :: [DescribeOperatingSystemsResponse] -> ShowS
show :: DescribeOperatingSystemsResponse -> String
$cshow :: DescribeOperatingSystemsResponse -> String
showsPrec :: Int -> DescribeOperatingSystemsResponse -> ShowS
$cshowsPrec :: Int -> DescribeOperatingSystemsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeOperatingSystemsResponse
 -> Rep DescribeOperatingSystemsResponse x)
-> (forall x.
    Rep DescribeOperatingSystemsResponse x
    -> DescribeOperatingSystemsResponse)
-> Generic DescribeOperatingSystemsResponse
forall x.
Rep DescribeOperatingSystemsResponse x
-> DescribeOperatingSystemsResponse
forall x.
DescribeOperatingSystemsResponse
-> Rep DescribeOperatingSystemsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeOperatingSystemsResponse x
-> DescribeOperatingSystemsResponse
$cfrom :: forall x.
DescribeOperatingSystemsResponse
-> Rep DescribeOperatingSystemsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeOperatingSystemsResponse' 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:
--
-- 'operatingSystems', 'describeOperatingSystemsResponse_operatingSystems' - Contains information in response to a @DescribeOperatingSystems@
-- request.
--
-- 'httpStatus', 'describeOperatingSystemsResponse_httpStatus' - The response's http status code.
newDescribeOperatingSystemsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeOperatingSystemsResponse
newDescribeOperatingSystemsResponse :: Int -> DescribeOperatingSystemsResponse
newDescribeOperatingSystemsResponse Int
pHttpStatus_ =
  DescribeOperatingSystemsResponse' :: Maybe [OperatingSystem] -> Int -> DescribeOperatingSystemsResponse
DescribeOperatingSystemsResponse'
    { $sel:operatingSystems:DescribeOperatingSystemsResponse' :: Maybe [OperatingSystem]
operatingSystems =
        Maybe [OperatingSystem]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeOperatingSystemsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Contains information in response to a @DescribeOperatingSystems@
-- request.
describeOperatingSystemsResponse_operatingSystems :: Lens.Lens' DescribeOperatingSystemsResponse (Prelude.Maybe [OperatingSystem])
describeOperatingSystemsResponse_operatingSystems :: (Maybe [OperatingSystem] -> f (Maybe [OperatingSystem]))
-> DescribeOperatingSystemsResponse
-> f DescribeOperatingSystemsResponse
describeOperatingSystemsResponse_operatingSystems = (DescribeOperatingSystemsResponse -> Maybe [OperatingSystem])
-> (DescribeOperatingSystemsResponse
    -> Maybe [OperatingSystem] -> DescribeOperatingSystemsResponse)
-> Lens
     DescribeOperatingSystemsResponse
     DescribeOperatingSystemsResponse
     (Maybe [OperatingSystem])
     (Maybe [OperatingSystem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeOperatingSystemsResponse' {Maybe [OperatingSystem]
operatingSystems :: Maybe [OperatingSystem]
$sel:operatingSystems:DescribeOperatingSystemsResponse' :: DescribeOperatingSystemsResponse -> Maybe [OperatingSystem]
operatingSystems} -> Maybe [OperatingSystem]
operatingSystems) (\s :: DescribeOperatingSystemsResponse
s@DescribeOperatingSystemsResponse' {} Maybe [OperatingSystem]
a -> DescribeOperatingSystemsResponse
s {$sel:operatingSystems:DescribeOperatingSystemsResponse' :: Maybe [OperatingSystem]
operatingSystems = Maybe [OperatingSystem]
a} :: DescribeOperatingSystemsResponse) ((Maybe [OperatingSystem] -> f (Maybe [OperatingSystem]))
 -> DescribeOperatingSystemsResponse
 -> f DescribeOperatingSystemsResponse)
-> ((Maybe [OperatingSystem] -> f (Maybe [OperatingSystem]))
    -> Maybe [OperatingSystem] -> f (Maybe [OperatingSystem]))
-> (Maybe [OperatingSystem] -> f (Maybe [OperatingSystem]))
-> DescribeOperatingSystemsResponse
-> f DescribeOperatingSystemsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [OperatingSystem]
  [OperatingSystem]
  [OperatingSystem]
  [OperatingSystem]
-> Iso
     (Maybe [OperatingSystem])
     (Maybe [OperatingSystem])
     (Maybe [OperatingSystem])
     (Maybe [OperatingSystem])
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
  [OperatingSystem]
  [OperatingSystem]
  [OperatingSystem]
  [OperatingSystem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DescribeOperatingSystemsResponse