on bec6ff8 help sign in
185 lines 5.6 kB history raw
1{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE DeriveDataTypeable #-}
3{-# LANGUAGE DeriveGeneric #-}
4{-# LANGUAGE OverloadedStrings #-}
5{-# LANGUAGE RecordWildCards #-}
6{-# LANGUAGE TypeFamilies #-}
7{-# LANGUAGE TypeOperators #-}
9{-# OPTIONS_GHC -fno-warn-unused-imports #-}
10{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
12-- |
13-- Module : Network.Google.Resource.Taskqueue.Tasks.Insert
14-- Copyright : (c) 2015 Brendan Hay
15-- License : Mozilla Public License, v. 2.0.
16-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
17-- Stability : auto-generated
18-- Portability : non-portable (GHC extensions)
19--
20-- | Insert a new task in a TaskQueue
21--
22-- /See:/ <https://developers.google.com/appengine/docs/python/taskqueue/rest TaskQueue API Reference> for @TaskqueueTasksInsert@.
23module Network.Google.Resource.Taskqueue.Tasks.Insert
24 (
25 -- * REST Resource
26 TasksInsertResource
28 -- * Creating a Request
29 , tasksInsert'
30 , TasksInsert'
32 -- * Request Lenses
33 , tiTaskqueue
34 , tiQuotaUser
35 , tiPrettyPrint
36 , tiProject
37 , tiUserIP
38 , tiKey
39 , tiTask
40 , tiOAuthToken
41 , tiFields
42 ) where
44import Network.Google.AppEngineTaskQueue.Types
45import Network.Google.Prelude
47-- | A resource alias for @TaskqueueTasksInsert@ which the
48-- 'TasksInsert'' request conforms to.
49type TasksInsertResource =
50 Capture "project" Text :>
51 "taskqueues" :>
52 Capture "taskqueue" Text :>
53 "tasks" :>
54 QueryParam "quotaUser" Text :>
55 QueryParam "prettyPrint" Bool :>
56 QueryParam "userIp" Text :>
57 QueryParam "key" Key :>
58 QueryParam "oauth_token" OAuthToken :>
59 QueryParam "fields" Text :>
60 QueryParam "alt" AltJSON :>
61 ReqBody '[JSON] Task :> Post '[JSON] Task
63-- | Insert a new task in a TaskQueue
64--
65-- /See:/ 'tasksInsert'' smart constructor.
66data TasksInsert' = TasksInsert'
67 { _tiTaskqueue :: !Text
68 , _tiQuotaUser :: !(Maybe Text)
69 , _tiPrettyPrint :: !Bool
70 , _tiProject :: !Text
71 , _tiUserIP :: !(Maybe Text)
72 , _tiKey :: !(Maybe Key)
73 , _tiTask :: !Task
74 , _tiOAuthToken :: !(Maybe OAuthToken)
75 , _tiFields :: !(Maybe Text)
76 } deriving (Eq,Read,Show,Data,Typeable,Generic)
78-- | Creates a value of 'TasksInsert'' with the minimum fields required to make a request.
79--
80-- Use one of the following lenses to modify other fields as desired:
81--
82-- * 'tiTaskqueue'
83--
84-- * 'tiQuotaUser'
85--
86-- * 'tiPrettyPrint'
87--
88-- * 'tiProject'
89--
90-- * 'tiUserIP'
91--
92-- * 'tiKey'
93--
94-- * 'tiTask'
95--
96-- * 'tiOAuthToken'
97--
98-- * 'tiFields'
99tasksInsert'
100 :: Text -- ^ 'taskqueue'
101 -> Text -- ^ 'project'
102 -> Task -- ^ 'Task'
103 -> TasksInsert'
104tasksInsert' pTiTaskqueue_ pTiProject_ pTiTask_ =
105 TasksInsert'
106 { _tiTaskqueue = pTiTaskqueue_
107 , _tiQuotaUser = Nothing
108 , _tiPrettyPrint = True
109 , _tiProject = pTiProject_
110 , _tiUserIP = Nothing
111 , _tiKey = Nothing
112 , _tiTask = pTiTask_
113 , _tiOAuthToken = Nothing
114 , _tiFields = Nothing
115 }
117-- | The taskqueue to insert the task into
118tiTaskqueue :: Lens' TasksInsert' Text
119tiTaskqueue
120 = lens _tiTaskqueue (\ s a -> s{_tiTaskqueue = a})
122-- | Available to use for quota purposes for server-side applications. Can be
123-- any arbitrary string assigned to a user, but should not exceed 40
124-- characters. Overrides userIp if both are provided.
125tiQuotaUser :: Lens' TasksInsert' (Maybe Text)
126tiQuotaUser
127 = lens _tiQuotaUser (\ s a -> s{_tiQuotaUser = a})
129-- | Returns response with indentations and line breaks.
130tiPrettyPrint :: Lens' TasksInsert' Bool
131tiPrettyPrint
132 = lens _tiPrettyPrint
133 (\ s a -> s{_tiPrettyPrint = a})
135-- | The project under which the queue lies
136tiProject :: Lens' TasksInsert' Text
137tiProject
138 = lens _tiProject (\ s a -> s{_tiProject = a})
140-- | IP address of the site where the request originates. Use this if you
141-- want to enforce per-user limits.
142tiUserIP :: Lens' TasksInsert' (Maybe Text)
143tiUserIP = lens _tiUserIP (\ s a -> s{_tiUserIP = a})
145-- | API key. Your API key identifies your project and provides you with API
146-- access, quota, and reports. Required unless you provide an OAuth 2.0
147-- token.
148tiKey :: Lens' TasksInsert' (Maybe Key)
149tiKey = lens _tiKey (\ s a -> s{_tiKey = a})
151-- | Multipart request metadata.
152tiTask :: Lens' TasksInsert' Task
153tiTask = lens _tiTask (\ s a -> s{_tiTask = a})
155-- | OAuth 2.0 token for the current user.
156tiOAuthToken :: Lens' TasksInsert' (Maybe OAuthToken)
157tiOAuthToken
158 = lens _tiOAuthToken (\ s a -> s{_tiOAuthToken = a})
160-- | Selector specifying which fields to include in a partial response.
161tiFields :: Lens' TasksInsert' (Maybe Text)
162tiFields = lens _tiFields (\ s a -> s{_tiFields = a})
164instance GoogleAuth TasksInsert' where
165 authKey = tiKey . _Just
166 authToken = tiOAuthToken . _Just
168instance GoogleRequest TasksInsert' where
169 type Rs TasksInsert' = Task
170 request
171 = requestWithRoute defReq appEngineTaskQueueURL
172 requestWithRoute r u TasksInsert'{..}
173 = go _tiTaskqueue _tiQuotaUser (Just _tiPrettyPrint)
174 _tiProject
175 _tiUserIP
176 _tiKey
177 _tiOAuthToken
178 _tiFields
179 (Just AltJSON)
180 _tiTask
181 where go
182 = clientWithRoute
183 (Proxy :: Proxy TasksInsertResource)
184 r
185 u