Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
feat: add occurrencePath template method (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and JustinBeckwith committed Jul 15, 2019
1 parent 406cea5 commit 9d66e07
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 5 deletions.
41 changes: 41 additions & 0 deletions src/v1/container_analysis_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class ContainerAnalysisClient {
// Create useful helper objects for these.
this._pathTemplates = {
notePathTemplate: new gax.PathTemplate('projects/{project}/notes/{note}'),
occurrencePathTemplate: new gax.PathTemplate(
'projects/{project}/occurrences/{occurrence}'
),
};

// Put together the default options sent with requests.
Expand Down Expand Up @@ -436,6 +439,20 @@ class ContainerAnalysisClient {
});
}

/**
* Return a fully-qualified occurrence resource name string.
*
* @param {String} project
* @param {String} occurrence
* @returns {String}
*/
occurrencePath(project, occurrence) {
return this._pathTemplates.occurrencePathTemplate.render({
project: project,
occurrence: occurrence,
});
}

/**
* Parse the noteName from a note resource.
*
Expand Down Expand Up @@ -470,6 +487,30 @@ class ContainerAnalysisClient {
getGrafeasClient() {
return new GrafeasClient(this.opts);
}

/**
* Parse the occurrenceName from a occurrence resource.
*
* @param {String} occurrenceName
* A fully-qualified path representing a occurrence resources.
* @returns {String} - A string representing the project.
*/
matchProjectFromOccurrenceName(occurrenceName) {
return this._pathTemplates.occurrencePathTemplate.match(occurrenceName)
.project;
}

/**
* Parse the occurrenceName from a occurrence resource.
*
* @param {String} occurrenceName
* A fully-qualified path representing a occurrence resources.
* @returns {String} - A string representing the occurrence.
*/
matchOccurrenceFromOccurrenceName(occurrenceName) {
return this._pathTemplates.occurrencePathTemplate.match(occurrenceName)
.occurrence;
}
}

module.exports = ContainerAnalysisClient;
41 changes: 41 additions & 0 deletions src/v1beta1/container_analysis_v1_beta1_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ class ContainerAnalysisV1Beta1Client {
// Create useful helper objects for these.
this._pathTemplates = {
notePathTemplate: new gax.PathTemplate('projects/{project}/notes/{note}'),
occurrencePathTemplate: new gax.PathTemplate(
'projects/{project}/occurrences/{occurrence}'
),
projectPathTemplate: new gax.PathTemplate('projects/{project}'),
scanConfigPathTemplate: new gax.PathTemplate(
'projects/{project}/scanConfigs/{scan_config}'
Expand Down Expand Up @@ -728,6 +731,20 @@ class ContainerAnalysisV1Beta1Client {
});
}

/**
* Return a fully-qualified occurrence resource name string.
*
* @param {String} project
* @param {String} occurrence
* @returns {String}
*/
occurrencePath(project, occurrence) {
return this._pathTemplates.occurrencePathTemplate.render({
project: project,
occurrence: occurrence,
});
}

/**
* Return a fully-qualified project resource name string.
*
Expand Down Expand Up @@ -776,6 +793,30 @@ class ContainerAnalysisV1Beta1Client {
return this._pathTemplates.notePathTemplate.match(noteName).note;
}

/**
* Parse the occurrenceName from a occurrence resource.
*
* @param {String} occurrenceName
* A fully-qualified path representing a occurrence resources.
* @returns {String} - A string representing the project.
*/
matchProjectFromOccurrenceName(occurrenceName) {
return this._pathTemplates.occurrencePathTemplate.match(occurrenceName)
.project;
}

/**
* Parse the occurrenceName from a occurrence resource.
*
* @param {String} occurrenceName
* A fully-qualified path representing a occurrence resources.
* @returns {String} - A string representing the occurrence.
*/
matchOccurrenceFromOccurrenceName(occurrenceName) {
return this._pathTemplates.occurrencePathTemplate.match(occurrenceName)
.occurrence;
}

/**
* Parse the projectName from a project resource.
*
Expand Down
10 changes: 5 additions & 5 deletions synth.metadata
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"updateTime": "2019-07-09T11:09:34.187843Z",
"updateTime": "2019-07-10T11:09:53.358268Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.29.3",
"dockerImage": "googleapis/artman@sha256:8900f94a81adaab0238965aa8a7b3648791f4f3a95ee65adc6a56cfcc3753101"
"version": "0.29.4",
"dockerImage": "googleapis/artman@sha256:63f21e83cb92680b7001dc381069e962c9e6dee314fd8365ac554c07c89221fb"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "b4c73face84fefb967ef6c72f0eae64faf67895f",
"internalRef": "256453142"
"sha": "16c0ea3cde17a897ba04b7b94d9bf4dd57e3227e",
"internalRef": "257239177"
}
},
{
Expand Down

0 comments on commit 9d66e07

Please sign in to comment.