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

fix: [AnalyticsAdmin] CustomDimension and CustomMetric resource configuration in Analytics Admin API #5270

Merged
merged 2 commits into from
May 12, 2022
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
Binary file modified AnalyticsAdmin/metadata/V1Alpha/Resources.php
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private static function getConversionEventNameTemplate()
private static function getCustomDimensionNameTemplate()
{
if (self::$customDimensionNameTemplate == null) {
self::$customDimensionNameTemplate = new PathTemplate('properties/{property}/customDimensions');
self::$customDimensionNameTemplate = new PathTemplate('properties/{property}/customDimensions/{custom_dimension}');
}

return self::$customDimensionNameTemplate;
Expand All @@ -303,7 +303,7 @@ private static function getCustomDimensionNameTemplate()
private static function getCustomMetricNameTemplate()
{
if (self::$customMetricNameTemplate == null) {
self::$customMetricNameTemplate = new PathTemplate('properties/{property}/customMetrics');
self::$customMetricNameTemplate = new PathTemplate('properties/{property}/customMetrics/{custom_metric}');
}

return self::$customMetricNameTemplate;
Expand Down Expand Up @@ -514,15 +514,17 @@ public static function conversionEventName($property, $conversionEvent)
* custom_dimension resource.
*
* @param string $property
* @param string $customDimension
*
* @return string The formatted custom_dimension resource.
*
* @experimental
*/
public static function customDimensionName($property)
public static function customDimensionName($property, $customDimension)
{
return self::getCustomDimensionNameTemplate()->render([
'property' => $property,
'custom_dimension' => $customDimension,
]);
}

Expand All @@ -531,15 +533,17 @@ public static function customDimensionName($property)
* custom_metric resource.
*
* @param string $property
* @param string $customMetric
*
* @return string The formatted custom_metric resource.
*
* @experimental
*/
public static function customMetricName($property)
public static function customMetricName($property, $customMetric)
{
return self::getCustomMetricNameTemplate()->render([
'property' => $property,
'custom_metric' => $customMetric,
]);
}

Expand Down Expand Up @@ -791,8 +795,8 @@ public static function userLinkName($account, $userLink)
* - account: accounts/{account}
* - accountUserLink: accounts/{account}/userLinks/{user_link}
* - conversionEvent: properties/{property}/conversionEvents/{conversion_event}
* - customDimension: properties/{property}/customDimensions
* - customMetric: properties/{property}/customMetrics
* - customDimension: properties/{property}/customDimensions/{custom_dimension}
* - customMetric: properties/{property}/customMetrics/{custom_metric}
* - dataRetentionSettings: properties/{property}/dataRetentionSettings
* - dataSharingSettings: accounts/{account}/dataSharingSettings
* - dataStream: properties/{property}/dataStreams/{data_stream}
Expand Down Expand Up @@ -1016,7 +1020,7 @@ public function approveDisplayVideo360AdvertiserLinkProposal($name, array $optio
* ```
* $analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
* try {
* $formattedName = $analyticsAdminServiceClient->customDimensionName('[PROPERTY]');
* $formattedName = $analyticsAdminServiceClient->customDimensionName('[PROPERTY]', '[CUSTOM_DIMENSION]');
* $analyticsAdminServiceClient->archiveCustomDimension($formattedName);
* } finally {
* $analyticsAdminServiceClient->close();
Expand Down Expand Up @@ -1057,7 +1061,7 @@ public function archiveCustomDimension($name, array $optionalArgs = [])
* ```
* $analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
* try {
* $formattedName = $analyticsAdminServiceClient->customMetricName('[PROPERTY]');
* $formattedName = $analyticsAdminServiceClient->customMetricName('[PROPERTY]', '[CUSTOM_METRIC]');
* $analyticsAdminServiceClient->archiveCustomMetric($formattedName);
* } finally {
* $analyticsAdminServiceClient->close();
Expand Down Expand Up @@ -2464,7 +2468,7 @@ public function getConversionEvent($name, array $optionalArgs = [])
* ```
* $analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
* try {
* $formattedName = $analyticsAdminServiceClient->customDimensionName('[PROPERTY]');
* $formattedName = $analyticsAdminServiceClient->customDimensionName('[PROPERTY]', '[CUSTOM_DIMENSION]');
* $response = $analyticsAdminServiceClient->getCustomDimension($formattedName);
* } finally {
* $analyticsAdminServiceClient->close();
Expand Down Expand Up @@ -2507,7 +2511,7 @@ public function getCustomDimension($name, array $optionalArgs = [])
* ```
* $analyticsAdminServiceClient = new AnalyticsAdminServiceClient();
* try {
* $formattedName = $analyticsAdminServiceClient->customMetricName('[PROPERTY]');
* $formattedName = $analyticsAdminServiceClient->customMetricName('[PROPERTY]', '[CUSTOM_METRIC]');
* $response = $analyticsAdminServiceClient->getCustomMetric($formattedName);
* } finally {
* $analyticsAdminServiceClient->close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function archiveCustomDimensionTest()
$expectedResponse = new GPBEmpty();
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $client->customDimensionName('[PROPERTY]');
$formattedName = $client->customDimensionName('[PROPERTY]', '[CUSTOM_DIMENSION]');
$client->archiveCustomDimension($formattedName);
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
Expand Down Expand Up @@ -287,7 +287,7 @@ public function archiveCustomDimensionExceptionTest()
], JSON_PRETTY_PRINT);
$transport->addResponse(null, $status);
// Mock request
$formattedName = $client->customDimensionName('[PROPERTY]');
$formattedName = $client->customDimensionName('[PROPERTY]', '[CUSTOM_DIMENSION]');
try {
$client->archiveCustomDimension($formattedName);
// If the $client method call did not throw, fail the test
Expand Down Expand Up @@ -315,7 +315,7 @@ public function archiveCustomMetricTest()
$expectedResponse = new GPBEmpty();
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $client->customMetricName('[PROPERTY]');
$formattedName = $client->customMetricName('[PROPERTY]', '[CUSTOM_METRIC]');
$client->archiveCustomMetric($formattedName);
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
Expand Down Expand Up @@ -348,7 +348,7 @@ public function archiveCustomMetricExceptionTest()
], JSON_PRETTY_PRINT);
$transport->addResponse(null, $status);
// Mock request
$formattedName = $client->customMetricName('[PROPERTY]');
$formattedName = $client->customMetricName('[PROPERTY]', '[CUSTOM_METRIC]');
try {
$client->archiveCustomMetric($formattedName);
// If the $client method call did not throw, fail the test
Expand Down Expand Up @@ -2402,7 +2402,7 @@ public function getCustomDimensionTest()
$expectedResponse->setDisallowAdsPersonalization($disallowAdsPersonalization);
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $client->customDimensionName('[PROPERTY]');
$formattedName = $client->customDimensionName('[PROPERTY]', '[CUSTOM_DIMENSION]');
$response = $client->getCustomDimension($formattedName);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
Expand Down Expand Up @@ -2436,7 +2436,7 @@ public function getCustomDimensionExceptionTest()
], JSON_PRETTY_PRINT);
$transport->addResponse(null, $status);
// Mock request
$formattedName = $client->customDimensionName('[PROPERTY]');
$formattedName = $client->customDimensionName('[PROPERTY]', '[CUSTOM_DIMENSION]');
try {
$client->getCustomDimension($formattedName);
// If the $client method call did not throw, fail the test
Expand Down Expand Up @@ -2472,7 +2472,7 @@ public function getCustomMetricTest()
$expectedResponse->setDescription($description);
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $client->customMetricName('[PROPERTY]');
$formattedName = $client->customMetricName('[PROPERTY]', '[CUSTOM_METRIC]');
$response = $client->getCustomMetric($formattedName);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
Expand Down Expand Up @@ -2506,7 +2506,7 @@ public function getCustomMetricExceptionTest()
], JSON_PRETTY_PRINT);
$transport->addResponse(null, $status);
// Mock request
$formattedName = $client->customMetricName('[PROPERTY]');
$formattedName = $client->customMetricName('[PROPERTY]', '[CUSTOM_METRIC]');
try {
$client->getCustomMetric($formattedName);
// If the $client method call did not throw, fail the test
Expand Down