@@ -1090,7 +1090,7 @@ private Mono<ApplicationResource> getApplicationV3(String application) {
10901090 List <String >,
10911091 SummaryApplicationResponse ,
10921092 String ,
1093- List < InstanceDetail > ,
1093+ GetApplicationProcessStatisticsResponse ,
10941094 ApplicationResource >>
10951095 getAuxiliaryContent (ApplicationResource applicationResource ) {
10961096 String applicationId = applicationResource .getId ();
@@ -1102,14 +1102,11 @@ private Mono<ApplicationResource> getApplicationV3(String application) {
11021102 stackName = ((BuildpackData ) data ).getStack ();
11031103 }
11041104
1105- Mono <List <InstanceDetail >> appInstanceDetails =
1106- requestApplicationStatisticsV3 (applicationId ).map (this ::toInstanceDetailList );
1107-
11081105 return Mono .zip (
11091106 getApplicationBuildpacks (applicationId ),
11101107 requestApplicationSummary (applicationId ),
11111108 Mono .just (stackName ),
1112- appInstanceDetails ,
1109+ requestApplicationStatisticsV3 ( applicationId ) ,
11131110 Mono .just (applicationResource ));
11141111 }
11151112
@@ -2280,27 +2277,35 @@ private static ApplicationDetail toApplicationDetail(
22802277 List <String > buildpacks ,
22812278 SummaryApplicationResponse summaryApplicationResponse ,
22822279 String stackName ,
2283- List < InstanceDetail > instanceDetails ,
2280+ GetApplicationProcessStatisticsResponse processStats ,
22842281 ApplicationResource application ) {
2285- Long runningInstances =
2286- instanceDetails .stream ()
2282+ List <InstanceDetail > instanceDetails = toInstanceDetailList (processStats );
2283+ long runningInstances =
2284+ processStats .getResources ().stream ()
22872285 .filter (
22882286 details ->
2289- details .getState ().equals (ProcessState .RUNNING .getValue ())
2290- || details .getState ()
2291- .equals (ProcessState .STARTING .getValue ()))
2287+ details .getState () == ProcessState .RUNNING
2288+ || details .getState () == ProcessState .STARTING )
22922289 .count ();
22932290
2291+ // TODO: we should use the `/v3/apps/:guid/manifest` endpoint to get the requested quotas
2292+ long diskQuota = -1 ;
2293+ long memoryLimit = -1 ;
2294+ if (!instanceDetails .isEmpty ()) {
2295+ diskQuota = instanceDetails .get (0 ).getDiskQuota ();
2296+ memoryLimit = instanceDetails .get (0 ).getMemoryQuota ();
2297+ }
2298+
22942299 return ApplicationDetail .builder ()
22952300 .buildpacks (buildpacks )
22962301 .id (application .getId ())
22972302 .name (application .getName ())
22982303 .requestedState (application .getState ().getValue ())
22992304 .instanceDetails (instanceDetails )
2300- .instances (instanceDetails .size ())
2301- .runningInstances (runningInstances . intValue () )
2302- .diskQuota (summaryApplicationResponse . getDiskQuota () )
2303- .memoryLimit (summaryApplicationResponse . getMemory () )
2305+ .instances (processStats . getResources () .size ())
2306+ .runningInstances (( int ) runningInstances )
2307+ .diskQuota (( int ) diskQuota )
2308+ .memoryLimit (( int ) memoryLimit )
23042309 .lastUploaded (toDate (summaryApplicationResponse .getPackageUpdatedAt ()))
23052310 .urls (toUrls (summaryApplicationResponse .getRoutes ()))
23062311 .stack (stackName )
@@ -2434,7 +2439,7 @@ private static HealthCheckType fromHealthCheck(ApplicationHealthCheck type) {
24342439 }
24352440 }
24362441
2437- private List <InstanceDetail > toInstanceDetailList (
2442+ private static List <InstanceDetail > toInstanceDetailList (
24382443 GetApplicationProcessStatisticsResponse statisticsResponse ) {
24392444 return statisticsResponse .getResources ().stream ()
24402445 .map (
0 commit comments