• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2022 The ChromiumOS Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5syntax = "proto3";
6
7package chromiumos.test.api;
8
9option go_package = "go.chromium.org/chromiumos/config/go/test/api";
10
11import "google/protobuf/duration.proto";
12import "google/protobuf/timestamp.proto";
13import "chromiumos/test/api/device_leasing.proto";
14
15service VMLeaserService {
16  // Creates a lease record and returns a VM.
17  rpc LeaseVM(LeaseVMRequest) returns (LeaseVMResponse) {};
18  // Releases a lease for a VM.
19  rpc ReleaseVM(ReleaseVMRequest) returns (ReleaseVMResponse) {};
20  // Extends a lease for a VM.
21  rpc ExtendLease(ExtendLeaseRequest) returns (ExtendLeaseResponse) {};
22  // Lists the current VM leases.
23  rpc ListLeases(ListLeasesRequest) returns (ListLeasesResponse) {};
24  // Imports a VM custom image.
25  rpc ImportImage(ImportImageRequest) returns (ImportImageResponse) {};
26}
27
28message LeaseVMRequest {
29  // Generated on the client side, shared across retries but pseudo-unique
30  // across different logical requests. Requests with the same key will be
31  // treated as duplicate of original request, return the same response.
32  string idempotency_key = 1;
33
34  // This is the final end user (can be human or robot). Useful for both
35  // debugging and analytics. For example for a tests triggered for a CL, this
36  // field could indicate the CL author as they are the end user.
37  //
38  // For direct invocations like CLI, this is enforced at first entry point but
39  // trusted from there.
40  //
41  // Not to be confused with LUCI auth which is done by the caller assuming the
42  // appropriate identity from a permissions perspective — like LUCI project.
43  string on_behalf_of = 2;
44
45  // This is the quota the end user is requesting to use. One user can have
46  // access to multiple quotas. For example, release, CQ, performance testing,
47  // etc.
48  string quota_id = 3;
49
50  // Optional with a good default.
51  // Important to configure a good max (e.g. 10 min). This will put a ceiling on
52  // time wasted if the client dies.
53  google.protobuf.Duration lease_duration = 4;
54
55  // The populated requirements will specify the requirements for a VM host.
56  VMRequirements host_reqs = 5;
57
58  // The client that is calling VM Leaser for a VM host.
59  VMTestingClient testing_client = 6;
60
61  // Optional labels added to the VM. Useful for filtering.
62  // Requirements: https://cloud.google.com/compute/docs/labeling-resources
63  map<string, string> labels = 7;
64}
65
66message VM {
67  string id = 1;
68  VMAddress address = 2;
69  VMType type = 3;
70  string gce_region = 4;
71  google.protobuf.Timestamp expiration_time = 5;
72}
73
74message VMAddress {
75  // IP address of the device.
76  string host = 1;
77  int32 port = 2;
78}
79
80// VMTestingClient specifies who the caller is (e.g. ChromeOS, Android, etc.)
81enum VMTestingClient {
82  VM_TESTING_CLIENT_UNSPECIFIED = 0;
83  VM_TESTING_CLIENT_CHROMEOS = 1;
84  VM_TESTING_CLIENT_CROSFLEET = 2;
85}
86
87message LeaseVMResponse {
88  // Relevant information for the lease.
89  string lease_id = 1;
90  VM vm = 2;
91
92  // Client is responsible for extending the lease as needed.
93  google.protobuf.Timestamp expiration_time = 3;
94
95  // Eventually we will include authentication token to access device for the
96  // duration of the lease. Shared and long lived secrets are not good security.
97  // Today there is no such enforcement so this is not a regression.
98}
99
100message ReleaseVMRequest {
101  string lease_id = 1;
102  string gce_project = 2;
103  string gce_region = 3;
104}
105
106message ReleaseVMResponse {
107  string lease_id = 1;
108}
109
110// ListLeasesRequest is the request to list VM Leases.
111//
112// TODO (b/294414530): Need support for googleapis protos enabled.
113// It follows AIP-132 (https://google.aip.dev/132) but do not have use the
114// google.api.* annotations as they are not currently supported in this repo.
115message ListLeasesRequest {
116  // The name of the GCP project for which to list VM leases.
117  // Format: projects/{project}
118  string parent = 1;
119
120  // The maximum number of VM leases to return. The service may return fewer
121  // than this value. If unspecified, at most 50 leases will be returned.
122  int32 page_size = 2;
123
124  // A page token, received from a previous `ListLeases` call. Provide this to
125  // retrieve the subsequent page.
126  //
127  // When paginating, all other parameters provided to `ListLeases` must match
128  // the call that provided the page token.
129  string page_token = 3;
130
131  // The string filter follows AIP-160 (https://google.aip.dev/160) for the
132  // filtering syntax. For the initial release, this filter only supports
133  // filtering by zone, tags, and metadata fields related to VMs.
134  //
135  // Examples:
136  // 1. `metadata.idempotency_key = "test-idempotency-uuid-key"` will find the
137  // VMs that have the key matched.
138  // 2. `metadata.expiration_time > 1690490598` will find the VMs that expire
139  // later than the specified unix time.
140  string filter = 4;
141}
142
143message ListLeasesResponse {
144  repeated VM vms = 1;
145
146  // A token, which can be sent as `page_token` to retrieve the next page. If
147  // this field is omitted, there are no subsequent pages.
148  string next_page_token = 2;
149}
150
151message ImportImageRequest {
152  // Build path of the image, e.g. betty-arc-r-release/R119-15626.0.0
153  string image_path = 1;
154}
155
156message ImportImageResponse {
157  // Name of the imported custom image.
158  string image_name = 1;
159}
160