Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.
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
4 changes: 2 additions & 2 deletions protos/google/analytics/admin/v1alpha/resources.proto
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ message GoogleSignalsSettings {
message CustomDimension {
option (google.api.resource) = {
type: "analyticsadmin.googleapis.com/CustomDimension"
pattern: "properties/{property}/customDimensions"
pattern: "properties/{property}/customDimensions/{custom_dimension}"
};

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

// Possible types of representing the custom metric's value.
Expand Down
4 changes: 2 additions & 2 deletions protos/protos.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 33 additions & 4 deletions src/v1alpha/analytics_admin_service_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ export class AnalyticsAdminServiceClient {
'properties/{property}/conversionEvents/{conversion_event}'
),
customDimensionPathTemplate: new this._gaxModule.PathTemplate(
'properties/{property}/customDimensions'
'properties/{property}/customDimensions/{custom_dimension}'
),
customMetricPathTemplate: new this._gaxModule.PathTemplate(
'properties/{property}/customMetrics'
'properties/{property}/customMetrics/{custom_metric}'
),
dataRetentionSettingsPathTemplate: new this._gaxModule.PathTemplate(
'properties/{property}/dataRetentionSettings'
Expand Down Expand Up @@ -9512,11 +9512,13 @@ export class AnalyticsAdminServiceClient {
* Return a fully-qualified customDimension resource name string.
*
* @param {string} property
* @param {string} custom_dimension
* @returns {string} Resource name string.
*/
customDimensionPath(property: string) {
customDimensionPath(property: string, customDimension: string) {
return this.pathTemplates.customDimensionPathTemplate.render({
property: property,
custom_dimension: customDimension,
});
}

Expand All @@ -9533,15 +9535,30 @@ export class AnalyticsAdminServiceClient {
).property;
}

/**
* Parse the custom_dimension from CustomDimension resource.
*
* @param {string} customDimensionName
* A fully-qualified path representing CustomDimension resource.
* @returns {string} A string representing the custom_dimension.
*/
matchCustomDimensionFromCustomDimensionName(customDimensionName: string) {
return this.pathTemplates.customDimensionPathTemplate.match(
customDimensionName
).custom_dimension;
}

/**
* Return a fully-qualified customMetric resource name string.
*
* @param {string} property
* @param {string} custom_metric
* @returns {string} Resource name string.
*/
customMetricPath(property: string) {
customMetricPath(property: string, customMetric: string) {
return this.pathTemplates.customMetricPathTemplate.render({
property: property,
custom_metric: customMetric,
});
}

Expand All @@ -9557,6 +9574,18 @@ export class AnalyticsAdminServiceClient {
.property;
}

/**
* Parse the custom_metric from CustomMetric resource.
*
* @param {string} customMetricName
* A fully-qualified path representing CustomMetric resource.
* @returns {string} A string representing the custom_metric.
*/
matchCustomMetricFromCustomMetricName(customMetricName: string) {
return this.pathTemplates.customMetricPathTemplate.match(customMetricName)
.custom_metric;
}

/**
* Return a fully-qualified dataRetentionSettings resource name string.
*
Expand Down
33 changes: 31 additions & 2 deletions test/gapic_analytics_admin_service_v1alpha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12622,6 +12622,7 @@ describe('v1alpha.AnalyticsAdminServiceClient', () => {
const fakePath = '/rendered/path/customDimension';
const expectedParameters = {
property: 'propertyValue',
custom_dimension: 'customDimensionValue',
};
const client =
new analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient({
Expand All @@ -12637,7 +12638,10 @@ describe('v1alpha.AnalyticsAdminServiceClient', () => {
.returns(expectedParameters);

it('customDimensionPath', () => {
const result = client.customDimensionPath('propertyValue');
const result = client.customDimensionPath(
'propertyValue',
'customDimensionValue'
);
assert.strictEqual(result, fakePath);
assert(
(client.pathTemplates.customDimensionPathTemplate.render as SinonStub)
Expand All @@ -12655,12 +12659,24 @@ describe('v1alpha.AnalyticsAdminServiceClient', () => {
.calledWith(fakePath)
);
});

it('matchCustomDimensionFromCustomDimensionName', () => {
const result =
client.matchCustomDimensionFromCustomDimensionName(fakePath);
assert.strictEqual(result, 'customDimensionValue');
assert(
(client.pathTemplates.customDimensionPathTemplate.match as SinonStub)
.getCall(-1)
.calledWith(fakePath)
);
});
});

describe('customMetric', () => {
const fakePath = '/rendered/path/customMetric';
const expectedParameters = {
property: 'propertyValue',
custom_metric: 'customMetricValue',
};
const client =
new analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient({
Expand All @@ -12676,7 +12692,10 @@ describe('v1alpha.AnalyticsAdminServiceClient', () => {
.returns(expectedParameters);

it('customMetricPath', () => {
const result = client.customMetricPath('propertyValue');
const result = client.customMetricPath(
'propertyValue',
'customMetricValue'
);
assert.strictEqual(result, fakePath);
assert(
(client.pathTemplates.customMetricPathTemplate.render as SinonStub)
Expand All @@ -12694,6 +12713,16 @@ describe('v1alpha.AnalyticsAdminServiceClient', () => {
.calledWith(fakePath)
);
});

it('matchCustomMetricFromCustomMetricName', () => {
const result = client.matchCustomMetricFromCustomMetricName(fakePath);
assert.strictEqual(result, 'customMetricValue');
assert(
(client.pathTemplates.customMetricPathTemplate.match as SinonStub)
.getCall(-1)
.calledWith(fakePath)
);
});
});

describe('dataRetentionSettings', () => {
Expand Down