google-analytics-data-v1alpha 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ # This gem does not autoload during Bundler.require. To load this gem,
20
+ # issue explicit require statements for the packages desired, e.g.:
21
+ # require "google/analytics/data/v1alpha"
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/analytics/data/v1alpha/analytics_data"
20
+ require "google/analytics/data/v1alpha/version"
21
+
22
+ module Google
23
+ module Analytics
24
+ module Data
25
+ ##
26
+ # To load this package, including all its services, and instantiate a client:
27
+ #
28
+ # require "google/analytics/data/v1alpha"
29
+ # client = ::Google::Analytics::Data::V1alpha::AnalyticsData::Client.new
30
+ #
31
+ module V1alpha
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/analytics/data/v1alpha/version"
24
+
25
+ require "google/analytics/data/v1alpha/analytics_data/credentials"
26
+ require "google/analytics/data/v1alpha/analytics_data/paths"
27
+ require "google/analytics/data/v1alpha/analytics_data/client"
28
+
29
+ module Google
30
+ module Analytics
31
+ module Data
32
+ module V1alpha
33
+ ##
34
+ # Google Analytics reporting data service.
35
+ #
36
+ # To load this service and instantiate a client:
37
+ #
38
+ # require "google/analytics/data/v1alpha/analytics_data"
39
+ # client = ::Google::Analytics::Data::V1alpha::AnalyticsData::Client.new
40
+ #
41
+ module AnalyticsData
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ helper_path = ::File.join __dir__, "analytics_data", "helpers.rb"
49
+ require "google/analytics/data/v1alpha/analytics_data/helpers" if ::File.file? helper_path
@@ -0,0 +1,760 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/analytics/data/v1alpha/analytics_data_api_pb"
21
+
22
+ module Google
23
+ module Analytics
24
+ module Data
25
+ module V1alpha
26
+ module AnalyticsData
27
+ ##
28
+ # Client for the AnalyticsData service.
29
+ #
30
+ # Google Analytics reporting data service.
31
+ #
32
+ class Client
33
+ include Paths
34
+
35
+ # @private
36
+ attr_reader :analytics_data_stub
37
+
38
+ ##
39
+ # Configure the AnalyticsData Client class.
40
+ #
41
+ # See {::Google::Analytics::Data::V1alpha::AnalyticsData::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # ## Example
45
+ #
46
+ # To modify the configuration for all AnalyticsData clients:
47
+ #
48
+ # ::Google::Analytics::Data::V1alpha::AnalyticsData::Client.configure do |config|
49
+ # config.timeout = 10.0
50
+ # end
51
+ #
52
+ # @yield [config] Configure the Client client.
53
+ # @yieldparam config [Client::Configuration]
54
+ #
55
+ # @return [Client::Configuration]
56
+ #
57
+ def self.configure
58
+ @configure ||= begin
59
+ namespace = ["Google", "Analytics", "Data", "V1alpha"]
60
+ parent_config = while namespace.any?
61
+ parent_name = namespace.join "::"
62
+ parent_const = const_get parent_name
63
+ break parent_const.configure if parent_const&.respond_to? :configure
64
+ namespace.pop
65
+ end
66
+ default_config = Client::Configuration.new parent_config
67
+
68
+ default_config.timeout = 60.0
69
+ default_config.retry_policy = {
70
+ initial_delay: 1.0,
71
+ max_delay: 60.0,
72
+ multiplier: 1.3,
73
+ retry_codes: [2]
74
+ }
75
+
76
+ default_config.rpcs.run_report.timeout = 60.0
77
+
78
+ default_config.rpcs.run_pivot_report.timeout = 60.0
79
+
80
+ default_config.rpcs.batch_run_reports.timeout = 60.0
81
+
82
+ default_config.rpcs.batch_run_pivot_reports.timeout = 60.0
83
+
84
+ default_config
85
+ end
86
+ yield @configure if block_given?
87
+ @configure
88
+ end
89
+
90
+ ##
91
+ # Configure the AnalyticsData Client instance.
92
+ #
93
+ # The configuration is set to the derived mode, meaning that values can be changed,
94
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
95
+ # should be made on {Client.configure}.
96
+ #
97
+ # See {::Google::Analytics::Data::V1alpha::AnalyticsData::Client::Configuration}
98
+ # for a description of the configuration fields.
99
+ #
100
+ # @yield [config] Configure the Client client.
101
+ # @yieldparam config [Client::Configuration]
102
+ #
103
+ # @return [Client::Configuration]
104
+ #
105
+ def configure
106
+ yield @config if block_given?
107
+ @config
108
+ end
109
+
110
+ ##
111
+ # Create a new AnalyticsData client object.
112
+ #
113
+ # ## Examples
114
+ #
115
+ # To create a new AnalyticsData client with the default
116
+ # configuration:
117
+ #
118
+ # client = ::Google::Analytics::Data::V1alpha::AnalyticsData::Client.new
119
+ #
120
+ # To create a new AnalyticsData client with a custom
121
+ # configuration:
122
+ #
123
+ # client = ::Google::Analytics::Data::V1alpha::AnalyticsData::Client.new do |config|
124
+ # config.timeout = 10.0
125
+ # end
126
+ #
127
+ # @yield [config] Configure the AnalyticsData client.
128
+ # @yieldparam config [Client::Configuration]
129
+ #
130
+ def initialize
131
+ # These require statements are intentionally placed here to initialize
132
+ # the gRPC module only when it's required.
133
+ # See https://github.com/googleapis/toolkit/issues/446
134
+ require "gapic/grpc"
135
+ require "google/analytics/data/v1alpha/analytics_data_api_services_pb"
136
+
137
+ # Create the configuration object
138
+ @config = Configuration.new Client.configure
139
+
140
+ # Yield the configuration if needed
141
+ yield @config if block_given?
142
+
143
+ # Create credentials
144
+ credentials = @config.credentials
145
+ credentials ||= Credentials.default scope: @config.scope
146
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
147
+ credentials = Credentials.new credentials, scope: @config.scope
148
+ end
149
+ @quota_project_id = @config.quota_project
150
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
151
+
152
+ @analytics_data_stub = ::Gapic::ServiceStub.new(
153
+ ::Google::Analytics::Data::V1alpha::AlphaAnalyticsData::Stub,
154
+ credentials: credentials,
155
+ endpoint: @config.endpoint,
156
+ channel_args: @config.channel_args,
157
+ interceptors: @config.interceptors
158
+ )
159
+ end
160
+
161
+ # Service calls
162
+
163
+ ##
164
+ # Returns a customized report of your Google Analytics event data. Reports
165
+ # contain statistics derived from data collected by the Google Analytics
166
+ # tracking code. The data returned from the API is as a table with columns
167
+ # for the requested dimensions and metrics. Metrics are individual
168
+ # measurements of user activity on your property, such as active users or
169
+ # event count. Dimensions break down metrics across some common criteria,
170
+ # such as country or event name.
171
+ #
172
+ # @overload run_report(request, options = nil)
173
+ # Pass arguments to `run_report` via a request object, either of type
174
+ # {::Google::Analytics::Data::V1alpha::RunReportRequest} or an equivalent Hash.
175
+ #
176
+ # @param request [::Google::Analytics::Data::V1alpha::RunReportRequest, ::Hash]
177
+ # A request object representing the call parameters. Required. To specify no
178
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
179
+ # @param options [::Gapic::CallOptions, ::Hash]
180
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
181
+ #
182
+ # @overload run_report(entity: nil, dimensions: nil, metrics: nil, date_ranges: nil, offset: nil, limit: nil, metric_aggregations: nil, dimension_filter: nil, metric_filter: nil, order_bys: nil, currency_code: nil, cohort_spec: nil, keep_empty_rows: nil, return_property_quota: nil)
183
+ # Pass arguments to `run_report` via keyword arguments. Note that at
184
+ # least one keyword argument is required. To specify no parameters, or to keep all
185
+ # the default parameter values, pass an empty Hash as a request object (see above).
186
+ #
187
+ # @param entity [::Google::Analytics::Data::V1alpha::Entity, ::Hash]
188
+ # A property whose events are tracked. Within a batch request, this entity
189
+ # should either be unspecified or consistent with the batch-level entity.
190
+ # @param dimensions [::Array<::Google::Analytics::Data::V1alpha::Dimension, ::Hash>]
191
+ # The dimensions requested and displayed.
192
+ # @param metrics [::Array<::Google::Analytics::Data::V1alpha::Metric, ::Hash>]
193
+ # The metrics requested and displayed.
194
+ # @param date_ranges [::Array<::Google::Analytics::Data::V1alpha::DateRange, ::Hash>]
195
+ # Date ranges of data to read. If multiple date ranges are requested, each
196
+ # response row will contain a zero based date range index. If two date
197
+ # ranges overlap, the event data for the overlapping days is included in the
198
+ # response rows for both date ranges. In a cohort request, this `dateRanges`
199
+ # must be unspecified.
200
+ # @param offset [::Integer]
201
+ # The row count of the start row. The first row is counted as row 0.
202
+ # @param limit [::Integer]
203
+ # The number of rows to return. If unspecified, 10 rows are returned. If
204
+ # -1, all rows are returned.
205
+ # @param metric_aggregations [::Array<::Google::Analytics::Data::V1alpha::MetricAggregation>]
206
+ # Aggregation of metrics. Aggregated metric values will be shown in rows
207
+ # where the dimension_values are set to "RESERVED_(MetricAggregation)".
208
+ # @param dimension_filter [::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash]
209
+ # The filter clause of dimensions. Dimensions must be requested to be used in
210
+ # this filter. Metrics cannot be used in this filter.
211
+ # @param metric_filter [::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash]
212
+ # The filter clause of metrics. Applied at post aggregation phase, similar to
213
+ # SQL having-clause. Metrics must be requested to be used in this filter.
214
+ # Dimensions cannot be used in this filter.
215
+ # @param order_bys [::Array<::Google::Analytics::Data::V1alpha::OrderBy, ::Hash>]
216
+ # Specifies how rows are ordered in the response.
217
+ # @param currency_code [::String]
218
+ # A currency code in ISO4217 format, such as "AED", "USD", "JPY".
219
+ # If the field is empty, the report uses the entity's default currency.
220
+ # @param cohort_spec [::Google::Analytics::Data::V1alpha::CohortSpec, ::Hash]
221
+ # Cohort group associated with this request. If there is a cohort group
222
+ # in the request the 'cohort' dimension must be present.
223
+ # @param keep_empty_rows [::Boolean]
224
+ # If false or unspecified, each row with all metrics equal to 0 will not be
225
+ # returned. If true, these rows will be returned if they are not separately
226
+ # removed by a filter.
227
+ # @param return_property_quota [::Boolean]
228
+ # Toggles whether to return the current state of this Analytics Property's
229
+ # quota. Quota is returned in [PropertyQuota](#PropertyQuota).
230
+ #
231
+ # @yield [response, operation] Access the result along with the RPC operation
232
+ # @yieldparam response [::Google::Analytics::Data::V1alpha::RunReportResponse]
233
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
234
+ #
235
+ # @return [::Google::Analytics::Data::V1alpha::RunReportResponse]
236
+ #
237
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
238
+ #
239
+ def run_report request, options = nil
240
+ raise ::ArgumentError, "request must be provided" if request.nil?
241
+
242
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Analytics::Data::V1alpha::RunReportRequest
243
+
244
+ # Converts hash and nil to an options object
245
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
246
+
247
+ # Customize the options with defaults
248
+ metadata = @config.rpcs.run_report.metadata.to_h
249
+
250
+ # Set x-goog-api-client and x-goog-user-project headers
251
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
252
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
253
+ gapic_version: ::Google::Analytics::Data::V1alpha::VERSION
254
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
255
+
256
+ options.apply_defaults timeout: @config.rpcs.run_report.timeout,
257
+ metadata: metadata,
258
+ retry_policy: @config.rpcs.run_report.retry_policy
259
+ options.apply_defaults metadata: @config.metadata,
260
+ retry_policy: @config.retry_policy
261
+
262
+ @analytics_data_stub.call_rpc :run_report, request, options: options do |response, operation|
263
+ yield response, operation if block_given?
264
+ return response
265
+ end
266
+ rescue ::GRPC::BadStatus => e
267
+ raise ::Google::Cloud::Error.from_error(e)
268
+ end
269
+
270
+ ##
271
+ # Returns a customized pivot report of your Google Analytics event data.
272
+ # Pivot reports are more advanced and expressive formats than regular
273
+ # reports. In a pivot report, dimensions are only visible if they are
274
+ # included in a pivot. Multiple pivots can be specified to further dissect
275
+ # your data.
276
+ #
277
+ # @overload run_pivot_report(request, options = nil)
278
+ # Pass arguments to `run_pivot_report` via a request object, either of type
279
+ # {::Google::Analytics::Data::V1alpha::RunPivotReportRequest} or an equivalent Hash.
280
+ #
281
+ # @param request [::Google::Analytics::Data::V1alpha::RunPivotReportRequest, ::Hash]
282
+ # A request object representing the call parameters. Required. To specify no
283
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
284
+ # @param options [::Gapic::CallOptions, ::Hash]
285
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
286
+ #
287
+ # @overload run_pivot_report(entity: nil, dimensions: nil, metrics: nil, dimension_filter: nil, metric_filter: nil, pivots: nil, date_ranges: nil, currency_code: nil, cohort_spec: nil, keep_empty_rows: nil, return_property_quota: nil)
288
+ # Pass arguments to `run_pivot_report` via keyword arguments. Note that at
289
+ # least one keyword argument is required. To specify no parameters, or to keep all
290
+ # the default parameter values, pass an empty Hash as a request object (see above).
291
+ #
292
+ # @param entity [::Google::Analytics::Data::V1alpha::Entity, ::Hash]
293
+ # A property whose events are tracked. Within a batch request, this entity
294
+ # should either be unspecified or consistent with the batch-level entity.
295
+ # @param dimensions [::Array<::Google::Analytics::Data::V1alpha::Dimension, ::Hash>]
296
+ # The dimensions requested. All defined dimensions must be used by one of the
297
+ # following: dimension_expression, dimension_filter, pivots, order_bys.
298
+ # @param metrics [::Array<::Google::Analytics::Data::V1alpha::Metric, ::Hash>]
299
+ # The metrics requested, at least one metric needs to be specified. All
300
+ # defined metrics must be used by one of the following: metric_expression,
301
+ # metric_filter, order_bys.
302
+ # @param dimension_filter [::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash]
303
+ # The filter clause of dimensions. Dimensions must be requested to be used in
304
+ # this filter. Metrics cannot be used in this filter.
305
+ # @param metric_filter [::Google::Analytics::Data::V1alpha::FilterExpression, ::Hash]
306
+ # The filter clause of metrics. Applied at post aggregation phase, similar to
307
+ # SQL having-clause. Metrics must be requested to be used in this filter.
308
+ # Dimensions cannot be used in this filter.
309
+ # @param pivots [::Array<::Google::Analytics::Data::V1alpha::Pivot, ::Hash>]
310
+ # Describes the visual format of the report's dimensions in columns or rows.
311
+ # The union of the fieldNames (dimension names) in all pivots must be a
312
+ # subset of dimension names defined in Dimensions. No two pivots can share a
313
+ # dimension. A dimension is only visible if it appears in a pivot.
314
+ # @param date_ranges [::Array<::Google::Analytics::Data::V1alpha::DateRange, ::Hash>]
315
+ # The date range to retrieve event data for the report. If multiple date
316
+ # ranges are specified, event data from each date range is used in the
317
+ # report. A special dimension with field name "dateRange" can be included in
318
+ # a Pivot's field names; if included, the report compares between date
319
+ # ranges. In a cohort request, this `dateRanges` must be unspecified.
320
+ # @param currency_code [::String]
321
+ # A currency code in ISO4217 format, such as "AED", "USD", "JPY".
322
+ # If the field is empty, the report uses the entity's default currency.
323
+ # @param cohort_spec [::Google::Analytics::Data::V1alpha::CohortSpec, ::Hash]
324
+ # Cohort group associated with this request. If there is a cohort group
325
+ # in the request the 'cohort' dimension must be present.
326
+ # @param keep_empty_rows [::Boolean]
327
+ # If false or unspecified, each row with all metrics equal to 0 will not be
328
+ # returned. If true, these rows will be returned if they are not separately
329
+ # removed by a filter.
330
+ # @param return_property_quota [::Boolean]
331
+ # Toggles whether to return the current state of this Analytics Property's
332
+ # quota. Quota is returned in [PropertyQuota](#PropertyQuota).
333
+ #
334
+ # @yield [response, operation] Access the result along with the RPC operation
335
+ # @yieldparam response [::Google::Analytics::Data::V1alpha::RunPivotReportResponse]
336
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
337
+ #
338
+ # @return [::Google::Analytics::Data::V1alpha::RunPivotReportResponse]
339
+ #
340
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
341
+ #
342
+ def run_pivot_report request, options = nil
343
+ raise ::ArgumentError, "request must be provided" if request.nil?
344
+
345
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Analytics::Data::V1alpha::RunPivotReportRequest
346
+
347
+ # Converts hash and nil to an options object
348
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
349
+
350
+ # Customize the options with defaults
351
+ metadata = @config.rpcs.run_pivot_report.metadata.to_h
352
+
353
+ # Set x-goog-api-client and x-goog-user-project headers
354
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
355
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
356
+ gapic_version: ::Google::Analytics::Data::V1alpha::VERSION
357
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
358
+
359
+ options.apply_defaults timeout: @config.rpcs.run_pivot_report.timeout,
360
+ metadata: metadata,
361
+ retry_policy: @config.rpcs.run_pivot_report.retry_policy
362
+ options.apply_defaults metadata: @config.metadata,
363
+ retry_policy: @config.retry_policy
364
+
365
+ @analytics_data_stub.call_rpc :run_pivot_report, request, options: options do |response, operation|
366
+ yield response, operation if block_given?
367
+ return response
368
+ end
369
+ rescue ::GRPC::BadStatus => e
370
+ raise ::Google::Cloud::Error.from_error(e)
371
+ end
372
+
373
+ ##
374
+ # Returns multiple reports in a batch. All reports must be for the same
375
+ # Entity.
376
+ #
377
+ # @overload batch_run_reports(request, options = nil)
378
+ # Pass arguments to `batch_run_reports` via a request object, either of type
379
+ # {::Google::Analytics::Data::V1alpha::BatchRunReportsRequest} or an equivalent Hash.
380
+ #
381
+ # @param request [::Google::Analytics::Data::V1alpha::BatchRunReportsRequest, ::Hash]
382
+ # A request object representing the call parameters. Required. To specify no
383
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
384
+ # @param options [::Gapic::CallOptions, ::Hash]
385
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
386
+ #
387
+ # @overload batch_run_reports(entity: nil, requests: nil)
388
+ # Pass arguments to `batch_run_reports` via keyword arguments. Note that at
389
+ # least one keyword argument is required. To specify no parameters, or to keep all
390
+ # the default parameter values, pass an empty Hash as a request object (see above).
391
+ #
392
+ # @param entity [::Google::Analytics::Data::V1alpha::Entity, ::Hash]
393
+ # A property whose events are tracked. This entity must be specified for the
394
+ # batch. The entity within RunReportRequest may either be unspecified or
395
+ # consistent with this entity.
396
+ # @param requests [::Array<::Google::Analytics::Data::V1alpha::RunReportRequest, ::Hash>]
397
+ # Individual requests. Each request has a separate report response. Each
398
+ # batch request is allowed up to 5 requests.
399
+ #
400
+ # @yield [response, operation] Access the result along with the RPC operation
401
+ # @yieldparam response [::Google::Analytics::Data::V1alpha::BatchRunReportsResponse]
402
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
403
+ #
404
+ # @return [::Google::Analytics::Data::V1alpha::BatchRunReportsResponse]
405
+ #
406
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
407
+ #
408
+ def batch_run_reports request, options = nil
409
+ raise ::ArgumentError, "request must be provided" if request.nil?
410
+
411
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Analytics::Data::V1alpha::BatchRunReportsRequest
412
+
413
+ # Converts hash and nil to an options object
414
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
415
+
416
+ # Customize the options with defaults
417
+ metadata = @config.rpcs.batch_run_reports.metadata.to_h
418
+
419
+ # Set x-goog-api-client and x-goog-user-project headers
420
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
421
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
422
+ gapic_version: ::Google::Analytics::Data::V1alpha::VERSION
423
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
424
+
425
+ options.apply_defaults timeout: @config.rpcs.batch_run_reports.timeout,
426
+ metadata: metadata,
427
+ retry_policy: @config.rpcs.batch_run_reports.retry_policy
428
+ options.apply_defaults metadata: @config.metadata,
429
+ retry_policy: @config.retry_policy
430
+
431
+ @analytics_data_stub.call_rpc :batch_run_reports, request, options: options do |response, operation|
432
+ yield response, operation if block_given?
433
+ return response
434
+ end
435
+ rescue ::GRPC::BadStatus => e
436
+ raise ::Google::Cloud::Error.from_error(e)
437
+ end
438
+
439
+ ##
440
+ # Returns multiple pivot reports in a batch. All reports must be for the same
441
+ # Entity.
442
+ #
443
+ # @overload batch_run_pivot_reports(request, options = nil)
444
+ # Pass arguments to `batch_run_pivot_reports` via a request object, either of type
445
+ # {::Google::Analytics::Data::V1alpha::BatchRunPivotReportsRequest} or an equivalent Hash.
446
+ #
447
+ # @param request [::Google::Analytics::Data::V1alpha::BatchRunPivotReportsRequest, ::Hash]
448
+ # A request object representing the call parameters. Required. To specify no
449
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
450
+ # @param options [::Gapic::CallOptions, ::Hash]
451
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
452
+ #
453
+ # @overload batch_run_pivot_reports(entity: nil, requests: nil)
454
+ # Pass arguments to `batch_run_pivot_reports` via keyword arguments. Note that at
455
+ # least one keyword argument is required. To specify no parameters, or to keep all
456
+ # the default parameter values, pass an empty Hash as a request object (see above).
457
+ #
458
+ # @param entity [::Google::Analytics::Data::V1alpha::Entity, ::Hash]
459
+ # A property whose events are tracked. This entity must be specified for the
460
+ # batch. The entity within RunPivotReportRequest may either be unspecified or
461
+ # consistent with this entity.
462
+ # @param requests [::Array<::Google::Analytics::Data::V1alpha::RunPivotReportRequest, ::Hash>]
463
+ # Individual requests. Each request has a separate pivot report response.
464
+ # Each batch request is allowed up to 5 requests.
465
+ #
466
+ # @yield [response, operation] Access the result along with the RPC operation
467
+ # @yieldparam response [::Google::Analytics::Data::V1alpha::BatchRunPivotReportsResponse]
468
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
469
+ #
470
+ # @return [::Google::Analytics::Data::V1alpha::BatchRunPivotReportsResponse]
471
+ #
472
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
473
+ #
474
+ def batch_run_pivot_reports request, options = nil
475
+ raise ::ArgumentError, "request must be provided" if request.nil?
476
+
477
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Analytics::Data::V1alpha::BatchRunPivotReportsRequest
478
+
479
+ # Converts hash and nil to an options object
480
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
481
+
482
+ # Customize the options with defaults
483
+ metadata = @config.rpcs.batch_run_pivot_reports.metadata.to_h
484
+
485
+ # Set x-goog-api-client and x-goog-user-project headers
486
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
487
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
488
+ gapic_version: ::Google::Analytics::Data::V1alpha::VERSION
489
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
490
+
491
+ options.apply_defaults timeout: @config.rpcs.batch_run_pivot_reports.timeout,
492
+ metadata: metadata,
493
+ retry_policy: @config.rpcs.batch_run_pivot_reports.retry_policy
494
+ options.apply_defaults metadata: @config.metadata,
495
+ retry_policy: @config.retry_policy
496
+
497
+ @analytics_data_stub.call_rpc :batch_run_pivot_reports, request, options: options do |response, operation|
498
+ yield response, operation if block_given?
499
+ return response
500
+ end
501
+ rescue ::GRPC::BadStatus => e
502
+ raise ::Google::Cloud::Error.from_error(e)
503
+ end
504
+
505
+ ##
506
+ # Returns metadata for dimensions and metrics available in reporting methods.
507
+ # Used to explore the dimensions and metrics. Dimensions and metrics will be
508
+ # mostly added over time, but renames and deletions may occur.
509
+ #
510
+ # @overload get_metadata(request, options = nil)
511
+ # Pass arguments to `get_metadata` via a request object, either of type
512
+ # {::Google::Analytics::Data::V1alpha::GetMetadataRequest} or an equivalent Hash.
513
+ #
514
+ # @param request [::Google::Analytics::Data::V1alpha::GetMetadataRequest, ::Hash]
515
+ # A request object representing the call parameters. Required. To specify no
516
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
517
+ # @param options [::Gapic::CallOptions, ::Hash]
518
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
519
+ #
520
+ # @overload get_metadata(name: nil)
521
+ # Pass arguments to `get_metadata` via keyword arguments. Note that at
522
+ # least one keyword argument is required. To specify no parameters, or to keep all
523
+ # the default parameter values, pass an empty Hash as a request object (see above).
524
+ #
525
+ # @param name [::String]
526
+ # Required. The name of the metadata to retrieve. Either has the form
527
+ # 'metadata' or 'properties/\\{property}/metadata'. This name field is
528
+ # specified in the URL path and not URL parameters. Property is a numeric
529
+ # Google Analytics App + Web Property Id.
530
+ #
531
+ # @yield [response, operation] Access the result along with the RPC operation
532
+ # @yieldparam response [::Google::Analytics::Data::V1alpha::Metadata]
533
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
534
+ #
535
+ # @return [::Google::Analytics::Data::V1alpha::Metadata]
536
+ #
537
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
538
+ #
539
+ def get_metadata request, options = nil
540
+ raise ::ArgumentError, "request must be provided" if request.nil?
541
+
542
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Analytics::Data::V1alpha::GetMetadataRequest
543
+
544
+ # Converts hash and nil to an options object
545
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
546
+
547
+ # Customize the options with defaults
548
+ metadata = @config.rpcs.get_metadata.metadata.to_h
549
+
550
+ # Set x-goog-api-client and x-goog-user-project headers
551
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
552
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
553
+ gapic_version: ::Google::Analytics::Data::V1alpha::VERSION
554
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
555
+
556
+ header_params = {
557
+ "name" => request.name
558
+ }
559
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
560
+ metadata[:"x-goog-request-params"] ||= request_params_header
561
+
562
+ options.apply_defaults timeout: @config.rpcs.get_metadata.timeout,
563
+ metadata: metadata,
564
+ retry_policy: @config.rpcs.get_metadata.retry_policy
565
+ options.apply_defaults metadata: @config.metadata,
566
+ retry_policy: @config.retry_policy
567
+
568
+ @analytics_data_stub.call_rpc :get_metadata, request, options: options do |response, operation|
569
+ yield response, operation if block_given?
570
+ return response
571
+ end
572
+ rescue ::GRPC::BadStatus => e
573
+ raise ::Google::Cloud::Error.from_error(e)
574
+ end
575
+
576
+ ##
577
+ # Configuration class for the AnalyticsData API.
578
+ #
579
+ # This class represents the configuration for AnalyticsData,
580
+ # providing control over timeouts, retry behavior, logging, transport
581
+ # parameters, and other low-level controls. Certain parameters can also be
582
+ # applied individually to specific RPCs. See
583
+ # {::Google::Analytics::Data::V1alpha::AnalyticsData::Client::Configuration::Rpcs}
584
+ # for a list of RPCs that can be configured independently.
585
+ #
586
+ # Configuration can be applied globally to all clients, or to a single client
587
+ # on construction.
588
+ #
589
+ # # Examples
590
+ #
591
+ # To modify the global config, setting the timeout for run_report
592
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
593
+ #
594
+ # ::Google::Analytics::Data::V1alpha::AnalyticsData::Client.configure do |config|
595
+ # config.timeout = 10.0
596
+ # config.rpcs.run_report.timeout = 20.0
597
+ # end
598
+ #
599
+ # To apply the above configuration only to a new client:
600
+ #
601
+ # client = ::Google::Analytics::Data::V1alpha::AnalyticsData::Client.new do |config|
602
+ # config.timeout = 10.0
603
+ # config.rpcs.run_report.timeout = 20.0
604
+ # end
605
+ #
606
+ # @!attribute [rw] endpoint
607
+ # The hostname or hostname:port of the service endpoint.
608
+ # Defaults to `"analyticsdata.googleapis.com"`.
609
+ # @return [::String]
610
+ # @!attribute [rw] credentials
611
+ # Credentials to send with calls. You may provide any of the following types:
612
+ # * (`String`) The path to a service account key file in JSON format
613
+ # * (`Hash`) A service account key as a Hash
614
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
615
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
616
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
617
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
618
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
619
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
620
+ # * (`nil`) indicating no credentials
621
+ # @return [::Object]
622
+ # @!attribute [rw] scope
623
+ # The OAuth scopes
624
+ # @return [::Array<::String>]
625
+ # @!attribute [rw] lib_name
626
+ # The library name as recorded in instrumentation and logging
627
+ # @return [::String]
628
+ # @!attribute [rw] lib_version
629
+ # The library version as recorded in instrumentation and logging
630
+ # @return [::String]
631
+ # @!attribute [rw] channel_args
632
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
633
+ # `GRPC::Core::Channel` object is provided as the credential.
634
+ # @return [::Hash]
635
+ # @!attribute [rw] interceptors
636
+ # An array of interceptors that are run before calls are executed.
637
+ # @return [::Array<::GRPC::ClientInterceptor>]
638
+ # @!attribute [rw] timeout
639
+ # The call timeout in seconds.
640
+ # @return [::Numeric]
641
+ # @!attribute [rw] metadata
642
+ # Additional gRPC headers to be sent with the call.
643
+ # @return [::Hash{::Symbol=>::String}]
644
+ # @!attribute [rw] retry_policy
645
+ # The retry policy. The value is a hash with the following keys:
646
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
647
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
648
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
649
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
650
+ # trigger a retry.
651
+ # @return [::Hash]
652
+ # @!attribute [rw] quota_project
653
+ # A separate project against which to charge quota.
654
+ # @return [::String]
655
+ #
656
+ class Configuration
657
+ extend ::Gapic::Config
658
+
659
+ config_attr :endpoint, "analyticsdata.googleapis.com", ::String
660
+ config_attr :credentials, nil do |value|
661
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
662
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
663
+ allowed.any? { |klass| klass === value }
664
+ end
665
+ config_attr :scope, nil, ::String, ::Array, nil
666
+ config_attr :lib_name, nil, ::String, nil
667
+ config_attr :lib_version, nil, ::String, nil
668
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
669
+ config_attr :interceptors, nil, ::Array, nil
670
+ config_attr :timeout, nil, ::Numeric, nil
671
+ config_attr :metadata, nil, ::Hash, nil
672
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
673
+ config_attr :quota_project, nil, ::String, nil
674
+
675
+ # @private
676
+ def initialize parent_config = nil
677
+ @parent_config = parent_config unless parent_config.nil?
678
+
679
+ yield self if block_given?
680
+ end
681
+
682
+ ##
683
+ # Configurations for individual RPCs
684
+ # @return [Rpcs]
685
+ #
686
+ def rpcs
687
+ @rpcs ||= begin
688
+ parent_rpcs = nil
689
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
690
+ Rpcs.new parent_rpcs
691
+ end
692
+ end
693
+
694
+ ##
695
+ # Configuration RPC class for the AnalyticsData API.
696
+ #
697
+ # Includes fields providing the configuration for each RPC in this service.
698
+ # Each configuration object is of type `Gapic::Config::Method` and includes
699
+ # the following configuration fields:
700
+ #
701
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
702
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
703
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
704
+ # include the following keys:
705
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
706
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
707
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
708
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
709
+ # trigger a retry.
710
+ #
711
+ class Rpcs
712
+ ##
713
+ # RPC-specific configuration for `run_report`
714
+ # @return [::Gapic::Config::Method]
715
+ #
716
+ attr_reader :run_report
717
+ ##
718
+ # RPC-specific configuration for `run_pivot_report`
719
+ # @return [::Gapic::Config::Method]
720
+ #
721
+ attr_reader :run_pivot_report
722
+ ##
723
+ # RPC-specific configuration for `batch_run_reports`
724
+ # @return [::Gapic::Config::Method]
725
+ #
726
+ attr_reader :batch_run_reports
727
+ ##
728
+ # RPC-specific configuration for `batch_run_pivot_reports`
729
+ # @return [::Gapic::Config::Method]
730
+ #
731
+ attr_reader :batch_run_pivot_reports
732
+ ##
733
+ # RPC-specific configuration for `get_metadata`
734
+ # @return [::Gapic::Config::Method]
735
+ #
736
+ attr_reader :get_metadata
737
+
738
+ # @private
739
+ def initialize parent_rpcs = nil
740
+ run_report_config = parent_rpcs&.run_report if parent_rpcs&.respond_to? :run_report
741
+ @run_report = ::Gapic::Config::Method.new run_report_config
742
+ run_pivot_report_config = parent_rpcs&.run_pivot_report if parent_rpcs&.respond_to? :run_pivot_report
743
+ @run_pivot_report = ::Gapic::Config::Method.new run_pivot_report_config
744
+ batch_run_reports_config = parent_rpcs&.batch_run_reports if parent_rpcs&.respond_to? :batch_run_reports
745
+ @batch_run_reports = ::Gapic::Config::Method.new batch_run_reports_config
746
+ batch_run_pivot_reports_config = parent_rpcs&.batch_run_pivot_reports if parent_rpcs&.respond_to? :batch_run_pivot_reports
747
+ @batch_run_pivot_reports = ::Gapic::Config::Method.new batch_run_pivot_reports_config
748
+ get_metadata_config = parent_rpcs&.get_metadata if parent_rpcs&.respond_to? :get_metadata
749
+ @get_metadata = ::Gapic::Config::Method.new get_metadata_config
750
+
751
+ yield self if block_given?
752
+ end
753
+ end
754
+ end
755
+ end
756
+ end
757
+ end
758
+ end
759
+ end
760
+ end