Skip to content

Commit ae0d8f8

Browse files
DeviceInfracopybara-github
authored andcommitted
Internal change
PiperOrigin-RevId: 850272462
1 parent b265dd5 commit ae0d8f8

File tree

7 files changed

+92
-0
lines changed

7 files changed

+92
-0
lines changed

src/devtools/mobileharness/fe/v6/angular/app/core/services/host/fake_host_service.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,24 @@ export class FakeHostService extends HostService {
6464
);
6565
}
6666
}
67+
68+
override decommissionMissingDevices(
69+
hostName: string,
70+
deviceControlIds: string[],
71+
): Observable<void> {
72+
const scenario = MOCK_HOST_SCENARIOS.find((s) => s.hostName === hostName);
73+
if (scenario && scenario.deviceSummaries) {
74+
scenario.deviceSummaries = scenario.deviceSummaries.filter(
75+
(d) => !deviceControlIds.includes(d.id),
76+
);
77+
return of(undefined);
78+
} else {
79+
return throwError(
80+
() =>
81+
new Error(
82+
`Host with '${hostName}' not found or has no devices in mock data.`,
83+
),
84+
);
85+
}
86+
}
6787
}

src/devtools/mobileharness/fe/v6/angular/app/core/services/host/host_service.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,15 @@ export abstract class HostService {
3131
hostName: string,
3232
flags: string,
3333
): Observable<void>;
34+
35+
/**
36+
* Decommissions missing devices on a specific host.
37+
* @param hostName The name of the host.
38+
* @param deviceControlIds The list of device control IDs to decommission.
39+
* @return An Observable emitting when the operation is complete.
40+
*/
41+
abstract decommissionMissingDevices(
42+
hostName: string,
43+
deviceControlIds: string[],
44+
): Observable<void>;
3445
}

src/devtools/mobileharness/fe/v6/angular/app/core/services/host/http_host_service.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,16 @@ export class HttpHostService extends HostService {
3636
flags,
3737
});
3838
}
39+
40+
override decommissionMissingDevices(
41+
hostName: string,
42+
deviceControlIds: string[],
43+
): Observable<void> {
44+
return this.http.post<void>(
45+
`${this.apiUrl}/${hostName}/decommissionMissingDevices`,
46+
{
47+
deviceControlIds,
48+
},
49+
);
50+
}
3951
}

src/devtools/mobileharness/fe/v6/service/proto/host/host_service.proto

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ service HostService {
5050
body: "*"
5151
};
5252
}
53+
54+
// Decommissions missing devices on a specific host.
55+
rpc DecommissionMissingDevices(DecommissionMissingDevicesRequest)
56+
returns (DecommissionMissingDevicesResponse) {
57+
option (google.api.http) = {
58+
post: "/v6/hosts/{host_name}/decommission_missing_devices"
59+
body: "*"
60+
};
61+
}
5362
}
5463

