Skip to content

Commit f70aa90

Browse files
fix: CustomDimension and CustomMetric resource configuration in Analytics Admin API (#204)
PiperOrigin-RevId: 448304423 Source-Link: googleapis/googleapis@d018d54 Source-Link: googleapis/googleapis-gen@6c363ee Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNmMzNjNlZWEwZjk5ZDAwYTIxNmE0ZWZjODAxNWU2OTI3MmNjYWE4MyJ9 See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 58e6154 commit f70aa90

File tree

4 files changed

+68
-10
lines changed

4 files changed

+68
-10
lines changed

packages/google-analytics-admin/protos/google/analytics/admin/v1alpha/resources.proto

+2-2
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ message GoogleSignalsSettings {
951951
message CustomDimension {
952952
option (google.api.resource) = {
953953
type: "analyticsadmin.googleapis.com/CustomDimension"
954-
pattern: "properties/{property}/customDimensions"
954+
pattern: "properties/{property}/customDimensions/{custom_dimension}"
955955
};
956956

957957
// Valid values for the scope of this dimension.
@@ -1011,7 +1011,7 @@ message CustomDimension {
10111011
message CustomMetric {
10121012
option (google.api.resource) = {
10131013
type: "analyticsadmin.googleapis.com/CustomMetric"
1014-
pattern: "properties/{property}/customMetrics"
1014+
pattern: "properties/{property}/customMetrics/{custom_metric}"
10151015
};
10161016

10171017
// Possible types of representing the custom metric's value.

packages/google-analytics-admin/protos/protos.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/google-analytics-admin/src/v1alpha/analytics_admin_service_client.ts

+33-4
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ export class AnalyticsAdminServiceClient {
178178
'properties/{property}/conversionEvents/{conversion_event}'
179179
),
180180
customDimensionPathTemplate: new this._gaxModule.PathTemplate(
181-
'properties/{property}/customDimensions'
181+
'properties/{property}/customDimensions/{custom_dimension}'
182182
),
183183
customMetricPathTemplate: new this._gaxModule.PathTemplate(
184-
'properties/{property}/customMetrics'
184+
'properties/{property}/customMetrics/{custom_metric}'
185185
),
186186
dataRetentionSettingsPathTemplate: new this._gaxModule.PathTemplate(
187187
'properties/{property}/dataRetentionSettings'
@@ -9512,11 +9512,13 @@ export class AnalyticsAdminServiceClient {
95129512
* Return a fully-qualified customDimension resource name string.
95139513
*
95149514
* @param {string} property
9515+
* @param {string} custom_dimension
95159516
* @returns {string} Resource name string.
95169517
*/
9517-
customDimensionPath(property: string) {
9518+
customDimensionPath(property: string, customDimension: string) {
95189519
return this.pathTemplates.customDimensionPathTemplate.render({
95199520
property: property,
9521+
custom_dimension: customDimension,
95209522
});
95219523
}
95229524

@@ -9533,15 +9535,30 @@ export class AnalyticsAdminServiceClient {
95339535
).property;
95349536
}
95359537

9538+
/**
9539+
* Parse the custom_dimension from CustomDimension resource.
9540+
*
9541+
* @param {string} customDimensionName
9542+
* A fully-qualified path representing CustomDimension resource.
9543+
* @returns {string} A string representing the custom_dimension.
9544+
*/
9545+
matchCustomDimensionFromCustomDimensionName(customDimensionName: string) {
9546+
return this.pathTemplates.customDimensionPathTemplate.match(
9547+
customDimensionName
9548+
).custom_dimension;
9549+
}
9550+
95369551
/**
95379552
* Return a fully-qualified customMetric resource name string.
95389553
*
95399554
* @param {string} property
9555+
* @param {string} custom_metric
95409556
* @returns {string} Resource name string.
95419557
*/
9542-
customMetricPath(property: string) {
9558+
customMetricPath(property: string, customMetric: string) {
95439559
return this.pathTemplates.customMetricPathTemplate.render({
95449560
property: property,
9561+
custom_metric: customMetric,
95459562
});
95469563
}
95479564

@@ -9557,6 +9574,18 @@ export class AnalyticsAdminServiceClient {
95579574
.property;
95589575
}
95599576

9577+
/**
9578+
* Parse the custom_metric from CustomMetric resource.
9579+
*
9580+
* @param {string} customMetricName
9581+
* A fully-qualified path representing CustomMetric resource.
9582+
* @returns {string} A string representing the custom_metric.
9583+
*/
9584+
matchCustomMetricFromCustomMetricName(customMetricName: string) {
9585+
return this.pathTemplates.customMetricPathTemplate.match(customMetricName)
9586+
.custom_metric;
9587+
}
9588+
95609589
/**
95619590
* Return a fully-qualified dataRetentionSettings resource name string.
95629591
*

packages/google-analytics-admin/test/gapic_analytics_admin_service_v1alpha.ts

+31-2
Original file line numberDiff line numberDiff line change
@@ -12622,6 +12622,7 @@ describe('v1alpha.AnalyticsAdminServiceClient', () => {
1262212622
const fakePath = '/rendered/path/customDimension';
1262312623
const expectedParameters = {
1262412624
property: 'propertyValue',
12625+
custom_dimension: 'customDimensionValue',
1262512626
};
1262612627
const client =
1262712628
new analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient({
@@ -12637,7 +12638,10 @@ describe('v1alpha.AnalyticsAdminServiceClient', () => {
1263712638
.returns(expectedParameters);
1263812639

1263912640
it('customDimensionPath', () => {
12640-
const result = client.customDimensionPath('propertyValue');
12641+
const result = client.customDimensionPath(
12642+
'propertyValue',
12643+
'customDimensionValue'
12644+
);
1264112645
assert.strictEqual(result, fakePath);
1264212646
assert(
1264312647
(client.pathTemplates.customDimensionPathTemplate.render as SinonStub)
@@ -12655,12 +12659,24 @@ describe('v1alpha.AnalyticsAdminServiceClient', () => {
1265512659
.calledWith(fakePath)
1265612660
);
1265712661
});
12662+
12663+
it('matchCustomDimensionFromCustomDimensionName', () => {
12664+
const result =
12665+
client.matchCustomDimensionFromCustomDimensionName(fakePath);
12666+
assert.strictEqual(result, 'customDimensionValue');
12667+
assert(
12668+
(client.pathTemplates.customDimensionPathTemplate.match as SinonStub)
12669+
.getCall(-1)
12670+
.calledWith(fakePath)
12671+
);
12672+
});
1265812673
});
1265912674

1266012675
describe('customMetric', () => {
1266112676
const fakePath = '/rendered/path/customMetric';
1266212677
const expectedParameters = {
1266312678
property: 'propertyValue',
12679+
custom_metric: 'customMetricValue',
1266412680
};
1266512681
const client =
1266612682
new analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient({
@@ -12676,7 +12692,10 @@ describe('v1alpha.AnalyticsAdminServiceClient', () => {
1267612692
.returns(expectedParameters);
1267712693

1267812694
it('customMetricPath', () => {
12679-
const result = client.customMetricPath('propertyValue');
12695+
const result = client.customMetricPath(
12696+
'propertyValue',
12697+
'customMetricValue'
12698+
);
1268012699
assert.strictEqual(result, fakePath);
1268112700
assert(
1268212701
(client.pathTemplates.customMetricPathTemplate.render as SinonStub)
@@ -12694,6 +12713,16 @@ describe('v1alpha.AnalyticsAdminServiceClient', () => {
1269412713
.calledWith(fakePath)
1269512714
);
1269612715
});
12716+
12717+
it('matchCustomMetricFromCustomMetricName', () => {
12718+
const result = client.matchCustomMetricFromCustomMetricName(fakePath);
12719+
assert.strictEqual(result, 'customMetricValue');
12720+
assert(
12721+
(client.pathTemplates.customMetricPathTemplate.match as SinonStub)
12722+
.getCall(-1)
12723+
.calledWith(fakePath)
12724+
);
12725+
});
1269712726
});
1269812727

1269912728
describe('dataRetentionSettings', () => {

0 commit comments

Comments
 (0)