|
73 | 73 | import org.cloudfoundry.client.v2.userprovidedserviceinstances.ListUserProvidedServiceInstancesRequest; |
74 | 74 | import org.cloudfoundry.client.v2.userprovidedserviceinstances.RemoveUserProvidedServiceInstanceRouteRequest; |
75 | 75 | import org.cloudfoundry.client.v2.userprovidedserviceinstances.UserProvidedServiceInstanceResource; |
76 | | -import org.cloudfoundry.client.v2.users.UserResource; |
77 | 76 | import org.cloudfoundry.client.v3.Metadata; |
78 | 77 | import org.cloudfoundry.client.v3.Relationship; |
79 | 78 | import org.cloudfoundry.client.v3.applications.Application; |
|
86 | 85 | import org.cloudfoundry.client.v3.spaces.GetSpaceResponse; |
87 | 86 | import org.cloudfoundry.client.v3.spaces.UpdateSpaceRequest; |
88 | 87 | import org.cloudfoundry.client.v3.spaces.UpdateSpaceResponse; |
| 88 | +import org.cloudfoundry.client.v3.users.UserResource; |
89 | 89 | import org.cloudfoundry.networking.NetworkingClient; |
90 | 90 | import org.cloudfoundry.networking.v1.policies.DeletePoliciesRequest; |
91 | 91 | import org.cloudfoundry.networking.v1.policies.Destination; |
@@ -213,7 +213,7 @@ void clean() { |
213 | 213 | cleanSpaceQuotaDefinitions( |
214 | 214 | this.cloudFoundryClient, this.nameFactory), |
215 | 215 | cleanStacks(this.cloudFoundryClient, this.nameFactory), |
216 | | - cleanUsers(this.cloudFoundryClient, this.nameFactory))) |
| 216 | + cleanUsersV3(this.cloudFoundryClient, this.nameFactory))) |
217 | 217 | .thenMany( |
218 | 218 | Mono.when( |
219 | 219 | cleanApplicationsV3( |
@@ -1043,35 +1043,29 @@ private static Flux<Void> cleanUserProvidedServiceInstances( |
1043 | 1043 | t))); |
1044 | 1044 | } |
1045 | 1045 |
|
1046 | | - private static Flux<Void> cleanUsers( |
| 1046 | + private static Flux<Void> cleanUsersV3( |
1047 | 1047 | CloudFoundryClient cloudFoundryClient, NameFactory nameFactory) { |
1048 | | - return PaginationUtils.requestClientV2Resources( |
| 1048 | + return PaginationUtils.requestClientV3Resources( |
1049 | 1049 | page -> |
1050 | 1050 | cloudFoundryClient |
1051 | | - .users() |
| 1051 | + .usersV3() |
1052 | 1052 | .list( |
1053 | | - org.cloudfoundry.client.v2.users.ListUsersRequest |
| 1053 | + org.cloudfoundry.client.v3.users.ListUsersRequest |
1054 | 1054 | .builder() |
1055 | 1055 | .page(page) |
1056 | 1056 | .build())) |
1057 | 1057 | .filter(resource -> isCleanable(nameFactory, resource)) |
1058 | | - .map(resource -> resource.getMetadata().getId()) |
| 1058 | + .map(UserResource::getId) |
1059 | 1059 | .flatMap( |
1060 | 1060 | userId -> |
1061 | 1061 | cloudFoundryClient |
1062 | | - .users() |
| 1062 | + .usersV3() |
1063 | 1063 | .delete( |
1064 | | - org.cloudfoundry.client.v2.users.DeleteUserRequest |
| 1064 | + org.cloudfoundry.client.v3.users.DeleteUserRequest |
1065 | 1065 | .builder() |
1066 | | - .async(true) |
1067 | 1066 | .userId(userId) |
1068 | 1067 | .build()) |
1069 | | - .flatMapMany( |
1070 | | - job -> |
1071 | | - JobUtils.waitForCompletion( |
1072 | | - cloudFoundryClient, |
1073 | | - Duration.ofMinutes(5), |
1074 | | - job)) |
| 1068 | + .then() |
1075 | 1069 | .doOnError( |
1076 | 1070 | t -> |
1077 | 1071 | LOGGER.error( |
@@ -1150,12 +1144,12 @@ private static Flux<Void> ifCfVersion( |
1150 | 1144 | CloudFoundryVersion expectedVersion, |
1151 | 1145 | Version serverVersion, |
1152 | 1146 | Supplier<Flux<Void>> supplier) { |
1153 | | - return serverVersion.lessThan(expectedVersion.getVersion()) ? Flux.empty() : supplier.get(); |
| 1147 | + return serverVersion.isLowerThan(expectedVersion.getVersion()) ? Flux.empty() : supplier.get(); |
1154 | 1148 | } |
1155 | 1149 |
|
1156 | 1150 | private static boolean isCleanable(NameFactory nameFactory, UserResource resource) { |
1157 | | - return nameFactory.isUserId(ResourceUtils.getId(resource)) |
1158 | | - || nameFactory.isUserName(ResourceUtils.getEntity(resource).getUsername()); |
| 1151 | + return nameFactory.isUserId(resource.getId()) |
| 1152 | + || nameFactory.isUserName(resource.getUsername()); |
1159 | 1153 | } |
1160 | 1154 |
|
1161 | 1155 | private static Flux<Void> removeApplicationServiceBindings( |
|
0 commit comments