xref: /aosp_15_r20/external/pigweed/pw_file/file.proto (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker// Copyright 2021 The Pigweed Authors
2*61c4878aSAndroid Build Coastguard Worker//
3*61c4878aSAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4*61c4878aSAndroid Build Coastguard Worker// use this file except in compliance with the License. You may obtain a copy of
5*61c4878aSAndroid Build Coastguard Worker// the License at
6*61c4878aSAndroid Build Coastguard Worker//
7*61c4878aSAndroid Build Coastguard Worker//     https://www.apache.org/licenses/LICENSE-2.0
8*61c4878aSAndroid Build Coastguard Worker//
9*61c4878aSAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
10*61c4878aSAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11*61c4878aSAndroid Build Coastguard Worker// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12*61c4878aSAndroid Build Coastguard Worker// License for the specific language governing permissions and limitations under
13*61c4878aSAndroid Build Coastguard Worker// the License.
14*61c4878aSAndroid Build Coastguard Worker
15*61c4878aSAndroid Build Coastguard Workersyntax = "proto3";
16*61c4878aSAndroid Build Coastguard Worker
17*61c4878aSAndroid Build Coastguard Workerpackage pw.file;
18*61c4878aSAndroid Build Coastguard Worker
19*61c4878aSAndroid Build Coastguard Workerimport "pw_protobuf_protos/common.proto";
20*61c4878aSAndroid Build Coastguard Worker
21*61c4878aSAndroid Build Coastguard Workeroption java_outer_classname = "File";
22*61c4878aSAndroid Build Coastguard Worker
23*61c4878aSAndroid Build Coastguard Worker// The FileSystem RPC service is used to enumerate and manage files present on a
24*61c4878aSAndroid Build Coastguard Worker// server.
25*61c4878aSAndroid Build Coastguard Workerservice FileSystem {
26*61c4878aSAndroid Build Coastguard Worker  // Returns a series of file paths with associated metadata for all immediate
27*61c4878aSAndroid Build Coastguard Worker  // children of the provided path.
28*61c4878aSAndroid Build Coastguard Worker  rpc List(ListRequest) returns (stream ListResponse) {}
29*61c4878aSAndroid Build Coastguard Worker
30*61c4878aSAndroid Build Coastguard Worker  // Deletes the file at the requested path.
31*61c4878aSAndroid Build Coastguard Worker  rpc Delete(DeleteRequest) returns (pw.protobuf.Empty) {}
32*61c4878aSAndroid Build Coastguard Worker}
33*61c4878aSAndroid Build Coastguard Worker
34*61c4878aSAndroid Build Coastguard Worker// A ListRequest has the following properties:
35*61c4878aSAndroid Build Coastguard Worker//
36*61c4878aSAndroid Build Coastguard Worker//  - A request with an empty `path` string is valid and will list the contents
37*61c4878aSAndroid Build Coastguard Worker//    at the "root" directory.
38*61c4878aSAndroid Build Coastguard Worker//  - Only exact path matches will be resolved (i.e. no prefix matching).
39*61c4878aSAndroid Build Coastguard Worker//  - Paths should be treated as case-sensitive.
40*61c4878aSAndroid Build Coastguard Worker//  - The provided path must be absolute. If no matching path is found, a
41*61c4878aSAndroid Build Coastguard Worker//    NOT_FOUND error is raised.
42*61c4878aSAndroid Build Coastguard Workermessage ListRequest {
43*61c4878aSAndroid Build Coastguard Worker  string path = 1;
44*61c4878aSAndroid Build Coastguard Worker}
45*61c4878aSAndroid Build Coastguard Worker
46*61c4878aSAndroid Build Coastguard Worker// A DeleteRequest has the following properties:
47*61c4878aSAndroid Build Coastguard Worker//
48*61c4878aSAndroid Build Coastguard Worker//  - Only exact path matches will be resolved (i.e. no prefix matching).
49*61c4878aSAndroid Build Coastguard Worker//  - Paths should be treated as case-sensitive.
50*61c4878aSAndroid Build Coastguard Worker//  - Deletion of directories is implementation-defined, and may be
51*61c4878aSAndroid Build Coastguard Worker//    disallowed and return an UNIMPLEMENTED error.
52*61c4878aSAndroid Build Coastguard Worker//  - The provided path must be absolute. If no matching path is found, a
53*61c4878aSAndroid Build Coastguard Worker//    NOT_FOUND error is raised.
54*61c4878aSAndroid Build Coastguard Workermessage DeleteRequest {
55*61c4878aSAndroid Build Coastguard Worker  string path = 1;
56*61c4878aSAndroid Build Coastguard Worker}
57*61c4878aSAndroid Build Coastguard Worker
58*61c4878aSAndroid Build Coastguard Workermessage Path {
59*61c4878aSAndroid Build Coastguard Worker  // This enum is a bitmask of permissions:
60*61c4878aSAndroid Build Coastguard Worker  // Bit 0: readable.
61*61c4878aSAndroid Build Coastguard Worker  // Bit 1: writable.
62*61c4878aSAndroid Build Coastguard Worker  enum Permissions {
63*61c4878aSAndroid Build Coastguard Worker    NONE = 0;
64*61c4878aSAndroid Build Coastguard Worker    READ = 1;
65*61c4878aSAndroid Build Coastguard Worker    WRITE = 2;
66*61c4878aSAndroid Build Coastguard Worker    READ_AND_WRITE = 3;
67*61c4878aSAndroid Build Coastguard Worker  }
68*61c4878aSAndroid Build Coastguard Worker
69*61c4878aSAndroid Build Coastguard Worker  // A path to a file/directory. This path is relative to the requested path
70*61c4878aSAndroid Build Coastguard Worker  // to reduce transmission of redundant information.
71*61c4878aSAndroid Build Coastguard Worker  string path = 1;
72*61c4878aSAndroid Build Coastguard Worker
73*61c4878aSAndroid Build Coastguard Worker  // Permitted operations on this path.
74*61c4878aSAndroid Build Coastguard Worker  optional Permissions permissions = 2;
75*61c4878aSAndroid Build Coastguard Worker
76*61c4878aSAndroid Build Coastguard Worker  // The size of the file at this path.
77*61c4878aSAndroid Build Coastguard Worker  optional uint32 size_bytes = 3;
78*61c4878aSAndroid Build Coastguard Worker
79*61c4878aSAndroid Build Coastguard Worker  // A globally-unique transfer ID for this file path (e.g. for use with
80*61c4878aSAndroid Build Coastguard Worker  // pw_transfer's RPC service). It is implementation defined whether a file's
81*61c4878aSAndroid Build Coastguard Worker  // file ID is stable or ephemeral.
82*61c4878aSAndroid Build Coastguard Worker  optional uint32 file_id = 4;
83*61c4878aSAndroid Build Coastguard Worker}
84*61c4878aSAndroid Build Coastguard Worker
85*61c4878aSAndroid Build Coastguard Workermessage ListResponse {
86*61c4878aSAndroid Build Coastguard Worker  // Each returned Path's path name is always relative to the requested path to
87*61c4878aSAndroid Build Coastguard Worker  // reduce transmission of redundant information.
88*61c4878aSAndroid Build Coastguard Worker  repeated Path paths = 1;
89*61c4878aSAndroid Build Coastguard Worker}
90