@camunda/ccma-api 14.3.0 → 14.5.0

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.
@@ -0,0 +1,65 @@
1
+ import { request } from "../../utils/api.js";
2
+ import { HttpError } from "../../utils/errors.js";
3
+ class AccountsInfraNoticesService {
4
+ static async getInfraNoticeSubscription(params) {
5
+ return send(params, {
6
+ name: "AccountsInfraNoticesService.getInfraNoticeSubscription",
7
+ path: "infra-notices/subscription",
8
+ type: "get"
9
+ });
10
+ }
11
+ static async putInfraNoticeSubscription(params) {
12
+ return send(
13
+ params,
14
+ {
15
+ name: "AccountsInfraNoticesService.putInfraNoticeSubscription",
16
+ path: "infra-notices/subscription",
17
+ type: "put"
18
+ },
19
+ { subscribed: params.subscribed }
20
+ );
21
+ }
22
+ static async getInfraNoticeRecipients(params) {
23
+ return send(params, {
24
+ name: "AccountsInfraNoticesService.getInfraNoticeRecipients",
25
+ path: "infra-notice-recipients",
26
+ type: "get"
27
+ });
28
+ }
29
+ }
30
+ async function send(params, method, body) {
31
+ const template = `api/organizations/:orgId/${method.path}`;
32
+ const serviceContext = {
33
+ method: {
34
+ name: method.name,
35
+ url: template,
36
+ normalizedUrl: template,
37
+ type: method.type
38
+ },
39
+ source: params.config.metrics?.source || "unset",
40
+ target: { name: "accounts", type: "internal" }
41
+ };
42
+ const response = await request({
43
+ config: params.config,
44
+ base: { id: "accounts" },
45
+ url: `api/organizations/${encodeURIComponent(params.orgId)}/${method.path}`,
46
+ // The log and the metrics show the template, not the org id.
47
+ logUrl: template,
48
+ method: serviceContext.method.type,
49
+ metricsDetails: serviceContext,
50
+ body,
51
+ responseType: "json"
52
+ });
53
+ if (!response.ok || response.body === void 0) {
54
+ throw new HttpError(
55
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
56
+ response.status,
57
+ response.statusText
58
+ );
59
+ }
60
+ return response.body;
61
+ }
62
+ export {
63
+ AccountsInfraNoticesService
64
+ };
65
+ //# sourceMappingURL=infra-notices.service.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/services/accounts/infra-notices.service.ts"],
4
+ "sourcesContent": ["/*\n * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH\n * under one or more contributor license agreements. Licensed under a commercial license.\n * You may not use this file except in compliance with the commercial license.\n */\n\nimport type {\n RequestBaseParams,\n RequestBaseServiceContext,\n} from '../../types/general.types.js'\nimport { request } from '../../utils/api.js'\nimport { HttpError } from '../../utils/errors.js'\n\n/** The choice of the caller for the email of infra notices (#11886). */\nexport interface InfraNoticeSubscription {\n subscribed: boolean\n}\n\n/** The recipients of the email of infra notices for one org (#11886). */\nexport interface InfraNoticeRecipients {\n /** The user ids of the recipients, sorted by byte order. */\n userIds: string[]\n /** The stored ids that opted in, without the ids that are not members. */\n optedIn: string[]\n /** The stored ids that opted out, without the ids that are not members. */\n optedOut: string[]\n}\n\nexport type InfraNoticeOrgRequest = RequestBaseParams & { orgId: string }\n\n/**\n * The infra notice routes of accounts. Section 5.4 of\n * `docs/infra-notices/contracts.md` is the contract. The subscription routes\n * answer 404 while the flag `shared.infraNotices` is off.\n */\nexport class AccountsInfraNoticesService {\n public static async getInfraNoticeSubscription(\n params: InfraNoticeOrgRequest,\n ): Promise<InfraNoticeSubscription> {\n return send<InfraNoticeSubscription>(params, {\n name: 'AccountsInfraNoticesService.getInfraNoticeSubscription',\n path: 'infra-notices/subscription',\n type: 'get',\n })\n }\n\n public static async putInfraNoticeSubscription(\n params: InfraNoticeOrgRequest & InfraNoticeSubscription,\n ): Promise<InfraNoticeSubscription> {\n return send<InfraNoticeSubscription>(\n params,\n {\n name: 'AccountsInfraNoticesService.putInfraNoticeSubscription',\n path: 'infra-notices/subscription',\n type: 'put',\n },\n { subscribed: params.subscribed },\n )\n }\n\n public static async getInfraNoticeRecipients(\n params: InfraNoticeOrgRequest,\n ): Promise<InfraNoticeRecipients> {\n return send<InfraNoticeRecipients>(params, {\n name: 'AccountsInfraNoticesService.getInfraNoticeRecipients',\n path: 'infra-notice-recipients',\n type: 'get',\n })\n }\n}\n\nasync function send<T>(\n params: InfraNoticeOrgRequest,\n method: { name: string; path: string; type: 'get' | 'put' },\n body?: InfraNoticeSubscription,\n): Promise<T> {\n const template = `api/organizations/:orgId/${method.path}`\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: method.name,\n url: template,\n normalizedUrl: template,\n type: method.type,\n },\n source: params.config.metrics?.source || 'unset',\n target: { name: 'accounts', type: 'internal' },\n }\n const response = await request<T>({\n config: params.config,\n base: { id: 'accounts' },\n url: `api/organizations/${encodeURIComponent(params.orgId)}/${method.path}`,\n // The log and the metrics show the template, not the org id.\n logUrl: template,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n body,\n responseType: 'json',\n })\n if (!response.ok || response.body === undefined) {\n throw new HttpError(\n `${serviceContext.method.name}: ${response.status} ${response.statusText}`,\n response.status,\n response.statusText,\n )\n }\n return response.body\n}\n"],
5
+ "mappings": "AAUA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAwBnB,MAAM,4BAA4B;AAAA,EACvC,aAAoB,2BAClB,QACkC;AAClC,WAAO,KAA8B,QAAQ;AAAA,MAC3C,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,IACR,CAAC;AAAA,EACH;AAAA,EAEA,aAAoB,2BAClB,QACkC;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,MACA,EAAE,YAAY,OAAO,WAAW;AAAA,IAClC;AAAA,EACF;AAAA,EAEA,aAAoB,yBAClB,QACgC;AAChC,WAAO,KAA4B,QAAQ;AAAA,MACzC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,IACR,CAAC;AAAA,EACH;AACF;AAEA,eAAe,KACb,QACA,QACA,MACY;AACZ,QAAM,WAAW,4BAA4B,OAAO,IAAI;AACxD,QAAM,iBAA4C;AAAA,IAChD,QAAQ;AAAA,MACN,MAAM,OAAO;AAAA,MACb,KAAK;AAAA,MACL,eAAe;AAAA,MACf,MAAM,OAAO;AAAA,IACf;AAAA,IACA,QAAQ,OAAO,OAAO,SAAS,UAAU;AAAA,IACzC,QAAQ,EAAE,MAAM,YAAY,MAAM,WAAW;AAAA,EAC/C;AACA,QAAM,WAAW,MAAM,QAAW;AAAA,IAChC,QAAQ,OAAO;AAAA,IACf,MAAM,EAAE,IAAI,WAAW;AAAA,IACvB,KAAK,qBAAqB,mBAAmB,OAAO,KAAK,CAAC,IAAI,OAAO,IAAI;AAAA;AAAA,IAEzE,QAAQ;AAAA,IACR,QAAQ,eAAe,OAAO;AAAA,IAC9B,gBAAgB;AAAA,IAChB;AAAA,IACA,cAAc;AAAA,EAChB,CAAC;AACD,MAAI,CAAC,SAAS,MAAM,SAAS,SAAS,QAAW;AAC/C,UAAM,IAAI;AAAA,MACR,GAAG,eAAe,OAAO,IAAI,KAAK,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,MACxE,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,EACF;AACA,SAAO,SAAS;AAClB;",
6
+ "names": []
7
+ }
@@ -3,6 +3,25 @@ import type { RequestBaseParams } from '../../types/general.types.js';
3
3
  import type { OpenIncident, RecentIncident } from '../incident-io/incident-io.service.js';
