Skip to content

Commit

Permalink
feat!: update AnalyticsData V1alpha (#6959)
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored Jan 12, 2024
1 parent b7abd63 commit 2ca6317
Show file tree
Hide file tree
Showing 98 changed files with 13,116 additions and 685 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?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_CreateAudienceList_sync]
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\AudienceDimension;
use Google\Analytics\Data\V1alpha\AudienceList;
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Rpc\Status;

/**
* Creates an audience list for later retrieval. This method quickly returns
* the audience list's resource name and initiates a long running asynchronous
* request to form an audience list. To list the users in an audience list,
* first create the audience list through this method and then send the
* audience resource name to the `QueryAudienceList` method.
*
* See [Creating an Audience
* List](https://developers.google.com/analytics/devguides/reporting/data/v1/audience-list-basics)
* for an introduction to Audience Lists with examples.
*
* An audience list is a snapshot of the users currently in the audience at
* the time of audience list creation. Creating audience lists for one
* audience on different days will return different results as users enter and
* exit the audience.
*
* Audiences in Google Analytics 4 allow you to segment your users in the ways
* that are important to your business. To learn more, see
* https://support.google.com/analytics/answer/9267572. Audience lists contain
* the users in each audience.
*
* This method is introduced at alpha stability with the intention of
* gathering feedback on syntax and capabilities before entering beta. To give
* your feedback on this API, complete the
* [Google Analytics Audience Export API
* Feedback](https://forms.gle/EeA5u5LW6PEggtCEA) form.
*
* @param string $formattedParent The parent resource where this audience list will be created.
* Format: `properties/{property}`
* Please see {@see AlphaAnalyticsDataClient::propertyName()} for help formatting this field.
* @param string $audienceListAudience The audience resource name. This resource name identifies the
* audience being listed and is shared between the Analytics Data & Admin
* APIs.
*
* Format: `properties/{property}/audiences/{audience}`
*/
function create_audience_list_sample(string $formattedParent, string $audienceListAudience): void
{
// Create a client.
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

// Prepare any non-scalar elements to be passed along with the request.
$audienceListDimensions = [new AudienceDimension()];
$audienceList = (new AudienceList())
->setAudience($audienceListAudience)
->setDimensions($audienceListDimensions);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alphaAnalyticsDataClient->createAudienceList($formattedParent, $audienceList);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var AudienceList $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]');
$audienceListAudience = '[AUDIENCE]';

create_audience_list_sample($formattedParent, $audienceListAudience);
}
// [END analyticsdata_v1alpha_generated_AlphaAnalyticsData_CreateAudienceList_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?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_CreateRecurringAudienceList_sync]
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\AudienceDimension;
use Google\Analytics\Data\V1alpha\RecurringAudienceList;
use Google\ApiCore\ApiException;

