• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.analytics.data.v1beta;
18 
19 import com.google.analytics.data.v1beta.stub.BetaAnalyticsDataStub;
20 import com.google.analytics.data.v1beta.stub.BetaAnalyticsDataStubSettings;
21 import com.google.api.core.BetaApi;
22 import com.google.api.gax.core.BackgroundResource;
23 import com.google.api.gax.rpc.UnaryCallable;
24 import java.io.IOException;
25 import java.util.concurrent.TimeUnit;
26 import javax.annotation.Generated;
27 
28 // AUTO-GENERATED DOCUMENTATION AND CLASS.
29 /**
30  * Service Description: Google Analytics reporting data service.
31  *
32  * <p>This class provides the ability to make remote calls to the backing service through method
33  * calls that map to API methods. Sample code to get started:
34  *
35  * <pre>{@code
36  * // This snippet has been automatically generated and should be regarded as a code template only.
37  * // It will require modifications to work:
38  * // - It may require correct/in-range values for request initialization.
39  * // - It may require specifying regional endpoints when creating the service client as shown in
40  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
41  * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
42  *   RunReportRequest request =
43  *       RunReportRequest.newBuilder()
44  *           .setProperty("property-993141291")
45  *           .addAllDimensions(new ArrayList<Dimension>())
46  *           .addAllMetrics(new ArrayList<Metric>())
47  *           .addAllDateRanges(new ArrayList<DateRange>())
48  *           .setDimensionFilter(FilterExpression.newBuilder().build())
49  *           .setMetricFilter(FilterExpression.newBuilder().build())
50  *           .setOffset(-1019779949)
51  *           .setLimit(102976443)
52  *           .addAllMetricAggregations(new ArrayList<MetricAggregation>())
53  *           .addAllOrderBys(new ArrayList<OrderBy>())
54  *           .setCurrencyCode("currencyCode1004773790")
55  *           .setCohortSpec(CohortSpec.newBuilder().build())
56  *           .setKeepEmptyRows(true)
57  *           .setReturnPropertyQuota(true)
58  *           .build();
59  *   RunReportResponse response = betaAnalyticsDataClient.runReport(request);
60  * }
61  * }</pre>
62  *
63  * <p>Note: close() needs to be called on the BetaAnalyticsDataClient object to clean up resources
64  * such as threads. In the example above, try-with-resources is used, which automatically calls
65  * close().
66  *
67  * <p>The surface of this class includes several types of Java methods for each of the API's
68  * methods:
69  *
70  * <ol>
71  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
72  *       converted into function parameters. It may be the case that not all fields are available as
73  *       parameters, and not every API method will have a flattened method entry point.
74  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
75  *       which must be constructed before the call. Not every API method will have a request object
76  *       method.
77  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
78  *       callable object, which can be used to initiate calls to the service.
79  * </ol>
80  *
81  * <p>See the individual methods for example code.
82  *
83  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
84  * these names, this class includes a format method for each type of name, and additionally a parse
85  * method to extract the individual identifiers contained within names that are returned.
86  *
87  * <p>This class can be customized by passing in a custom instance of BetaAnalyticsDataSettings to
88  * create(). For example:
89  *
90  * <p>To customize credentials:
91  *
92  * <pre>{@code
93  * // This snippet has been automatically generated and should be regarded as a code template only.
94  * // It will require modifications to work:
95  * // - It may require correct/in-range values for request initialization.
96  * // - It may require specifying regional endpoints when creating the service client as shown in
97  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
98  * BetaAnalyticsDataSettings betaAnalyticsDataSettings =
99  *     BetaAnalyticsDataSettings.newBuilder()
100  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
101  *         .build();
102  * BetaAnalyticsDataClient betaAnalyticsDataClient =
103  *     BetaAnalyticsDataClient.create(betaAnalyticsDataSettings);
104  * }</pre>
105  *
106  * <p>To customize the endpoint:
107  *
108  * <pre>{@code
109  * // This snippet has been automatically generated and should be regarded as a code template only.
110  * // It will require modifications to work:
111  * // - It may require correct/in-range values for request initialization.
112  * // - It may require specifying regional endpoints when creating the service client as shown in
113  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
114  * BetaAnalyticsDataSettings betaAnalyticsDataSettings =
115  *     BetaAnalyticsDataSettings.newBuilder().setEndpoint(myEndpoint).build();
116  * BetaAnalyticsDataClient betaAnalyticsDataClient =
117  *     BetaAnalyticsDataClient.create(betaAnalyticsDataSettings);
118  * }</pre>
119  *
120  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
121  * the wire:
122  *
123  * <pre>{@code
124  * // This snippet has been automatically generated and should be regarded as a code template only.
125  * // It will require modifications to work:
126  * // - It may require correct/in-range values for request initialization.
127  * // - It may require specifying regional endpoints when creating the service client as shown in
128  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
129  * BetaAnalyticsDataSettings betaAnalyticsDataSettings =
130  *     BetaAnalyticsDataSettings.newHttpJsonBuilder().build();
131  * BetaAnalyticsDataClient betaAnalyticsDataClient =
132  *     BetaAnalyticsDataClient.create(betaAnalyticsDataSettings);
133  * }</pre>
134  *
135  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
136  */
137 @BetaApi
138 @Generated("by gapic-generator-java")
139 public class BetaAnalyticsDataClient implements BackgroundResource {
140   private final BetaAnalyticsDataSettings settings;
141   private final BetaAnalyticsDataStub stub;
142 
143   /** Constructs an instance of BetaAnalyticsDataClient with default settings. */
create()144   public static final BetaAnalyticsDataClient create() throws IOException {
145     return create(BetaAnalyticsDataSettings.newBuilder().build());
146   }
147 
148   /**
149    * Constructs an instance of BetaAnalyticsDataClient, using the given settings. The channels are
150    * created based on the settings passed in, or defaults for any settings that are not set.
151    */
create(BetaAnalyticsDataSettings settings)152   public static final BetaAnalyticsDataClient create(BetaAnalyticsDataSettings settings)
153       throws IOException {
154     return new BetaAnalyticsDataClient(settings);
155   }
156 
157   /**
158    * Constructs an instance of BetaAnalyticsDataClient, using the given stub for making calls. This
159    * is for advanced usage - prefer using create(BetaAnalyticsDataSettings).
160    */
create(BetaAnalyticsDataStub stub)161   public static final BetaAnalyticsDataClient create(BetaAnalyticsDataStub stub) {
162     return new BetaAnalyticsDataClient(stub);
163   }
164 
165   /**
166    * Constructs an instance of BetaAnalyticsDataClient, using the given settings. This is protected
167    * so that it is easy to make a subclass, but otherwise, the static factory methods should be
168    * preferred.
169    */
BetaAnalyticsDataClient(BetaAnalyticsDataSettings settings)170   protected BetaAnalyticsDataClient(BetaAnalyticsDataSettings settings) throws IOException {
171     this.settings = settings;
172     this.stub = ((BetaAnalyticsDataStubSettings) settings.getStubSettings()).createStub();
173   }
174 
BetaAnalyticsDataClient(BetaAnalyticsDataStub stub)175   protected BetaAnalyticsDataClient(BetaAnalyticsDataStub stub) {
176     this.settings = null;
177     this.stub = stub;
178   }
179 
getSettings()180   public final BetaAnalyticsDataSettings getSettings() {
181     return settings;
182   }
183 
getStub()184   public BetaAnalyticsDataStub getStub() {
185     return stub;
186   }
187 
188   // AUTO-GENERATED DOCUMENTATION AND METHOD.
189   /**
190    * Returns a customized report of your Google Analytics event data. Reports contain statistics
191    * derived from data collected by the Google Analytics tracking code. The data returned from the
192    * API is as a table with columns for the requested dimensions and metrics. Metrics are individual
193    * measurements of user activity on your property, such as active users or event count. Dimensions
194    * break down metrics across some common criteria, such as country or event name.
195    *
196    * <p>For a guide to constructing requests &amp; understanding responses, see [Creating a
197    * Report](https://developers.google.com/analytics/devguides/reporting/data/v1/basics).
198    *
199    * <p>Sample code:
200    *
201    * <pre>{@code
202    * // This snippet has been automatically generated and should be regarded as a code template only.
203    * // It will require modifications to work:
204    * // - It may require correct/in-range values for request initialization.
205    * // - It may require specifying regional endpoints when creating the service client as shown in
206    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
207    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
208    *   RunReportRequest request =
209    *       RunReportRequest.newBuilder()
210    *           .setProperty("property-993141291")
211    *           .addAllDimensions(new ArrayList<Dimension>())
212    *           .addAllMetrics(new ArrayList<Metric>())
213    *           .addAllDateRanges(new ArrayList<DateRange>())
214    *           .setDimensionFilter(FilterExpression.newBuilder().build())
215    *           .setMetricFilter(FilterExpression.newBuilder().build())
216    *           .setOffset(-1019779949)
217    *           .setLimit(102976443)
218    *           .addAllMetricAggregations(new ArrayList<MetricAggregation>())
219    *           .addAllOrderBys(new ArrayList<OrderBy>())
220    *           .setCurrencyCode("currencyCode1004773790")
221    *           .setCohortSpec(CohortSpec.newBuilder().build())
222    *           .setKeepEmptyRows(true)
223    *           .setReturnPropertyQuota(true)
224    *           .build();
225    *   RunReportResponse response = betaAnalyticsDataClient.runReport(request);
226    * }
227    * }</pre>
228    *
229    * @param request The request object containing all of the parameters for the API call.
230    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
231    */
runReport(RunReportRequest request)232   public final RunReportResponse runReport(RunReportRequest request) {
233     return runReportCallable().call(request);
234   }
235 
236   // AUTO-GENERATED DOCUMENTATION AND METHOD.
237   /**
238    * Returns a customized report of your Google Analytics event data. Reports contain statistics
239    * derived from data collected by the Google Analytics tracking code. The data returned from the
240    * API is as a table with columns for the requested dimensions and metrics. Metrics are individual
241    * measurements of user activity on your property, such as active users or event count. Dimensions
242    * break down metrics across some common criteria, such as country or event name.
243    *
244    * <p>For a guide to constructing requests &amp; understanding responses, see [Creating a
245    * Report](https://developers.google.com/analytics/devguides/reporting/data/v1/basics).
246    *
247    * <p>Sample code:
248    *
249    * <pre>{@code
250    * // This snippet has been automatically generated and should be regarded as a code template only.
251    * // It will require modifications to work:
252    * // - It may require correct/in-range values for request initialization.
253    * // - It may require specifying regional endpoints when creating the service client as shown in
254    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
255    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
256    *   RunReportRequest request =
257    *       RunReportRequest.newBuilder()
258    *           .setProperty("property-993141291")
259    *           .addAllDimensions(new ArrayList<Dimension>())
260    *           .addAllMetrics(new ArrayList<Metric>())
261    *           .addAllDateRanges(new ArrayList<DateRange>())
262    *           .setDimensionFilter(FilterExpression.newBuilder().build())
263    *           .setMetricFilter(FilterExpression.newBuilder().build())
264    *           .setOffset(-1019779949)
265    *           .setLimit(102976443)
266    *           .addAllMetricAggregations(new ArrayList<MetricAggregation>())
267    *           .addAllOrderBys(new ArrayList<OrderBy>())
268    *           .setCurrencyCode("currencyCode1004773790")
269    *           .setCohortSpec(CohortSpec.newBuilder().build())
270    *           .setKeepEmptyRows(true)
271    *           .setReturnPropertyQuota(true)
272    *           .build();
273    *   ApiFuture<RunReportResponse> future =
274    *       betaAnalyticsDataClient.runReportCallable().futureCall(request);
275    *   // Do something.
276    *   RunReportResponse response = future.get();
277    * }
278    * }</pre>
279    */
runReportCallable()280   public final UnaryCallable<RunReportRequest, RunReportResponse> runReportCallable() {
281     return stub.runReportCallable();
282   }
283 
284   // AUTO-GENERATED DOCUMENTATION AND METHOD.
285   /**
286    * Returns a customized pivot report of your Google Analytics event data. Pivot reports are more
287    * advanced and expressive formats than regular reports. In a pivot report, dimensions are only
288    * visible if they are included in a pivot. Multiple pivots can be specified to further dissect
289    * your data.
290    *
291    * <p>Sample code:
292    *
293    * <pre>{@code
294    * // This snippet has been automatically generated and should be regarded as a code template only.
295    * // It will require modifications to work:
296    * // - It may require correct/in-range values for request initialization.
297    * // - It may require specifying regional endpoints when creating the service client as shown in
298    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
299    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
300    *   RunPivotReportRequest request =
301    *       RunPivotReportRequest.newBuilder()
302    *           .setProperty("property-993141291")
303    *           .addAllDimensions(new ArrayList<Dimension>())
304    *           .addAllMetrics(new ArrayList<Metric>())
305    *           .addAllDateRanges(new ArrayList<DateRange>())
306    *           .addAllPivots(new ArrayList<Pivot>())
307    *           .setDimensionFilter(FilterExpression.newBuilder().build())
308    *           .setMetricFilter(FilterExpression.newBuilder().build())
309    *           .setCurrencyCode("currencyCode1004773790")
310    *           .setCohortSpec(CohortSpec.newBuilder().build())
311    *           .setKeepEmptyRows(true)
312    *           .setReturnPropertyQuota(true)
313    *           .build();
314    *   RunPivotReportResponse response = betaAnalyticsDataClient.runPivotReport(request);
315    * }
316    * }</pre>
317    *
318    * @param request The request object containing all of the parameters for the API call.
319    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
320    */
runPivotReport(RunPivotReportRequest request)321   public final RunPivotReportResponse runPivotReport(RunPivotReportRequest request) {
322     return runPivotReportCallable().call(request);
323   }
324 
325   // AUTO-GENERATED DOCUMENTATION AND METHOD.
326   /**
327    * Returns a customized pivot report of your Google Analytics event data. Pivot reports are more
328    * advanced and expressive formats than regular reports. In a pivot report, dimensions are only
329    * visible if they are included in a pivot. Multiple pivots can be specified to further dissect
330    * your data.
331    *
332    * <p>Sample code:
333    *
334    * <pre>{@code
335    * // This snippet has been automatically generated and should be regarded as a code template only.
336    * // It will require modifications to work:
337    * // - It may require correct/in-range values for request initialization.
338    * // - It may require specifying regional endpoints when creating the service client as shown in
339    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
340    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
341    *   RunPivotReportRequest request =
342    *       RunPivotReportRequest.newBuilder()
343    *           .setProperty("property-993141291")
344    *           .addAllDimensions(new ArrayList<Dimension>())
345    *           .addAllMetrics(new ArrayList<Metric>())
346    *           .addAllDateRanges(new ArrayList<DateRange>())
347    *           .addAllPivots(new ArrayList<Pivot>())
348    *           .setDimensionFilter(FilterExpression.newBuilder().build())
349    *           .setMetricFilter(FilterExpression.newBuilder().build())
350    *           .setCurrencyCode("currencyCode1004773790")
351    *           .setCohortSpec(CohortSpec.newBuilder().build())
352    *           .setKeepEmptyRows(true)
353    *           .setReturnPropertyQuota(true)
354    *           .build();
355    *   ApiFuture<RunPivotReportResponse> future =
356    *       betaAnalyticsDataClient.runPivotReportCallable().futureCall(request);
357    *   // Do something.
358    *   RunPivotReportResponse response = future.get();
359    * }
360    * }</pre>
361    */
362   public final UnaryCallable<RunPivotReportRequest, RunPivotReportResponse>
runPivotReportCallable()363       runPivotReportCallable() {
364     return stub.runPivotReportCallable();
365   }
366 
367   // AUTO-GENERATED DOCUMENTATION AND METHOD.
368   /**
369    * Returns multiple reports in a batch. All reports must be for the same GA4 Property.
370    *
371    * <p>Sample code:
372    *
373    * <pre>{@code
374    * // This snippet has been automatically generated and should be regarded as a code template only.
375    * // It will require modifications to work:
376    * // - It may require correct/in-range values for request initialization.
377    * // - It may require specifying regional endpoints when creating the service client as shown in
378    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
379    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
380    *   BatchRunReportsRequest request =
381    *       BatchRunReportsRequest.newBuilder()
382    *           .setProperty("property-993141291")
383    *           .addAllRequests(new ArrayList<RunReportRequest>())
384    *           .build();
385    *   BatchRunReportsResponse response = betaAnalyticsDataClient.batchRunReports(request);
386    * }
387    * }</pre>
388    *
389    * @param request The request object containing all of the parameters for the API call.
390    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
391    */
batchRunReports(BatchRunReportsRequest request)392   public final BatchRunReportsResponse batchRunReports(BatchRunReportsRequest request) {
393     return batchRunReportsCallable().call(request);
394   }
395 
396   // AUTO-GENERATED DOCUMENTATION AND METHOD.
397   /**
398    * Returns multiple reports in a batch. All reports must be for the same GA4 Property.
399    *
400    * <p>Sample code:
401    *
402    * <pre>{@code
403    * // This snippet has been automatically generated and should be regarded as a code template only.
404    * // It will require modifications to work:
405    * // - It may require correct/in-range values for request initialization.
406    * // - It may require specifying regional endpoints when creating the service client as shown in
407    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
408    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
409    *   BatchRunReportsRequest request =
410    *       BatchRunReportsRequest.newBuilder()
411    *           .setProperty("property-993141291")
412    *           .addAllRequests(new ArrayList<RunReportRequest>())
413    *           .build();
414    *   ApiFuture<BatchRunReportsResponse> future =
415    *       betaAnalyticsDataClient.batchRunReportsCallable().futureCall(request);
416    *   // Do something.
417    *   BatchRunReportsResponse response = future.get();
418    * }
419    * }</pre>
420    */
421   public final UnaryCallable<BatchRunReportsRequest, BatchRunReportsResponse>
batchRunReportsCallable()422       batchRunReportsCallable() {
423     return stub.batchRunReportsCallable();
424   }
425 
426   // AUTO-GENERATED DOCUMENTATION AND METHOD.
427   /**
428    * Returns multiple pivot reports in a batch. All reports must be for the same GA4 Property.
429    *
430    * <p>Sample code:
431    *
432    * <pre>{@code
433    * // This snippet has been automatically generated and should be regarded as a code template only.
434    * // It will require modifications to work:
435    * // - It may require correct/in-range values for request initialization.
436    * // - It may require specifying regional endpoints when creating the service client as shown in
437    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
438    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
439    *   BatchRunPivotReportsRequest request =
440    *       BatchRunPivotReportsRequest.newBuilder()
441    *           .setProperty("property-993141291")
442    *           .addAllRequests(new ArrayList<RunPivotReportRequest>())
443    *           .build();
444    *   BatchRunPivotReportsResponse response = betaAnalyticsDataClient.batchRunPivotReports(request);
445    * }
446    * }</pre>
447    *
448    * @param request The request object containing all of the parameters for the API call.
449    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
450    */
batchRunPivotReports( BatchRunPivotReportsRequest request)451   public final BatchRunPivotReportsResponse batchRunPivotReports(
452       BatchRunPivotReportsRequest request) {
453     return batchRunPivotReportsCallable().call(request);
454   }
455 
456   // AUTO-GENERATED DOCUMENTATION AND METHOD.
457   /**
458    * Returns multiple pivot reports in a batch. All reports must be for the same GA4 Property.
459    *
460    * <p>Sample code:
461    *
462    * <pre>{@code
463    * // This snippet has been automatically generated and should be regarded as a code template only.
464    * // It will require modifications to work:
465    * // - It may require correct/in-range values for request initialization.
466    * // - It may require specifying regional endpoints when creating the service client as shown in
467    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
468    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
469    *   BatchRunPivotReportsRequest request =
470    *       BatchRunPivotReportsRequest.newBuilder()
471    *           .setProperty("property-993141291")
472    *           .addAllRequests(new ArrayList<RunPivotReportRequest>())
473    *           .build();
474    *   ApiFuture<BatchRunPivotReportsResponse> future =
475    *       betaAnalyticsDataClient.batchRunPivotReportsCallable().futureCall(request);
476    *   // Do something.
477    *   BatchRunPivotReportsResponse response = future.get();
478    * }
479    * }</pre>
480    */
481   public final UnaryCallable<BatchRunPivotReportsRequest, BatchRunPivotReportsResponse>
batchRunPivotReportsCallable()482       batchRunPivotReportsCallable() {
483     return stub.batchRunPivotReportsCallable();
484   }
485 
486   // AUTO-GENERATED DOCUMENTATION AND METHOD.
487   /**
488    * Returns metadata for dimensions and metrics available in reporting methods. Used to explore the
489    * dimensions and metrics. In this method, a Google Analytics GA4 Property Identifier is specified
490    * in the request, and the metadata response includes Custom dimensions and metrics as well as
491    * Universal metadata.
492    *
493    * <p>For example if a custom metric with parameter name `levels_unlocked` is registered to a
494    * property, the Metadata response will contain `customEvent:levels_unlocked`. Universal metadata
495    * are dimensions and metrics applicable to any property such as `country` and `totalUsers`.
496    *
497    * <p>Sample code:
498    *
499    * <pre>{@code
500    * // This snippet has been automatically generated and should be regarded as a code template only.
501    * // It will require modifications to work:
502    * // - It may require correct/in-range values for request initialization.
503    * // - It may require specifying regional endpoints when creating the service client as shown in
504    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
505    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
506    *   MetadataName name = MetadataName.of("[PROPERTY]");
507    *   Metadata response = betaAnalyticsDataClient.getMetadata(name);
508    * }
509    * }</pre>
510    *
511    * @param name Required. The resource name of the metadata to retrieve. This name field is
512    *     specified in the URL path and not URL parameters. Property is a numeric Google Analytics
513    *     GA4 Property identifier. To learn more, see [where to find your Property
514    *     ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id).
515    *     <p>Example: properties/1234/metadata
516    *     <p>Set the Property ID to 0 for dimensions and metrics common to all properties. In this
517    *     special mode, this method will not return custom dimensions and metrics.
518    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
519    */
getMetadata(MetadataName name)520   public final Metadata getMetadata(MetadataName name) {
521     GetMetadataRequest request =
522         GetMetadataRequest.newBuilder().setName(name == null ? null : name.toString()).build();
523     return getMetadata(request);
524   }
525 
526   // AUTO-GENERATED DOCUMENTATION AND METHOD.
527   /**
528    * Returns metadata for dimensions and metrics available in reporting methods. Used to explore the
529    * dimensions and metrics. In this method, a Google Analytics GA4 Property Identifier is specified
530    * in the request, and the metadata response includes Custom dimensions and metrics as well as
531    * Universal metadata.
532    *
533    * <p>For example if a custom metric with parameter name `levels_unlocked` is registered to a
534    * property, the Metadata response will contain `customEvent:levels_unlocked`. Universal metadata
535    * are dimensions and metrics applicable to any property such as `country` and `totalUsers`.
536    *
537    * <p>Sample code:
538    *
539    * <pre>{@code
540    * // This snippet has been automatically generated and should be regarded as a code template only.
541    * // It will require modifications to work:
542    * // - It may require correct/in-range values for request initialization.
543    * // - It may require specifying regional endpoints when creating the service client as shown in
544    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
545    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
546    *   String name = MetadataName.of("[PROPERTY]").toString();
547    *   Metadata response = betaAnalyticsDataClient.getMetadata(name);
548    * }
549    * }</pre>
550    *
551    * @param name Required. The resource name of the metadata to retrieve. This name field is
552    *     specified in the URL path and not URL parameters. Property is a numeric Google Analytics
553    *     GA4 Property identifier. To learn more, see [where to find your Property
554    *     ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id).
555    *     <p>Example: properties/1234/metadata
556    *     <p>Set the Property ID to 0 for dimensions and metrics common to all properties. In this
557    *     special mode, this method will not return custom dimensions and metrics.
558    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
559    */
getMetadata(String name)560   public final Metadata getMetadata(String name) {
561     GetMetadataRequest request = GetMetadataRequest.newBuilder().setName(name).build();
562     return getMetadata(request);
563   }
564 
565   // AUTO-GENERATED DOCUMENTATION AND METHOD.
566   /**
567    * Returns metadata for dimensions and metrics available in reporting methods. Used to explore the
568    * dimensions and metrics. In this method, a Google Analytics GA4 Property Identifier is specified
569    * in the request, and the metadata response includes Custom dimensions and metrics as well as
570    * Universal metadata.
571    *
572    * <p>For example if a custom metric with parameter name `levels_unlocked` is registered to a
573    * property, the Metadata response will contain `customEvent:levels_unlocked`. Universal metadata
574    * are dimensions and metrics applicable to any property such as `country` and `totalUsers`.
575    *
576    * <p>Sample code:
577    *
578    * <pre>{@code
579    * // This snippet has been automatically generated and should be regarded as a code template only.
580    * // It will require modifications to work:
581    * // - It may require correct/in-range values for request initialization.
582    * // - It may require specifying regional endpoints when creating the service client as shown in
583    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
584    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
585    *   GetMetadataRequest request =
586    *       GetMetadataRequest.newBuilder().setName(MetadataName.of("[PROPERTY]").toString()).build();
587    *   Metadata response = betaAnalyticsDataClient.getMetadata(request);
588    * }
589    * }</pre>
590    *
591    * @param request The request object containing all of the parameters for the API call.
592    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
593    */
getMetadata(GetMetadataRequest request)594   public final Metadata getMetadata(GetMetadataRequest request) {
595     return getMetadataCallable().call(request);
596   }
597 
598   // AUTO-GENERATED DOCUMENTATION AND METHOD.
599   /**
600    * Returns metadata for dimensions and metrics available in reporting methods. Used to explore the
601    * dimensions and metrics. In this method, a Google Analytics GA4 Property Identifier is specified
602    * in the request, and the metadata response includes Custom dimensions and metrics as well as
603    * Universal metadata.
604    *
605    * <p>For example if a custom metric with parameter name `levels_unlocked` is registered to a
606    * property, the Metadata response will contain `customEvent:levels_unlocked`. Universal metadata
607    * are dimensions and metrics applicable to any property such as `country` and `totalUsers`.
608    *
609    * <p>Sample code:
610    *
611    * <pre>{@code
612    * // This snippet has been automatically generated and should be regarded as a code template only.
613    * // It will require modifications to work:
614    * // - It may require correct/in-range values for request initialization.
615    * // - It may require specifying regional endpoints when creating the service client as shown in
616    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
617    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
618    *   GetMetadataRequest request =
619    *       GetMetadataRequest.newBuilder().setName(MetadataName.of("[PROPERTY]").toString()).build();
620    *   ApiFuture<Metadata> future =
621    *       betaAnalyticsDataClient.getMetadataCallable().futureCall(request);
622    *   // Do something.
623    *   Metadata response = future.get();
624    * }
625    * }</pre>
626    */
getMetadataCallable()627   public final UnaryCallable<GetMetadataRequest, Metadata> getMetadataCallable() {
628     return stub.getMetadataCallable();
629   }
630 
631   // AUTO-GENERATED DOCUMENTATION AND METHOD.
632   /**
633    * Returns a customized report of realtime event data for your property. Events appear in realtime
634    * reports seconds after they have been sent to the Google Analytics. Realtime reports show events
635    * and usage data for the periods of time ranging from the present moment to 30 minutes ago (up to
636    * 60 minutes for Google Analytics 360 properties).
637    *
638    * <p>For a guide to constructing realtime requests &amp; understanding responses, see [Creating a
639    * Realtime
640    * Report](https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-basics).
641    *
642    * <p>Sample code:
643    *
644    * <pre>{@code
645    * // This snippet has been automatically generated and should be regarded as a code template only.
646    * // It will require modifications to work:
647    * // - It may require correct/in-range values for request initialization.
648    * // - It may require specifying regional endpoints when creating the service client as shown in
649    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
650    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
651    *   RunRealtimeReportRequest request =
652    *       RunRealtimeReportRequest.newBuilder()
653    *           .setProperty("property-993141291")
654    *           .addAllDimensions(new ArrayList<Dimension>())
655    *           .addAllMetrics(new ArrayList<Metric>())
656    *           .setDimensionFilter(FilterExpression.newBuilder().build())
657    *           .setMetricFilter(FilterExpression.newBuilder().build())
658    *           .setLimit(102976443)
659    *           .addAllMetricAggregations(new ArrayList<MetricAggregation>())
660    *           .addAllOrderBys(new ArrayList<OrderBy>())
661    *           .setReturnPropertyQuota(true)
662    *           .addAllMinuteRanges(new ArrayList<MinuteRange>())
663    *           .build();
664    *   RunRealtimeReportResponse response = betaAnalyticsDataClient.runRealtimeReport(request);
665    * }
666    * }</pre>
667    *
668    * @param request The request object containing all of the parameters for the API call.
669    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
670    */
runRealtimeReport(RunRealtimeReportRequest request)671   public final RunRealtimeReportResponse runRealtimeReport(RunRealtimeReportRequest request) {
672     return runRealtimeReportCallable().call(request);
673   }
674 
675   // AUTO-GENERATED DOCUMENTATION AND METHOD.
676   /**
677    * Returns a customized report of realtime event data for your property. Events appear in realtime
678    * reports seconds after they have been sent to the Google Analytics. Realtime reports show events
679    * and usage data for the periods of time ranging from the present moment to 30 minutes ago (up to
680    * 60 minutes for Google Analytics 360 properties).
681    *
682    * <p>For a guide to constructing realtime requests &amp; understanding responses, see [Creating a
683    * Realtime
684    * Report](https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-basics).
685    *
686    * <p>Sample code:
687    *
688    * <pre>{@code
689    * // This snippet has been automatically generated and should be regarded as a code template only.
690    * // It will require modifications to work:
691    * // - It may require correct/in-range values for request initialization.
692    * // - It may require specifying regional endpoints when creating the service client as shown in
693    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
694    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
695    *   RunRealtimeReportRequest request =
696    *       RunRealtimeReportRequest.newBuilder()
697    *           .setProperty("property-993141291")
698    *           .addAllDimensions(new ArrayList<Dimension>())
699    *           .addAllMetrics(new ArrayList<Metric>())
700    *           .setDimensionFilter(FilterExpression.newBuilder().build())
701    *           .setMetricFilter(FilterExpression.newBuilder().build())
702    *           .setLimit(102976443)
703    *           .addAllMetricAggregations(new ArrayList<MetricAggregation>())
704    *           .addAllOrderBys(new ArrayList<OrderBy>())
705    *           .setReturnPropertyQuota(true)
706    *           .addAllMinuteRanges(new ArrayList<MinuteRange>())
707    *           .build();
708    *   ApiFuture<RunRealtimeReportResponse> future =
709    *       betaAnalyticsDataClient.runRealtimeReportCallable().futureCall(request);
710    *   // Do something.
711    *   RunRealtimeReportResponse response = future.get();
712    * }
713    * }</pre>
714    */
715   public final UnaryCallable<RunRealtimeReportRequest, RunRealtimeReportResponse>
runRealtimeReportCallable()716       runRealtimeReportCallable() {
717     return stub.runRealtimeReportCallable();
718   }
719 
720   // AUTO-GENERATED DOCUMENTATION AND METHOD.
721   /**
722    * This compatibility method lists dimensions and metrics that can be added to a report request
723    * and maintain compatibility. This method fails if the request's dimensions and metrics are
724    * incompatible.
725    *
726    * <p>In Google Analytics, reports fail if they request incompatible dimensions and/or metrics; in
727    * that case, you will need to remove dimensions and/or metrics from the incompatible report until
728    * the report is compatible.
729    *
730    * <p>The Realtime and Core reports have different compatibility rules. This method checks
731    * compatibility for Core reports.
732    *
733    * <p>Sample code:
734    *
735    * <pre>{@code
736    * // This snippet has been automatically generated and should be regarded as a code template only.
737    * // It will require modifications to work:
738    * // - It may require correct/in-range values for request initialization.
739    * // - It may require specifying regional endpoints when creating the service client as shown in
740    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
741    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
742    *   CheckCompatibilityRequest request =
743    *       CheckCompatibilityRequest.newBuilder()
744    *           .setProperty("property-993141291")
745    *           .addAllDimensions(new ArrayList<Dimension>())
746    *           .addAllMetrics(new ArrayList<Metric>())
747    *           .setDimensionFilter(FilterExpression.newBuilder().build())
748    *           .setMetricFilter(FilterExpression.newBuilder().build())
749    *           .setCompatibilityFilter(Compatibility.forNumber(0))
750    *           .build();
751    *   CheckCompatibilityResponse response = betaAnalyticsDataClient.checkCompatibility(request);
752    * }
753    * }</pre>
754    *
755    * @param request The request object containing all of the parameters for the API call.
756    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
757    */
checkCompatibility(CheckCompatibilityRequest request)758   public final CheckCompatibilityResponse checkCompatibility(CheckCompatibilityRequest request) {
759     return checkCompatibilityCallable().call(request);
760   }
761 
762   // AUTO-GENERATED DOCUMENTATION AND METHOD.
763   /**
764    * This compatibility method lists dimensions and metrics that can be added to a report request
765    * and maintain compatibility. This method fails if the request's dimensions and metrics are
766    * incompatible.
767    *
768    * <p>In Google Analytics, reports fail if they request incompatible dimensions and/or metrics; in
769    * that case, you will need to remove dimensions and/or metrics from the incompatible report until
770    * the report is compatible.
771    *
772    * <p>The Realtime and Core reports have different compatibility rules. This method checks
773    * compatibility for Core reports.
774    *
775    * <p>Sample code:
776    *
777    * <pre>{@code
778    * // This snippet has been automatically generated and should be regarded as a code template only.
779    * // It will require modifications to work:
780    * // - It may require correct/in-range values for request initialization.
781    * // - It may require specifying regional endpoints when creating the service client as shown in
782    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
783    * try (BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.create()) {
784    *   CheckCompatibilityRequest request =
785    *       CheckCompatibilityRequest.newBuilder()
786    *           .setProperty("property-993141291")
787    *           .addAllDimensions(new ArrayList<Dimension>())
788    *           .addAllMetrics(new ArrayList<Metric>())
789    *           .setDimensionFilter(FilterExpression.newBuilder().build())
790    *           .setMetricFilter(FilterExpression.newBuilder().build())
791    *           .setCompatibilityFilter(Compatibility.forNumber(0))
792    *           .build();
793    *   ApiFuture<CheckCompatibilityResponse> future =
794    *       betaAnalyticsDataClient.checkCompatibilityCallable().futureCall(request);
795    *   // Do something.
796    *   CheckCompatibilityResponse response = future.get();
797    * }
798    * }</pre>
799    */
800   public final UnaryCallable<CheckCompatibilityRequest, CheckCompatibilityResponse>
checkCompatibilityCallable()801       checkCompatibilityCallable() {
802     return stub.checkCompatibilityCallable();
803   }
804 
805   @Override
close()806   public final void close() {
807     stub.close();
808   }
809 
810   @Override
shutdown()811   public void shutdown() {
812     stub.shutdown();
813   }
814 
815   @Override
isShutdown()816   public boolean isShutdown() {
817     return stub.isShutdown();
818   }
819 
820   @Override
isTerminated()821   public boolean isTerminated() {
822     return stub.isTerminated();
823   }
824 
825   @Override
shutdownNow()826   public void shutdownNow() {
827     stub.shutdownNow();
828   }
829 
830   @Override
awaitTermination(long duration, TimeUnit unit)831   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
832     return stub.awaitTermination(duration, unit);
833   }
834 }
835