1
1
import {
2
2
type AmServiceSkeleton ,
3
+ type ServiceNextDescendent ,
3
4
deleteService ,
4
5
deleteServiceNextDescendent ,
5
6
type FullService ,
8
9
getServiceDescendents ,
9
10
putService ,
10
11
putServiceNextDescendent ,
12
+ ServiceNextDescendentResponse ,
11
13
} from '../api/ServiceApi' ;
12
14
import { State } from '../shared/State' ;
13
15
import {
@@ -46,6 +48,10 @@ export type Service = {
46
48
serviceId : string ,
47
49
globalConfig ?: boolean
48
50
) : Promise < AmServiceSkeleton > ;
51
+ deleteServiceNextDescendentOnly (
52
+ serviceId :string ,
53
+ globalConfig ?:boolean
54
+ ) :Promise < ServiceNextDescendent > ;
49
55
/**
50
56
* Deletes all services
51
57
* @param {boolean } globalConfig true if the global service is the target of the operation, false otherwise. Default: false.
@@ -124,7 +130,12 @@ export default (state: State): Service => {
124
130
) : Promise < AmServiceSkeleton > {
125
131
return deleteFullService ( { serviceId, globalConfig, state } ) ;
126
132
} ,
127
-
133
+ async deleteServiceNextDescendentOnly (
134
+ serviceId :string ,
135
+ globalConfig = false
136
+ ) : Promise < ServiceNextDescendent > {
137
+ return deleteServiceNextDescentdentOnly ( { serviceId, globalConfig, state} ) ;
138
+ } ,
128
139
/**
129
140
* Deletes all services
130
141
* @param {boolean } globalConfig true if the global service is the target of the operation, false otherwise. Default: false.
@@ -312,7 +323,7 @@ export async function getFullServices({
312
323
! (
313
324
error . response ?. status === 403 &&
314
325
error . response ?. data ?. message ===
315
- 'This operation is not available in PingOne Advanced Identity Cloud.'
326
+ 'This operation is not available in PingOne Advanced Identity Cloud.'
316
327
)
317
328
) {
318
329
const message = error . response ?. data ?. message ;
@@ -466,8 +477,7 @@ export async function putFullService({
466
477
return result ;
467
478
} catch ( error ) {
468
479
throw new FrodoError (
469
- `Error putting ${
470
- globalConfig ? 'global' : 'realm'
480
+ `Error putting ${ globalConfig ? 'global' : 'realm'
471
481
} full service config ${ serviceId } `,
472
482
error
473
483
) ;
@@ -582,14 +592,51 @@ export async function deleteFullService({
582
592
return deleteService ( { serviceId, globalConfig, state } ) ;
583
593
} catch ( error ) {
584
594
throw new FrodoError (
585
- `Error deleting ${
586
- globalConfig ? 'global' : 'realm'
595
+ `Error deleting ${ globalConfig ? 'global' : 'realm'
587
596
} full service config ${ serviceId } `,
588
597
error
589
598
) ;
590
599
}
591
600
}
592
601
602
+ export async function deleteServiceNextDescentdentOnly ( {
603
+ serviceId,
604
+ globalConfig = false ,
605
+ state,
606
+ } : {
607
+ serviceId : string ;
608
+ globalConfig : boolean ;
609
+ state : State ;
610
+ } ) :Promise < ServiceNextDescendent > {
611
+ try {
612
+ debugMessage ( {
613
+ message : `ServiceOps.deleteServiceDescendentOnly: start, globalConfig=${ globalConfig } ` ,
614
+ state,
615
+ } ) ;
616
+ const serviceNextDescendentData = await getServiceDescendents ( {
617
+ serviceId,
618
+ globalConfig,
619
+ state,
620
+ } ) ;
621
+
622
+ return await Promise . all ( serviceNextDescendentData . map ( ( nextDescendent ) => deleteServiceNextDescendent ( {
623
+ serviceId,
624
+ serviceType : nextDescendent . _type . _id ,
625
+ serviceNextDescendentId : nextDescendent . _id ,
626
+ globalConfig,
627
+ state,
628
+ } )
629
+ )
630
+ )
631
+ }
632
+ catch ( error ) {
633
+ throw new FrodoError (
634
+ `Error deleting ${ globalConfig ? 'global' : 'realm'
635
+ } full service config ${ serviceId } `,
636
+ error
637
+ ) ;
638
+ }
639
+ }
593
640
/**
594
641
* Deletes all services
595
642
* @param {boolean } globalConfig true if the global service is the target of the operation, false otherwise. Default: false.
@@ -622,7 +669,7 @@ export async function deleteFullServices({
622
669
! (
623
670
error . response ?. status === 403 &&
624
671
error . response ?. data ?. message ===
625
- 'This operation is not available in PingOne Advanced Identity Cloud.'
672
+ 'This operation is not available in PingOne Advanced Identity Cloud.'
626
673
)
627
674
) {
628
675
const message = error . response ?. data ?. message ;
@@ -639,8 +686,7 @@ export async function deleteFullServices({
639
686
return deleted ;
640
687
} catch ( error ) {
641
688
throw new FrodoError (
642
- `Error deleting ${
643
- globalConfig ? 'global' : 'realm'
689
+ `Error deleting ${ globalConfig ? 'global' : 'realm'
644
690
} full service configs`,
645
691
error
646
692
) ;
@@ -680,8 +726,7 @@ export async function exportService({
680
726
return exportData ;
681
727
} catch ( error ) {
682
728
throw new FrodoError (
683
- `Error exporting ${
684
- globalConfig ? 'global' : 'realm'
729
+ `Error exporting ${ globalConfig ? 'global' : 'realm'
685
730
} service ${ serviceId } `,
686
731
error
687
732
) ;
@@ -715,19 +760,17 @@ export async function exportServices({
715
760
for ( const service of services ) {
716
761
updateProgressIndicator ( {
717
762
id : indicatorId ,
718
- message : `Exporting ${ globalConfig ? 'global' : 'realm' } service ${
719
- service . _id
720
- } `,
763
+ message : `Exporting ${ globalConfig ? 'global' : 'realm' } service ${ service . _id
764
+ } `,
721
765
state,
722
766
} ) ;
723
767
service . location = globalConfig ? 'global' : state . getRealm ( ) ;
724
768
exportData . service [ service . _type . _id ] = service ;
725
769
}
726
770
stopProgressIndicator ( {
727
771
id : indicatorId ,
728
- message : `Exported ${ services . length } ${
729
- globalConfig ? 'global' : 'realm'
730
- } services.`,
772
+ message : `Exported ${ services . length } ${ globalConfig ? 'global' : 'realm'
773
+ } services.`,
731
774
state,
732
775
} ) ;
733
776
debugMessage ( { message : `ServiceOps.exportServices: end` , state } ) ;
0 commit comments