|
40 | 40 | import java.util.function.UnaryOperator; |
41 | 41 | import java.util.stream.Collectors; |
42 | 42 | import org.cloudfoundry.client.CloudFoundryClient; |
43 | | -import org.cloudfoundry.client.v2.OrderDirection; |
44 | 43 | import org.cloudfoundry.client.v2.applications.AbstractApplicationResource; |
45 | 44 | import org.cloudfoundry.client.v2.applications.ApplicationEntity; |
46 | 45 | import org.cloudfoundry.client.v2.applications.ApplicationInstanceInfo; |
|
68 | 67 | import org.cloudfoundry.client.v2.applications.UploadApplicationRequest; |
69 | 68 | import org.cloudfoundry.client.v2.applications.UploadApplicationResponse; |
70 | 69 | import org.cloudfoundry.client.v2.applications.Usage; |
71 | | -import org.cloudfoundry.client.v2.events.EventEntity; |
72 | | -import org.cloudfoundry.client.v2.events.EventResource; |
73 | | -import org.cloudfoundry.client.v2.events.ListEventsRequest; |
74 | 70 | import org.cloudfoundry.client.v2.organizations.ListOrganizationPrivateDomainsRequest; |
75 | 71 | import org.cloudfoundry.client.v2.organizations.ListOrganizationSpacesRequest; |
76 | 72 | import org.cloudfoundry.client.v2.organizations.ListOrganizationsRequest; |
|
122 | 118 | import org.cloudfoundry.client.v3.applications.ListApplicationsRequest; |
123 | 119 | import org.cloudfoundry.client.v3.applications.SetApplicationCurrentDropletRequest; |
124 | 120 | import org.cloudfoundry.client.v3.applications.UpdateApplicationFeatureRequest; |
| 121 | +import org.cloudfoundry.client.v3.auditevents.AuditEventResource; |
| 122 | +import org.cloudfoundry.client.v3.auditevents.ListAuditEventsRequest; |
125 | 123 | import org.cloudfoundry.client.v3.builds.BuildState; |
126 | 124 | import org.cloudfoundry.client.v3.builds.CreateBuildRequest; |
127 | 125 | import org.cloudfoundry.client.v3.builds.CreateBuildResponse; |
@@ -356,7 +354,7 @@ public Mono<ApplicationEnvironments> getEnvironments( |
356 | 354 |
|
357 | 355 | @Override |
358 | 356 | public Flux<ApplicationEvent> getEvents(GetApplicationEventsRequest request) { |
359 | | - return getApplicationId(request.getName()) |
| 357 | + return getApplicationIdV3(request.getName()) |
360 | 358 | .flatMapMany( |
361 | 359 | applicationId -> |
362 | 360 | requestEvents(applicationId) |
@@ -843,20 +841,19 @@ public static BiFunction<ProcessState, ProcessState, ProcessState> collectStates |
843 | 841 | }; |
844 | 842 | } |
845 | 843 |
|
846 | | - private static ApplicationEvent convertToApplicationEvent(EventResource resource) { |
847 | | - EventEntity entity = resource.getEntity(); |
| 844 | + private static ApplicationEvent convertToApplicationEvent(AuditEventResource entity) { |
848 | 845 | Date timestamp = null; |
849 | 846 | try { |
850 | | - timestamp = DateUtils.parseFromIso8601(entity.getTimestamp()); |
| 847 | + timestamp = DateUtils.parseFromIso8601(entity.getCreatedAt()); |
851 | 848 | } catch (IllegalArgumentException iae) { |
852 | 849 | // do not set time |
853 | 850 | } |
854 | 851 | return ApplicationEvent.builder() |
855 | | - .actor(entity.getActorName()) |
| 852 | + .actor(entity.getAuditEventActor().getName()) |
856 | 853 | .description( |
857 | 854 | eventDescription( |
858 | 855 | getMetadataRequest(entity), getEntryNames(entity.getType()))) |
859 | | - .id(ResourceUtils.getId(resource)) |
| 856 | + .id(entity.getId()) |
860 | 857 | .event(entity.getType()) |
861 | 858 | .time(timestamp) |
862 | 859 | .build(); |
@@ -1210,17 +1207,14 @@ private Flux<LogMessage> getLogs(String applicationId, Boolean recent) { |
1210 | 1207 | } |
1211 | 1208 |
|
1212 | 1209 | @SuppressWarnings("unchecked") |
1213 | | - private static Map<String, Object> getMetadataRequest(EventEntity entity) { |
1214 | | - Map<String, Optional<Object>> metadata = |
1215 | | - Optional.ofNullable(entity.getMetadatas()).orElse(Collections.emptyMap()); |
| 1210 | + private static Map<String, Object> getMetadataRequest(AuditEventResource entity) { |
| 1211 | + Map<String, Object> metadata = |
| 1212 | + Optional.ofNullable(entity.getData()).orElse(Collections.emptyMap()); |
1216 | 1213 |
|
1217 | 1214 | if (metadata.get("request") != null) { |
1218 | | - return metadata.get("request") |
1219 | | - .map(m -> (Map<String, Object>) m) |
1220 | | - .orElse(Collections.emptyMap()); |
| 1215 | + return (Map<String, Object>) metadata.getOrDefault("request", Collections.emptyMap()); |
1221 | 1216 | } else if (metadata.get("instance") != null) { |
1222 | | - return metadata.entrySet().stream() |
1223 | | - .collect(Collectors.toMap(Map.Entry::getKey, v -> v.getValue().orElse(""))); |
| 1217 | + return Collections.unmodifiableMap(metadata); |
1224 | 1218 | } else { |
1225 | 1219 | return Collections.emptyMap(); |
1226 | 1220 | } |
@@ -1871,16 +1865,16 @@ private Mono<DeleteRouteResponse> requestDeleteRoute(String routeId) { |
1871 | 1865 | .delete(DeleteRouteRequest.builder().async(true).routeId(routeId).build()); |
1872 | 1866 | } |
1873 | 1867 |
|
1874 | | - private Flux<EventResource> requestEvents(String applicationId) { |
1875 | | - return PaginationUtils.requestClientV2Resources( |
| 1868 | + private Flux<AuditEventResource> requestEvents(String applicationId) { |
| 1869 | + return PaginationUtils.requestClientV3Resources( |
1876 | 1870 | page -> |
1877 | 1871 | this.cloudFoundryClient |
1878 | | - .events() |
| 1872 | + .auditEventsV3() |
1879 | 1873 | .list( |
1880 | | - ListEventsRequest.builder() |
1881 | | - .actee(applicationId) |
1882 | | - .orderDirection(OrderDirection.DESCENDING) |
1883 | | - .resultsPerPage(50) |
| 1874 | + ListAuditEventsRequest.builder() |
| 1875 | + .targetId(applicationId) |
| 1876 | + .orderBy("-created_at") |
| 1877 | + .perPage(50) |
1884 | 1878 | .page(page) |
1885 | 1879 | .build())); |
1886 | 1880 | } |
|
0 commit comments