@centreon/js-config 24.4.23 → 24.4.24

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.
@@ -138,6 +138,102 @@ Cypress.Commands.add(
138
138
  }
139
139
  );
140
140
 
141
+ interface Contact {
142
+ admin?: boolean;
143
+ alias?: string | null;
144
+ authenticationType?: 'local' | 'ldap';
145
+ email: string;
146
+ enableNotifications?: boolean;
147
+ GUIAccess?: boolean;
148
+ language?: string;
149
+ name: string;
150
+ password: string;
151
+ }
152
+
153
+ Cypress.Commands.add(
154
+ 'addContact',
155
+ ({
156
+ admin = true,
157
+ alias = null,
158
+ authenticationType = 'local',
159
+ email,
160
+ enableNotifications = true,
161
+ GUIAccess = true,
162
+ language = 'en_US',
163
+ name,
164
+ password
165
+ }: Contact): Cypress.Chainable => {
166
+ const contactAdmin = admin ? 1 : 0;
167
+ const contactAlias = alias === null ? name : alias;
168
+ const contactEnableNotifications = enableNotifications ? 1 : 0;
169
+ const contactGUIAccess = GUIAccess ? 1 : 0;
170
+
171
+ return cy
172
+ .executeActionViaClapi({
173
+ bodyContent: {
174
+ action: 'ADD',
175
+ object: 'CONTACT',
176
+ values: `${name};${contactAlias};${email};${password};${contactAdmin};${contactGUIAccess};${language};${authenticationType}`
177
+ }
178
+ })
179
+ .then(() => {
180
+ const contactParams = {
181
+ enable_notifications: contactEnableNotifications
182
+ };
183
+ Object.entries(contactParams).map(([paramName, paramValue]) => {
184
+ if (paramValue === null) {
185
+ return null;
186
+ }
187
+
188
+ return cy.executeActionViaClapi({
189
+ bodyContent: {
190
+ action: 'SETPARAM',
191
+ object: 'CONTACT',
192
+ values: `${name};${paramName};${paramValue}`
193
+ }
194
+ });
195
+ });
196
+
197
+ return cy.wrap(null);
198
+ });
199
+ }
200
+ );
201
+
202
+ interface ContactGroup {
203
+ alias?: string | null;
204
+ contacts: string[];
205
+ name: string;
206
+ }
207
+
208
+ Cypress.Commands.add(
209
+ 'addContactGroup',
210
+ ({ alias = null, contacts, name }: ContactGroup): Cypress.Chainable => {
211
+ const contactGroupAlias = alias === null ? name : alias;
212
+
213
+ return cy
214
+ .executeActionViaClapi({
215
+ bodyContent: {
216
+ action: 'ADD',
217
+ object: 'CG',
218
+ values: `${name};${contactGroupAlias}`
219
+ }
220
+ })
221
+ .then(() => {
222
+ contacts.map((contact) => {
223
+ return cy.executeActionViaClapi({
224
+ bodyContent: {
225
+ action: 'ADDCONTACT',
226
+ object: 'CG',
227
+ values: `${name};${contact}`
228
+ }
229
+ });
230
+ });
231
+
232
+ return cy.wrap(null);
233
+ });
234
+ }
235
+ );
236
+
141
237
  interface Host {
142
238
  activeCheckEnabled?: boolean;
143
239
  address?: string;
@@ -208,6 +304,26 @@ Cypress.Commands.add(
208
304
  }
209
305
  );
210
306
 
307
+ interface HostGroup {
308
+ alias?: string | null;
309
+ name: string;
310
+ }
311
+
312
+ Cypress.Commands.add(
313
+ 'addHostGroup',
314
+ ({ alias = null, name }: HostGroup): Cypress.Chainable => {
315
+ const hostGroupAlias = alias === null ? name : alias;
316
+
317
+ return cy.executeActionViaClapi({
318
+ bodyContent: {
319
+ action: 'ADD',
320
+ object: 'HG',
321
+ values: `${name};${hostGroupAlias}`
322
+ }
323
+ });
324
+ }
325
+ );
326
+
211
327
  interface ServiceTemplate {
212
328
  activeCheckEnabled?: boolean;
213
329
  checkCommand?: string | null;
@@ -329,6 +445,45 @@ Cypress.Commands.add(
329
445
  }
330
446
  );
331
447
 
448
+ interface ServiceGroup {
449
+ alias?: string | null;
450
+ hostsAndServices: string[][];
451
+ name: string;
452
+ }
453
+
454
+ Cypress.Commands.add(
455
+ 'addServiceGroup',
456
+ ({
457
+ alias = null,
458
+ hostsAndServices,
459
+ name
460
+ }: ServiceGroup): Cypress.Chainable => {
461
+ const serviceGroupAlias = alias === null ? name : alias;
462
+
463
+ return cy
464
+ .executeActionViaClapi({
465
+ bodyContent: {
466
+ action: 'ADD',
467
+ object: 'SG',
468
+ values: `${name};${serviceGroupAlias}`
469
+ }
470
+ })
471
+ .then(() => {
472
+ hostsAndServices.map((hostAndService) => {
473
+ return cy.executeActionViaClapi({
474
+ bodyContent: {
475
+ action: 'ADDSERVICE',
476
+ object: 'SG',
477
+ values: `${name};${hostAndService[0]},${hostAndService[1]}`
478
+ }
479
+ });
480
+ });
481
+
482
+ return cy.wrap(null);
483
+ });
484
+ }
485
+ );
486
+
332
487
  Cypress.Commands.add(
333
488
  'applyPollerConfiguration',
334
489
  (pollerName = 'Central'): Cypress.Chainable => {
@@ -345,8 +500,12 @@ declare global {
345
500
  namespace Cypress {
346
501
  interface Chainable {
347
502
  addCheckCommand: (props: CheckCommand) => Cypress.Chainable;
503
+ addContact: (props: Contact) => Cypress.Chainable;
504
+ addContactGroup: (props: ContactGroup) => Cypress.Chainable;
348
505
  addHost: (props: Host) => Cypress.Chainable;
506
+ addHostGroup: (props: HostGroup) => Cypress.Chainable;
349
507
  addService: (props: Service) => Cypress.Chainable;
508
+ addServiceGroup: (props: ServiceGroup) => Cypress.Chainable;
350
509
  addServiceTemplate: (props: ServiceTemplate) => Cypress.Chainable;
351
510
  addTimePeriod: (props: TimePeriod) => Cypress.Chainable;
352
511
  applyPollerConfiguration: (props?: string) => Cypress.Chainable;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@centreon/js-config",
3
3
  "description": "Centreon Frontend shared build configuration",
4
- "version": "24.4.23",
4
+ "version": "24.4.24",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"