{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module Network.Google.TaskQueue.Types.Product where
import Network.Google.Prelude
import Network.Google.TaskQueue.Types.Sum
data Tasks2 = Tasks2'
{ _tKind :: !Text
, _tItems :: !(Maybe [Task])
} deriving (Eq,Show,Data,Typeable,Generic)
tasks2
:: Tasks2
tasks2 =
Tasks2'
{ _tKind = "taskqueues#tasks"
, _tItems = Nothing
}
tKind :: Lens' Tasks2 Text
tKind = lens _tKind (\ s a -> s{_tKind = a})
tItems :: Lens' Tasks2 [Task]
tItems
= lens _tItems (\ s a -> s{_tItems = a}) . _Default .
_Coerce
instance FromJSON Tasks2 where
parseJSON
= withObject "Tasks2"
(\ o ->
Tasks2' <$>
(o .:? "kind" .!= "taskqueues#tasks") <*>
(o .:? "items" .!= mempty))
instance ToJSON Tasks2 where
toJSON Tasks2'{..}
= object
(catMaybes
[Just ("kind" .= _tKind), ("items" .=) <$> _tItems])
data TaskQueue = TaskQueue'
{ _tqKind :: !Text
, _tqStats :: !(Maybe TaskQueueStats)
, _tqMaxLeases :: !(Maybe (Textual Int32))
, _tqId :: !(Maybe Text)
, _tqACL :: !(Maybe TaskQueueACL)
} deriving (Eq,Show,Data,Typeable,Generic)
taskQueue
:: TaskQueue
taskQueue =
TaskQueue'
{ _tqKind = "taskqueues#taskqueue"
, _tqStats = Nothing
, _tqMaxLeases = Nothing
, _tqId = Nothing
, _tqACL = Nothing
}
tqKind :: Lens' TaskQueue Text
tqKind = lens _tqKind (\ s a -> s{_tqKind = a})
tqStats :: Lens' TaskQueue (Maybe TaskQueueStats)
tqStats = lens _tqStats (\ s a -> s{_tqStats = a})
tqMaxLeases :: Lens' TaskQueue (Maybe Int32)
tqMaxLeases
= lens _tqMaxLeases (\ s a -> s{_tqMaxLeases = a}) .
mapping _Coerce
tqId :: Lens' TaskQueue (Maybe Text)
tqId = lens _tqId (\ s a -> s{_tqId = a})
tqACL :: Lens' TaskQueue (Maybe TaskQueueACL)
tqACL = lens _tqACL (\ s a -> s{_tqACL = a})
instance FromJSON TaskQueue where
parseJSON
= withObject "TaskQueue"
(\ o ->
TaskQueue' <$>
(o .:? "kind" .!= "taskqueues#taskqueue") <*>
(o .:? "stats")
<*> (o .:? "maxLeases")
<*> (o .:? "id")
<*> (o .:? "acl"))
instance ToJSON TaskQueue where
toJSON TaskQueue'{..}
= object
(catMaybes
[Just ("kind" .= _tqKind), ("stats" .=) <$> _tqStats,
("maxLeases" .=) <$> _tqMaxLeases,
("id" .=) <$> _tqId, ("acl" .=) <$> _tqACL])
data TaskQueueACL = TaskQueueACL'
{ _tqaProducerEmails :: !(Maybe [Text])
, _tqaAdminEmails :: !(Maybe [Text])
, _tqaConsumerEmails :: !(Maybe [Text])
} deriving (Eq,Show,Data,Typeable,Generic)
taskQueueACL
:: TaskQueueACL
taskQueueACL =
TaskQueueACL'
{ _tqaProducerEmails = Nothing
, _tqaAdminEmails = Nothing
, _tqaConsumerEmails = Nothing
}
tqaProducerEmails :: Lens' TaskQueueACL [Text]
tqaProducerEmails
= lens _tqaProducerEmails
(\ s a -> s{_tqaProducerEmails = a})
. _Default
. _Coerce
tqaAdminEmails :: Lens' TaskQueueACL [Text]
tqaAdminEmails
= lens _tqaAdminEmails
(\ s a -> s{_tqaAdminEmails = a})
. _Default
. _Coerce
tqaConsumerEmails :: Lens' TaskQueueACL [Text]
tqaConsumerEmails
= lens _tqaConsumerEmails
(\ s a -> s{_tqaConsumerEmails = a})
. _Default
. _Coerce
instance FromJSON TaskQueueACL where
parseJSON
= withObject "TaskQueueACL"
(\ o ->
TaskQueueACL' <$>
(o .:? "producerEmails" .!= mempty) <*>
(o .:? "adminEmails" .!= mempty)
<*> (o .:? "consumerEmails" .!= mempty))
instance ToJSON TaskQueueACL where
toJSON TaskQueueACL'{..}
= object
(catMaybes
[("producerEmails" .=) <$> _tqaProducerEmails,
("adminEmails" .=) <$> _tqaAdminEmails,
("consumerEmails" .=) <$> _tqaConsumerEmails])
data TaskQueueStats = TaskQueueStats'
{ _tqsTotalTasks :: !(Maybe (Textual Int32))
, _tqsOldestTask :: !(Maybe (Textual Int64))
, _tqsLeasedLastHour :: !(Maybe (Textual Int64))
, _tqsLeasedLastMinute :: !(Maybe (Textual Int64))
} deriving (Eq,Show,Data,Typeable,Generic)
taskQueueStats
:: TaskQueueStats
taskQueueStats =
TaskQueueStats'
{ _tqsTotalTasks = Nothing
, _tqsOldestTask = Nothing
, _tqsLeasedLastHour = Nothing
, _tqsLeasedLastMinute = Nothing
}
tqsTotalTasks :: Lens' TaskQueueStats (Maybe Int32)
tqsTotalTasks
= lens _tqsTotalTasks
(\ s a -> s{_tqsTotalTasks = a})
. mapping _Coerce
tqsOldestTask :: Lens' TaskQueueStats (Maybe Int64)
tqsOldestTask
= lens _tqsOldestTask
(\ s a -> s{_tqsOldestTask = a})
. mapping _Coerce
tqsLeasedLastHour :: Lens' TaskQueueStats (Maybe Int64)
tqsLeasedLastHour
= lens _tqsLeasedLastHour
(\ s a -> s{_tqsLeasedLastHour = a})
. mapping _Coerce
tqsLeasedLastMinute :: Lens' TaskQueueStats (Maybe Int64)
tqsLeasedLastMinute
= lens _tqsLeasedLastMinute
(\ s a -> s{_tqsLeasedLastMinute = a})
. mapping _Coerce
instance FromJSON TaskQueueStats where
parseJSON
= withObject "TaskQueueStats"
(\ o ->
TaskQueueStats' <$>
(o .:? "totalTasks") <*> (o .:? "oldestTask") <*>
(o .:? "leasedLastHour")
<*> (o .:? "leasedLastMinute"))
instance ToJSON TaskQueueStats where
toJSON TaskQueueStats'{..}
= object
(catMaybes
[("totalTasks" .=) <$> _tqsTotalTasks,
("oldestTask" .=) <$> _tqsOldestTask,
("leasedLastHour" .=) <$> _tqsLeasedLastHour,
("leasedLastMinute" .=) <$> _tqsLeasedLastMinute])
data Tasks = Tasks'
{ _tasKind :: !Text
, _tasItems :: !(Maybe [Task])
} deriving (Eq,Show,Data,Typeable,Generic)
tasks
:: Tasks
tasks =
Tasks'
{ _tasKind = "taskqueue#tasks"
, _tasItems = Nothing
}
tasKind :: Lens' Tasks Text
tasKind = lens _tasKind (\ s a -> s{_tasKind = a})
tasItems :: Lens' Tasks [Task]
tasItems
= lens _tasItems (\ s a -> s{_tasItems = a}) .
_Default
. _Coerce
instance FromJSON Tasks where
parseJSON
= withObject "Tasks"
(\ o ->
Tasks' <$>
(o .:? "kind" .!= "taskqueue#tasks") <*>
(o .:? "items" .!= mempty))
instance ToJSON Tasks where
toJSON Tasks'{..}
= object
(catMaybes
[Just ("kind" .= _tasKind),
("items" .=) <$> _tasItems])
data Task = Task'
{ _ttRetryCount :: !(Maybe (Textual Int32))
, _ttEnQueueTimestamp :: !(Maybe (Textual Int64))
, _ttTag :: !(Maybe Text)
, _ttKind :: !Text
, _ttQueueName :: !(Maybe Text)
, _ttPayloadBase64 :: !(Maybe Text)
, _ttId :: !(Maybe Text)
, _ttLeaseTimestamp :: !(Maybe (Textual Int64))
} deriving (Eq,Show,Data,Typeable,Generic)
task
:: Task
task =
Task'
{ _ttRetryCount = Nothing
, _ttEnQueueTimestamp = Nothing
, _ttTag = Nothing
, _ttKind = "taskqueues#task"
, _ttQueueName = Nothing
, _ttPayloadBase64 = Nothing
, _ttId = Nothing
, _ttLeaseTimestamp = Nothing
}
ttRetryCount :: Lens' Task (Maybe Int32)
ttRetryCount
= lens _ttRetryCount (\ s a -> s{_ttRetryCount = a})
. mapping _Coerce
ttEnQueueTimestamp :: Lens' Task (Maybe Int64)
ttEnQueueTimestamp
= lens _ttEnQueueTimestamp
(\ s a -> s{_ttEnQueueTimestamp = a})
. mapping _Coerce
ttTag :: Lens' Task (Maybe Text)
ttTag = lens _ttTag (\ s a -> s{_ttTag = a})
ttKind :: Lens' Task Text
ttKind = lens _ttKind (\ s a -> s{_ttKind = a})
ttQueueName :: Lens' Task (Maybe Text)
ttQueueName
= lens _ttQueueName (\ s a -> s{_ttQueueName = a})
ttPayloadBase64 :: Lens' Task (Maybe Text)
ttPayloadBase64
= lens _ttPayloadBase64
(\ s a -> s{_ttPayloadBase64 = a})
ttId :: Lens' Task (Maybe Text)
ttId = lens _ttId (\ s a -> s{_ttId = a})
ttLeaseTimestamp :: Lens' Task (Maybe Int64)
ttLeaseTimestamp
= lens _ttLeaseTimestamp
(\ s a -> s{_ttLeaseTimestamp = a})
. mapping _Coerce
instance FromJSON Task where
parseJSON
= withObject "Task"
(\ o ->
Task' <$>
(o .:? "retry_count") <*> (o .:? "enqueueTimestamp")
<*> (o .:? "tag")
<*> (o .:? "kind" .!= "taskqueues#task")
<*> (o .:? "queueName")
<*> (o .:? "payloadBase64")
<*> (o .:? "id")
<*> (o .:? "leaseTimestamp"))
instance ToJSON Task where
toJSON Task'{..}
= object
(catMaybes
[("retry_count" .=) <$> _ttRetryCount,
("enqueueTimestamp" .=) <$> _ttEnQueueTimestamp,
("tag" .=) <$> _ttTag, Just ("kind" .= _ttKind),
("queueName" .=) <$> _ttQueueName,
("payloadBase64" .=) <$> _ttPayloadBase64,
("id" .=) <$> _ttId,
("leaseTimestamp" .=) <$> _ttLeaseTimestamp])