@@ -0,0 +1,1434 @@
1+{-# LANGUAGE DeriveDataTypeable #-}
2+{-# LANGUAGE DeriveGeneric #-}
3+{-# LANGUAGE NoImplicitPrelude #-}
4+{-# LANGUAGE OverloadedStrings #-}
5+{-# LANGUAGE RecordWildCards #-}
6+
7+{-# OPTIONS_GHC -fno-warn-unused-binds #-}
8+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
9+
10+-- |
11+-- Module : Network.Google.ServiceControl.Types.Product
12+-- Copyright : (c) 2015-2016 Brendan Hay
13+-- License : Mozilla Public License, v. 2.0.
14+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
15+-- Stability : auto-generated
16+-- Portability : non-portable (GHC extensions)
17+--
18+module Network.Google.ServiceControl.Types.Product where
19+
20+import Network.Google.Prelude
21+import Network.Google.ServiceControl.Types.Sum
22+
23+-- | The \`Status\` type defines a logical error model that is suitable for
24+-- different programming environments, including REST APIs and RPC APIs. It
25+-- is used by [gRPC](https:\/\/github.com\/grpc). The error model is
26+-- designed to be: - Simple to use and understand for most users - Flexible
27+-- enough to meet unexpected needs # Overview The \`Status\` message
28+-- contains three pieces of data: error code, error message, and error
29+-- details. The error code should be an enum value of google.rpc.Code, but
30+-- it may accept additional error codes if needed. The error message should
31+-- be a developer-facing English message that helps developers *understand*
32+-- and *resolve* the error. If a localized user-facing error message is
33+-- needed, put the localized message in the error details or localize it in
34+-- the client. The optional error details may contain arbitrary information
35+-- about the error. There is a predefined set of error detail types in the
36+-- package \`google.rpc\` which can be used for common error conditions. #
37+-- Language mapping The \`Status\` message is the logical representation of
38+-- the error model, but it is not necessarily the actual wire format. When
39+-- the \`Status\` message is exposed in different client libraries and
40+-- different wire protocols, it can be mapped differently. For example, it
41+-- will likely be mapped to some exceptions in Java, but more likely mapped
42+-- to some error codes in C. # Other uses The error model and the
43+-- \`Status\` message can be used in a variety of environments, either with
44+-- or without APIs, to provide a consistent developer experience across
45+-- different environments. Example uses of this error model include: -
46+-- Partial errors. If a service needs to return partial errors to the
47+-- client, it may embed the \`Status\` in the normal response to indicate
48+-- the partial errors. - Workflow errors. A typical workflow has multiple
49+-- steps. Each step may have a \`Status\` message for error reporting
50+-- purpose. - Batch operations. If a client uses batch request and batch
51+-- response, the \`Status\` message should be used directly inside batch
52+-- response, one for each error sub-response. - Asynchronous operations. If
53+-- an API call embeds asynchronous operation results in its response, the
54+-- status of those operations should be represented directly using the
55+-- \`Status\` message. - Logging. If some API errors are stored in logs,
56+-- the message \`Status\` could be used directly after any stripping needed
57+-- for security\/privacy reasons.
58+--
59+-- /See:/ 'status' smart constructor.
60+data Status = Status'
61+ { _sDetails :: !(Maybe [StatusDetailsItem])
62+ , _sCode :: !(Maybe (Textual Int32))
63+ , _sMessage :: !(Maybe Text)
64+ } deriving (Eq,Show,Data,Typeable,Generic)
65+
66+-- | Creates a value of 'Status' with the minimum fields required to make a request.
67+--
68+-- Use one of the following lenses to modify other fields as desired:
69+--
70+-- * 'sDetails'
71+--
72+-- * 'sCode'
73+--
74+-- * 'sMessage'
75+status
76+ :: Status
77+status =
78+ Status'
79+ { _sDetails = Nothing
80+ , _sCode = Nothing
81+ , _sMessage = Nothing
82+ }
83+
84+-- | A list of messages that carry the error details. There will be a common
85+-- set of message types for APIs to use.
86+sDetails :: Lens' Status [StatusDetailsItem]
87+sDetails
88+ = lens _sDetails (\ s a -> s{_sDetails = a}) .
89+ _Default
90+ . _Coerce
91+
92+-- | The status code, which should be an enum value of google.rpc.Code.
93+sCode :: Lens' Status (Maybe Int32)
94+sCode
95+ = lens _sCode (\ s a -> s{_sCode = a}) .
96+ mapping _Coerce
97+
98+-- | A developer-facing error message, which should be in English. Any
99+-- user-facing error message should be localized and sent in the
100+-- google.rpc.Status.details field, or localized by the client.
101+sMessage :: Lens' Status (Maybe Text)
102+sMessage = lens _sMessage (\ s a -> s{_sMessage = a})
103+
104+instance FromJSON Status where
105+ parseJSON
106+ = withObject "Status"
107+ (\ o ->
108+ Status' <$>
109+ (o .:? "details" .!= mempty) <*> (o .:? "code") <*>
110+ (o .:? "message"))
111+
112+instance ToJSON Status where
113+ toJSON Status'{..}
114+ = object
115+ (catMaybes
116+ [("details" .=) <$> _sDetails,
117+ ("code" .=) <$> _sCode,
118+ ("message" .=) <$> _sMessage])
119+
120+-- | Request message for the Report method.
121+--
122+-- /See:/ 'reportRequest' smart constructor.
123+newtype ReportRequest = ReportRequest'
124+ { _rrOperations :: Maybe [Operation]
125+ } deriving (Eq,Show,Data,Typeable,Generic)
126+
127+-- | Creates a value of 'ReportRequest' with the minimum fields required to make a request.
128+--
129+-- Use one of the following lenses to modify other fields as desired:
130+--
131+-- * 'rrOperations'
132+reportRequest
133+ :: ReportRequest
134+reportRequest =
135+ ReportRequest'
136+ { _rrOperations = Nothing
137+ }
138+
139+-- | Operations to be reported. Typically the service should report one
140+-- operation per request. Putting multiple operations into a single request
141+-- is allowed, but should be used only when multiple operations are
142+-- natually available at the time of the report. If multiple operations are
143+-- in a single request, the total request size should be no larger than
144+-- 1MB. See ReportResponse.report_errors for partial failure behavior.
145+rrOperations :: Lens' ReportRequest [Operation]
146+rrOperations
147+ = lens _rrOperations (\ s a -> s{_rrOperations = a})
148+ . _Default
149+ . _Coerce
150+
151+instance FromJSON ReportRequest where
152+ parseJSON
153+ = withObject "ReportRequest"
154+ (\ o ->
155+ ReportRequest' <$> (o .:? "operations" .!= mempty))
156+
157+instance ToJSON ReportRequest where
158+ toJSON ReportRequest'{..}
159+ = object
160+ (catMaybes [("operations" .=) <$> _rrOperations])
161+
162+-- | Request message for the Check method.
163+--
164+-- /See:/ 'checkRequest' smart constructor.
165+newtype CheckRequest = CheckRequest'
166+ { _crOperation :: Maybe Operation
167+ } deriving (Eq,Show,Data,Typeable,Generic)
168+
169+-- | Creates a value of 'CheckRequest' with the minimum fields required to make a request.
170+--
171+-- Use one of the following lenses to modify other fields as desired:
172+--
173+-- * 'crOperation'
174+checkRequest
175+ :: CheckRequest
176+checkRequest =
177+ CheckRequest'
178+ { _crOperation = Nothing
179+ }
180+
181+-- | The operation to be checked.
182+crOperation :: Lens' CheckRequest (Maybe Operation)
183+crOperation
184+ = lens _crOperation (\ s a -> s{_crOperation = a})
185+
186+instance FromJSON CheckRequest where
187+ parseJSON
188+ = withObject "CheckRequest"
189+ (\ o -> CheckRequest' <$> (o .:? "operation"))
190+
191+instance ToJSON CheckRequest where
192+ toJSON CheckRequest'{..}
193+ = object
194+ (catMaybes [("operation" .=) <$> _crOperation])
195+
196+-- | The labels describing the metric value. See comments on
197+-- google.api.servicecontrol.v1.Operation.labels for the overriding
198+-- relationship.
199+--
200+-- /See:/ 'metricValueLabels' smart constructor.
201+newtype MetricValueLabels = MetricValueLabels'
202+ { _mvlAddtional :: HashMap Text Text
203+ } deriving (Eq,Show,Data,Typeable,Generic)
204+
205+-- | Creates a value of 'MetricValueLabels' with the minimum fields required to make a request.
206+--
207+-- Use one of the following lenses to modify other fields as desired:
208+--
209+-- * 'mvlAddtional'
210+metricValueLabels
211+ :: HashMap Text Text -- ^ 'mvlAddtional'
212+ -> MetricValueLabels
213+metricValueLabels pMvlAddtional_ =
214+ MetricValueLabels'
215+ { _mvlAddtional = _Coerce # pMvlAddtional_
216+ }
217+
218+mvlAddtional :: Lens' MetricValueLabels (HashMap Text Text)
219+mvlAddtional
220+ = lens _mvlAddtional (\ s a -> s{_mvlAddtional = a})
221+ . _Coerce
222+
223+instance FromJSON MetricValueLabels where
224+ parseJSON
225+ = withObject "MetricValueLabels"
226+ (\ o -> MetricValueLabels' <$> (parseJSONObject o))
227+
228+instance ToJSON MetricValueLabels where
229+ toJSON = toJSON . _mvlAddtional
230+
231+-- | Distribution represents a frequency distribution of double-valued sample
232+-- points. It contains the size of the population of sample points plus
233+-- additional optional information: - the arithmetic mean of the samples -
234+-- the minimum and maximum of the samples - the sum-squared-deviation of
235+-- the samples, used to compute variance - a histogram of the values of the
236+-- sample points
237+--
238+-- /See:/ 'distribution' smart constructor.
239+data Distribution = Distribution'
240+ { _dSumOfSquaredDeviation :: !(Maybe (Textual Double))
241+ , _dMean :: !(Maybe (Textual Double))
242+ , _dExponentialBuckets :: !(Maybe ExponentialBuckets)
243+ , _dMaximum :: !(Maybe (Textual Double))
244+ , _dLinearBuckets :: !(Maybe LinearBuckets)
245+ , _dCount :: !(Maybe (Textual Int64))
246+ , _dMinimum :: !(Maybe (Textual Double))
247+ , _dBucketCounts :: !(Maybe [Textual Int64])
248+ , _dExplicitBuckets :: !(Maybe ExplicitBuckets)
249+ } deriving (Eq,Show,Data,Typeable,Generic)
250+
251+-- | Creates a value of 'Distribution' with the minimum fields required to make a request.
252+--
253+-- Use one of the following lenses to modify other fields as desired:
254+--
255+-- * 'dSumOfSquaredDeviation'
256+--
257+-- * 'dMean'
258+--
259+-- * 'dExponentialBuckets'
260+--
261+-- * 'dMaximum'
262+--
263+-- * 'dLinearBuckets'
264+--
265+-- * 'dCount'
266+--
267+-- * 'dMinimum'
268+--
269+-- * 'dBucketCounts'
270+--
271+-- * 'dExplicitBuckets'
272+distribution
273+ :: Distribution
274+distribution =
275+ Distribution'
276+ { _dSumOfSquaredDeviation = Nothing
277+ , _dMean = Nothing
278+ , _dExponentialBuckets = Nothing
279+ , _dMaximum = Nothing
280+ , _dLinearBuckets = Nothing
281+ , _dCount = Nothing
282+ , _dMinimum = Nothing
283+ , _dBucketCounts = Nothing
284+ , _dExplicitBuckets = Nothing
285+ }
286+
287+-- | The sum of squared deviations from the mean: Sum[i=1..count]((x_i -
288+-- mean)^2) where each x_i is a sample values. If \`count\` is zero then
289+-- this field must be zero, otherwise validation of the request fails.
290+dSumOfSquaredDeviation :: Lens' Distribution (Maybe Double)
291+dSumOfSquaredDeviation
292+ = lens _dSumOfSquaredDeviation
293+ (\ s a -> s{_dSumOfSquaredDeviation = a})
294+ . mapping _Coerce
295+
296+-- | The arithmetic mean of the samples in the distribution. If \`count\` is
297+-- zero then this field must be zero.
298+dMean :: Lens' Distribution (Maybe Double)
299+dMean
300+ = lens _dMean (\ s a -> s{_dMean = a}) .
301+ mapping _Coerce
302+
303+-- | Buckets with exponentially growing width.
304+dExponentialBuckets :: Lens' Distribution (Maybe ExponentialBuckets)
305+dExponentialBuckets
306+ = lens _dExponentialBuckets
307+ (\ s a -> s{_dExponentialBuckets = a})
308+
309+-- | The maximum of the population of values. Ignored if \`count\` is zero.
310+dMaximum :: Lens' Distribution (Maybe Double)
311+dMaximum
312+ = lens _dMaximum (\ s a -> s{_dMaximum = a}) .
313+ mapping _Coerce
314+
315+-- | Buckets with constant width.
316+dLinearBuckets :: Lens' Distribution (Maybe LinearBuckets)
317+dLinearBuckets
318+ = lens _dLinearBuckets
319+ (\ s a -> s{_dLinearBuckets = a})
320+
321+-- | The total number of samples in the distribution. Must be >= 0.
322+dCount :: Lens' Distribution (Maybe Int64)
323+dCount
324+ = lens _dCount (\ s a -> s{_dCount = a}) .
325+ mapping _Coerce
326+
327+-- | The minimum of the population of values. Ignored if \`count\` is zero.
328+dMinimum :: Lens' Distribution (Maybe Double)
329+dMinimum
330+ = lens _dMinimum (\ s a -> s{_dMinimum = a}) .
331+ mapping _Coerce
332+
333+-- | The number of samples in each histogram bucket. \`bucket_counts\` are
334+-- optional. If present, they must sum to the \`count\` value. The buckets
335+-- are defined below in \`bucket_option\`. There are N buckets.
336+-- \`bucket_counts[0]\` is the number of samples in the underflow bucket.
337+-- \`bucket_counts[1]\` to \`bucket_counts[N-1]\` are the numbers of
338+-- samples in each of the finite buckets. And \`bucket_counts[N] is the
339+-- number of samples in the overflow bucket. See the comments of
340+-- \`bucket_option\` below for more details. Any suffix of trailing zeros
341+-- may be omitted.
342+dBucketCounts :: Lens' Distribution [Int64]
343+dBucketCounts
344+ = lens _dBucketCounts
345+ (\ s a -> s{_dBucketCounts = a})
346+ . _Default
347+ . _Coerce
348+
349+-- | Buckets with arbitrary user-provided width.
350+dExplicitBuckets :: Lens' Distribution (Maybe ExplicitBuckets)
351+dExplicitBuckets
352+ = lens _dExplicitBuckets
353+ (\ s a -> s{_dExplicitBuckets = a})
354+
355+instance FromJSON Distribution where
356+ parseJSON
357+ = withObject "Distribution"
358+ (\ o ->
359+ Distribution' <$>
360+ (o .:? "sumOfSquaredDeviation") <*> (o .:? "mean")
361+ <*> (o .:? "exponentialBuckets")
362+ <*> (o .:? "maximum")
363+ <*> (o .:? "linearBuckets")
364+ <*> (o .:? "count")
365+ <*> (o .:? "minimum")
366+ <*> (o .:? "bucketCounts" .!= mempty)
367+ <*> (o .:? "explicitBuckets"))
368+
369+instance ToJSON Distribution where
370+ toJSON Distribution'{..}
371+ = object
372+ (catMaybes
373+ [("sumOfSquaredDeviation" .=) <$>
374+ _dSumOfSquaredDeviation,
375+ ("mean" .=) <$> _dMean,
376+ ("exponentialBuckets" .=) <$> _dExponentialBuckets,
377+ ("maximum" .=) <$> _dMaximum,
378+ ("linearBuckets" .=) <$> _dLinearBuckets,
379+ ("count" .=) <$> _dCount,
380+ ("minimum" .=) <$> _dMinimum,
381+ ("bucketCounts" .=) <$> _dBucketCounts,
382+ ("explicitBuckets" .=) <$> _dExplicitBuckets])
383+
384+-- | Describing buckets with exponentially growing width.
385+--
386+-- /See:/ 'exponentialBuckets' smart constructor.
387+data ExponentialBuckets = ExponentialBuckets'
388+ { _ebGrowthFactor :: !(Maybe (Textual Double))
389+ , _ebScale :: !(Maybe (Textual Double))
390+ , _ebNumFiniteBuckets :: !(Maybe (Textual Int32))
391+ } deriving (Eq,Show,Data,Typeable,Generic)
392+
393+-- | Creates a value of 'ExponentialBuckets' with the minimum fields required to make a request.
394+--
395+-- Use one of the following lenses to modify other fields as desired:
396+--
397+-- * 'ebGrowthFactor'
398+--
399+-- * 'ebScale'
400+--
401+-- * 'ebNumFiniteBuckets'
402+exponentialBuckets
403+ :: ExponentialBuckets
404+exponentialBuckets =
405+ ExponentialBuckets'
406+ { _ebGrowthFactor = Nothing
407+ , _ebScale = Nothing
408+ , _ebNumFiniteBuckets = Nothing
409+ }
410+
411+-- | The i\'th exponential bucket covers the interval [scale *
412+-- growth_factor^(i-1), scale * growth_factor^i) where i ranges from 1 to
413+-- num_finite_buckets inclusive. Must be larger than 1.0.
414+ebGrowthFactor :: Lens' ExponentialBuckets (Maybe Double)
415+ebGrowthFactor
416+ = lens _ebGrowthFactor
417+ (\ s a -> s{_ebGrowthFactor = a})
418+ . mapping _Coerce
419+
420+-- | The i\'th exponential bucket covers the interval [scale *
421+-- growth_factor^(i-1), scale * growth_factor^i) where i ranges from 1 to
422+-- num_finite_buckets inclusive. Must be > 0.
423+ebScale :: Lens' ExponentialBuckets (Maybe Double)
424+ebScale
425+ = lens _ebScale (\ s a -> s{_ebScale = a}) .
426+ mapping _Coerce
427+
428+-- | The number of finite buckets. With the underflow and overflow buckets,
429+-- the total number of buckets is \`num_finite_buckets\` + 2. See comments
430+-- on \`bucket_options\` for details.
431+ebNumFiniteBuckets :: Lens' ExponentialBuckets (Maybe Int32)
432+ebNumFiniteBuckets
433+ = lens _ebNumFiniteBuckets
434+ (\ s a -> s{_ebNumFiniteBuckets = a})
435+ . mapping _Coerce
436+
437+instance FromJSON ExponentialBuckets where
438+ parseJSON
439+ = withObject "ExponentialBuckets"
440+ (\ o ->
441+ ExponentialBuckets' <$>
442+ (o .:? "growthFactor") <*> (o .:? "scale") <*>
443+ (o .:? "numFiniteBuckets"))
444+
445+instance ToJSON ExponentialBuckets where
446+ toJSON ExponentialBuckets'{..}
447+ = object
448+ (catMaybes
449+ [("growthFactor" .=) <$> _ebGrowthFactor,
450+ ("scale" .=) <$> _ebScale,
451+ ("numFiniteBuckets" .=) <$> _ebNumFiniteBuckets])
452+
453+-- | Represents information regarding an operation.
454+--
455+-- /See:/ 'operation' smart constructor.
456+data Operation = Operation'
457+ { _oImportance :: !(Maybe OperationImportance)
458+ , _oStartTime :: !(Maybe DateTime')
459+ , _oEndTime :: !(Maybe DateTime')
460+ , _oOperationName :: !(Maybe Text)
461+ , _oLabels :: !(Maybe OperationLabels)
462+ , _oOperationId :: !(Maybe Text)
463+ , _oConsumerId :: !(Maybe Text)
464+ , _oMetricValueSets :: !(Maybe [MetricValueSet])
465+ , _oLogEntries :: !(Maybe [LogEntry])
466+ } deriving (Eq,Show,Data,Typeable,Generic)
467+
468+-- | Creates a value of 'Operation' with the minimum fields required to make a request.
469+--
470+-- Use one of the following lenses to modify other fields as desired:
471+--
472+-- * 'oImportance'
473+--
474+-- * 'oStartTime'
475+--
476+-- * 'oEndTime'
477+--
478+-- * 'oOperationName'
479+--
480+-- * 'oLabels'
481+--
482+-- * 'oOperationId'
483+--
484+-- * 'oConsumerId'
485+--
486+-- * 'oMetricValueSets'
487+--
488+-- * 'oLogEntries'
489+operation
490+ :: Operation
491+operation =
492+ Operation'
493+ { _oImportance = Nothing
494+ , _oStartTime = Nothing
495+ , _oEndTime = Nothing
496+ , _oOperationName = Nothing
497+ , _oLabels = Nothing
498+ , _oOperationId = Nothing
499+ , _oConsumerId = Nothing
500+ , _oMetricValueSets = Nothing
501+ , _oLogEntries = Nothing
502+ }
503+
504+-- | DO NOT USE. This is an experimental field.
505+oImportance :: Lens' Operation (Maybe OperationImportance)
506+oImportance
507+ = lens _oImportance (\ s a -> s{_oImportance = a})
508+
509+-- | Required. Start time of the operation.
510+oStartTime :: Lens' Operation (Maybe UTCTime)
511+oStartTime
512+ = lens _oStartTime (\ s a -> s{_oStartTime = a}) .
513+ mapping _DateTime
514+
515+-- | End time of the operation. Required when the operation is used in
516+-- ServiceController.Report, but optional when the operation is used in
517+-- ServiceController.Check.
518+oEndTime :: Lens' Operation (Maybe UTCTime)
519+oEndTime
520+ = lens _oEndTime (\ s a -> s{_oEndTime = a}) .
521+ mapping _DateTime
522+
523+-- | Fully qualified name of the operation. Reserved for future use.
524+oOperationName :: Lens' Operation (Maybe Text)
525+oOperationName
526+ = lens _oOperationName
527+ (\ s a -> s{_oOperationName = a})
528+
529+-- | Labels describing the operation. Only the following labels are allowed:
530+-- - Labels describing monitored resources as defined in the service
531+-- configuration. - Default labels of metric values. When specified, labels
532+-- defined in the metric value override these default. - The following
533+-- labels defined by Google Cloud Platform: -
534+-- \`cloud.googleapis.com\/location\` describing the location where the
535+-- operation happened, - \`servicecontrol.googleapis.com\/user_agent\`
536+-- describing the user agent of the API request, -
537+-- \`servicecontrol.googleapis.com\/service_agent\` describing the service
538+-- used to handle the API request (e.g. ESP), -
539+-- \`servicecontrol.googleapis.com\/platform\` describing the platform
540+-- where the API is served (e.g. GAE, GCE, GKE).
541+oLabels :: Lens' Operation (Maybe OperationLabels)
542+oLabels = lens _oLabels (\ s a -> s{_oLabels = a})
543+
544+-- | Identity of the operation. This must be unique within the scope of the
545+-- service that generated the operation. If the service calls Check() and
546+-- Report() on the same operation, the two calls should carry the same id.
547+-- UUID version 4 is recommended, though not required. In scenarios where
548+-- an operation is computed from existing information and an idempotent id
549+-- is desirable for deduplication purpose, UUID version 5 is recommended.
550+-- See RFC 4122 for details.
551+oOperationId :: Lens' Operation (Maybe Text)
552+oOperationId
553+ = lens _oOperationId (\ s a -> s{_oOperationId = a})
554+
555+-- | Identity of the consumer who is using the service. This field should be
556+-- filled in for the operations initiated by a consumer, but not for
557+-- service-initiated operations that are not related to a specific
558+-- consumer. This can be in one of the following formats: project:,
559+-- project_number:, api_key:.
560+oConsumerId :: Lens' Operation (Maybe Text)
561+oConsumerId
562+ = lens _oConsumerId (\ s a -> s{_oConsumerId = a})
563+
564+-- | Represents information about this operation. Each MetricValueSet
565+-- corresponds to a metric defined in the service configuration. The data
566+-- type used in the MetricValueSet must agree with the data type specified
567+-- in the metric definition. Within a single operation, it is not allowed
568+-- to have more than one MetricValue instances that have the same metric
569+-- names and identical label value combinations. If a request has such
570+-- duplicated MetricValue instances, the entire request is rejected with an
571+-- invalid argument error.
572+oMetricValueSets :: Lens' Operation [MetricValueSet]
573+oMetricValueSets
574+ = lens _oMetricValueSets
575+ (\ s a -> s{_oMetricValueSets = a})
576+ . _Default
577+ . _Coerce
578+
579+-- | Represents information to be logged.
580+oLogEntries :: Lens' Operation [LogEntry]
581+oLogEntries
582+ = lens _oLogEntries (\ s a -> s{_oLogEntries = a}) .
583+ _Default
584+ . _Coerce
585+
586+instance FromJSON Operation where
587+ parseJSON
588+ = withObject "Operation"
589+ (\ o ->
590+ Operation' <$>
591+ (o .:? "importance") <*> (o .:? "startTime") <*>
592+ (o .:? "endTime")
593+ <*> (o .:? "operationName")
594+ <*> (o .:? "labels")
595+ <*> (o .:? "operationId")
596+ <*> (o .:? "consumerId")
597+ <*> (o .:? "metricValueSets" .!= mempty)
598+ <*> (o .:? "logEntries" .!= mempty))
599+
600+instance ToJSON Operation where
601+ toJSON Operation'{..}
602+ = object
603+ (catMaybes
604+ [("importance" .=) <$> _oImportance,
605+ ("startTime" .=) <$> _oStartTime,
606+ ("endTime" .=) <$> _oEndTime,
607+ ("operationName" .=) <$> _oOperationName,
608+ ("labels" .=) <$> _oLabels,
609+ ("operationId" .=) <$> _oOperationId,
610+ ("consumerId" .=) <$> _oConsumerId,
611+ ("metricValueSets" .=) <$> _oMetricValueSets,
612+ ("logEntries" .=) <$> _oLogEntries])
613+
614+-- | Represents a set of metric values in the same metric. Each metric value
615+-- in the set should have a unique combination of start time, end time, and
616+-- label values.
617+--
618+-- /See:/ 'metricValueSet' smart constructor.
619+data MetricValueSet = MetricValueSet'
620+ { _mvsMetricName :: !(Maybe Text)
621+ , _mvsMetricValues :: !(Maybe [MetricValue])
622+ } deriving (Eq,Show,Data,Typeable,Generic)
623+
624+-- | Creates a value of 'MetricValueSet' with the minimum fields required to make a request.
625+--
626+-- Use one of the following lenses to modify other fields as desired:
627+--
628+-- * 'mvsMetricName'
629+--
630+-- * 'mvsMetricValues'
631+metricValueSet
632+ :: MetricValueSet
633+metricValueSet =
634+ MetricValueSet'
635+ { _mvsMetricName = Nothing
636+ , _mvsMetricValues = Nothing
637+ }
638+
639+-- | The metric name defined in the service configuration.
640+mvsMetricName :: Lens' MetricValueSet (Maybe Text)
641+mvsMetricName
642+ = lens _mvsMetricName
643+ (\ s a -> s{_mvsMetricName = a})
644+
645+-- | The values in this metric.
646+mvsMetricValues :: Lens' MetricValueSet [MetricValue]
647+mvsMetricValues
648+ = lens _mvsMetricValues
649+ (\ s a -> s{_mvsMetricValues = a})
650+ . _Default
651+ . _Coerce
652+
653+instance FromJSON MetricValueSet where
654+ parseJSON
655+ = withObject "MetricValueSet"
656+ (\ o ->
657+ MetricValueSet' <$>
658+ (o .:? "metricName") <*>
659+ (o .:? "metricValues" .!= mempty))
660+
661+instance ToJSON MetricValueSet where
662+ toJSON MetricValueSet'{..}
663+ = object
664+ (catMaybes
665+ [("metricName" .=) <$> _mvsMetricName,
666+ ("metricValues" .=) <$> _mvsMetricValues])
667+
668+-- | A set of user-defined (key, value) data that provides additional
669+-- information about the log entry.
670+--
671+-- /See:/ 'logEntryLabels' smart constructor.
672+newtype LogEntryLabels = LogEntryLabels'
673+ { _lelAddtional :: HashMap Text Text
674+ } deriving (Eq,Show,Data,Typeable,Generic)
675+
676+-- | Creates a value of 'LogEntryLabels' with the minimum fields required to make a request.
677+--
678+-- Use one of the following lenses to modify other fields as desired:
679+--
680+-- * 'lelAddtional'
681+logEntryLabels
682+ :: HashMap Text Text -- ^ 'lelAddtional'
683+ -> LogEntryLabels
684+logEntryLabels pLelAddtional_ =
685+ LogEntryLabels'
686+ { _lelAddtional = _Coerce # pLelAddtional_
687+ }
688+
689+lelAddtional :: Lens' LogEntryLabels (HashMap Text Text)
690+lelAddtional
691+ = lens _lelAddtional (\ s a -> s{_lelAddtional = a})
692+ . _Coerce
693+
694+instance FromJSON LogEntryLabels where
695+ parseJSON
696+ = withObject "LogEntryLabels"
697+ (\ o -> LogEntryLabels' <$> (parseJSONObject o))
698+
699+instance ToJSON LogEntryLabels where
700+ toJSON = toJSON . _lelAddtional
701+
702+-- | The log entry payload, represented as a protocol buffer that is
703+-- expressed as a JSON object. You can only pass \`protoPayload\` values
704+-- that belong to a set of approved types.
705+--
706+-- /See:/ 'logEntryProtoPayload' smart constructor.
707+newtype LogEntryProtoPayload = LogEntryProtoPayload'
708+ { _leppAddtional :: HashMap Text JSONValue
709+ } deriving (Eq,Show,Data,Typeable,Generic)
710+
711+-- | Creates a value of 'LogEntryProtoPayload' with the minimum fields required to make a request.
712+--
713+-- Use one of the following lenses to modify other fields as desired:
714+--
715+-- * 'leppAddtional'
716+logEntryProtoPayload
717+ :: HashMap Text JSONValue -- ^ 'leppAddtional'
718+ -> LogEntryProtoPayload
719+logEntryProtoPayload pLeppAddtional_ =
720+ LogEntryProtoPayload'
721+ { _leppAddtional = _Coerce # pLeppAddtional_
722+ }
723+
724+-- | Properties of the object. Contains field \'type with type URL.
725+leppAddtional :: Lens' LogEntryProtoPayload (HashMap Text JSONValue)
726+leppAddtional
727+ = lens _leppAddtional
728+ (\ s a -> s{_leppAddtional = a})
729+ . _Coerce
730+
731+instance FromJSON LogEntryProtoPayload where
732+ parseJSON
733+ = withObject "LogEntryProtoPayload"
734+ (\ o ->
735+ LogEntryProtoPayload' <$> (parseJSONObject o))
736+
737+instance ToJSON LogEntryProtoPayload where
738+ toJSON = toJSON . _leppAddtional
739+
740+-- | Describing buckets with constant width.
741+--
742+-- /See:/ 'linearBuckets' smart constructor.
743+data LinearBuckets = LinearBuckets'
744+ { _lbOffSet :: !(Maybe (Textual Double))
745+ , _lbWidth :: !(Maybe (Textual Double))
746+ , _lbNumFiniteBuckets :: !(Maybe (Textual Int32))
747+ } deriving (Eq,Show,Data,Typeable,Generic)
748+
749+-- | Creates a value of 'LinearBuckets' with the minimum fields required to make a request.
750+--
751+-- Use one of the following lenses to modify other fields as desired:
752+--
753+-- * 'lbOffSet'
754+--
755+-- * 'lbWidth'
756+--
757+-- * 'lbNumFiniteBuckets'
758+linearBuckets
759+ :: LinearBuckets
760+linearBuckets =
761+ LinearBuckets'
762+ { _lbOffSet = Nothing
763+ , _lbWidth = Nothing
764+ , _lbNumFiniteBuckets = Nothing
765+ }
766+
767+-- | The i\'th linear bucket covers the interval [offset + (i-1) * width,
768+-- offset + i * width) where i ranges from 1 to num_finite_buckets,
769+-- inclusive.
770+lbOffSet :: Lens' LinearBuckets (Maybe Double)
771+lbOffSet
772+ = lens _lbOffSet (\ s a -> s{_lbOffSet = a}) .
773+ mapping _Coerce
774+
775+-- | The i\'th linear bucket covers the interval [offset + (i-1) * width,
776+-- offset + i * width) where i ranges from 1 to num_finite_buckets,
777+-- inclusive. Must be strictly positive.
778+lbWidth :: Lens' LinearBuckets (Maybe Double)
779+lbWidth
780+ = lens _lbWidth (\ s a -> s{_lbWidth = a}) .
781+ mapping _Coerce
782+
783+-- | The number of finite buckets. With the underflow and overflow buckets,
784+-- the total number of buckets is \`num_finite_buckets\` + 2. See comments
785+-- on \`bucket_options\` for details.
786+lbNumFiniteBuckets :: Lens' LinearBuckets (Maybe Int32)
787+lbNumFiniteBuckets
788+ = lens _lbNumFiniteBuckets
789+ (\ s a -> s{_lbNumFiniteBuckets = a})
790+ . mapping _Coerce
791+
792+instance FromJSON LinearBuckets where
793+ parseJSON
794+ = withObject "LinearBuckets"
795+ (\ o ->
796+ LinearBuckets' <$>
797+ (o .:? "offset") <*> (o .:? "width") <*>
798+ (o .:? "numFiniteBuckets"))
799+
800+instance ToJSON LinearBuckets where
801+ toJSON LinearBuckets'{..}
802+ = object
803+ (catMaybes
804+ [("offset" .=) <$> _lbOffSet,
805+ ("width" .=) <$> _lbWidth,
806+ ("numFiniteBuckets" .=) <$> _lbNumFiniteBuckets])
807+
808+--
809+-- /See:/ 'statusDetailsItem' smart constructor.
810+newtype StatusDetailsItem = StatusDetailsItem'
811+ { _sdiAddtional :: HashMap Text JSONValue
812+ } deriving (Eq,Show,Data,Typeable,Generic)
813+
814+-- | Creates a value of 'StatusDetailsItem' with the minimum fields required to make a request.
815+--
816+-- Use one of the following lenses to modify other fields as desired:
817+--
818+-- * 'sdiAddtional'
819+statusDetailsItem
820+ :: HashMap Text JSONValue -- ^ 'sdiAddtional'
821+ -> StatusDetailsItem
822+statusDetailsItem pSdiAddtional_ =
823+ StatusDetailsItem'
824+ { _sdiAddtional = _Coerce # pSdiAddtional_
825+ }
826+
827+-- | Properties of the object. Contains field \'type with type URL.
828+sdiAddtional :: Lens' StatusDetailsItem (HashMap Text JSONValue)
829+sdiAddtional
830+ = lens _sdiAddtional (\ s a -> s{_sdiAddtional = a})
831+ . _Coerce
832+
833+instance FromJSON StatusDetailsItem where
834+ parseJSON
835+ = withObject "StatusDetailsItem"
836+ (\ o -> StatusDetailsItem' <$> (parseJSONObject o))
837+
838+instance ToJSON StatusDetailsItem where
839+ toJSON = toJSON . _sdiAddtional
840+
841+-- | Defines the errors to be returned in
842+-- google.api.servicecontrol.v1.CheckResponse.check_errors.
843+--
844+-- /See:/ 'checkError' smart constructor.
845+data CheckError = CheckError'
846+ { _ceCode :: !(Maybe CheckErrorCode)
847+ , _ceDetail :: !(Maybe Text)
848+ } deriving (Eq,Show,Data,Typeable,Generic)
849+
850+-- | Creates a value of 'CheckError' with the minimum fields required to make a request.
851+--
852+-- Use one of the following lenses to modify other fields as desired:
853+--
854+-- * 'ceCode'
855+--
856+-- * 'ceDetail'
857+checkError
858+ :: CheckError
859+checkError =
860+ CheckError'
861+ { _ceCode = Nothing
862+ , _ceDetail = Nothing
863+ }
864+
865+-- | The error code.
866+ceCode :: Lens' CheckError (Maybe CheckErrorCode)
867+ceCode = lens _ceCode (\ s a -> s{_ceCode = a})
868+
869+-- | Free-form text providing details on the error cause of the error.
870+ceDetail :: Lens' CheckError (Maybe Text)
871+ceDetail = lens _ceDetail (\ s a -> s{_ceDetail = a})
872+
873+instance FromJSON CheckError where
874+ parseJSON
875+ = withObject "CheckError"
876+ (\ o ->
877+ CheckError' <$> (o .:? "code") <*> (o .:? "detail"))
878+
879+instance ToJSON CheckError where
880+ toJSON CheckError'{..}
881+ = object
882+ (catMaybes
883+ [("code" .=) <$> _ceCode,
884+ ("detail" .=) <$> _ceDetail])
885+
886+-- | Represents the processing error of one \`Operation\` in the request.
887+--
888+-- /See:/ 'reportError' smart constructor.
889+data ReportError = ReportError'
890+ { _reStatus :: !(Maybe Status)
891+ , _reOperationId :: !(Maybe Text)
892+ } deriving (Eq,Show,Data,Typeable,Generic)
893+
894+-- | Creates a value of 'ReportError' with the minimum fields required to make a request.
895+--
896+-- Use one of the following lenses to modify other fields as desired:
897+--
898+-- * 'reStatus'
899+--
900+-- * 'reOperationId'
901+reportError
902+ :: ReportError
903+reportError =
904+ ReportError'
905+ { _reStatus = Nothing
906+ , _reOperationId = Nothing
907+ }
908+
909+-- | Details of the error when processing the \`Operation\`.
910+reStatus :: Lens' ReportError (Maybe Status)
911+reStatus = lens _reStatus (\ s a -> s{_reStatus = a})
912+
913+-- | The Operation.operation_id value from the request.
914+reOperationId :: Lens' ReportError (Maybe Text)
915+reOperationId
916+ = lens _reOperationId
917+ (\ s a -> s{_reOperationId = a})
918+
919+instance FromJSON ReportError where
920+ parseJSON
921+ = withObject "ReportError"
922+ (\ o ->
923+ ReportError' <$>
924+ (o .:? "status") <*> (o .:? "operationId"))
925+
926+instance ToJSON ReportError where
927+ toJSON ReportError'{..}
928+ = object
929+ (catMaybes
930+ [("status" .=) <$> _reStatus,
931+ ("operationId" .=) <$> _reOperationId])
932+
933+-- | Represents a single metric value.
934+--
935+-- /See:/ 'metricValue' smart constructor.
936+data MetricValue = MetricValue'
937+ { _mvBoolValue :: !(Maybe Bool)
938+ , _mvStartTime :: !(Maybe DateTime')
939+ , _mvDoubleValue :: !(Maybe (Textual Double))
940+ , _mvStringValue :: !(Maybe Text)
941+ , _mvDistributionValue :: !(Maybe Distribution)
942+ , _mvEndTime :: !(Maybe DateTime')
943+ , _mvInt64Value :: !(Maybe (Textual Int64))
944+ , _mvLabels :: !(Maybe MetricValueLabels)
945+ } deriving (Eq,Show,Data,Typeable,Generic)
946+
947+-- | Creates a value of 'MetricValue' with the minimum fields required to make a request.
948+--
949+-- Use one of the following lenses to modify other fields as desired:
950+--
951+-- * 'mvBoolValue'
952+--
953+-- * 'mvStartTime'
954+--
955+-- * 'mvDoubleValue'
956+--
957+-- * 'mvStringValue'
958+--
959+-- * 'mvDistributionValue'
960+--
961+-- * 'mvEndTime'
962+--
963+-- * 'mvInt64Value'
964+--
965+-- * 'mvLabels'
966+metricValue
967+ :: MetricValue
968+metricValue =
969+ MetricValue'
970+ { _mvBoolValue = Nothing
971+ , _mvStartTime = Nothing
972+ , _mvDoubleValue = Nothing
973+ , _mvStringValue = Nothing
974+ , _mvDistributionValue = Nothing
975+ , _mvEndTime = Nothing
976+ , _mvInt64Value = Nothing
977+ , _mvLabels = Nothing
978+ }
979+
980+-- | A boolean value.
981+mvBoolValue :: Lens' MetricValue (Maybe Bool)
982+mvBoolValue
983+ = lens _mvBoolValue (\ s a -> s{_mvBoolValue = a})
984+
985+-- | The start of the time period over which this metric value\'s measurement
986+-- applies. The time period has different semantics for different metric
987+-- types (cumulative, delta, and gauge). See the metric definition
988+-- documentation in the service configuration for details.
989+mvStartTime :: Lens' MetricValue (Maybe UTCTime)
990+mvStartTime
991+ = lens _mvStartTime (\ s a -> s{_mvStartTime = a}) .
992+ mapping _DateTime
993+
994+-- | A double precision floating point value.
995+mvDoubleValue :: Lens' MetricValue (Maybe Double)
996+mvDoubleValue
997+ = lens _mvDoubleValue
998+ (\ s a -> s{_mvDoubleValue = a})
999+ . mapping _Coerce
1000+
1001+-- | A text string value.
1002+mvStringValue :: Lens' MetricValue (Maybe Text)
1003+mvStringValue
1004+ = lens _mvStringValue
1005+ (\ s a -> s{_mvStringValue = a})
1006+
1007+-- | A distribution value.
1008+mvDistributionValue :: Lens' MetricValue (Maybe Distribution)
1009+mvDistributionValue
1010+ = lens _mvDistributionValue
1011+ (\ s a -> s{_mvDistributionValue = a})
1012+
1013+-- | The end of the time period over which this metric value\'s measurement
1014+-- applies.
1015+mvEndTime :: Lens' MetricValue (Maybe UTCTime)
1016+mvEndTime
1017+ = lens _mvEndTime (\ s a -> s{_mvEndTime = a}) .
1018+ mapping _DateTime
1019+
1020+-- | A signed 64-bit integer value.
1021+mvInt64Value :: Lens' MetricValue (Maybe Int64)
1022+mvInt64Value
1023+ = lens _mvInt64Value (\ s a -> s{_mvInt64Value = a})
1024+ . mapping _Coerce
1025+
1026+-- | The labels describing the metric value. See comments on
1027+-- google.api.servicecontrol.v1.Operation.labels for the overriding
1028+-- relationship.
1029+mvLabels :: Lens' MetricValue (Maybe MetricValueLabels)
1030+mvLabels = lens _mvLabels (\ s a -> s{_mvLabels = a})
1031+
1032+instance FromJSON MetricValue where
1033+ parseJSON
1034+ = withObject "MetricValue"
1035+ (\ o ->
1036+ MetricValue' <$>
1037+ (o .:? "boolValue") <*> (o .:? "startTime") <*>
1038+ (o .:? "doubleValue")
1039+ <*> (o .:? "stringValue")
1040+ <*> (o .:? "distributionValue")
1041+ <*> (o .:? "endTime")
1042+ <*> (o .:? "int64Value")
1043+ <*> (o .:? "labels"))
1044+
1045+instance ToJSON MetricValue where
1046+ toJSON MetricValue'{..}
1047+ = object
1048+ (catMaybes
1049+ [("boolValue" .=) <$> _mvBoolValue,
1050+ ("startTime" .=) <$> _mvStartTime,
1051+ ("doubleValue" .=) <$> _mvDoubleValue,
1052+ ("stringValue" .=) <$> _mvStringValue,
1053+ ("distributionValue" .=) <$> _mvDistributionValue,
1054+ ("endTime" .=) <$> _mvEndTime,
1055+ ("int64Value" .=) <$> _mvInt64Value,
1056+ ("labels" .=) <$> _mvLabels])
1057+
1058+-- | Response message for the Check method.
1059+--
1060+-- /See:/ 'checkResponse' smart constructor.
1061+data CheckResponse = CheckResponse'
1062+ { _crCheckErrors :: !(Maybe [CheckError])
1063+ , _crServiceConfigId :: !(Maybe Text)
1064+ , _crOperationId :: !(Maybe Text)
1065+ } deriving (Eq,Show,Data,Typeable,Generic)
1066+
1067+-- | Creates a value of 'CheckResponse' with the minimum fields required to make a request.
1068+--
1069+-- Use one of the following lenses to modify other fields as desired:
1070+--
1071+-- * 'crCheckErrors'
1072+--
1073+-- * 'crServiceConfigId'
1074+--
1075+-- * 'crOperationId'
1076+checkResponse
1077+ :: CheckResponse
1078+checkResponse =
1079+ CheckResponse'
1080+ { _crCheckErrors = Nothing
1081+ , _crServiceConfigId = Nothing
1082+ , _crOperationId = Nothing
1083+ }
1084+
1085+-- | Indicate the decision of the check. If no check errors are present, the
1086+-- service should process the operation. Otherwise the service should use
1087+-- the list of errors to determine the appropriate action.
1088+crCheckErrors :: Lens' CheckResponse [CheckError]
1089+crCheckErrors
1090+ = lens _crCheckErrors
1091+ (\ s a -> s{_crCheckErrors = a})
1092+ . _Default
1093+ . _Coerce
1094+
1095+-- | The actual config id used to process the request.
1096+crServiceConfigId :: Lens' CheckResponse (Maybe Text)
1097+crServiceConfigId
1098+ = lens _crServiceConfigId
1099+ (\ s a -> s{_crServiceConfigId = a})
1100+
1101+-- | The same operation_id value used in the CheckRequest. Used for logging
1102+-- and diagnostics purposes.
1103+crOperationId :: Lens' CheckResponse (Maybe Text)
1104+crOperationId
1105+ = lens _crOperationId
1106+ (\ s a -> s{_crOperationId = a})
1107+
1108+instance FromJSON CheckResponse where
1109+ parseJSON
1110+ = withObject "CheckResponse"
1111+ (\ o ->
1112+ CheckResponse' <$>
1113+ (o .:? "checkErrors" .!= mempty) <*>
1114+ (o .:? "serviceConfigId")
1115+ <*> (o .:? "operationId"))
1116+
1117+instance ToJSON CheckResponse where
1118+ toJSON CheckResponse'{..}
1119+ = object
1120+ (catMaybes
1121+ [("checkErrors" .=) <$> _crCheckErrors,
1122+ ("serviceConfigId" .=) <$> _crServiceConfigId,
1123+ ("operationId" .=) <$> _crOperationId])
1124+
1125+-- | Response message for the Report method.
1126+--
1127+-- /See:/ 'reportResponse' smart constructor.
1128+data ReportResponse = ReportResponse'
1129+ { _rrReportErrors :: !(Maybe [ReportError])
1130+ , _rrServiceConfigId :: !(Maybe Text)
1131+ } deriving (Eq,Show,Data,Typeable,Generic)
1132+
1133+-- | Creates a value of 'ReportResponse' with the minimum fields required to make a request.
1134+--
1135+-- Use one of the following lenses to modify other fields as desired:
1136+--
1137+-- * 'rrReportErrors'
1138+--
1139+-- * 'rrServiceConfigId'
1140+reportResponse
1141+ :: ReportResponse
1142+reportResponse =
1143+ ReportResponse'
1144+ { _rrReportErrors = Nothing
1145+ , _rrServiceConfigId = Nothing
1146+ }
1147+
1148+-- | Partial failures, one for each \`Operation\` in the request that failed
1149+-- processing. There are three possible combinations of the RPC status: 1.
1150+-- The combination of a successful RPC status and an empty
1151+-- \`report_errors\` list indicates a complete success where all
1152+-- \`Operations\` in the request are processed successfully. 2. The
1153+-- combination of a successful RPC status and a non-empty \`report_errors\`
1154+-- list indicates a partial success where some \`Operations\` in the
1155+-- request succeeded. Each \`Operation\` that failed processing has a
1156+-- corresponding item in this list. 3. A failed RPC status indicates a
1157+-- complete failure where none of the \`Operations\` in the request
1158+-- succeeded.
1159+rrReportErrors :: Lens' ReportResponse [ReportError]
1160+rrReportErrors
1161+ = lens _rrReportErrors
1162+ (\ s a -> s{_rrReportErrors = a})
1163+ . _Default
1164+ . _Coerce
1165+
1166+-- | The actual config id used to process the request.
1167+rrServiceConfigId :: Lens' ReportResponse (Maybe Text)
1168+rrServiceConfigId
1169+ = lens _rrServiceConfigId
1170+ (\ s a -> s{_rrServiceConfigId = a})
1171+
1172+instance FromJSON ReportResponse where
1173+ parseJSON
1174+ = withObject "ReportResponse"
1175+ (\ o ->
1176+ ReportResponse' <$>
1177+ (o .:? "reportErrors" .!= mempty) <*>
1178+ (o .:? "serviceConfigId"))
1179+
1180+instance ToJSON ReportResponse where
1181+ toJSON ReportResponse'{..}
1182+ = object
1183+ (catMaybes
1184+ [("reportErrors" .=) <$> _rrReportErrors,
1185+ ("serviceConfigId" .=) <$> _rrServiceConfigId])
1186+
1187+-- | An individual log entry.
1188+--
1189+-- /See:/ 'logEntry' smart constructor.
1190+data LogEntry = LogEntry'
1191+ { _leSeverity :: !(Maybe LogEntrySeverity)
1192+ , _leTextPayload :: !(Maybe Text)
1193+ , _leStructPayload :: !(Maybe LogEntryStructPayload)
1194+ , _leName :: !(Maybe Text)
1195+ , _leInsertId :: !(Maybe Text)
1196+ , _leLabels :: !(Maybe LogEntryLabels)
1197+ , _leProtoPayload :: !(Maybe LogEntryProtoPayload)
1198+ , _leTimestamp :: !(Maybe DateTime')
1199+ } deriving (Eq,Show,Data,Typeable,Generic)
1200+
1201+-- | Creates a value of 'LogEntry' with the minimum fields required to make a request.
1202+--
1203+-- Use one of the following lenses to modify other fields as desired:
1204+--
1205+-- * 'leSeverity'
1206+--
1207+-- * 'leTextPayload'
1208+--
1209+-- * 'leStructPayload'
1210+--
1211+-- * 'leName'
1212+--
1213+-- * 'leInsertId'
1214+--
1215+-- * 'leLabels'
1216+--
1217+-- * 'leProtoPayload'
1218+--
1219+-- * 'leTimestamp'
1220+logEntry
1221+ :: LogEntry
1222+logEntry =
1223+ LogEntry'
1224+ { _leSeverity = Nothing
1225+ , _leTextPayload = Nothing
1226+ , _leStructPayload = Nothing
1227+ , _leName = Nothing
1228+ , _leInsertId = Nothing
1229+ , _leLabels = Nothing
1230+ , _leProtoPayload = Nothing
1231+ , _leTimestamp = Nothing
1232+ }
1233+
1234+-- | The severity of the log entry. The default value is
1235+-- \`LogSeverity.DEFAULT\`.
1236+leSeverity :: Lens' LogEntry (Maybe LogEntrySeverity)
1237+leSeverity
1238+ = lens _leSeverity (\ s a -> s{_leSeverity = a})
1239+
1240+-- | The log entry payload, represented as a Unicode string (UTF-8).
1241+leTextPayload :: Lens' LogEntry (Maybe Text)
1242+leTextPayload
1243+ = lens _leTextPayload
1244+ (\ s a -> s{_leTextPayload = a})
1245+
1246+-- | The log entry payload, represented as a structure that is expressed as a
1247+-- JSON object.
1248+leStructPayload :: Lens' LogEntry (Maybe LogEntryStructPayload)
1249+leStructPayload
1250+ = lens _leStructPayload
1251+ (\ s a -> s{_leStructPayload = a})
1252+
1253+-- | Required. The log to which this log entry belongs. Examples:
1254+-- \`\"syslog\"\`, \`\"book_log\"\`.
1255+leName :: Lens' LogEntry (Maybe Text)
1256+leName = lens _leName (\ s a -> s{_leName = a})
1257+
1258+-- | A unique ID for the log entry used for deduplication. If omitted, the
1259+-- implementation will generate one based on operation_id.
1260+leInsertId :: Lens' LogEntry (Maybe Text)
1261+leInsertId
1262+ = lens _leInsertId (\ s a -> s{_leInsertId = a})
1263+
1264+-- | A set of user-defined (key, value) data that provides additional
1265+-- information about the log entry.
1266+leLabels :: Lens' LogEntry (Maybe LogEntryLabels)
1267+leLabels = lens _leLabels (\ s a -> s{_leLabels = a})
1268+
1269+-- | The log entry payload, represented as a protocol buffer that is
1270+-- expressed as a JSON object. You can only pass \`protoPayload\` values
1271+-- that belong to a set of approved types.
1272+leProtoPayload :: Lens' LogEntry (Maybe LogEntryProtoPayload)
1273+leProtoPayload
1274+ = lens _leProtoPayload
1275+ (\ s a -> s{_leProtoPayload = a})
1276+
1277+-- | The time the event described by the log entry occurred. If omitted,
1278+-- defaults to operation start time.
1279+leTimestamp :: Lens' LogEntry (Maybe UTCTime)
1280+leTimestamp
1281+ = lens _leTimestamp (\ s a -> s{_leTimestamp = a}) .
1282+ mapping _DateTime
1283+
1284+instance FromJSON LogEntry where
1285+ parseJSON
1286+ = withObject "LogEntry"
1287+ (\ o ->
1288+ LogEntry' <$>
1289+ (o .:? "severity") <*> (o .:? "textPayload") <*>
1290+ (o .:? "structPayload")
1291+ <*> (o .:? "name")
1292+ <*> (o .:? "insertId")
1293+ <*> (o .:? "labels")
1294+ <*> (o .:? "protoPayload")
1295+ <*> (o .:? "timestamp"))
1296+
1297+instance ToJSON LogEntry where
1298+ toJSON LogEntry'{..}
1299+ = object
1300+ (catMaybes
1301+ [("severity" .=) <$> _leSeverity,
1302+ ("textPayload" .=) <$> _leTextPayload,
1303+ ("structPayload" .=) <$> _leStructPayload,
1304+ ("name" .=) <$> _leName,
1305+ ("insertId" .=) <$> _leInsertId,
1306+ ("labels" .=) <$> _leLabels,
1307+ ("protoPayload" .=) <$> _leProtoPayload,
1308+ ("timestamp" .=) <$> _leTimestamp])
1309+
1310+-- | Labels describing the operation. Only the following labels are allowed:
1311+-- - Labels describing monitored resources as defined in the service
1312+-- configuration. - Default labels of metric values. When specified, labels
1313+-- defined in the metric value override these default. - The following
1314+-- labels defined by Google Cloud Platform: -
1315+-- \`cloud.googleapis.com\/location\` describing the location where the
1316+-- operation happened, - \`servicecontrol.googleapis.com\/user_agent\`
1317+-- describing the user agent of the API request, -
1318+-- \`servicecontrol.googleapis.com\/service_agent\` describing the service
1319+-- used to handle the API request (e.g. ESP), -
1320+-- \`servicecontrol.googleapis.com\/platform\` describing the platform
1321+-- where the API is served (e.g. GAE, GCE, GKE).
1322+--
1323+-- /See:/ 'operationLabels' smart constructor.
1324+newtype OperationLabels = OperationLabels'
1325+ { _olAddtional :: HashMap Text Text
1326+ } deriving (Eq,Show,Data,Typeable,Generic)
1327+
1328+-- | Creates a value of 'OperationLabels' with the minimum fields required to make a request.
1329+--
1330+-- Use one of the following lenses to modify other fields as desired:
1331+--
1332+-- * 'olAddtional'
1333+operationLabels
1334+ :: HashMap Text Text -- ^ 'olAddtional'
1335+ -> OperationLabels
1336+operationLabels pOlAddtional_ =
1337+ OperationLabels'
1338+ { _olAddtional = _Coerce # pOlAddtional_
1339+ }
1340+
1341+olAddtional :: Lens' OperationLabels (HashMap Text Text)
1342+olAddtional
1343+ = lens _olAddtional (\ s a -> s{_olAddtional = a}) .
1344+ _Coerce
1345+
1346+instance FromJSON OperationLabels where
1347+ parseJSON
1348+ = withObject "OperationLabels"
1349+ (\ o -> OperationLabels' <$> (parseJSONObject o))
1350+
1351+instance ToJSON OperationLabels where
1352+ toJSON = toJSON . _olAddtional
1353+
1354+-- | Describing buckets with arbitrary user-provided width.
1355+--
1356+-- /See:/ 'explicitBuckets' smart constructor.
1357+newtype ExplicitBuckets = ExplicitBuckets'
1358+ { _ebBounds :: Maybe [Textual Double]
1359+ } deriving (Eq,Show,Data,Typeable,Generic)
1360+
1361+-- | Creates a value of 'ExplicitBuckets' with the minimum fields required to make a request.
1362+--
1363+-- Use one of the following lenses to modify other fields as desired:
1364+--
1365+-- * 'ebBounds'
1366+explicitBuckets
1367+ :: ExplicitBuckets
1368+explicitBuckets =
1369+ ExplicitBuckets'
1370+ { _ebBounds = Nothing
1371+ }
1372+
1373+-- | \'bound\' is a list of strictly increasing boundaries between buckets.
1374+-- Note that a list of length N-1 defines N buckets because of
1375+-- fenceposting. See comments on \`bucket_options\` for details. The i\'th
1376+-- finite bucket covers the interval [bound[i-1], bound[i]) where i ranges
1377+-- from 1 to bound_size() - 1. Note that there are no finite buckets at all
1378+-- if \'bound\' only contains a single element; in that special case the
1379+-- single bound defines the boundary between the underflow and overflow
1380+-- buckets. bucket number lower bound upper bound i == 0 (underflow) -inf
1381+-- bound[i] 0 \< i \< bound_size() bound[i-1] bound[i] i == bound_size()
1382+-- (overflow) bound[i-1] +inf
1383+ebBounds :: Lens' ExplicitBuckets [Double]
1384+ebBounds
1385+ = lens _ebBounds (\ s a -> s{_ebBounds = a}) .
1386+ _Default
1387+ . _Coerce
1388+
1389+instance FromJSON ExplicitBuckets where
1390+ parseJSON
1391+ = withObject "ExplicitBuckets"
1392+ (\ o ->
1393+ ExplicitBuckets' <$> (o .:? "bounds" .!= mempty))
1394+
1395+instance ToJSON ExplicitBuckets where
1396+ toJSON ExplicitBuckets'{..}
1397+ = object (catMaybes [("bounds" .=) <$> _ebBounds])
1398+
1399+-- | The log entry payload, represented as a structure that is expressed as a
1400+-- JSON object.
1401+--
1402+-- /See:/ 'logEntryStructPayload' smart constructor.
1403+newtype LogEntryStructPayload = LogEntryStructPayload'
1404+ { _lespAddtional :: HashMap Text JSONValue
1405+ } deriving (Eq,Show,Data,Typeable,Generic)
1406+
1407+-- | Creates a value of 'LogEntryStructPayload' with the minimum fields required to make a request.
1408+--
1409+-- Use one of the following lenses to modify other fields as desired:
1410+--
1411+-- * 'lespAddtional'
1412+logEntryStructPayload
1413+ :: HashMap Text JSONValue -- ^ 'lespAddtional'
1414+ -> LogEntryStructPayload
1415+logEntryStructPayload pLespAddtional_ =
1416+ LogEntryStructPayload'
1417+ { _lespAddtional = _Coerce # pLespAddtional_
1418+ }
1419+
1420+-- | Properties of the object.
1421+lespAddtional :: Lens' LogEntryStructPayload (HashMap Text JSONValue)
1422+lespAddtional
1423+ = lens _lespAddtional
1424+ (\ s a -> s{_lespAddtional = a})
1425+ . _Coerce
1426+
1427+instance FromJSON LogEntryStructPayload where
1428+ parseJSON
1429+ = withObject "LogEntryStructPayload"
1430+ (\ o ->
1431+ LogEntryStructPayload' <$> (parseJSONObject o))
1432+
1433+instance ToJSON LogEntryStructPayload where
1434+ toJSON = toJSON . _lespAddtional