|
116 | 116 | import org.cloudfoundry.client.v3.applications.GetApplicationResponse; |
117 | 117 | import org.cloudfoundry.client.v3.applications.GetApplicationSshEnabledRequest; |
118 | 118 | import org.cloudfoundry.client.v3.applications.GetApplicationSshEnabledResponse; |
| 119 | +import org.cloudfoundry.client.v3.applications.ListApplicationProcessesRequest; |
119 | 120 | import org.cloudfoundry.client.v3.applications.ListApplicationsRequest; |
| 121 | +import org.cloudfoundry.client.v3.applications.SetApplicationCurrentDropletRequest; |
120 | 122 | import org.cloudfoundry.client.v3.applications.UpdateApplicationFeatureRequest; |
| 123 | +import org.cloudfoundry.client.v3.builds.BuildState; |
| 124 | +import org.cloudfoundry.client.v3.builds.CreateBuildRequest; |
| 125 | +import org.cloudfoundry.client.v3.builds.CreateBuildResponse; |
| 126 | +import org.cloudfoundry.client.v3.builds.GetBuildRequest; |
| 127 | +import org.cloudfoundry.client.v3.builds.GetBuildResponse; |
| 128 | +import org.cloudfoundry.client.v3.domains.DomainResource; |
| 129 | +import org.cloudfoundry.client.v3.domains.ListDomainsRequest; |
| 130 | +import org.cloudfoundry.client.v3.packages.BitsData; |
| 131 | +import org.cloudfoundry.client.v3.packages.CreatePackageRequest; |
| 132 | +import org.cloudfoundry.client.v3.packages.CreatePackageResponse; |
| 133 | +import org.cloudfoundry.client.v3.packages.DockerData; |
| 134 | +import org.cloudfoundry.client.v3.packages.GetPackageRequest; |
| 135 | +import org.cloudfoundry.client.v3.packages.GetPackageResponse; |
| 136 | +import org.cloudfoundry.client.v3.packages.PackageRelationships; |
| 137 | +import org.cloudfoundry.client.v3.packages.PackageState; |
| 138 | +import org.cloudfoundry.client.v3.packages.PackageType; |
| 139 | +import org.cloudfoundry.client.v3.packages.UploadPackageRequest; |
| 140 | +import org.cloudfoundry.client.v3.processes.GetProcessStatisticsRequest; |
| 141 | +import org.cloudfoundry.client.v3.processes.GetProcessStatisticsResponse; |
| 142 | +import org.cloudfoundry.client.v3.processes.ProcessState; |
| 143 | +import org.cloudfoundry.client.v3.processes.ProcessStatisticsResource; |
| 144 | +import org.cloudfoundry.client.v3.resourcematch.MatchedResource; |
| 145 | +import org.cloudfoundry.client.v3.spaces.ApplyManifestRequest; |
121 | 146 | import org.cloudfoundry.client.v3.tasks.CancelTaskRequest; |
122 | 147 | import org.cloudfoundry.client.v3.tasks.CancelTaskResponse; |
123 | 148 | import org.cloudfoundry.client.v3.tasks.CreateTaskRequest; |
@@ -295,42 +320,68 @@ public Mono<Void> delete(DeleteApplicationRequest request) { |
295 | 320 |
|
296 | 321 | @Override |
297 | 322 | public Mono<Void> disableSsh(DisableApplicationSshRequest request) { |
298 | | - return Mono |
299 | | - .zip(this.cloudFoundryClient, this.spaceId) |
300 | | - .flatMap(function((cloudFoundryClient, spaceId) -> Mono.zip( |
301 | | - Mono.just(cloudFoundryClient), |
302 | | - getApplicationIdV3(cloudFoundryClient, request.getName(), spaceId) |
303 | | - ))) |
304 | | - .flatMap(function((cloudFoundryClient, applicationId) -> Mono.zip( |
305 | | - Mono.just(cloudFoundryClient), |
306 | | - Mono.just(applicationId), |
307 | | - getSshEnabled(cloudFoundryClient, applicationId) |
308 | | - ))) |
309 | | - .filter(predicate((cloudFoundryClient,applicationId,sshEnabled) -> sshEnabled.equals(true))) |
310 | | - .flatMap(function((cloudFoundryClient, applicationId) -> requestUpdateApplicationSsh(cloudFoundryClient, applicationId, false))) |
311 | | - .then() |
312 | | - .transform(OperationsLogging.log("Disable Application SSH")) |
313 | | - .checkpoint(); |
| 323 | + return Mono.zip(this.cloudFoundryClient, this.spaceId) |
| 324 | + .flatMap( |
| 325 | + function( |
| 326 | + (cloudFoundryClient, spaceId) -> |
| 327 | + Mono.zip( |
| 328 | + Mono.just(cloudFoundryClient), |
| 329 | + getApplicationIdV3( |
| 330 | + cloudFoundryClient, |
| 331 | + request.getName(), |
| 332 | + spaceId)))) |
| 333 | + .flatMap( |
| 334 | + function( |
| 335 | + (cloudFoundryClient, applicationId) -> |
| 336 | + Mono.zip( |
| 337 | + Mono.just(cloudFoundryClient), |
| 338 | + Mono.just(applicationId), |
| 339 | + getSshEnabled(cloudFoundryClient, applicationId)))) |
| 340 | + .filter( |
| 341 | + predicate( |
| 342 | + (cloudFoundryClient, applicationId, sshEnabled) -> |
| 343 | + sshEnabled.equals(true))) |
| 344 | + .flatMap( |
| 345 | + function( |
| 346 | + (cloudFoundryClient, applicationId) -> |
| 347 | + requestUpdateApplicationSsh( |
| 348 | + cloudFoundryClient, applicationId, false))) |
| 349 | + .then() |
| 350 | + .transform(OperationsLogging.log("Disable Application SSH")) |
| 351 | + .checkpoint(); |
314 | 352 | } |
315 | 353 |
|
316 | 354 | @Override |
317 | 355 | public Mono<Void> enableSsh(EnableApplicationSshRequest request) { |
318 | | - return Mono |
319 | | - .zip(this.cloudFoundryClient, this.spaceId) |
320 | | - .flatMap(function((cloudFoundryClient, spaceId) -> Mono.zip( |
321 | | - Mono.just(cloudFoundryClient), |
322 | | - getApplicationIdV3(cloudFoundryClient, request.getName(), spaceId) |
323 | | - ))) |
324 | | - .flatMap(function((cloudFoundryClient, applicationId) -> Mono.zip( |
325 | | - Mono.just(cloudFoundryClient), |
326 | | - Mono.just(applicationId), |
327 | | - getSshEnabled(cloudFoundryClient, applicationId) |
328 | | - ))) |
329 | | - .filter(predicate((cloudFoundryClient,applicationId,sshEnabled) -> sshEnabled.equals(false))) |
330 | | - .flatMap(function((cloudFoundryClient, applicationId) -> requestUpdateApplicationSsh(cloudFoundryClient, applicationId, true))) |
331 | | - .then() |
332 | | - .transform(OperationsLogging.log("Enable Application SSH")) |
333 | | - .checkpoint(); |
| 356 | + return Mono.zip(this.cloudFoundryClient, this.spaceId) |
| 357 | + .flatMap( |
| 358 | + function( |
| 359 | + (cloudFoundryClient, spaceId) -> |
| 360 | + Mono.zip( |
| 361 | + Mono.just(cloudFoundryClient), |
| 362 | + getApplicationIdV3( |
| 363 | + cloudFoundryClient, |
| 364 | + request.getName(), |
| 365 | + spaceId)))) |
| 366 | + .flatMap( |
| 367 | + function( |
| 368 | + (cloudFoundryClient, applicationId) -> |
| 369 | + Mono.zip( |
| 370 | + Mono.just(cloudFoundryClient), |
| 371 | + Mono.just(applicationId), |
| 372 | + getSshEnabled(cloudFoundryClient, applicationId)))) |
| 373 | + .filter( |
| 374 | + predicate( |
| 375 | + (cloudFoundryClient, applicationId, sshEnabled) -> |
| 376 | + sshEnabled.equals(false))) |
| 377 | + .flatMap( |
| 378 | + function( |
| 379 | + (cloudFoundryClient, applicationId) -> |
| 380 | + requestUpdateApplicationSsh( |
| 381 | + cloudFoundryClient, applicationId, true))) |
| 382 | + .then() |
| 383 | + .transform(OperationsLogging.log("Enable Application SSH")) |
| 384 | + .checkpoint(); |
334 | 385 | } |
335 | 386 |
|
336 | 387 | @Override |
@@ -387,17 +438,22 @@ public Mono<ApplicationManifest> getApplicationManifest(GetApplicationManifestRe |
387 | 438 | } |
388 | 439 |
|
389 | 440 | @Override |
390 | | - public Mono<ApplicationEnvironments> getEnvironments(GetApplicationEnvironmentsRequest request) { |
391 | | - return Mono |
392 | | - .zip(this.cloudFoundryClient, this.spaceId) |
393 | | - .flatMap(function((cloudFoundryClient, spaceId) -> Mono.zip( |
394 | | - Mono.just(cloudFoundryClient), |
395 | | - getApplicationIdV3(cloudFoundryClient, request.getName(), spaceId) |
396 | | - ))) |
397 | | - .flatMap(function(DefaultApplications::requestApplicationEnvironment)) |
398 | | - .map(DefaultApplications::toApplicationEnvironments) |
399 | | - .transform(OperationsLogging.log("Get Application Environments")) |
400 | | - .checkpoint(); |
| 441 | + public Mono<ApplicationEnvironments> getEnvironments( |
| 442 | + GetApplicationEnvironmentsRequest request) { |
| 443 | + return Mono.zip(this.cloudFoundryClient, this.spaceId) |
| 444 | + .flatMap( |
| 445 | + function( |
| 446 | + (cloudFoundryClient, spaceId) -> |
| 447 | + Mono.zip( |
| 448 | + Mono.just(cloudFoundryClient), |
| 449 | + getApplicationIdV3( |
| 450 | + cloudFoundryClient, |
| 451 | + request.getName(), |
| 452 | + spaceId)))) |
| 453 | + .flatMap(function(DefaultApplications::requestApplicationEnvironment)) |
| 454 | + .map(DefaultApplications::toApplicationEnvironments) |
| 455 | + .transform(OperationsLogging.log("Get Application Environments")) |
| 456 | + .checkpoint(); |
401 | 457 | } |
402 | 458 |
|
403 | 459 | @Override |
@@ -872,21 +928,30 @@ public Mono<Void> setHealthCheck(SetApplicationHealthCheckRequest request) { |
872 | 928 |
|
873 | 929 | @Override |
874 | 930 | public Mono<Boolean> sshEnabled(ApplicationSshEnabledRequest request) { |
875 | | - return Mono |
876 | | - .zip(this.cloudFoundryClient, this.spaceId) |
877 | | - .flatMap(function((cloudFoundryClient, spaceId) -> Mono.zip( |
878 | | - Mono.just(cloudFoundryClient), |
879 | | - getApplicationIdV3(cloudFoundryClient, request.getName(), spaceId)))) |
880 | | - .flatMap(function(DefaultApplications::getSshEnabled)) |
881 | | - .transform(OperationsLogging.log("Is Application SSH Enabled")) |
882 | | - .checkpoint(); |
| 931 | + return Mono.zip(this.cloudFoundryClient, this.spaceId) |
| 932 | + .flatMap( |
| 933 | + function( |
| 934 | + (cloudFoundryClient, spaceId) -> |
| 935 | + Mono.zip( |
| 936 | + Mono.just(cloudFoundryClient), |
| 937 | + getApplicationIdV3( |
| 938 | + cloudFoundryClient, |
| 939 | + request.getName(), |
| 940 | + spaceId)))) |
| 941 | + .flatMap(function(DefaultApplications::getSshEnabled)) |
| 942 | + .transform(OperationsLogging.log("Is Application SSH Enabled")) |
| 943 | + .checkpoint(); |
883 | 944 | } |
884 | 945 |
|
885 | | - private static Mono<Boolean> getSshEnabled(CloudFoundryClient cloudFoundryClient, String applicationId) { |
886 | | - return cloudFoundryClient.applicationsV3() |
887 | | - .getSshEnabled(GetApplicationSshEnabledRequest.builder() |
888 | | - .applicationId(applicationId).build()) |
889 | | - .map(GetApplicationSshEnabledResponse::getEnabled); |
| 946 | + private static Mono<Boolean> getSshEnabled( |
| 947 | + CloudFoundryClient cloudFoundryClient, String applicationId) { |
| 948 | + return cloudFoundryClient |
| 949 | + .applicationsV3() |
| 950 | + .getSshEnabled( |
| 951 | + GetApplicationSshEnabledRequest.builder() |
| 952 | + .applicationId(applicationId) |
| 953 | + .build()) |
| 954 | + .map(GetApplicationSshEnabledResponse::getEnabled); |
890 | 955 | } |
891 | 956 |
|
892 | 957 | @Override |
@@ -2060,11 +2125,14 @@ private static Mono<Void> removeServiceBindings( |
2060 | 2125 | .then(); |
2061 | 2126 | } |
2062 | 2127 |
|
2063 | | - private static Mono<GetApplicationEnvironmentResponse> requestApplicationEnvironment(CloudFoundryClient cloudFoundryClient, String applicationId) { |
2064 | | - return cloudFoundryClient.applicationsV3() |
2065 | | - .getEnvironment(GetApplicationEnvironmentRequest.builder() |
2066 | | - .applicationId(applicationId) |
2067 | | - .build()); |
| 2128 | + private static Mono<GetApplicationEnvironmentResponse> requestApplicationEnvironment( |
| 2129 | + CloudFoundryClient cloudFoundryClient, String applicationId) { |
| 2130 | + return cloudFoundryClient |
| 2131 | + .applicationsV3() |
| 2132 | + .getEnvironment( |
| 2133 | + GetApplicationEnvironmentRequest.builder() |
| 2134 | + .applicationId(applicationId) |
| 2135 | + .build()); |
2068 | 2136 | } |
2069 | 2137 |
|
2070 | 2138 | private static Mono<ApplicationInstancesResponse> requestApplicationInstances( |
@@ -2627,16 +2695,33 @@ private static Mono<AbstractApplicationResource> requestUpdateApplicationHealthC |
2627 | 2695 | builder -> builder.healthCheckType(type.getValue())); |
2628 | 2696 | } |
2629 | 2697 |
|
2630 | | - private static Mono<ApplicationFeature> requestUpdateApplicationSsh(CloudFoundryClient cloudFoundryClient, String applicationId, boolean enabled) { |
2631 | | - return requestUpdateApplicationFeature(cloudFoundryClient, applicationId,builder -> builder.featureName(APP_FEATURE_SSH).enabled(enabled)); |
| 2698 | + private static Mono<AbstractApplicationResource> requestUpdateApplicationName( |
| 2699 | + CloudFoundryClient cloudFoundryClient, String applicationId, String name) { |
| 2700 | + return requestUpdateApplication( |
| 2701 | + cloudFoundryClient, applicationId, builder -> builder.name(name)); |
| 2702 | + } |
| 2703 | + |
| 2704 | + private static Mono<ApplicationFeature> requestUpdateApplicationSsh( |
| 2705 | + CloudFoundryClient cloudFoundryClient, String applicationId, boolean enabled) { |
| 2706 | + return requestUpdateApplicationFeature( |
| 2707 | + cloudFoundryClient, |
| 2708 | + applicationId, |
| 2709 | + builder -> builder.featureName(APP_FEATURE_SSH).enabled(enabled)); |
2632 | 2710 | } |
2633 | 2711 |
|
2634 | | - private static Mono<ApplicationFeature> requestUpdateApplicationFeature(CloudFoundryClient cloudFoundryClient, String applicationId, UnaryOperator<UpdateApplicationFeatureRequest.Builder> modifier) { |
2635 | | - return cloudFoundryClient.applicationsV3() |
2636 | | - .updateFeature(modifier.apply(org.cloudfoundry.client.v3.applications.UpdateApplicationFeatureRequest.builder() |
2637 | | - .applicationId(applicationId)) |
2638 | | - .build()) |
2639 | | - .cast(ApplicationFeature.class); |
| 2712 | + private static Mono<ApplicationFeature> requestUpdateApplicationFeature( |
| 2713 | + CloudFoundryClient cloudFoundryClient, |
| 2714 | + String applicationId, |
| 2715 | + UnaryOperator<UpdateApplicationFeatureRequest.Builder> modifier) { |
| 2716 | + return cloudFoundryClient |
| 2717 | + .applicationsV3() |
| 2718 | + .updateFeature( |
| 2719 | + modifier.apply( |
| 2720 | + org.cloudfoundry.client.v3.applications |
| 2721 | + .UpdateApplicationFeatureRequest.builder() |
| 2722 | + .applicationId(applicationId)) |
| 2723 | + .build()) |
| 2724 | + .cast(ApplicationFeature.class); |
2640 | 2725 | } |
2641 | 2726 |
|
2642 | 2727 | private static Mono<AbstractApplicationResource> requestUpdateApplicationScale( |
@@ -2750,7 +2835,12 @@ private static boolean shouldStartApplication(PushApplicationManifestRequest req |
2750 | 2835 | return !Optional.ofNullable(request.getNoStart()).orElse(false); |
2751 | 2836 | } |
2752 | 2837 |
|
2753 | | - private static Mono<Void> startApplicationAndWait(CloudFoundryClient cloudFoundryClient, String application, String applicationId, Duration stagingTimeout, Duration startupTimeout) { |
| 2838 | + private static Mono<Void> startApplicationAndWait( |
| 2839 | + CloudFoundryClient cloudFoundryClient, |
| 2840 | + String application, |
| 2841 | + String applicationId, |
| 2842 | + Duration stagingTimeout, |
| 2843 | + Duration startupTimeout) { |
2754 | 2844 | return requestUpdateApplicationState(cloudFoundryClient, applicationId, STARTED_STATE) |
2755 | 2845 | .flatMap( |
2756 | 2846 | response -> |
@@ -2820,13 +2910,14 @@ private static ApplicationDetail toApplicationDetail( |
2820 | 2910 | .build(); |
2821 | 2911 | } |
2822 | 2912 |
|
2823 | | - private static ApplicationEnvironments toApplicationEnvironments(GetApplicationEnvironmentResponse response) { |
| 2913 | + private static ApplicationEnvironments toApplicationEnvironments( |
| 2914 | + GetApplicationEnvironmentResponse response) { |
2824 | 2915 | return ApplicationEnvironments.builder() |
2825 | | - .running(response.getRunningEnvironmentVariables()) |
2826 | | - .staging(response.getStagingEnvironmentVariables()) |
2827 | | - .systemProvided(response.getSystemEnvironmentVariables()) |
2828 | | - .userProvided(response.getEnvironmentVariables()) |
2829 | | - .build(); |
| 2916 | + .running(response.getRunningEnvironmentVariables()) |
| 2917 | + .staging(response.getStagingEnvironmentVariables()) |
| 2918 | + .systemProvided(response.getSystemEnvironmentVariables()) |
| 2919 | + .userProvided(response.getEnvironmentVariables()) |
| 2920 | + .build(); |
2830 | 2921 | } |
2831 | 2922 |
|
2832 | 2923 | private static Mono<ApplicationManifest> toApplicationManifest( |
|
0 commit comments