Skip to content

Commit

Permalink
feat: add CreateReportTask, QueryReportTask, GetReportTask, `Li…
Browse files Browse the repository at this point in the history
…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
gcf-owl-bot[bot] committed May 10, 2024
1 parent 0f600d2 commit bd673bd
Show file tree
Hide file tree
Showing 34 changed files with 4,618 additions and 83 deletions.
Binary file modified AnalyticsData/metadata/V1Alpha/AnalyticsDataApi.php
Binary file not shown.
Binary file modified AnalyticsData/metadata/V1Alpha/Data.php
Binary file not shown.
@@ -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]
@@ -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]
@@ -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]
@@ -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]

0 comments on commit bd673bd

Please sign in to comment.