5564
// Request message for GetHostOverview.
@@ -80,3 +89,14 @@ message UpdatePassThroughFlagsRequest {
8089

8190
// Response message for UpdatePassThroughFlags.
8291
message UpdatePassThroughFlagsResponse {}
92+
93+
// Request message for DecommissionMissingDevices.
94+
message DecommissionMissingDevicesRequest {
95+
// The unique name of the host.
96+
string host_name = 1;
97+
// The list of device control IDs to decommission.
98+
repeated string device_control_ids = 2;
99+
}
100+
101+
// Response message for DecommissionMissingDevices.
102+
message DecommissionMissingDevicesResponse {}

src/java/com/google/devtools/mobileharness/fe/v6/service/host/HostServiceGrpcImpl.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import com.google.common.util.concurrent.ListeningExecutorService;
2020
import com.google.devtools.common.metrics.stability.rpc.grpc.GrpcServiceUtil;
21+
import com.google.devtools.mobileharness.fe.v6.service.proto.host.DecommissionMissingDevicesRequest;
22+
import com.google.devtools.mobileharness.fe.v6.service.proto.host.DecommissionMissingDevicesResponse;
2123
import com.google.devtools.mobileharness.fe.v6.service.proto.host.GetHostDeviceSummariesRequest;
2224
import com.google.devtools.mobileharness.fe.v6.service.proto.host.GetHostDeviceSummariesResponse;
2325
import com.google.devtools.mobileharness.fe.v6.service.proto.host.GetHostOverviewRequest;
@@ -77,4 +79,17 @@ public void updatePassThroughFlags(
7779
HostServiceGrpc.getServiceDescriptor(),
7880
HostServiceGrpc.getUpdatePassThroughFlagsMethod());
7981
}
82+
83+
@Override
84+
public void decommissionMissingDevices(
85+
DecommissionMissingDevicesRequest request,
86+
StreamObserver<DecommissionMissingDevicesResponse> responseObserver) {
87+
GrpcServiceUtil.invokeAsync(
88+
request,
89+
responseObserver,
90+
logic::decommissionMissingDevices,
91+
executor,
92+
HostServiceGrpc.getServiceDescriptor(),
93+
HostServiceGrpc.getDecommissionMissingDevicesMethod());
94+
}
8095
}

src/java/com/google/devtools/mobileharness/fe/v6/service/host/HostServiceLogic.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.google.devtools.mobileharness.fe.v6.service.host;
1818

1919
import com.google.common.util.concurrent.ListenableFuture;
20+
import com.google.devtools.mobileharness.fe.v6.service.proto.host.DecommissionMissingDevicesRequest;
21+
import com.google.devtools.mobileharness.fe.v6.service.proto.host.DecommissionMissingDevicesResponse;
2022
import com.google.devtools.mobileharness.fe.v6.service.proto.host.GetHostDeviceSummariesRequest;
2123
import com.google.devtools.mobileharness.fe.v6.service.proto.host.GetHostDeviceSummariesResponse;
2224
import com.google.devtools.mobileharness.fe.v6.service.proto.host.GetHostOverviewRequest;
@@ -33,4 +35,7 @@ ListenableFuture<GetHostDeviceSummariesResponse> getHostDeviceSummaries(
3335

3436
ListenableFuture<UpdatePassThroughFlagsResponse> updatePassThroughFlags(
3537
UpdatePassThroughFlagsRequest request);
38+
39+
ListenableFuture<DecommissionMissingDevicesResponse> decommissionMissingDevices(
40+
DecommissionMissingDevicesRequest request);
3641
}

src/java/com/google/devtools/mobileharness/fe/v6/service/host/HostServiceLogicImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import com.google.common.util.concurrent.ListenableFuture;
2222
import com.google.devtools.mobileharness.fe.v6.service.host.handlers.GetHostOverviewHandler;
23+
import com.google.devtools.mobileharness.fe.v6.service.proto.host.DecommissionMissingDevicesRequest;
24+
import com.google.devtools.mobileharness.fe.v6.service.proto.host.DecommissionMissingDevicesResponse;
2325
import com.google.devtools.mobileharness.fe.v6.service.proto.host.GetHostDeviceSummariesRequest;
2426
import com.google.devtools.mobileharness.fe.v6.service.proto.host.GetHostDeviceSummariesResponse;
2527
import com.google.devtools.mobileharness.fe.v6.service.proto.host.GetHostOverviewRequest;
@@ -58,4 +60,11 @@ public ListenableFuture<UpdatePassThroughFlagsResponse> updatePassThroughFlags(
5860
// TODO: Implement this method.
5961
return immediateFuture(UpdatePassThroughFlagsResponse.getDefaultInstance());
6062
}
63+
64+
@Override
65+
public ListenableFuture<DecommissionMissingDevicesResponse> decommissionMissingDevices(
66+
DecommissionMissingDevicesRequest request) {
67+
// TODO: Implement this method.
68+
return immediateFuture(DecommissionMissingDevicesResponse.getDefaultInstance());
69+
}
6170
}

0 commit comments

Comments
 (0)