@@ -0,0 +1,236 @@
1+{-# LANGUAGE DataKinds #-}
2+{-# LANGUAGE DeriveDataTypeable #-}
3+{-# LANGUAGE DeriveGeneric #-}
4+{-# LANGUAGE FlexibleInstances #-}
5+{-# LANGUAGE NoImplicitPrelude #-}
6+{-# LANGUAGE OverloadedStrings #-}
7+{-# LANGUAGE RecordWildCards #-}
8+{-# LANGUAGE TypeFamilies #-}
9+{-# LANGUAGE TypeOperators #-}
10+
11+{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
12+{-# OPTIONS_GHC -fno-warn-unused-binds #-}
13+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
14+
15+-- |
16+-- Module : Network.Google.Resource.PagespeedOnline.PagespeedAPI.RunPagespeed
17+-- Copyright : (c) 2015 Brendan Hay
18+-- License : Mozilla Public License, v. 2.0.
19+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
20+-- Stability : auto-generated
21+-- Portability : non-portable (GHC extensions)
22+--
23+-- | Runs PageSpeed analysis on the page at the specified URL, and returns
24+-- PageSpeed scores, a list of suggestions to make that page faster, and
25+-- other information.
26+--
27+-- /See:/ <https://developers.google.com/speed/docs/insights/v2/getting-started PageSpeed Insights API Reference> for @PagespeedOnlinePagespeedAPIRunPagespeed@.
28+module Network.Google.Resource.PagespeedOnline.PagespeedAPI.RunPagespeed
29+ (
30+ -- * REST Resource
31+ PagespeedAPIRunPagespeedResource
32+
33+ -- * Creating a Request
34+ , pagespeedAPIRunPagespeed'
35+ , PagespeedAPIRunPagespeed'
36+
37+ -- * Request Lenses
38+ , parpScreenshot
39+ , parpQuotaUser
40+ , parpPrettyPrint
41+ , parpUserIP
42+ , parpLocale
43+ , parpURL
44+ , parpFilterThirdPartyResources
45+ , parpStrategy
46+ , parpRule
47+ , parpKey
48+ , parpOAuthToken
49+ , parpFields
50+ ) where
51+
52+import Network.Google.PageSpeed.Types
53+import Network.Google.Prelude
54+
55+-- | A resource alias for @PagespeedOnlinePagespeedAPIRunPagespeed@ which the
56+-- 'PagespeedAPIRunPagespeed'' request conforms to.
57+type PagespeedAPIRunPagespeedResource =
58+ "runPagespeed" :>
59+ QueryParam "url" Text :>
60+ QueryParam "screenshot" Bool :>
61+ QueryParam "locale" Text :>
62+ QueryParam "filter_third_party_resources" Bool :>
63+ QueryParam "strategy"
64+ PagespeedAPIRunPagespeedStrategy
65+ :>
66+ QueryParams "rule" Text :>
67+ QueryParam "quotaUser" Text :>
68+ QueryParam "prettyPrint" Bool :>
69+ QueryParam "userIp" Text :>
70+ QueryParam "fields" Text :>
71+ QueryParam "key" AuthKey :>
72+ QueryParam "oauth_token" OAuthToken :>
73+ QueryParam "alt" AltJSON :> Get '[JSON] Result
74+
75+-- | Runs PageSpeed analysis on the page at the specified URL, and returns
76+-- PageSpeed scores, a list of suggestions to make that page faster, and
77+-- other information.
78+--
79+-- /See:/ 'pagespeedAPIRunPagespeed'' smart constructor.
80+data PagespeedAPIRunPagespeed' = PagespeedAPIRunPagespeed'
81+ { _parpScreenshot :: !Bool
82+ , _parpQuotaUser :: !(Maybe Text)
83+ , _parpPrettyPrint :: !Bool
84+ , _parpUserIP :: !(Maybe Text)
85+ , _parpLocale :: !(Maybe Text)
86+ , _parpURL :: !Text
87+ , _parpFilterThirdPartyResources :: !Bool
88+ , _parpStrategy :: !(Maybe PagespeedAPIRunPagespeedStrategy)
89+ , _parpRule :: !(Maybe [Text])
90+ , _parpKey :: !(Maybe AuthKey)
91+ , _parpOAuthToken :: !(Maybe OAuthToken)
92+ , _parpFields :: !(Maybe Text)
93+ } deriving (Eq,Show,Data,Typeable,Generic)
94+
95+-- | Creates a value of 'PagespeedAPIRunPagespeed'' with the minimum fields required to make a request.
96+--
97+-- Use one of the following lenses to modify other fields as desired:
98+--
99+-- * 'parpScreenshot'
100+--
101+-- * 'parpQuotaUser'
102+--
103+-- * 'parpPrettyPrint'
104+--
105+-- * 'parpUserIP'
106+--
107+-- * 'parpLocale'
108+--
109+-- * 'parpURL'
110+--
111+-- * 'parpFilterThirdPartyResources'
112+--
113+-- * 'parpStrategy'
114+--
115+-- * 'parpRule'
116+--
117+-- * 'parpKey'
118+--
119+-- * 'parpOAuthToken'
120+--
121+-- * 'parpFields'
122+pagespeedAPIRunPagespeed'
123+ :: Text -- ^ 'url'
124+ -> PagespeedAPIRunPagespeed'
125+pagespeedAPIRunPagespeed' pParpURL_ =
126+ PagespeedAPIRunPagespeed'
127+ { _parpScreenshot = False
128+ , _parpQuotaUser = Nothing
129+ , _parpPrettyPrint = True
130+ , _parpUserIP = Nothing
131+ , _parpLocale = Nothing
132+ , _parpURL = pParpURL_
133+ , _parpFilterThirdPartyResources = False
134+ , _parpStrategy = Nothing
135+ , _parpRule = Nothing
136+ , _parpKey = Nothing
137+ , _parpOAuthToken = Nothing
138+ , _parpFields = Nothing
139+ }
140+
141+-- | Indicates if binary data containing a screenshot should be included
142+parpScreenshot :: Lens' PagespeedAPIRunPagespeed' Bool
143+parpScreenshot
144+ = lens _parpScreenshot
145+ (\ s a -> s{_parpScreenshot = a})
146+
147+-- | Available to use for quota purposes for server-side applications. Can be
148+-- any arbitrary string assigned to a user, but should not exceed 40
149+-- characters. Overrides userIp if both are provided.
150+parpQuotaUser :: Lens' PagespeedAPIRunPagespeed' (Maybe Text)
151+parpQuotaUser
152+ = lens _parpQuotaUser
153+ (\ s a -> s{_parpQuotaUser = a})
154+
155+-- | Returns response with indentations and line breaks.
156+parpPrettyPrint :: Lens' PagespeedAPIRunPagespeed' Bool
157+parpPrettyPrint
158+ = lens _parpPrettyPrint
159+ (\ s a -> s{_parpPrettyPrint = a})
160+
161+-- | IP address of the site where the request originates. Use this if you
162+-- want to enforce per-user limits.
163+parpUserIP :: Lens' PagespeedAPIRunPagespeed' (Maybe Text)
164+parpUserIP
165+ = lens _parpUserIP (\ s a -> s{_parpUserIP = a})
166+
167+-- | The locale used to localize formatted results
168+parpLocale :: Lens' PagespeedAPIRunPagespeed' (Maybe Text)
169+parpLocale
170+ = lens _parpLocale (\ s a -> s{_parpLocale = a})
171+
172+-- | The URL to fetch and analyze
173+parpURL :: Lens' PagespeedAPIRunPagespeed' Text
174+parpURL = lens _parpURL (\ s a -> s{_parpURL = a})
175+
176+-- | Indicates if third party resources should be filtered out before
177+-- PageSpeed analysis.
178+parpFilterThirdPartyResources :: Lens' PagespeedAPIRunPagespeed' Bool
179+parpFilterThirdPartyResources
180+ = lens _parpFilterThirdPartyResources
181+ (\ s a -> s{_parpFilterThirdPartyResources = a})
182+
183+-- | The analysis strategy to use
184+parpStrategy :: Lens' PagespeedAPIRunPagespeed' (Maybe PagespeedAPIRunPagespeedStrategy)
185+parpStrategy
186+ = lens _parpStrategy (\ s a -> s{_parpStrategy = a})
187+
188+-- | A PageSpeed rule to run; if none are given, all rules are run
189+parpRule :: Lens' PagespeedAPIRunPagespeed' [Text]
190+parpRule
191+ = lens _parpRule (\ s a -> s{_parpRule = a}) .
192+ _Default
193+ . _Coerce
194+
195+-- | API key. Your API key identifies your project and provides you with API
196+-- access, quota, and reports. Required unless you provide an OAuth 2.0
197+-- token.
198+parpKey :: Lens' PagespeedAPIRunPagespeed' (Maybe AuthKey)
199+parpKey = lens _parpKey (\ s a -> s{_parpKey = a})
200+
201+-- | OAuth 2.0 token for the current user.
202+parpOAuthToken :: Lens' PagespeedAPIRunPagespeed' (Maybe OAuthToken)
203+parpOAuthToken
204+ = lens _parpOAuthToken
205+ (\ s a -> s{_parpOAuthToken = a})
206+
207+-- | Selector specifying which fields to include in a partial response.
208+parpFields :: Lens' PagespeedAPIRunPagespeed' (Maybe Text)
209+parpFields
210+ = lens _parpFields (\ s a -> s{_parpFields = a})
211+
212+instance GoogleAuth PagespeedAPIRunPagespeed' where
213+ _AuthKey = parpKey . _Just
214+ _AuthToken = parpOAuthToken . _Just
215+
216+instance GoogleRequest PagespeedAPIRunPagespeed'
217+ where
218+ type Rs PagespeedAPIRunPagespeed' = Result
219+ request = requestWith pageSpeedRequest
220+ requestWith rq PagespeedAPIRunPagespeed'{..}
221+ = go (Just _parpURL) (Just _parpScreenshot)
222+ _parpLocale
223+ (Just _parpFilterThirdPartyResources)
224+ _parpStrategy
225+ (_parpRule ^. _Default)
226+ _parpQuotaUser
227+ (Just _parpPrettyPrint)
228+ _parpUserIP
229+ _parpFields
230+ _parpKey
231+ _parpOAuthToken
232+ (Just AltJSON)
233+ where go
234+ = clientBuild
235+ (Proxy :: Proxy PagespeedAPIRunPagespeedResource)
236+ rq