/**
* Creates a recurring audience list. Recurring audience lists produces new
* audience lists each day. Audience lists are users in an audience at the
* time of the list's creation.
*
* A recurring audience list ensures that you have audience list based on the
* most recent data available for use each day. If you manually create
* audience list, you don't know when an audience list based on an additional
* day's data is available. This recurring audience list automates the
* creation of an audience list when an additional day's data is available.
* You will consume fewer quota tokens by using recurring audience list versus
* manually creating audience list at various times of day trying to guess
* when an additional day's data is ready.
*
* This method is introduced at alpha stability with the intention of
* gathering feedback on syntax and capabilities before entering beta. To give
* your feedback on this API, complete the
* [Google Analytics Audience Export API
* Feedback](https://forms.gle/EeA5u5LW6PEggtCEA) form.
*
* @param string $formattedParent The parent resource where this recurring audience list will be
* created. Format: `properties/{property}`
* Please see {@see AlphaAnalyticsDataClient::propertyName()} for help formatting this field.
* @param string $recurringAudienceListAudience The audience resource name. This resource name identifies the
* audience being listed and is shared between the Analytics Data & Admin
* APIs.
*
* Format: `properties/{property}/audiences/{audience}`
*/
function create_recurring_audience_list_sample(
string $formattedParent,
string $recurringAudienceListAudience
): void {
// Create a client.
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

// Prepare any non-scalar elements to be passed along with the request.
$recurringAudienceListDimensions = [new AudienceDimension()];
$recurringAudienceList = (new RecurringAudienceList())
->setAudience($recurringAudienceListAudience)
->setDimensions($recurringAudienceListDimensions);

// Call the API and handle any network failures.
try {
/** @var RecurringAudienceList $response */
$response = $alphaAnalyticsDataClient->createRecurringAudienceList(
$formattedParent,
$recurringAudienceList
);
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
{
$formattedParent = AlphaAnalyticsDataClient::propertyName('[PROPERTY]');
$recurringAudienceListAudience = '[AUDIENCE]';

create_recurring_audience_list_sample($formattedParent, $recurringAudienceListAudience);
}
// [END analyticsdata_v1alpha_generated_AlphaAnalyticsData_CreateRecurringAudienceList_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?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_GetAudienceList_sync]
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\AudienceList;
use Google\ApiCore\ApiException;

/**
* Gets configuration metadata about a specific audience list. This method
* can be used to understand an audience list after it has been created.
*
* See [Creating an Audience
* List](https://developers.google.com/analytics/devguides/reporting/data/v1/audience-list-basics)
* for an introduction to Audience Lists with examples.
*
* This method is introduced at alpha stability with the intention of
* gathering feedback on syntax and capabilities before entering beta. To give
* your feedback on this API, complete the
* [Google Analytics Audience Export API
* Feedback](https://forms.gle/EeA5u5LW6PEggtCEA) form.
*
* @param string $formattedName The audience list resource name.
* Format: `properties/{property}/audienceLists/{audience_list}`
* Please see {@see AlphaAnalyticsDataClient::audienceListName()} for help formatting this field.
*/
function get_audience_list_sample(string $formattedName): void
{
// Create a client.
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

// Call the API and handle any network failures.
try {
/** @var AudienceList $response */
$response = $alphaAnalyticsDataClient->getAudienceList($formattedName);
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::audienceListName('[PROPERTY]', '[AUDIENCE_LIST]');

get_audience_list_sample($formattedName);
}
// [END analyticsdata_v1alpha_generated_AlphaAnalyticsData_GetAudienceList_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?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_GetRecurringAudienceList_sync]
use Google\Analytics\Data\V1alpha\AlphaAnalyticsDataClient;
use Google\Analytics\Data\V1alpha\RecurringAudienceList;
use Google\ApiCore\ApiException;

/**
* Gets configuration metadata about a specific recurring audience list. This
* method can be used to understand a recurring audience list's state after it
* has been created. For example, a recurring audience list resource will
* generate audience list instances for each day, and this method can be used
* to get the resource name of the most recent audience list instance.
*
* This method is introduced at alpha stability with the intention of
* gathering feedback on syntax and capabilities before entering beta. To give
* your feedback on this API, complete the
* [Google Analytics Audience Export API
* Feedback](https://forms.gle/EeA5u5LW6PEggtCEA) form.
*
* @param string $formattedName The recurring audience list resource name.
* Format:
* `properties/{property}/recurringAudienceLists/{recurring_audience_list}`
* Please see {@see AlphaAnalyticsDataClient::recurringAudienceListName()} for help formatting this field.
*/
function get_recurring_audience_list_sample(string $formattedName): void
{
// Create a client.
$alphaAnalyticsDataClient = new AlphaAnalyticsDataClient();

// Call the API and handle any network failures.
try {
/** @var RecurringAudienceList $response */
$response = $alphaAnalyticsDataClient->getRecurringAudienceList($formattedName);
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::recurringAudienceListName(
'[PROPERTY]',
'[RECURRING_AUDIENCE_LIST]'
);

get_recurring_audience_list_sample($formattedName);
}
// [END analyticsdata_v1alpha_generated_AlphaAnalyticsData_GetRecurringAudienceList_sync]
Loading

0 comments on commit 2ca6317

Please sign in to comment.