Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [AnalyticsAdmin] add GetKeyEvent, CreateKeyEvent, ListKeyEvents, UpdateKeyEvent, and DeleteKeyEvent methods #7571

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 87 additions & 22 deletions AnalyticsAdmin/metadata/V1Alpha/AnalyticsAdmin.php

Large diffs are not rendered by default.

Binary file modified AnalyticsAdmin/metadata/V1Alpha/Audience.php
Binary file not shown.
Binary file modified AnalyticsAdmin/metadata/V1Alpha/ChannelGroup.php
Binary file not shown.
Binary file modified AnalyticsAdmin/metadata/V1Alpha/EventCreateAndEdit.php
Binary file not shown.
Binary file modified AnalyticsAdmin/metadata/V1Alpha/Resources.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?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 analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateBigQueryLink_sync]
use Google\Analytics\Admin\V1alpha\BigQueryLink;
use Google\Analytics\Admin\V1alpha\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1alpha\CreateBigQueryLinkRequest;
use Google\ApiCore\ApiException;

/**
* Creates a BigQueryLink.
*
* @param string $formattedParent Example format: properties/1234
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
* @param string $bigqueryLinkDatasetLocation Immutable. The geographic location where the created BigQuery
* dataset should reside. See https://cloud.google.com/bigquery/docs/locations
* for supported locations.
*/
function create_big_query_link_sample(
string $formattedParent,
string $bigqueryLinkDatasetLocation
): void {
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();

// Prepare the request message.
$bigqueryLink = (new BigQueryLink())
->setDatasetLocation($bigqueryLinkDatasetLocation);
$request = (new CreateBigQueryLinkRequest())
->setParent($formattedParent)
->setBigqueryLink($bigqueryLink);

// Call the API and handle any network failures.
try {
/** @var BigQueryLink $response */
$response = $analyticsAdminServiceClient->createBigQueryLink($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
{
$formattedParent = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');
$bigqueryLinkDatasetLocation = '[DATASET_LOCATION]';

create_big_query_link_sample($formattedParent, $bigqueryLinkDatasetLocation);
}
// [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateBigQueryLink_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Google\ApiCore\ApiException;

/**
* Deprecated: Use `CreateKeyEvent` instead.
* Creates a conversion event with the specified attributes.
*
* @param string $formattedParent The resource name of the parent property where this conversion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?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 analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateEventEditRule_sync]
use Google\Analytics\Admin\V1alpha\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1alpha\CreateEventEditRuleRequest;
use Google\Analytics\Admin\V1alpha\EventEditRule;
use Google\Analytics\Admin\V1alpha\MatchingCondition;
use Google\Analytics\Admin\V1alpha\MatchingCondition\ComparisonType;
use Google\Analytics\Admin\V1alpha\ParameterMutation;
use Google\ApiCore\ApiException;

/**
* Creates an EventEditRule.
*
* @param string $formattedParent Example format: properties/123/dataStreams/456
* Please see {@see AnalyticsAdminServiceClient::dataStreamName()} for help formatting this field.
* @param string $eventEditRuleDisplayName The display name of this event edit rule. Maximum of 255
* characters.
* @param string $eventEditRuleEventConditionsField The name of the field that is compared against for the condition.
* If 'event_name' is specified this condition will apply to the name of the
* event. Otherwise the condition will apply to a parameter with the
* specified name.
*
* This value cannot contain spaces.
* @param int $eventEditRuleEventConditionsComparisonType The type of comparison to be applied to the value.
* @param string $eventEditRuleEventConditionsValue The value being compared against for this condition. The runtime
* implementation may perform type coercion of this value to evaluate this
* condition based on the type of the parameter value.
* @param string $eventEditRuleParameterMutationsParameter The name of the parameter to mutate.
* This value must:
* * be less than 40 characters.
* * be unique across across all mutations within the rule
* * consist only of letters, digits or _ (underscores)
* For event edit rules, the name may also be set to 'event_name' to modify
* the event_name in place.
* @param string $eventEditRuleParameterMutationsParameterValue The value mutation to perform.
* * Must be less than 100 characters.
* * To specify a constant value for the param, use the value's string.
* * To copy value from another parameter, use syntax like
* "[[other_parameter]]" For more details, see this [help center
* article](https://support.google.com/analytics/answer/10085872#modify-an-event&zippy=%2Cin-this-article%2Cmodify-parameters).
*/
function create_event_edit_rule_sample(
string $formattedParent,
string $eventEditRuleDisplayName,
string $eventEditRuleEventConditionsField,
int $eventEditRuleEventConditionsComparisonType,
string $eventEditRuleEventConditionsValue,
string $eventEditRuleParameterMutationsParameter,
string $eventEditRuleParameterMutationsParameterValue
): void {
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();

// Prepare the request message.
$matchingCondition = (new MatchingCondition())
->setField($eventEditRuleEventConditionsField)
->setComparisonType($eventEditRuleEventConditionsComparisonType)
->setValue($eventEditRuleEventConditionsValue);
$eventEditRuleEventConditions = [$matchingCondition,];
$parameterMutation = (new ParameterMutation())
->setParameter($eventEditRuleParameterMutationsParameter)
->setParameterValue($eventEditRuleParameterMutationsParameterValue);
$eventEditRuleParameterMutations = [$parameterMutation,];
$eventEditRule = (new EventEditRule())
->setDisplayName($eventEditRuleDisplayName)
->setEventConditions($eventEditRuleEventConditions)
->setParameterMutations($eventEditRuleParameterMutations);
$request = (new CreateEventEditRuleRequest())
->setParent($formattedParent)
->setEventEditRule($eventEditRule);

// Call the API and handle any network failures.
try {
/** @var EventEditRule $response */
$response = $analyticsAdminServiceClient->createEventEditRule($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
{
$formattedParent = AnalyticsAdminServiceClient::dataStreamName('[PROPERTY]', '[DATA_STREAM]');
$eventEditRuleDisplayName = '[DISPLAY_NAME]';
$eventEditRuleEventConditionsField = '[FIELD]';
$eventEditRuleEventConditionsComparisonType = ComparisonType::COMPARISON_TYPE_UNSPECIFIED;
$eventEditRuleEventConditionsValue = '[VALUE]';
$eventEditRuleParameterMutationsParameter = '[PARAMETER]';
$eventEditRuleParameterMutationsParameterValue = '[PARAMETER_VALUE]';

create_event_edit_rule_sample(
$formattedParent,
$eventEditRuleDisplayName,
$eventEditRuleEventConditionsField,
$eventEditRuleEventConditionsComparisonType,
$eventEditRuleEventConditionsValue,
$eventEditRuleParameterMutationsParameter,
$eventEditRuleParameterMutationsParameterValue
);
}
// [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateEventEditRule_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
* Properties can have at most one FirebaseLink.
*
* @param string $formattedParent Format: properties/{property_id}
* Example: properties/1234
*
* Example: `properties/1234`
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function create_firebase_link_sample(string $formattedParent): void
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?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 analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateKeyEvent_sync]
use Google\Analytics\Admin\V1alpha\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1alpha\CreateKeyEventRequest;
use Google\Analytics\Admin\V1alpha\KeyEvent;
use Google\Analytics\Admin\V1alpha\KeyEvent\CountingMethod;
use Google\ApiCore\ApiException;

/**
* Creates a Key Event.
*
* @param int $keyEventCountingMethod The method by which Key Events will be counted across multiple
* events within a session.
* @param string $formattedParent The resource name of the parent property where this Key Event
* will be created. Format: properties/123
* Please see {@see AnalyticsAdminServiceClient::propertyName()} for help formatting this field.
*/
function create_key_event_sample(int $keyEventCountingMethod, string $formattedParent): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();

// Prepare the request message.
$keyEvent = (new KeyEvent())
->setCountingMethod($keyEventCountingMethod);
$request = (new CreateKeyEventRequest())
->setKeyEvent($keyEvent)
->setParent($formattedParent);

// Call the API and handle any network failures.
try {
/** @var KeyEvent $response */
$response = $analyticsAdminServiceClient->createKeyEvent($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
{
$keyEventCountingMethod = CountingMethod::COUNTING_METHOD_UNSPECIFIED;
$formattedParent = AnalyticsAdminServiceClient::propertyName('[PROPERTY]');

create_key_event_sample($keyEventCountingMethod, $formattedParent);
}
// [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_CreateKeyEvent_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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 analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteBigQueryLink_sync]
use Google\Analytics\Admin\V1alpha\Client\AnalyticsAdminServiceClient;
use Google\Analytics\Admin\V1alpha\DeleteBigQueryLinkRequest;
use Google\ApiCore\ApiException;

/**
* Deletes a BigQueryLink on a property.
*
* @param string $formattedName The BigQueryLink to delete.
* Example format: properties/1234/bigQueryLinks/5678
* Please see {@see AnalyticsAdminServiceClient::bigQueryLinkName()} for help formatting this field.
*/
function delete_big_query_link_sample(string $formattedName): void
{
// Create a client.
$analyticsAdminServiceClient = new AnalyticsAdminServiceClient();

// Prepare the request message.
$request = (new DeleteBigQueryLinkRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
$analyticsAdminServiceClient->deleteBigQueryLink($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = AnalyticsAdminServiceClient::bigQueryLinkName('[PROPERTY]', '[BIGQUERY_LINK]');

delete_big_query_link_sample($formattedName);
}
// [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_DeleteBigQueryLink_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Google\ApiCore\ApiException;

/**
* Deprecated: Use `DeleteKeyEvent` instead.
* Deletes a conversion event in a property.
*
* @param string $formattedName The resource name of the conversion event to delete.
Expand Down
Loading
Loading