|
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; |
|
121 | 117 | import org.cloudfoundry.client.v3.applications.ListApplicationsRequest; |
122 | 118 | import org.cloudfoundry.client.v3.applications.SetApplicationCurrentDropletRequest; |
123 | 119 | import org.cloudfoundry.client.v3.applications.UpdateApplicationFeatureRequest; |
| 120 | +import org.cloudfoundry.client.v3.auditevents.AuditEventResource; |
| 121 | +import org.cloudfoundry.client.v3.auditevents.ListAuditEventsRequest; |
124 | 122 | import org.cloudfoundry.client.v3.builds.BuildState; |
125 | 123 | import org.cloudfoundry.client.v3.builds.CreateBuildRequest; |
126 | 124 | import org.cloudfoundry.client.v3.builds.CreateBuildResponse; |
@@ -355,7 +353,7 @@ public Mono<ApplicationEnvironments> getEnvironments( |
355 | 353 |
|
356 | 354 | @Override |
357 | 355 | public Flux<ApplicationEvent> getEvents(GetApplicationEventsRequest request) { |
358 | | - return getApplicationId(request.getName()) |
| 356 | + return getApplicationIdV3(request.getName()) |
359 | 357 | .flatMapMany( |
360 | 358 | applicationId -> |
361 | 359 | requestEvents(applicationId) |
@@ -857,20 +855,19 @@ public static BiFunction<ProcessState, ProcessState, ProcessState> collectStates |
857 | 855 | }; |
858 | 856 | } |
859 | 857 |
|
860 | | - private static ApplicationEvent convertToApplicationEvent(EventResource resource) { |
861 | | - EventEntity entity = resource.getEntity(); |
| 858 | + private static ApplicationEvent convertToApplicationEvent(AuditEventResource entity) { |
862 | 859 | Date timestamp = null; |
863 | 860 | try { |
864 | | - timestamp = DateUtils.parseFromIso8601(entity.getTimestamp()); |
| 861 | + timestamp = DateUtils.parseFromIso8601(entity.getCreatedAt()); |
865 | 862 | } catch (IllegalArgumentException iae) { |
866 | 863 | // do not set time |
867 | 864 | } |
868 | 865 | return ApplicationEvent.builder() |
869 | | - .actor(entity.getActorName()) |
| 866 | + .actor(entity.getAuditEventActor().getName()) |
870 | 867 | .description( |
871 | 868 | eventDescription( |
872 | 869 | getMetadataRequest(entity), getEntryNames(entity.getType()))) |
873 | | - .id(ResourceUtils.getId(resource)) |
| 870 | + .id(entity.getId()) |
874 | 871 | .event(entity.getType()) |
875 | 872 | .time(timestamp) |
876 | 873 | .build(); |
@@ -1224,17 +1221,14 @@ private Flux<LogMessage> getLogs(String applicationId, Boolean recent) { |
1224 | 1221 | } |
1225 | 1222 |
|
1226 | 1223 | @SuppressWarnings("unchecked") |
1227 | | - private static Map<String, Object> getMetadataRequest(EventEntity entity) { |
1228 | | - Map<String, Optional<Object>> metadata = |
1229 | | - Optional.ofNullable(entity.getMetadatas()).orElse(Collections.emptyMap()); |
| 1224 | + private static Map<String, Object> getMetadataRequest(AuditEventResource entity) { |
| 1225 | + Map<String, Object> metadata = |
| 1226 | + Optional.ofNullable(entity.getData()).orElse(Collections.emptyMap()); |
1230 | 1227 |
|
1231 | 1228 | if (metadata.get("request") != null) { |
1232 | | - return metadata.get("request") |
1233 | | - .map(m -> (Map<String, Object>) m) |
1234 | | - .orElse(Collections.emptyMap()); |
| 1229 | + return (Map<String, Object>) metadata.getOrDefault("request", Collections.emptyMap()); |
1235 | 1230 | } else if (metadata.get("instance") != null) { |
1236 | | - return metadata.entrySet().stream() |
1237 | | - .collect(Collectors.toMap(Map.Entry::getKey, v -> v.getValue().orElse(""))); |
| 1231 | + return Collections.unmodifiableMap(metadata); |
1238 | 1232 | } else { |
1239 | 1233 | return Collections.emptyMap(); |
1240 | 1234 | } |
@@ -1887,16 +1881,16 @@ private Mono<DeleteRouteResponse> requestDeleteRoute(String routeId) { |
1887 | 1881 | .delete(DeleteRouteRequest.builder().async(true).routeId(routeId).build()); |
1888 | 1882 | } |
1889 | 1883 |
|
1890 | | - private Flux<EventResource> requestEvents(String applicationId) { |
1891 | | - return PaginationUtils.requestClientV2Resources( |
| 1884 | + private Flux<AuditEventResource> requestEvents(String applicationId) { |
| 1885 | + return PaginationUtils.requestClientV3Resources( |
1892 | 1886 | page -> |
1893 | 1887 | this.cloudFoundryClient |
1894 | | - .events() |
| 1888 | + .auditEventsV3() |
1895 | 1889 | .list( |
1896 | | - ListEventsRequest.builder() |
1897 | | - .actee(applicationId) |
1898 | | - .orderDirection(OrderDirection.DESCENDING) |
1899 | | - .resultsPerPage(50) |
| 1890 | + ListAuditEventsRequest.builder() |
| 1891 | + .targetId(applicationId) |
| 1892 | + .orderBy("-created_at") |
| 1893 | + .perPage(50) |
1900 | 1894 | .page(page) |
1901 | 1895 | .build())); |
1902 | 1896 | } |
|
0 commit comments