-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
CreateReportTask
, QueryReportTask
, GetReportTask
, `Li…
…stReportTasks` methods to the Data API v1alpha (#7295) feat: add `ReportTask`, `Metric`, `OrderBy`, `Cohort`, `CohortsRange`, `CohortReportSettings`, `ResponseMetaData`, `MetricAggregation`, `RestrictedMetricType` types to the Data API v1alpha PiperOrigin-RevId: 631240474 Source-Link: googleapis/googleapis@2df3336 Source-Link: googleapis/googleapis-gen@4dee394 Copy-Tag: eyJwIjoiQW5hbHl0aWNzRGF0YS8uT3dsQm90LnlhbWwiLCJoIjoiNGRlZTM5NGQyYzIwYjY5YTdiMDE3N2U4MzU0ODk5MmQ3MGJmMmQ3MyJ9
- Loading branch information
1 parent
0f600d2
commit bd673bd
Showing
34 changed files
with
4,618 additions
and
83 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
89 changes: 89 additions & 0 deletions
89
AnalyticsData/samples/V1alpha/AlphaAnalyticsDataClient/create_report_task.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START analyticsdata_v1alpha_generated_AlphaAnalyticsData_CreateReportTask_sync] | ||
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient; | ||
use Google\Analytics\Data\V1alpha\CreateReportTaskRequest; | ||
use Google\Analytics\Data\V1alpha\ReportTask; | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\OperationResponse; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Initiates the creation of a report task. This method quickly | ||
* returns a report task and initiates a long running | ||
* asynchronous request to form a customized report of your Google Analytics | ||
* event data. | ||
* | ||
* @param string $formattedParent The parent resource where this report task will be created. | ||
* Format: `properties/{propertyId}` | ||
* Please see {@see AlphaAnalyticsDataClient::propertyName()} for help formatting this field. | ||
*/ | ||
function create_report_task_sample(string $formattedParent): void | ||
{ | ||
// Create a client. | ||
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient(); | ||
|
||
// Prepare the request message. | ||
$reportTask = new ReportTask(); | ||
$request = (new CreateReportTaskRequest()) | ||
->setParent($formattedParent) | ||
->setReportTask($reportTask); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $alphaAnalyticsDataClient->createReportTask($request); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
/** @var ReportTask $result */ | ||
$result = $response->getResult(); | ||
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); | ||
} else { | ||
/** @var Status $error */ | ||
$error = $response->getError(); | ||
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); | ||
} | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedParent = AlphaAnalyticsDataClient::propertyName('[PROPERTY]'); | ||
|
||
create_report_task_sample($formattedParent); | ||
} | ||
// [END analyticsdata_v1alpha_generated_AlphaAnalyticsData_CreateReportTask_sync] |
74 changes: 74 additions & 0 deletions
74
AnalyticsData/samples/V1alpha/AlphaAnalyticsDataClient/get_report_task.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START analyticsdata_v1alpha_generated_AlphaAnalyticsData_GetReportTask_sync] | ||
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient; | ||
use Google\Analytics\Data\V1alpha\GetReportTaskRequest; | ||
use Google\Analytics\Data\V1alpha\ReportTask; | ||
use Google\ApiCore\ApiException; | ||
|
||
/** | ||
* Gets report metadata about a specific report task. After creating a report | ||
* task, use this method to check its processing state or inspect its | ||
* report definition. | ||
* | ||
* @param string $formattedName The report task resource name. | ||
* Format: `properties/{property}/reportTasks/{report_task}` | ||
* Please see {@see AlphaAnalyticsDataClient::reportTaskName()} for help formatting this field. | ||
*/ | ||
function get_report_task_sample(string $formattedName): void | ||
{ | ||
// Create a client. | ||
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new GetReportTaskRequest()) | ||
->setName($formattedName); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var ReportTask $response */ | ||
$response = $alphaAnalyticsDataClient->getReportTask($request); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedName = AlphaAnalyticsDataClient::reportTaskName('[PROPERTY]', '[REPORT_TASK]'); | ||
|
||
get_report_task_sample($formattedName); | ||
} | ||
// [END analyticsdata_v1alpha_generated_AlphaAnalyticsData_GetReportTask_sync] |
77 changes: 77 additions & 0 deletions
77
AnalyticsData/samples/V1alpha/AlphaAnalyticsDataClient/list_report_tasks.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START analyticsdata_v1alpha_generated_AlphaAnalyticsData_ListReportTasks_sync] | ||
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient; | ||
use Google\Analytics\Data\V1alpha\ListReportTasksRequest; | ||
use Google\Analytics\Data\V1alpha\ReportTask; | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\PagedListResponse; | ||
|
||
/** | ||
* Lists all report tasks for a property. | ||
* | ||
* @param string $formattedParent All report tasks for this property will be listed in the | ||
* response. Format: `properties/{property}` | ||
* Please see {@see AlphaAnalyticsDataClient::propertyName()} for help formatting this field. | ||
*/ | ||
function list_report_tasks_sample(string $formattedParent): void | ||
{ | ||
// Create a client. | ||
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new ListReportTasksRequest()) | ||
->setParent($formattedParent); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var PagedListResponse $response */ | ||
$response = $alphaAnalyticsDataClient->listReportTasks($request); | ||
|
||
/** @var ReportTask $element */ | ||
foreach ($response as $element) { | ||
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); | ||
} | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedParent = AlphaAnalyticsDataClient::propertyName('[PROPERTY]'); | ||
|
||
list_report_tasks_sample($formattedParent); | ||
} | ||
// [END analyticsdata_v1alpha_generated_AlphaAnalyticsData_ListReportTasks_sync] |
75 changes: 75 additions & 0 deletions
75
AnalyticsData/samples/V1alpha/AlphaAnalyticsDataClient/query_report_task.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START analyticsdata_v1alpha_generated_AlphaAnalyticsData_QueryReportTask_sync] | ||
use Google\Analytics\Data\V1alpha\Client\AlphaAnalyticsDataClient; | ||
use Google\Analytics\Data\V1alpha\QueryReportTaskRequest; | ||
use Google\Analytics\Data\V1alpha\QueryReportTaskResponse; | ||
use Google\ApiCore\ApiException; | ||
|
||
/** | ||
* Retrieves a report task's content. After requesting the `CreateReportTask`, | ||
* you are able to retrieve the report content once the report is | ||
* ACTIVE. This method will return an error if the report task's state is not | ||
* `ACTIVE`. A query response will return the tabular row & column values of | ||
* the report. | ||
* | ||
* @param string $name The report source name. | ||
* Format: `properties/{property}/reportTasks/{report}` | ||
*/ | ||
function query_report_task_sample(string $name): void | ||
{ | ||
// Create a client. | ||
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new QueryReportTaskRequest()) | ||
->setName($name); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var QueryReportTaskResponse $response */ | ||
$response = $alphaAnalyticsDataClient->queryReportTask($request); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$name = '[NAME]'; | ||
|
||
query_report_task_sample($name); | ||
} | ||
// [END analyticsdata_v1alpha_generated_AlphaAnalyticsData_QueryReportTask_sync] |
Oops, something went wrong.