4
4
  import type { ConsoleClusterClientDto } from './console.cluster-clients.service.js';
5
5
  import type { SecureConnectivityStatusDto } from './console.secure-connectivity.service.js';
6
+ export interface InfraNoticeFleetCluster {
7
+ uuid: string;
8
+ name: string;
9
+ orgId: string;
10
+ /** Left out when the cluster has no Kubernetes context. */
11
+ region?: string;
12
+ generationUuid: string;
13
+ generationName: string;
14
+ }
15
+ export interface InfraNoticeFleetGeneration {
16
+ uuid: string;
17
+ name: string;
18
+ }
19
+ export interface InfraNoticeFleet {
20
+ clusters: InfraNoticeFleetCluster[];
21
+ /** The distinct regions of all Kubernetes contexts, sorted. */
22
+ regions: string[];
23
+ generations: InfraNoticeFleetGeneration[];
24
+ }
6
25
  export interface UpdateClusterToNewPlanTypeRequest extends RequestBaseParams {
7
26
  params: {
8
27
  orgId: string;
@@ -438,6 +457,12 @@ export declare class ConsoleAdminService {
438
457
  * m2m permission `cmracs`.
439
458
  */
440
459
  static getApiClientStats(params: RequestBaseParams): Promise<ApiClientStatsDto>;
460
+ /**
461
+ * The fleet for the infra notices: each cluster with its org, region and
462
+ * generation, and each generation. It needs `ccrai`, or the m2m permission
463
+ * `cmrinf`.
464
+ */
465
+ static getInfraNoticeFleet(params: RequestBaseParams): Promise<InfraNoticeFleet>;
441
466
  static getApiClients(params: {
442
467
  orgId: string;
443
468
  } & RequestBaseParams): Promise<any[] | undefined>;
@@ -1027,6 +1027,40 @@ class ConsoleAdminService {
1027
1027
  }
1028
1028
  return response.body;
1029
1029
  }
1030
+ /**
1031
+ * The fleet for the infra notices: each cluster with its org, region and
1032
+ * generation, and each generation. It needs `ccrai`, or the m2m permission
1033
+ * `cmrinf`.
1034
+ */
1035
+ static async getInfraNoticeFleet(params) {
1036
+ const serviceContext = {
1037
+ method: {
1038
+ name: `ConsoleAdminService.getInfraNoticeFleet`,
1039
+ url: `api/admin/infra-notices/fleet`,
1040
+ normalizedUrl: `api/admin/infra-notices/fleet`,
1041
+ type: "get"
1042
+ },
1043
+ source: params.config.metrics?.source || "unset",
1044
+ target: { name: "console", type: "internal" }
1045
+ };
1046
+ const response = await request({
1047
+ ...params,
1048
+ base: { id: "console" },
1049
+ responseType: "json",
1050
+ url: serviceContext.method.url,
1051
+ method: serviceContext.method.type,
1052
+ metricsDetails: serviceContext,
1053
+ retryTransientErrors: true
1054
+ });
1055
+ if (!response.ok) {
1056
+ throw new HttpError(
1057
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
1058
+ response.status,
1059
+ response.statusText
1060
+ );
1061
+ }
1062
+ return response.body;
1063
+ }
1030
1064
  static async getApiClients(params) {
1031
1065
  const serviceContext = {
1032
1066
  method: {