Skip to content

Commit b78e065

Browse files
committed
Add public attr for rawr resources
1 parent 9e72e9d commit b78e065

File tree

3 files changed

+71
-24
lines changed

3 files changed

+71
-24
lines changed

api/src/core/main.tsp

+3
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ namespace models {
159159
@doc("Whether the resource should be private by default. Private resources can only be accessed by the uploader and by instances and actors declared in the `allowlist`.")
160160
private: boolean = false;
161161

162+
@doc("Whether the resource should be publicly retrievable, i.e. without requiring authentication. If this is `true`, the allow- and denylists are ignored.")
163+
public: boolean = false;
164+
162165
@doc("A list of actors and/or instances allowed to access this resource.")
163166
@example(#["[email protected]", "instance.example.com"])
164167
allowlist?: string[];

api/src/core/routes/rawr.tsp

+60-19
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace ResourceAddressingWithRelativeRoots {
3030
*/
3131
@route("/{rid}")
3232
@get
33+
@useAuth(BearerAuth | NoAuth)
3334
@added(Version.`v1.0-beta.1`)
3435
@summary("Get resource by resource ID")
3536
op getResource(@path rid: string):
@@ -39,10 +40,62 @@ namespace ResourceAddressingWithRelativeRoots {
3940
}
4041
| {
4142
@statusCode _: 308;
43+
4244
@header({
4345
name: "Location",
4446
})
4547
location: url;
48+
49+
@body reason: "ROOT_CHANGED";
50+
}
51+
| {
52+
@statusCode _: 403;
53+
@body reason: "ACCESS_FORBIDDEN";
54+
}
55+
| {
56+
@statusCode _: 401;
57+
@body reason: "NEEDS_AUTHENTICATION";
58+
}
59+
| {
60+
@statusCode _: 404;
61+
@body reason: "NOT_FOUND";
62+
};
63+
64+
/**
65+
* Query the server for information about a RawR resource.
66+
* This route accepts a Bearer token, but public resources may also be queried without
67+
* specifying a token.
68+
* @param rid The resource ID of the resource which you'd like to query information of.
69+
*
70+
* @returns
71+
* - `200`: Found, contains resource information
72+
* - `308`: URI root has changed.
73+
* - `401`: Server or resource requires authentication to access this endpoint.
74+
* - `403`: Server or resource not accessible for the actor making this request.
75+
* - `404`: Resource not found.
76+
*/
77+
@route("/{rid}/info/")
78+
@get
79+
@useAuth(BearerAuth | NoAuth)
80+
@added(Version.`v1.0-beta.1`)
81+
@summary("Retrieve information about a RawR resource")
82+
op getResourceInfos(@path rid: string):
83+
| {
84+
@statusCode statusCode: 200;
85+
@body body: {
86+
resourceId: string;
87+
size: uint64;
88+
access: polyproto.core.models.ResourceAccessProperties;
89+
}[];
90+
}
91+
| {
92+
@statusCode _: 308;
93+
94+
@header({
95+
name: "Location",
96+
})
97+
location: url;
98+
4699
@body reason: "ROOT_CHANGED";
47100
}
48101
| {
@@ -83,12 +136,15 @@ namespace ResourceAddressingWithRelativeRoots {
83136
@summary("Upload RawR resource")
84137
op postResource(
85138
@path rid: string,
139+
86140
@header({
87141
name: "Content-Length",
88142
})
89143
contentLength: uint64,
144+
90145
@query
91146
resourceAccessProperties: polyproto.core.models.ResourceAccessProperties,
147+
92148
@body file: File,
93149
):
94150
| {
@@ -119,6 +175,7 @@ namespace ResourceAddressingWithRelativeRoots {
119175
}
120176
| {
121177
@statusCode _: 204;
178+
122179
@header({
123180
name: "Content-Length",
124181
})
@@ -145,33 +202,16 @@ namespace ResourceAddressingWithRelativeRoots {
145202
@summary("Update RawR resource access properties")
146203
op modifyResource(
147204
@path rid: string,
205+
148206
@body
149207
resourceAccessProperties: polyproto.core.models.ResourceAccessProperties,
150208
): {
151209
@header({
152210
name: "Content-Length",
153211
})
154212
contentLength: 0;
155-
@statusCode _: 204;
156-
};
157213

158-
/**
159-
* @param rid The resource ID of the resource which you'd like to query information of.
160-
*/
161-
@route("/{rid}/info/")
162-
@get
163-
@added(Version.`v1.0-beta.1`)
164-
@summary("Retrieve information about one of your RawR resources")
165-
op getResourceInfos(@path rid: string): {
166-
@statusCode statusCode: 200;
167-
@body body: {
168-
resourceId: string;
169-
size: uint64;
170-
access: polyproto.core.models.ResourceAccessProperties;
171-
}[];
172-
} | {
173-
@statusCode statusCode: 404;
174-
@body reason: "NOT_FOUND";
214+
@statusCode _: 204;
175215
};
176216

177217
/**
@@ -195,6 +235,7 @@ namespace ResourceAddressingWithRelativeRoots {
195235
}[];
196236
} | {
197237
@statusCode _: 204;
238+
198239
@header({
199240
name: "Content-Length",
200241
})

docs/Protocol Specifications/core.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -2147,11 +2147,14 @@ The URI for resource addressing with relative roots is formatted as follows:
21472147

21482148
`<server_url>/.p2/core/resource/<resource_id>`
21492149

2150-
Uploaded resources can be made private, and access to them can be controlled via allow- and deny lists,
2151-
specifying access properties for each individual resource. Individual actors and entire instances can
2152-
be part of these allow- and deny lists. Marking a resource as private restricts access to only the
2153-
uploader and the actors and instances that are part of the allow list. APIs and JSON schemas
2154-
associated with access control are part of the [API documentation](https://apidocs.polyproto.org).
2150+
Uploaded resources can be made private or private, and access to them can be controlled via
2151+
allow- and deny lists, specifying access properties for each individual resource. Individual
2152+
actors and entire instances can be part of these allow- and deny lists. Marking a resource as
2153+
private restricts access to only the uploader and the actors and instances that are part of the
2154+
allow list. Marking a resource as public will mean that the allow- and deny lists are ignored, and that
2155+
the resource is accessible to anyone who has the link. Marking a resource as both public and private
2156+
is an illegal state. APIs and JSON schemas associated with access control are part of the
2157+
[API documentation](https://apidocs.polyproto.org).
21552158

21562159
The API routes for resource addressing with relative roots are documented more thoroughly in the
21572160
[API documentation](https://apidocs.polyproto.org).

0 commit comments

Comments
 (0)