mblabs-roccato-backend-commons 1.0.58 → 1.0.60
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.
- package/dist/interfaces/aws.d.ts +18 -0
- package/dist/interfaces/gcp.d.ts +24 -0
- package/dist/services/aws/cloudwatch.d.ts +1 -0
- package/dist/services/aws/cloudwatch.js +24 -0
- package/dist/services/gcp/index.d.ts +2 -1
- package/dist/services/gcp/index.js +3 -1
- package/dist/services/gcp/monitor.d.ts +6 -0
- package/dist/services/gcp/monitor.js +27 -0
- package/dist/services/gcp/secrets.js +4 -1
- package/dist/services/index.d.ts +2 -2
- package/dist/services/index.js +2 -1
- package/package.json +6 -2
- package/src/interfaces/aws.ts +25 -0
- package/src/interfaces/gcp.ts +26 -0
- package/src/services/aws/cloudwatch.ts +26 -0
- package/src/services/gcp/index.ts +2 -0
- package/src/services/gcp/monitor.ts +33 -0
- package/src/services/gcp/secrets.ts +4 -1
- package/src/services/index.ts +2 -0
- package/yarn.lock +982 -268
package/dist/interfaces/aws.d.ts
CHANGED
|
@@ -25,6 +25,23 @@ export declare namespace AmazonCloudwatch {
|
|
|
25
25
|
credentials: Credentials;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
+
namespace CreateMetric {
|
|
29
|
+
interface Request {
|
|
30
|
+
data: {
|
|
31
|
+
namespace: string;
|
|
32
|
+
metric: {
|
|
33
|
+
title: string;
|
|
34
|
+
dimensions: {
|
|
35
|
+
name: string;
|
|
36
|
+
value: string;
|
|
37
|
+
}[];
|
|
38
|
+
value: number;
|
|
39
|
+
unit: 'Count' | 'Percent' | 'Seconds' | 'Microseconds' | 'Milliseconds' | 'None';
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
credentials: Credentials;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
28
45
|
}
|
|
29
46
|
export declare namespace AmazonPinpoint {
|
|
30
47
|
namespace SendMail {
|
|
@@ -194,6 +211,7 @@ export declare namespace AmazonSQS {
|
|
|
194
211
|
}
|
|
195
212
|
export interface IAmazonCloudwatchService {
|
|
196
213
|
createLogEvent(req: AmazonCloudwatch.CreateLogEvent.Request): Promise<void>;
|
|
214
|
+
createMetric(req: AmazonCloudwatch.CreateMetric.Request): Promise<void>;
|
|
197
215
|
}
|
|
198
216
|
export interface IAmazonPinpointService {
|
|
199
217
|
sendMail(req: AmazonPinpoint.SendMail.Request): Promise<void>;
|
package/dist/interfaces/gcp.d.ts
CHANGED
|
@@ -51,6 +51,27 @@ export declare namespace GoogleCalendar {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
+
export declare namespace GoogleMonitor {
|
|
55
|
+
namespace CreateMetric {
|
|
56
|
+
interface Request {
|
|
57
|
+
data: {
|
|
58
|
+
namespace: string;
|
|
59
|
+
metric: {
|
|
60
|
+
title: string;
|
|
61
|
+
value: number;
|
|
62
|
+
typeof: 'VALUE_TYPE_UNSPECIFIED' | 'BOOL' | 'INT64' | 'DOUBLE' | 'STRING' | 'DISTRIBUTION' | 'MONEY';
|
|
63
|
+
measure: 'METRIC_KIND_UNSPECIFIED' | 'GAUGE' | 'DELTA' | 'CUMULATIVE';
|
|
64
|
+
labels: {
|
|
65
|
+
key: string;
|
|
66
|
+
typeof: 'STRING' | 'BOOL' | 'INT64';
|
|
67
|
+
description: string;
|
|
68
|
+
}[];
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
credentials: Credentials;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
54
75
|
export declare namespace GoogleStorage {
|
|
55
76
|
namespace GetSignedUrl {
|
|
56
77
|
interface Request {
|
|
@@ -112,3 +133,6 @@ export interface IGoogleAuthService {
|
|
|
112
133
|
export interface IGoogleCalendarService {
|
|
113
134
|
getEvents(req: GoogleCalendar.GetEvents.Request): Promise<GoogleCalendar.GetEvents.Response>;
|
|
114
135
|
}
|
|
136
|
+
export interface IGoogleMonitorService {
|
|
137
|
+
createMetric(req: GoogleMonitor.CreateMetric.Request): Promise<void>;
|
|
138
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AmazonCloudwatch, IAmazonCloudwatchService } from '../../interfaces';
|
|
2
2
|
declare class AmazonCloudwatchService implements IAmazonCloudwatchService {
|
|
3
|
+
createMetric({ credentials, data }: AmazonCloudwatch.CreateMetric.Request): Promise<void>;
|
|
3
4
|
createLogEvent({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request): Promise<void>;
|
|
4
5
|
private getLogGroupByName;
|
|
5
6
|
private getLogStreamByName;
|
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const client_cloudwatch_1 = require("@aws-sdk/client-cloudwatch");
|
|
3
4
|
const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
|
|
4
5
|
class AmazonCloudwatchService {
|
|
6
|
+
async createMetric({ credentials, data }) {
|
|
7
|
+
const client = new client_cloudwatch_1.CloudWatch({
|
|
8
|
+
credentials: {
|
|
9
|
+
accessKeyId: credentials.accessKey,
|
|
10
|
+
secretAccessKey: credentials.secretKey,
|
|
11
|
+
},
|
|
12
|
+
region: credentials.region,
|
|
13
|
+
});
|
|
14
|
+
await client.putMetricData({
|
|
15
|
+
Namespace: data.namespace,
|
|
16
|
+
MetricData: [
|
|
17
|
+
{
|
|
18
|
+
MetricName: data.metric.title,
|
|
19
|
+
Dimensions: data.metric.dimensions.map(dimension => ({
|
|
20
|
+
Name: dimension.name,
|
|
21
|
+
Value: dimension.value,
|
|
22
|
+
})),
|
|
23
|
+
Value: data.metric.value,
|
|
24
|
+
Unit: data.metric.unit,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
}
|
|
5
29
|
async createLogEvent({ credentials, data }) {
|
|
6
30
|
const client = new client_cloudwatch_logs_1.CloudWatchLogs({
|
|
7
31
|
credentials: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import GoogleAuthService from './auth';
|
|
2
2
|
import GoogleCalendarService from './calendar';
|
|
3
|
+
import GoogleMonitorService from './monitor';
|
|
3
4
|
import GoogleSecretsService from './secrets';
|
|
4
5
|
import GoogleSheetsService from './sheets';
|
|
5
6
|
import GoogleStorageService from './storage';
|
|
6
|
-
export { GoogleAuthService, GoogleCalendarService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService, };
|
|
7
|
+
export { GoogleAuthService, GoogleCalendarService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService, GoogleMonitorService, };
|
|
@@ -3,11 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GoogleStorageService = exports.GoogleSheetsService = exports.GoogleSecretsService = exports.GoogleCalendarService = exports.GoogleAuthService = void 0;
|
|
6
|
+
exports.GoogleMonitorService = exports.GoogleStorageService = exports.GoogleSheetsService = exports.GoogleSecretsService = exports.GoogleCalendarService = exports.GoogleAuthService = void 0;
|
|
7
7
|
const auth_1 = __importDefault(require("./auth"));
|
|
8
8
|
exports.GoogleAuthService = auth_1.default;
|
|
9
9
|
const calendar_1 = __importDefault(require("./calendar"));
|
|
10
10
|
exports.GoogleCalendarService = calendar_1.default;
|
|
11
|
+
const monitor_1 = __importDefault(require("./monitor"));
|
|
12
|
+
exports.GoogleMonitorService = monitor_1.default;
|
|
11
13
|
const secrets_1 = __importDefault(require("./secrets"));
|
|
12
14
|
exports.GoogleSecretsService = secrets_1.default;
|
|
13
15
|
const sheets_1 = __importDefault(require("./sheets"));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GoogleMonitor, IGoogleMonitorService } from '../../interfaces';
|
|
2
|
+
declare class GoogleMonitorService implements IGoogleMonitorService {
|
|
3
|
+
createMetric({ credentials, data, }: GoogleMonitor.CreateMetric.Request): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
declare const _default: GoogleMonitorService;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const monitoring_1 = require("@google-cloud/monitoring");
|
|
4
|
+
class GoogleMonitorService {
|
|
5
|
+
async createMetric({ credentials, data, }) {
|
|
6
|
+
const client = new monitoring_1.MetricServiceClient({
|
|
7
|
+
apiKey: credentials.apiKey,
|
|
8
|
+
projectId: credentials.project,
|
|
9
|
+
});
|
|
10
|
+
await client.createMetricDescriptor({
|
|
11
|
+
name: client.projectPath(credentials.project),
|
|
12
|
+
metricDescriptor: {
|
|
13
|
+
name: data.metric.title,
|
|
14
|
+
type: data.namespace,
|
|
15
|
+
metricKind: data.metric.measure,
|
|
16
|
+
valueType: data.metric.typeof,
|
|
17
|
+
unit: data.metric.value.toString(),
|
|
18
|
+
labels: data.metric.labels.map((label) => ({
|
|
19
|
+
key: label.key,
|
|
20
|
+
valueType: label.typeof,
|
|
21
|
+
description: label.description,
|
|
22
|
+
})),
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = new GoogleMonitorService();
|
|
@@ -4,7 +4,10 @@ const secret_manager_1 = require("@google-cloud/secret-manager");
|
|
|
4
4
|
const parser_1 = require("../../utils/parser");
|
|
5
5
|
class GoogleSecretsService {
|
|
6
6
|
async getSecret({ credentials, data, }) {
|
|
7
|
-
const client = new secret_manager_1.SecretManagerServiceClient({
|
|
7
|
+
const client = new secret_manager_1.SecretManagerServiceClient({
|
|
8
|
+
apiKey: credentials.apiKey,
|
|
9
|
+
projectId: credentials.project,
|
|
10
|
+
});
|
|
8
11
|
const [version] = await client.accessSecretVersion({
|
|
9
12
|
name: `projects/${data.project}/secrets/${data.secret}/versions/latest`,
|
|
10
13
|
});
|
package/dist/services/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AzureApplicationInsightsService, AzureAuthService, AzureCalendarService
|
|
|
3
3
|
import DateService from './date';
|
|
4
4
|
import FileService from './file';
|
|
5
5
|
import FirebaseService from './firebase';
|
|
6
|
-
import { GoogleAuthService, GoogleCalendarService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService } from './gcp';
|
|
6
|
+
import { GoogleAuthService, GoogleCalendarService, GoogleMonitorService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService } from './gcp';
|
|
7
7
|
import GrafanaService from './grafana';
|
|
8
8
|
import I18nService from './i18n';
|
|
9
9
|
import KafkaService from './kafka';
|
|
@@ -12,4 +12,4 @@ import NodeMailerService from './nodemailer';
|
|
|
12
12
|
import RabbitMQService from './rabbit';
|
|
13
13
|
import RedisService from './redis';
|
|
14
14
|
import SendgridService from './sendgrid';
|
|
15
|
-
export { AmazonCloudwatchService, AmazonPinpointService, AmazonS3Service, AmazonSecretManagerService, AmazonSQSService, AzureApplicationInsightsService, AzureAuthService, AzureCalendarService, AzureCommunicationService, AzureKeyVaultService, AzureStorageBlobService, DateService, FileService, FirebaseService, GoogleAuthService, GoogleCalendarService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService, GrafanaService, I18nService, KafkaService, KeycloakService, NodeMailerService, RabbitMQService, RedisService, SendgridService, };
|
|
15
|
+
export { AmazonCloudwatchService, AmazonPinpointService, AmazonS3Service, AmazonSecretManagerService, AmazonSQSService, AzureApplicationInsightsService, AzureAuthService, AzureCalendarService, AzureCommunicationService, AzureKeyVaultService, AzureStorageBlobService, DateService, FileService, FirebaseService, GoogleAuthService, GoogleCalendarService, GoogleMonitorService, GoogleSecretsService, GoogleSheetsService, GoogleStorageService, GrafanaService, I18nService, KafkaService, KeycloakService, NodeMailerService, RabbitMQService, RedisService, SendgridService, };
|
package/dist/services/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SendgridService = exports.RedisService = exports.RabbitMQService = exports.NodeMailerService = exports.KeycloakService = exports.KafkaService = exports.I18nService = exports.GrafanaService = exports.GoogleStorageService = exports.GoogleSheetsService = exports.GoogleSecretsService = exports.GoogleCalendarService = exports.GoogleAuthService = exports.FirebaseService = exports.FileService = exports.DateService = exports.AzureStorageBlobService = exports.AzureKeyVaultService = exports.AzureCommunicationService = exports.AzureCalendarService = exports.AzureAuthService = exports.AzureApplicationInsightsService = exports.AmazonSQSService = exports.AmazonSecretManagerService = exports.AmazonS3Service = exports.AmazonPinpointService = exports.AmazonCloudwatchService = void 0;
|
|
6
|
+
exports.SendgridService = exports.RedisService = exports.RabbitMQService = exports.NodeMailerService = exports.KeycloakService = exports.KafkaService = exports.I18nService = exports.GrafanaService = exports.GoogleStorageService = exports.GoogleSheetsService = exports.GoogleSecretsService = exports.GoogleMonitorService = exports.GoogleCalendarService = exports.GoogleAuthService = exports.FirebaseService = exports.FileService = exports.DateService = exports.AzureStorageBlobService = exports.AzureKeyVaultService = exports.AzureCommunicationService = exports.AzureCalendarService = exports.AzureAuthService = exports.AzureApplicationInsightsService = exports.AmazonSQSService = exports.AmazonSecretManagerService = exports.AmazonS3Service = exports.AmazonPinpointService = exports.AmazonCloudwatchService = void 0;
|
|
7
7
|
const aws_1 = require("./aws");
|
|
8
8
|
Object.defineProperty(exports, "AmazonCloudwatchService", { enumerable: true, get: function () { return aws_1.AmazonCloudwatchService; } });
|
|
9
9
|
Object.defineProperty(exports, "AmazonPinpointService", { enumerable: true, get: function () { return aws_1.AmazonPinpointService; } });
|
|
@@ -26,6 +26,7 @@ exports.FirebaseService = firebase_1.default;
|
|
|
26
26
|
const gcp_1 = require("./gcp");
|
|
27
27
|
Object.defineProperty(exports, "GoogleAuthService", { enumerable: true, get: function () { return gcp_1.GoogleAuthService; } });
|
|
28
28
|
Object.defineProperty(exports, "GoogleCalendarService", { enumerable: true, get: function () { return gcp_1.GoogleCalendarService; } });
|
|
29
|
+
Object.defineProperty(exports, "GoogleMonitorService", { enumerable: true, get: function () { return gcp_1.GoogleMonitorService; } });
|
|
29
30
|
Object.defineProperty(exports, "GoogleSecretsService", { enumerable: true, get: function () { return gcp_1.GoogleSecretsService; } });
|
|
30
31
|
Object.defineProperty(exports, "GoogleSheetsService", { enumerable: true, get: function () { return gcp_1.GoogleSheetsService; } });
|
|
31
32
|
Object.defineProperty(exports, "GoogleStorageService", { enumerable: true, get: function () { return gcp_1.GoogleStorageService; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mblabs-roccato-backend-commons",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.60",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -39,20 +39,24 @@
|
|
|
39
39
|
"migration:run": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:run -d src/core/database/provider.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
+
"@aws-sdk/client-cloudwatch": "^3.803.0",
|
|
42
43
|
"@aws-sdk/client-cloudwatch-logs": "^3.803.0",
|
|
43
44
|
"@aws-sdk/client-pinpoint": "^3.803.0",
|
|
44
45
|
"@aws-sdk/client-pinpoint-email": "^3.803.0",
|
|
45
46
|
"@aws-sdk/client-pinpoint-sms-voice": "^3.803.0",
|
|
46
47
|
"@aws-sdk/client-s3": "^3.803.0",
|
|
47
48
|
"@aws-sdk/client-secrets-manager": "^3.803.0",
|
|
48
|
-
"@aws-sdk/client-sqs": "^3.
|
|
49
|
+
"@aws-sdk/client-sqs": "^3.803.0",
|
|
49
50
|
"@aws-sdk/s3-request-presigner": "^3.803.0",
|
|
50
51
|
"@azure/communication-email": "^1.0.0",
|
|
51
52
|
"@azure/communication-sms": "^1.2.0-beta.3",
|
|
52
53
|
"@azure/identity": "^4.9.1",
|
|
53
54
|
"@azure/keyvault-secrets": "^4.9.0",
|
|
55
|
+
"@azure/monitor-query": "^1.3.3",
|
|
56
|
+
"@azure/monitor-query-metrics": "^1.0.0",
|
|
54
57
|
"@azure/msal-node": "^3.8.0",
|
|
55
58
|
"@azure/storage-blob": "^12.27.0",
|
|
59
|
+
"@google-cloud/monitoring": "^5.3.0",
|
|
56
60
|
"@google-cloud/secret-manager": "^6.0.1",
|
|
57
61
|
"@google-cloud/storage": "^7.16.0",
|
|
58
62
|
"@keycloak/keycloak-admin-client": "^26.3.1",
|
package/src/interfaces/aws.ts
CHANGED
|
@@ -28,6 +28,30 @@ export namespace AmazonCloudwatch {
|
|
|
28
28
|
credentials: Credentials;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
export namespace CreateMetric {
|
|
33
|
+
export interface Request {
|
|
34
|
+
data: {
|
|
35
|
+
namespace: string;
|
|
36
|
+
metric: {
|
|
37
|
+
title: string;
|
|
38
|
+
dimensions: {
|
|
39
|
+
name: string,
|
|
40
|
+
value: string
|
|
41
|
+
}[];
|
|
42
|
+
value: number;
|
|
43
|
+
unit:
|
|
44
|
+
'Count' |
|
|
45
|
+
'Percent' |
|
|
46
|
+
'Seconds' |
|
|
47
|
+
'Microseconds' |
|
|
48
|
+
'Milliseconds' |
|
|
49
|
+
'None';
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
credentials: Credentials;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
31
55
|
}
|
|
32
56
|
|
|
33
57
|
export namespace AmazonPinpoint {
|
|
@@ -218,6 +242,7 @@ export namespace AmazonSQS {
|
|
|
218
242
|
|
|
219
243
|
export interface IAmazonCloudwatchService {
|
|
220
244
|
createLogEvent(req: AmazonCloudwatch.CreateLogEvent.Request): Promise<void>;
|
|
245
|
+
createMetric(req: AmazonCloudwatch.CreateMetric.Request): Promise<void>;
|
|
221
246
|
}
|
|
222
247
|
|
|
223
248
|
export interface IAmazonPinpointService {
|
package/src/interfaces/gcp.ts
CHANGED
|
@@ -57,6 +57,28 @@ export namespace GoogleCalendar {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export namespace GoogleMonitor {
|
|
61
|
+
export namespace CreateMetric {
|
|
62
|
+
export interface Request {
|
|
63
|
+
data: {
|
|
64
|
+
namespace: string;
|
|
65
|
+
metric: {
|
|
66
|
+
title: string;
|
|
67
|
+
value: number;
|
|
68
|
+
typeof: 'VALUE_TYPE_UNSPECIFIED' | 'BOOL' | 'INT64' | 'DOUBLE' | 'STRING' | 'DISTRIBUTION' | 'MONEY',
|
|
69
|
+
measure: 'METRIC_KIND_UNSPECIFIED' | 'GAUGE' | 'DELTA' | 'CUMULATIVE',
|
|
70
|
+
labels: {
|
|
71
|
+
key: string;
|
|
72
|
+
typeof: 'STRING' | 'BOOL' | 'INT64';
|
|
73
|
+
description: string;
|
|
74
|
+
}[];
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
credentials: Credentials;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
60
82
|
export namespace GoogleStorage {
|
|
61
83
|
export namespace GetSignedUrl {
|
|
62
84
|
export interface Request {
|
|
@@ -128,3 +150,7 @@ export interface IGoogleAuthService {
|
|
|
128
150
|
export interface IGoogleCalendarService {
|
|
129
151
|
getEvents(req: GoogleCalendar.GetEvents.Request): Promise<GoogleCalendar.GetEvents.Response>;
|
|
130
152
|
}
|
|
153
|
+
|
|
154
|
+
export interface IGoogleMonitorService {
|
|
155
|
+
createMetric(req: GoogleMonitor.CreateMetric.Request): Promise<void>;
|
|
156
|
+
}
|
|
@@ -1,8 +1,34 @@
|
|
|
1
|
+
import { CloudWatch } from '@aws-sdk/client-cloudwatch';
|
|
1
2
|
import { CloudWatchLogs } from '@aws-sdk/client-cloudwatch-logs';
|
|
2
3
|
|
|
3
4
|
import { AmazonCloudwatch, IAmazonCloudwatchService } from '../../interfaces';
|
|
4
5
|
|
|
5
6
|
class AmazonCloudwatchService implements IAmazonCloudwatchService {
|
|
7
|
+
async createMetric ({ credentials, data }: AmazonCloudwatch.CreateMetric.Request): Promise<void> {
|
|
8
|
+
const client: CloudWatch = new CloudWatch({
|
|
9
|
+
credentials: {
|
|
10
|
+
accessKeyId: credentials.accessKey,
|
|
11
|
+
secretAccessKey: credentials.secretKey,
|
|
12
|
+
},
|
|
13
|
+
region: credentials.region,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
await client.putMetricData({
|
|
17
|
+
Namespace: data.namespace,
|
|
18
|
+
MetricData: [
|
|
19
|
+
{
|
|
20
|
+
MetricName: data.metric.title,
|
|
21
|
+
Dimensions: data.metric.dimensions.map(dimension => ({
|
|
22
|
+
Name: dimension.name,
|
|
23
|
+
Value: dimension.value,
|
|
24
|
+
})),
|
|
25
|
+
Value: data.metric.value,
|
|
26
|
+
Unit: data.metric.unit,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
6
32
|
public async createLogEvent ({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request): Promise<void> {
|
|
7
33
|
const client: CloudWatchLogs = new CloudWatchLogs({
|
|
8
34
|
credentials: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import GoogleAuthService from './auth';
|
|
2
2
|
import GoogleCalendarService from './calendar';
|
|
3
|
+
import GoogleMonitorService from './monitor';
|
|
3
4
|
import GoogleSecretsService from './secrets';
|
|
4
5
|
import GoogleSheetsService from './sheets';
|
|
5
6
|
import GoogleStorageService from './storage';
|
|
@@ -10,4 +11,5 @@ export {
|
|
|
10
11
|
GoogleSecretsService,
|
|
11
12
|
GoogleSheetsService,
|
|
12
13
|
GoogleStorageService,
|
|
14
|
+
GoogleMonitorService,
|
|
13
15
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MetricServiceClient } from '@google-cloud/monitoring';
|
|
2
|
+
|
|
3
|
+
import { GoogleMonitor, IGoogleMonitorService } from '../../interfaces';
|
|
4
|
+
|
|
5
|
+
class GoogleMonitorService implements IGoogleMonitorService {
|
|
6
|
+
async createMetric ({
|
|
7
|
+
credentials,
|
|
8
|
+
data,
|
|
9
|
+
}: GoogleMonitor.CreateMetric.Request): Promise<void> {
|
|
10
|
+
const client = new MetricServiceClient({
|
|
11
|
+
apiKey: credentials.apiKey,
|
|
12
|
+
projectId: credentials.project,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
await client.createMetricDescriptor({
|
|
16
|
+
name: client.projectPath(credentials.project),
|
|
17
|
+
metricDescriptor: {
|
|
18
|
+
name: data.metric.title,
|
|
19
|
+
type: data.namespace,
|
|
20
|
+
metricKind: data.metric.measure,
|
|
21
|
+
valueType: data.metric.typeof,
|
|
22
|
+
unit: data.metric.value.toString(),
|
|
23
|
+
labels: data.metric.labels.map((label) => ({
|
|
24
|
+
key: label.key,
|
|
25
|
+
valueType: label.typeof,
|
|
26
|
+
description: label.description,
|
|
27
|
+
})),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default new GoogleMonitorService();
|
|
@@ -8,7 +8,10 @@ class GoogleSecretsService implements IGoogleSecretsService {
|
|
|
8
8
|
credentials,
|
|
9
9
|
data,
|
|
10
10
|
}: GoogleSecrets.GetSecret.Request): Promise<GoogleSecrets.GetSecret.Response<T>> {
|
|
11
|
-
const client = new SecretManagerServiceClient({
|
|
11
|
+
const client = new SecretManagerServiceClient({
|
|
12
|
+
apiKey: credentials.apiKey,
|
|
13
|
+
projectId: credentials.project,
|
|
14
|
+
});
|
|
12
15
|
|
|
13
16
|
const [ version ] = await client.accessSecretVersion({
|
|
14
17
|
name: `projects/${data.project}/secrets/${data.secret}/versions/latest`,
|
package/src/services/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ import FirebaseService from './firebase';
|
|
|
19
19
|
import {
|
|
20
20
|
GoogleAuthService,
|
|
21
21
|
GoogleCalendarService,
|
|
22
|
+
GoogleMonitorService,
|
|
22
23
|
GoogleSecretsService,
|
|
23
24
|
GoogleSheetsService,
|
|
24
25
|
GoogleStorageService,
|
|
@@ -49,6 +50,7 @@ export {
|
|
|
49
50
|
FirebaseService,
|
|
50
51
|
GoogleAuthService,
|
|
51
52
|
GoogleCalendarService,
|
|
53
|
+
GoogleMonitorService,
|
|
52
54
|
GoogleSecretsService,
|
|
53
55
|
GoogleSheetsService,
|
|
54
56
|
GoogleStorageService,
|