/
GetAPIKeys.hs
204 lines (178 loc) · 6.8 KB
/
GetAPIKeys.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-- Derived from AWS service descriptions, licensed under Apache 2.0.
-- |
-- Module : Network.AWS.APIGateway.GetAPIKeys
-- Copyright : (c) 2013-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets information about the current 'ApiKeys' resource.
--
--
--
-- This operation returns paginated results.
module Network.AWS.APIGateway.GetAPIKeys
(
-- * Creating a Request
getAPIKeys
, GetAPIKeys
-- * Request Lenses
, gakIncludeValues
, gakCustomerId
, gakNameQuery
, gakLimit
, gakPosition
-- * Destructuring the Response
, getAPIKeysResponse
, GetAPIKeysResponse
-- * Response Lenses
, gakrsItems
, gakrsWarnings
, gakrsPosition
, gakrsResponseStatus
) where
import Network.AWS.APIGateway.Types
import Network.AWS.APIGateway.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
-- | A request to get information about the current 'ApiKeys' resource.
--
--
--
-- /See:/ 'getAPIKeys' smart constructor.
data GetAPIKeys = GetAPIKeys'
{ _gakIncludeValues :: !(Maybe Bool)
, _gakCustomerId :: !(Maybe Text)
, _gakNameQuery :: !(Maybe Text)
, _gakLimit :: !(Maybe Int)
, _gakPosition :: !(Maybe Text)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'GetAPIKeys' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'gakIncludeValues' - A boolean flag to specify whether (@true@ ) or not (@false@ ) the result contains key values.
--
-- * 'gakCustomerId' - Undocumented member.
--
-- * 'gakNameQuery' - The name of queried API keys.
--
-- * 'gakLimit' - The maximum number of 'ApiKeys' to get information about.
--
-- * 'gakPosition' - The position of the current 'ApiKeys' resource to get information about.
getAPIKeys
:: GetAPIKeys
getAPIKeys =
GetAPIKeys'
{ _gakIncludeValues = Nothing
, _gakCustomerId = Nothing
, _gakNameQuery = Nothing
, _gakLimit = Nothing
, _gakPosition = Nothing
}
-- | A boolean flag to specify whether (@true@ ) or not (@false@ ) the result contains key values.
gakIncludeValues :: Lens' GetAPIKeys (Maybe Bool)
gakIncludeValues = lens _gakIncludeValues (\ s a -> s{_gakIncludeValues = a});
-- | Undocumented member.
gakCustomerId :: Lens' GetAPIKeys (Maybe Text)
gakCustomerId = lens _gakCustomerId (\ s a -> s{_gakCustomerId = a});
-- | The name of queried API keys.
gakNameQuery :: Lens' GetAPIKeys (Maybe Text)
gakNameQuery = lens _gakNameQuery (\ s a -> s{_gakNameQuery = a});
-- | The maximum number of 'ApiKeys' to get information about.
gakLimit :: Lens' GetAPIKeys (Maybe Int)
gakLimit = lens _gakLimit (\ s a -> s{_gakLimit = a});
-- | The position of the current 'ApiKeys' resource to get information about.
gakPosition :: Lens' GetAPIKeys (Maybe Text)
gakPosition = lens _gakPosition (\ s a -> s{_gakPosition = a});
instance AWSPager GetAPIKeys where
page rq rs
| stop (rs ^. gakrsPosition) = Nothing
| stop (rs ^. gakrsItems) = Nothing
| otherwise =
Just $ rq & gakPosition .~ rs ^. gakrsPosition
instance AWSRequest GetAPIKeys where
type Rs GetAPIKeys = GetAPIKeysResponse
request = get apiGateway
response
= receiveJSON
(\ s h x ->
GetAPIKeysResponse' <$>
(x .?> "item" .!@ mempty) <*>
(x .?> "warnings" .!@ mempty)
<*> (x .?> "position")
<*> (pure (fromEnum s)))
instance Hashable GetAPIKeys
instance NFData GetAPIKeys
instance ToHeaders GetAPIKeys where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToPath GetAPIKeys where
toPath = const "/apikeys"
instance ToQuery GetAPIKeys where
toQuery GetAPIKeys'{..}
= mconcat
["includeValues" =: _gakIncludeValues,
"customerId" =: _gakCustomerId,
"name" =: _gakNameQuery, "limit" =: _gakLimit,
"position" =: _gakPosition]
-- | Represents a collection of API keys as represented by an 'ApiKeys' resource.
--
--
-- <http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-api-keys.html Use API Keys>
--
-- /See:/ 'getAPIKeysResponse' smart constructor.
data GetAPIKeysResponse = GetAPIKeysResponse'
{ _gakrsItems :: !(Maybe [APIKey])
, _gakrsWarnings :: !(Maybe [Text])
, _gakrsPosition :: !(Maybe Text)
, _gakrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'GetAPIKeysResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'gakrsItems' - The current page of any 'ApiKey' resources in the collection of 'ApiKey' resources.
--
-- * 'gakrsWarnings' - A list of warning messages logged during the import of API keys when the @failOnWarnings@ option is set to true.
--
-- * 'gakrsPosition' - Undocumented member.
--
-- * 'gakrsResponseStatus' - -- | The response status code.
getAPIKeysResponse
:: Int -- ^ 'gakrsResponseStatus'
-> GetAPIKeysResponse
getAPIKeysResponse pResponseStatus_ =
GetAPIKeysResponse'
{ _gakrsItems = Nothing
, _gakrsWarnings = Nothing
, _gakrsPosition = Nothing
, _gakrsResponseStatus = pResponseStatus_
}
-- | The current page of any 'ApiKey' resources in the collection of 'ApiKey' resources.
gakrsItems :: Lens' GetAPIKeysResponse [APIKey]
gakrsItems = lens _gakrsItems (\ s a -> s{_gakrsItems = a}) . _Default . _Coerce;
-- | A list of warning messages logged during the import of API keys when the @failOnWarnings@ option is set to true.
gakrsWarnings :: Lens' GetAPIKeysResponse [Text]
gakrsWarnings = lens _gakrsWarnings (\ s a -> s{_gakrsWarnings = a}) . _Default . _Coerce;
-- | Undocumented member.
gakrsPosition :: Lens' GetAPIKeysResponse (Maybe Text)
gakrsPosition = lens _gakrsPosition (\ s a -> s{_gakrsPosition = a});
-- | -- | The response status code.
gakrsResponseStatus :: Lens' GetAPIKeysResponse Int
gakrsResponseStatus = lens _gakrsResponseStatus (\ s a -> s{_gakrsResponseStatus = a});
instance NFData GetAPIKeysResponse