@google-cloud/nodejs-common 1.7.1 → 1.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -92,6 +92,7 @@ declare -A GOOGLE_CLOUD_APIS
92
92
  GOOGLE_CLOUD_APIS=(
93
93
  ["appengine.googleapis.com"]="App Engine Admin API"
94
94
  ["cloudbuild.googleapis.com"]="Google Build API"
95
+ ["artifactregistry.googleapis.com"]="Artifact Registry API"
95
96
  ["cloudresourcemanager.googleapis.com"]="Resource Manager API"
96
97
  ["iam.googleapis.com"]="Cloud Identity and Access Management API"
97
98
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google-cloud/nodejs-common",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "A NodeJs common library for solutions based on Cloud Functions",
5
5
  "author": "Google Inc.",
6
6
  "license": "Apache-2.0",
@@ -16,26 +16,26 @@
16
16
  },
17
17
  "homepage": "https://github.com/GoogleCloudPlatform/cloud-for-marketing/blob/master/marketing-analytics/activation/common-libs/nodejs-common/README.md",
18
18
  "dependencies": {
19
- "@google-cloud/aiplatform": "^2.13.0",
20
- "@google-cloud/automl": "^3.1.3",
21
- "@google-cloud/bigquery": "^6.2.0",
22
- "@google-cloud/datastore": "^7.5.1",
23
- "@google-cloud/firestore": "^6.5.0",
24
- "@google-cloud/logging-winston": "^5.3.0",
25
- "@google-cloud/pubsub": "^3.6.0",
26
- "@google-cloud/storage": "^6.10.1",
27
- "@google-cloud/scheduler": "^3.3.1",
28
- "@google-cloud/secret-manager": "^4.2.2",
29
- "gaxios": "^5.1.0",
19
+ "@google-cloud/aiplatform": "^3.0.0",
20
+ "@google-cloud/automl": "^4.0.0",
21
+ "@google-cloud/bigquery": "^7.2.0",
22
+ "@google-cloud/datastore": "^8.0.0",
23
+ "@google-cloud/firestore": "^6.7.0",
24
+ "@google-cloud/logging-winston": "^6.0.0",
25
+ "@google-cloud/pubsub": "^4.0.2",
26
+ "@google-cloud/storage": "^7.0.1",
27
+ "@google-cloud/scheduler": "^4.0.0",
28
+ "@google-cloud/secret-manager": "^5.0.0",
29
+ "gaxios": "^6.1.0",
30
30
  "google-ads-api": "^13.0.1",
31
31
  "google-ads-node": "^11.0.0",
32
- "google-auth-library": "^8.8.0",
33
- "googleapis": "^118.0.0",
34
- "winston": "^3.8.2",
32
+ "google-auth-library": "^9.0.0",
33
+ "googleapis": "^126.0.1",
34
+ "winston": "^3.10.0",
35
35
  "lodash": "^4.17.21"
36
36
  },
37
37
  "devDependencies": {
38
- "jasmine": "^4.4.0"
38
+ "jasmine": "^5.1.0"
39
39
  },
40
40
  "scripts": {
41
41
  "test": "node node_modules/jasmine/bin/jasmine"
@@ -0,0 +1,97 @@
1
+ // Copyright 2019 Google Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ /**
16
+ * @fileoverview Google DoubleClick Search Ads Conversions uploading on Google
17
+ * API Client Library.
18
+ */
19
+
20
+ 'use strict';
21
+
22
+ const { google } = require('googleapis');
23
+ const AuthClient = require('./auth_client.js');
24
+ const {
25
+ getLogger,
26
+ getObjectByPath,
27
+ SendSingleBatch,
28
+ BatchResult,
29
+ } = require('../components/utils.js');
30
+
31
+ const API_SCOPES = Object.freeze([
32
+ 'https://www.googleapis.com/auth/display-video',
33
+ ]);
34
+ const API_VERSION = 'v2';
35
+
36
+ /**
37
+ * Display and Video 360 API v2 stub.
38
+ * @see https://developers.google.com/display-video/api/reference/rest/v2
39
+ * This is not the same to Reports Display & Video 360 API which is from Google
40
+ * Bid Manager API.
41
+ * @see https://developers.google.com/bid-manager/reference/rest
42
+ */
43
+ class DisplayVideo {
44
+
45
+ /**
46
+ * @constructor
47
+ * @param {!Object<string,string>=} env The environment object to hold env
48
+ * variables.
49
+ */
50
+ constructor(env = process.env) {
51
+ this.authClient = new AuthClient(API_SCOPES, env);
52
+ this.logger = getLogger('API.DV3API');
53
+ }
54
+
55
+ /**
56
+ * Prepares the Google DV3 instance.
57
+ * @return {!google.displayvideo}
58
+ * @private
59
+ */
60
+ async getApiClient_() {
61
+ if (this.displayvideo) return this.displayvideo;
62
+ this.logger.debug(`Initialized ${this.constructor.name} instance.`);
63
+ this.displayvideo = google.displayvideo({
64
+ version: API_VERSION,
65
+ auth: await this.getAuth_(),
66
+ });
67
+ return this.displayvideo;
68
+ }
69
+
70
+ /**
71
+ * Gets the auth object.
72
+ * @return {!Promise<{!OAuth2Client|!JWT|!Compute}>}
73
+ */
74
+ async getAuth_() {
75
+ if (this.auth) return this.auth;
76
+ await this.authClient.prepareCredentials();
77
+ this.auth = this.authClient.getDefaultAuth();
78
+ return this.auth;
79
+ }
80
+
81
+ /**
82
+ * Gets the instance of function object based on Google API client library.
83
+ * @param {string|undefined} path
84
+ * @return {Object}
85
+ */
86
+ async getFunctionObject(path) {
87
+ const instance = await this.getApiClient_();
88
+ return getObjectByPath(instance, path);
89
+ }
90
+
91
+ }
92
+
93
+ module.exports = {
94
+ DisplayVideo,
95
+ API_VERSION,
96
+ API_SCOPES,
97
+ };
package/src/apis/index.js CHANGED
@@ -30,6 +30,14 @@ exports.AuthClient = require('./auth_client.js');
30
30
  */
31
31
  exports.dfareporting = require('./dfa_reporting.js');
32
32
 
33
+ /**
34
+ * APIs integration class for DV3 API.
35
+ * @const {{
36
+ * DisplayVideo:!DisplayVideo,
37
+ * }}
38
+ */
39
+ exports.displayvideo = require('./display_video.js');
40
+
33
41
  /**
34
42
  * APIs integration class for Google Analytics Data Import API.
35
43
  * @const {{
@@ -497,6 +497,26 @@ const extractObject = (paths) => {
497
497
  };
498
498
  };
499
499
 
500
+ /**
501
+ * Returns the embedded object from the given object and path.
502
+ * @param {Object} obj
503
+ * @param {string|undefined} paths
504
+ * @return {Object}
505
+ */
506
+ const getObjectByPath = (obj, paths) => {
507
+ let instance = obj;
508
+ if (paths) {
509
+ paths.split('.').filter((key) => !!key).forEach((key) => {
510
+ instance = instance[key];
511
+ if (!instance) {
512
+ console.error('Fail to get function containter', paths);
513
+ return instance;
514
+ }
515
+ });
516
+ }
517
+ return instance;
518
+ };
519
+
500
520
  /**
501
521
  * For more details, see:
502
522
  * https://developers.google.com/google-ads/api/docs/rest/design/json-mappings
@@ -533,6 +553,7 @@ module.exports = {
533
553
  replaceParameters,
534
554
  getFilterFunction,
535
555
  extractObject,
556
+ getObjectByPath,
536
557
  changeNamingFromSnakeToUpperCamel,
537
558
  changeNamingFromSnakeToLowerCamel,
538
559
  };