images: update proto
This commit is contained in:
parent
7d10ad48b9
commit
c30dce73dd
|
@ -2,6 +2,7 @@ syntax = "proto3";
|
|||
|
||||
package images.v1;
|
||||
|
||||
import "images/v1/list_by_subreddit.proto";
|
||||
import "images/v1/recently_added.proto";
|
||||
|
||||
service ImageService {
|
||||
|
@ -13,4 +14,5 @@ service ImageService {
|
|||
//
|
||||
// Maximum number of images that can be fetched at a time is 300.
|
||||
rpc RecentlyAddedImages(RecentlyAddedImagesRequest) returns (RecentlyAddedImagesResponse) {}
|
||||
rpc ListBySubreddit(ListBySubredditRequest) returns (ListBySubredditResponse) {}
|
||||
}
|
||||
|
|
70
schemas/proto/images/v1/list.proto
Normal file
70
schemas/proto/images/v1/list.proto
Normal file
|
@ -0,0 +1,70 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package images.v1;
|
||||
|
||||
import "buf/validate/validate.proto";
|
||||
import "images/v1/types.proto";
|
||||
|
||||
message ListImagesRequest {
|
||||
option (buf.validate.message).cel = {
|
||||
id: "ListBySubredditRequest.after_cannot_exist_with_before"
|
||||
message: "after and before cannot be set at the same time"
|
||||
expression: "this.after > 0 && this.before > 0"
|
||||
};
|
||||
|
||||
// subreddits filter the images to be fetched belonging to the given subreddits names.
|
||||
//
|
||||
// If empty, images from all subreddits will be fetched.
|
||||
string subreddit = 1 [(buf.validate.field).string.min_len = 1];
|
||||
// devices filter the images to be fetched belonging to the given devices slugs.
|
||||
//
|
||||
// If empty, images from all devices will be fetched.
|
||||
repeated string devices = 2;
|
||||
|
||||
// limit limits the number of images to be fetched.
|
||||
//
|
||||
// if 0 (or not set), the default limit is 25.
|
||||
//
|
||||
// if set, the maximum limit is clamped to 100.
|
||||
int64 limit = 3 [(buf.validate.field).int64.gte = 0];
|
||||
// after lists the image after the given timestamp.
|
||||
//
|
||||
// using after will return images that are created after the given timestamp.
|
||||
//
|
||||
// cannot be set (value > 0) with before (value > 0).
|
||||
int64 after = 4;
|
||||
// before lists the image before the given timestamp.
|
||||
//
|
||||
// using before will return images that are created before the given timestamp.
|
||||
//
|
||||
// cannot be set (value > 0) with after (value > 0).
|
||||
int64 before = 5;
|
||||
|
||||
OrderBy order_by = 6;
|
||||
|
||||
Sort sort = 7;
|
||||
|
||||
// search searches images by text. ignored if empty.
|
||||
//
|
||||
// It will look up by following rank and prioritizes matches
|
||||
// based on following fields:
|
||||
//
|
||||
// - Post Title
|
||||
// - Post ID
|
||||
// - Author's name
|
||||
// - Author's ID
|
||||
// - Image filename (url path suffix to get this image from web browser)
|
||||
// - Image original url
|
||||
// - Post url
|
||||
// - Author's url
|
||||
string search = 8;
|
||||
|
||||
// nsfw filters the images to be fetched based on the nsfw flag.
|
||||
NSFW nsfw = 9;
|
||||
}
|
||||
|
||||
message ListImagesResponse {
|
||||
repeated GroupedByDeviceImages devices = 1;
|
||||
optional int64 after = 2;
|
||||
optional int64 before = 3;
|
||||
}
|
|
@ -6,7 +6,34 @@ import "buf/validate/validate.proto";
|
|||
import "images/v1/types.proto";
|
||||
|
||||
message ListBySubredditRequest {
|
||||
option (buf.validate.message).cel = {
|
||||
id: "ListBySubredditRequest.after_cannot_exist_with_before"
|
||||
message: "after and before cannot be set at the same time"
|
||||
expression: "this.after > 0 && this.before > 0"
|
||||
};
|
||||
string subreddit = 1 [(buf.validate.field).string.min_len = 1];
|
||||
// devices filter the images to be fetched belonging to the given devices.
|
||||
//
|
||||
// If empty, images from all devices will be fetched.
|
||||
repeated string devices = 2;
|
||||
// limit limits the number of images to be fetched.
|
||||
//
|
||||
// if 0 (or not set), the default limit is 25.
|
||||
//
|
||||
// if set, the maximum limit is clamped to 100.
|
||||
int64 limit = 3 [(buf.validate.field).int64.gte = 0];
|
||||
// after lists the image after the given timestamp.
|
||||
//
|
||||
// using after will return images that are created after the given timestamp.
|
||||
//
|
||||
// cannot be set (value > 0) with before (value > 0).
|
||||
int64 after = 4;
|
||||
// before lists the image before the given timestamp.
|
||||
//
|
||||
// using before will return images that are created before the given timestamp.
|
||||
//
|
||||
// cannot be set (value > 0) with after (value > 0).
|
||||
int64 before = 5;
|
||||
}
|
||||
|
||||
message ListBySubredditResponse {
|
||||
|
|
|
@ -13,9 +13,10 @@ message Image {
|
|||
string post_author_url = 8;
|
||||
string image_relative_path = 9;
|
||||
string image_original_url = 10;
|
||||
uint32 image_height = 11;
|
||||
uint32 image_width = 12;
|
||||
int64 image_height = 11;
|
||||
int64 image_width = 12;
|
||||
int64 image_size = 13;
|
||||
bool nsfw = 14;
|
||||
}
|
||||
|
||||
message GroupedByDeviceImages {
|
||||
|
@ -28,3 +29,38 @@ message GroupedBySubredditDevices {
|
|||
string subreddit = 1;
|
||||
repeated GroupedByDeviceImages devices = 2;
|
||||
}
|
||||
|
||||
enum OrderBy {
|
||||
ORDER_BY_UNSPECIFIED = 0;
|
||||
ORDER_BY_ID = 1;
|
||||
ORDER_BY_SUBREDDIT = 2;
|
||||
ORDER_BY_DEVICE = 3;
|
||||
ORDER_BY_POST_TITLE = 4;
|
||||
ORDER_BY_POST_URL = 5;
|
||||
ORDER_BY_POST_CREATED = 6;
|
||||
ORDER_BY_POST_AUTHOR = 7;
|
||||
ORDER_BY_POST_AUTHOR_URL = 8;
|
||||
ORDER_BY_IMAGE_RELATIVE_PATH = 9;
|
||||
ORDER_BY_IMAGE_ORIGINAL_URL = 10;
|
||||
ORDER_BY_IMAGE_HEIGHT = 11;
|
||||
ORDER_BY_IMAGE_WIDTH = 12;
|
||||
ORDER_BY_IMAGE_SIZE = 13;
|
||||
}
|
||||
|
||||
enum NSFW {
|
||||
NSFW_UNSPECIFIED = 0;
|
||||
NSFW_TRUE = 1;
|
||||
NSFW_FALSE = 2;
|
||||
}
|
||||
|
||||
enum Sort {
|
||||
SORT_UNSPECIFIED = 0;
|
||||
SORT_ASCENDING = 1;
|
||||
SORT_DESCENDING = 2;
|
||||
}
|
||||
|
||||
enum Blacklist {
|
||||
BLACKLIST_UNSPECIFIED = 0;
|
||||
BLACKLIST_TRUE = 1;
|
||||
BLACKLIST_FALSE = 2;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue