{-# 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.Scheduler.GetScheduleGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the specified schedule group.
module Amazonka.Scheduler.GetScheduleGroup
  ( -- * Creating a Request
    GetScheduleGroup (..),
    newGetScheduleGroup,

    -- * Request Lenses
    getScheduleGroup_name,

    -- * Destructuring the Response
    GetScheduleGroupResponse (..),
    newGetScheduleGroupResponse,

    -- * Response Lenses
    getScheduleGroupResponse_arn,
    getScheduleGroupResponse_creationDate,
    getScheduleGroupResponse_lastModificationDate,
    getScheduleGroupResponse_name,
    getScheduleGroupResponse_state,
    getScheduleGroupResponse_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.Scheduler.Types

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

-- |
-- Create a value of 'GetScheduleGroup' 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:
--
-- 'name', 'getScheduleGroup_name' - The name of the schedule group to retrieve.
newGetScheduleGroup ::
  -- | 'name'
  Prelude.Text ->
  GetScheduleGroup
newGetScheduleGroup :: Text -> GetScheduleGroup
newGetScheduleGroup Text
pName_ =
  GetScheduleGroup' {$sel:name:GetScheduleGroup' :: Text
name = Text
pName_}

-- | The name of the schedule group to retrieve.
getScheduleGroup_name :: Lens.Lens' GetScheduleGroup Prelude.Text
getScheduleGroup_name :: Lens' GetScheduleGroup Text
getScheduleGroup_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetScheduleGroup' {Text
name :: Text
$sel:name:GetScheduleGroup' :: GetScheduleGroup -> Text
name} -> Text
name) (\s :: GetScheduleGroup
s@GetScheduleGroup' {} Text
a -> GetScheduleGroup
s {$sel:name:GetScheduleGroup' :: Text
name = Text
a} :: GetScheduleGroup)

instance Core.AWSRequest GetScheduleGroup where
  type
    AWSResponse GetScheduleGroup =
      GetScheduleGroupResponse
  request :: (Service -> Service)
-> GetScheduleGroup -> Request GetScheduleGroup
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetScheduleGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetScheduleGroup)))
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 Text
-> Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe ScheduleGroupState
-> Int
-> GetScheduleGroupResponse
GetScheduleGroupResponse'
            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
"Arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"CreationDate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"LastModificationDate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"State")
            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 GetScheduleGroup where
  hashWithSalt :: Int -> GetScheduleGroup -> Int
hashWithSalt Int
_salt GetScheduleGroup' {Text
name :: Text
$sel:name:GetScheduleGroup' :: GetScheduleGroup -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

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

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

instance Data.ToPath GetScheduleGroup where
  toPath :: GetScheduleGroup -> ByteString
toPath GetScheduleGroup' {Text
name :: Text
$sel:name:GetScheduleGroup' :: GetScheduleGroup -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/schedule-groups/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
name]

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

-- | /See:/ 'newGetScheduleGroupResponse' smart constructor.
data GetScheduleGroupResponse = GetScheduleGroupResponse'
  { -- | The Amazon Resource Name (ARN) of the schedule group.
    GetScheduleGroupResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The time at which the schedule group was created.
    GetScheduleGroupResponse -> Maybe POSIX
creationDate :: Prelude.Maybe Data.POSIX,
    -- | The time at which the schedule group was last modified.
    GetScheduleGroupResponse -> Maybe POSIX
lastModificationDate :: Prelude.Maybe Data.POSIX,
    -- | The name of the schedule group.
    GetScheduleGroupResponse -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Specifies the state of the schedule group.
    GetScheduleGroupResponse -> Maybe ScheduleGroupState
state :: Prelude.Maybe ScheduleGroupState,
    -- | The response's http status code.
    GetScheduleGroupResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetScheduleGroupResponse -> GetScheduleGroupResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetScheduleGroupResponse -> GetScheduleGroupResponse -> Bool
$c/= :: GetScheduleGroupResponse -> GetScheduleGroupResponse -> Bool
== :: GetScheduleGroupResponse -> GetScheduleGroupResponse -> Bool
$c== :: GetScheduleGroupResponse -> GetScheduleGroupResponse -> Bool
Prelude.Eq, ReadPrec [GetScheduleGroupResponse]
ReadPrec GetScheduleGroupResponse
Int -> ReadS GetScheduleGroupResponse
ReadS [GetScheduleGroupResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetScheduleGroupResponse]
$creadListPrec :: ReadPrec [GetScheduleGroupResponse]
readPrec :: ReadPrec GetScheduleGroupResponse
$creadPrec :: ReadPrec GetScheduleGroupResponse
readList :: ReadS [GetScheduleGroupResponse]
$creadList :: ReadS [GetScheduleGroupResponse]
readsPrec :: Int -> ReadS GetScheduleGroupResponse
$creadsPrec :: Int -> ReadS GetScheduleGroupResponse
Prelude.Read, Int -> GetScheduleGroupResponse -> ShowS
[GetScheduleGroupResponse] -> ShowS
GetScheduleGroupResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetScheduleGroupResponse] -> ShowS
$cshowList :: [GetScheduleGroupResponse] -> ShowS
show :: GetScheduleGroupResponse -> String
$cshow :: GetScheduleGroupResponse -> String
showsPrec :: Int -> GetScheduleGroupResponse -> ShowS
$cshowsPrec :: Int -> GetScheduleGroupResponse -> ShowS
Prelude.Show, forall x.
Rep GetScheduleGroupResponse x -> GetScheduleGroupResponse
forall x.
GetScheduleGroupResponse -> Rep GetScheduleGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetScheduleGroupResponse x -> GetScheduleGroupResponse
$cfrom :: forall x.
GetScheduleGroupResponse -> Rep GetScheduleGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetScheduleGroupResponse' 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:
--
-- 'arn', 'getScheduleGroupResponse_arn' - The Amazon Resource Name (ARN) of the schedule group.
--
-- 'creationDate', 'getScheduleGroupResponse_creationDate' - The time at which the schedule group was created.
--
-- 'lastModificationDate', 'getScheduleGroupResponse_lastModificationDate' - The time at which the schedule group was last modified.
--
-- 'name', 'getScheduleGroupResponse_name' - The name of the schedule group.
--
-- 'state', 'getScheduleGroupResponse_state' - Specifies the state of the schedule group.
--
-- 'httpStatus', 'getScheduleGroupResponse_httpStatus' - The response's http status code.
newGetScheduleGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetScheduleGroupResponse
newGetScheduleGroupResponse :: Int -> GetScheduleGroupResponse
newGetScheduleGroupResponse Int
pHttpStatus_ =
  GetScheduleGroupResponse'
    { $sel:arn:GetScheduleGroupResponse' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:GetScheduleGroupResponse' :: Maybe POSIX
creationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:lastModificationDate:GetScheduleGroupResponse' :: Maybe POSIX
lastModificationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetScheduleGroupResponse' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:state:GetScheduleGroupResponse' :: Maybe ScheduleGroupState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetScheduleGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the schedule group.
getScheduleGroupResponse_arn :: Lens.Lens' GetScheduleGroupResponse (Prelude.Maybe Prelude.Text)
getScheduleGroupResponse_arn :: Lens' GetScheduleGroupResponse (Maybe Text)
getScheduleGroupResponse_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetScheduleGroupResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:GetScheduleGroupResponse' :: GetScheduleGroupResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: GetScheduleGroupResponse
s@GetScheduleGroupResponse' {} Maybe Text
a -> GetScheduleGroupResponse
s {$sel:arn:GetScheduleGroupResponse' :: Maybe Text
arn = Maybe Text
a} :: GetScheduleGroupResponse)

-- | The time at which the schedule group was created.
getScheduleGroupResponse_creationDate :: Lens.Lens' GetScheduleGroupResponse (Prelude.Maybe Prelude.UTCTime)
getScheduleGroupResponse_creationDate :: Lens' GetScheduleGroupResponse (Maybe UTCTime)
getScheduleGroupResponse_creationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetScheduleGroupResponse' {Maybe POSIX
creationDate :: Maybe POSIX
$sel:creationDate:GetScheduleGroupResponse' :: GetScheduleGroupResponse -> Maybe POSIX
creationDate} -> Maybe POSIX
creationDate) (\s :: GetScheduleGroupResponse
s@GetScheduleGroupResponse' {} Maybe POSIX
a -> GetScheduleGroupResponse
s {$sel:creationDate:GetScheduleGroupResponse' :: Maybe POSIX
creationDate = Maybe POSIX
a} :: GetScheduleGroupResponse) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The time at which the schedule group was last modified.
getScheduleGroupResponse_lastModificationDate :: Lens.Lens' GetScheduleGroupResponse (Prelude.Maybe Prelude.UTCTime)
getScheduleGroupResponse_lastModificationDate :: Lens' GetScheduleGroupResponse (Maybe UTCTime)
getScheduleGroupResponse_lastModificationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetScheduleGroupResponse' {Maybe POSIX
lastModificationDate :: Maybe POSIX
$sel:lastModificationDate:GetScheduleGroupResponse' :: GetScheduleGroupResponse -> Maybe POSIX
lastModificationDate} -> Maybe POSIX
lastModificationDate) (\s :: GetScheduleGroupResponse
s@GetScheduleGroupResponse' {} Maybe POSIX
a -> GetScheduleGroupResponse
s {$sel:lastModificationDate:GetScheduleGroupResponse' :: Maybe POSIX
lastModificationDate = Maybe POSIX
a} :: GetScheduleGroupResponse) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The name of the schedule group.
getScheduleGroupResponse_name :: Lens.Lens' GetScheduleGroupResponse (Prelude.Maybe Prelude.Text)
getScheduleGroupResponse_name :: Lens' GetScheduleGroupResponse (Maybe Text)
getScheduleGroupResponse_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetScheduleGroupResponse' {Maybe Text
name :: Maybe Text
$sel:name:GetScheduleGroupResponse' :: GetScheduleGroupResponse -> Maybe Text
name} -> Maybe Text
name) (\s :: GetScheduleGroupResponse
s@GetScheduleGroupResponse' {} Maybe Text
a -> GetScheduleGroupResponse
s {$sel:name:GetScheduleGroupResponse' :: Maybe Text
name = Maybe Text
a} :: GetScheduleGroupResponse)

-- | Specifies the state of the schedule group.
getScheduleGroupResponse_state :: Lens.Lens' GetScheduleGroupResponse (Prelude.Maybe ScheduleGroupState)
getScheduleGroupResponse_state :: Lens' GetScheduleGroupResponse (Maybe ScheduleGroupState)
getScheduleGroupResponse_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetScheduleGroupResponse' {Maybe ScheduleGroupState
state :: Maybe ScheduleGroupState
$sel:state:GetScheduleGroupResponse' :: GetScheduleGroupResponse -> Maybe ScheduleGroupState
state} -> Maybe ScheduleGroupState
state) (\s :: GetScheduleGroupResponse
s@GetScheduleGroupResponse' {} Maybe ScheduleGroupState
a -> GetScheduleGroupResponse
s {$sel:state:GetScheduleGroupResponse' :: Maybe ScheduleGroupState
state = Maybe ScheduleGroupState
a} :: GetScheduleGroupResponse)

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

instance Prelude.NFData GetScheduleGroupResponse where
  rnf :: GetScheduleGroupResponse -> ()
rnf GetScheduleGroupResponse' {Int
Maybe Text
Maybe POSIX
Maybe ScheduleGroupState
httpStatus :: Int
state :: Maybe ScheduleGroupState
name :: Maybe Text
lastModificationDate :: Maybe POSIX
creationDate :: Maybe POSIX
arn :: Maybe Text
$sel:httpStatus:GetScheduleGroupResponse' :: GetScheduleGroupResponse -> Int
$sel:state:GetScheduleGroupResponse' :: GetScheduleGroupResponse -> Maybe ScheduleGroupState
$sel:name:GetScheduleGroupResponse' :: GetScheduleGroupResponse -> Maybe Text
$sel:lastModificationDate:GetScheduleGroupResponse' :: GetScheduleGroupResponse -> Maybe POSIX
$sel:creationDate:GetScheduleGroupResponse' :: GetScheduleGroupResponse -> Maybe POSIX
$sel:arn:GetScheduleGroupResponse' :: GetScheduleGroupResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastModificationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ScheduleGroupState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus