mirror of
https://github.com/usememos/memos.git
synced 2026-11-19 10:29:11 +01:00
refactor(api)!: drop the v1 version marker (#6447)
This commit is contained in:
@@ -72,7 +72,8 @@ All must pass before you propose the tag:
|
||||
|
||||
Write notes for the range from the last stable tag to the candidate, following [release-notes.md](references/release-notes.md).
|
||||
Read the commits, the merged PRs (`gh pr view`), and the diff for migrations, proto changes, configuration flags, and removed
|
||||
behavior. Save the draft in a temporary directory outside the repo.
|
||||
behavior. Carry the `## Unreleased` entries of `proto/api/CHANGELOG.md` into the notes as breaking API changes. Save the
|
||||
draft in a temporary directory outside the repo.
|
||||
|
||||
## 5. Propose, Then Tag
|
||||
|
||||
@@ -125,4 +126,5 @@ that links resolve to the right PRs and commits.
|
||||
|
||||
Give the release URL, tag, SHA, image tags and digest, verification results, any reruns and why, and anything not done. Out of
|
||||
scope for this skill: announcements, website or docs updates, and the demo deploy (`demo-deploy.yml`, manual dispatch). List
|
||||
them as follow-ups for the user rather than doing them.
|
||||
them as follow-ups for the user rather than doing them. If `proto/api/CHANGELOG.md` has `## Unreleased` entries, list
|
||||
renaming that heading to the tag as a follow-up too.
|
||||
|
||||
@@ -38,3 +38,23 @@ jobs:
|
||||
echo "❌ Proto files are not formatted. Run 'buf format -w' to fix."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# A breaking change to the public API is allowed only when the same change
|
||||
# records it in proto/api/CHANGELOG.md.
|
||||
- name: Check breaking API changes
|
||||
working-directory: proto
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
|
||||
run: |
|
||||
if [[ -z "$BASE_SHA" || "$BASE_SHA" =~ ^0+$ ]] || ! git cat-file -e "$BASE_SHA^{commit}" 2>/dev/null; then
|
||||
echo "No comparable base commit; skipping."
|
||||
exit 0
|
||||
fi
|
||||
if buf breaking --against "../.git#ref=$BASE_SHA,subdir=proto" --path api; then
|
||||
exit 0
|
||||
fi
|
||||
if git diff --quiet "$BASE_SHA" HEAD -- api/CHANGELOG.md; then
|
||||
echo "❌ Breaking API change. Record it in proto/api/CHANGELOG.md, or make the change compatible."
|
||||
exit 1
|
||||
fi
|
||||
echo "::warning::Breaking API change recorded in proto/api/CHANGELOG.md."
|
||||
|
||||
@@ -18,7 +18,7 @@ Memos is a self-hosted note-taking app.
|
||||
- Keep diffs scoped. Do not do repo-wide cleanup, dependency churn, or generated-file rewrites unless the task requires it.
|
||||
- Do not hand-edit generated proto outputs. Change `.proto` files, then run `buf generate`.
|
||||
- Add migrations for all database drivers when schema changes, and update each driver's `LATEST.sql`.
|
||||
- Add public API endpoints to `server/api/v1/acl_config.go`.
|
||||
- Add public API endpoints to `server/api/acl_config.go`.
|
||||
- Ask before adding heavy dependencies, changing auth/token behavior, or altering Docker/release workflows.
|
||||
|
||||
## Documentation
|
||||
@@ -67,7 +67,7 @@ Every root folder is named for what it holds. Read the folder's `doc.go` or `REA
|
||||
| --- | --- | --- |
|
||||
| `cmd/memos/` | Cobra/Viper CLI setup and server startup | anything |
|
||||
| `server/` | The HTTP process: Echo bootstrap, graceful shutdown, every transport | core, store, provider, markdown, filter, internal |
|
||||
| `server/api/v1/` | Connect/gRPC-Gateway services, ACL config, SSE hub. Thin handlers; rules go to `core/` | |
|
||||
| `server/api/` | Connect/gRPC-Gateway services, ACL config, SSE hub. Thin handlers; rules go to `core/` | |
|
||||
| `server/fileserver/` | Native HTTP file serving, thumbnails, range requests | |
|
||||
| `server/frontend/` | Static SPA serving; `dist/` is the built SPA baked in by `go:embed` | |
|
||||
| `server/mcp/` | Model Context Protocol server | |
|
||||
@@ -78,7 +78,7 @@ Every root folder is named for what it holds. Read the folder's `doc.go` or `REA
|
||||
| `filter/` | CEL filter compiler: parse to IR, render to SQL per driver, filterable field schema | internal |
|
||||
| `provider/` | Backends configured by instance settings: `ai`, `idp`, `storage` | proto/gen, internal |
|
||||
| `internal/` | Private plumbing with no memos vocabulary (`identifier`, `email`, `webhook`, `ratelimit`, …) | third party only |
|
||||
| `proto/api/v1/`, `proto/store/` | Public API and internal storage proto sources; `proto/gen/` is generated | |
|
||||
| `proto/api/`, `proto/store/` | Public API and internal storage proto sources; `proto/gen/` is generated | |
|
||||
| `web/src/` | React SPA: `connect.ts` clients, `auth-state.ts`, `hooks/`, `contexts/`, `components/`, `themes/` | |
|
||||
|
||||
Layering rules, enforced by `depguard` in `.golangci.yaml`:
|
||||
@@ -87,11 +87,11 @@ Layering rules, enforced by `depguard` in `.golangci.yaml`:
|
||||
- `internal/` packages import nothing from this module (except `internal/testutil`, which may import `proto/gen`).
|
||||
- A package goes in `internal/` only if it could be published as a standalone module unchanged. If it knows what a Memo, Space, or instance setting is, it is a root package.
|
||||
- Never create `util`, `common`, `base`, `helpers`, `misc`, or `pkg` packages. Name a package for the one thing it does, or put the code next to its only caller.
|
||||
- New business rules extracted from `server/api/v1` go to `core/<resource>/`, one package per resource.
|
||||
- New business rules extracted from `server/api` go to `core/<resource>/`, one package per resource.
|
||||
|
||||
File convention inside `server/api/v1/`: `<resource>_service.go` holds the RPC handlers, `<resource>_service_converters.go` the
|
||||
File convention inside `server/api/`: `<resource>_service.go` holds the RPC handlers, `<resource>_service_converters.go` the
|
||||
store↔proto conversion, and `<resource>_service_<topic>.go` further splits. Extend the matching file; do not add `*_helpers2.go`.
|
||||
Black-box service tests live in `server/api/v1/test/`, unit tests next to the code.
|
||||
Black-box service tests live in `server/api/test/`, unit tests next to the code.
|
||||
|
||||
## Change Routing
|
||||
|
||||
@@ -103,8 +103,8 @@ Black-box service tests live in `server/api/v1/test/`, unit tests next to the co
|
||||
| Internal package logic | Relevant `internal/` package tests | `go test -v -race ./internal/...` |
|
||||
| Frontend behavior | Components/hooks/contexts under `web/src/` | `cd web && pnpm lint && pnpm test` |
|
||||
| Frontend production output | Vite config or release-sensitive UI | `cd web && pnpm build` or `pnpm release` |
|
||||
| Proto API | `.proto` source plus generated outputs | `cd proto && buf generate && buf lint` |
|
||||
| Public unauthenticated route | `server/api/v1/acl_config.go` | Targeted server test or manual route check |
|
||||
| Proto API | `.proto` source, generated outputs, `proto/api/CHANGELOG.md` for breaks | `cd proto && buf generate && buf lint` |
|
||||
| Public unauthenticated route | `server/api/acl_config.go` | Targeted server test or manual route check |
|
||||
|
||||
## Go Conventions
|
||||
|
||||
@@ -127,7 +127,8 @@ Black-box service tests live in `server/api/v1/test/`, unit tests next to the co
|
||||
|
||||
- Schema changes require SQLite, MySQL, and PostgreSQL migrations plus `LATEST.sql` updates.
|
||||
- Fresh-install SQL and incremental migrations must stay equivalent.
|
||||
- Proto field changes must preserve compatibility unless the task explicitly allows a breaking API change.
|
||||
- Proto field changes must preserve compatibility unless the task explicitly allows a breaking API change. Record every
|
||||
allowed break in `proto/api/CHANGELOG.md`; CI fails a `buf breaking` failure without an edit there.
|
||||
- Regenerate after proto edits and include both Go/OpenAPI and TypeScript generated outputs.
|
||||
|
||||
## Verification Policy
|
||||
|
||||
+1
-1
@@ -13,5 +13,5 @@ apply the same way.
|
||||
|
||||
Layering: `core` may import `store`, `provider`, `markdown`, `filter`,
|
||||
`proto/gen`, and `internal`. It must not import `server` or `cmd`. New
|
||||
resource-specific rules extracted from `server/api/v1` belong here, one package
|
||||
resource-specific rules extracted from `server/api` belong here, one package
|
||||
per resource.
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
# API Changelog
|
||||
|
||||
Breaking and deprecated changes to the public API in `proto/api/`, newest release first. Additive changes are not listed.
|
||||
|
||||
The Proto Linter workflow runs `buf breaking` against the base commit and fails when a schema break lands without an edit to
|
||||
this file. It cannot see REST route changes in `google.api.http` annotations or behavior changes with an unchanged schema;
|
||||
record those by hand.
|
||||
|
||||
Add entries under a `## Unreleased` heading. After the release ships, rename it to the release tag.
|
||||
|
||||
```markdown
|
||||
## Unreleased
|
||||
|
||||
### Breaking
|
||||
|
||||
- `MemoService.ListShortcuts`: removed. Use `UserService.ListMemoViews`.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- `Memo.unassigned`: use an unset `Memo.space`. Removed in a later release.
|
||||
```
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Breaking
|
||||
|
||||
- The API no longer carries a `v1` version marker. Every client must update its paths:
|
||||
- REST routes move from `/api/v1/...` to `/api/...` (for example `GET /api/memos`). Server-sent events move from
|
||||
`/api/v1/sse` to `/api/sse`.
|
||||
- The proto package `memos.api.v1` is now `memos.api`, so Connect and gRPC procedures move from
|
||||
`/memos.api.v1.<Service>/<Method>` to `/memos.api.<Service>/<Method>`.
|
||||
- Resource types move from `memos.api.v1/<Type>` to `memos.api/<Type>`.
|
||||
- The `domain` of `google.rpc.ErrorInfo` details is now `memos.api`.
|
||||
- For this release only, requests to `/api/v1/...` and `/memos.api.v1.*` return `410 Gone` with an `UNIMPLEMENTED`
|
||||
error that points here. The next release removes these routes.
|
||||
- Field numbers in every message are renumbered from 1 in declaration order, and all `reserved` ranges are removed.
|
||||
JSON field names are unchanged; clients that use the binary protobuf encoding must regenerate from the new schema.
|
||||
- Names now follow AIP conventions:
|
||||
- `MemoService`: `ListMemoAttachments`, `ListMemoRelations`, `ListMemoComments`, `CreateMemoComment`,
|
||||
`ListMemoReactions`, and `UpsertMemoReaction` take `parent` instead of `name` (REST path variable
|
||||
`{parent=memos/*}`). `ListMemoCommentsResponse.memos` is now `comments`. The nested `MemoRelation.Memo` type is
|
||||
now `MemoRelation.MemoRef`. The `MemoShare` resource singular/plural is now `memoShare`/`memoShares`.
|
||||
- `UserService.ListAllUserStats` is now `ListUserStats`. It requires a `parent`: `users/-` for all users (REST
|
||||
`GET /api/users/-/stats` instead of `GET /api/users:stats`) or `users/{user}` for one user. The response field
|
||||
`stats` is now `user_stats`.
|
||||
- `BatchGetUsersRequest.usernames` is now `names` and takes resource names (`users/{user}`), not bare usernames.
|
||||
- `PersonalAccessToken.created_at`, `expires_at`, and `last_used_at` are now `create_time`, `expire_time`, and
|
||||
`last_use_time`.
|
||||
- `LinkedIdentity.idp_name` and `extern_uid` are now `identity_provider` and `external_uid`;
|
||||
`CreateLinkedIdentityRequest.idp_name` is now `identity_provider`.
|
||||
- The `MemoView` and `UserNotification` resource singulars are now `memoView` and `userNotification`.
|
||||
- `UserStats.tag_count` is now `tag_counts`.
|
||||
- `MemoImportPlan`, `MemoImportReport`, and `MemoImportIssue` are now `ImportMemosPlan`, `ImportMemosReport`, and
|
||||
`ImportMemosIssue`. `ImportMemosPlan.memos` and `attachments` are now `memo_count` and `attachment_count`;
|
||||
`ImportMemosIssue.memo` is now `memo_uid`.
|
||||
- `UserNotification.SpaceInvitationPayload.State` is now `InvitationState`.
|
||||
- `UpdateUserSettingRequest.setting` and `ListUserSettingsResponse.settings` are now `user_setting` and
|
||||
`user_settings`; `UpdateInstanceSettingRequest.setting` and `BatchGetInstanceSettingsResponse.settings` are now
|
||||
`instance_setting` and `instance_settings`.
|
||||
- `SignInResponse.access_token_expires_at` and `RefreshTokenResponse.expires_at` are both now
|
||||
`access_token_expire_time`.
|
||||
- `SignInRequest.SSOCredentials` is now `SsoCredentials`, and its `idp_name` is now `identity_provider`.
|
||||
@@ -0,0 +1,32 @@
|
||||
# Memos API Design
|
||||
|
||||
This API design should follow the guidelines and best practices outlined in the [Google API Improvement Proposals (AIPs)](https://google.aip.dev/).
|
||||
|
||||
The package is `memos.api`. It carries no version marker; breaking changes are recorded in [CHANGELOG.md](CHANGELOG.md).
|
||||
|
||||
## File Layout
|
||||
|
||||
1. The service, then shared top-level types used by more than one group.
|
||||
2. One block per resource group, in service order: the resource message, then the group's request/response messages in
|
||||
RPC order, then helper messages used only by that group.
|
||||
|
||||
Within a group, order RPCs `List`, `Get`, `BatchGet`, `Create`, `Update`, `Delete`, `BatchDelete`, then custom methods.
|
||||
|
||||
## Messages
|
||||
|
||||
- Resources: `name` first, timestamps (`create_time`, `update_time`, others) last.
|
||||
- Requests: `parent` or `name`, the payload, `update_mask`, then `page_size`, `page_token`, `filter`, `order_by`, and
|
||||
other options.
|
||||
- Responses: items, then `next_page_token`.
|
||||
- Fields first, then nested enums, then nested messages.
|
||||
- Number fields 1..N in declaration order. A new field takes the next number; never reuse or renumber a released field
|
||||
outside a recorded breaking change.
|
||||
- `google.api.resource` lists `type`, `pattern`, `singular`, `plural`; omit `name_field: "name"`.
|
||||
|
||||
## Comments
|
||||
|
||||
- Every service, RPC, message, enum and field has a comment. RPC comments start with the RPC name.
|
||||
- Fields with `google.api.field_behavior` start with the matching prefix: `Identifier.`, `Required.`, `Optional.`,
|
||||
`Output only.`, or `Input only.`. Fields without the annotation get no prefix.
|
||||
- Resource-name fields end with a `Format: memos/{memo}` line.
|
||||
- Describe what the server does, not what it might do.
|
||||
@@ -0,0 +1,52 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/client.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
|
||||
option go_package = "gen/api";
|
||||
|
||||
// AIService runs AI tasks through the AI providers configured on the instance.
|
||||
service AIService {
|
||||
// Transcribe transcribes an audio file with the instance's configured
|
||||
// transcription provider. The caller must be signed in, and requests are rate limited per user.
|
||||
rpc Transcribe(TranscribeRequest) returns (TranscribeResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/ai:transcribe"
|
||||
body: "*"
|
||||
};
|
||||
option (google.api.method_signature) = "audio";
|
||||
}
|
||||
}
|
||||
|
||||
// Request message for AIService.Transcribe.
|
||||
message TranscribeRequest {
|
||||
// Required. The audio to transcribe.
|
||||
TranscriptionAudio audio = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Response message for AIService.Transcribe.
|
||||
message TranscribeResponse {
|
||||
// The transcribed text.
|
||||
string text = 1;
|
||||
}
|
||||
|
||||
// TranscriptionAudio is the audio input for a transcription.
|
||||
message TranscriptionAudio {
|
||||
// The audio source. Only inline content is supported.
|
||||
oneof source {
|
||||
// Input only. Inline audio bytes, at most 25 MiB.
|
||||
bytes content = 1 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
|
||||
// URI of the audio content. Reserved for future use; the service rejects requests that set it.
|
||||
string uri = 2;
|
||||
}
|
||||
|
||||
// Optional. The uploaded filename, at most 255 characters.
|
||||
string filename = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The MIME type of the audio. If empty, the service detects it from the content.
|
||||
string content_type = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
@@ -0,0 +1,377 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/client.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
import "google/api/resource.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "gen/api";
|
||||
|
||||
// AttachmentService manages files attached to memos.
|
||||
service AttachmentService {
|
||||
// ListAttachments lists attachments linked to memos the caller can read, plus the caller's unlinked uploads.
|
||||
rpc ListAttachments(ListAttachmentsRequest) returns (ListAttachmentsResponse) {
|
||||
option (google.api.http) = {get: "/api/attachments"};
|
||||
}
|
||||
|
||||
// GetAttachment gets an attachment by name. An unlinked attachment is visible only to its uploader and admins;
|
||||
// a linked attachment follows the read access of its memo.
|
||||
rpc GetAttachment(GetAttachmentRequest) returns (Attachment) {
|
||||
option (google.api.http) = {get: "/api/{name=attachments/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// CreateAttachment creates an attachment from inline content.
|
||||
rpc CreateAttachment(CreateAttachmentRequest) returns (Attachment) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/attachments"
|
||||
body: "attachment"
|
||||
};
|
||||
option (google.api.method_signature) = "attachment";
|
||||
}
|
||||
|
||||
// UpdateAttachment updates an attachment. Only `filename` can be updated. The caller must be the uploader or an
|
||||
// admin.
|
||||
rpc UpdateAttachment(UpdateAttachmentRequest) returns (Attachment) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/{attachment.name=attachments/*}"
|
||||
body: "attachment"
|
||||
};
|
||||
option (google.api.method_signature) = "attachment,update_mask";
|
||||
}
|
||||
|
||||
// DeleteAttachment deletes an attachment uploaded by the caller.
|
||||
rpc DeleteAttachment(DeleteAttachmentRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/{name=attachments/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// BatchDeleteAttachments deletes up to 100 attachments in one atomic request. The caller must be the uploader of
|
||||
// each attachment or an admin.
|
||||
rpc BatchDeleteAttachments(BatchDeleteAttachmentsRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/attachments:batchDelete"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries the spec and returns an upload_id;
|
||||
// later calls carry that upload_id. Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// inactivity, and do not survive a server restart.
|
||||
rpc UploadAttachment(UploadAttachmentRequest) returns (UploadAttachmentResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/attachments:upload"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Attachment is a file uploaded by a user, optionally linked to a memo.
|
||||
message Attachment {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api/Attachment"
|
||||
pattern: "attachments/{attachment}"
|
||||
singular: "attachment"
|
||||
plural: "attachments"
|
||||
};
|
||||
|
||||
// Identifier. The resource name of the attachment.
|
||||
// Format: attachments/{attachment}
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// Output only. The user who uploaded the attachment, which may differ from the creator of the linked memo.
|
||||
// Format: users/{user}
|
||||
string creator = 2 [
|
||||
(google.api.field_behavior) = OUTPUT_ONLY,
|
||||
(google.api.resource_reference) = {type: "memos.api/User"}
|
||||
];
|
||||
|
||||
// Required. The filename of the attachment.
|
||||
string filename = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The MIME type of the attachment. If empty on create, the service detects it from the filename and
|
||||
// content.
|
||||
string type = 4 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Input only. The content of the attachment.
|
||||
bytes content = 5 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
|
||||
// Optional. The external link of the attachment. Set only for externally stored attachments; ignored on create.
|
||||
string external_link = 6 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Motion photo metadata. Clients may only supply Apple Live Photo metadata; the service detects Android
|
||||
// motion photos in JPEG content.
|
||||
MotionMedia motion_media = 7 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Normalized media metadata supplied by the client at creation time. Immutable after creation.
|
||||
MediaMetadata media_metadata = 8 [
|
||||
(google.api.field_behavior) = OPTIONAL,
|
||||
(google.api.field_behavior) = IMMUTABLE
|
||||
];
|
||||
|
||||
// Optional. The memo the attachment is linked to. On create, the caller must be able to manage the memo.
|
||||
// Format: memos/{memo}
|
||||
optional string memo = 9 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Output only. The size of the stored content in bytes.
|
||||
int64 size = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Output only. The creation time.
|
||||
google.protobuf.Timestamp create_time = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
}
|
||||
|
||||
// Request message for AttachmentService.ListAttachments.
|
||||
message ListAttachmentsRequest {
|
||||
// Optional. The maximum number of attachments to return. The service may return fewer.
|
||||
// If unspecified, at most 50 attachments are returned. Values above 1000 are coerced to 1000.
|
||||
int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token from a previous call. Provide it to retrieve the next page.
|
||||
string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A CEL filter over the results.
|
||||
// Example: `mime_type == "image/png"` or `filename.contains("test")`.
|
||||
// Supported operators: ==, !=, <, <=, >, >=, : (contains), in.
|
||||
// Supported fields: creator, filename, mime_type, create_time, memo_id, space.
|
||||
// `creator` is the linked memo's creator, or the uploader for an unlinked attachment. It supports equality with a
|
||||
// User resource name.
|
||||
// `space` is the linked memo's Space resource name, or null when the attachment is unlinked or its memo has no
|
||||
// space. It supports only a non-negated `==` comparison with a Space resource name or null.
|
||||
string filter = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The order to sort results by, such as "create_time desc" or "filename asc". The service does not apply
|
||||
// it yet.
|
||||
string order_by = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Response message for AttachmentService.ListAttachments.
|
||||
message ListAttachmentsResponse {
|
||||
// The attachments.
|
||||
repeated Attachment attachments = 1;
|
||||
|
||||
// A token to retrieve the next page. Empty when there are no more pages.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
// Request message for AttachmentService.GetAttachment.
|
||||
message GetAttachmentRequest {
|
||||
// Required. The name of the attachment to get.
|
||||
// Format: attachments/{attachment}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Attachment"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for AttachmentService.CreateAttachment.
|
||||
message CreateAttachmentRequest {
|
||||
// Required. The attachment to create.
|
||||
Attachment attachment = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The ID to use for the attachment. If empty, a unique ID is generated.
|
||||
// Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$
|
||||
string attachment_id = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Request message for AttachmentService.UpdateAttachment.
|
||||
message UpdateAttachmentRequest {
|
||||
// Required. The attachment to update. Its `name` identifies the attachment.
|
||||
Attachment attachment = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The fields to update. Only `filename` is supported.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Request message for AttachmentService.DeleteAttachment.
|
||||
message DeleteAttachmentRequest {
|
||||
// Required. The name of the attachment to delete.
|
||||
// Format: attachments/{attachment}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Attachment"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for AttachmentService.BatchDeleteAttachments.
|
||||
message BatchDeleteAttachmentsRequest {
|
||||
// Required. The names of the attachments to delete, at most 100. Duplicate names are ignored.
|
||||
// Format: attachments/{attachment}
|
||||
repeated string names = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Request message for AttachmentService.UploadAttachment.
|
||||
message UploadAttachmentRequest {
|
||||
// Starts a new upload or continues an existing one. Exactly one must be set.
|
||||
oneof upload {
|
||||
// Starts a new upload. The same call may also carry data and finish_write.
|
||||
UploadAttachmentSpec spec = 1;
|
||||
|
||||
// Continues the upload identified by a previous response.
|
||||
string upload_id = 2;
|
||||
}
|
||||
|
||||
// Required. Zero-based byte offset at which data is written. Must equal the committed size, except when retrying
|
||||
// the most recently accepted chunk with identical bytes and offset, which is accepted without writing again.
|
||||
int64 write_offset = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. File bytes, at most max_chunk_size long. With no data and finish_write false, the call reports
|
||||
// progress without writing, and write_offset is ignored.
|
||||
bytes data = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Finalize the upload after writing data. The committed size must then equal total_size. Any later call
|
||||
// for the same upload_id returns the created attachment.
|
||||
bool finish_write = 5 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Response message for AttachmentService.UploadAttachment.
|
||||
message UploadAttachmentResponse {
|
||||
// Opaque ID for subsequent calls. This is not a resource name.
|
||||
string upload_id = 1;
|
||||
|
||||
// Number of file bytes committed so far.
|
||||
int64 committed_size = 2;
|
||||
|
||||
// Maximum number of data bytes accepted in one call.
|
||||
int32 max_chunk_size = 3;
|
||||
|
||||
// The created attachment. Set once the upload has been finalized.
|
||||
Attachment attachment = 4;
|
||||
}
|
||||
|
||||
// UploadAttachmentSpec describes the attachment that a new upload creates.
|
||||
message UploadAttachmentSpec {
|
||||
// Required. Metadata for the attachment to create. content must be empty; file bytes are sent in data.
|
||||
Attachment attachment = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The ID to use for the attachment. If empty, a unique ID is generated.
|
||||
// Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$
|
||||
string attachment_id = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Total size of the file in bytes before media processing. Zero represents an empty file.
|
||||
int64 total_size = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// MotionMedia links the parts of a motion photo.
|
||||
message MotionMedia {
|
||||
// The motion photo format.
|
||||
MotionMediaFamily family = 1;
|
||||
|
||||
// The part this attachment plays in the motion photo.
|
||||
MotionMediaRole role = 2;
|
||||
|
||||
// Groups the attachments that belong to one motion photo. Required for client-supplied Apple Live Photo metadata;
|
||||
// for an Android motion photo it is the attachment's own ID.
|
||||
string group_id = 3;
|
||||
|
||||
// Presentation timestamp of the still frame within the video, in microseconds.
|
||||
int64 presentation_timestamp_us = 4;
|
||||
|
||||
// Whether the file embeds the motion video, as in an Android motion photo container.
|
||||
bool has_embedded_video = 5;
|
||||
}
|
||||
|
||||
// MotionMediaFamily is the format of a motion photo.
|
||||
enum MotionMediaFamily {
|
||||
MOTION_MEDIA_FAMILY_UNSPECIFIED = 0;
|
||||
// An Apple Live Photo: a still image and a video stored as separate attachments.
|
||||
APPLE_LIVE_PHOTO = 1;
|
||||
// An Android motion photo: a JPEG with an embedded video.
|
||||
ANDROID_MOTION_PHOTO = 2;
|
||||
}
|
||||
|
||||
// MotionMediaRole is the part an attachment plays in a motion photo.
|
||||
enum MotionMediaRole {
|
||||
MOTION_MEDIA_ROLE_UNSPECIFIED = 0;
|
||||
// The still image of an Apple Live Photo.
|
||||
STILL = 1;
|
||||
// The video of an Apple Live Photo.
|
||||
VIDEO = 2;
|
||||
// A single file holding both the still image and the video.
|
||||
CONTAINER = 3;
|
||||
}
|
||||
|
||||
// MediaMetadata contains normalized metadata explicitly supplied by a client.
|
||||
// The service validates and stores this data but does not extract it from the media file.
|
||||
message MediaMetadata {
|
||||
// Display-oriented width in pixels. Must be provided with height.
|
||||
optional int32 width = 1;
|
||||
|
||||
// Display-oriented height in pixels. Must be provided with width.
|
||||
optional int32 height = 2;
|
||||
|
||||
// Type-specific metadata. Must match the attachment's MIME type.
|
||||
oneof details {
|
||||
// Photo metadata, for image attachments.
|
||||
PhotoMetadata photo = 3;
|
||||
|
||||
// Video metadata, for video attachments.
|
||||
VideoMetadata video = 4;
|
||||
}
|
||||
}
|
||||
|
||||
// PhotoMetadata is metadata recorded by the source of a photo.
|
||||
message PhotoMetadata {
|
||||
// Capture time as recorded by the source media.
|
||||
MediaCaptureTime capture_time = 1;
|
||||
|
||||
// Geographic location recorded by the source media.
|
||||
MediaLocation location = 2;
|
||||
|
||||
// EXIF orientation value from 1 through 8 as recorded by the source file.
|
||||
// This value is informational and must not be reapplied to the stored attachment;
|
||||
// width and height already describe its display-oriented dimensions.
|
||||
optional int32 source_exif_orientation = 3;
|
||||
|
||||
// The camera manufacturer.
|
||||
string camera_make = 4;
|
||||
|
||||
// The camera model.
|
||||
string camera_model = 5;
|
||||
|
||||
// The lens model.
|
||||
string lens_model = 6;
|
||||
|
||||
// The aperture f-number.
|
||||
optional double f_number = 7;
|
||||
|
||||
// The exposure time in seconds.
|
||||
optional double exposure_time_seconds = 8;
|
||||
|
||||
// The ISO sensitivity.
|
||||
optional int32 iso = 9;
|
||||
|
||||
// The focal length in millimeters.
|
||||
optional double focal_length_mm = 10;
|
||||
}
|
||||
|
||||
// MediaCaptureTime is the local time at which media was captured.
|
||||
message MediaCaptureTime {
|
||||
// Local date and time without a time zone, formatted as YYYY-MM-DDTHH:mm:ss[.fraction].
|
||||
string local_date_time = 1;
|
||||
|
||||
// UTC offset formatted as Z or +/-HH:MM.
|
||||
optional string utc_offset = 2;
|
||||
}
|
||||
|
||||
// MediaLocation is the geographic location at which media was captured.
|
||||
message MediaLocation {
|
||||
// WGS84 latitude in decimal degrees. Must be provided with longitude.
|
||||
optional double latitude = 1;
|
||||
|
||||
// WGS84 longitude in decimal degrees. Must be provided with latitude.
|
||||
optional double longitude = 2;
|
||||
|
||||
// Signed altitude in meters relative to sea level.
|
||||
optional double altitude_meters = 3;
|
||||
}
|
||||
|
||||
// VideoMetadata is metadata recorded by the source of a video.
|
||||
message VideoMetadata {
|
||||
// The duration of the video in seconds.
|
||||
optional double duration_seconds = 1;
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api;
|
||||
|
||||
import "api/user_service.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
import "google/api/resource.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "gen/api";
|
||||
|
||||
// AuthService manages sign-in sessions: it issues, refreshes, and revokes the tokens that authenticate API calls.
|
||||
service AuthService {
|
||||
// SignIn authenticates a user with password or SSO credentials.
|
||||
// On success, returns a short-lived access token and sets a refresh token in an HttpOnly cookie.
|
||||
// Public. Attempts are rate limited. Archived users cannot sign in.
|
||||
rpc SignIn(SignInRequest) returns (SignInResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/auth/signin"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
// RefreshToken exchanges the refresh token for a new access token.
|
||||
// The refresh token is read from the HttpOnly cookie and rotated: the old token is revoked and a new one with a
|
||||
// fresh 30-day expiry is set in the cookie.
|
||||
// Public, so it can be called after the access token has expired.
|
||||
rpc RefreshToken(RefreshTokenRequest) returns (RefreshTokenResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/auth/refresh"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
// GetCurrentUser returns the authenticated user, similar to OIDC's /userinfo endpoint.
|
||||
// When the caller is not signed in or the account is no longer active, clears the refresh token cookie and returns
|
||||
// UNAUTHENTICATED.
|
||||
rpc GetCurrentUser(GetCurrentUserRequest) returns (GetCurrentUserResponse) {
|
||||
option (google.api.http) = {get: "/api/auth/me"};
|
||||
}
|
||||
|
||||
// SignOut ends the current session.
|
||||
// Revokes the refresh token from the cookie and clears the cookie.
|
||||
rpc SignOut(SignOutRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {post: "/api/auth/signout"};
|
||||
}
|
||||
}
|
||||
|
||||
// Request message for AuthService.SignIn.
|
||||
message SignInRequest {
|
||||
// The credentials to authenticate with. Provide exactly one.
|
||||
oneof credentials {
|
||||
// Username and password credentials.
|
||||
PasswordCredentials password_credentials = 1;
|
||||
|
||||
// SSO credentials from an OAuth2 authorization code flow.
|
||||
SsoCredentials sso_credentials = 2;
|
||||
}
|
||||
|
||||
// PasswordCredentials are a username and password.
|
||||
// Regular users cannot use them when the instance disallows password sign-in.
|
||||
message PasswordCredentials {
|
||||
// Required. The username to sign in with.
|
||||
string username = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The password to sign in with.
|
||||
string password = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// SsoCredentials are the result of an OAuth2 authorization code flow with an identity provider.
|
||||
// A first sign-in creates a local user unless the instance disallows user registration.
|
||||
message SsoCredentials {
|
||||
// Required. The resource name of the identity provider.
|
||||
// Format: identity-providers/{idp}
|
||||
string identity_provider = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/IdentityProvider"}
|
||||
];
|
||||
|
||||
// Required. The authorization code returned by the identity provider.
|
||||
string code = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The redirect URI used in the authorization request.
|
||||
string redirect_uri = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The PKCE code verifier (RFC 7636). Set it when the authorization request used a code challenge.
|
||||
string code_verifier = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
}
|
||||
|
||||
// Response message for AuthService.SignIn.
|
||||
message SignInResponse {
|
||||
// The signed-in user.
|
||||
User user = 1;
|
||||
|
||||
// The short-lived access token for API requests.
|
||||
// Keep it in memory only, not in localStorage.
|
||||
string access_token = 2;
|
||||
|
||||
// When the access token expires.
|
||||
// Call RefreshToken before this time.
|
||||
google.protobuf.Timestamp access_token_expire_time = 3;
|
||||
}
|
||||
|
||||
// Request message for AuthService.RefreshToken.
|
||||
// It has no fields: the refresh token is read from the HttpOnly cookie.
|
||||
message RefreshTokenRequest {}
|
||||
|
||||
// Response message for AuthService.RefreshToken.
|
||||
message RefreshTokenResponse {
|
||||
// The new short-lived access token.
|
||||
string access_token = 1;
|
||||
|
||||
// When the new access token expires.
|
||||
google.protobuf.Timestamp access_token_expire_time = 2;
|
||||
}
|
||||
|
||||
// Request message for AuthService.GetCurrentUser.
|
||||
message GetCurrentUserRequest {}
|
||||
|
||||
// Response message for AuthService.GetCurrentUser.
|
||||
message GetCurrentUserResponse {
|
||||
// The authenticated user.
|
||||
User user = 1;
|
||||
}
|
||||
|
||||
// Request message for AuthService.SignOut.
|
||||
message SignOutRequest {}
|
||||
@@ -0,0 +1,33 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api;
|
||||
|
||||
option go_package = "gen/api";
|
||||
|
||||
// State is the lifecycle state of a resource.
|
||||
enum State {
|
||||
STATE_UNSPECIFIED = 0;
|
||||
// The resource is active.
|
||||
NORMAL = 1;
|
||||
// The resource is archived.
|
||||
ARCHIVED = 2;
|
||||
}
|
||||
|
||||
// Direction is a sort direction.
|
||||
enum Direction {
|
||||
DIRECTION_UNSPECIFIED = 0;
|
||||
// Ascending order.
|
||||
ASC = 1;
|
||||
// Descending order.
|
||||
DESC = 2;
|
||||
}
|
||||
|
||||
// PageToken is the internal content of an opaque page token. The service
|
||||
// serializes it and encodes it as base64; clients must not parse it.
|
||||
message PageToken {
|
||||
// The page size used for the next page.
|
||||
int32 limit = 1;
|
||||
|
||||
// The number of items to skip before the next page.
|
||||
int32 offset = 2;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api.v1;
|
||||
package memos.api;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/client.proto";
|
||||
@@ -9,55 +9,63 @@ import "google/api/resource.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
|
||||
option go_package = "gen/api/v1";
|
||||
option go_package = "gen/api";
|
||||
|
||||
// IdentityProviderService manages the external identity providers users can sign in with.
|
||||
service IdentityProviderService {
|
||||
// ListIdentityProviders lists identity providers.
|
||||
// Public, so the sign-in page can show SSO options. Client secrets are never returned.
|
||||
rpc ListIdentityProviders(ListIdentityProvidersRequest) returns (ListIdentityProvidersResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/identity-providers"};
|
||||
option (google.api.http) = {get: "/api/identity-providers"};
|
||||
}
|
||||
|
||||
// GetIdentityProvider gets an identity provider.
|
||||
// The client secret is never returned.
|
||||
rpc GetIdentityProvider(GetIdentityProviderRequest) returns (IdentityProvider) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=identity-providers/*}"};
|
||||
option (google.api.http) = {get: "/api/{name=identity-providers/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// CreateIdentityProvider creates an identity provider.
|
||||
// Requires the admin role. Fails with FAILED_PRECONDITION when the ID belongs to a provider configured by the
|
||||
// deployment.
|
||||
rpc CreateIdentityProvider(CreateIdentityProviderRequest) returns (IdentityProvider) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/identity-providers"
|
||||
post: "/api/identity-providers"
|
||||
body: "identity_provider"
|
||||
};
|
||||
option (google.api.method_signature) = "identity_provider";
|
||||
}
|
||||
|
||||
// UpdateIdentityProvider updates an identity provider.
|
||||
// Requires the admin role. Providers configured by the deployment cannot be updated.
|
||||
rpc UpdateIdentityProvider(UpdateIdentityProviderRequest) returns (IdentityProvider) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/v1/{identity_provider.name=identity-providers/*}"
|
||||
patch: "/api/{identity_provider.name=identity-providers/*}"
|
||||
body: "identity_provider"
|
||||
};
|
||||
option (google.api.method_signature) = "identity_provider,update_mask";
|
||||
}
|
||||
|
||||
// DeleteIdentityProvider deletes an identity provider.
|
||||
// Requires the admin role. Providers configured by the deployment cannot be deleted. Fails with
|
||||
// FAILED_PRECONDITION when password sign-in is disabled for regular users and no other effective provider remains.
|
||||
rpc DeleteIdentityProvider(DeleteIdentityProviderRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/v1/{name=identity-providers/*}"};
|
||||
option (google.api.http) = {delete: "/api/{name=identity-providers/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
}
|
||||
|
||||
// IdentityProvider is an external identity provider users can sign in with.
|
||||
message IdentityProvider {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api.v1/IdentityProvider"
|
||||
type: "memos.api/IdentityProvider"
|
||||
pattern: "identity-providers/{idp}"
|
||||
name_field: "name"
|
||||
singular: "identityProvider"
|
||||
plural: "identityProviders"
|
||||
};
|
||||
|
||||
// The resource name of the identity provider.
|
||||
// Identifier. The resource name of the identity provider.
|
||||
// Format: identity-providers/{idp}
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
@@ -67,12 +75,13 @@ message IdentityProvider {
|
||||
// Required. The display title of the identity provider.
|
||||
string title = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. Filter applied to user identifiers.
|
||||
// Optional. A regular expression the user identifier must match to sign in. Empty allows every identifier.
|
||||
string identifier_filter = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Required. Configuration for the identity provider.
|
||||
// Required. The type-specific configuration of the identity provider.
|
||||
IdentityProviderConfig config = 5 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Type is the protocol of an identity provider.
|
||||
enum Type {
|
||||
TYPE_UNSPECIFIED = 0;
|
||||
// OAuth2 identity provider.
|
||||
@@ -80,69 +89,101 @@ message IdentityProvider {
|
||||
}
|
||||
}
|
||||
|
||||
message IdentityProviderConfig {
|
||||
oneof config {
|
||||
OAuth2Config oauth2_config = 1;
|
||||
}
|
||||
}
|
||||
|
||||
message FieldMapping {
|
||||
string identifier = 1;
|
||||
string display_name = 2;
|
||||
string email = 3;
|
||||
string avatar_url = 4;
|
||||
}
|
||||
|
||||
message OAuth2Config {
|
||||
string client_id = 1;
|
||||
string client_secret = 2;
|
||||
string auth_url = 3;
|
||||
string token_url = 4;
|
||||
string user_info_url = 5;
|
||||
repeated string scopes = 6;
|
||||
FieldMapping field_mapping = 7;
|
||||
}
|
||||
|
||||
// Request message for IdentityProviderService.ListIdentityProviders.
|
||||
message ListIdentityProvidersRequest {}
|
||||
|
||||
// Response message for IdentityProviderService.ListIdentityProviders.
|
||||
message ListIdentityProvidersResponse {
|
||||
// The list of identity providers.
|
||||
// The identity providers.
|
||||
repeated IdentityProvider identity_providers = 1;
|
||||
}
|
||||
|
||||
// Request message for IdentityProviderService.GetIdentityProvider.
|
||||
message GetIdentityProviderRequest {
|
||||
// Required. The resource name of the identity provider to get.
|
||||
// Format: identity-providers/{idp}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/IdentityProvider"}
|
||||
(google.api.resource_reference) = {type: "memos.api/IdentityProvider"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for IdentityProviderService.CreateIdentityProvider.
|
||||
message CreateIdentityProviderRequest {
|
||||
// Required. The identity provider to create.
|
||||
IdentityProvider identity_provider = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The ID to use for the identity provider, which will become the final component of the resource name.
|
||||
// If not provided, the system will generate one.
|
||||
// Optional. The ID to use for the identity provider, which becomes the final component of the resource name.
|
||||
// If empty, the server generates one.
|
||||
// Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$
|
||||
string identity_provider_id = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Request message for IdentityProviderService.UpdateIdentityProvider.
|
||||
message UpdateIdentityProviderRequest {
|
||||
// Required. The identity provider to update.
|
||||
// Required. The identity provider to update. Its name identifies the provider.
|
||||
IdentityProvider identity_provider = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The update mask applies to the resource. Only the top level fields of
|
||||
// IdentityProvider are supported.
|
||||
// Required. The fields to update. Supported paths: title, identifier_filter, config; other paths are ignored.
|
||||
// An empty OAuth2 client secret in config keeps the stored secret.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Request message for IdentityProviderService.DeleteIdentityProvider.
|
||||
message DeleteIdentityProviderRequest {
|
||||
// Required. The resource name of the identity provider to delete.
|
||||
// Format: identity-providers/{idp}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/IdentityProvider"}
|
||||
(google.api.resource_reference) = {type: "memos.api/IdentityProvider"}
|
||||
];
|
||||
}
|
||||
|
||||
// IdentityProviderConfig is the type-specific configuration of an identity provider.
|
||||
message IdentityProviderConfig {
|
||||
// The configuration, matching the provider type.
|
||||
oneof config {
|
||||
// The configuration of an OAuth2 identity provider.
|
||||
OAuth2Config oauth2_config = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// OAuth2Config is the configuration of an OAuth2 identity provider.
|
||||
message OAuth2Config {
|
||||
// The OAuth2 client ID.
|
||||
string client_id = 1;
|
||||
|
||||
// The OAuth2 client secret. Write-only: it is never returned in responses.
|
||||
string client_secret = 2;
|
||||
|
||||
// The authorization endpoint URL.
|
||||
string auth_url = 3;
|
||||
|
||||
// The token endpoint URL, used to exchange the authorization code for an access token.
|
||||
string token_url = 4;
|
||||
|
||||
// The user info endpoint URL, used to fetch the claims of the signed-in user.
|
||||
string user_info_url = 5;
|
||||
|
||||
// The scopes to request.
|
||||
repeated string scopes = 6;
|
||||
|
||||
// How user info claims map to user fields.
|
||||
FieldMapping field_mapping = 7;
|
||||
}
|
||||
|
||||
// FieldMapping maps user info claims of an OAuth2 identity provider to user fields.
|
||||
// Each field holds the name of a claim.
|
||||
message FieldMapping {
|
||||
// The claim that uniquely identifies the user. Sign-in fails when it is missing or empty.
|
||||
string identifier = 1;
|
||||
|
||||
// The claim used as the display name. Falls back to the identifier when unset.
|
||||
string display_name = 2;
|
||||
|
||||
// The claim used as the email address.
|
||||
string email = 3;
|
||||
|
||||
// The claim used as the avatar URL.
|
||||
string avatar_url = 4;
|
||||
}
|
||||
@@ -0,0 +1,532 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api;
|
||||
|
||||
import "api/user_service.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/client.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
import "google/api/resource.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/type/color.proto";
|
||||
|
||||
option go_package = "gen/api";
|
||||
|
||||
// InstanceService exposes the instance profile, instance-wide settings and usage statistics.
|
||||
service InstanceService {
|
||||
// GetInstanceProfile gets the instance profile. Available without authentication, including on a private instance.
|
||||
rpc GetInstanceProfile(GetInstanceProfileRequest) returns (InstanceProfile) {
|
||||
option (google.api.http) = {get: "/api/instance/profile"};
|
||||
}
|
||||
|
||||
// GetInstanceSetting gets an instance setting. Available without authentication, except STORAGE and NOTIFICATION,
|
||||
// which are admin only, and AI, which requires a signed-in user and hides transcription defaults from non-admins.
|
||||
rpc GetInstanceSetting(GetInstanceSettingRequest) returns (InstanceSetting) {
|
||||
option (google.api.http) = {get: "/api/{name=instance/settings/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// BatchGetInstanceSettings gets up to 100 instance settings in request order, with the same access rules as
|
||||
// GetInstanceSetting. The call fails if any setting cannot be returned.
|
||||
rpc BatchGetInstanceSettings(BatchGetInstanceSettingsRequest) returns (BatchGetInstanceSettingsResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/instance/settings:batchGet"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
// UpdateInstanceSetting replaces an instance setting. Admin only. Settings configured by the deployment cannot be
|
||||
// updated. Empty write-only credentials keep the stored values.
|
||||
rpc UpdateInstanceSetting(UpdateInstanceSettingRequest) returns (InstanceSetting) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/{instance_setting.name=instance/settings/*}"
|
||||
body: "instance_setting"
|
||||
};
|
||||
option (google.api.method_signature) = "instance_setting,update_mask";
|
||||
}
|
||||
|
||||
// TestInstanceEmailSetting sends a test email with the provided or stored SMTP settings. Admin only.
|
||||
rpc TestInstanceEmailSetting(TestInstanceEmailSettingRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/instance/settings/notification:testEmail"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
// GetInstanceStats gets resource usage statistics for the instance. Admin only. Results are cached for 60 seconds.
|
||||
rpc GetInstanceStats(GetInstanceStatsRequest) returns (InstanceStats) {
|
||||
option (google.api.http) = {get: "/api/instance/stats"};
|
||||
}
|
||||
}
|
||||
|
||||
// InstanceAccessMode controls whether unauthenticated users may access instance content.
|
||||
enum InstanceAccessMode {
|
||||
INSTANCE_ACCESS_MODE_UNSPECIFIED = 0;
|
||||
// Unauthenticated users may only reach the endpoints needed to sign in, register and open share links.
|
||||
// This is the default.
|
||||
INSTANCE_ACCESS_MODE_PRIVATE = 1;
|
||||
// Unauthenticated users may read public content.
|
||||
INSTANCE_ACCESS_MODE_PUBLIC = 2;
|
||||
}
|
||||
|
||||
// InstanceProfile is the basic information about the instance.
|
||||
message InstanceProfile {
|
||||
// The version of the running server.
|
||||
string version = 1;
|
||||
|
||||
// The build commit of the running server.
|
||||
string commit = 2;
|
||||
|
||||
// Whether the instance runs in demo mode.
|
||||
bool demo = 3;
|
||||
|
||||
// The configured URL of the instance.
|
||||
string instance_url = 4;
|
||||
|
||||
// Whether unauthenticated users may access instance content.
|
||||
InstanceAccessMode access_mode = 5;
|
||||
|
||||
// Whether the instance has no users yet and requires initial setup (creating the first admin account).
|
||||
// Unlike a null admin, this stays false once any user exists, so an instance that has lost its admins is not
|
||||
// mistaken for a fresh install.
|
||||
bool needs_setup = 6;
|
||||
|
||||
// The first administrator of the instance, for display purposes.
|
||||
// May be null on an instance that has lost all admins; use needs_setup to determine whether initial setup is
|
||||
// required.
|
||||
User admin = 7;
|
||||
|
||||
// The proof-of-humanity challenge required on signup and password sign-in.
|
||||
// Absent when none is configured, which is the case on every self-hosted instance.
|
||||
Challenge challenge = 8;
|
||||
|
||||
// Challenge describes a proof-of-humanity challenge widget.
|
||||
message Challenge {
|
||||
// The challenge provider, which selects the widget the web app renders.
|
||||
string provider = 1;
|
||||
|
||||
// The provider's public site key for the widget.
|
||||
string site_key = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Request message for InstanceService.GetInstanceProfile.
|
||||
message GetInstanceProfileRequest {}
|
||||
|
||||
// InstanceSetting is one group of instance-wide settings, selected by its key.
|
||||
message InstanceSetting {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api/InstanceSetting"
|
||||
pattern: "instance/settings/{setting}"
|
||||
singular: "instanceSetting"
|
||||
plural: "instanceSettings"
|
||||
};
|
||||
|
||||
// Identifier. The resource name of the instance setting. {setting} is a Key value, such as GENERAL.
|
||||
// Format: instance/settings/{setting}
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// The setting value. The set field matches the key in name.
|
||||
oneof value {
|
||||
// The value of the GENERAL setting.
|
||||
GeneralSetting general_setting = 2;
|
||||
// The value of the STORAGE setting.
|
||||
StorageSetting storage_setting = 3;
|
||||
// The value of the MEMO_RELATED setting.
|
||||
MemoRelatedSetting memo_related_setting = 4;
|
||||
// The value of the TAGS setting.
|
||||
TagsSetting tags_setting = 5;
|
||||
// The value of the NOTIFICATION setting.
|
||||
NotificationSetting notification_setting = 6;
|
||||
// The value of the AI setting.
|
||||
AISetting ai_setting = 7;
|
||||
// The value of the ACCESS setting.
|
||||
AccessSetting access_setting = 8;
|
||||
}
|
||||
|
||||
// Key identifies an instance setting.
|
||||
enum Key {
|
||||
KEY_UNSPECIFIED = 0;
|
||||
// General settings.
|
||||
GENERAL = 1;
|
||||
// Attachment storage settings.
|
||||
STORAGE = 2;
|
||||
// Memo-related settings.
|
||||
MEMO_RELATED = 3;
|
||||
// Tag metadata.
|
||||
TAGS = 4;
|
||||
// Notification transport settings.
|
||||
NOTIFICATION = 5;
|
||||
// AI provider settings.
|
||||
AI = 6;
|
||||
// Instance access policy settings.
|
||||
ACCESS = 7;
|
||||
}
|
||||
|
||||
// StorageType is the backend of a configured storage.
|
||||
enum StorageType {
|
||||
STORAGE_TYPE_UNSPECIFIED = 0;
|
||||
// Stores attachment content in the application database.
|
||||
DATABASE = 1;
|
||||
// Stores attachment content on the local filesystem.
|
||||
LOCAL = 2;
|
||||
// Stores attachment content in an S3-compatible object store.
|
||||
S3 = 3;
|
||||
}
|
||||
|
||||
// AIProviderType is the provider implementation type.
|
||||
enum AIProviderType {
|
||||
AI_PROVIDER_TYPE_UNSPECIFIED = 0;
|
||||
// OpenAI API. The endpoint defaults to https://api.openai.com/v1.
|
||||
OPENAI = 1;
|
||||
// Google Gemini API. The endpoint defaults to https://generativelanguage.googleapis.com/v1beta.
|
||||
GEMINI = 2;
|
||||
}
|
||||
|
||||
// GeneralSetting is the general instance configuration.
|
||||
message GeneralSetting {
|
||||
// Branding shown in the web app.
|
||||
CustomProfile custom_profile = 1;
|
||||
|
||||
// Whether user self-registration is disabled.
|
||||
bool disallow_user_registration = 2;
|
||||
|
||||
// Whether password authentication is disabled.
|
||||
bool disallow_password_auth = 3;
|
||||
|
||||
// Whether users are prevented from changing their username.
|
||||
bool disallow_change_username = 4;
|
||||
|
||||
// Whether users are prevented from changing their nickname.
|
||||
bool disallow_change_nickname = 5;
|
||||
|
||||
// The first day of the week as an offset from Sunday.
|
||||
// 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday.
|
||||
// Default is Sunday.
|
||||
int32 week_start_day_offset = 6;
|
||||
|
||||
// Custom CSS injected into the web app.
|
||||
string additional_style = 7;
|
||||
|
||||
// Custom JavaScript injected into the web app.
|
||||
string additional_script = 8;
|
||||
|
||||
// CustomProfile is the instance branding.
|
||||
message CustomProfile {
|
||||
// The instance title.
|
||||
string title = 1;
|
||||
|
||||
// The instance description.
|
||||
string description = 2;
|
||||
|
||||
// The URL of the instance logo.
|
||||
string logo_url = 3;
|
||||
}
|
||||
}
|
||||
|
||||
// StorageSetting is the attachment storage configuration.
|
||||
message StorageSetting {
|
||||
// Configured storage instances, including inactive instances still referenced by attachments.
|
||||
repeated Storage storages = 1;
|
||||
|
||||
// The ID of the storage used for new attachments.
|
||||
string default_storage_id = 2;
|
||||
|
||||
// The template of attachment file paths.
|
||||
// Default is assets/{timestamp}_{uuid}_{filename}.
|
||||
string filepath_template = 3;
|
||||
|
||||
// The maximum upload size in megabytes. Default is 30.
|
||||
int64 upload_size_limit_mb = 4;
|
||||
|
||||
// Legacy compatibility field. New clients use default_storage_id.
|
||||
StorageType storage_type = 5;
|
||||
|
||||
// Legacy compatibility field. New clients use storages.
|
||||
S3Config s3_config = 6;
|
||||
|
||||
// StorageType is the legacy storage type, retained for compatibility with existing clients.
|
||||
enum StorageType {
|
||||
STORAGE_TYPE_UNSPECIFIED = 0;
|
||||
// Database storage.
|
||||
DATABASE = 1;
|
||||
// Local filesystem storage.
|
||||
LOCAL = 2;
|
||||
// S3 storage.
|
||||
S3 = 3;
|
||||
}
|
||||
|
||||
// S3Config is the legacy S3 configuration, retained for compatibility with existing clients.
|
||||
// Reference: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/
|
||||
message S3Config {
|
||||
// The S3 endpoint URL.
|
||||
string endpoint = 1;
|
||||
|
||||
// The S3 region.
|
||||
string region = 2;
|
||||
|
||||
// The S3 bucket.
|
||||
string bucket = 3;
|
||||
|
||||
// The S3 access key ID.
|
||||
string access_key_id = 4;
|
||||
|
||||
// Input only. The S3 access key secret. Never returned; an empty value keeps the stored secret.
|
||||
string access_key_secret = 5 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
|
||||
// Whether to use path-style addressing instead of virtual-hosted-style.
|
||||
bool use_path_style = 6;
|
||||
|
||||
// Whether to skip TLS certificate verification when connecting to the S3 endpoint.
|
||||
// Only enable this for trusted endpoints that use a self-signed certificate; it removes protection against
|
||||
// man-in-the-middle attacks.
|
||||
bool insecure_skip_tls_verify = 7;
|
||||
}
|
||||
}
|
||||
|
||||
// Storage is a configured attachment storage instance.
|
||||
message Storage {
|
||||
// The stable identifier referenced by attachments.
|
||||
string id = 1;
|
||||
|
||||
// The human-readable storage name.
|
||||
string name = 2;
|
||||
|
||||
// The storage backend.
|
||||
StorageType type = 3;
|
||||
|
||||
// The backend-specific configuration.
|
||||
oneof config {
|
||||
// The configuration of an S3 storage.
|
||||
S3Config s3_config = 4;
|
||||
}
|
||||
|
||||
// S3Config is the configuration of an S3-compatible object store.
|
||||
// Reference: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/
|
||||
message S3Config {
|
||||
// The S3 endpoint URL.
|
||||
string endpoint = 1;
|
||||
|
||||
// The S3 region.
|
||||
string region = 2;
|
||||
|
||||
// The S3 bucket.
|
||||
string bucket = 3;
|
||||
|
||||
// The S3 access key ID.
|
||||
string access_key_id = 4;
|
||||
|
||||
// Input only. The S3 access key secret. Never returned; an empty value keeps the stored secret.
|
||||
string access_key_secret = 5 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
|
||||
// Whether to use path-style addressing instead of virtual-hosted-style.
|
||||
bool use_path_style = 6;
|
||||
|
||||
// Whether to skip TLS certificate verification when connecting to the S3 endpoint.
|
||||
// Only enable this for trusted endpoints that use a self-signed certificate; it removes protection against
|
||||
// man-in-the-middle attacks.
|
||||
bool insecure_skip_tls_verify = 7;
|
||||
}
|
||||
}
|
||||
|
||||
// MemoRelatedSetting is the memo-related instance configuration.
|
||||
message MemoRelatedSetting {
|
||||
// The maximum memo content length in bytes. Default and minimum is 8192.
|
||||
int32 content_length_limit = 1;
|
||||
|
||||
// The reactions users can choose from. Defaults to a built-in emoji set when empty.
|
||||
repeated string reactions = 2;
|
||||
|
||||
// Whether double-clicking a memo opens it for editing.
|
||||
bool enable_double_click_edit = 3;
|
||||
}
|
||||
|
||||
// TagsSetting is the instance-wide tag metadata configuration.
|
||||
// Active tag metadata is stored in per-user tag settings. This message remains for backward compatibility with
|
||||
// existing clients and migrations.
|
||||
message TagsSetting {
|
||||
// Map of tag name pattern to tag metadata.
|
||||
// Each key is treated as an anchored regular expression (^pattern$), so a single entry like "project/.*" matches
|
||||
// all tags under that prefix. Exact tag names are also valid.
|
||||
map<string, TagMetadata> tags = 1;
|
||||
}
|
||||
|
||||
// TagMetadata is the display metadata for a tag.
|
||||
message TagMetadata {
|
||||
// The background color of the tag label. When unset, the default tag color is used.
|
||||
google.type.Color background_color = 1;
|
||||
|
||||
// Whether memos with this tag have their content blurred.
|
||||
bool blur_content = 2;
|
||||
}
|
||||
|
||||
// NotificationSetting is the notification transport configuration.
|
||||
message NotificationSetting {
|
||||
// The email delivery configuration.
|
||||
EmailSetting email = 1;
|
||||
|
||||
// EmailSetting is the SMTP configuration for notification emails.
|
||||
message EmailSetting {
|
||||
// Whether email notifications are enabled.
|
||||
bool enabled = 1;
|
||||
|
||||
// The SMTP server host.
|
||||
string smtp_host = 2;
|
||||
|
||||
// The SMTP server port.
|
||||
int32 smtp_port = 3;
|
||||
|
||||
// The SMTP username.
|
||||
string smtp_username = 4;
|
||||
|
||||
// Input only. The SMTP password. Never returned. An empty value keeps the stored password, unless the host,
|
||||
// port, username or encryption settings change.
|
||||
string smtp_password = 5 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
|
||||
// Whether to use STARTTLS.
|
||||
bool use_tls = 6;
|
||||
|
||||
// Whether to use implicit SSL/TLS.
|
||||
bool use_ssl = 7;
|
||||
|
||||
// The sender email address.
|
||||
string from_email = 8;
|
||||
|
||||
// The sender display name.
|
||||
string from_name = 9;
|
||||
|
||||
// The Reply-To email address.
|
||||
string reply_to = 10;
|
||||
}
|
||||
}
|
||||
|
||||
// AISetting is the AI provider configuration.
|
||||
message AISetting {
|
||||
// The AI provider configurations available instance-wide.
|
||||
repeated AIProviderConfig providers = 1;
|
||||
|
||||
// The speech-to-text feature configuration.
|
||||
// When unset or transcription.provider_id is empty, transcription is disabled. An update that omits it keeps the
|
||||
// stored configuration.
|
||||
TranscriptionConfig transcription = 2;
|
||||
}
|
||||
|
||||
// AIProviderConfig is one callable AI provider connection.
|
||||
message AIProviderConfig {
|
||||
// The provider ID. Generated when empty on update.
|
||||
string id = 1;
|
||||
|
||||
// The provider display title.
|
||||
string title = 2;
|
||||
|
||||
// The provider implementation type.
|
||||
AIProviderType type = 3;
|
||||
|
||||
// The provider API endpoint. Defaults to the provider's public endpoint when empty.
|
||||
string endpoint = 4;
|
||||
|
||||
// Input only. The provider API key. Never returned; an empty value keeps the stored key.
|
||||
string api_key = 5 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
|
||||
// Output only. Whether an API key is stored for this provider.
|
||||
bool api_key_set = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Output only. A masked hint of the stored API key.
|
||||
string api_key_hint = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
}
|
||||
|
||||
// TranscriptionConfig is the speech-to-text feature configuration.
|
||||
message TranscriptionConfig {
|
||||
// The ID of the provider used for transcription; must reference an entry in AISetting.providers.
|
||||
// Empty means transcription is disabled.
|
||||
string provider_id = 1;
|
||||
|
||||
// The provider-specific model identifier. Hidden from non-admins.
|
||||
// Empty falls back to the engine default (whisper-1 for OPENAI providers, gemini-2.5-flash for GEMINI providers).
|
||||
string model = 2;
|
||||
|
||||
// The default ISO 639-1 language hint sent to the provider. Hidden from non-admins.
|
||||
// Empty lets the provider auto-detect.
|
||||
string language = 3;
|
||||
|
||||
// A default spelling and vocabulary hint passed to the provider. Hidden from non-admins.
|
||||
string prompt = 4;
|
||||
}
|
||||
|
||||
// AccessSetting is the instance access policy.
|
||||
message AccessSetting {
|
||||
// Whether unauthenticated users may access instance content. Must be PRIVATE or PUBLIC on update.
|
||||
InstanceAccessMode access_mode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Request message for InstanceService.GetInstanceSetting.
|
||||
message GetInstanceSettingRequest {
|
||||
// Required. The resource name of the instance setting.
|
||||
// Format: instance/settings/{setting}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/InstanceSetting"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for InstanceService.BatchGetInstanceSettings.
|
||||
message BatchGetInstanceSettingsRequest {
|
||||
// Required. The resource names of the instance settings. At most 100.
|
||||
// Format: instance/settings/{setting}
|
||||
repeated string names = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/InstanceSetting"}
|
||||
];
|
||||
}
|
||||
|
||||
// Response message for InstanceService.BatchGetInstanceSettings.
|
||||
message BatchGetInstanceSettingsResponse {
|
||||
// The instance settings, in the same order as the requested names.
|
||||
repeated InstanceSetting instance_settings = 1;
|
||||
}
|
||||
|
||||
// Request message for InstanceService.UpdateInstanceSetting.
|
||||
message UpdateInstanceSettingRequest {
|
||||
// Required. The instance setting, which replaces the stored setting.
|
||||
InstanceSetting instance_setting = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The list of fields to update. Currently ignored; the whole setting is replaced.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Request message for InstanceService.TestInstanceEmailSetting.
|
||||
message TestInstanceEmailSettingRequest {
|
||||
// Optional. The SMTP settings to test. If omitted, the stored notification email setting is used. An empty
|
||||
// password reuses the stored password when the connection settings are unchanged.
|
||||
InstanceSetting.NotificationSetting.EmailSetting email = 1 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The recipient email address. If omitted, the current user's email address is used.
|
||||
string recipient_email = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// InstanceStats is a snapshot of the instance's resource usage.
|
||||
message InstanceStats {
|
||||
// The database size statistics.
|
||||
DatabaseStats database = 1;
|
||||
|
||||
// The recursive size of the data directory in bytes. -1 if unavailable.
|
||||
int64 local_storage_bytes = 2;
|
||||
|
||||
// The time the snapshot was generated on the server.
|
||||
google.protobuf.Timestamp generated_time = 3;
|
||||
|
||||
// DatabaseStats is the database size statistics.
|
||||
message DatabaseStats {
|
||||
// The database driver: "sqlite", "mysql" or "postgres".
|
||||
string driver = 1;
|
||||
|
||||
// The database size in bytes. -1 if unavailable.
|
||||
int64 size_bytes = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Request message for InstanceService.GetInstanceStats.
|
||||
message GetInstanceStatsRequest {}
|
||||
@@ -0,0 +1,761 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api;
|
||||
|
||||
import "api/attachment_service.proto";
|
||||
import "api/common.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/client.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
import "google/api/resource.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "gen/api";
|
||||
|
||||
// MemoService manages memos and their attachments, relations, comments,
|
||||
// reactions, and share links.
|
||||
service MemoService {
|
||||
// ListMemos lists the memos the caller can read, excluding comments.
|
||||
// Anonymous callers can list only when the instance allows public access.
|
||||
rpc ListMemos(ListMemosRequest) returns (ListMemosResponse) {
|
||||
option (google.api.http) = {get: "/api/memos"};
|
||||
option (google.api.method_signature) = "";
|
||||
}
|
||||
|
||||
// GetMemo gets a memo. Requires read access to the memo.
|
||||
rpc GetMemo(GetMemoRequest) returns (Memo) {
|
||||
option (google.api.http) = {get: "/api/{name=memos/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// CreateMemo creates a memo owned by the authenticated user. The request body
|
||||
// is a Memo; set its Markdown content and visibility (defaults to PRIVATE).
|
||||
// Requires authentication.
|
||||
rpc CreateMemo(CreateMemoRequest) returns (Memo) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/memos"
|
||||
body: "memo"
|
||||
};
|
||||
option (google.api.method_signature) = "memo";
|
||||
}
|
||||
|
||||
// UpdateMemo updates the memo fields listed in update_mask. Requires the memo
|
||||
// creator or an instance administrator.
|
||||
rpc UpdateMemo(UpdateMemoRequest) returns (Memo) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/{memo.name=memos/*}"
|
||||
body: "memo"
|
||||
};
|
||||
option (google.api.method_signature) = "memo,update_mask";
|
||||
}
|
||||
|
||||
// DeleteMemo deletes the named memo and its comment subtree, including nested
|
||||
// replies and their owned resources. It removes incident relations for all
|
||||
// deleted memos. Requires the memo creator or an instance administrator.
|
||||
rpc DeleteMemo(DeleteMemoRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/{name=memos/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// ListMemoAttachments lists the attachments of a memo. Requires read access
|
||||
// to the memo.
|
||||
rpc ListMemoAttachments(ListMemoAttachmentsRequest) returns (ListMemoAttachmentsResponse) {
|
||||
option (google.api.http) = {get: "/api/{parent=memos/*}/attachments"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// SetMemoAttachments replaces the full set of attachments on a memo with the
|
||||
// provided list (not an append). Pass the complete desired set; an empty list
|
||||
// clears all attachments. Idempotent. Requires the memo creator or an
|
||||
// instance administrator.
|
||||
rpc SetMemoAttachments(SetMemoAttachmentsRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/{name=memos/*}/attachments"
|
||||
body: "*"
|
||||
};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// ListMemoRelations lists the relations of a memo in both directions.
|
||||
// Requires read access to the memo.
|
||||
rpc ListMemoRelations(ListMemoRelationsRequest) returns (ListMemoRelationsResponse) {
|
||||
option (google.api.http) = {get: "/api/{parent=memos/*}/relations"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// SetMemoRelations replaces the full set of mutable REFERENCE relations on a
|
||||
// memo. COMMENT relations are immutable creation context and are rejected by
|
||||
// this RPC. An empty list clears references without changing COMMENT.
|
||||
// Requires the memo creator or an instance administrator.
|
||||
rpc SetMemoRelations(SetMemoRelationsRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/{name=memos/*}/relations"
|
||||
body: "*"
|
||||
};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// ListMemoComments lists the active comments on a memo that the caller can
|
||||
// read. Requires read access to the memo.
|
||||
rpc ListMemoComments(ListMemoCommentsRequest) returns (ListMemoCommentsResponse) {
|
||||
option (google.api.http) = {get: "/api/{parent=memos/*}/comments"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// CreateMemoComment atomically creates an independent memo plus one immutable
|
||||
// COMMENT context relation to the named memo. The new memo keeps its own
|
||||
// placement, visibility, authorship, and lifecycle. The named memo must be
|
||||
// readable by the caller and not archived.
|
||||
rpc CreateMemoComment(CreateMemoCommentRequest) returns (Memo) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/{parent=memos/*}/comments"
|
||||
body: "comment"
|
||||
};
|
||||
option (google.api.method_signature) = "parent,comment";
|
||||
}
|
||||
|
||||
// ListMemoReactions lists the reactions on a memo. Requires read access to
|
||||
// the memo.
|
||||
rpc ListMemoReactions(ListMemoReactionsRequest) returns (ListMemoReactionsResponse) {
|
||||
option (google.api.http) = {get: "/api/{parent=memos/*}/reactions"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// DeleteMemoReaction deletes a reaction. Requires the reaction creator or an
|
||||
// instance administrator.
|
||||
rpc DeleteMemoReaction(DeleteMemoReactionRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/{name=memos/*/reactions/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// UpsertMemoReaction adds or updates the authenticated user's reaction on a
|
||||
// memo. Requires read access to the memo.
|
||||
rpc UpsertMemoReaction(UpsertMemoReactionRequest) returns (Reaction) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/{parent=memos/*}/reactions"
|
||||
body: "*"
|
||||
};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// ListMemoShares lists all share links for a memo. Requires the memo creator
|
||||
// or an instance administrator.
|
||||
rpc ListMemoShares(ListMemoSharesRequest) returns (ListMemoSharesResponse) {
|
||||
option (google.api.http) = {get: "/api/{parent=memos/*}/shares"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// CreateMemoShare creates a share link for a memo. Requires the memo creator
|
||||
// or an instance administrator. Only active memos without SPACE visibility
|
||||
// can be shared.
|
||||
rpc CreateMemoShare(CreateMemoShareRequest) returns (MemoShare) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/{parent=memos/*}/shares"
|
||||
body: "memo_share"
|
||||
};
|
||||
option (google.api.method_signature) = "parent,memo_share";
|
||||
}
|
||||
|
||||
// DeleteMemoShare revokes a share link. Requires the memo creator or an
|
||||
// instance administrator.
|
||||
rpc DeleteMemoShare(DeleteMemoShareRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/{name=memos/*/shares/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// GetSharedMemo resolves a share token to its memo. No authentication is
|
||||
// required. Returns NOT_FOUND if the token is invalid or expired.
|
||||
rpc GetSharedMemo(GetSharedMemoRequest) returns (Memo) {
|
||||
option (google.api.http) = {get: "/api/shares/{share_token}/memo"};
|
||||
}
|
||||
|
||||
// GetLinkMetadata fetches the title, description, and image of a link.
|
||||
rpc GetLinkMetadata(GetLinkMetadataRequest) returns (LinkMetadata) {
|
||||
option (google.api.http) = {get: "/api/memos/-/linkMetadata"};
|
||||
}
|
||||
|
||||
// BatchGetLinkMetadata fetches the metadata of up to 10 links.
|
||||
rpc BatchGetLinkMetadata(BatchGetLinkMetadataRequest) returns (BatchGetLinkMetadataResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/memos/-/linkMetadata:batchGet"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Visibility controls who can read a memo.
|
||||
enum Visibility {
|
||||
VISIBILITY_UNSPECIFIED = 0;
|
||||
// Only the creator can read the memo.
|
||||
PRIVATE = 1;
|
||||
// Signed-in users of the instance can read the memo.
|
||||
PROTECTED = 2;
|
||||
// Signed-in users can read the memo; anonymous visitors can read it when
|
||||
// instance policy permits.
|
||||
PUBLIC = 3;
|
||||
// Active members of the memo's space can read the memo.
|
||||
SPACE = 4;
|
||||
}
|
||||
|
||||
// Memo is a Markdown note written by a user.
|
||||
message Memo {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api/Memo"
|
||||
pattern: "memos/{memo}"
|
||||
singular: "memo"
|
||||
plural: "memos"
|
||||
};
|
||||
|
||||
// Identifier. The resource name of the memo, where memo is the
|
||||
// user-defined UID.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// Output only. The resource name of the creator.
|
||||
// Format: users/{user}
|
||||
string creator = 2 [
|
||||
(google.api.field_behavior) = OUTPUT_ONLY,
|
||||
(google.api.resource_reference) = {type: "memos.api/User"}
|
||||
];
|
||||
|
||||
// Optional. The space in which the memo is placed. Every memo, including a
|
||||
// comment, owns its placement independently.
|
||||
// Format: spaces/{space}
|
||||
optional string space = 3 [
|
||||
(google.api.field_behavior) = OPTIONAL,
|
||||
(google.api.resource_reference) = {type: "memos.api/Space"}
|
||||
];
|
||||
|
||||
// Required. The content of the memo in Markdown. Must not exceed the
|
||||
// instance's content length limit.
|
||||
string content = 4 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The location of the memo.
|
||||
optional Location location = 5 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Required. The visibility of the memo. Defaults to PRIVATE on creation when
|
||||
// unspecified. SPACE requires the memo to be placed in a space.
|
||||
Visibility visibility = 6 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The state of the memo. New memos are always NORMAL; change it
|
||||
// with UpdateMemo.
|
||||
State state = 7 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. Whether the memo is pinned. Ignored on creation; change it with
|
||||
// UpdateMemo.
|
||||
bool pinned = 8 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The attachments of the memo. Setting it replaces the full set.
|
||||
repeated Attachment attachments = 9 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The relations of the memo in both directions. Only REFERENCE
|
||||
// relations can be set; COMMENT relations are output only.
|
||||
repeated MemoRelation relations = 10 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Output only. The reactions to the memo.
|
||||
repeated Reaction reactions = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Output only. The context memo of this COMMENT relation, if any.
|
||||
// Its identity is returned even when the caller cannot read the parent.
|
||||
// Fetch the parent independently; this field does not grant read access.
|
||||
// Format: memos/{memo}
|
||||
optional string parent = 12 [
|
||||
(google.api.field_behavior) = OUTPUT_ONLY,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
|
||||
// Output only. The tags extracted from the content.
|
||||
repeated string tags = 13 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Output only. The properties computed from the content.
|
||||
Property property = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Output only. A plain-text snippet of the content.
|
||||
string snippet = 15 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Optional. The creation time. Defaults to the current time when unset on
|
||||
// creation.
|
||||
google.protobuf.Timestamp create_time = 16 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The last update time. Defaults to the current time when unset on
|
||||
// creation.
|
||||
google.protobuf.Timestamp update_time = 17 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Property holds properties computed from the memo content.
|
||||
message Property {
|
||||
// The text of the H1 heading when it is the first block of the content.
|
||||
string title = 1;
|
||||
|
||||
// Whether the content contains a link.
|
||||
bool has_link = 2;
|
||||
|
||||
// Whether the content contains inline code or a code block.
|
||||
bool has_code = 3;
|
||||
|
||||
// Whether the content contains a task list.
|
||||
bool has_task_list = 4;
|
||||
|
||||
// Whether the content contains an unchecked task.
|
||||
bool has_incomplete_tasks = 5;
|
||||
}
|
||||
}
|
||||
|
||||
// Request message for MemoService.ListMemos.
|
||||
message ListMemosRequest {
|
||||
// Optional. The maximum number of memos to return. The service may return
|
||||
// fewer. Defaults to 50; values above 1000 are coerced to 1000.
|
||||
int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token from a previous call. Provide it to retrieve the
|
||||
// next page.
|
||||
string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A CEL expression to filter memos. Combine terms with && and ||.
|
||||
// Available fields:
|
||||
// content (string), creator (string, e.g. "users/1"),
|
||||
// created_ts / updated_ts (timestamp), pinned (bool),
|
||||
// visibility (string: PRIVATE | PROTECTED | PUBLIC | SPACE),
|
||||
// space (string resource name, or null when the memo has no space;
|
||||
// supports == and comparisons against null, e.g. space != null),
|
||||
// tags (list<string>; match with `"work" in tags`, not `tag == "work"`),
|
||||
// has_task_list / has_link / has_code / has_incomplete_tasks (bool),
|
||||
// has_location (bool; true when the memo has a location attached).
|
||||
// Note: the time fields here are created_ts / updated_ts, which differ from
|
||||
// the create_time / update_time names used by order_by.
|
||||
// Examples:
|
||||
// pinned == true && visibility == "PUBLIC"
|
||||
// space == "spaces/team" or space == null
|
||||
// tags.exists(t, t == "urgent")
|
||||
// content.contains("roadmap") && created_ts > now - duration("168h")
|
||||
string filter = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The order to sort results by, as a comma-separated list of
|
||||
// fields following AIP-132. Defaults to "create_time desc".
|
||||
// Supported fields: pinned, create_time, update_time, name.
|
||||
// Example: "pinned desc, create_time desc" or "update_time asc".
|
||||
// Note: order_by uses create_time / update_time, while the filter
|
||||
// expression uses created_ts / updated_ts for the same timestamps.
|
||||
string order_by = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Whether to include deleted memos. Currently ignored by the
|
||||
// server.
|
||||
bool show_deleted = 5 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The state of the memos to list. Defaults to NORMAL. Set to
|
||||
// ARCHIVED to list the caller's own archived memos.
|
||||
State state = 6 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Response message for MemoService.ListMemos.
|
||||
message ListMemosResponse {
|
||||
// The memos.
|
||||
repeated Memo memos = 1;
|
||||
|
||||
// A token to retrieve the next page. Empty when there are no more pages.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
// Request message for MemoService.GetMemo.
|
||||
message GetMemoRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for MemoService.CreateMemo.
|
||||
message CreateMemoRequest {
|
||||
// Required. The memo to create.
|
||||
Memo memo = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The ID to use for the memo, which becomes the final segment of
|
||||
// its resource name. If empty, a unique ID is generated.
|
||||
// Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$
|
||||
string memo_id = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Request message for MemoService.UpdateMemo.
|
||||
message UpdateMemoRequest {
|
||||
// Required. The memo to update. Its name identifies the memo.
|
||||
Memo memo = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The fields to update. Supported paths: content, visibility,
|
||||
// space, pinned, state, create_time, update_time, location, attachments,
|
||||
// relations.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Request message for MemoService.DeleteMemo.
|
||||
message DeleteMemoRequest {
|
||||
// Required. The resource name of the memo to delete.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
|
||||
// Optional. Currently ignored by the server; deletion always includes the
|
||||
// comment subtree.
|
||||
bool force = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Location is a geographic location attached to a memo.
|
||||
message Location {
|
||||
// Optional. A human-readable label for the location.
|
||||
string placeholder = 1 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The latitude of the location.
|
||||
double latitude = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The longitude of the location.
|
||||
double longitude = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Request message for MemoService.ListMemoAttachments.
|
||||
message ListMemoAttachmentsRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of attachments to return. The service may
|
||||
// return fewer. Currently ignored; all attachments are returned.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token from a previous call. Provide it to retrieve the
|
||||
// next page. Currently ignored.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Response message for MemoService.ListMemoAttachments.
|
||||
message ListMemoAttachmentsResponse {
|
||||
// The attachments.
|
||||
repeated Attachment attachments = 1;
|
||||
|
||||
// A token to retrieve the next page. Empty when there are no more pages.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
// Request message for MemoService.SetMemoAttachments.
|
||||
message SetMemoAttachmentsRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
|
||||
// Required. The complete set of attachments for the memo.
|
||||
repeated Attachment attachments = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// MemoRelation is a directed link from one memo to another.
|
||||
message MemoRelation {
|
||||
// Required. The source memo of the relation. For COMMENT, the comment.
|
||||
MemoRef memo = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The target memo of the relation. For COMMENT, the memo being
|
||||
// commented on.
|
||||
MemoRef related_memo = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The type of the relation.
|
||||
Type type = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Type is the kind of a memo relation.
|
||||
enum Type {
|
||||
TYPE_UNSPECIFIED = 0;
|
||||
// The source memo references the target memo. Clients can set it.
|
||||
REFERENCE = 1;
|
||||
// The source memo is a comment on the target memo. Output only.
|
||||
COMMENT = 2;
|
||||
}
|
||||
|
||||
// MemoRef identifies a memo in a relation.
|
||||
message MemoRef {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
|
||||
// Output only. A plain-text snippet of the memo content. Empty in
|
||||
// ListMemos and ListMemoComments responses.
|
||||
string snippet = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
}
|
||||
}
|
||||
|
||||
// Request message for MemoService.ListMemoRelations.
|
||||
message ListMemoRelationsRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of relations to return. The service may
|
||||
// return fewer. Defaults to 50; values above 1000 are coerced to 1000.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token from a previous call. Provide it to retrieve the
|
||||
// next page.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Response message for MemoService.ListMemoRelations.
|
||||
message ListMemoRelationsResponse {
|
||||
// The relations.
|
||||
repeated MemoRelation relations = 1;
|
||||
|
||||
// A token to retrieve the next page. Empty when there are no more pages.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
// Request message for MemoService.SetMemoRelations.
|
||||
message SetMemoRelationsRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
|
||||
// Required. The complete set of REFERENCE relations for the memo. COMMENT
|
||||
// relations are rejected.
|
||||
repeated MemoRelation relations = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Request message for MemoService.ListMemoComments.
|
||||
message ListMemoCommentsRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of comments to return. The service may return
|
||||
// fewer. Defaults to 50; values above 1000 are coerced to 1000.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token from a previous call. Provide it to retrieve the
|
||||
// next page.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The order to sort results by. Currently ignored by the server.
|
||||
string order_by = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Response message for MemoService.ListMemoComments.
|
||||
message ListMemoCommentsResponse {
|
||||
// The comment memos.
|
||||
repeated Memo comments = 1;
|
||||
|
||||
// A token to retrieve the next page. Empty when there are no more pages.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
// Request message for MemoService.CreateMemoComment.
|
||||
message CreateMemoCommentRequest {
|
||||
// Required. The resource name of the memo to comment on.
|
||||
// Format: memos/{memo}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
|
||||
// Required. The comment memo to create.
|
||||
Memo comment = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The ID to use for the comment memo, in the same format as
|
||||
// CreateMemoRequest.memo_id. If empty, a unique ID is generated.
|
||||
string comment_id = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Reaction is a reaction a user leaves on a memo.
|
||||
message Reaction {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api/Reaction"
|
||||
pattern: "memos/{memo}/reactions/{reaction}"
|
||||
singular: "reaction"
|
||||
plural: "reactions"
|
||||
};
|
||||
|
||||
// Identifier. The resource name of the reaction.
|
||||
// Format: memos/{memo}/reactions/{reaction}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = OUTPUT_ONLY,
|
||||
(google.api.field_behavior) = IDENTIFIER
|
||||
];
|
||||
|
||||
// Output only. The resource name of the creator.
|
||||
// Format: users/{user}
|
||||
string creator = 2 [
|
||||
(google.api.field_behavior) = OUTPUT_ONLY,
|
||||
(google.api.resource_reference) = {type: "memos.api/User"}
|
||||
];
|
||||
|
||||
// Required. The reaction, such as an emoji ("👍", "❤️", "😄").
|
||||
string reaction_type = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Output only. The creation time.
|
||||
google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
}
|
||||
|
||||
// Request message for MemoService.ListMemoReactions.
|
||||
message ListMemoReactionsRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of reactions to return. The service may
|
||||
// return fewer. Currently ignored; all reactions are returned.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token from a previous call. Provide it to retrieve the
|
||||
// next page. Currently ignored.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Response message for MemoService.ListMemoReactions.
|
||||
message ListMemoReactionsResponse {
|
||||
// The reactions.
|
||||
repeated Reaction reactions = 1;
|
||||
|
||||
// A token to retrieve the next page. Empty when there are no more pages.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
// Request message for MemoService.DeleteMemoReaction.
|
||||
message DeleteMemoReactionRequest {
|
||||
// Required. The resource name of the reaction to delete.
|
||||
// Format: memos/{memo}/reactions/{reaction}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Reaction"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for MemoService.UpsertMemoReaction.
|
||||
message UpsertMemoReactionRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
|
||||
// Required. The reaction to upsert. Only reaction_type is used.
|
||||
Reaction reaction = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// MemoShare is an access grant that permits read-only access to a memo via an
|
||||
// opaque bearer token.
|
||||
message MemoShare {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api/MemoShare"
|
||||
pattern: "memos/{memo}/shares/{share}"
|
||||
singular: "memoShare"
|
||||
plural: "memoShares"
|
||||
};
|
||||
|
||||
// Identifier. The resource name of the share. The {share} segment is the
|
||||
// opaque token used in the share URL.
|
||||
// Format: memos/{memo}/shares/{share}
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// Output only. The creation time.
|
||||
google.protobuf.Timestamp create_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Optional. The time after which the share link stops working. Must be in
|
||||
// the future when set. If unset, the link never expires.
|
||||
optional google.protobuf.Timestamp expire_time = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Request message for MemoService.ListMemoShares.
|
||||
message ListMemoSharesRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
}
|
||||
|
||||
// Response message for MemoService.ListMemoShares.
|
||||
message ListMemoSharesResponse {
|
||||
// The share links.
|
||||
repeated MemoShare memo_shares = 1;
|
||||
}
|
||||
|
||||
// Request message for MemoService.CreateMemoShare.
|
||||
message CreateMemoShareRequest {
|
||||
// Required. The resource name of the memo to share.
|
||||
// Format: memos/{memo}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Memo"}
|
||||
];
|
||||
|
||||
// Required. The share to create. Only expire_time is used.
|
||||
MemoShare memo_share = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Request message for MemoService.DeleteMemoShare.
|
||||
message DeleteMemoShareRequest {
|
||||
// Required. The resource name of the share to delete.
|
||||
// Format: memos/{memo}/shares/{share}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/MemoShare"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for MemoService.GetSharedMemo.
|
||||
message GetSharedMemoRequest {
|
||||
// Required. The opaque bearer token from the share URL.
|
||||
string share_token = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// LinkMetadata is the preview metadata of a web link.
|
||||
message LinkMetadata {
|
||||
// The link URL as given in the request.
|
||||
string url = 1;
|
||||
|
||||
// The page title.
|
||||
string title = 2;
|
||||
|
||||
// The page description.
|
||||
string description = 3;
|
||||
|
||||
// The preview image URL.
|
||||
string image = 4;
|
||||
}
|
||||
|
||||
// Request message for MemoService.GetLinkMetadata.
|
||||
message GetLinkMetadataRequest {
|
||||
// Required. The link URL.
|
||||
string url = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Request message for MemoService.BatchGetLinkMetadata.
|
||||
message BatchGetLinkMetadataRequest {
|
||||
// Required. The link URLs. At most 10.
|
||||
repeated string urls = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Response message for MemoService.BatchGetLinkMetadata.
|
||||
message BatchGetLinkMetadataResponse {
|
||||
// The link metadata, in the same order as the requested URLs.
|
||||
repeated LinkMetadata link_metadata = 1;
|
||||
}
|
||||
@@ -0,0 +1,474 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/client.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
import "google/api/resource.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
|
||||
option go_package = "gen/api";
|
||||
|
||||
// SpaceService manages collaborative spaces, their members and their invitations.
|
||||
service SpaceService {
|
||||
// ListSpaces lists the spaces of which the authenticated caller is a member.
|
||||
rpc ListSpaces(ListSpacesRequest) returns (ListSpacesResponse) {
|
||||
option (google.api.http) = {get: "/api/spaces"};
|
||||
option (google.api.method_signature) = "";
|
||||
}
|
||||
|
||||
// GetSpace gets a space of which the authenticated caller is a member.
|
||||
// Spaces the caller is not a member of are reported as not found.
|
||||
rpc GetSpace(GetSpaceRequest) returns (Space) {
|
||||
option (google.api.http) = {get: "/api/{name=spaces/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// CreateSpace creates a space and makes the authenticated caller its first
|
||||
// administrator.
|
||||
rpc CreateSpace(CreateSpaceRequest) returns (Space) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/spaces"
|
||||
body: "space"
|
||||
};
|
||||
option (google.api.method_signature) = "space";
|
||||
}
|
||||
|
||||
// UpdateSpace updates space metadata. Only a space administrator can update
|
||||
// a space.
|
||||
rpc UpdateSpace(UpdateSpaceRequest) returns (Space) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/{space.name=spaces/*}"
|
||||
body: "space"
|
||||
};
|
||||
option (google.api.method_signature) = "space,update_mask";
|
||||
}
|
||||
|
||||
// DeleteSpace permanently deletes a space and every memo currently placed
|
||||
// in it. It never follows memo relations to other memos. Only a space
|
||||
// administrator can delete a space.
|
||||
rpc DeleteSpace(DeleteSpaceRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/{name=spaces/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// ListSpaceMembers lists the members of a space. The caller must be a member
|
||||
// of the space.
|
||||
rpc ListSpaceMembers(ListSpaceMembersRequest) returns (ListSpaceMembersResponse) {
|
||||
option (google.api.http) = {get: "/api/{parent=spaces/*}/members"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// GetSpaceMember gets one membership in a space. The caller must be a member
|
||||
// of the space.
|
||||
rpc GetSpaceMember(GetSpaceMemberRequest) returns (SpaceMember) {
|
||||
option (google.api.http) = {get: "/api/{name=spaces/*/members/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// UpdateSpaceMember changes a member's space role. Only a space administrator
|
||||
// can change roles, and a space must keep at least one administrator.
|
||||
rpc UpdateSpaceMember(UpdateSpaceMemberRequest) returns (SpaceMember) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/{space_member.name=spaces/*/members/*}"
|
||||
body: "space_member"
|
||||
};
|
||||
option (google.api.method_signature) = "space_member,update_mask";
|
||||
}
|
||||
|
||||
// DeleteSpaceMember removes a member. A space administrator can remove any
|
||||
// member, and a member may delete their own membership to leave the space.
|
||||
// A space must keep at least one administrator.
|
||||
rpc DeleteSpaceMember(DeleteSpaceMemberRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/{name=spaces/*/members/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// ListSpaceInvitations lists the pending invitations for a space. Only a
|
||||
// space administrator can list them.
|
||||
rpc ListSpaceInvitations(ListSpaceInvitationsRequest) returns (ListSpaceInvitationsResponse) {
|
||||
option (google.api.http) = {get: "/api/{parent=spaces/*}/invitations"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// ListUserSpaceInvitations lists the authenticated user's pending space
|
||||
// invitations. A user cannot list another user's invitations.
|
||||
rpc ListUserSpaceInvitations(ListUserSpaceInvitationsRequest) returns (ListUserSpaceInvitationsResponse) {
|
||||
option (google.api.http) = {get: "/api/{parent=users/*}/spaceInvitations"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// GetSpaceInvitation gets one pending invitation. Only the invitee or a
|
||||
// space administrator can get it.
|
||||
rpc GetSpaceInvitation(GetSpaceInvitationRequest) returns (SpaceInvitation) {
|
||||
option (google.api.http) = {get: "/api/{name=spaces/*/invitations/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// CreateSpaceInvitation invites an existing active user to a space. Only a
|
||||
// space administrator can invite. The invitee gets no space access until
|
||||
// they accept.
|
||||
rpc CreateSpaceInvitation(CreateSpaceInvitationRequest) returns (SpaceInvitation) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/{parent=spaces/*}/invitations"
|
||||
body: "space_invitation"
|
||||
};
|
||||
option (google.api.method_signature) = "parent,space_invitation";
|
||||
}
|
||||
|
||||
// DeleteSpaceInvitation revokes a pending invitation. Only a space
|
||||
// administrator can revoke it.
|
||||
rpc DeleteSpaceInvitation(DeleteSpaceInvitationRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/{name=spaces/*/invitations/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// AcceptSpaceInvitation accepts a pending invitation and creates a
|
||||
// membership with the invited role. Only the invitee can accept it.
|
||||
rpc AcceptSpaceInvitation(AcceptSpaceInvitationRequest) returns (SpaceMember) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/{name=spaces/*/invitations/*}:accept"
|
||||
body: "*"
|
||||
};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// DeclineSpaceInvitation declines a pending invitation without creating a
|
||||
// membership. Only the invitee can decline it.
|
||||
rpc DeclineSpaceInvitation(DeclineSpaceInvitationRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/{name=spaces/*/invitations/*}:decline"
|
||||
body: "*"
|
||||
};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
}
|
||||
|
||||
// Space is a collaboration boundary for placed memos.
|
||||
message Space {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api/Space"
|
||||
pattern: "spaces/{space}"
|
||||
singular: "space"
|
||||
plural: "spaces"
|
||||
};
|
||||
|
||||
// Identifier. The resource name of the space.
|
||||
// Format: spaces/{space}
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// Required. The human-readable title.
|
||||
string title = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. A description of the space.
|
||||
string description = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The display icon. Omit it when updating with the "icon" mask to
|
||||
// reset to the default space mark.
|
||||
Icon icon = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Output only. The authenticated user's membership role in this space.
|
||||
// ROLE_UNSPECIFIED when this space is exposed as metadata only.
|
||||
SpaceMember.Role current_user_role = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Output only. The number of accepted members in this space. Pending
|
||||
// invitations are excluded. Zero when this space is exposed as metadata only.
|
||||
int32 member_count = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Icon is the display icon of a space.
|
||||
message Icon {
|
||||
// The icon value.
|
||||
oneof value {
|
||||
// A Unicode emoji sequence.
|
||||
string emoji = 1;
|
||||
|
||||
// A canonical Lucide icon name, such as "leaf".
|
||||
string lucide = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Request message for SpaceService.ListSpaces.
|
||||
message ListSpacesRequest {
|
||||
// Optional. The maximum number of spaces to return. The service may return fewer.
|
||||
int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token from a previous call. Provide it to retrieve the next page.
|
||||
string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Response message for SpaceService.ListSpaces.
|
||||
message ListSpacesResponse {
|
||||
// The spaces of which the caller is a member.
|
||||
repeated Space spaces = 1;
|
||||
|
||||
// A token to retrieve the next page. Empty when there are no more pages.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
// Request message for SpaceService.GetSpace.
|
||||
message GetSpaceRequest {
|
||||
// Required. The resource name of the space.
|
||||
// Format: spaces/{space}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Space"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for SpaceService.CreateSpace.
|
||||
message CreateSpaceRequest {
|
||||
// Required. The space to create.
|
||||
Space space = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The ID to use for the space, which becomes the final segment of
|
||||
// its resource name. If empty, a UUID v4 is generated. Must match
|
||||
// ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$.
|
||||
string space_id = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Request message for SpaceService.UpdateSpace.
|
||||
message UpdateSpaceRequest {
|
||||
// Required. The space with updated values. Its name identifies the space to
|
||||
// update.
|
||||
Space space = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The fields to update. Supported paths: title, description, icon.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Request message for SpaceService.DeleteSpace.
|
||||
message DeleteSpaceRequest {
|
||||
// Required. The resource name of the space.
|
||||
// Format: spaces/{space}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/Space"}
|
||||
];
|
||||
}
|
||||
|
||||
// SpaceMember is a user's membership and governance role in a space.
|
||||
message SpaceMember {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api/SpaceMember"
|
||||
pattern: "spaces/{space}/members/{member}"
|
||||
singular: "spaceMember"
|
||||
plural: "spaceMembers"
|
||||
};
|
||||
|
||||
// Identifier. The resource name of the membership. The member segment is
|
||||
// the member's username.
|
||||
// Format: spaces/{space}/members/{member}
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// Required. The member user.
|
||||
// Format: users/{user}
|
||||
string user = 2 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/User"}
|
||||
];
|
||||
|
||||
// Required. The member's role within this space.
|
||||
Role role = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Role is a member's governance role within a space.
|
||||
enum Role {
|
||||
ROLE_UNSPECIFIED = 0;
|
||||
// Can update and delete the space, manage members and manage invitations.
|
||||
ADMIN = 1;
|
||||
// A regular member without governance permissions.
|
||||
USER = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Request message for SpaceService.ListSpaceMembers.
|
||||
message ListSpaceMembersRequest {
|
||||
// Required. The parent space.
|
||||
// Format: spaces/{space}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {child_type: "memos.api/SpaceMember"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of members to return. The service may return fewer.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token from a previous call. Provide it to retrieve the next page.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Response message for SpaceService.ListSpaceMembers.
|
||||
message ListSpaceMembersResponse {
|
||||
// The members of the space.
|
||||
repeated SpaceMember space_members = 1;
|
||||
|
||||
// A token to retrieve the next page. Empty when there are no more pages.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
// Request message for SpaceService.GetSpaceMember.
|
||||
message GetSpaceMemberRequest {
|
||||
// Required. The resource name of the membership.
|
||||
// Format: spaces/{space}/members/{member}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/SpaceMember"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for SpaceService.UpdateSpaceMember.
|
||||
message UpdateSpaceMemberRequest {
|
||||
// Required. The membership with the new role. Its name identifies the
|
||||
// membership to update.
|
||||
SpaceMember space_member = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The fields to update. Must include role. The user path is also
|
||||
// accepted, but the user must match the existing member and is never changed.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Request message for SpaceService.DeleteSpaceMember.
|
||||
message DeleteSpaceMemberRequest {
|
||||
// Required. The resource name of the membership.
|
||||
// Format: spaces/{space}/members/{member}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/SpaceMember"}
|
||||
];
|
||||
}
|
||||
|
||||
// SpaceInvitation is a pending invitation for an existing user to join a space.
|
||||
message SpaceInvitation {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api/SpaceInvitation"
|
||||
pattern: "spaces/{space}/invitations/{invitation}"
|
||||
singular: "spaceInvitation"
|
||||
plural: "spaceInvitations"
|
||||
};
|
||||
|
||||
// Identifier. The resource name of the invitation. The invitation segment
|
||||
// is the invitee's username.
|
||||
// Format: spaces/{space}/invitations/{invitation}
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// Required. The invited user.
|
||||
// Format: users/{user}
|
||||
string invitee = 2 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/User"}
|
||||
];
|
||||
|
||||
// Required. The role the user receives after accepting the invitation.
|
||||
SpaceMember.Role role = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Output only. The space the user is invited to, as metadata only. This lets
|
||||
// an invitee understand the invitation without membership-based GetSpace
|
||||
// access.
|
||||
Space space = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
}
|
||||
|
||||
// Request message for SpaceService.ListSpaceInvitations.
|
||||
message ListSpaceInvitationsRequest {
|
||||
// Required. The parent space.
|
||||
// Format: spaces/{space}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {child_type: "memos.api/SpaceInvitation"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of invitations to return. The service may return fewer.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token from a previous call. Provide it to retrieve the next page.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Response message for SpaceService.ListSpaceInvitations.
|
||||
message ListSpaceInvitationsResponse {
|
||||
// The pending invitations for the space.
|
||||
repeated SpaceInvitation space_invitations = 1;
|
||||
|
||||
// A token to retrieve the next page. Empty when there are no more pages.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
// Request message for SpaceService.ListUserSpaceInvitations.
|
||||
message ListUserSpaceInvitationsRequest {
|
||||
// Required. The user whose invitations to list. Must be the authenticated
|
||||
// user.
|
||||
// Format: users/{user}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/User"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of invitations to return. The service may return fewer.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token from a previous call. Provide it to retrieve the next page.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Response message for SpaceService.ListUserSpaceInvitations.
|
||||
message ListUserSpaceInvitationsResponse {
|
||||
// The pending invitations received by the user.
|
||||
repeated SpaceInvitation space_invitations = 1;
|
||||
|
||||
// A token to retrieve the next page. Empty when there are no more pages.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
// Request message for SpaceService.GetSpaceInvitation.
|
||||
message GetSpaceInvitationRequest {
|
||||
// Required. The resource name of the invitation.
|
||||
// Format: spaces/{space}/invitations/{invitation}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/SpaceInvitation"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for SpaceService.CreateSpaceInvitation.
|
||||
message CreateSpaceInvitationRequest {
|
||||
// Required. The parent space.
|
||||
// Format: spaces/{space}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {child_type: "memos.api/SpaceInvitation"}
|
||||
];
|
||||
|
||||
// Required. The invitation to create. The role must be ADMIN or USER.
|
||||
SpaceInvitation space_invitation = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Request message for SpaceService.DeleteSpaceInvitation.
|
||||
message DeleteSpaceInvitationRequest {
|
||||
// Required. The resource name of the invitation.
|
||||
// Format: spaces/{space}/invitations/{invitation}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/SpaceInvitation"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for SpaceService.AcceptSpaceInvitation.
|
||||
message AcceptSpaceInvitationRequest {
|
||||
// Required. The resource name of the invitation.
|
||||
// Format: spaces/{space}/invitations/{invitation}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/SpaceInvitation"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for SpaceService.DeclineSpaceInvitation.
|
||||
message DeclineSpaceInvitationRequest {
|
||||
// Required. The resource name of the invitation.
|
||||
// Format: spaces/{space}/invitations/{invitation}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api/SpaceInvitation"}
|
||||
];
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +0,0 @@
|
||||
# Memos API Design
|
||||
|
||||
This API design should follow the guidelines and best practices outlined in the [Google API Improvement Proposals (AIPs)](https://google.aip.dev/).
|
||||
@@ -1,46 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api.v1;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/client.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
|
||||
option go_package = "gen/api/v1";
|
||||
|
||||
service AIService {
|
||||
// Transcribe transcribes an audio file using an instance AI provider.
|
||||
rpc Transcribe(TranscribeRequest) returns (TranscribeResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/ai:transcribe"
|
||||
body: "*"
|
||||
};
|
||||
option (google.api.method_signature) = "audio";
|
||||
}
|
||||
}
|
||||
|
||||
message TranscribeRequest {
|
||||
// Required. Audio input.
|
||||
TranscriptionAudio audio = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message TranscriptionAudio {
|
||||
oneof source {
|
||||
// Inline audio bytes.
|
||||
bytes content = 1 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
|
||||
// URI for audio content. Reserved for future use.
|
||||
string uri = 2;
|
||||
}
|
||||
|
||||
// Optional. The uploaded filename.
|
||||
string filename = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The MIME type of the input audio.
|
||||
string content_type = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message TranscribeResponse {
|
||||
// The transcribed text.
|
||||
string text = 1;
|
||||
}
|
||||
@@ -1,322 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api.v1;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/client.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
import "google/api/resource.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "gen/api/v1";
|
||||
|
||||
service AttachmentService {
|
||||
// CreateAttachment creates a new attachment.
|
||||
rpc CreateAttachment(CreateAttachmentRequest) returns (Attachment) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/attachments"
|
||||
body: "attachment"
|
||||
};
|
||||
option (google.api.method_signature) = "attachment";
|
||||
}
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries
|
||||
// the spec and returns an upload_id; later calls carry that upload_id.
|
||||
// Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// inactivity, and do not survive a server restart.
|
||||
rpc UploadAttachment(UploadAttachmentRequest) returns (UploadAttachmentResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/attachments:upload"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
// ListAttachments lists attachments linked to readable memos and the caller's unlinked uploads.
|
||||
rpc ListAttachments(ListAttachmentsRequest) returns (ListAttachmentsResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/attachments"};
|
||||
}
|
||||
// GetAttachment returns an attachment by name.
|
||||
rpc GetAttachment(GetAttachmentRequest) returns (Attachment) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=attachments/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// UpdateAttachment updates an attachment.
|
||||
rpc UpdateAttachment(UpdateAttachmentRequest) returns (Attachment) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/v1/{attachment.name=attachments/*}"
|
||||
body: "attachment"
|
||||
};
|
||||
option (google.api.method_signature) = "attachment,update_mask";
|
||||
}
|
||||
// DeleteAttachment deletes an attachment by name.
|
||||
rpc DeleteAttachment(DeleteAttachmentRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/v1/{name=attachments/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// BatchDeleteAttachments deletes multiple attachments in one request.
|
||||
rpc BatchDeleteAttachments(BatchDeleteAttachmentsRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/attachments:batchDelete"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
enum MotionMediaFamily {
|
||||
MOTION_MEDIA_FAMILY_UNSPECIFIED = 0;
|
||||
APPLE_LIVE_PHOTO = 1;
|
||||
ANDROID_MOTION_PHOTO = 2;
|
||||
}
|
||||
|
||||
enum MotionMediaRole {
|
||||
MOTION_MEDIA_ROLE_UNSPECIFIED = 0;
|
||||
STILL = 1;
|
||||
VIDEO = 2;
|
||||
CONTAINER = 3;
|
||||
}
|
||||
|
||||
message MotionMedia {
|
||||
MotionMediaFamily family = 1;
|
||||
MotionMediaRole role = 2;
|
||||
string group_id = 3;
|
||||
int64 presentation_timestamp_us = 4;
|
||||
bool has_embedded_video = 5;
|
||||
}
|
||||
|
||||
// MediaMetadata contains normalized metadata explicitly supplied by a client.
|
||||
// The server validates and stores this data but does not extract it from the media file.
|
||||
message MediaMetadata {
|
||||
// Optional. Display-oriented width in pixels.
|
||||
optional int32 width = 1;
|
||||
// Optional. Display-oriented height in pixels.
|
||||
optional int32 height = 2;
|
||||
|
||||
oneof details {
|
||||
PhotoMetadata photo = 3;
|
||||
VideoMetadata video = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message PhotoMetadata {
|
||||
// Optional. Capture time as recorded by the source media.
|
||||
MediaCaptureTime capture_time = 1;
|
||||
// Optional. Geographic location recorded by the source media.
|
||||
MediaLocation location = 2;
|
||||
// Optional. EXIF orientation value from 1 through 8 as recorded by the source file.
|
||||
// This value is informational and must not be reapplied to the stored attachment;
|
||||
// width and height already describe its display-oriented dimensions.
|
||||
optional int32 source_exif_orientation = 3;
|
||||
string camera_make = 4;
|
||||
string camera_model = 5;
|
||||
string lens_model = 6;
|
||||
optional double f_number = 7;
|
||||
optional double exposure_time_seconds = 8;
|
||||
optional int32 iso = 9;
|
||||
optional double focal_length_mm = 10;
|
||||
}
|
||||
|
||||
message MediaCaptureTime {
|
||||
// Local date and time without a time zone, formatted as YYYY-MM-DDTHH:mm:ss[.fraction].
|
||||
string local_date_time = 1;
|
||||
// Optional. UTC offset formatted as Z or +/-HH:MM.
|
||||
optional string utc_offset = 2;
|
||||
}
|
||||
|
||||
message MediaLocation {
|
||||
// Optional. WGS84 latitude in decimal degrees. Must be provided with longitude.
|
||||
optional double latitude = 1;
|
||||
// Optional. WGS84 longitude in decimal degrees. Must be provided with latitude.
|
||||
optional double longitude = 2;
|
||||
// Optional. Signed altitude in meters relative to sea level.
|
||||
optional double altitude_meters = 3;
|
||||
}
|
||||
|
||||
message VideoMetadata {
|
||||
optional double duration_seconds = 1;
|
||||
}
|
||||
|
||||
message Attachment {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api.v1/Attachment"
|
||||
pattern: "attachments/{attachment}"
|
||||
singular: "attachment"
|
||||
plural: "attachments"
|
||||
};
|
||||
|
||||
// The name of the attachment.
|
||||
// Format: attachments/{attachment}
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// Output only. The creation timestamp.
|
||||
google.protobuf.Timestamp create_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// The filename of the attachment.
|
||||
string filename = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Input only. The content of the attachment.
|
||||
bytes content = 4 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
|
||||
// Optional. The external link of the attachment.
|
||||
string external_link = 5 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// The MIME type of the attachment.
|
||||
string type = 6 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Output only. The size of the attachment in bytes.
|
||||
int64 size = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Optional. The related memo. Refer to `Memo.name`.
|
||||
// Format: memos/{memo}
|
||||
optional string memo = 8 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Motion media metadata.
|
||||
MotionMedia motion_media = 9 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Immutable normalized media metadata explicitly supplied by the client at creation time.
|
||||
MediaMetadata media_metadata = 10 [
|
||||
(google.api.field_behavior) = OPTIONAL,
|
||||
(google.api.field_behavior) = IMMUTABLE
|
||||
];
|
||||
|
||||
// Output only. The user who uploaded this attachment, which may differ from
|
||||
// the creator of the linked memo. Format: users/{user}.
|
||||
string creator = 11 [
|
||||
(google.api.field_behavior) = OUTPUT_ONLY,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/User"}
|
||||
];
|
||||
}
|
||||
|
||||
message CreateAttachmentRequest {
|
||||
// Required. The attachment to create.
|
||||
Attachment attachment = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The attachment ID to use for this attachment.
|
||||
// If empty, a unique ID will be generated.
|
||||
// Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$
|
||||
string attachment_id = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message UploadAttachmentRequest {
|
||||
// Required. Start a new upload or continue an existing one.
|
||||
oneof upload {
|
||||
// Starts a new upload. The same call may also carry data and finish_write.
|
||||
UploadAttachmentSpec spec = 1;
|
||||
|
||||
// Continues the upload identified by a previous response.
|
||||
string upload_id = 2;
|
||||
}
|
||||
|
||||
// Required. Zero-based byte offset at which data is written. Must equal the
|
||||
// committed size, except when retrying the most recently accepted chunk
|
||||
// with identical bytes and offset, which is accepted without writing again.
|
||||
int64 write_offset = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. File bytes, at most max_chunk_size long. With no data and
|
||||
// finish_write false, the call reports progress without writing, and
|
||||
// write_offset is ignored.
|
||||
bytes data = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Finalize the upload after writing data. The committed size must
|
||||
// then equal total_size. Any later call for the same upload_id returns the
|
||||
// created attachment.
|
||||
bool finish_write = 5 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message UploadAttachmentSpec {
|
||||
// Required. Metadata for the attachment to create. content must be empty;
|
||||
// file bytes are sent in data.
|
||||
Attachment attachment = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The attachment ID to use for this attachment.
|
||||
// If empty, a unique ID will be generated.
|
||||
// Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$
|
||||
string attachment_id = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Total size of the file in bytes before media processing.
|
||||
// Zero represents an empty file.
|
||||
int64 total_size = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message UploadAttachmentResponse {
|
||||
// Opaque ID for subsequent calls. This is not a resource name.
|
||||
string upload_id = 1;
|
||||
|
||||
// Number of file bytes committed so far.
|
||||
int64 committed_size = 2;
|
||||
|
||||
// Set once the upload has been finalized.
|
||||
Attachment attachment = 3;
|
||||
|
||||
// Maximum number of data bytes accepted in one call.
|
||||
int32 max_chunk_size = 4;
|
||||
}
|
||||
|
||||
message ListAttachmentsRequest {
|
||||
// Optional. The maximum number of attachments to return.
|
||||
// The service may return fewer than this value.
|
||||
// If unspecified, at most 50 attachments will be returned.
|
||||
// The maximum value is 1000; values above 1000 will be coerced to 1000.
|
||||
int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token, received from a previous `ListAttachments` call.
|
||||
// Provide this to retrieve the subsequent page.
|
||||
string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Filter to apply to the list results.
|
||||
// Example: "mime_type==\"image/png\"" or "filename.contains(\"test\")"
|
||||
// Supported operators: =, !=, <, <=, >, >=, : (contains), in
|
||||
// Supported fields: creator, filename, mime_type, create_time, memo_id, space.
|
||||
// `creator` is the linked memo's creator, or the uploader for an unlinked
|
||||
// attachment. It supports equality with a User resource name.
|
||||
// `space` only supports a non-negated `==` comparison with a Space resource
|
||||
// name or null.
|
||||
// `space` is the linked memo's space resource name, or null when the
|
||||
// attachment is unlinked or its linked memo has no space.
|
||||
string filter = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The order to sort results by.
|
||||
// Example: "create_time desc" or "filename asc"
|
||||
string order_by = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
reserved 5, 6;
|
||||
reserved "space", "unassigned";
|
||||
}
|
||||
|
||||
message ListAttachmentsResponse {
|
||||
// The list of attachments.
|
||||
repeated Attachment attachments = 1;
|
||||
|
||||
// A token that can be sent as `page_token` to retrieve the next page.
|
||||
// If this field is omitted, there are no subsequent pages.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
message GetAttachmentRequest {
|
||||
// Required. The attachment name of the attachment to retrieve.
|
||||
// Format: attachments/{attachment}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Attachment"}
|
||||
];
|
||||
}
|
||||
|
||||
message UpdateAttachmentRequest {
|
||||
// Required. The attachment which replaces the attachment on the server.
|
||||
Attachment attachment = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The list of fields to update.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message DeleteAttachmentRequest {
|
||||
// Required. The attachment name of the attachment to delete.
|
||||
// Format: attachments/{attachment}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Attachment"}
|
||||
];
|
||||
}
|
||||
|
||||
message BatchDeleteAttachmentsRequest {
|
||||
repeated string names = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api.v1;
|
||||
|
||||
import "api/v1/user_service.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "gen/api/v1";
|
||||
|
||||
service AuthService {
|
||||
// GetCurrentUser returns the authenticated user's information.
|
||||
// Validates the access token and returns user details.
|
||||
// Similar to OIDC's /userinfo endpoint.
|
||||
rpc GetCurrentUser(GetCurrentUserRequest) returns (GetCurrentUserResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/auth/me"};
|
||||
}
|
||||
|
||||
// SignIn authenticates a user with credentials and returns tokens.
|
||||
// On success, returns an access token and sets a refresh token cookie.
|
||||
// Supports password-based and SSO authentication methods.
|
||||
rpc SignIn(SignInRequest) returns (SignInResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/auth/signin"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
// SignOut terminates the user's authentication.
|
||||
// Revokes the refresh token and clears the authentication cookie.
|
||||
rpc SignOut(SignOutRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {post: "/api/v1/auth/signout"};
|
||||
}
|
||||
|
||||
// RefreshToken exchanges a valid refresh token for a new access token.
|
||||
// The refresh token is read from the HttpOnly cookie.
|
||||
// Returns a new short-lived access token.
|
||||
rpc RefreshToken(RefreshTokenRequest) returns (RefreshTokenResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/auth/refresh"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
message GetCurrentUserRequest {}
|
||||
|
||||
message GetCurrentUserResponse {
|
||||
// The authenticated user's information.
|
||||
User user = 1;
|
||||
}
|
||||
|
||||
message SignInRequest {
|
||||
// Nested message for password-based authentication credentials.
|
||||
message PasswordCredentials {
|
||||
// The username to sign in with.
|
||||
string username = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// The password to sign in with.
|
||||
string password = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// Nested message for SSO authentication credentials.
|
||||
message SSOCredentials {
|
||||
// The resource name of the SSO provider.
|
||||
// Format: identity-providers/{idp}
|
||||
string idp_name = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// The authorization code from the SSO provider.
|
||||
string code = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// The redirect URI used in the SSO flow.
|
||||
string redirect_uri = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// The PKCE code verifier for enhanced security (RFC 7636).
|
||||
// Optional - enables PKCE flow protection against authorization code interception.
|
||||
string code_verifier = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Authentication credentials. Provide one method.
|
||||
oneof credentials {
|
||||
// Username and password authentication.
|
||||
PasswordCredentials password_credentials = 1;
|
||||
|
||||
// SSO provider authentication.
|
||||
SSOCredentials sso_credentials = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message SignInResponse {
|
||||
// The authenticated user's information.
|
||||
User user = 1;
|
||||
|
||||
// The short-lived access token for API requests.
|
||||
// Store in memory only, not in localStorage.
|
||||
string access_token = 2;
|
||||
|
||||
// When the access token expires.
|
||||
// Client should call RefreshToken before this time.
|
||||
google.protobuf.Timestamp access_token_expires_at = 3;
|
||||
}
|
||||
|
||||
message SignOutRequest {}
|
||||
|
||||
message RefreshTokenRequest {}
|
||||
|
||||
message RefreshTokenResponse {
|
||||
// The new short-lived access token.
|
||||
string access_token = 1;
|
||||
|
||||
// When the access token expires.
|
||||
google.protobuf.Timestamp expires_at = 2;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api.v1;
|
||||
|
||||
option go_package = "gen/api/v1";
|
||||
|
||||
enum State {
|
||||
STATE_UNSPECIFIED = 0;
|
||||
NORMAL = 1;
|
||||
ARCHIVED = 2;
|
||||
}
|
||||
|
||||
// Used internally for obfuscating the page token.
|
||||
message PageToken {
|
||||
int32 limit = 1;
|
||||
int32 offset = 2;
|
||||
}
|
||||
|
||||
enum Direction {
|
||||
DIRECTION_UNSPECIFIED = 0;
|
||||
ASC = 1;
|
||||
DESC = 2;
|
||||
}
|
||||
@@ -1,431 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api.v1;
|
||||
|
||||
import "api/v1/user_service.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/client.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
import "google/api/resource.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/type/color.proto";
|
||||
|
||||
option go_package = "gen/api/v1";
|
||||
|
||||
service InstanceService {
|
||||
// Gets the instance profile.
|
||||
rpc GetInstanceProfile(GetInstanceProfileRequest) returns (InstanceProfile) {
|
||||
option (google.api.http) = {get: "/api/v1/instance/profile"};
|
||||
}
|
||||
|
||||
// Gets an instance setting.
|
||||
rpc GetInstanceSetting(GetInstanceSettingRequest) returns (InstanceSetting) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=instance/settings/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// Batch gets instance settings.
|
||||
rpc BatchGetInstanceSettings(BatchGetInstanceSettingsRequest) returns (BatchGetInstanceSettingsResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/instance/settings:batchGet"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
// Updates an instance setting.
|
||||
rpc UpdateInstanceSetting(UpdateInstanceSettingRequest) returns (InstanceSetting) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/v1/{setting.name=instance/settings/*}"
|
||||
body: "setting"
|
||||
};
|
||||
option (google.api.method_signature) = "setting,update_mask";
|
||||
}
|
||||
|
||||
// Tests notification email delivery with the provided or stored SMTP settings.
|
||||
rpc TestInstanceEmailSetting(TestInstanceEmailSettingRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/instance/settings/notification:testEmail"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
// GetInstanceStats returns resource usage statistics for the instance. Admin only.
|
||||
rpc GetInstanceStats(GetInstanceStatsRequest) returns (InstanceStats) {
|
||||
option (google.api.http) = {get: "/api/v1/instance/stats"};
|
||||
}
|
||||
}
|
||||
|
||||
// InstanceAccessMode controls whether unauthenticated users may access instance content.
|
||||
enum InstanceAccessMode {
|
||||
INSTANCE_ACCESS_MODE_UNSPECIFIED = 0;
|
||||
INSTANCE_ACCESS_MODE_PRIVATE = 1;
|
||||
INSTANCE_ACCESS_MODE_PUBLIC = 2;
|
||||
}
|
||||
|
||||
// Instance profile message containing basic instance information.
|
||||
message InstanceProfile {
|
||||
// Version is the current version of instance.
|
||||
string version = 2;
|
||||
|
||||
// Demo indicates if the instance is in demo mode.
|
||||
bool demo = 3;
|
||||
|
||||
// Instance URL is the URL of the instance.
|
||||
string instance_url = 6;
|
||||
|
||||
// The first administrator who set up this instance, for display purposes.
|
||||
// May be null on an instance that has lost all admins; use needs_setup to
|
||||
// determine whether initial setup is actually required.
|
||||
User admin = 7;
|
||||
|
||||
// Commit is the current build commit of instance.
|
||||
string commit = 8;
|
||||
|
||||
// NeedsSetup is true when the instance has no users yet and requires initial
|
||||
// setup (creating the first admin account). Unlike a null admin, this stays
|
||||
// false once any user exists, so an instance that has lost its admins is not
|
||||
// mistaken for a fresh install.
|
||||
bool needs_setup = 9;
|
||||
|
||||
// Access mode controls whether unauthenticated users may access instance content.
|
||||
InstanceAccessMode access_mode = 10;
|
||||
|
||||
// A proof-of-humanity challenge the deployment requires on signup and
|
||||
// password sign-in. Absent when none is configured, which is the case on
|
||||
// every self-hosted instance.
|
||||
message Challenge {
|
||||
// The challenge provider, which selects the widget the web app renders.
|
||||
string provider = 1;
|
||||
// The provider's public site key for the widget.
|
||||
string site_key = 2;
|
||||
}
|
||||
Challenge challenge = 11;
|
||||
}
|
||||
|
||||
// Request for instance profile.
|
||||
message GetInstanceProfileRequest {}
|
||||
|
||||
// An instance setting resource.
|
||||
message InstanceSetting {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api.v1/InstanceSetting"
|
||||
pattern: "instance/settings/{setting}"
|
||||
singular: "instanceSetting"
|
||||
plural: "instanceSettings"
|
||||
};
|
||||
|
||||
// The name of the instance setting.
|
||||
// Format: instance/settings/{setting}
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
oneof value {
|
||||
GeneralSetting general_setting = 2;
|
||||
StorageSetting storage_setting = 3;
|
||||
MemoRelatedSetting memo_related_setting = 4;
|
||||
TagsSetting tags_setting = 5;
|
||||
NotificationSetting notification_setting = 6;
|
||||
AISetting ai_setting = 7;
|
||||
AccessSetting access_setting = 8;
|
||||
}
|
||||
|
||||
// Enumeration of instance setting keys.
|
||||
enum Key {
|
||||
KEY_UNSPECIFIED = 0;
|
||||
// GENERAL is the key for general settings.
|
||||
GENERAL = 1;
|
||||
// STORAGE is the key for storage settings.
|
||||
STORAGE = 2;
|
||||
// MEMO_RELATED is the key for memo related settings.
|
||||
MEMO_RELATED = 3;
|
||||
// TAGS is the key for tag metadata.
|
||||
TAGS = 4;
|
||||
// NOTIFICATION is the key for notification transport settings.
|
||||
NOTIFICATION = 5;
|
||||
// AI is the key for AI provider settings.
|
||||
AI = 6;
|
||||
// ACCESS is the key for instance access policy settings.
|
||||
ACCESS = 7;
|
||||
}
|
||||
|
||||
// General instance settings configuration.
|
||||
message GeneralSetting {
|
||||
// disallow_user_registration disallows user registration.
|
||||
bool disallow_user_registration = 2;
|
||||
// disallow_password_auth disallows password authentication.
|
||||
bool disallow_password_auth = 3;
|
||||
// additional_script is the additional script.
|
||||
string additional_script = 4;
|
||||
// additional_style is the additional style.
|
||||
string additional_style = 5;
|
||||
// custom_profile is the custom profile.
|
||||
CustomProfile custom_profile = 6;
|
||||
// week_start_day_offset is the week start day offset from Sunday.
|
||||
// 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday
|
||||
// Default is Sunday.
|
||||
int32 week_start_day_offset = 7;
|
||||
|
||||
// disallow_change_username disallows changing username.
|
||||
bool disallow_change_username = 8;
|
||||
// disallow_change_nickname disallows changing nickname.
|
||||
bool disallow_change_nickname = 9;
|
||||
|
||||
// Custom profile configuration for instance branding.
|
||||
message CustomProfile {
|
||||
string title = 1;
|
||||
string description = 2;
|
||||
string logo_url = 3;
|
||||
}
|
||||
}
|
||||
|
||||
enum StorageType {
|
||||
STORAGE_TYPE_UNSPECIFIED = 0;
|
||||
// DATABASE stores attachment content in the application database.
|
||||
DATABASE = 1;
|
||||
// LOCAL stores attachment content on the local filesystem.
|
||||
LOCAL = 2;
|
||||
// S3 stores attachment content in an S3-compatible object store.
|
||||
S3 = 3;
|
||||
}
|
||||
|
||||
// Storage is a configured attachment storage instance.
|
||||
message Storage {
|
||||
// id is the stable identifier referenced by attachments.
|
||||
string id = 1;
|
||||
// name is the human-readable storage name.
|
||||
string name = 2;
|
||||
StorageType type = 3;
|
||||
|
||||
oneof config {
|
||||
S3Config s3_config = 10;
|
||||
}
|
||||
|
||||
// S3 configuration for an S3-compatible object store.
|
||||
// Reference: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/
|
||||
message S3Config {
|
||||
string access_key_id = 1;
|
||||
string access_key_secret = 2 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
string endpoint = 3;
|
||||
string region = 4;
|
||||
string bucket = 5;
|
||||
bool use_path_style = 6;
|
||||
// insecure_skip_tls_verify disables TLS certificate verification when connecting
|
||||
// to the S3 endpoint. Only enable this for trusted endpoints that use a self-signed
|
||||
// certificate; it removes protection against man-in-the-middle attacks.
|
||||
bool insecure_skip_tls_verify = 7;
|
||||
}
|
||||
}
|
||||
|
||||
// Storage configuration settings for instance attachments.
|
||||
message StorageSetting {
|
||||
// Legacy storage type enum retained for compatibility with existing clients.
|
||||
enum StorageType {
|
||||
STORAGE_TYPE_UNSPECIFIED = 0;
|
||||
// DATABASE is the database storage type.
|
||||
DATABASE = 1;
|
||||
// LOCAL is the local storage type.
|
||||
LOCAL = 2;
|
||||
// S3 is the S3 storage type.
|
||||
S3 = 3;
|
||||
}
|
||||
// Legacy compatibility field. New clients use default_storage_id.
|
||||
StorageType storage_type = 1;
|
||||
// The template of file path.
|
||||
// e.g. assets/{timestamp}_{filename}
|
||||
string filepath_template = 2;
|
||||
// The max upload size in megabytes.
|
||||
int64 upload_size_limit_mb = 3;
|
||||
|
||||
// Legacy S3 configuration retained for compatibility with existing clients.
|
||||
// Reference: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/
|
||||
message S3Config {
|
||||
string access_key_id = 1;
|
||||
string access_key_secret = 2 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
string endpoint = 3;
|
||||
string region = 4;
|
||||
string bucket = 5;
|
||||
bool use_path_style = 6;
|
||||
// insecure_skip_tls_verify disables TLS certificate verification when connecting
|
||||
// to the S3 endpoint. Only enable this for trusted endpoints that use a self-signed
|
||||
// certificate; it removes protection against man-in-the-middle attacks.
|
||||
bool insecure_skip_tls_verify = 7;
|
||||
}
|
||||
// Legacy compatibility field. New clients use storages.
|
||||
S3Config s3_config = 4;
|
||||
// Configured storage instances, including inactive instances referenced by attachments.
|
||||
repeated Storage storages = 5;
|
||||
// Storage used for new attachments.
|
||||
string default_storage_id = 6;
|
||||
}
|
||||
|
||||
// Memo-related instance settings and policies.
|
||||
message MemoRelatedSetting {
|
||||
reserved 2;
|
||||
reserved "display_with_update_time";
|
||||
// content_length_limit is the limit of content length. Unit is byte.
|
||||
int32 content_length_limit = 3;
|
||||
// enable_double_click_edit enables editing on double click.
|
||||
bool enable_double_click_edit = 4;
|
||||
// reactions is the list of reactions.
|
||||
repeated string reactions = 7;
|
||||
}
|
||||
|
||||
// Metadata for a tag.
|
||||
message TagMetadata {
|
||||
// Optional background color for the tag label.
|
||||
// When unset, the default tag color is used.
|
||||
google.type.Color background_color = 1;
|
||||
// Whether memos with this tag should have their content blurred.
|
||||
bool blur_content = 2;
|
||||
}
|
||||
|
||||
// Tag metadata configuration.
|
||||
// Active tag metadata is stored in per-user tag settings.
|
||||
// This message remains for backward compatibility with existing clients and migrations.
|
||||
message TagsSetting {
|
||||
// Map of tag name pattern to tag metadata.
|
||||
// Each key is treated as an anchored regular expression (^pattern$),
|
||||
// so a single entry like "project/.*" matches all tags under that prefix.
|
||||
// Exact tag names are also valid (they are trivially valid regex patterns).
|
||||
map<string, TagMetadata> tags = 1;
|
||||
}
|
||||
|
||||
// Notification transport configuration.
|
||||
message NotificationSetting {
|
||||
EmailSetting email = 1;
|
||||
|
||||
// Email delivery configuration for notifications.
|
||||
message EmailSetting {
|
||||
bool enabled = 1;
|
||||
string smtp_host = 2;
|
||||
int32 smtp_port = 3;
|
||||
string smtp_username = 4;
|
||||
string smtp_password = 5 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
string from_email = 6;
|
||||
string from_name = 7;
|
||||
string reply_to = 8;
|
||||
bool use_tls = 9;
|
||||
bool use_ssl = 10;
|
||||
}
|
||||
}
|
||||
|
||||
// AI provider configuration settings.
|
||||
message AISetting {
|
||||
// providers is the list of AI provider configurations available instance-wide.
|
||||
repeated AIProviderConfig providers = 1;
|
||||
|
||||
// transcription is the speech-to-text feature configuration.
|
||||
// When unset or transcription.provider_id is empty, transcription is disabled.
|
||||
TranscriptionConfig transcription = 2;
|
||||
}
|
||||
|
||||
// AIProviderConfig represents one callable AI provider connection.
|
||||
message AIProviderConfig {
|
||||
string id = 1;
|
||||
string title = 2;
|
||||
AIProviderType type = 3;
|
||||
string endpoint = 4;
|
||||
// api_key is write-only and is never returned by GetInstanceSetting.
|
||||
string api_key = 5 [(google.api.field_behavior) = INPUT_ONLY];
|
||||
// api_key_set indicates whether an API key is stored for this provider.
|
||||
bool api_key_set = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
// api_key_hint is a masked hint for the stored API key.
|
||||
string api_key_hint = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
}
|
||||
|
||||
// AIProviderType is the provider implementation type.
|
||||
enum AIProviderType {
|
||||
AI_PROVIDER_TYPE_UNSPECIFIED = 0;
|
||||
OPENAI = 1;
|
||||
GEMINI = 2;
|
||||
}
|
||||
|
||||
// TranscriptionConfig configures the speech-to-text feature.
|
||||
message TranscriptionConfig {
|
||||
// provider_id references an entry in AISetting.providers[].id.
|
||||
// Empty string means transcription is disabled.
|
||||
string provider_id = 1;
|
||||
|
||||
// model is the provider-specific model identifier.
|
||||
// Empty string falls back to the engine default
|
||||
// (whisper-1 for OPENAI providers, gemini-2.5-flash for GEMINI providers).
|
||||
string model = 2;
|
||||
|
||||
// language is the default ISO 639-1 language hint sent to the provider.
|
||||
// Empty string lets the provider auto-detect.
|
||||
string language = 3;
|
||||
|
||||
// prompt is a default spelling/vocabulary hint passed to the provider.
|
||||
string prompt = 4;
|
||||
}
|
||||
|
||||
// Access policy configuration for the instance.
|
||||
message AccessSetting {
|
||||
InstanceAccessMode access_mode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Request message for GetInstanceSetting method.
|
||||
message GetInstanceSettingRequest {
|
||||
// The resource name of the instance setting.
|
||||
// Format: instance/settings/{setting}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/InstanceSetting"}
|
||||
];
|
||||
}
|
||||
|
||||
// Request message for BatchGetInstanceSettings method.
|
||||
message BatchGetInstanceSettingsRequest {
|
||||
// The resource names of the instance settings.
|
||||
// Format: instance/settings/{setting}
|
||||
repeated string names = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/InstanceSetting"}
|
||||
];
|
||||
}
|
||||
|
||||
// Response message for BatchGetInstanceSettings method.
|
||||
message BatchGetInstanceSettingsResponse {
|
||||
// The instance settings in the same order as the input names.
|
||||
repeated InstanceSetting settings = 1;
|
||||
}
|
||||
|
||||
// Request message for UpdateInstanceSetting method.
|
||||
message UpdateInstanceSettingRequest {
|
||||
// The instance setting resource which replaces the resource on the server.
|
||||
InstanceSetting setting = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// The list of fields to update.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Request message for TestInstanceEmailSetting method.
|
||||
message TestInstanceEmailSettingRequest {
|
||||
// Optional. SMTP email settings to test. If omitted, the stored notification email setting is used.
|
||||
InstanceSetting.NotificationSetting.EmailSetting email = 1 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Recipient email address. If omitted, the current user's email address is used.
|
||||
string recipient_email = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Request message for GetInstanceStats.
|
||||
message GetInstanceStatsRequest {}
|
||||
|
||||
// Resource usage statistics for the instance.
|
||||
message InstanceStats {
|
||||
DatabaseStats database = 1;
|
||||
// Recursive size of the data directory in bytes. -1 if unavailable.
|
||||
int64 local_storage_bytes = 2;
|
||||
// Server-side timestamp when the snapshot was generated.
|
||||
google.protobuf.Timestamp generated_time = 4;
|
||||
|
||||
// Database size statistics.
|
||||
message DatabaseStats {
|
||||
// driver is one of "sqlite", "mysql", "postgres".
|
||||
string driver = 1;
|
||||
// size_bytes is the database size in bytes; -1 if unavailable.
|
||||
int64 size_bytes = 2;
|
||||
}
|
||||
}
|
||||
@@ -1,677 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api.v1;
|
||||
|
||||
import "api/v1/attachment_service.proto";
|
||||
import "api/v1/common.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/client.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
import "google/api/resource.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "gen/api/v1";
|
||||
|
||||
service MemoService {
|
||||
// CreateMemo creates a memo. The request body is a Memo; set its content
|
||||
// (Markdown) and visibility (PRIVATE | PROTECTED | PUBLIC | SPACE,
|
||||
// default PRIVATE).
|
||||
// The memo is owned by the authenticated user; requires authentication.
|
||||
rpc CreateMemo(CreateMemoRequest) returns (Memo) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/memos"
|
||||
body: "memo"
|
||||
};
|
||||
option (google.api.method_signature) = "memo";
|
||||
}
|
||||
// ListMemos lists readable non-comment memos with pagination and filter.
|
||||
rpc ListMemos(ListMemosRequest) returns (ListMemosResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/memos"};
|
||||
option (google.api.method_signature) = "";
|
||||
}
|
||||
// GetMemo gets a memo.
|
||||
rpc GetMemo(GetMemoRequest) returns (Memo) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=memos/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// UpdateMemo updates a memo.
|
||||
rpc UpdateMemo(UpdateMemoRequest) returns (Memo) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/v1/{memo.name=memos/*}"
|
||||
body: "memo"
|
||||
};
|
||||
option (google.api.method_signature) = "memo,update_mask";
|
||||
}
|
||||
// DeleteMemo deletes the named memo and its comment subtree, including nested
|
||||
// replies and their owned resources. It removes incident relations for all
|
||||
// deleted memos.
|
||||
rpc DeleteMemo(DeleteMemoRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/v1/{name=memos/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// SetMemoAttachments replaces the full set of attachments on a memo with the
|
||||
// provided list (not an append). Pass the complete desired set; an empty list
|
||||
// clears all attachments. Idempotent.
|
||||
rpc SetMemoAttachments(SetMemoAttachmentsRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/v1/{name=memos/*}/attachments"
|
||||
body: "*"
|
||||
};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// ListMemoAttachments lists attachments for a memo.
|
||||
rpc ListMemoAttachments(ListMemoAttachmentsRequest) returns (ListMemoAttachmentsResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=memos/*}/attachments"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// SetMemoRelations replaces the full set of mutable REFERENCE relations on a
|
||||
// memo. COMMENT relations are immutable creation context and are rejected by
|
||||
// this RPC. An empty list clears references without changing COMMENT.
|
||||
rpc SetMemoRelations(SetMemoRelationsRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/v1/{name=memos/*}/relations"
|
||||
body: "*"
|
||||
};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// ListMemoRelations lists relations for a memo.
|
||||
rpc ListMemoRelations(ListMemoRelationsRequest) returns (ListMemoRelationsResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=memos/*}/relations"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// CreateMemoComment atomically creates an independent memo plus one immutable
|
||||
// COMMENT context relation to the named memo. The new memo keeps its own
|
||||
// placement, visibility, authorship, and lifecycle.
|
||||
rpc CreateMemoComment(CreateMemoCommentRequest) returns (Memo) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/{name=memos/*}/comments"
|
||||
body: "comment"
|
||||
};
|
||||
option (google.api.method_signature) = "name,comment";
|
||||
}
|
||||
// ListMemoComments lists comments for a memo.
|
||||
rpc ListMemoComments(ListMemoCommentsRequest) returns (ListMemoCommentsResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=memos/*}/comments"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// ListMemoReactions lists reactions for a memo.
|
||||
rpc ListMemoReactions(ListMemoReactionsRequest) returns (ListMemoReactionsResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=memos/*}/reactions"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// UpsertMemoReaction adds or updates the authenticated user's reaction on a memo.
|
||||
rpc UpsertMemoReaction(UpsertMemoReactionRequest) returns (Reaction) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/{name=memos/*}/reactions"
|
||||
body: "*"
|
||||
};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// DeleteMemoReaction deletes a reaction for a memo.
|
||||
rpc DeleteMemoReaction(DeleteMemoReactionRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/v1/{name=memos/*/reactions/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// CreateMemoShare creates a share link for a memo. Requires the memo creator or an instance administrator.
|
||||
rpc CreateMemoShare(CreateMemoShareRequest) returns (MemoShare) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/{parent=memos/*}/shares"
|
||||
body: "memo_share"
|
||||
};
|
||||
option (google.api.method_signature) = "parent,memo_share";
|
||||
}
|
||||
// ListMemoShares lists all share links for a memo. Requires the memo creator or an instance administrator.
|
||||
rpc ListMemoShares(ListMemoSharesRequest) returns (ListMemoSharesResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/{parent=memos/*}/shares"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
// DeleteMemoShare revokes a share link. Requires the memo creator or an instance administrator.
|
||||
rpc DeleteMemoShare(DeleteMemoShareRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/v1/{name=memos/*/shares/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
// GetSharedMemo resolves a share token to its memo. No authentication required.
|
||||
// Returns NOT_FOUND if the token is invalid or expired.
|
||||
rpc GetSharedMemo(GetSharedMemoRequest) returns (Memo) {
|
||||
option (google.api.http) = {get: "/api/v1/shares/{share_token}/memo"};
|
||||
}
|
||||
// GetLinkMetadata gets metadata for a link.
|
||||
rpc GetLinkMetadata(GetLinkMetadataRequest) returns (LinkMetadata) {
|
||||
option (google.api.http) = {get: "/api/v1/memos/-/linkMetadata"};
|
||||
}
|
||||
// BatchGetLinkMetadata gets metadata for links.
|
||||
rpc BatchGetLinkMetadata(BatchGetLinkMetadataRequest) returns (BatchGetLinkMetadataResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/memos/-/linkMetadata:batchGet"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Visibility controls who can read a memo.
|
||||
enum Visibility {
|
||||
VISIBILITY_UNSPECIFIED = 0;
|
||||
// PRIVATE: only the creator can read the memo.
|
||||
PRIVATE = 1;
|
||||
// PROTECTED: signed-in users of the instance can read the memo.
|
||||
PROTECTED = 2;
|
||||
// PUBLIC: signed-in users can read the memo; anonymous visitors can read it
|
||||
// when instance policy permits.
|
||||
PUBLIC = 3;
|
||||
// SPACE: active members of the memo's space can read it.
|
||||
SPACE = 4;
|
||||
}
|
||||
|
||||
// Reaction is a reaction attached to a memo.
|
||||
message Reaction {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api.v1/Reaction"
|
||||
pattern: "memos/{memo}/reactions/{reaction}"
|
||||
name_field: "name"
|
||||
singular: "reaction"
|
||||
plural: "reactions"
|
||||
};
|
||||
|
||||
// The resource name of the reaction.
|
||||
// Format: memos/{memo}/reactions/{reaction}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = OUTPUT_ONLY,
|
||||
(google.api.field_behavior) = IDENTIFIER
|
||||
];
|
||||
|
||||
// The resource name of the creator.
|
||||
// Format: users/{user}
|
||||
string creator = 2 [
|
||||
(google.api.field_behavior) = OUTPUT_ONLY,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/User"}
|
||||
];
|
||||
|
||||
reserved 3;
|
||||
reserved "content_id";
|
||||
|
||||
// Required. The type of reaction (e.g., "👍", "❤️", "😄").
|
||||
string reaction_type = 4 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Output only. The creation timestamp.
|
||||
google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
}
|
||||
|
||||
message Memo {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api.v1/Memo"
|
||||
pattern: "memos/{memo}"
|
||||
name_field: "name"
|
||||
singular: "memo"
|
||||
plural: "memos"
|
||||
};
|
||||
|
||||
// The resource name of the memo.
|
||||
// Format: memos/{memo}, where memo is the user-defined UID.
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// The state of the memo.
|
||||
State state = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// The name of the creator.
|
||||
// Format: users/{user}
|
||||
string creator = 3 [
|
||||
(google.api.field_behavior) = OUTPUT_ONLY,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/User"}
|
||||
];
|
||||
|
||||
// The creation timestamp.
|
||||
// If not set on creation, the server will set it to the current time.
|
||||
google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// The last update timestamp.
|
||||
// If not set on creation, the server will set it to the current time.
|
||||
google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
reserved 6;
|
||||
reserved "display_time";
|
||||
|
||||
// Required. The content of the memo in Markdown format.
|
||||
string content = 7 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// The visibility of the memo.
|
||||
// One of PRIVATE (creator only), PROTECTED (signed-in users), PUBLIC
|
||||
// (anonymous-eligible), or SPACE (active space members). Defaults to
|
||||
// PRIVATE on creation when unspecified.
|
||||
Visibility visibility = 9 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Output only. The tags extracted from the content.
|
||||
repeated string tags = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Whether the memo is pinned.
|
||||
bool pinned = 11 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The attachments of the memo.
|
||||
repeated Attachment attachments = 12 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The relations of the memo.
|
||||
repeated MemoRelation relations = 13 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Output only. The reactions to the memo.
|
||||
repeated Reaction reactions = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Output only. The computed properties of the memo.
|
||||
Property property = 15 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Output only. The context memo of this COMMENT relation, if any.
|
||||
// Its identity is returned even when the caller cannot read the parent.
|
||||
// Fetch the parent independently; this field does not grant read access.
|
||||
// Format: memos/{memo}
|
||||
optional string parent = 16 [
|
||||
(google.api.field_behavior) = OUTPUT_ONLY,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
|
||||
// Output only. The snippet of the memo content. Plain text only.
|
||||
string snippet = 17 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Optional. The location of the memo.
|
||||
optional Location location = 18 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The space in which this memo is placed. Format: spaces/{space}.
|
||||
// Every memo, including a comment, owns its placement independently.
|
||||
optional string space = 19 [
|
||||
(google.api.field_behavior) = OPTIONAL,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Space"}
|
||||
];
|
||||
|
||||
// Computed properties of a memo.
|
||||
message Property {
|
||||
bool has_link = 1;
|
||||
bool has_task_list = 2;
|
||||
bool has_code = 3;
|
||||
bool has_incomplete_tasks = 4;
|
||||
// The title extracted from the first H1 heading, if present.
|
||||
string title = 5;
|
||||
}
|
||||
}
|
||||
|
||||
message Location {
|
||||
// A placeholder text for the location.
|
||||
string placeholder = 1 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// The latitude of the location.
|
||||
double latitude = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// The longitude of the location.
|
||||
double longitude = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message CreateMemoRequest {
|
||||
// Required. The memo to create.
|
||||
Memo memo = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The memo ID to use for this memo.
|
||||
// If empty, a unique ID will be generated.
|
||||
// Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$
|
||||
string memo_id = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message ListMemosRequest {
|
||||
// Optional. The maximum number of memos to return.
|
||||
// The service may return fewer than this value.
|
||||
// If unspecified, at most 50 memos will be returned.
|
||||
// The maximum value is 1000; values above 1000 will be coerced to 1000.
|
||||
int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token, received from a previous `ListMemos` call.
|
||||
// Provide this to retrieve the subsequent page.
|
||||
string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The state of the memos to list.
|
||||
// Default to `NORMAL`. Set to `ARCHIVED` to list archived memos.
|
||||
State state = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The order to sort results by.
|
||||
// Default to "create_time desc".
|
||||
// Supports comma-separated list of fields following AIP-132.
|
||||
// Example: "pinned desc, create_time desc" or "update_time asc"
|
||||
// Supported fields: pinned, create_time, update_time, name.
|
||||
// Note: order_by uses create_time / update_time, while the filter
|
||||
// expression uses created_ts / updated_ts for the same timestamps.
|
||||
string order_by = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A CEL expression to filter memos. Combine terms with && and ||.
|
||||
// Available fields:
|
||||
// content (string), creator (string, e.g. "users/1"),
|
||||
// created_ts / updated_ts (timestamp), pinned (bool),
|
||||
// visibility (string: PRIVATE | PROTECTED | PUBLIC | SPACE),
|
||||
// space (string resource name, or null when the memo has no space;
|
||||
// supports == and comparisons against null, e.g. space != null),
|
||||
// tags (list<string>; match with `"work" in tags`, not `tag == "work"`),
|
||||
// has_task_list / has_link / has_code / has_incomplete_tasks (bool),
|
||||
// has_location (bool; true when the memo has a location attached).
|
||||
// Note: the time fields here are created_ts / updated_ts, which differ from
|
||||
// the create_time / update_time names used by order_by.
|
||||
// Examples:
|
||||
// pinned == true && visibility == "PUBLIC"
|
||||
// space == "spaces/team" or space == null
|
||||
// tags.exists(t, t == "urgent")
|
||||
// content.contains("roadmap") && created_ts > now - duration("168h")
|
||||
string filter = 5 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. If true, show deleted memos in the response.
|
||||
bool show_deleted = 6 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
reserved 7, 8;
|
||||
reserved "space", "unassigned";
|
||||
}
|
||||
|
||||
message ListMemosResponse {
|
||||
// The list of memos.
|
||||
repeated Memo memos = 1;
|
||||
|
||||
// A token that can be sent as `page_token` to retrieve the next page.
|
||||
// If this field is omitted, there are no subsequent pages.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
message GetMemoRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
}
|
||||
|
||||
message UpdateMemoRequest {
|
||||
// Required. The memo to update.
|
||||
// The `name` field is required.
|
||||
Memo memo = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The list of fields to update.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message DeleteMemoRequest {
|
||||
// Required. The resource name of the memo to delete.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
|
||||
// Optional. If set to true, the memo will be deleted even if it has associated data.
|
||||
bool force = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message SetMemoAttachmentsRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
|
||||
// Required. The attachments to set for the memo.
|
||||
repeated Attachment attachments = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message ListMemoAttachmentsRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of attachments to return.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token for pagination.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message ListMemoAttachmentsResponse {
|
||||
// The list of attachments.
|
||||
repeated Attachment attachments = 1;
|
||||
|
||||
// A token for the next page of results.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
message MemoRelation {
|
||||
// The memo in the relation.
|
||||
Memo memo = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// The related memo.
|
||||
Memo related_memo = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// The type of the relation.
|
||||
enum Type {
|
||||
TYPE_UNSPECIFIED = 0;
|
||||
REFERENCE = 1;
|
||||
COMMENT = 2;
|
||||
}
|
||||
Type type = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Memo reference in relations.
|
||||
message Memo {
|
||||
// The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
|
||||
// Output only. The snippet of the memo content. Plain text only.
|
||||
string snippet = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
}
|
||||
}
|
||||
|
||||
message SetMemoRelationsRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
|
||||
// Required. The REFERENCE relations to set for the memo. COMMENT is invalid.
|
||||
repeated MemoRelation relations = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message ListMemoRelationsRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of relations to return.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token for pagination.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message ListMemoRelationsResponse {
|
||||
// The list of relations.
|
||||
repeated MemoRelation relations = 1;
|
||||
|
||||
// A token for the next page of results.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
message CreateMemoCommentRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
|
||||
// Required. The comment to create.
|
||||
Memo comment = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The comment ID to use.
|
||||
string comment_id = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message ListMemoCommentsRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of comments to return.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token for pagination.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. The order to sort results by.
|
||||
string order_by = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message ListMemoCommentsResponse {
|
||||
// The list of comment memos.
|
||||
repeated Memo memos = 1;
|
||||
|
||||
// A token for the next page of results.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
message ListMemoReactionsRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of reactions to return.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A page token for pagination.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message ListMemoReactionsResponse {
|
||||
// The list of reactions.
|
||||
repeated Reaction reactions = 1;
|
||||
|
||||
// A token for the next page of results.
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
message UpsertMemoReactionRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
|
||||
// Required. The reaction to upsert.
|
||||
Reaction reaction = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message DeleteMemoReactionRequest {
|
||||
// Required. The resource name of the reaction to delete.
|
||||
// Format: memos/{memo}/reactions/{reaction}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Reaction"}
|
||||
];
|
||||
}
|
||||
|
||||
// MemoShare is an access grant that permits read-only access to a memo via an opaque bearer token.
|
||||
message MemoShare {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api.v1/MemoShare"
|
||||
pattern: "memos/{memo}/shares/{share}"
|
||||
singular: "share"
|
||||
plural: "shares"
|
||||
};
|
||||
|
||||
// The resource name of the share. Format: memos/{memo}/shares/{share}
|
||||
// The {share} segment is the opaque token used in the share URL.
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// Output only. When this share link was created.
|
||||
google.protobuf.Timestamp create_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Optional. When set, the share link stops working after this time.
|
||||
// If unset, the link never expires.
|
||||
optional google.protobuf.Timestamp expire_time = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message CreateMemoShareRequest {
|
||||
// Required. The resource name of the memo to share.
|
||||
// Format: memos/{memo}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
|
||||
// Required. The share to create.
|
||||
MemoShare memo_share = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message ListMemoSharesRequest {
|
||||
// Required. The resource name of the memo.
|
||||
// Format: memos/{memo}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Memo"}
|
||||
];
|
||||
}
|
||||
|
||||
message ListMemoSharesResponse {
|
||||
// The list of share links.
|
||||
repeated MemoShare memo_shares = 1;
|
||||
}
|
||||
|
||||
message DeleteMemoShareRequest {
|
||||
// Required. The resource name of the share to delete.
|
||||
// Format: memos/{memo}/shares/{share}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/MemoShare"}
|
||||
];
|
||||
}
|
||||
|
||||
message GetSharedMemoRequest {
|
||||
// Required. The opaque bearer token extracted from the share URL.
|
||||
string share_token = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message GetLinkMetadataRequest {
|
||||
// Required. The link URL.
|
||||
string url = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message BatchGetLinkMetadataRequest {
|
||||
// Required. The link URLs.
|
||||
repeated string urls = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message BatchGetLinkMetadataResponse {
|
||||
// The link metadata list, in the same order as the input URLs.
|
||||
repeated LinkMetadata link_metadata = 1;
|
||||
}
|
||||
|
||||
message LinkMetadata {
|
||||
// The original link URL.
|
||||
string url = 1;
|
||||
|
||||
// The link title.
|
||||
string title = 2;
|
||||
|
||||
// The link description.
|
||||
string description = 3;
|
||||
|
||||
// The link image URL.
|
||||
string image = 4;
|
||||
}
|
||||
@@ -1,400 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package memos.api.v1;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/client.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
import "google/api/resource.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
|
||||
option go_package = "gen/api/v1";
|
||||
|
||||
// SpaceService manages collaborative spaces and their memberships.
|
||||
service SpaceService {
|
||||
// CreateSpace creates a space and makes the authenticated caller its first
|
||||
// administrator.
|
||||
rpc CreateSpace(CreateSpaceRequest) returns (Space) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/spaces"
|
||||
body: "space"
|
||||
};
|
||||
option (google.api.method_signature) = "space";
|
||||
}
|
||||
|
||||
// ListSpaces lists spaces of which the authenticated caller is a member.
|
||||
rpc ListSpaces(ListSpacesRequest) returns (ListSpacesResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/spaces"};
|
||||
option (google.api.method_signature) = "";
|
||||
}
|
||||
|
||||
// GetSpace gets a space of which the authenticated caller is a member.
|
||||
rpc GetSpace(GetSpaceRequest) returns (Space) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=spaces/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// UpdateSpace updates space metadata.
|
||||
rpc UpdateSpace(UpdateSpaceRequest) returns (Space) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/v1/{space.name=spaces/*}"
|
||||
body: "space"
|
||||
};
|
||||
option (google.api.method_signature) = "space,update_mask";
|
||||
}
|
||||
|
||||
// DeleteSpace permanently deletes a space and every memo currently placed
|
||||
// in it. It never follows memo relations to other memos.
|
||||
rpc DeleteSpace(DeleteSpaceRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/v1/{name=spaces/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// CreateSpaceInvitation invites an existing active user to a space.
|
||||
rpc CreateSpaceInvitation(CreateSpaceInvitationRequest) returns (SpaceInvitation) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/{parent=spaces/*}/invitations"
|
||||
body: "space_invitation"
|
||||
};
|
||||
option (google.api.method_signature) = "parent,space_invitation";
|
||||
}
|
||||
|
||||
// ListSpaceInvitations lists the pending invitations for a space.
|
||||
rpc ListSpaceInvitations(ListSpaceInvitationsRequest) returns (ListSpaceInvitationsResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/{parent=spaces/*}/invitations"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// ListUserSpaceInvitations lists the authenticated user's pending space invitations.
|
||||
rpc ListUserSpaceInvitations(ListUserSpaceInvitationsRequest) returns (ListUserSpaceInvitationsResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/{parent=users/*}/spaceInvitations"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// GetSpaceInvitation gets one pending invitation.
|
||||
rpc GetSpaceInvitation(GetSpaceInvitationRequest) returns (SpaceInvitation) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=spaces/*/invitations/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// DeleteSpaceInvitation revokes a pending invitation.
|
||||
rpc DeleteSpaceInvitation(DeleteSpaceInvitationRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/v1/{name=spaces/*/invitations/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// AcceptSpaceInvitation accepts a pending invitation and creates a membership.
|
||||
rpc AcceptSpaceInvitation(AcceptSpaceInvitationRequest) returns (SpaceMember) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/{name=spaces/*/invitations/*}:accept"
|
||||
body: "*"
|
||||
};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// DeclineSpaceInvitation declines a pending invitation.
|
||||
rpc DeclineSpaceInvitation(DeclineSpaceInvitationRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/{name=spaces/*/invitations/*}:decline"
|
||||
body: "*"
|
||||
};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// ListSpaceMembers lists the members of a space.
|
||||
rpc ListSpaceMembers(ListSpaceMembersRequest) returns (ListSpaceMembersResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/{parent=spaces/*}/members"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// GetSpaceMember gets one membership in a space.
|
||||
rpc GetSpaceMember(GetSpaceMemberRequest) returns (SpaceMember) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=spaces/*/members/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// UpdateSpaceMember changes a member's space role.
|
||||
rpc UpdateSpaceMember(UpdateSpaceMemberRequest) returns (SpaceMember) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/v1/{space_member.name=spaces/*/members/*}"
|
||||
body: "space_member"
|
||||
};
|
||||
option (google.api.method_signature) = "space_member,update_mask";
|
||||
}
|
||||
|
||||
// DeleteSpaceMember removes a member. A member may delete their own
|
||||
// membership to leave the space.
|
||||
rpc DeleteSpaceMember(DeleteSpaceMemberRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/v1/{name=spaces/*/members/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
}
|
||||
|
||||
// Space is a collaboration boundary for placed memos.
|
||||
message Space {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api.v1/Space"
|
||||
pattern: "spaces/{space}"
|
||||
name_field: "name"
|
||||
singular: "space"
|
||||
plural: "spaces"
|
||||
};
|
||||
|
||||
// The resource name of the space. Format: spaces/{space}.
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// Required. The human-readable title.
|
||||
string title = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. A description of the space.
|
||||
string description = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Output only. The authenticated user's membership role in this space.
|
||||
// ROLE_UNSPECIFIED when this Space is exposed as metadata-only.
|
||||
SpaceMember.Role current_user_role = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Output only. The number of accepted members in this space. Pending
|
||||
// invitations are excluded. Zero when this Space is exposed as metadata-only.
|
||||
int32 member_count = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Optional. Display icon. Omit when updating with the "icon" mask to reset
|
||||
// to the default Space mark.
|
||||
Icon icon = 6 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
message Icon {
|
||||
oneof value {
|
||||
// A Unicode emoji sequence.
|
||||
string emoji = 1;
|
||||
// A canonical Lucide icon name, such as "leaf".
|
||||
string lucide = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SpaceMember is a user's membership and governance role in a space.
|
||||
message SpaceMember {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api.v1/SpaceMember"
|
||||
pattern: "spaces/{space}/members/{member}"
|
||||
name_field: "name"
|
||||
singular: "spaceMember"
|
||||
plural: "spaceMembers"
|
||||
};
|
||||
|
||||
enum Role {
|
||||
ROLE_UNSPECIFIED = 0;
|
||||
ADMIN = 1;
|
||||
USER = 2;
|
||||
}
|
||||
|
||||
// The resource name. Format: spaces/{space}/members/{username}.
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// Required. The member user. Format: users/{username}.
|
||||
string user = 2 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/User"}
|
||||
];
|
||||
|
||||
// Required. The member's role within this space.
|
||||
Role role = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
// SpaceInvitation is a pending invitation for an existing user to join a space.
|
||||
message SpaceInvitation {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api.v1/SpaceInvitation"
|
||||
pattern: "spaces/{space}/invitations/{invitation}"
|
||||
name_field: "name"
|
||||
singular: "spaceInvitation"
|
||||
plural: "spaceInvitations"
|
||||
};
|
||||
|
||||
// The resource name. Format: spaces/{space}/invitations/{username}.
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// Required. The invited user. Format: users/{username}.
|
||||
string invitee = 2 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/User"}
|
||||
];
|
||||
|
||||
// Required. The role the user will receive after accepting the invitation.
|
||||
SpaceMember.Role role = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Output only. The Space the user is invited to. This lets an invitee
|
||||
// understand the invitation without granting membership-based GetSpace access.
|
||||
Space space = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
}
|
||||
|
||||
message CreateSpaceRequest {
|
||||
// Required. The space to create.
|
||||
Space space = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The space UID to use for this space.
|
||||
// If empty, a canonical UUID v4 will be generated.
|
||||
// Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$
|
||||
string space_id = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message ListSpacesRequest {
|
||||
// Optional. The maximum number of spaces to return.
|
||||
int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A token from a previous ListSpaces response.
|
||||
string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message ListSpacesResponse {
|
||||
repeated Space spaces = 1;
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
message GetSpaceRequest {
|
||||
// Required. The resource name of the space.
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Space"}
|
||||
];
|
||||
}
|
||||
|
||||
message UpdateSpaceRequest {
|
||||
// Required. The space with updated values.
|
||||
Space space = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. The fields to update: title or description.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message DeleteSpaceRequest {
|
||||
// Required. The resource name of the space.
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/Space"}
|
||||
];
|
||||
}
|
||||
|
||||
message CreateSpaceInvitationRequest {
|
||||
// Required. The parent space. Format: spaces/{space}.
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {child_type: "memos.api.v1/SpaceInvitation"}
|
||||
];
|
||||
|
||||
// Required. The invitation to create.
|
||||
SpaceInvitation space_invitation = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message ListSpaceInvitationsRequest {
|
||||
// Required. The parent space. Format: spaces/{space}.
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {child_type: "memos.api.v1/SpaceInvitation"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of invitations to return.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A token from a previous ListSpaceInvitations response.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message ListSpaceInvitationsResponse {
|
||||
repeated SpaceInvitation space_invitations = 1;
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
message ListUserSpaceInvitationsRequest {
|
||||
// Required. The authenticated user. Format: users/{username}.
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/User"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of invitations to return.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A token from a previous ListUserSpaceInvitations response.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message ListUserSpaceInvitationsResponse {
|
||||
repeated SpaceInvitation space_invitations = 1;
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
message GetSpaceInvitationRequest {
|
||||
// Required. Format: spaces/{space}/invitations/{username}.
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/SpaceInvitation"}
|
||||
];
|
||||
}
|
||||
|
||||
message DeleteSpaceInvitationRequest {
|
||||
// Required. Format: spaces/{space}/invitations/{username}.
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/SpaceInvitation"}
|
||||
];
|
||||
}
|
||||
|
||||
message AcceptSpaceInvitationRequest {
|
||||
// Required. Format: spaces/{space}/invitations/{username}.
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/SpaceInvitation"}
|
||||
];
|
||||
}
|
||||
|
||||
message DeclineSpaceInvitationRequest {
|
||||
// Required. Format: spaces/{space}/invitations/{username}.
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/SpaceInvitation"}
|
||||
];
|
||||
}
|
||||
|
||||
message ListSpaceMembersRequest {
|
||||
// Required. The parent space. Format: spaces/{space}.
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {child_type: "memos.api.v1/SpaceMember"}
|
||||
];
|
||||
|
||||
// Optional. The maximum number of members to return.
|
||||
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. A token from a previous ListSpaceMembers response.
|
||||
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message ListSpaceMembersResponse {
|
||||
repeated SpaceMember space_members = 1;
|
||||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
message GetSpaceMemberRequest {
|
||||
// Required. Format: spaces/{space}/members/{username}.
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/SpaceMember"}
|
||||
];
|
||||
}
|
||||
|
||||
message UpdateSpaceMemberRequest {
|
||||
// Required. The membership with the new role.
|
||||
SpaceMember space_member = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Required. Only role is supported.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message DeleteSpaceMemberRequest {
|
||||
// Required. Format: spaces/{space}/members/{username}.
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/SpaceMember"}
|
||||
];
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -14,7 +14,7 @@ plugins:
|
||||
- remote: buf.build/grpc/go
|
||||
out: gen
|
||||
opt: paths=source_relative
|
||||
- remote: buf.build/connectrpc/go
|
||||
- remote: buf.build/connectrpc/go:v1.20.0
|
||||
out: gen
|
||||
opt: paths=source_relative
|
||||
- remote: buf.build/grpc-ecosystem/gateway
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.12
|
||||
// protoc (unknown)
|
||||
// source: api/v1/ai_service.proto
|
||||
// source: api/ai_service.proto
|
||||
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
@@ -22,9 +22,10 @@ const (
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// Request message for AIService.Transcribe.
|
||||
type TranscribeRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. Audio input.
|
||||
// Required. The audio to transcribe.
|
||||
Audio *TranscriptionAudio `protobuf:"bytes,1,opt,name=audio,proto3" json:"audio,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -32,7 +33,7 @@ type TranscribeRequest struct {
|
||||
|
||||
func (x *TranscribeRequest) Reset() {
|
||||
*x = TranscribeRequest{}
|
||||
mi := &file_api_v1_ai_service_proto_msgTypes[0]
|
||||
mi := &file_api_ai_service_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -44,7 +45,7 @@ func (x *TranscribeRequest) String() string {
|
||||
func (*TranscribeRequest) ProtoMessage() {}
|
||||
|
||||
func (x *TranscribeRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_ai_service_proto_msgTypes[0]
|
||||
mi := &file_api_ai_service_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -57,7 +58,7 @@ func (x *TranscribeRequest) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use TranscribeRequest.ProtoReflect.Descriptor instead.
|
||||
func (*TranscribeRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_ai_service_proto_rawDescGZIP(), []int{0}
|
||||
return file_api_ai_service_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *TranscribeRequest) GetAudio() *TranscriptionAudio {
|
||||
@@ -67,16 +68,65 @@ func (x *TranscribeRequest) GetAudio() *TranscriptionAudio {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Response message for AIService.Transcribe.
|
||||
type TranscribeResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The transcribed text.
|
||||
Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *TranscribeResponse) Reset() {
|
||||
*x = TranscribeResponse{}
|
||||
mi := &file_api_ai_service_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *TranscribeResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*TranscribeResponse) ProtoMessage() {}
|
||||
|
||||
func (x *TranscribeResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_ai_service_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use TranscribeResponse.ProtoReflect.Descriptor instead.
|
||||
func (*TranscribeResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_ai_service_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *TranscribeResponse) GetText() string {
|
||||
if x != nil {
|
||||
return x.Text
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// TranscriptionAudio is the audio input for a transcription.
|
||||
type TranscriptionAudio struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The audio source. Only inline content is supported.
|
||||
//
|
||||
// Types that are valid to be assigned to Source:
|
||||
//
|
||||
// *TranscriptionAudio_Content
|
||||
// *TranscriptionAudio_Uri
|
||||
Source isTranscriptionAudio_Source `protobuf_oneof:"source"`
|
||||
// Optional. The uploaded filename.
|
||||
// Optional. The uploaded filename, at most 255 characters.
|
||||
Filename string `protobuf:"bytes,3,opt,name=filename,proto3" json:"filename,omitempty"`
|
||||
// Optional. The MIME type of the input audio.
|
||||
// Optional. The MIME type of the audio. If empty, the service detects it from the content.
|
||||
ContentType string `protobuf:"bytes,4,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -84,7 +134,7 @@ type TranscriptionAudio struct {
|
||||
|
||||
func (x *TranscriptionAudio) Reset() {
|
||||
*x = TranscriptionAudio{}
|
||||
mi := &file_api_v1_ai_service_proto_msgTypes[1]
|
||||
mi := &file_api_ai_service_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -96,7 +146,7 @@ func (x *TranscriptionAudio) String() string {
|
||||
func (*TranscriptionAudio) ProtoMessage() {}
|
||||
|
||||
func (x *TranscriptionAudio) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_ai_service_proto_msgTypes[1]
|
||||
mi := &file_api_ai_service_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -109,7 +159,7 @@ func (x *TranscriptionAudio) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use TranscriptionAudio.ProtoReflect.Descriptor instead.
|
||||
func (*TranscriptionAudio) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_ai_service_proto_rawDescGZIP(), []int{1}
|
||||
return file_api_ai_service_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *TranscriptionAudio) GetSource() isTranscriptionAudio_Source {
|
||||
@@ -156,12 +206,12 @@ type isTranscriptionAudio_Source interface {
|
||||
}
|
||||
|
||||
type TranscriptionAudio_Content struct {
|
||||
// Inline audio bytes.
|
||||
// Input only. Inline audio bytes, at most 25 MiB.
|
||||
Content []byte `protobuf:"bytes,1,opt,name=content,proto3,oneof"`
|
||||
}
|
||||
|
||||
type TranscriptionAudio_Uri struct {
|
||||
// URI for audio content. Reserved for future use.
|
||||
// URI of the audio content. Reserved for future use; the service rejects requests that set it.
|
||||
Uri string `protobuf:"bytes,2,opt,name=uri,proto3,oneof"`
|
||||
}
|
||||
|
||||
@@ -169,93 +219,49 @@ func (*TranscriptionAudio_Content) isTranscriptionAudio_Source() {}
|
||||
|
||||
func (*TranscriptionAudio_Uri) isTranscriptionAudio_Source() {}
|
||||
|
||||
type TranscribeResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The transcribed text.
|
||||
Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
var File_api_ai_service_proto protoreflect.FileDescriptor
|
||||
|
||||
func (x *TranscribeResponse) Reset() {
|
||||
*x = TranscribeResponse{}
|
||||
mi := &file_api_v1_ai_service_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *TranscribeResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*TranscribeResponse) ProtoMessage() {}
|
||||
|
||||
func (x *TranscribeResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_ai_service_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use TranscribeResponse.ProtoReflect.Descriptor instead.
|
||||
func (*TranscribeResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_ai_service_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *TranscribeResponse) GetText() string {
|
||||
if x != nil {
|
||||
return x.Text
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_api_v1_ai_service_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_api_v1_ai_service_proto_rawDesc = "" +
|
||||
const file_api_ai_service_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x17api/v1/ai_service.proto\x12\fmemos.api.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\"P\n" +
|
||||
"\x11TranscribeRequest\x12;\n" +
|
||||
"\x05audio\x18\x01 \x01(\v2 .memos.api.v1.TranscriptionAudioB\x03\xe0A\x02R\x05audio\"\x9c\x01\n" +
|
||||
"\x14api/ai_service.proto\x12\tmemos.api\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\"M\n" +
|
||||
"\x11TranscribeRequest\x128\n" +
|
||||
"\x05audio\x18\x01 \x01(\v2\x1d.memos.api.TranscriptionAudioB\x03\xe0A\x02R\x05audio\"(\n" +
|
||||
"\x12TranscribeResponse\x12\x12\n" +
|
||||
"\x04text\x18\x01 \x01(\tR\x04text\"\x9c\x01\n" +
|
||||
"\x12TranscriptionAudio\x12\x1f\n" +
|
||||
"\acontent\x18\x01 \x01(\fB\x03\xe0A\x04H\x00R\acontent\x12\x12\n" +
|
||||
"\x03uri\x18\x02 \x01(\tH\x00R\x03uri\x12\x1f\n" +
|
||||
"\bfilename\x18\x03 \x01(\tB\x03\xe0A\x01R\bfilename\x12&\n" +
|
||||
"\fcontent_type\x18\x04 \x01(\tB\x03\xe0A\x01R\vcontentTypeB\b\n" +
|
||||
"\x06source\"(\n" +
|
||||
"\x12TranscribeResponse\x12\x12\n" +
|
||||
"\x04text\x18\x01 \x01(\tR\x04text2\x86\x01\n" +
|
||||
"\tAIService\x12y\n" +
|
||||
"\x06source2}\n" +
|
||||
"\tAIService\x12p\n" +
|
||||
"\n" +
|
||||
"Transcribe\x12\x1f.memos.api.v1.TranscribeRequest\x1a .memos.api.v1.TranscribeResponse\"(\xdaA\x05audio\x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/api/v1/ai:transcribeB\xa6\x01\n" +
|
||||
"\x10com.memos.api.v1B\x0eAiServiceProtoP\x01Z0github.com/usememos/memos/proto/gen/api/v1;apiv1\xa2\x02\x03MAX\xaa\x02\fMemos.Api.V1\xca\x02\fMemos\\Api\\V1\xe2\x02\x18Memos\\Api\\V1\\GPBMetadata\xea\x02\x0eMemos::Api::V1b\x06proto3"
|
||||
"Transcribe\x12\x1c.memos.api.TranscribeRequest\x1a\x1d.memos.api.TranscribeResponse\"%\xdaA\x05audio\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/ai:transcribeB\x8d\x01\n" +
|
||||
"\rcom.memos.apiB\x0eAiServiceProtoP\x01Z'github.com/usememos/memos/proto/gen/api\xa2\x02\x03MAX\xaa\x02\tMemos.Api\xca\x02\tMemos\\Api\xe2\x02\x15Memos\\Api\\GPBMetadata\xea\x02\n" +
|
||||
"Memos::Apib\x06proto3"
|
||||
|
||||
var (
|
||||
file_api_v1_ai_service_proto_rawDescOnce sync.Once
|
||||
file_api_v1_ai_service_proto_rawDescData []byte
|
||||
file_api_ai_service_proto_rawDescOnce sync.Once
|
||||
file_api_ai_service_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_api_v1_ai_service_proto_rawDescGZIP() []byte {
|
||||
file_api_v1_ai_service_proto_rawDescOnce.Do(func() {
|
||||
file_api_v1_ai_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_v1_ai_service_proto_rawDesc), len(file_api_v1_ai_service_proto_rawDesc)))
|
||||
func file_api_ai_service_proto_rawDescGZIP() []byte {
|
||||
file_api_ai_service_proto_rawDescOnce.Do(func() {
|
||||
file_api_ai_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_ai_service_proto_rawDesc), len(file_api_ai_service_proto_rawDesc)))
|
||||
})
|
||||
return file_api_v1_ai_service_proto_rawDescData
|
||||
return file_api_ai_service_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_api_v1_ai_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_api_v1_ai_service_proto_goTypes = []any{
|
||||
(*TranscribeRequest)(nil), // 0: memos.api.v1.TranscribeRequest
|
||||
(*TranscriptionAudio)(nil), // 1: memos.api.v1.TranscriptionAudio
|
||||
(*TranscribeResponse)(nil), // 2: memos.api.v1.TranscribeResponse
|
||||
var file_api_ai_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_api_ai_service_proto_goTypes = []any{
|
||||
(*TranscribeRequest)(nil), // 0: memos.api.TranscribeRequest
|
||||
(*TranscribeResponse)(nil), // 1: memos.api.TranscribeResponse
|
||||
(*TranscriptionAudio)(nil), // 2: memos.api.TranscriptionAudio
|
||||
}
|
||||
var file_api_v1_ai_service_proto_depIdxs = []int32{
|
||||
1, // 0: memos.api.v1.TranscribeRequest.audio:type_name -> memos.api.v1.TranscriptionAudio
|
||||
0, // 1: memos.api.v1.AIService.Transcribe:input_type -> memos.api.v1.TranscribeRequest
|
||||
2, // 2: memos.api.v1.AIService.Transcribe:output_type -> memos.api.v1.TranscribeResponse
|
||||
var file_api_ai_service_proto_depIdxs = []int32{
|
||||
2, // 0: memos.api.TranscribeRequest.audio:type_name -> memos.api.TranscriptionAudio
|
||||
0, // 1: memos.api.AIService.Transcribe:input_type -> memos.api.TranscribeRequest
|
||||
1, // 2: memos.api.AIService.Transcribe:output_type -> memos.api.TranscribeResponse
|
||||
2, // [2:3] is the sub-list for method output_type
|
||||
1, // [1:2] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
@@ -263,12 +269,12 @@ var file_api_v1_ai_service_proto_depIdxs = []int32{
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_v1_ai_service_proto_init() }
|
||||
func file_api_v1_ai_service_proto_init() {
|
||||
if File_api_v1_ai_service_proto != nil {
|
||||
func init() { file_api_ai_service_proto_init() }
|
||||
func file_api_ai_service_proto_init() {
|
||||
if File_api_ai_service_proto != nil {
|
||||
return
|
||||
}
|
||||
file_api_v1_ai_service_proto_msgTypes[1].OneofWrappers = []any{
|
||||
file_api_ai_service_proto_msgTypes[2].OneofWrappers = []any{
|
||||
(*TranscriptionAudio_Content)(nil),
|
||||
(*TranscriptionAudio_Uri)(nil),
|
||||
}
|
||||
@@ -276,17 +282,17 @@ func file_api_v1_ai_service_proto_init() {
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_v1_ai_service_proto_rawDesc), len(file_api_v1_ai_service_proto_rawDesc)),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_ai_service_proto_rawDesc), len(file_api_ai_service_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_api_v1_ai_service_proto_goTypes,
|
||||
DependencyIndexes: file_api_v1_ai_service_proto_depIdxs,
|
||||
MessageInfos: file_api_v1_ai_service_proto_msgTypes,
|
||||
GoTypes: file_api_ai_service_proto_goTypes,
|
||||
DependencyIndexes: file_api_ai_service_proto_depIdxs,
|
||||
MessageInfos: file_api_ai_service_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_v1_ai_service_proto = out.File
|
||||
file_api_v1_ai_service_proto_goTypes = nil
|
||||
file_api_v1_ai_service_proto_depIdxs = nil
|
||||
File_api_ai_service_proto = out.File
|
||||
file_api_ai_service_proto_goTypes = nil
|
||||
file_api_ai_service_proto_depIdxs = nil
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: api/v1/ai_service.proto
|
||||
// source: api/ai_service.proto
|
||||
|
||||
/*
|
||||
Package apiv1 is a reverse proxy.
|
||||
Package api is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -74,7 +74,7 @@ func RegisterAIServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AIService/Transcribe", runtime.WithHTTPPathPattern("/api/v1/ai:transcribe"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.AIService/Transcribe", runtime.WithHTTPPathPattern("/api/ai:transcribe"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -132,7 +132,7 @@ func RegisterAIServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AIService/Transcribe", runtime.WithHTTPPathPattern("/api/v1/ai:transcribe"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.AIService/Transcribe", runtime.WithHTTPPathPattern("/api/ai:transcribe"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -149,7 +149,7 @@ func RegisterAIServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_AIService_Transcribe_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "ai"}, "transcribe"))
|
||||
pattern_AIService_Transcribe_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "ai"}, "transcribe"))
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -2,9 +2,9 @@
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc (unknown)
|
||||
// source: api/v1/ai_service.proto
|
||||
// source: api/ai_service.proto
|
||||
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
context "context"
|
||||
@@ -19,14 +19,17 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
AIService_Transcribe_FullMethodName = "/memos.api.v1.AIService/Transcribe"
|
||||
AIService_Transcribe_FullMethodName = "/memos.api.AIService/Transcribe"
|
||||
)
|
||||
|
||||
// AIServiceClient is the client API for AIService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
//
|
||||
// AIService runs AI tasks through the AI providers configured on the instance.
|
||||
type AIServiceClient interface {
|
||||
// Transcribe transcribes an audio file using an instance AI provider.
|
||||
// Transcribe transcribes an audio file with the instance's configured
|
||||
// transcription provider. The caller must be signed in, and requests are rate limited per user.
|
||||
Transcribe(ctx context.Context, in *TranscribeRequest, opts ...grpc.CallOption) (*TranscribeResponse, error)
|
||||
}
|
||||
|
||||
@@ -51,8 +54,11 @@ func (c *aIServiceClient) Transcribe(ctx context.Context, in *TranscribeRequest,
|
||||
// AIServiceServer is the server API for AIService service.
|
||||
// All implementations must embed UnimplementedAIServiceServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// AIService runs AI tasks through the AI providers configured on the instance.
|
||||
type AIServiceServer interface {
|
||||
// Transcribe transcribes an audio file using an instance AI provider.
|
||||
// Transcribe transcribes an audio file with the instance's configured
|
||||
// transcription provider. The caller must be signed in, and requests are rate limited per user.
|
||||
Transcribe(context.Context, *TranscribeRequest) (*TranscribeResponse, error)
|
||||
mustEmbedUnimplementedAIServiceServer()
|
||||
}
|
||||
@@ -110,7 +116,7 @@ func _AIService_Transcribe_Handler(srv interface{}, ctx context.Context, dec fun
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var AIService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "memos.api.v1.AIService",
|
||||
ServiceName: "memos.api.AIService",
|
||||
HandlerType: (*AIServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
@@ -119,5 +125,5 @@ var AIService_ServiceDesc = grpc.ServiceDesc{
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v1/ai_service.proto",
|
||||
Metadata: "api/ai_service.proto",
|
||||
}
|
||||
+24
-22
@@ -1,14 +1,14 @@
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: api/v1/ai_service.proto
|
||||
// Source: api/ai_service.proto
|
||||
|
||||
package apiv1connect
|
||||
package apiconnect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
v1 "github.com/usememos/memos/proto/gen/api/v1"
|
||||
api "github.com/usememos/memos/proto/gen/api"
|
||||
http "net/http"
|
||||
strings "strings"
|
||||
)
|
||||
@@ -22,7 +22,7 @@ const _ = connect.IsAtLeastVersion1_13_0
|
||||
|
||||
const (
|
||||
// AIServiceName is the fully-qualified name of the AIService service.
|
||||
AIServiceName = "memos.api.v1.AIService"
|
||||
AIServiceName = "memos.api.AIService"
|
||||
)
|
||||
|
||||
// These constants are the fully-qualified names of the RPCs defined in this package. They're
|
||||
@@ -34,17 +34,18 @@ const (
|
||||
// period.
|
||||
const (
|
||||
// AIServiceTranscribeProcedure is the fully-qualified name of the AIService's Transcribe RPC.
|
||||
AIServiceTranscribeProcedure = "/memos.api.v1.AIService/Transcribe"
|
||||
AIServiceTranscribeProcedure = "/memos.api.AIService/Transcribe"
|
||||
)
|
||||
|
||||
// AIServiceClient is a client for the memos.api.v1.AIService service.
|
||||
// AIServiceClient is a client for the memos.api.AIService service.
|
||||
type AIServiceClient interface {
|
||||
// Transcribe transcribes an audio file using an instance AI provider.
|
||||
Transcribe(context.Context, *connect.Request[v1.TranscribeRequest]) (*connect.Response[v1.TranscribeResponse], error)
|
||||
// Transcribe transcribes an audio file with the instance's configured
|
||||
// transcription provider. The caller must be signed in, and requests are rate limited per user.
|
||||
Transcribe(context.Context, *connect.Request[api.TranscribeRequest]) (*connect.Response[api.TranscribeResponse], error)
|
||||
}
|
||||
|
||||
// NewAIServiceClient constructs a client for the memos.api.v1.AIService service. By default, it
|
||||
// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
|
||||
// NewAIServiceClient constructs a client for the memos.api.AIService service. By default, it uses
|
||||
// the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
|
||||
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
|
||||
// connect.WithGRPCWeb() options.
|
||||
//
|
||||
@@ -52,9 +53,9 @@ type AIServiceClient interface {
|
||||
// http://api.acme.com or https://acme.com/grpc).
|
||||
func NewAIServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AIServiceClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
aIServiceMethods := v1.File_api_v1_ai_service_proto.Services().ByName("AIService").Methods()
|
||||
aIServiceMethods := api.File_api_ai_service_proto.Services().ByName("AIService").Methods()
|
||||
return &aIServiceClient{
|
||||
transcribe: connect.NewClient[v1.TranscribeRequest, v1.TranscribeResponse](
|
||||
transcribe: connect.NewClient[api.TranscribeRequest, api.TranscribeResponse](
|
||||
httpClient,
|
||||
baseURL+AIServiceTranscribeProcedure,
|
||||
connect.WithSchema(aIServiceMethods.ByName("Transcribe")),
|
||||
@@ -65,18 +66,19 @@ func NewAIServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...c
|
||||
|
||||
// aIServiceClient implements AIServiceClient.
|
||||
type aIServiceClient struct {
|
||||
transcribe *connect.Client[v1.TranscribeRequest, v1.TranscribeResponse]
|
||||
transcribe *connect.Client[api.TranscribeRequest, api.TranscribeResponse]
|
||||
}
|
||||
|
||||
// Transcribe calls memos.api.v1.AIService.Transcribe.
|
||||
func (c *aIServiceClient) Transcribe(ctx context.Context, req *connect.Request[v1.TranscribeRequest]) (*connect.Response[v1.TranscribeResponse], error) {
|
||||
// Transcribe calls memos.api.AIService.Transcribe.
|
||||
func (c *aIServiceClient) Transcribe(ctx context.Context, req *connect.Request[api.TranscribeRequest]) (*connect.Response[api.TranscribeResponse], error) {
|
||||
return c.transcribe.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// AIServiceHandler is an implementation of the memos.api.v1.AIService service.
|
||||
// AIServiceHandler is an implementation of the memos.api.AIService service.
|
||||
type AIServiceHandler interface {
|
||||
// Transcribe transcribes an audio file using an instance AI provider.
|
||||
Transcribe(context.Context, *connect.Request[v1.TranscribeRequest]) (*connect.Response[v1.TranscribeResponse], error)
|
||||
// Transcribe transcribes an audio file with the instance's configured
|
||||
// transcription provider. The caller must be signed in, and requests are rate limited per user.
|
||||
Transcribe(context.Context, *connect.Request[api.TranscribeRequest]) (*connect.Response[api.TranscribeResponse], error)
|
||||
}
|
||||
|
||||
// NewAIServiceHandler builds an HTTP handler from the service implementation. It returns the path
|
||||
@@ -85,14 +87,14 @@ type AIServiceHandler interface {
|
||||
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
|
||||
// and JSON codecs. They also support gzip compression.
|
||||
func NewAIServiceHandler(svc AIServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
aIServiceMethods := v1.File_api_v1_ai_service_proto.Services().ByName("AIService").Methods()
|
||||
aIServiceMethods := api.File_api_ai_service_proto.Services().ByName("AIService").Methods()
|
||||
aIServiceTranscribeHandler := connect.NewUnaryHandler(
|
||||
AIServiceTranscribeProcedure,
|
||||
svc.Transcribe,
|
||||
connect.WithSchema(aIServiceMethods.ByName("Transcribe")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/memos.api.v1.AIService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
return "/memos.api.AIService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case AIServiceTranscribeProcedure:
|
||||
aIServiceTranscribeHandler.ServeHTTP(w, r)
|
||||
@@ -105,6 +107,6 @@ func NewAIServiceHandler(svc AIServiceHandler, opts ...connect.HandlerOption) (s
|
||||
// UnimplementedAIServiceHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedAIServiceHandler struct{}
|
||||
|
||||
func (UnimplementedAIServiceHandler) Transcribe(context.Context, *connect.Request[v1.TranscribeRequest]) (*connect.Response[v1.TranscribeResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AIService.Transcribe is not implemented"))
|
||||
func (UnimplementedAIServiceHandler) Transcribe(context.Context, *connect.Request[api.TranscribeRequest]) (*connect.Response[api.TranscribeResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AIService.Transcribe is not implemented"))
|
||||
}
|
||||
+131
-127
@@ -1,14 +1,14 @@
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: api/v1/attachment_service.proto
|
||||
// Source: api/attachment_service.proto
|
||||
|
||||
package apiv1connect
|
||||
package apiconnect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
v1 "github.com/usememos/memos/proto/gen/api/v1"
|
||||
api "github.com/usememos/memos/proto/gen/api"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
http "net/http"
|
||||
strings "strings"
|
||||
@@ -23,7 +23,7 @@ const _ = connect.IsAtLeastVersion1_13_0
|
||||
|
||||
const (
|
||||
// AttachmentServiceName is the fully-qualified name of the AttachmentService service.
|
||||
AttachmentServiceName = "memos.api.v1.AttachmentService"
|
||||
AttachmentServiceName = "memos.api.AttachmentService"
|
||||
)
|
||||
|
||||
// These constants are the fully-qualified names of the RPCs defined in this package. They're
|
||||
@@ -34,51 +34,53 @@ const (
|
||||
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
|
||||
// period.
|
||||
const (
|
||||
// AttachmentServiceCreateAttachmentProcedure is the fully-qualified name of the AttachmentService's
|
||||
// CreateAttachment RPC.
|
||||
AttachmentServiceCreateAttachmentProcedure = "/memos.api.v1.AttachmentService/CreateAttachment"
|
||||
// AttachmentServiceUploadAttachmentProcedure is the fully-qualified name of the AttachmentService's
|
||||
// UploadAttachment RPC.
|
||||
AttachmentServiceUploadAttachmentProcedure = "/memos.api.v1.AttachmentService/UploadAttachment"
|
||||
// AttachmentServiceListAttachmentsProcedure is the fully-qualified name of the AttachmentService's
|
||||
// ListAttachments RPC.
|
||||
AttachmentServiceListAttachmentsProcedure = "/memos.api.v1.AttachmentService/ListAttachments"
|
||||
AttachmentServiceListAttachmentsProcedure = "/memos.api.AttachmentService/ListAttachments"
|
||||
// AttachmentServiceGetAttachmentProcedure is the fully-qualified name of the AttachmentService's
|
||||
// GetAttachment RPC.
|
||||
AttachmentServiceGetAttachmentProcedure = "/memos.api.v1.AttachmentService/GetAttachment"
|
||||
AttachmentServiceGetAttachmentProcedure = "/memos.api.AttachmentService/GetAttachment"
|
||||
// AttachmentServiceCreateAttachmentProcedure is the fully-qualified name of the AttachmentService's
|
||||
// CreateAttachment RPC.
|
||||
AttachmentServiceCreateAttachmentProcedure = "/memos.api.AttachmentService/CreateAttachment"
|
||||
// AttachmentServiceUpdateAttachmentProcedure is the fully-qualified name of the AttachmentService's
|
||||
// UpdateAttachment RPC.
|
||||
AttachmentServiceUpdateAttachmentProcedure = "/memos.api.v1.AttachmentService/UpdateAttachment"
|
||||
AttachmentServiceUpdateAttachmentProcedure = "/memos.api.AttachmentService/UpdateAttachment"
|
||||
// AttachmentServiceDeleteAttachmentProcedure is the fully-qualified name of the AttachmentService's
|
||||
// DeleteAttachment RPC.
|
||||
AttachmentServiceDeleteAttachmentProcedure = "/memos.api.v1.AttachmentService/DeleteAttachment"
|
||||
AttachmentServiceDeleteAttachmentProcedure = "/memos.api.AttachmentService/DeleteAttachment"
|
||||
// AttachmentServiceBatchDeleteAttachmentsProcedure is the fully-qualified name of the
|
||||
// AttachmentService's BatchDeleteAttachments RPC.
|
||||
AttachmentServiceBatchDeleteAttachmentsProcedure = "/memos.api.v1.AttachmentService/BatchDeleteAttachments"
|
||||
AttachmentServiceBatchDeleteAttachmentsProcedure = "/memos.api.AttachmentService/BatchDeleteAttachments"
|
||||
// AttachmentServiceUploadAttachmentProcedure is the fully-qualified name of the AttachmentService's
|
||||
// UploadAttachment RPC.
|
||||
AttachmentServiceUploadAttachmentProcedure = "/memos.api.AttachmentService/UploadAttachment"
|
||||
)
|
||||
|
||||
// AttachmentServiceClient is a client for the memos.api.v1.AttachmentService service.
|
||||
// AttachmentServiceClient is a client for the memos.api.AttachmentService service.
|
||||
type AttachmentServiceClient interface {
|
||||
// CreateAttachment creates a new attachment.
|
||||
CreateAttachment(context.Context, *connect.Request[v1.CreateAttachmentRequest]) (*connect.Response[v1.Attachment], error)
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries
|
||||
// the spec and returns an upload_id; later calls carry that upload_id.
|
||||
// Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// ListAttachments lists attachments linked to memos the caller can read, plus the caller's unlinked uploads.
|
||||
ListAttachments(context.Context, *connect.Request[api.ListAttachmentsRequest]) (*connect.Response[api.ListAttachmentsResponse], error)
|
||||
// GetAttachment gets an attachment by name. An unlinked attachment is visible only to its uploader and admins;
|
||||
// a linked attachment follows the read access of its memo.
|
||||
GetAttachment(context.Context, *connect.Request[api.GetAttachmentRequest]) (*connect.Response[api.Attachment], error)
|
||||
// CreateAttachment creates an attachment from inline content.
|
||||
CreateAttachment(context.Context, *connect.Request[api.CreateAttachmentRequest]) (*connect.Response[api.Attachment], error)
|
||||
// UpdateAttachment updates an attachment. Only `filename` can be updated. The caller must be the uploader or an
|
||||
// admin.
|
||||
UpdateAttachment(context.Context, *connect.Request[api.UpdateAttachmentRequest]) (*connect.Response[api.Attachment], error)
|
||||
// DeleteAttachment deletes an attachment uploaded by the caller.
|
||||
DeleteAttachment(context.Context, *connect.Request[api.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// BatchDeleteAttachments deletes up to 100 attachments in one atomic request. The caller must be the uploader of
|
||||
// each attachment or an admin.
|
||||
BatchDeleteAttachments(context.Context, *connect.Request[api.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries the spec and returns an upload_id;
|
||||
// later calls carry that upload_id. Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// inactivity, and do not survive a server restart.
|
||||
UploadAttachment(context.Context, *connect.Request[v1.UploadAttachmentRequest]) (*connect.Response[v1.UploadAttachmentResponse], error)
|
||||
// ListAttachments lists attachments linked to readable memos and the caller's unlinked uploads.
|
||||
ListAttachments(context.Context, *connect.Request[v1.ListAttachmentsRequest]) (*connect.Response[v1.ListAttachmentsResponse], error)
|
||||
// GetAttachment returns an attachment by name.
|
||||
GetAttachment(context.Context, *connect.Request[v1.GetAttachmentRequest]) (*connect.Response[v1.Attachment], error)
|
||||
// UpdateAttachment updates an attachment.
|
||||
UpdateAttachment(context.Context, *connect.Request[v1.UpdateAttachmentRequest]) (*connect.Response[v1.Attachment], error)
|
||||
// DeleteAttachment deletes an attachment by name.
|
||||
DeleteAttachment(context.Context, *connect.Request[v1.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// BatchDeleteAttachments deletes multiple attachments in one request.
|
||||
BatchDeleteAttachments(context.Context, *connect.Request[v1.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
UploadAttachment(context.Context, *connect.Request[api.UploadAttachmentRequest]) (*connect.Response[api.UploadAttachmentResponse], error)
|
||||
}
|
||||
|
||||
// NewAttachmentServiceClient constructs a client for the memos.api.v1.AttachmentService service. By
|
||||
// NewAttachmentServiceClient constructs a client for the memos.api.AttachmentService service. By
|
||||
// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
|
||||
// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
|
||||
// connect.WithGRPC() or connect.WithGRPCWeb() options.
|
||||
@@ -87,118 +89,120 @@ type AttachmentServiceClient interface {
|
||||
// http://api.acme.com or https://acme.com/grpc).
|
||||
func NewAttachmentServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AttachmentServiceClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
attachmentServiceMethods := v1.File_api_v1_attachment_service_proto.Services().ByName("AttachmentService").Methods()
|
||||
attachmentServiceMethods := api.File_api_attachment_service_proto.Services().ByName("AttachmentService").Methods()
|
||||
return &attachmentServiceClient{
|
||||
createAttachment: connect.NewClient[v1.CreateAttachmentRequest, v1.Attachment](
|
||||
httpClient,
|
||||
baseURL+AttachmentServiceCreateAttachmentProcedure,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("CreateAttachment")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
uploadAttachment: connect.NewClient[v1.UploadAttachmentRequest, v1.UploadAttachmentResponse](
|
||||
httpClient,
|
||||
baseURL+AttachmentServiceUploadAttachmentProcedure,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("UploadAttachment")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
listAttachments: connect.NewClient[v1.ListAttachmentsRequest, v1.ListAttachmentsResponse](
|
||||
listAttachments: connect.NewClient[api.ListAttachmentsRequest, api.ListAttachmentsResponse](
|
||||
httpClient,
|
||||
baseURL+AttachmentServiceListAttachmentsProcedure,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("ListAttachments")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getAttachment: connect.NewClient[v1.GetAttachmentRequest, v1.Attachment](
|
||||
getAttachment: connect.NewClient[api.GetAttachmentRequest, api.Attachment](
|
||||
httpClient,
|
||||
baseURL+AttachmentServiceGetAttachmentProcedure,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("GetAttachment")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
updateAttachment: connect.NewClient[v1.UpdateAttachmentRequest, v1.Attachment](
|
||||
createAttachment: connect.NewClient[api.CreateAttachmentRequest, api.Attachment](
|
||||
httpClient,
|
||||
baseURL+AttachmentServiceCreateAttachmentProcedure,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("CreateAttachment")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
updateAttachment: connect.NewClient[api.UpdateAttachmentRequest, api.Attachment](
|
||||
httpClient,
|
||||
baseURL+AttachmentServiceUpdateAttachmentProcedure,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("UpdateAttachment")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
deleteAttachment: connect.NewClient[v1.DeleteAttachmentRequest, emptypb.Empty](
|
||||
deleteAttachment: connect.NewClient[api.DeleteAttachmentRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+AttachmentServiceDeleteAttachmentProcedure,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("DeleteAttachment")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
batchDeleteAttachments: connect.NewClient[v1.BatchDeleteAttachmentsRequest, emptypb.Empty](
|
||||
batchDeleteAttachments: connect.NewClient[api.BatchDeleteAttachmentsRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+AttachmentServiceBatchDeleteAttachmentsProcedure,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("BatchDeleteAttachments")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
uploadAttachment: connect.NewClient[api.UploadAttachmentRequest, api.UploadAttachmentResponse](
|
||||
httpClient,
|
||||
baseURL+AttachmentServiceUploadAttachmentProcedure,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("UploadAttachment")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// attachmentServiceClient implements AttachmentServiceClient.
|
||||
type attachmentServiceClient struct {
|
||||
createAttachment *connect.Client[v1.CreateAttachmentRequest, v1.Attachment]
|
||||
uploadAttachment *connect.Client[v1.UploadAttachmentRequest, v1.UploadAttachmentResponse]
|
||||
listAttachments *connect.Client[v1.ListAttachmentsRequest, v1.ListAttachmentsResponse]
|
||||
getAttachment *connect.Client[v1.GetAttachmentRequest, v1.Attachment]
|
||||
updateAttachment *connect.Client[v1.UpdateAttachmentRequest, v1.Attachment]
|
||||
deleteAttachment *connect.Client[v1.DeleteAttachmentRequest, emptypb.Empty]
|
||||
batchDeleteAttachments *connect.Client[v1.BatchDeleteAttachmentsRequest, emptypb.Empty]
|
||||
listAttachments *connect.Client[api.ListAttachmentsRequest, api.ListAttachmentsResponse]
|
||||
getAttachment *connect.Client[api.GetAttachmentRequest, api.Attachment]
|
||||
createAttachment *connect.Client[api.CreateAttachmentRequest, api.Attachment]
|
||||
updateAttachment *connect.Client[api.UpdateAttachmentRequest, api.Attachment]
|
||||
deleteAttachment *connect.Client[api.DeleteAttachmentRequest, emptypb.Empty]
|
||||
batchDeleteAttachments *connect.Client[api.BatchDeleteAttachmentsRequest, emptypb.Empty]
|
||||
uploadAttachment *connect.Client[api.UploadAttachmentRequest, api.UploadAttachmentResponse]
|
||||
}
|
||||
|
||||
// CreateAttachment calls memos.api.v1.AttachmentService.CreateAttachment.
|
||||
func (c *attachmentServiceClient) CreateAttachment(ctx context.Context, req *connect.Request[v1.CreateAttachmentRequest]) (*connect.Response[v1.Attachment], error) {
|
||||
return c.createAttachment.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// UploadAttachment calls memos.api.v1.AttachmentService.UploadAttachment.
|
||||
func (c *attachmentServiceClient) UploadAttachment(ctx context.Context, req *connect.Request[v1.UploadAttachmentRequest]) (*connect.Response[v1.UploadAttachmentResponse], error) {
|
||||
return c.uploadAttachment.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ListAttachments calls memos.api.v1.AttachmentService.ListAttachments.
|
||||
func (c *attachmentServiceClient) ListAttachments(ctx context.Context, req *connect.Request[v1.ListAttachmentsRequest]) (*connect.Response[v1.ListAttachmentsResponse], error) {
|
||||
// ListAttachments calls memos.api.AttachmentService.ListAttachments.
|
||||
func (c *attachmentServiceClient) ListAttachments(ctx context.Context, req *connect.Request[api.ListAttachmentsRequest]) (*connect.Response[api.ListAttachmentsResponse], error) {
|
||||
return c.listAttachments.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetAttachment calls memos.api.v1.AttachmentService.GetAttachment.
|
||||
func (c *attachmentServiceClient) GetAttachment(ctx context.Context, req *connect.Request[v1.GetAttachmentRequest]) (*connect.Response[v1.Attachment], error) {
|
||||
// GetAttachment calls memos.api.AttachmentService.GetAttachment.
|
||||
func (c *attachmentServiceClient) GetAttachment(ctx context.Context, req *connect.Request[api.GetAttachmentRequest]) (*connect.Response[api.Attachment], error) {
|
||||
return c.getAttachment.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// UpdateAttachment calls memos.api.v1.AttachmentService.UpdateAttachment.
|
||||
func (c *attachmentServiceClient) UpdateAttachment(ctx context.Context, req *connect.Request[v1.UpdateAttachmentRequest]) (*connect.Response[v1.Attachment], error) {
|
||||
// CreateAttachment calls memos.api.AttachmentService.CreateAttachment.
|
||||
func (c *attachmentServiceClient) CreateAttachment(ctx context.Context, req *connect.Request[api.CreateAttachmentRequest]) (*connect.Response[api.Attachment], error) {
|
||||
return c.createAttachment.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// UpdateAttachment calls memos.api.AttachmentService.UpdateAttachment.
|
||||
func (c *attachmentServiceClient) UpdateAttachment(ctx context.Context, req *connect.Request[api.UpdateAttachmentRequest]) (*connect.Response[api.Attachment], error) {
|
||||
return c.updateAttachment.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// DeleteAttachment calls memos.api.v1.AttachmentService.DeleteAttachment.
|
||||
func (c *attachmentServiceClient) DeleteAttachment(ctx context.Context, req *connect.Request[v1.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
// DeleteAttachment calls memos.api.AttachmentService.DeleteAttachment.
|
||||
func (c *attachmentServiceClient) DeleteAttachment(ctx context.Context, req *connect.Request[api.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.deleteAttachment.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// BatchDeleteAttachments calls memos.api.v1.AttachmentService.BatchDeleteAttachments.
|
||||
func (c *attachmentServiceClient) BatchDeleteAttachments(ctx context.Context, req *connect.Request[v1.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
// BatchDeleteAttachments calls memos.api.AttachmentService.BatchDeleteAttachments.
|
||||
func (c *attachmentServiceClient) BatchDeleteAttachments(ctx context.Context, req *connect.Request[api.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.batchDeleteAttachments.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// AttachmentServiceHandler is an implementation of the memos.api.v1.AttachmentService service.
|
||||
// UploadAttachment calls memos.api.AttachmentService.UploadAttachment.
|
||||
func (c *attachmentServiceClient) UploadAttachment(ctx context.Context, req *connect.Request[api.UploadAttachmentRequest]) (*connect.Response[api.UploadAttachmentResponse], error) {
|
||||
return c.uploadAttachment.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// AttachmentServiceHandler is an implementation of the memos.api.AttachmentService service.
|
||||
type AttachmentServiceHandler interface {
|
||||
// CreateAttachment creates a new attachment.
|
||||
CreateAttachment(context.Context, *connect.Request[v1.CreateAttachmentRequest]) (*connect.Response[v1.Attachment], error)
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries
|
||||
// the spec and returns an upload_id; later calls carry that upload_id.
|
||||
// Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// ListAttachments lists attachments linked to memos the caller can read, plus the caller's unlinked uploads.
|
||||
ListAttachments(context.Context, *connect.Request[api.ListAttachmentsRequest]) (*connect.Response[api.ListAttachmentsResponse], error)
|
||||
// GetAttachment gets an attachment by name. An unlinked attachment is visible only to its uploader and admins;
|
||||
// a linked attachment follows the read access of its memo.
|
||||
GetAttachment(context.Context, *connect.Request[api.GetAttachmentRequest]) (*connect.Response[api.Attachment], error)
|
||||
// CreateAttachment creates an attachment from inline content.
|
||||
CreateAttachment(context.Context, *connect.Request[api.CreateAttachmentRequest]) (*connect.Response[api.Attachment], error)
|
||||
// UpdateAttachment updates an attachment. Only `filename` can be updated. The caller must be the uploader or an
|
||||
// admin.
|
||||
UpdateAttachment(context.Context, *connect.Request[api.UpdateAttachmentRequest]) (*connect.Response[api.Attachment], error)
|
||||
// DeleteAttachment deletes an attachment uploaded by the caller.
|
||||
DeleteAttachment(context.Context, *connect.Request[api.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// BatchDeleteAttachments deletes up to 100 attachments in one atomic request. The caller must be the uploader of
|
||||
// each attachment or an admin.
|
||||
BatchDeleteAttachments(context.Context, *connect.Request[api.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries the spec and returns an upload_id;
|
||||
// later calls carry that upload_id. Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// inactivity, and do not survive a server restart.
|
||||
UploadAttachment(context.Context, *connect.Request[v1.UploadAttachmentRequest]) (*connect.Response[v1.UploadAttachmentResponse], error)
|
||||
// ListAttachments lists attachments linked to readable memos and the caller's unlinked uploads.
|
||||
ListAttachments(context.Context, *connect.Request[v1.ListAttachmentsRequest]) (*connect.Response[v1.ListAttachmentsResponse], error)
|
||||
// GetAttachment returns an attachment by name.
|
||||
GetAttachment(context.Context, *connect.Request[v1.GetAttachmentRequest]) (*connect.Response[v1.Attachment], error)
|
||||
// UpdateAttachment updates an attachment.
|
||||
UpdateAttachment(context.Context, *connect.Request[v1.UpdateAttachmentRequest]) (*connect.Response[v1.Attachment], error)
|
||||
// DeleteAttachment deletes an attachment by name.
|
||||
DeleteAttachment(context.Context, *connect.Request[v1.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// BatchDeleteAttachments deletes multiple attachments in one request.
|
||||
BatchDeleteAttachments(context.Context, *connect.Request[v1.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
UploadAttachment(context.Context, *connect.Request[api.UploadAttachmentRequest]) (*connect.Response[api.UploadAttachmentResponse], error)
|
||||
}
|
||||
|
||||
// NewAttachmentServiceHandler builds an HTTP handler from the service implementation. It returns
|
||||
@@ -207,19 +211,7 @@ type AttachmentServiceHandler interface {
|
||||
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
|
||||
// and JSON codecs. They also support gzip compression.
|
||||
func NewAttachmentServiceHandler(svc AttachmentServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
attachmentServiceMethods := v1.File_api_v1_attachment_service_proto.Services().ByName("AttachmentService").Methods()
|
||||
attachmentServiceCreateAttachmentHandler := connect.NewUnaryHandler(
|
||||
AttachmentServiceCreateAttachmentProcedure,
|
||||
svc.CreateAttachment,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("CreateAttachment")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
attachmentServiceUploadAttachmentHandler := connect.NewUnaryHandler(
|
||||
AttachmentServiceUploadAttachmentProcedure,
|
||||
svc.UploadAttachment,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("UploadAttachment")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
attachmentServiceMethods := api.File_api_attachment_service_proto.Services().ByName("AttachmentService").Methods()
|
||||
attachmentServiceListAttachmentsHandler := connect.NewUnaryHandler(
|
||||
AttachmentServiceListAttachmentsProcedure,
|
||||
svc.ListAttachments,
|
||||
@@ -232,6 +224,12 @@ func NewAttachmentServiceHandler(svc AttachmentServiceHandler, opts ...connect.H
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("GetAttachment")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
attachmentServiceCreateAttachmentHandler := connect.NewUnaryHandler(
|
||||
AttachmentServiceCreateAttachmentProcedure,
|
||||
svc.CreateAttachment,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("CreateAttachment")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
attachmentServiceUpdateAttachmentHandler := connect.NewUnaryHandler(
|
||||
AttachmentServiceUpdateAttachmentProcedure,
|
||||
svc.UpdateAttachment,
|
||||
@@ -250,22 +248,28 @@ func NewAttachmentServiceHandler(svc AttachmentServiceHandler, opts ...connect.H
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("BatchDeleteAttachments")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/memos.api.v1.AttachmentService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
attachmentServiceUploadAttachmentHandler := connect.NewUnaryHandler(
|
||||
AttachmentServiceUploadAttachmentProcedure,
|
||||
svc.UploadAttachment,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("UploadAttachment")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/memos.api.AttachmentService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case AttachmentServiceCreateAttachmentProcedure:
|
||||
attachmentServiceCreateAttachmentHandler.ServeHTTP(w, r)
|
||||
case AttachmentServiceUploadAttachmentProcedure:
|
||||
attachmentServiceUploadAttachmentHandler.ServeHTTP(w, r)
|
||||
case AttachmentServiceListAttachmentsProcedure:
|
||||
attachmentServiceListAttachmentsHandler.ServeHTTP(w, r)
|
||||
case AttachmentServiceGetAttachmentProcedure:
|
||||
attachmentServiceGetAttachmentHandler.ServeHTTP(w, r)
|
||||
case AttachmentServiceCreateAttachmentProcedure:
|
||||
attachmentServiceCreateAttachmentHandler.ServeHTTP(w, r)
|
||||
case AttachmentServiceUpdateAttachmentProcedure:
|
||||
attachmentServiceUpdateAttachmentHandler.ServeHTTP(w, r)
|
||||
case AttachmentServiceDeleteAttachmentProcedure:
|
||||
attachmentServiceDeleteAttachmentHandler.ServeHTTP(w, r)
|
||||
case AttachmentServiceBatchDeleteAttachmentsProcedure:
|
||||
attachmentServiceBatchDeleteAttachmentsHandler.ServeHTTP(w, r)
|
||||
case AttachmentServiceUploadAttachmentProcedure:
|
||||
attachmentServiceUploadAttachmentHandler.ServeHTTP(w, r)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
@@ -275,30 +279,30 @@ func NewAttachmentServiceHandler(svc AttachmentServiceHandler, opts ...connect.H
|
||||
// UnimplementedAttachmentServiceHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedAttachmentServiceHandler struct{}
|
||||
|
||||
func (UnimplementedAttachmentServiceHandler) CreateAttachment(context.Context, *connect.Request[v1.CreateAttachmentRequest]) (*connect.Response[v1.Attachment], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.CreateAttachment is not implemented"))
|
||||
func (UnimplementedAttachmentServiceHandler) ListAttachments(context.Context, *connect.Request[api.ListAttachmentsRequest]) (*connect.Response[api.ListAttachmentsResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.ListAttachments is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAttachmentServiceHandler) UploadAttachment(context.Context, *connect.Request[v1.UploadAttachmentRequest]) (*connect.Response[v1.UploadAttachmentResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.UploadAttachment is not implemented"))
|
||||
func (UnimplementedAttachmentServiceHandler) GetAttachment(context.Context, *connect.Request[api.GetAttachmentRequest]) (*connect.Response[api.Attachment], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.GetAttachment is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAttachmentServiceHandler) ListAttachments(context.Context, *connect.Request[v1.ListAttachmentsRequest]) (*connect.Response[v1.ListAttachmentsResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.ListAttachments is not implemented"))
|
||||
func (UnimplementedAttachmentServiceHandler) CreateAttachment(context.Context, *connect.Request[api.CreateAttachmentRequest]) (*connect.Response[api.Attachment], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.CreateAttachment is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAttachmentServiceHandler) GetAttachment(context.Context, *connect.Request[v1.GetAttachmentRequest]) (*connect.Response[v1.Attachment], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.GetAttachment is not implemented"))
|
||||
func (UnimplementedAttachmentServiceHandler) UpdateAttachment(context.Context, *connect.Request[api.UpdateAttachmentRequest]) (*connect.Response[api.Attachment], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.UpdateAttachment is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAttachmentServiceHandler) UpdateAttachment(context.Context, *connect.Request[v1.UpdateAttachmentRequest]) (*connect.Response[v1.Attachment], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.UpdateAttachment is not implemented"))
|
||||
func (UnimplementedAttachmentServiceHandler) DeleteAttachment(context.Context, *connect.Request[api.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.DeleteAttachment is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAttachmentServiceHandler) DeleteAttachment(context.Context, *connect.Request[v1.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.DeleteAttachment is not implemented"))
|
||||
func (UnimplementedAttachmentServiceHandler) BatchDeleteAttachments(context.Context, *connect.Request[api.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.BatchDeleteAttachments is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAttachmentServiceHandler) BatchDeleteAttachments(context.Context, *connect.Request[v1.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.BatchDeleteAttachments is not implemented"))
|
||||
func (UnimplementedAttachmentServiceHandler) UploadAttachment(context.Context, *connect.Request[api.UploadAttachmentRequest]) (*connect.Response[api.UploadAttachmentResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.UploadAttachment is not implemented"))
|
||||
}
|
||||
+105
-103
@@ -1,14 +1,14 @@
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: api/v1/auth_service.proto
|
||||
// Source: api/auth_service.proto
|
||||
|
||||
package apiv1connect
|
||||
package apiconnect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
v1 "github.com/usememos/memos/proto/gen/api/v1"
|
||||
api "github.com/usememos/memos/proto/gen/api"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
http "net/http"
|
||||
strings "strings"
|
||||
@@ -23,7 +23,7 @@ const _ = connect.IsAtLeastVersion1_13_0
|
||||
|
||||
const (
|
||||
// AuthServiceName is the fully-qualified name of the AuthService service.
|
||||
AuthServiceName = "memos.api.v1.AuthService"
|
||||
AuthServiceName = "memos.api.AuthService"
|
||||
)
|
||||
|
||||
// These constants are the fully-qualified names of the RPCs defined in this package. They're
|
||||
@@ -34,38 +34,39 @@ const (
|
||||
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
|
||||
// period.
|
||||
const (
|
||||
// AuthServiceGetCurrentUserProcedure is the fully-qualified name of the AuthService's
|
||||
// GetCurrentUser RPC.
|
||||
AuthServiceGetCurrentUserProcedure = "/memos.api.v1.AuthService/GetCurrentUser"
|
||||
// AuthServiceSignInProcedure is the fully-qualified name of the AuthService's SignIn RPC.
|
||||
AuthServiceSignInProcedure = "/memos.api.v1.AuthService/SignIn"
|
||||
// AuthServiceSignOutProcedure is the fully-qualified name of the AuthService's SignOut RPC.
|
||||
AuthServiceSignOutProcedure = "/memos.api.v1.AuthService/SignOut"
|
||||
AuthServiceSignInProcedure = "/memos.api.AuthService/SignIn"
|
||||
// AuthServiceRefreshTokenProcedure is the fully-qualified name of the AuthService's RefreshToken
|
||||
// RPC.
|
||||
AuthServiceRefreshTokenProcedure = "/memos.api.v1.AuthService/RefreshToken"
|
||||
AuthServiceRefreshTokenProcedure = "/memos.api.AuthService/RefreshToken"
|
||||
// AuthServiceGetCurrentUserProcedure is the fully-qualified name of the AuthService's
|
||||
// GetCurrentUser RPC.
|
||||
AuthServiceGetCurrentUserProcedure = "/memos.api.AuthService/GetCurrentUser"
|
||||
// AuthServiceSignOutProcedure is the fully-qualified name of the AuthService's SignOut RPC.
|
||||
AuthServiceSignOutProcedure = "/memos.api.AuthService/SignOut"
|
||||
)
|
||||
|
||||
// AuthServiceClient is a client for the memos.api.v1.AuthService service.
|
||||
// AuthServiceClient is a client for the memos.api.AuthService service.
|
||||
type AuthServiceClient interface {
|
||||
// GetCurrentUser returns the authenticated user's information.
|
||||
// Validates the access token and returns user details.
|
||||
// Similar to OIDC's /userinfo endpoint.
|
||||
GetCurrentUser(context.Context, *connect.Request[v1.GetCurrentUserRequest]) (*connect.Response[v1.GetCurrentUserResponse], error)
|
||||
// SignIn authenticates a user with credentials and returns tokens.
|
||||
// On success, returns an access token and sets a refresh token cookie.
|
||||
// Supports password-based and SSO authentication methods.
|
||||
SignIn(context.Context, *connect.Request[v1.SignInRequest]) (*connect.Response[v1.SignInResponse], error)
|
||||
// SignOut terminates the user's authentication.
|
||||
// Revokes the refresh token and clears the authentication cookie.
|
||||
SignOut(context.Context, *connect.Request[v1.SignOutRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// RefreshToken exchanges a valid refresh token for a new access token.
|
||||
// The refresh token is read from the HttpOnly cookie.
|
||||
// Returns a new short-lived access token.
|
||||
RefreshToken(context.Context, *connect.Request[v1.RefreshTokenRequest]) (*connect.Response[v1.RefreshTokenResponse], error)
|
||||
// SignIn authenticates a user with password or SSO credentials.
|
||||
// On success, returns a short-lived access token and sets a refresh token in an HttpOnly cookie.
|
||||
// Public. Attempts are rate limited. Archived users cannot sign in.
|
||||
SignIn(context.Context, *connect.Request[api.SignInRequest]) (*connect.Response[api.SignInResponse], error)
|
||||
// RefreshToken exchanges the refresh token for a new access token.
|
||||
// The refresh token is read from the HttpOnly cookie and rotated: the old token is revoked and a new one with a
|
||||
// fresh 30-day expiry is set in the cookie.
|
||||
// Public, so it can be called after the access token has expired.
|
||||
RefreshToken(context.Context, *connect.Request[api.RefreshTokenRequest]) (*connect.Response[api.RefreshTokenResponse], error)
|
||||
// GetCurrentUser returns the authenticated user, similar to OIDC's /userinfo endpoint.
|
||||
// When the caller is not signed in or the account is no longer active, clears the refresh token cookie and returns
|
||||
// UNAUTHENTICATED.
|
||||
GetCurrentUser(context.Context, *connect.Request[api.GetCurrentUserRequest]) (*connect.Response[api.GetCurrentUserResponse], error)
|
||||
// SignOut ends the current session.
|
||||
// Revokes the refresh token from the cookie and clears the cookie.
|
||||
SignOut(context.Context, *connect.Request[api.SignOutRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
}
|
||||
|
||||
// NewAuthServiceClient constructs a client for the memos.api.v1.AuthService service. By default, it
|
||||
// NewAuthServiceClient constructs a client for the memos.api.AuthService service. By default, it
|
||||
// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
|
||||
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
|
||||
// connect.WithGRPCWeb() options.
|
||||
@@ -74,80 +75,81 @@ type AuthServiceClient interface {
|
||||
// http://api.acme.com or https://acme.com/grpc).
|
||||
func NewAuthServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AuthServiceClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
authServiceMethods := v1.File_api_v1_auth_service_proto.Services().ByName("AuthService").Methods()
|
||||
authServiceMethods := api.File_api_auth_service_proto.Services().ByName("AuthService").Methods()
|
||||
return &authServiceClient{
|
||||
getCurrentUser: connect.NewClient[v1.GetCurrentUserRequest, v1.GetCurrentUserResponse](
|
||||
httpClient,
|
||||
baseURL+AuthServiceGetCurrentUserProcedure,
|
||||
connect.WithSchema(authServiceMethods.ByName("GetCurrentUser")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
signIn: connect.NewClient[v1.SignInRequest, v1.SignInResponse](
|
||||
signIn: connect.NewClient[api.SignInRequest, api.SignInResponse](
|
||||
httpClient,
|
||||
baseURL+AuthServiceSignInProcedure,
|
||||
connect.WithSchema(authServiceMethods.ByName("SignIn")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
signOut: connect.NewClient[v1.SignOutRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+AuthServiceSignOutProcedure,
|
||||
connect.WithSchema(authServiceMethods.ByName("SignOut")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
refreshToken: connect.NewClient[v1.RefreshTokenRequest, v1.RefreshTokenResponse](
|
||||
refreshToken: connect.NewClient[api.RefreshTokenRequest, api.RefreshTokenResponse](
|
||||
httpClient,
|
||||
baseURL+AuthServiceRefreshTokenProcedure,
|
||||
connect.WithSchema(authServiceMethods.ByName("RefreshToken")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getCurrentUser: connect.NewClient[api.GetCurrentUserRequest, api.GetCurrentUserResponse](
|
||||
httpClient,
|
||||
baseURL+AuthServiceGetCurrentUserProcedure,
|
||||
connect.WithSchema(authServiceMethods.ByName("GetCurrentUser")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
signOut: connect.NewClient[api.SignOutRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+AuthServiceSignOutProcedure,
|
||||
connect.WithSchema(authServiceMethods.ByName("SignOut")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// authServiceClient implements AuthServiceClient.
|
||||
type authServiceClient struct {
|
||||
getCurrentUser *connect.Client[v1.GetCurrentUserRequest, v1.GetCurrentUserResponse]
|
||||
signIn *connect.Client[v1.SignInRequest, v1.SignInResponse]
|
||||
signOut *connect.Client[v1.SignOutRequest, emptypb.Empty]
|
||||
refreshToken *connect.Client[v1.RefreshTokenRequest, v1.RefreshTokenResponse]
|
||||
signIn *connect.Client[api.SignInRequest, api.SignInResponse]
|
||||
refreshToken *connect.Client[api.RefreshTokenRequest, api.RefreshTokenResponse]
|
||||
getCurrentUser *connect.Client[api.GetCurrentUserRequest, api.GetCurrentUserResponse]
|
||||
signOut *connect.Client[api.SignOutRequest, emptypb.Empty]
|
||||
}
|
||||
|
||||
// GetCurrentUser calls memos.api.v1.AuthService.GetCurrentUser.
|
||||
func (c *authServiceClient) GetCurrentUser(ctx context.Context, req *connect.Request[v1.GetCurrentUserRequest]) (*connect.Response[v1.GetCurrentUserResponse], error) {
|
||||
return c.getCurrentUser.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SignIn calls memos.api.v1.AuthService.SignIn.
|
||||
func (c *authServiceClient) SignIn(ctx context.Context, req *connect.Request[v1.SignInRequest]) (*connect.Response[v1.SignInResponse], error) {
|
||||
// SignIn calls memos.api.AuthService.SignIn.
|
||||
func (c *authServiceClient) SignIn(ctx context.Context, req *connect.Request[api.SignInRequest]) (*connect.Response[api.SignInResponse], error) {
|
||||
return c.signIn.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SignOut calls memos.api.v1.AuthService.SignOut.
|
||||
func (c *authServiceClient) SignOut(ctx context.Context, req *connect.Request[v1.SignOutRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.signOut.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// RefreshToken calls memos.api.v1.AuthService.RefreshToken.
|
||||
func (c *authServiceClient) RefreshToken(ctx context.Context, req *connect.Request[v1.RefreshTokenRequest]) (*connect.Response[v1.RefreshTokenResponse], error) {
|
||||
// RefreshToken calls memos.api.AuthService.RefreshToken.
|
||||
func (c *authServiceClient) RefreshToken(ctx context.Context, req *connect.Request[api.RefreshTokenRequest]) (*connect.Response[api.RefreshTokenResponse], error) {
|
||||
return c.refreshToken.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// AuthServiceHandler is an implementation of the memos.api.v1.AuthService service.
|
||||
// GetCurrentUser calls memos.api.AuthService.GetCurrentUser.
|
||||
func (c *authServiceClient) GetCurrentUser(ctx context.Context, req *connect.Request[api.GetCurrentUserRequest]) (*connect.Response[api.GetCurrentUserResponse], error) {
|
||||
return c.getCurrentUser.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SignOut calls memos.api.AuthService.SignOut.
|
||||
func (c *authServiceClient) SignOut(ctx context.Context, req *connect.Request[api.SignOutRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.signOut.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// AuthServiceHandler is an implementation of the memos.api.AuthService service.
|
||||
type AuthServiceHandler interface {
|
||||
// GetCurrentUser returns the authenticated user's information.
|
||||
// Validates the access token and returns user details.
|
||||
// Similar to OIDC's /userinfo endpoint.
|
||||
GetCurrentUser(context.Context, *connect.Request[v1.GetCurrentUserRequest]) (*connect.Response[v1.GetCurrentUserResponse], error)
|
||||
// SignIn authenticates a user with credentials and returns tokens.
|
||||
// On success, returns an access token and sets a refresh token cookie.
|
||||
// Supports password-based and SSO authentication methods.
|
||||
SignIn(context.Context, *connect.Request[v1.SignInRequest]) (*connect.Response[v1.SignInResponse], error)
|
||||
// SignOut terminates the user's authentication.
|
||||
// Revokes the refresh token and clears the authentication cookie.
|
||||
SignOut(context.Context, *connect.Request[v1.SignOutRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// RefreshToken exchanges a valid refresh token for a new access token.
|
||||
// The refresh token is read from the HttpOnly cookie.
|
||||
// Returns a new short-lived access token.
|
||||
RefreshToken(context.Context, *connect.Request[v1.RefreshTokenRequest]) (*connect.Response[v1.RefreshTokenResponse], error)
|
||||
// SignIn authenticates a user with password or SSO credentials.
|
||||
// On success, returns a short-lived access token and sets a refresh token in an HttpOnly cookie.
|
||||
// Public. Attempts are rate limited. Archived users cannot sign in.
|
||||
SignIn(context.Context, *connect.Request[api.SignInRequest]) (*connect.Response[api.SignInResponse], error)
|
||||
// RefreshToken exchanges the refresh token for a new access token.
|
||||
// The refresh token is read from the HttpOnly cookie and rotated: the old token is revoked and a new one with a
|
||||
// fresh 30-day expiry is set in the cookie.
|
||||
// Public, so it can be called after the access token has expired.
|
||||
RefreshToken(context.Context, *connect.Request[api.RefreshTokenRequest]) (*connect.Response[api.RefreshTokenResponse], error)
|
||||
// GetCurrentUser returns the authenticated user, similar to OIDC's /userinfo endpoint.
|
||||
// When the caller is not signed in or the account is no longer active, clears the refresh token cookie and returns
|
||||
// UNAUTHENTICATED.
|
||||
GetCurrentUser(context.Context, *connect.Request[api.GetCurrentUserRequest]) (*connect.Response[api.GetCurrentUserResponse], error)
|
||||
// SignOut ends the current session.
|
||||
// Revokes the refresh token from the cookie and clears the cookie.
|
||||
SignOut(context.Context, *connect.Request[api.SignOutRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
}
|
||||
|
||||
// NewAuthServiceHandler builds an HTTP handler from the service implementation. It returns the path
|
||||
@@ -156,41 +158,41 @@ type AuthServiceHandler interface {
|
||||
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
|
||||
// and JSON codecs. They also support gzip compression.
|
||||
func NewAuthServiceHandler(svc AuthServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
authServiceMethods := v1.File_api_v1_auth_service_proto.Services().ByName("AuthService").Methods()
|
||||
authServiceGetCurrentUserHandler := connect.NewUnaryHandler(
|
||||
AuthServiceGetCurrentUserProcedure,
|
||||
svc.GetCurrentUser,
|
||||
connect.WithSchema(authServiceMethods.ByName("GetCurrentUser")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
authServiceMethods := api.File_api_auth_service_proto.Services().ByName("AuthService").Methods()
|
||||
authServiceSignInHandler := connect.NewUnaryHandler(
|
||||
AuthServiceSignInProcedure,
|
||||
svc.SignIn,
|
||||
connect.WithSchema(authServiceMethods.ByName("SignIn")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
authServiceSignOutHandler := connect.NewUnaryHandler(
|
||||
AuthServiceSignOutProcedure,
|
||||
svc.SignOut,
|
||||
connect.WithSchema(authServiceMethods.ByName("SignOut")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
authServiceRefreshTokenHandler := connect.NewUnaryHandler(
|
||||
AuthServiceRefreshTokenProcedure,
|
||||
svc.RefreshToken,
|
||||
connect.WithSchema(authServiceMethods.ByName("RefreshToken")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/memos.api.v1.AuthService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
authServiceGetCurrentUserHandler := connect.NewUnaryHandler(
|
||||
AuthServiceGetCurrentUserProcedure,
|
||||
svc.GetCurrentUser,
|
||||
connect.WithSchema(authServiceMethods.ByName("GetCurrentUser")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
authServiceSignOutHandler := connect.NewUnaryHandler(
|
||||
AuthServiceSignOutProcedure,
|
||||
svc.SignOut,
|
||||
connect.WithSchema(authServiceMethods.ByName("SignOut")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/memos.api.AuthService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case AuthServiceGetCurrentUserProcedure:
|
||||
authServiceGetCurrentUserHandler.ServeHTTP(w, r)
|
||||
case AuthServiceSignInProcedure:
|
||||
authServiceSignInHandler.ServeHTTP(w, r)
|
||||
case AuthServiceSignOutProcedure:
|
||||
authServiceSignOutHandler.ServeHTTP(w, r)
|
||||
case AuthServiceRefreshTokenProcedure:
|
||||
authServiceRefreshTokenHandler.ServeHTTP(w, r)
|
||||
case AuthServiceGetCurrentUserProcedure:
|
||||
authServiceGetCurrentUserHandler.ServeHTTP(w, r)
|
||||
case AuthServiceSignOutProcedure:
|
||||
authServiceSignOutHandler.ServeHTTP(w, r)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
@@ -200,18 +202,18 @@ func NewAuthServiceHandler(svc AuthServiceHandler, opts ...connect.HandlerOption
|
||||
// UnimplementedAuthServiceHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedAuthServiceHandler struct{}
|
||||
|
||||
func (UnimplementedAuthServiceHandler) GetCurrentUser(context.Context, *connect.Request[v1.GetCurrentUserRequest]) (*connect.Response[v1.GetCurrentUserResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AuthService.GetCurrentUser is not implemented"))
|
||||
func (UnimplementedAuthServiceHandler) SignIn(context.Context, *connect.Request[api.SignInRequest]) (*connect.Response[api.SignInResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AuthService.SignIn is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAuthServiceHandler) SignIn(context.Context, *connect.Request[v1.SignInRequest]) (*connect.Response[v1.SignInResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AuthService.SignIn is not implemented"))
|
||||
func (UnimplementedAuthServiceHandler) RefreshToken(context.Context, *connect.Request[api.RefreshTokenRequest]) (*connect.Response[api.RefreshTokenResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AuthService.RefreshToken is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAuthServiceHandler) SignOut(context.Context, *connect.Request[v1.SignOutRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AuthService.SignOut is not implemented"))
|
||||
func (UnimplementedAuthServiceHandler) GetCurrentUser(context.Context, *connect.Request[api.GetCurrentUserRequest]) (*connect.Response[api.GetCurrentUserResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AuthService.GetCurrentUser is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAuthServiceHandler) RefreshToken(context.Context, *connect.Request[v1.RefreshTokenRequest]) (*connect.Response[v1.RefreshTokenResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AuthService.RefreshToken is not implemented"))
|
||||
func (UnimplementedAuthServiceHandler) SignOut(context.Context, *connect.Request[api.SignOutRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AuthService.SignOut is not implemented"))
|
||||
}
|
||||
+69
-55
@@ -1,14 +1,14 @@
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: api/v1/idp_service.proto
|
||||
// Source: api/idp_service.proto
|
||||
|
||||
package apiv1connect
|
||||
package apiconnect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
v1 "github.com/usememos/memos/proto/gen/api/v1"
|
||||
api "github.com/usememos/memos/proto/gen/api"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
http "net/http"
|
||||
strings "strings"
|
||||
@@ -23,7 +23,7 @@ const _ = connect.IsAtLeastVersion1_13_0
|
||||
|
||||
const (
|
||||
// IdentityProviderServiceName is the fully-qualified name of the IdentityProviderService service.
|
||||
IdentityProviderServiceName = "memos.api.v1.IdentityProviderService"
|
||||
IdentityProviderServiceName = "memos.api.IdentityProviderService"
|
||||
)
|
||||
|
||||
// These constants are the fully-qualified names of the RPCs defined in this package. They're
|
||||
@@ -36,36 +36,43 @@ const (
|
||||
const (
|
||||
// IdentityProviderServiceListIdentityProvidersProcedure is the fully-qualified name of the
|
||||
// IdentityProviderService's ListIdentityProviders RPC.
|
||||
IdentityProviderServiceListIdentityProvidersProcedure = "/memos.api.v1.IdentityProviderService/ListIdentityProviders"
|
||||
IdentityProviderServiceListIdentityProvidersProcedure = "/memos.api.IdentityProviderService/ListIdentityProviders"
|
||||
// IdentityProviderServiceGetIdentityProviderProcedure is the fully-qualified name of the
|
||||
// IdentityProviderService's GetIdentityProvider RPC.
|
||||
IdentityProviderServiceGetIdentityProviderProcedure = "/memos.api.v1.IdentityProviderService/GetIdentityProvider"
|
||||
IdentityProviderServiceGetIdentityProviderProcedure = "/memos.api.IdentityProviderService/GetIdentityProvider"
|
||||
// IdentityProviderServiceCreateIdentityProviderProcedure is the fully-qualified name of the
|
||||
// IdentityProviderService's CreateIdentityProvider RPC.
|
||||
IdentityProviderServiceCreateIdentityProviderProcedure = "/memos.api.v1.IdentityProviderService/CreateIdentityProvider"
|
||||
IdentityProviderServiceCreateIdentityProviderProcedure = "/memos.api.IdentityProviderService/CreateIdentityProvider"
|
||||
// IdentityProviderServiceUpdateIdentityProviderProcedure is the fully-qualified name of the
|
||||
// IdentityProviderService's UpdateIdentityProvider RPC.
|
||||
IdentityProviderServiceUpdateIdentityProviderProcedure = "/memos.api.v1.IdentityProviderService/UpdateIdentityProvider"
|
||||
IdentityProviderServiceUpdateIdentityProviderProcedure = "/memos.api.IdentityProviderService/UpdateIdentityProvider"
|
||||
// IdentityProviderServiceDeleteIdentityProviderProcedure is the fully-qualified name of the
|
||||
// IdentityProviderService's DeleteIdentityProvider RPC.
|
||||
IdentityProviderServiceDeleteIdentityProviderProcedure = "/memos.api.v1.IdentityProviderService/DeleteIdentityProvider"
|
||||
IdentityProviderServiceDeleteIdentityProviderProcedure = "/memos.api.IdentityProviderService/DeleteIdentityProvider"
|
||||
)
|
||||
|
||||
// IdentityProviderServiceClient is a client for the memos.api.v1.IdentityProviderService service.
|
||||
// IdentityProviderServiceClient is a client for the memos.api.IdentityProviderService service.
|
||||
type IdentityProviderServiceClient interface {
|
||||
// ListIdentityProviders lists identity providers.
|
||||
ListIdentityProviders(context.Context, *connect.Request[v1.ListIdentityProvidersRequest]) (*connect.Response[v1.ListIdentityProvidersResponse], error)
|
||||
// Public, so the sign-in page can show SSO options. Client secrets are never returned.
|
||||
ListIdentityProviders(context.Context, *connect.Request[api.ListIdentityProvidersRequest]) (*connect.Response[api.ListIdentityProvidersResponse], error)
|
||||
// GetIdentityProvider gets an identity provider.
|
||||
GetIdentityProvider(context.Context, *connect.Request[v1.GetIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error)
|
||||
// The client secret is never returned.
|
||||
GetIdentityProvider(context.Context, *connect.Request[api.GetIdentityProviderRequest]) (*connect.Response[api.IdentityProvider], error)
|
||||
// CreateIdentityProvider creates an identity provider.
|
||||
CreateIdentityProvider(context.Context, *connect.Request[v1.CreateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error)
|
||||
// Requires the admin role. Fails with FAILED_PRECONDITION when the ID belongs to a provider configured by the
|
||||
// deployment.
|
||||
CreateIdentityProvider(context.Context, *connect.Request[api.CreateIdentityProviderRequest]) (*connect.Response[api.IdentityProvider], error)
|
||||
// UpdateIdentityProvider updates an identity provider.
|
||||
UpdateIdentityProvider(context.Context, *connect.Request[v1.UpdateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error)
|
||||
// Requires the admin role. Providers configured by the deployment cannot be updated.
|
||||
UpdateIdentityProvider(context.Context, *connect.Request[api.UpdateIdentityProviderRequest]) (*connect.Response[api.IdentityProvider], error)
|
||||
// DeleteIdentityProvider deletes an identity provider.
|
||||
DeleteIdentityProvider(context.Context, *connect.Request[v1.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// Requires the admin role. Providers configured by the deployment cannot be deleted. Fails with
|
||||
// FAILED_PRECONDITION when password sign-in is disabled for regular users and no other effective provider remains.
|
||||
DeleteIdentityProvider(context.Context, *connect.Request[api.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
}
|
||||
|
||||
// NewIdentityProviderServiceClient constructs a client for the memos.api.v1.IdentityProviderService
|
||||
// NewIdentityProviderServiceClient constructs a client for the memos.api.IdentityProviderService
|
||||
// service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for
|
||||
// gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply
|
||||
// the connect.WithGRPC() or connect.WithGRPCWeb() options.
|
||||
@@ -74,33 +81,33 @@ type IdentityProviderServiceClient interface {
|
||||
// http://api.acme.com or https://acme.com/grpc).
|
||||
func NewIdentityProviderServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) IdentityProviderServiceClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
identityProviderServiceMethods := v1.File_api_v1_idp_service_proto.Services().ByName("IdentityProviderService").Methods()
|
||||
identityProviderServiceMethods := api.File_api_idp_service_proto.Services().ByName("IdentityProviderService").Methods()
|
||||
return &identityProviderServiceClient{
|
||||
listIdentityProviders: connect.NewClient[v1.ListIdentityProvidersRequest, v1.ListIdentityProvidersResponse](
|
||||
listIdentityProviders: connect.NewClient[api.ListIdentityProvidersRequest, api.ListIdentityProvidersResponse](
|
||||
httpClient,
|
||||
baseURL+IdentityProviderServiceListIdentityProvidersProcedure,
|
||||
connect.WithSchema(identityProviderServiceMethods.ByName("ListIdentityProviders")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getIdentityProvider: connect.NewClient[v1.GetIdentityProviderRequest, v1.IdentityProvider](
|
||||
getIdentityProvider: connect.NewClient[api.GetIdentityProviderRequest, api.IdentityProvider](
|
||||
httpClient,
|
||||
baseURL+IdentityProviderServiceGetIdentityProviderProcedure,
|
||||
connect.WithSchema(identityProviderServiceMethods.ByName("GetIdentityProvider")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
createIdentityProvider: connect.NewClient[v1.CreateIdentityProviderRequest, v1.IdentityProvider](
|
||||
createIdentityProvider: connect.NewClient[api.CreateIdentityProviderRequest, api.IdentityProvider](
|
||||
httpClient,
|
||||
baseURL+IdentityProviderServiceCreateIdentityProviderProcedure,
|
||||
connect.WithSchema(identityProviderServiceMethods.ByName("CreateIdentityProvider")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
updateIdentityProvider: connect.NewClient[v1.UpdateIdentityProviderRequest, v1.IdentityProvider](
|
||||
updateIdentityProvider: connect.NewClient[api.UpdateIdentityProviderRequest, api.IdentityProvider](
|
||||
httpClient,
|
||||
baseURL+IdentityProviderServiceUpdateIdentityProviderProcedure,
|
||||
connect.WithSchema(identityProviderServiceMethods.ByName("UpdateIdentityProvider")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
deleteIdentityProvider: connect.NewClient[v1.DeleteIdentityProviderRequest, emptypb.Empty](
|
||||
deleteIdentityProvider: connect.NewClient[api.DeleteIdentityProviderRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+IdentityProviderServiceDeleteIdentityProviderProcedure,
|
||||
connect.WithSchema(identityProviderServiceMethods.ByName("DeleteIdentityProvider")),
|
||||
@@ -111,51 +118,58 @@ func NewIdentityProviderServiceClient(httpClient connect.HTTPClient, baseURL str
|
||||
|
||||
// identityProviderServiceClient implements IdentityProviderServiceClient.
|
||||
type identityProviderServiceClient struct {
|
||||
listIdentityProviders *connect.Client[v1.ListIdentityProvidersRequest, v1.ListIdentityProvidersResponse]
|
||||
getIdentityProvider *connect.Client[v1.GetIdentityProviderRequest, v1.IdentityProvider]
|
||||
createIdentityProvider *connect.Client[v1.CreateIdentityProviderRequest, v1.IdentityProvider]
|
||||
updateIdentityProvider *connect.Client[v1.UpdateIdentityProviderRequest, v1.IdentityProvider]
|
||||
deleteIdentityProvider *connect.Client[v1.DeleteIdentityProviderRequest, emptypb.Empty]
|
||||
listIdentityProviders *connect.Client[api.ListIdentityProvidersRequest, api.ListIdentityProvidersResponse]
|
||||
getIdentityProvider *connect.Client[api.GetIdentityProviderRequest, api.IdentityProvider]
|
||||
createIdentityProvider *connect.Client[api.CreateIdentityProviderRequest, api.IdentityProvider]
|
||||
updateIdentityProvider *connect.Client[api.UpdateIdentityProviderRequest, api.IdentityProvider]
|
||||
deleteIdentityProvider *connect.Client[api.DeleteIdentityProviderRequest, emptypb.Empty]
|
||||
}
|
||||
|
||||
// ListIdentityProviders calls memos.api.v1.IdentityProviderService.ListIdentityProviders.
|
||||
func (c *identityProviderServiceClient) ListIdentityProviders(ctx context.Context, req *connect.Request[v1.ListIdentityProvidersRequest]) (*connect.Response[v1.ListIdentityProvidersResponse], error) {
|
||||
// ListIdentityProviders calls memos.api.IdentityProviderService.ListIdentityProviders.
|
||||
func (c *identityProviderServiceClient) ListIdentityProviders(ctx context.Context, req *connect.Request[api.ListIdentityProvidersRequest]) (*connect.Response[api.ListIdentityProvidersResponse], error) {
|
||||
return c.listIdentityProviders.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetIdentityProvider calls memos.api.v1.IdentityProviderService.GetIdentityProvider.
|
||||
func (c *identityProviderServiceClient) GetIdentityProvider(ctx context.Context, req *connect.Request[v1.GetIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error) {
|
||||
// GetIdentityProvider calls memos.api.IdentityProviderService.GetIdentityProvider.
|
||||
func (c *identityProviderServiceClient) GetIdentityProvider(ctx context.Context, req *connect.Request[api.GetIdentityProviderRequest]) (*connect.Response[api.IdentityProvider], error) {
|
||||
return c.getIdentityProvider.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// CreateIdentityProvider calls memos.api.v1.IdentityProviderService.CreateIdentityProvider.
|
||||
func (c *identityProviderServiceClient) CreateIdentityProvider(ctx context.Context, req *connect.Request[v1.CreateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error) {
|
||||
// CreateIdentityProvider calls memos.api.IdentityProviderService.CreateIdentityProvider.
|
||||
func (c *identityProviderServiceClient) CreateIdentityProvider(ctx context.Context, req *connect.Request[api.CreateIdentityProviderRequest]) (*connect.Response[api.IdentityProvider], error) {
|
||||
return c.createIdentityProvider.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// UpdateIdentityProvider calls memos.api.v1.IdentityProviderService.UpdateIdentityProvider.
|
||||
func (c *identityProviderServiceClient) UpdateIdentityProvider(ctx context.Context, req *connect.Request[v1.UpdateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error) {
|
||||
// UpdateIdentityProvider calls memos.api.IdentityProviderService.UpdateIdentityProvider.
|
||||
func (c *identityProviderServiceClient) UpdateIdentityProvider(ctx context.Context, req *connect.Request[api.UpdateIdentityProviderRequest]) (*connect.Response[api.IdentityProvider], error) {
|
||||
return c.updateIdentityProvider.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// DeleteIdentityProvider calls memos.api.v1.IdentityProviderService.DeleteIdentityProvider.
|
||||
func (c *identityProviderServiceClient) DeleteIdentityProvider(ctx context.Context, req *connect.Request[v1.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
// DeleteIdentityProvider calls memos.api.IdentityProviderService.DeleteIdentityProvider.
|
||||
func (c *identityProviderServiceClient) DeleteIdentityProvider(ctx context.Context, req *connect.Request[api.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.deleteIdentityProvider.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// IdentityProviderServiceHandler is an implementation of the memos.api.v1.IdentityProviderService
|
||||
// IdentityProviderServiceHandler is an implementation of the memos.api.IdentityProviderService
|
||||
// service.
|
||||
type IdentityProviderServiceHandler interface {
|
||||
// ListIdentityProviders lists identity providers.
|
||||
ListIdentityProviders(context.Context, *connect.Request[v1.ListIdentityProvidersRequest]) (*connect.Response[v1.ListIdentityProvidersResponse], error)
|
||||
// Public, so the sign-in page can show SSO options. Client secrets are never returned.
|
||||
ListIdentityProviders(context.Context, *connect.Request[api.ListIdentityProvidersRequest]) (*connect.Response[api.ListIdentityProvidersResponse], error)
|
||||
// GetIdentityProvider gets an identity provider.
|
||||
GetIdentityProvider(context.Context, *connect.Request[v1.GetIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error)
|
||||
// The client secret is never returned.
|
||||
GetIdentityProvider(context.Context, *connect.Request[api.GetIdentityProviderRequest]) (*connect.Response[api.IdentityProvider], error)
|
||||
// CreateIdentityProvider creates an identity provider.
|
||||
CreateIdentityProvider(context.Context, *connect.Request[v1.CreateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error)
|
||||
// Requires the admin role. Fails with FAILED_PRECONDITION when the ID belongs to a provider configured by the
|
||||
// deployment.
|
||||
CreateIdentityProvider(context.Context, *connect.Request[api.CreateIdentityProviderRequest]) (*connect.Response[api.IdentityProvider], error)
|
||||
// UpdateIdentityProvider updates an identity provider.
|
||||
UpdateIdentityProvider(context.Context, *connect.Request[v1.UpdateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error)
|
||||
// Requires the admin role. Providers configured by the deployment cannot be updated.
|
||||
UpdateIdentityProvider(context.Context, *connect.Request[api.UpdateIdentityProviderRequest]) (*connect.Response[api.IdentityProvider], error)
|
||||
// DeleteIdentityProvider deletes an identity provider.
|
||||
DeleteIdentityProvider(context.Context, *connect.Request[v1.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// Requires the admin role. Providers configured by the deployment cannot be deleted. Fails with
|
||||
// FAILED_PRECONDITION when password sign-in is disabled for regular users and no other effective provider remains.
|
||||
DeleteIdentityProvider(context.Context, *connect.Request[api.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
}
|
||||
|
||||
// NewIdentityProviderServiceHandler builds an HTTP handler from the service implementation. It
|
||||
@@ -164,7 +178,7 @@ type IdentityProviderServiceHandler interface {
|
||||
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
|
||||
// and JSON codecs. They also support gzip compression.
|
||||
func NewIdentityProviderServiceHandler(svc IdentityProviderServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
identityProviderServiceMethods := v1.File_api_v1_idp_service_proto.Services().ByName("IdentityProviderService").Methods()
|
||||
identityProviderServiceMethods := api.File_api_idp_service_proto.Services().ByName("IdentityProviderService").Methods()
|
||||
identityProviderServiceListIdentityProvidersHandler := connect.NewUnaryHandler(
|
||||
IdentityProviderServiceListIdentityProvidersProcedure,
|
||||
svc.ListIdentityProviders,
|
||||
@@ -195,7 +209,7 @@ func NewIdentityProviderServiceHandler(svc IdentityProviderServiceHandler, opts
|
||||
connect.WithSchema(identityProviderServiceMethods.ByName("DeleteIdentityProvider")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/memos.api.v1.IdentityProviderService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
return "/memos.api.IdentityProviderService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case IdentityProviderServiceListIdentityProvidersProcedure:
|
||||
identityProviderServiceListIdentityProvidersHandler.ServeHTTP(w, r)
|
||||
@@ -216,22 +230,22 @@ func NewIdentityProviderServiceHandler(svc IdentityProviderServiceHandler, opts
|
||||
// UnimplementedIdentityProviderServiceHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedIdentityProviderServiceHandler struct{}
|
||||
|
||||
func (UnimplementedIdentityProviderServiceHandler) ListIdentityProviders(context.Context, *connect.Request[v1.ListIdentityProvidersRequest]) (*connect.Response[v1.ListIdentityProvidersResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.IdentityProviderService.ListIdentityProviders is not implemented"))
|
||||
func (UnimplementedIdentityProviderServiceHandler) ListIdentityProviders(context.Context, *connect.Request[api.ListIdentityProvidersRequest]) (*connect.Response[api.ListIdentityProvidersResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.IdentityProviderService.ListIdentityProviders is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedIdentityProviderServiceHandler) GetIdentityProvider(context.Context, *connect.Request[v1.GetIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.IdentityProviderService.GetIdentityProvider is not implemented"))
|
||||
func (UnimplementedIdentityProviderServiceHandler) GetIdentityProvider(context.Context, *connect.Request[api.GetIdentityProviderRequest]) (*connect.Response[api.IdentityProvider], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.IdentityProviderService.GetIdentityProvider is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedIdentityProviderServiceHandler) CreateIdentityProvider(context.Context, *connect.Request[v1.CreateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.IdentityProviderService.CreateIdentityProvider is not implemented"))
|
||||
func (UnimplementedIdentityProviderServiceHandler) CreateIdentityProvider(context.Context, *connect.Request[api.CreateIdentityProviderRequest]) (*connect.Response[api.IdentityProvider], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.IdentityProviderService.CreateIdentityProvider is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedIdentityProviderServiceHandler) UpdateIdentityProvider(context.Context, *connect.Request[v1.UpdateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.IdentityProviderService.UpdateIdentityProvider is not implemented"))
|
||||
func (UnimplementedIdentityProviderServiceHandler) UpdateIdentityProvider(context.Context, *connect.Request[api.UpdateIdentityProviderRequest]) (*connect.Response[api.IdentityProvider], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.IdentityProviderService.UpdateIdentityProvider is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedIdentityProviderServiceHandler) DeleteIdentityProvider(context.Context, *connect.Request[v1.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.IdentityProviderService.DeleteIdentityProvider is not implemented"))
|
||||
func (UnimplementedIdentityProviderServiceHandler) DeleteIdentityProvider(context.Context, *connect.Request[api.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.IdentityProviderService.DeleteIdentityProvider is not implemented"))
|
||||
}
|
||||
+82
-76
@@ -1,14 +1,14 @@
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: api/v1/instance_service.proto
|
||||
// Source: api/instance_service.proto
|
||||
|
||||
package apiv1connect
|
||||
package apiconnect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
v1 "github.com/usememos/memos/proto/gen/api/v1"
|
||||
api "github.com/usememos/memos/proto/gen/api"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
http "net/http"
|
||||
strings "strings"
|
||||
@@ -23,7 +23,7 @@ const _ = connect.IsAtLeastVersion1_13_0
|
||||
|
||||
const (
|
||||
// InstanceServiceName is the fully-qualified name of the InstanceService service.
|
||||
InstanceServiceName = "memos.api.v1.InstanceService"
|
||||
InstanceServiceName = "memos.api.InstanceService"
|
||||
)
|
||||
|
||||
// These constants are the fully-qualified names of the RPCs defined in this package. They're
|
||||
@@ -36,41 +36,44 @@ const (
|
||||
const (
|
||||
// InstanceServiceGetInstanceProfileProcedure is the fully-qualified name of the InstanceService's
|
||||
// GetInstanceProfile RPC.
|
||||
InstanceServiceGetInstanceProfileProcedure = "/memos.api.v1.InstanceService/GetInstanceProfile"
|
||||
InstanceServiceGetInstanceProfileProcedure = "/memos.api.InstanceService/GetInstanceProfile"
|
||||
// InstanceServiceGetInstanceSettingProcedure is the fully-qualified name of the InstanceService's
|
||||
// GetInstanceSetting RPC.
|
||||
InstanceServiceGetInstanceSettingProcedure = "/memos.api.v1.InstanceService/GetInstanceSetting"
|
||||
InstanceServiceGetInstanceSettingProcedure = "/memos.api.InstanceService/GetInstanceSetting"
|
||||
// InstanceServiceBatchGetInstanceSettingsProcedure is the fully-qualified name of the
|
||||
// InstanceService's BatchGetInstanceSettings RPC.
|
||||
InstanceServiceBatchGetInstanceSettingsProcedure = "/memos.api.v1.InstanceService/BatchGetInstanceSettings"
|
||||
InstanceServiceBatchGetInstanceSettingsProcedure = "/memos.api.InstanceService/BatchGetInstanceSettings"
|
||||
// InstanceServiceUpdateInstanceSettingProcedure is the fully-qualified name of the
|
||||
// InstanceService's UpdateInstanceSetting RPC.
|
||||
InstanceServiceUpdateInstanceSettingProcedure = "/memos.api.v1.InstanceService/UpdateInstanceSetting"
|
||||
InstanceServiceUpdateInstanceSettingProcedure = "/memos.api.InstanceService/UpdateInstanceSetting"
|
||||
// InstanceServiceTestInstanceEmailSettingProcedure is the fully-qualified name of the
|
||||
// InstanceService's TestInstanceEmailSetting RPC.
|
||||
InstanceServiceTestInstanceEmailSettingProcedure = "/memos.api.v1.InstanceService/TestInstanceEmailSetting"
|
||||
InstanceServiceTestInstanceEmailSettingProcedure = "/memos.api.InstanceService/TestInstanceEmailSetting"
|
||||
// InstanceServiceGetInstanceStatsProcedure is the fully-qualified name of the InstanceService's
|
||||
// GetInstanceStats RPC.
|
||||
InstanceServiceGetInstanceStatsProcedure = "/memos.api.v1.InstanceService/GetInstanceStats"
|
||||
InstanceServiceGetInstanceStatsProcedure = "/memos.api.InstanceService/GetInstanceStats"
|
||||
)
|
||||
|
||||
// InstanceServiceClient is a client for the memos.api.v1.InstanceService service.
|
||||
// InstanceServiceClient is a client for the memos.api.InstanceService service.
|
||||
type InstanceServiceClient interface {
|
||||
// Gets the instance profile.
|
||||
GetInstanceProfile(context.Context, *connect.Request[v1.GetInstanceProfileRequest]) (*connect.Response[v1.InstanceProfile], error)
|
||||
// Gets an instance setting.
|
||||
GetInstanceSetting(context.Context, *connect.Request[v1.GetInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error)
|
||||
// Batch gets instance settings.
|
||||
BatchGetInstanceSettings(context.Context, *connect.Request[v1.BatchGetInstanceSettingsRequest]) (*connect.Response[v1.BatchGetInstanceSettingsResponse], error)
|
||||
// Updates an instance setting.
|
||||
UpdateInstanceSetting(context.Context, *connect.Request[v1.UpdateInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error)
|
||||
// Tests notification email delivery with the provided or stored SMTP settings.
|
||||
TestInstanceEmailSetting(context.Context, *connect.Request[v1.TestInstanceEmailSettingRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// GetInstanceStats returns resource usage statistics for the instance. Admin only.
|
||||
GetInstanceStats(context.Context, *connect.Request[v1.GetInstanceStatsRequest]) (*connect.Response[v1.InstanceStats], error)
|
||||
// GetInstanceProfile gets the instance profile. Available without authentication, including on a private instance.
|
||||
GetInstanceProfile(context.Context, *connect.Request[api.GetInstanceProfileRequest]) (*connect.Response[api.InstanceProfile], error)
|
||||
// GetInstanceSetting gets an instance setting. Available without authentication, except STORAGE and NOTIFICATION,
|
||||
// which are admin only, and AI, which requires a signed-in user and hides transcription defaults from non-admins.
|
||||
GetInstanceSetting(context.Context, *connect.Request[api.GetInstanceSettingRequest]) (*connect.Response[api.InstanceSetting], error)
|
||||
// BatchGetInstanceSettings gets up to 100 instance settings in request order, with the same access rules as
|
||||
// GetInstanceSetting. The call fails if any setting cannot be returned.
|
||||
BatchGetInstanceSettings(context.Context, *connect.Request[api.BatchGetInstanceSettingsRequest]) (*connect.Response[api.BatchGetInstanceSettingsResponse], error)
|
||||
// UpdateInstanceSetting replaces an instance setting. Admin only. Settings configured by the deployment cannot be
|
||||
// updated. Empty write-only credentials keep the stored values.
|
||||
UpdateInstanceSetting(context.Context, *connect.Request[api.UpdateInstanceSettingRequest]) (*connect.Response[api.InstanceSetting], error)
|
||||
// TestInstanceEmailSetting sends a test email with the provided or stored SMTP settings. Admin only.
|
||||
TestInstanceEmailSetting(context.Context, *connect.Request[api.TestInstanceEmailSettingRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// GetInstanceStats gets resource usage statistics for the instance. Admin only. Results are cached for 60 seconds.
|
||||
GetInstanceStats(context.Context, *connect.Request[api.GetInstanceStatsRequest]) (*connect.Response[api.InstanceStats], error)
|
||||
}
|
||||
|
||||
// NewInstanceServiceClient constructs a client for the memos.api.v1.InstanceService service. By
|
||||
// NewInstanceServiceClient constructs a client for the memos.api.InstanceService service. By
|
||||
// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
|
||||
// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
|
||||
// connect.WithGRPC() or connect.WithGRPCWeb() options.
|
||||
@@ -79,39 +82,39 @@ type InstanceServiceClient interface {
|
||||
// http://api.acme.com or https://acme.com/grpc).
|
||||
func NewInstanceServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) InstanceServiceClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
instanceServiceMethods := v1.File_api_v1_instance_service_proto.Services().ByName("InstanceService").Methods()
|
||||
instanceServiceMethods := api.File_api_instance_service_proto.Services().ByName("InstanceService").Methods()
|
||||
return &instanceServiceClient{
|
||||
getInstanceProfile: connect.NewClient[v1.GetInstanceProfileRequest, v1.InstanceProfile](
|
||||
getInstanceProfile: connect.NewClient[api.GetInstanceProfileRequest, api.InstanceProfile](
|
||||
httpClient,
|
||||
baseURL+InstanceServiceGetInstanceProfileProcedure,
|
||||
connect.WithSchema(instanceServiceMethods.ByName("GetInstanceProfile")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getInstanceSetting: connect.NewClient[v1.GetInstanceSettingRequest, v1.InstanceSetting](
|
||||
getInstanceSetting: connect.NewClient[api.GetInstanceSettingRequest, api.InstanceSetting](
|
||||
httpClient,
|
||||
baseURL+InstanceServiceGetInstanceSettingProcedure,
|
||||
connect.WithSchema(instanceServiceMethods.ByName("GetInstanceSetting")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
batchGetInstanceSettings: connect.NewClient[v1.BatchGetInstanceSettingsRequest, v1.BatchGetInstanceSettingsResponse](
|
||||
batchGetInstanceSettings: connect.NewClient[api.BatchGetInstanceSettingsRequest, api.BatchGetInstanceSettingsResponse](
|
||||
httpClient,
|
||||
baseURL+InstanceServiceBatchGetInstanceSettingsProcedure,
|
||||
connect.WithSchema(instanceServiceMethods.ByName("BatchGetInstanceSettings")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
updateInstanceSetting: connect.NewClient[v1.UpdateInstanceSettingRequest, v1.InstanceSetting](
|
||||
updateInstanceSetting: connect.NewClient[api.UpdateInstanceSettingRequest, api.InstanceSetting](
|
||||
httpClient,
|
||||
baseURL+InstanceServiceUpdateInstanceSettingProcedure,
|
||||
connect.WithSchema(instanceServiceMethods.ByName("UpdateInstanceSetting")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
testInstanceEmailSetting: connect.NewClient[v1.TestInstanceEmailSettingRequest, emptypb.Empty](
|
||||
testInstanceEmailSetting: connect.NewClient[api.TestInstanceEmailSettingRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+InstanceServiceTestInstanceEmailSettingProcedure,
|
||||
connect.WithSchema(instanceServiceMethods.ByName("TestInstanceEmailSetting")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getInstanceStats: connect.NewClient[v1.GetInstanceStatsRequest, v1.InstanceStats](
|
||||
getInstanceStats: connect.NewClient[api.GetInstanceStatsRequest, api.InstanceStats](
|
||||
httpClient,
|
||||
baseURL+InstanceServiceGetInstanceStatsProcedure,
|
||||
connect.WithSchema(instanceServiceMethods.ByName("GetInstanceStats")),
|
||||
@@ -122,58 +125,61 @@ func NewInstanceServiceClient(httpClient connect.HTTPClient, baseURL string, opt
|
||||
|
||||
// instanceServiceClient implements InstanceServiceClient.
|
||||
type instanceServiceClient struct {
|
||||
getInstanceProfile *connect.Client[v1.GetInstanceProfileRequest, v1.InstanceProfile]
|
||||
getInstanceSetting *connect.Client[v1.GetInstanceSettingRequest, v1.InstanceSetting]
|
||||
batchGetInstanceSettings *connect.Client[v1.BatchGetInstanceSettingsRequest, v1.BatchGetInstanceSettingsResponse]
|
||||
updateInstanceSetting *connect.Client[v1.UpdateInstanceSettingRequest, v1.InstanceSetting]
|
||||
testInstanceEmailSetting *connect.Client[v1.TestInstanceEmailSettingRequest, emptypb.Empty]
|
||||
getInstanceStats *connect.Client[v1.GetInstanceStatsRequest, v1.InstanceStats]
|
||||
getInstanceProfile *connect.Client[api.GetInstanceProfileRequest, api.InstanceProfile]
|
||||
getInstanceSetting *connect.Client[api.GetInstanceSettingRequest, api.InstanceSetting]
|
||||
batchGetInstanceSettings *connect.Client[api.BatchGetInstanceSettingsRequest, api.BatchGetInstanceSettingsResponse]
|
||||
updateInstanceSetting *connect.Client[api.UpdateInstanceSettingRequest, api.InstanceSetting]
|
||||
testInstanceEmailSetting *connect.Client[api.TestInstanceEmailSettingRequest, emptypb.Empty]
|
||||
getInstanceStats *connect.Client[api.GetInstanceStatsRequest, api.InstanceStats]
|
||||
}
|
||||
|
||||
// GetInstanceProfile calls memos.api.v1.InstanceService.GetInstanceProfile.
|
||||
func (c *instanceServiceClient) GetInstanceProfile(ctx context.Context, req *connect.Request[v1.GetInstanceProfileRequest]) (*connect.Response[v1.InstanceProfile], error) {
|
||||
// GetInstanceProfile calls memos.api.InstanceService.GetInstanceProfile.
|
||||
func (c *instanceServiceClient) GetInstanceProfile(ctx context.Context, req *connect.Request[api.GetInstanceProfileRequest]) (*connect.Response[api.InstanceProfile], error) {
|
||||
return c.getInstanceProfile.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetInstanceSetting calls memos.api.v1.InstanceService.GetInstanceSetting.
|
||||
func (c *instanceServiceClient) GetInstanceSetting(ctx context.Context, req *connect.Request[v1.GetInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error) {
|
||||
// GetInstanceSetting calls memos.api.InstanceService.GetInstanceSetting.
|
||||
func (c *instanceServiceClient) GetInstanceSetting(ctx context.Context, req *connect.Request[api.GetInstanceSettingRequest]) (*connect.Response[api.InstanceSetting], error) {
|
||||
return c.getInstanceSetting.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// BatchGetInstanceSettings calls memos.api.v1.InstanceService.BatchGetInstanceSettings.
|
||||
func (c *instanceServiceClient) BatchGetInstanceSettings(ctx context.Context, req *connect.Request[v1.BatchGetInstanceSettingsRequest]) (*connect.Response[v1.BatchGetInstanceSettingsResponse], error) {
|
||||
// BatchGetInstanceSettings calls memos.api.InstanceService.BatchGetInstanceSettings.
|
||||
func (c *instanceServiceClient) BatchGetInstanceSettings(ctx context.Context, req *connect.Request[api.BatchGetInstanceSettingsRequest]) (*connect.Response[api.BatchGetInstanceSettingsResponse], error) {
|
||||
return c.batchGetInstanceSettings.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// UpdateInstanceSetting calls memos.api.v1.InstanceService.UpdateInstanceSetting.
|
||||
func (c *instanceServiceClient) UpdateInstanceSetting(ctx context.Context, req *connect.Request[v1.UpdateInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error) {
|
||||
// UpdateInstanceSetting calls memos.api.InstanceService.UpdateInstanceSetting.
|
||||
func (c *instanceServiceClient) UpdateInstanceSetting(ctx context.Context, req *connect.Request[api.UpdateInstanceSettingRequest]) (*connect.Response[api.InstanceSetting], error) {
|
||||
return c.updateInstanceSetting.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// TestInstanceEmailSetting calls memos.api.v1.InstanceService.TestInstanceEmailSetting.
|
||||
func (c *instanceServiceClient) TestInstanceEmailSetting(ctx context.Context, req *connect.Request[v1.TestInstanceEmailSettingRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
// TestInstanceEmailSetting calls memos.api.InstanceService.TestInstanceEmailSetting.
|
||||
func (c *instanceServiceClient) TestInstanceEmailSetting(ctx context.Context, req *connect.Request[api.TestInstanceEmailSettingRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.testInstanceEmailSetting.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetInstanceStats calls memos.api.v1.InstanceService.GetInstanceStats.
|
||||
func (c *instanceServiceClient) GetInstanceStats(ctx context.Context, req *connect.Request[v1.GetInstanceStatsRequest]) (*connect.Response[v1.InstanceStats], error) {
|
||||
// GetInstanceStats calls memos.api.InstanceService.GetInstanceStats.
|
||||
func (c *instanceServiceClient) GetInstanceStats(ctx context.Context, req *connect.Request[api.GetInstanceStatsRequest]) (*connect.Response[api.InstanceStats], error) {
|
||||
return c.getInstanceStats.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// InstanceServiceHandler is an implementation of the memos.api.v1.InstanceService service.
|
||||
// InstanceServiceHandler is an implementation of the memos.api.InstanceService service.
|
||||
type InstanceServiceHandler interface {
|
||||
// Gets the instance profile.
|
||||
GetInstanceProfile(context.Context, *connect.Request[v1.GetInstanceProfileRequest]) (*connect.Response[v1.InstanceProfile], error)
|
||||
// Gets an instance setting.
|
||||
GetInstanceSetting(context.Context, *connect.Request[v1.GetInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error)
|
||||
// Batch gets instance settings.
|
||||
BatchGetInstanceSettings(context.Context, *connect.Request[v1.BatchGetInstanceSettingsRequest]) (*connect.Response[v1.BatchGetInstanceSettingsResponse], error)
|
||||
// Updates an instance setting.
|
||||
UpdateInstanceSetting(context.Context, *connect.Request[v1.UpdateInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error)
|
||||
// Tests notification email delivery with the provided or stored SMTP settings.
|
||||
TestInstanceEmailSetting(context.Context, *connect.Request[v1.TestInstanceEmailSettingRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// GetInstanceStats returns resource usage statistics for the instance. Admin only.
|
||||
GetInstanceStats(context.Context, *connect.Request[v1.GetInstanceStatsRequest]) (*connect.Response[v1.InstanceStats], error)
|
||||
// GetInstanceProfile gets the instance profile. Available without authentication, including on a private instance.
|
||||
GetInstanceProfile(context.Context, *connect.Request[api.GetInstanceProfileRequest]) (*connect.Response[api.InstanceProfile], error)
|
||||
// GetInstanceSetting gets an instance setting. Available without authentication, except STORAGE and NOTIFICATION,
|
||||
// which are admin only, and AI, which requires a signed-in user and hides transcription defaults from non-admins.
|
||||
GetInstanceSetting(context.Context, *connect.Request[api.GetInstanceSettingRequest]) (*connect.Response[api.InstanceSetting], error)
|
||||
// BatchGetInstanceSettings gets up to 100 instance settings in request order, with the same access rules as
|
||||
// GetInstanceSetting. The call fails if any setting cannot be returned.
|
||||
BatchGetInstanceSettings(context.Context, *connect.Request[api.BatchGetInstanceSettingsRequest]) (*connect.Response[api.BatchGetInstanceSettingsResponse], error)
|
||||
// UpdateInstanceSetting replaces an instance setting. Admin only. Settings configured by the deployment cannot be
|
||||
// updated. Empty write-only credentials keep the stored values.
|
||||
UpdateInstanceSetting(context.Context, *connect.Request[api.UpdateInstanceSettingRequest]) (*connect.Response[api.InstanceSetting], error)
|
||||
// TestInstanceEmailSetting sends a test email with the provided or stored SMTP settings. Admin only.
|
||||
TestInstanceEmailSetting(context.Context, *connect.Request[api.TestInstanceEmailSettingRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// GetInstanceStats gets resource usage statistics for the instance. Admin only. Results are cached for 60 seconds.
|
||||
GetInstanceStats(context.Context, *connect.Request[api.GetInstanceStatsRequest]) (*connect.Response[api.InstanceStats], error)
|
||||
}
|
||||
|
||||
// NewInstanceServiceHandler builds an HTTP handler from the service implementation. It returns the
|
||||
@@ -182,7 +188,7 @@ type InstanceServiceHandler interface {
|
||||
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
|
||||
// and JSON codecs. They also support gzip compression.
|
||||
func NewInstanceServiceHandler(svc InstanceServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
instanceServiceMethods := v1.File_api_v1_instance_service_proto.Services().ByName("InstanceService").Methods()
|
||||
instanceServiceMethods := api.File_api_instance_service_proto.Services().ByName("InstanceService").Methods()
|
||||
instanceServiceGetInstanceProfileHandler := connect.NewUnaryHandler(
|
||||
InstanceServiceGetInstanceProfileProcedure,
|
||||
svc.GetInstanceProfile,
|
||||
@@ -219,7 +225,7 @@ func NewInstanceServiceHandler(svc InstanceServiceHandler, opts ...connect.Handl
|
||||
connect.WithSchema(instanceServiceMethods.ByName("GetInstanceStats")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/memos.api.v1.InstanceService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
return "/memos.api.InstanceService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case InstanceServiceGetInstanceProfileProcedure:
|
||||
instanceServiceGetInstanceProfileHandler.ServeHTTP(w, r)
|
||||
@@ -242,26 +248,26 @@ func NewInstanceServiceHandler(svc InstanceServiceHandler, opts ...connect.Handl
|
||||
// UnimplementedInstanceServiceHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedInstanceServiceHandler struct{}
|
||||
|
||||
func (UnimplementedInstanceServiceHandler) GetInstanceProfile(context.Context, *connect.Request[v1.GetInstanceProfileRequest]) (*connect.Response[v1.InstanceProfile], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.InstanceService.GetInstanceProfile is not implemented"))
|
||||
func (UnimplementedInstanceServiceHandler) GetInstanceProfile(context.Context, *connect.Request[api.GetInstanceProfileRequest]) (*connect.Response[api.InstanceProfile], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.InstanceService.GetInstanceProfile is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedInstanceServiceHandler) GetInstanceSetting(context.Context, *connect.Request[v1.GetInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.InstanceService.GetInstanceSetting is not implemented"))
|
||||
func (UnimplementedInstanceServiceHandler) GetInstanceSetting(context.Context, *connect.Request[api.GetInstanceSettingRequest]) (*connect.Response[api.InstanceSetting], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.InstanceService.GetInstanceSetting is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedInstanceServiceHandler) BatchGetInstanceSettings(context.Context, *connect.Request[v1.BatchGetInstanceSettingsRequest]) (*connect.Response[v1.BatchGetInstanceSettingsResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.InstanceService.BatchGetInstanceSettings is not implemented"))
|
||||
func (UnimplementedInstanceServiceHandler) BatchGetInstanceSettings(context.Context, *connect.Request[api.BatchGetInstanceSettingsRequest]) (*connect.Response[api.BatchGetInstanceSettingsResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.InstanceService.BatchGetInstanceSettings is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedInstanceServiceHandler) UpdateInstanceSetting(context.Context, *connect.Request[v1.UpdateInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.InstanceService.UpdateInstanceSetting is not implemented"))
|
||||
func (UnimplementedInstanceServiceHandler) UpdateInstanceSetting(context.Context, *connect.Request[api.UpdateInstanceSettingRequest]) (*connect.Response[api.InstanceSetting], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.InstanceService.UpdateInstanceSetting is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedInstanceServiceHandler) TestInstanceEmailSetting(context.Context, *connect.Request[v1.TestInstanceEmailSettingRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.InstanceService.TestInstanceEmailSetting is not implemented"))
|
||||
func (UnimplementedInstanceServiceHandler) TestInstanceEmailSetting(context.Context, *connect.Request[api.TestInstanceEmailSettingRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.InstanceService.TestInstanceEmailSetting is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedInstanceServiceHandler) GetInstanceStats(context.Context, *connect.Request[v1.GetInstanceStatsRequest]) (*connect.Response[v1.InstanceStats], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.InstanceService.GetInstanceStats is not implemented"))
|
||||
func (UnimplementedInstanceServiceHandler) GetInstanceStats(context.Context, *connect.Request[api.GetInstanceStatsRequest]) (*connect.Response[api.InstanceStats], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.InstanceService.GetInstanceStats is not implemented"))
|
||||
}
|
||||
+350
-322
File diff suppressed because it is too large
Load Diff
+363
-333
@@ -1,14 +1,14 @@
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: api/v1/space_service.proto
|
||||
// Source: api/space_service.proto
|
||||
|
||||
package apiv1connect
|
||||
package apiconnect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
v1 "github.com/usememos/memos/proto/gen/api/v1"
|
||||
api "github.com/usememos/memos/proto/gen/api"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
http "net/http"
|
||||
strings "strings"
|
||||
@@ -23,7 +23,7 @@ const _ = connect.IsAtLeastVersion1_13_0
|
||||
|
||||
const (
|
||||
// SpaceServiceName is the fully-qualified name of the SpaceService service.
|
||||
SpaceServiceName = "memos.api.v1.SpaceService"
|
||||
SpaceServiceName = "memos.api.SpaceService"
|
||||
)
|
||||
|
||||
// These constants are the fully-qualified names of the RPCs defined in this package. They're
|
||||
@@ -34,340 +34,370 @@ const (
|
||||
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
|
||||
// period.
|
||||
const (
|
||||
// SpaceServiceListSpacesProcedure is the fully-qualified name of the SpaceService's ListSpaces RPC.
|
||||
SpaceServiceListSpacesProcedure = "/memos.api.SpaceService/ListSpaces"
|
||||
// SpaceServiceGetSpaceProcedure is the fully-qualified name of the SpaceService's GetSpace RPC.
|
||||
SpaceServiceGetSpaceProcedure = "/memos.api.SpaceService/GetSpace"
|
||||
// SpaceServiceCreateSpaceProcedure is the fully-qualified name of the SpaceService's CreateSpace
|
||||
// RPC.
|
||||
SpaceServiceCreateSpaceProcedure = "/memos.api.v1.SpaceService/CreateSpace"
|
||||
// SpaceServiceListSpacesProcedure is the fully-qualified name of the SpaceService's ListSpaces RPC.
|
||||
SpaceServiceListSpacesProcedure = "/memos.api.v1.SpaceService/ListSpaces"
|
||||
// SpaceServiceGetSpaceProcedure is the fully-qualified name of the SpaceService's GetSpace RPC.
|
||||
SpaceServiceGetSpaceProcedure = "/memos.api.v1.SpaceService/GetSpace"
|
||||
SpaceServiceCreateSpaceProcedure = "/memos.api.SpaceService/CreateSpace"
|
||||
// SpaceServiceUpdateSpaceProcedure is the fully-qualified name of the SpaceService's UpdateSpace
|
||||
// RPC.
|
||||
SpaceServiceUpdateSpaceProcedure = "/memos.api.v1.SpaceService/UpdateSpace"
|
||||
SpaceServiceUpdateSpaceProcedure = "/memos.api.SpaceService/UpdateSpace"
|
||||
// SpaceServiceDeleteSpaceProcedure is the fully-qualified name of the SpaceService's DeleteSpace
|
||||
// RPC.
|
||||
SpaceServiceDeleteSpaceProcedure = "/memos.api.v1.SpaceService/DeleteSpace"
|
||||
// SpaceServiceCreateSpaceInvitationProcedure is the fully-qualified name of the SpaceService's
|
||||
// CreateSpaceInvitation RPC.
|
||||
SpaceServiceCreateSpaceInvitationProcedure = "/memos.api.v1.SpaceService/CreateSpaceInvitation"
|
||||
// SpaceServiceListSpaceInvitationsProcedure is the fully-qualified name of the SpaceService's
|
||||
// ListSpaceInvitations RPC.
|
||||
SpaceServiceListSpaceInvitationsProcedure = "/memos.api.v1.SpaceService/ListSpaceInvitations"
|
||||
// SpaceServiceListUserSpaceInvitationsProcedure is the fully-qualified name of the SpaceService's
|
||||
// ListUserSpaceInvitations RPC.
|
||||
SpaceServiceListUserSpaceInvitationsProcedure = "/memos.api.v1.SpaceService/ListUserSpaceInvitations"
|
||||
// SpaceServiceGetSpaceInvitationProcedure is the fully-qualified name of the SpaceService's
|
||||
// GetSpaceInvitation RPC.
|
||||
SpaceServiceGetSpaceInvitationProcedure = "/memos.api.v1.SpaceService/GetSpaceInvitation"
|
||||
// SpaceServiceDeleteSpaceInvitationProcedure is the fully-qualified name of the SpaceService's
|
||||
// DeleteSpaceInvitation RPC.
|
||||
SpaceServiceDeleteSpaceInvitationProcedure = "/memos.api.v1.SpaceService/DeleteSpaceInvitation"
|
||||
// SpaceServiceAcceptSpaceInvitationProcedure is the fully-qualified name of the SpaceService's
|
||||
// AcceptSpaceInvitation RPC.
|
||||
SpaceServiceAcceptSpaceInvitationProcedure = "/memos.api.v1.SpaceService/AcceptSpaceInvitation"
|
||||
// SpaceServiceDeclineSpaceInvitationProcedure is the fully-qualified name of the SpaceService's
|
||||
// DeclineSpaceInvitation RPC.
|
||||
SpaceServiceDeclineSpaceInvitationProcedure = "/memos.api.v1.SpaceService/DeclineSpaceInvitation"
|
||||
SpaceServiceDeleteSpaceProcedure = "/memos.api.SpaceService/DeleteSpace"
|
||||
// SpaceServiceListSpaceMembersProcedure is the fully-qualified name of the SpaceService's
|
||||
// ListSpaceMembers RPC.
|
||||
SpaceServiceListSpaceMembersProcedure = "/memos.api.v1.SpaceService/ListSpaceMembers"
|
||||
SpaceServiceListSpaceMembersProcedure = "/memos.api.SpaceService/ListSpaceMembers"
|
||||
// SpaceServiceGetSpaceMemberProcedure is the fully-qualified name of the SpaceService's
|
||||
// GetSpaceMember RPC.
|
||||
SpaceServiceGetSpaceMemberProcedure = "/memos.api.v1.SpaceService/GetSpaceMember"
|
||||
SpaceServiceGetSpaceMemberProcedure = "/memos.api.SpaceService/GetSpaceMember"
|
||||
// SpaceServiceUpdateSpaceMemberProcedure is the fully-qualified name of the SpaceService's
|
||||
// UpdateSpaceMember RPC.
|
||||
SpaceServiceUpdateSpaceMemberProcedure = "/memos.api.v1.SpaceService/UpdateSpaceMember"
|
||||
SpaceServiceUpdateSpaceMemberProcedure = "/memos.api.SpaceService/UpdateSpaceMember"
|
||||
// SpaceServiceDeleteSpaceMemberProcedure is the fully-qualified name of the SpaceService's
|
||||
// DeleteSpaceMember RPC.
|
||||
SpaceServiceDeleteSpaceMemberProcedure = "/memos.api.v1.SpaceService/DeleteSpaceMember"
|
||||
SpaceServiceDeleteSpaceMemberProcedure = "/memos.api.SpaceService/DeleteSpaceMember"
|
||||
// SpaceServiceListSpaceInvitationsProcedure is the fully-qualified name of the SpaceService's
|
||||
// ListSpaceInvitations RPC.
|
||||
SpaceServiceListSpaceInvitationsProcedure = "/memos.api.SpaceService/ListSpaceInvitations"
|
||||
// SpaceServiceListUserSpaceInvitationsProcedure is the fully-qualified name of the SpaceService's
|
||||
// ListUserSpaceInvitations RPC.
|
||||
SpaceServiceListUserSpaceInvitationsProcedure = "/memos.api.SpaceService/ListUserSpaceInvitations"
|
||||
// SpaceServiceGetSpaceInvitationProcedure is the fully-qualified name of the SpaceService's
|
||||
// GetSpaceInvitation RPC.
|
||||
SpaceServiceGetSpaceInvitationProcedure = "/memos.api.SpaceService/GetSpaceInvitation"
|
||||
// SpaceServiceCreateSpaceInvitationProcedure is the fully-qualified name of the SpaceService's
|
||||
// CreateSpaceInvitation RPC.
|
||||
SpaceServiceCreateSpaceInvitationProcedure = "/memos.api.SpaceService/CreateSpaceInvitation"
|
||||
// SpaceServiceDeleteSpaceInvitationProcedure is the fully-qualified name of the SpaceService's
|
||||
// DeleteSpaceInvitation RPC.
|
||||
SpaceServiceDeleteSpaceInvitationProcedure = "/memos.api.SpaceService/DeleteSpaceInvitation"
|
||||
// SpaceServiceAcceptSpaceInvitationProcedure is the fully-qualified name of the SpaceService's
|
||||
// AcceptSpaceInvitation RPC.
|
||||
SpaceServiceAcceptSpaceInvitationProcedure = "/memos.api.SpaceService/AcceptSpaceInvitation"
|
||||
// SpaceServiceDeclineSpaceInvitationProcedure is the fully-qualified name of the SpaceService's
|
||||
// DeclineSpaceInvitation RPC.
|
||||
SpaceServiceDeclineSpaceInvitationProcedure = "/memos.api.SpaceService/DeclineSpaceInvitation"
|
||||
)
|
||||
|
||||
// SpaceServiceClient is a client for the memos.api.v1.SpaceService service.
|
||||
// SpaceServiceClient is a client for the memos.api.SpaceService service.
|
||||
type SpaceServiceClient interface {
|
||||
// ListSpaces lists the spaces of which the authenticated caller is a member.
|
||||
ListSpaces(context.Context, *connect.Request[api.ListSpacesRequest]) (*connect.Response[api.ListSpacesResponse], error)
|
||||
// GetSpace gets a space of which the authenticated caller is a member.
|
||||
// Spaces the caller is not a member of are reported as not found.
|
||||
GetSpace(context.Context, *connect.Request[api.GetSpaceRequest]) (*connect.Response[api.Space], error)
|
||||
// CreateSpace creates a space and makes the authenticated caller its first
|
||||
// administrator.
|
||||
CreateSpace(context.Context, *connect.Request[v1.CreateSpaceRequest]) (*connect.Response[v1.Space], error)
|
||||
// ListSpaces lists spaces of which the authenticated caller is a member.
|
||||
ListSpaces(context.Context, *connect.Request[v1.ListSpacesRequest]) (*connect.Response[v1.ListSpacesResponse], error)
|
||||
// GetSpace gets a space of which the authenticated caller is a member.
|
||||
GetSpace(context.Context, *connect.Request[v1.GetSpaceRequest]) (*connect.Response[v1.Space], error)
|
||||
// UpdateSpace updates space metadata.
|
||||
UpdateSpace(context.Context, *connect.Request[v1.UpdateSpaceRequest]) (*connect.Response[v1.Space], error)
|
||||
CreateSpace(context.Context, *connect.Request[api.CreateSpaceRequest]) (*connect.Response[api.Space], error)
|
||||
// UpdateSpace updates space metadata. Only a space administrator can update
|
||||
// a space.
|
||||
UpdateSpace(context.Context, *connect.Request[api.UpdateSpaceRequest]) (*connect.Response[api.Space], error)
|
||||
// DeleteSpace permanently deletes a space and every memo currently placed
|
||||
// in it. It never follows memo relations to other memos.
|
||||
DeleteSpace(context.Context, *connect.Request[v1.DeleteSpaceRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// CreateSpaceInvitation invites an existing active user to a space.
|
||||
CreateSpaceInvitation(context.Context, *connect.Request[v1.CreateSpaceInvitationRequest]) (*connect.Response[v1.SpaceInvitation], error)
|
||||
// ListSpaceInvitations lists the pending invitations for a space.
|
||||
ListSpaceInvitations(context.Context, *connect.Request[v1.ListSpaceInvitationsRequest]) (*connect.Response[v1.ListSpaceInvitationsResponse], error)
|
||||
// ListUserSpaceInvitations lists the authenticated user's pending space invitations.
|
||||
ListUserSpaceInvitations(context.Context, *connect.Request[v1.ListUserSpaceInvitationsRequest]) (*connect.Response[v1.ListUserSpaceInvitationsResponse], error)
|
||||
// GetSpaceInvitation gets one pending invitation.
|
||||
GetSpaceInvitation(context.Context, *connect.Request[v1.GetSpaceInvitationRequest]) (*connect.Response[v1.SpaceInvitation], error)
|
||||
// DeleteSpaceInvitation revokes a pending invitation.
|
||||
DeleteSpaceInvitation(context.Context, *connect.Request[v1.DeleteSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// AcceptSpaceInvitation accepts a pending invitation and creates a membership.
|
||||
AcceptSpaceInvitation(context.Context, *connect.Request[v1.AcceptSpaceInvitationRequest]) (*connect.Response[v1.SpaceMember], error)
|
||||
// DeclineSpaceInvitation declines a pending invitation.
|
||||
DeclineSpaceInvitation(context.Context, *connect.Request[v1.DeclineSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// ListSpaceMembers lists the members of a space.
|
||||
ListSpaceMembers(context.Context, *connect.Request[v1.ListSpaceMembersRequest]) (*connect.Response[v1.ListSpaceMembersResponse], error)
|
||||
// GetSpaceMember gets one membership in a space.
|
||||
GetSpaceMember(context.Context, *connect.Request[v1.GetSpaceMemberRequest]) (*connect.Response[v1.SpaceMember], error)
|
||||
// UpdateSpaceMember changes a member's space role.
|
||||
UpdateSpaceMember(context.Context, *connect.Request[v1.UpdateSpaceMemberRequest]) (*connect.Response[v1.SpaceMember], error)
|
||||
// DeleteSpaceMember removes a member. A member may delete their own
|
||||
// membership to leave the space.
|
||||
DeleteSpaceMember(context.Context, *connect.Request[v1.DeleteSpaceMemberRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// in it. It never follows memo relations to other memos. Only a space
|
||||
// administrator can delete a space.
|
||||
DeleteSpace(context.Context, *connect.Request[api.DeleteSpaceRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// ListSpaceMembers lists the members of a space. The caller must be a member
|
||||
// of the space.
|
||||
ListSpaceMembers(context.Context, *connect.Request[api.ListSpaceMembersRequest]) (*connect.Response[api.ListSpaceMembersResponse], error)
|
||||
// GetSpaceMember gets one membership in a space. The caller must be a member
|
||||
// of the space.
|
||||
GetSpaceMember(context.Context, *connect.Request[api.GetSpaceMemberRequest]) (*connect.Response[api.SpaceMember], error)
|
||||
// UpdateSpaceMember changes a member's space role. Only a space administrator
|
||||
// can change roles, and a space must keep at least one administrator.
|
||||
UpdateSpaceMember(context.Context, *connect.Request[api.UpdateSpaceMemberRequest]) (*connect.Response[api.SpaceMember], error)
|
||||
// DeleteSpaceMember removes a member. A space administrator can remove any
|
||||
// member, and a member may delete their own membership to leave the space.
|
||||
// A space must keep at least one administrator.
|
||||
DeleteSpaceMember(context.Context, *connect.Request[api.DeleteSpaceMemberRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// ListSpaceInvitations lists the pending invitations for a space. Only a
|
||||
// space administrator can list them.
|
||||
ListSpaceInvitations(context.Context, *connect.Request[api.ListSpaceInvitationsRequest]) (*connect.Response[api.ListSpaceInvitationsResponse], error)
|
||||
// ListUserSpaceInvitations lists the authenticated user's pending space
|
||||
// invitations. A user cannot list another user's invitations.
|
||||
ListUserSpaceInvitations(context.Context, *connect.Request[api.ListUserSpaceInvitationsRequest]) (*connect.Response[api.ListUserSpaceInvitationsResponse], error)
|
||||
// GetSpaceInvitation gets one pending invitation. Only the invitee or a
|
||||
// space administrator can get it.
|
||||
GetSpaceInvitation(context.Context, *connect.Request[api.GetSpaceInvitationRequest]) (*connect.Response[api.SpaceInvitation], error)
|
||||
// CreateSpaceInvitation invites an existing active user to a space. Only a
|
||||
// space administrator can invite. The invitee gets no space access until
|
||||
// they accept.
|
||||
CreateSpaceInvitation(context.Context, *connect.Request[api.CreateSpaceInvitationRequest]) (*connect.Response[api.SpaceInvitation], error)
|
||||
// DeleteSpaceInvitation revokes a pending invitation. Only a space
|
||||
// administrator can revoke it.
|
||||
DeleteSpaceInvitation(context.Context, *connect.Request[api.DeleteSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// AcceptSpaceInvitation accepts a pending invitation and creates a
|
||||
// membership with the invited role. Only the invitee can accept it.
|
||||
AcceptSpaceInvitation(context.Context, *connect.Request[api.AcceptSpaceInvitationRequest]) (*connect.Response[api.SpaceMember], error)
|
||||
// DeclineSpaceInvitation declines a pending invitation without creating a
|
||||
// membership. Only the invitee can decline it.
|
||||
DeclineSpaceInvitation(context.Context, *connect.Request[api.DeclineSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
}
|
||||
|
||||
// NewSpaceServiceClient constructs a client for the memos.api.v1.SpaceService service. By default,
|
||||
// it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and
|
||||
// sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC()
|
||||
// or connect.WithGRPCWeb() options.
|
||||
// NewSpaceServiceClient constructs a client for the memos.api.SpaceService service. By default, it
|
||||
// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
|
||||
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
|
||||
// connect.WithGRPCWeb() options.
|
||||
//
|
||||
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
|
||||
// http://api.acme.com or https://acme.com/grpc).
|
||||
func NewSpaceServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SpaceServiceClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
spaceServiceMethods := v1.File_api_v1_space_service_proto.Services().ByName("SpaceService").Methods()
|
||||
spaceServiceMethods := api.File_api_space_service_proto.Services().ByName("SpaceService").Methods()
|
||||
return &spaceServiceClient{
|
||||
createSpace: connect.NewClient[v1.CreateSpaceRequest, v1.Space](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceCreateSpaceProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("CreateSpace")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
listSpaces: connect.NewClient[v1.ListSpacesRequest, v1.ListSpacesResponse](
|
||||
listSpaces: connect.NewClient[api.ListSpacesRequest, api.ListSpacesResponse](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceListSpacesProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("ListSpaces")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getSpace: connect.NewClient[v1.GetSpaceRequest, v1.Space](
|
||||
getSpace: connect.NewClient[api.GetSpaceRequest, api.Space](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceGetSpaceProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("GetSpace")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
updateSpace: connect.NewClient[v1.UpdateSpaceRequest, v1.Space](
|
||||
createSpace: connect.NewClient[api.CreateSpaceRequest, api.Space](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceCreateSpaceProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("CreateSpace")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
updateSpace: connect.NewClient[api.UpdateSpaceRequest, api.Space](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceUpdateSpaceProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("UpdateSpace")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
deleteSpace: connect.NewClient[v1.DeleteSpaceRequest, emptypb.Empty](
|
||||
deleteSpace: connect.NewClient[api.DeleteSpaceRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceDeleteSpaceProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("DeleteSpace")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
createSpaceInvitation: connect.NewClient[v1.CreateSpaceInvitationRequest, v1.SpaceInvitation](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceCreateSpaceInvitationProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("CreateSpaceInvitation")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
listSpaceInvitations: connect.NewClient[v1.ListSpaceInvitationsRequest, v1.ListSpaceInvitationsResponse](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceListSpaceInvitationsProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("ListSpaceInvitations")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
listUserSpaceInvitations: connect.NewClient[v1.ListUserSpaceInvitationsRequest, v1.ListUserSpaceInvitationsResponse](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceListUserSpaceInvitationsProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("ListUserSpaceInvitations")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getSpaceInvitation: connect.NewClient[v1.GetSpaceInvitationRequest, v1.SpaceInvitation](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceGetSpaceInvitationProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("GetSpaceInvitation")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
deleteSpaceInvitation: connect.NewClient[v1.DeleteSpaceInvitationRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceDeleteSpaceInvitationProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("DeleteSpaceInvitation")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
acceptSpaceInvitation: connect.NewClient[v1.AcceptSpaceInvitationRequest, v1.SpaceMember](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceAcceptSpaceInvitationProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("AcceptSpaceInvitation")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
declineSpaceInvitation: connect.NewClient[v1.DeclineSpaceInvitationRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceDeclineSpaceInvitationProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("DeclineSpaceInvitation")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
listSpaceMembers: connect.NewClient[v1.ListSpaceMembersRequest, v1.ListSpaceMembersResponse](
|
||||
listSpaceMembers: connect.NewClient[api.ListSpaceMembersRequest, api.ListSpaceMembersResponse](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceListSpaceMembersProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("ListSpaceMembers")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getSpaceMember: connect.NewClient[v1.GetSpaceMemberRequest, v1.SpaceMember](
|
||||
getSpaceMember: connect.NewClient[api.GetSpaceMemberRequest, api.SpaceMember](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceGetSpaceMemberProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("GetSpaceMember")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
updateSpaceMember: connect.NewClient[v1.UpdateSpaceMemberRequest, v1.SpaceMember](
|
||||
updateSpaceMember: connect.NewClient[api.UpdateSpaceMemberRequest, api.SpaceMember](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceUpdateSpaceMemberProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("UpdateSpaceMember")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
deleteSpaceMember: connect.NewClient[v1.DeleteSpaceMemberRequest, emptypb.Empty](
|
||||
deleteSpaceMember: connect.NewClient[api.DeleteSpaceMemberRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceDeleteSpaceMemberProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("DeleteSpaceMember")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
listSpaceInvitations: connect.NewClient[api.ListSpaceInvitationsRequest, api.ListSpaceInvitationsResponse](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceListSpaceInvitationsProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("ListSpaceInvitations")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
listUserSpaceInvitations: connect.NewClient[api.ListUserSpaceInvitationsRequest, api.ListUserSpaceInvitationsResponse](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceListUserSpaceInvitationsProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("ListUserSpaceInvitations")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getSpaceInvitation: connect.NewClient[api.GetSpaceInvitationRequest, api.SpaceInvitation](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceGetSpaceInvitationProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("GetSpaceInvitation")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
createSpaceInvitation: connect.NewClient[api.CreateSpaceInvitationRequest, api.SpaceInvitation](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceCreateSpaceInvitationProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("CreateSpaceInvitation")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
deleteSpaceInvitation: connect.NewClient[api.DeleteSpaceInvitationRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceDeleteSpaceInvitationProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("DeleteSpaceInvitation")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
acceptSpaceInvitation: connect.NewClient[api.AcceptSpaceInvitationRequest, api.SpaceMember](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceAcceptSpaceInvitationProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("AcceptSpaceInvitation")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
declineSpaceInvitation: connect.NewClient[api.DeclineSpaceInvitationRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+SpaceServiceDeclineSpaceInvitationProcedure,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("DeclineSpaceInvitation")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// spaceServiceClient implements SpaceServiceClient.
|
||||
type spaceServiceClient struct {
|
||||
createSpace *connect.Client[v1.CreateSpaceRequest, v1.Space]
|
||||
listSpaces *connect.Client[v1.ListSpacesRequest, v1.ListSpacesResponse]
|
||||
getSpace *connect.Client[v1.GetSpaceRequest, v1.Space]
|
||||
updateSpace *connect.Client[v1.UpdateSpaceRequest, v1.Space]
|
||||
deleteSpace *connect.Client[v1.DeleteSpaceRequest, emptypb.Empty]
|
||||
createSpaceInvitation *connect.Client[v1.CreateSpaceInvitationRequest, v1.SpaceInvitation]
|
||||
listSpaceInvitations *connect.Client[v1.ListSpaceInvitationsRequest, v1.ListSpaceInvitationsResponse]
|
||||
listUserSpaceInvitations *connect.Client[v1.ListUserSpaceInvitationsRequest, v1.ListUserSpaceInvitationsResponse]
|
||||
getSpaceInvitation *connect.Client[v1.GetSpaceInvitationRequest, v1.SpaceInvitation]
|
||||
deleteSpaceInvitation *connect.Client[v1.DeleteSpaceInvitationRequest, emptypb.Empty]
|
||||
acceptSpaceInvitation *connect.Client[v1.AcceptSpaceInvitationRequest, v1.SpaceMember]
|
||||
declineSpaceInvitation *connect.Client[v1.DeclineSpaceInvitationRequest, emptypb.Empty]
|
||||
listSpaceMembers *connect.Client[v1.ListSpaceMembersRequest, v1.ListSpaceMembersResponse]
|
||||
getSpaceMember *connect.Client[v1.GetSpaceMemberRequest, v1.SpaceMember]
|
||||
updateSpaceMember *connect.Client[v1.UpdateSpaceMemberRequest, v1.SpaceMember]
|
||||
deleteSpaceMember *connect.Client[v1.DeleteSpaceMemberRequest, emptypb.Empty]
|
||||
listSpaces *connect.Client[api.ListSpacesRequest, api.ListSpacesResponse]
|
||||
getSpace *connect.Client[api.GetSpaceRequest, api.Space]
|
||||
createSpace *connect.Client[api.CreateSpaceRequest, api.Space]
|
||||
updateSpace *connect.Client[api.UpdateSpaceRequest, api.Space]
|
||||
deleteSpace *connect.Client[api.DeleteSpaceRequest, emptypb.Empty]
|
||||
listSpaceMembers *connect.Client[api.ListSpaceMembersRequest, api.ListSpaceMembersResponse]
|
||||
getSpaceMember *connect.Client[api.GetSpaceMemberRequest, api.SpaceMember]
|
||||
updateSpaceMember *connect.Client[api.UpdateSpaceMemberRequest, api.SpaceMember]
|
||||
deleteSpaceMember *connect.Client[api.DeleteSpaceMemberRequest, emptypb.Empty]
|
||||
listSpaceInvitations *connect.Client[api.ListSpaceInvitationsRequest, api.ListSpaceInvitationsResponse]
|
||||
listUserSpaceInvitations *connect.Client[api.ListUserSpaceInvitationsRequest, api.ListUserSpaceInvitationsResponse]
|
||||
getSpaceInvitation *connect.Client[api.GetSpaceInvitationRequest, api.SpaceInvitation]
|
||||
createSpaceInvitation *connect.Client[api.CreateSpaceInvitationRequest, api.SpaceInvitation]
|
||||
deleteSpaceInvitation *connect.Client[api.DeleteSpaceInvitationRequest, emptypb.Empty]
|
||||
acceptSpaceInvitation *connect.Client[api.AcceptSpaceInvitationRequest, api.SpaceMember]
|
||||
declineSpaceInvitation *connect.Client[api.DeclineSpaceInvitationRequest, emptypb.Empty]
|
||||
}
|
||||
|
||||
// CreateSpace calls memos.api.v1.SpaceService.CreateSpace.
|
||||
func (c *spaceServiceClient) CreateSpace(ctx context.Context, req *connect.Request[v1.CreateSpaceRequest]) (*connect.Response[v1.Space], error) {
|
||||
return c.createSpace.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ListSpaces calls memos.api.v1.SpaceService.ListSpaces.
|
||||
func (c *spaceServiceClient) ListSpaces(ctx context.Context, req *connect.Request[v1.ListSpacesRequest]) (*connect.Response[v1.ListSpacesResponse], error) {
|
||||
// ListSpaces calls memos.api.SpaceService.ListSpaces.
|
||||
func (c *spaceServiceClient) ListSpaces(ctx context.Context, req *connect.Request[api.ListSpacesRequest]) (*connect.Response[api.ListSpacesResponse], error) {
|
||||
return c.listSpaces.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetSpace calls memos.api.v1.SpaceService.GetSpace.
|
||||
func (c *spaceServiceClient) GetSpace(ctx context.Context, req *connect.Request[v1.GetSpaceRequest]) (*connect.Response[v1.Space], error) {
|
||||
// GetSpace calls memos.api.SpaceService.GetSpace.
|
||||
func (c *spaceServiceClient) GetSpace(ctx context.Context, req *connect.Request[api.GetSpaceRequest]) (*connect.Response[api.Space], error) {
|
||||
return c.getSpace.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// UpdateSpace calls memos.api.v1.SpaceService.UpdateSpace.
|
||||
func (c *spaceServiceClient) UpdateSpace(ctx context.Context, req *connect.Request[v1.UpdateSpaceRequest]) (*connect.Response[v1.Space], error) {
|
||||
// CreateSpace calls memos.api.SpaceService.CreateSpace.
|
||||
func (c *spaceServiceClient) CreateSpace(ctx context.Context, req *connect.Request[api.CreateSpaceRequest]) (*connect.Response[api.Space], error) {
|
||||
return c.createSpace.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// UpdateSpace calls memos.api.SpaceService.UpdateSpace.
|
||||
func (c *spaceServiceClient) UpdateSpace(ctx context.Context, req *connect.Request[api.UpdateSpaceRequest]) (*connect.Response[api.Space], error) {
|
||||
return c.updateSpace.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// DeleteSpace calls memos.api.v1.SpaceService.DeleteSpace.
|
||||
func (c *spaceServiceClient) DeleteSpace(ctx context.Context, req *connect.Request[v1.DeleteSpaceRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
// DeleteSpace calls memos.api.SpaceService.DeleteSpace.
|
||||
func (c *spaceServiceClient) DeleteSpace(ctx context.Context, req *connect.Request[api.DeleteSpaceRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.deleteSpace.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// CreateSpaceInvitation calls memos.api.v1.SpaceService.CreateSpaceInvitation.
|
||||
func (c *spaceServiceClient) CreateSpaceInvitation(ctx context.Context, req *connect.Request[v1.CreateSpaceInvitationRequest]) (*connect.Response[v1.SpaceInvitation], error) {
|
||||
return c.createSpaceInvitation.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ListSpaceInvitations calls memos.api.v1.SpaceService.ListSpaceInvitations.
|
||||
func (c *spaceServiceClient) ListSpaceInvitations(ctx context.Context, req *connect.Request[v1.ListSpaceInvitationsRequest]) (*connect.Response[v1.ListSpaceInvitationsResponse], error) {
|
||||
return c.listSpaceInvitations.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ListUserSpaceInvitations calls memos.api.v1.SpaceService.ListUserSpaceInvitations.
|
||||
func (c *spaceServiceClient) ListUserSpaceInvitations(ctx context.Context, req *connect.Request[v1.ListUserSpaceInvitationsRequest]) (*connect.Response[v1.ListUserSpaceInvitationsResponse], error) {
|
||||
return c.listUserSpaceInvitations.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetSpaceInvitation calls memos.api.v1.SpaceService.GetSpaceInvitation.
|
||||
func (c *spaceServiceClient) GetSpaceInvitation(ctx context.Context, req *connect.Request[v1.GetSpaceInvitationRequest]) (*connect.Response[v1.SpaceInvitation], error) {
|
||||
return c.getSpaceInvitation.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// DeleteSpaceInvitation calls memos.api.v1.SpaceService.DeleteSpaceInvitation.
|
||||
func (c *spaceServiceClient) DeleteSpaceInvitation(ctx context.Context, req *connect.Request[v1.DeleteSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.deleteSpaceInvitation.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// AcceptSpaceInvitation calls memos.api.v1.SpaceService.AcceptSpaceInvitation.
|
||||
func (c *spaceServiceClient) AcceptSpaceInvitation(ctx context.Context, req *connect.Request[v1.AcceptSpaceInvitationRequest]) (*connect.Response[v1.SpaceMember], error) {
|
||||
return c.acceptSpaceInvitation.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// DeclineSpaceInvitation calls memos.api.v1.SpaceService.DeclineSpaceInvitation.
|
||||
func (c *spaceServiceClient) DeclineSpaceInvitation(ctx context.Context, req *connect.Request[v1.DeclineSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.declineSpaceInvitation.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ListSpaceMembers calls memos.api.v1.SpaceService.ListSpaceMembers.
|
||||
func (c *spaceServiceClient) ListSpaceMembers(ctx context.Context, req *connect.Request[v1.ListSpaceMembersRequest]) (*connect.Response[v1.ListSpaceMembersResponse], error) {
|
||||
// ListSpaceMembers calls memos.api.SpaceService.ListSpaceMembers.
|
||||
func (c *spaceServiceClient) ListSpaceMembers(ctx context.Context, req *connect.Request[api.ListSpaceMembersRequest]) (*connect.Response[api.ListSpaceMembersResponse], error) {
|
||||
return c.listSpaceMembers.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetSpaceMember calls memos.api.v1.SpaceService.GetSpaceMember.
|
||||
func (c *spaceServiceClient) GetSpaceMember(ctx context.Context, req *connect.Request[v1.GetSpaceMemberRequest]) (*connect.Response[v1.SpaceMember], error) {
|
||||
// GetSpaceMember calls memos.api.SpaceService.GetSpaceMember.
|
||||
func (c *spaceServiceClient) GetSpaceMember(ctx context.Context, req *connect.Request[api.GetSpaceMemberRequest]) (*connect.Response[api.SpaceMember], error) {
|
||||
return c.getSpaceMember.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// UpdateSpaceMember calls memos.api.v1.SpaceService.UpdateSpaceMember.
|
||||
func (c *spaceServiceClient) UpdateSpaceMember(ctx context.Context, req *connect.Request[v1.UpdateSpaceMemberRequest]) (*connect.Response[v1.SpaceMember], error) {
|
||||
// UpdateSpaceMember calls memos.api.SpaceService.UpdateSpaceMember.
|
||||
func (c *spaceServiceClient) UpdateSpaceMember(ctx context.Context, req *connect.Request[api.UpdateSpaceMemberRequest]) (*connect.Response[api.SpaceMember], error) {
|
||||
return c.updateSpaceMember.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// DeleteSpaceMember calls memos.api.v1.SpaceService.DeleteSpaceMember.
|
||||
func (c *spaceServiceClient) DeleteSpaceMember(ctx context.Context, req *connect.Request[v1.DeleteSpaceMemberRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
// DeleteSpaceMember calls memos.api.SpaceService.DeleteSpaceMember.
|
||||
func (c *spaceServiceClient) DeleteSpaceMember(ctx context.Context, req *connect.Request[api.DeleteSpaceMemberRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.deleteSpaceMember.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SpaceServiceHandler is an implementation of the memos.api.v1.SpaceService service.
|
||||
// ListSpaceInvitations calls memos.api.SpaceService.ListSpaceInvitations.
|
||||
func (c *spaceServiceClient) ListSpaceInvitations(ctx context.Context, req *connect.Request[api.ListSpaceInvitationsRequest]) (*connect.Response[api.ListSpaceInvitationsResponse], error) {
|
||||
return c.listSpaceInvitations.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ListUserSpaceInvitations calls memos.api.SpaceService.ListUserSpaceInvitations.
|
||||
func (c *spaceServiceClient) ListUserSpaceInvitations(ctx context.Context, req *connect.Request[api.ListUserSpaceInvitationsRequest]) (*connect.Response[api.ListUserSpaceInvitationsResponse], error) {
|
||||
return c.listUserSpaceInvitations.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetSpaceInvitation calls memos.api.SpaceService.GetSpaceInvitation.
|
||||
func (c *spaceServiceClient) GetSpaceInvitation(ctx context.Context, req *connect.Request[api.GetSpaceInvitationRequest]) (*connect.Response[api.SpaceInvitation], error) {
|
||||
return c.getSpaceInvitation.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// CreateSpaceInvitation calls memos.api.SpaceService.CreateSpaceInvitation.
|
||||
func (c *spaceServiceClient) CreateSpaceInvitation(ctx context.Context, req *connect.Request[api.CreateSpaceInvitationRequest]) (*connect.Response[api.SpaceInvitation], error) {
|
||||
return c.createSpaceInvitation.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// DeleteSpaceInvitation calls memos.api.SpaceService.DeleteSpaceInvitation.
|
||||
func (c *spaceServiceClient) DeleteSpaceInvitation(ctx context.Context, req *connect.Request[api.DeleteSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.deleteSpaceInvitation.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// AcceptSpaceInvitation calls memos.api.SpaceService.AcceptSpaceInvitation.
|
||||
func (c *spaceServiceClient) AcceptSpaceInvitation(ctx context.Context, req *connect.Request[api.AcceptSpaceInvitationRequest]) (*connect.Response[api.SpaceMember], error) {
|
||||
return c.acceptSpaceInvitation.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// DeclineSpaceInvitation calls memos.api.SpaceService.DeclineSpaceInvitation.
|
||||
func (c *spaceServiceClient) DeclineSpaceInvitation(ctx context.Context, req *connect.Request[api.DeclineSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.declineSpaceInvitation.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SpaceServiceHandler is an implementation of the memos.api.SpaceService service.
|
||||
type SpaceServiceHandler interface {
|
||||
// ListSpaces lists the spaces of which the authenticated caller is a member.
|
||||
ListSpaces(context.Context, *connect.Request[api.ListSpacesRequest]) (*connect.Response[api.ListSpacesResponse], error)
|
||||
// GetSpace gets a space of which the authenticated caller is a member.
|
||||
// Spaces the caller is not a member of are reported as not found.
|
||||
GetSpace(context.Context, *connect.Request[api.GetSpaceRequest]) (*connect.Response[api.Space], error)
|
||||
// CreateSpace creates a space and makes the authenticated caller its first
|
||||
// administrator.
|
||||
CreateSpace(context.Context, *connect.Request[v1.CreateSpaceRequest]) (*connect.Response[v1.Space], error)
|
||||
// ListSpaces lists spaces of which the authenticated caller is a member.
|
||||
ListSpaces(context.Context, *connect.Request[v1.ListSpacesRequest]) (*connect.Response[v1.ListSpacesResponse], error)
|
||||
// GetSpace gets a space of which the authenticated caller is a member.
|
||||
GetSpace(context.Context, *connect.Request[v1.GetSpaceRequest]) (*connect.Response[v1.Space], error)
|
||||
// UpdateSpace updates space metadata.
|
||||
UpdateSpace(context.Context, *connect.Request[v1.UpdateSpaceRequest]) (*connect.Response[v1.Space], error)
|
||||
CreateSpace(context.Context, *connect.Request[api.CreateSpaceRequest]) (*connect.Response[api.Space], error)
|
||||
// UpdateSpace updates space metadata. Only a space administrator can update
|
||||
// a space.
|
||||
UpdateSpace(context.Context, *connect.Request[api.UpdateSpaceRequest]) (*connect.Response[api.Space], error)
|
||||
// DeleteSpace permanently deletes a space and every memo currently placed
|
||||
// in it. It never follows memo relations to other memos.
|
||||
DeleteSpace(context.Context, *connect.Request[v1.DeleteSpaceRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// CreateSpaceInvitation invites an existing active user to a space.
|
||||
CreateSpaceInvitation(context.Context, *connect.Request[v1.CreateSpaceInvitationRequest]) (*connect.Response[v1.SpaceInvitation], error)
|
||||
// ListSpaceInvitations lists the pending invitations for a space.
|
||||
ListSpaceInvitations(context.Context, *connect.Request[v1.ListSpaceInvitationsRequest]) (*connect.Response[v1.ListSpaceInvitationsResponse], error)
|
||||
// ListUserSpaceInvitations lists the authenticated user's pending space invitations.
|
||||
ListUserSpaceInvitations(context.Context, *connect.Request[v1.ListUserSpaceInvitationsRequest]) (*connect.Response[v1.ListUserSpaceInvitationsResponse], error)
|
||||
// GetSpaceInvitation gets one pending invitation.
|
||||
GetSpaceInvitation(context.Context, *connect.Request[v1.GetSpaceInvitationRequest]) (*connect.Response[v1.SpaceInvitation], error)
|
||||
// DeleteSpaceInvitation revokes a pending invitation.
|
||||
DeleteSpaceInvitation(context.Context, *connect.Request[v1.DeleteSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// AcceptSpaceInvitation accepts a pending invitation and creates a membership.
|
||||
AcceptSpaceInvitation(context.Context, *connect.Request[v1.AcceptSpaceInvitationRequest]) (*connect.Response[v1.SpaceMember], error)
|
||||
// DeclineSpaceInvitation declines a pending invitation.
|
||||
DeclineSpaceInvitation(context.Context, *connect.Request[v1.DeclineSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// ListSpaceMembers lists the members of a space.
|
||||
ListSpaceMembers(context.Context, *connect.Request[v1.ListSpaceMembersRequest]) (*connect.Response[v1.ListSpaceMembersResponse], error)
|
||||
// GetSpaceMember gets one membership in a space.
|
||||
GetSpaceMember(context.Context, *connect.Request[v1.GetSpaceMemberRequest]) (*connect.Response[v1.SpaceMember], error)
|
||||
// UpdateSpaceMember changes a member's space role.
|
||||
UpdateSpaceMember(context.Context, *connect.Request[v1.UpdateSpaceMemberRequest]) (*connect.Response[v1.SpaceMember], error)
|
||||
// DeleteSpaceMember removes a member. A member may delete their own
|
||||
// membership to leave the space.
|
||||
DeleteSpaceMember(context.Context, *connect.Request[v1.DeleteSpaceMemberRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// in it. It never follows memo relations to other memos. Only a space
|
||||
// administrator can delete a space.
|
||||
DeleteSpace(context.Context, *connect.Request[api.DeleteSpaceRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// ListSpaceMembers lists the members of a space. The caller must be a member
|
||||
// of the space.
|
||||
ListSpaceMembers(context.Context, *connect.Request[api.ListSpaceMembersRequest]) (*connect.Response[api.ListSpaceMembersResponse], error)
|
||||
// GetSpaceMember gets one membership in a space. The caller must be a member
|
||||
// of the space.
|
||||
GetSpaceMember(context.Context, *connect.Request[api.GetSpaceMemberRequest]) (*connect.Response[api.SpaceMember], error)
|
||||
// UpdateSpaceMember changes a member's space role. Only a space administrator
|
||||
// can change roles, and a space must keep at least one administrator.
|
||||
UpdateSpaceMember(context.Context, *connect.Request[api.UpdateSpaceMemberRequest]) (*connect.Response[api.SpaceMember], error)
|
||||
// DeleteSpaceMember removes a member. A space administrator can remove any
|
||||
// member, and a member may delete their own membership to leave the space.
|
||||
// A space must keep at least one administrator.
|
||||
DeleteSpaceMember(context.Context, *connect.Request[api.DeleteSpaceMemberRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// ListSpaceInvitations lists the pending invitations for a space. Only a
|
||||
// space administrator can list them.
|
||||
ListSpaceInvitations(context.Context, *connect.Request[api.ListSpaceInvitationsRequest]) (*connect.Response[api.ListSpaceInvitationsResponse], error)
|
||||
// ListUserSpaceInvitations lists the authenticated user's pending space
|
||||
// invitations. A user cannot list another user's invitations.
|
||||
ListUserSpaceInvitations(context.Context, *connect.Request[api.ListUserSpaceInvitationsRequest]) (*connect.Response[api.ListUserSpaceInvitationsResponse], error)
|
||||
// GetSpaceInvitation gets one pending invitation. Only the invitee or a
|
||||
// space administrator can get it.
|
||||
GetSpaceInvitation(context.Context, *connect.Request[api.GetSpaceInvitationRequest]) (*connect.Response[api.SpaceInvitation], error)
|
||||
// CreateSpaceInvitation invites an existing active user to a space. Only a
|
||||
// space administrator can invite. The invitee gets no space access until
|
||||
// they accept.
|
||||
CreateSpaceInvitation(context.Context, *connect.Request[api.CreateSpaceInvitationRequest]) (*connect.Response[api.SpaceInvitation], error)
|
||||
// DeleteSpaceInvitation revokes a pending invitation. Only a space
|
||||
// administrator can revoke it.
|
||||
DeleteSpaceInvitation(context.Context, *connect.Request[api.DeleteSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// AcceptSpaceInvitation accepts a pending invitation and creates a
|
||||
// membership with the invited role. Only the invitee can accept it.
|
||||
AcceptSpaceInvitation(context.Context, *connect.Request[api.AcceptSpaceInvitationRequest]) (*connect.Response[api.SpaceMember], error)
|
||||
// DeclineSpaceInvitation declines a pending invitation without creating a
|
||||
// membership. Only the invitee can decline it.
|
||||
DeclineSpaceInvitation(context.Context, *connect.Request[api.DeclineSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
}
|
||||
|
||||
// NewSpaceServiceHandler builds an HTTP handler from the service implementation. It returns the
|
||||
@@ -376,13 +406,7 @@ type SpaceServiceHandler interface {
|
||||
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
|
||||
// and JSON codecs. They also support gzip compression.
|
||||
func NewSpaceServiceHandler(svc SpaceServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
spaceServiceMethods := v1.File_api_v1_space_service_proto.Services().ByName("SpaceService").Methods()
|
||||
spaceServiceCreateSpaceHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceCreateSpaceProcedure,
|
||||
svc.CreateSpace,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("CreateSpace")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceMethods := api.File_api_space_service_proto.Services().ByName("SpaceService").Methods()
|
||||
spaceServiceListSpacesHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceListSpacesProcedure,
|
||||
svc.ListSpaces,
|
||||
@@ -395,6 +419,12 @@ func NewSpaceServiceHandler(svc SpaceServiceHandler, opts ...connect.HandlerOpti
|
||||
connect.WithSchema(spaceServiceMethods.ByName("GetSpace")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceCreateSpaceHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceCreateSpaceProcedure,
|
||||
svc.CreateSpace,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("CreateSpace")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceUpdateSpaceHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceUpdateSpaceProcedure,
|
||||
svc.UpdateSpace,
|
||||
@@ -407,48 +437,6 @@ func NewSpaceServiceHandler(svc SpaceServiceHandler, opts ...connect.HandlerOpti
|
||||
connect.WithSchema(spaceServiceMethods.ByName("DeleteSpace")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceCreateSpaceInvitationHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceCreateSpaceInvitationProcedure,
|
||||
svc.CreateSpaceInvitation,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("CreateSpaceInvitation")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceListSpaceInvitationsHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceListSpaceInvitationsProcedure,
|
||||
svc.ListSpaceInvitations,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("ListSpaceInvitations")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceListUserSpaceInvitationsHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceListUserSpaceInvitationsProcedure,
|
||||
svc.ListUserSpaceInvitations,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("ListUserSpaceInvitations")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceGetSpaceInvitationHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceGetSpaceInvitationProcedure,
|
||||
svc.GetSpaceInvitation,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("GetSpaceInvitation")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceDeleteSpaceInvitationHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceDeleteSpaceInvitationProcedure,
|
||||
svc.DeleteSpaceInvitation,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("DeleteSpaceInvitation")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceAcceptSpaceInvitationHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceAcceptSpaceInvitationProcedure,
|
||||
svc.AcceptSpaceInvitation,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("AcceptSpaceInvitation")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceDeclineSpaceInvitationHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceDeclineSpaceInvitationProcedure,
|
||||
svc.DeclineSpaceInvitation,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("DeclineSpaceInvitation")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceListSpaceMembersHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceListSpaceMembersProcedure,
|
||||
svc.ListSpaceMembers,
|
||||
@@ -473,32 +461,60 @@ func NewSpaceServiceHandler(svc SpaceServiceHandler, opts ...connect.HandlerOpti
|
||||
connect.WithSchema(spaceServiceMethods.ByName("DeleteSpaceMember")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/memos.api.v1.SpaceService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
spaceServiceListSpaceInvitationsHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceListSpaceInvitationsProcedure,
|
||||
svc.ListSpaceInvitations,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("ListSpaceInvitations")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceListUserSpaceInvitationsHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceListUserSpaceInvitationsProcedure,
|
||||
svc.ListUserSpaceInvitations,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("ListUserSpaceInvitations")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceGetSpaceInvitationHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceGetSpaceInvitationProcedure,
|
||||
svc.GetSpaceInvitation,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("GetSpaceInvitation")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceCreateSpaceInvitationHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceCreateSpaceInvitationProcedure,
|
||||
svc.CreateSpaceInvitation,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("CreateSpaceInvitation")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceDeleteSpaceInvitationHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceDeleteSpaceInvitationProcedure,
|
||||
svc.DeleteSpaceInvitation,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("DeleteSpaceInvitation")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceAcceptSpaceInvitationHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceAcceptSpaceInvitationProcedure,
|
||||
svc.AcceptSpaceInvitation,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("AcceptSpaceInvitation")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
spaceServiceDeclineSpaceInvitationHandler := connect.NewUnaryHandler(
|
||||
SpaceServiceDeclineSpaceInvitationProcedure,
|
||||
svc.DeclineSpaceInvitation,
|
||||
connect.WithSchema(spaceServiceMethods.ByName("DeclineSpaceInvitation")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/memos.api.SpaceService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case SpaceServiceCreateSpaceProcedure:
|
||||
spaceServiceCreateSpaceHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceListSpacesProcedure:
|
||||
spaceServiceListSpacesHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceGetSpaceProcedure:
|
||||
spaceServiceGetSpaceHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceCreateSpaceProcedure:
|
||||
spaceServiceCreateSpaceHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceUpdateSpaceProcedure:
|
||||
spaceServiceUpdateSpaceHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceDeleteSpaceProcedure:
|
||||
spaceServiceDeleteSpaceHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceCreateSpaceInvitationProcedure:
|
||||
spaceServiceCreateSpaceInvitationHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceListSpaceInvitationsProcedure:
|
||||
spaceServiceListSpaceInvitationsHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceListUserSpaceInvitationsProcedure:
|
||||
spaceServiceListUserSpaceInvitationsHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceGetSpaceInvitationProcedure:
|
||||
spaceServiceGetSpaceInvitationHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceDeleteSpaceInvitationProcedure:
|
||||
spaceServiceDeleteSpaceInvitationHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceAcceptSpaceInvitationProcedure:
|
||||
spaceServiceAcceptSpaceInvitationHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceDeclineSpaceInvitationProcedure:
|
||||
spaceServiceDeclineSpaceInvitationHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceListSpaceMembersProcedure:
|
||||
spaceServiceListSpaceMembersHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceGetSpaceMemberProcedure:
|
||||
@@ -507,6 +523,20 @@ func NewSpaceServiceHandler(svc SpaceServiceHandler, opts ...connect.HandlerOpti
|
||||
spaceServiceUpdateSpaceMemberHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceDeleteSpaceMemberProcedure:
|
||||
spaceServiceDeleteSpaceMemberHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceListSpaceInvitationsProcedure:
|
||||
spaceServiceListSpaceInvitationsHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceListUserSpaceInvitationsProcedure:
|
||||
spaceServiceListUserSpaceInvitationsHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceGetSpaceInvitationProcedure:
|
||||
spaceServiceGetSpaceInvitationHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceCreateSpaceInvitationProcedure:
|
||||
spaceServiceCreateSpaceInvitationHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceDeleteSpaceInvitationProcedure:
|
||||
spaceServiceDeleteSpaceInvitationHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceAcceptSpaceInvitationProcedure:
|
||||
spaceServiceAcceptSpaceInvitationHandler.ServeHTTP(w, r)
|
||||
case SpaceServiceDeclineSpaceInvitationProcedure:
|
||||
spaceServiceDeclineSpaceInvitationHandler.ServeHTTP(w, r)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
@@ -516,66 +546,66 @@ func NewSpaceServiceHandler(svc SpaceServiceHandler, opts ...connect.HandlerOpti
|
||||
// UnimplementedSpaceServiceHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedSpaceServiceHandler struct{}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) CreateSpace(context.Context, *connect.Request[v1.CreateSpaceRequest]) (*connect.Response[v1.Space], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.CreateSpace is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) ListSpaces(context.Context, *connect.Request[api.ListSpacesRequest]) (*connect.Response[api.ListSpacesResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.ListSpaces is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) ListSpaces(context.Context, *connect.Request[v1.ListSpacesRequest]) (*connect.Response[v1.ListSpacesResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.ListSpaces is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) GetSpace(context.Context, *connect.Request[api.GetSpaceRequest]) (*connect.Response[api.Space], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.GetSpace is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) GetSpace(context.Context, *connect.Request[v1.GetSpaceRequest]) (*connect.Response[v1.Space], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.GetSpace is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) CreateSpace(context.Context, *connect.Request[api.CreateSpaceRequest]) (*connect.Response[api.Space], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.CreateSpace is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) UpdateSpace(context.Context, *connect.Request[v1.UpdateSpaceRequest]) (*connect.Response[v1.Space], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.UpdateSpace is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) UpdateSpace(context.Context, *connect.Request[api.UpdateSpaceRequest]) (*connect.Response[api.Space], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.UpdateSpace is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) DeleteSpace(context.Context, *connect.Request[v1.DeleteSpaceRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.DeleteSpace is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) DeleteSpace(context.Context, *connect.Request[api.DeleteSpaceRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.DeleteSpace is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) CreateSpaceInvitation(context.Context, *connect.Request[v1.CreateSpaceInvitationRequest]) (*connect.Response[v1.SpaceInvitation], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.CreateSpaceInvitation is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) ListSpaceMembers(context.Context, *connect.Request[api.ListSpaceMembersRequest]) (*connect.Response[api.ListSpaceMembersResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.ListSpaceMembers is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) ListSpaceInvitations(context.Context, *connect.Request[v1.ListSpaceInvitationsRequest]) (*connect.Response[v1.ListSpaceInvitationsResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.ListSpaceInvitations is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) GetSpaceMember(context.Context, *connect.Request[api.GetSpaceMemberRequest]) (*connect.Response[api.SpaceMember], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.GetSpaceMember is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) ListUserSpaceInvitations(context.Context, *connect.Request[v1.ListUserSpaceInvitationsRequest]) (*connect.Response[v1.ListUserSpaceInvitationsResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.ListUserSpaceInvitations is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) UpdateSpaceMember(context.Context, *connect.Request[api.UpdateSpaceMemberRequest]) (*connect.Response[api.SpaceMember], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.UpdateSpaceMember is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) GetSpaceInvitation(context.Context, *connect.Request[v1.GetSpaceInvitationRequest]) (*connect.Response[v1.SpaceInvitation], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.GetSpaceInvitation is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) DeleteSpaceMember(context.Context, *connect.Request[api.DeleteSpaceMemberRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.DeleteSpaceMember is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) DeleteSpaceInvitation(context.Context, *connect.Request[v1.DeleteSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.DeleteSpaceInvitation is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) ListSpaceInvitations(context.Context, *connect.Request[api.ListSpaceInvitationsRequest]) (*connect.Response[api.ListSpaceInvitationsResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.ListSpaceInvitations is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) AcceptSpaceInvitation(context.Context, *connect.Request[v1.AcceptSpaceInvitationRequest]) (*connect.Response[v1.SpaceMember], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.AcceptSpaceInvitation is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) ListUserSpaceInvitations(context.Context, *connect.Request[api.ListUserSpaceInvitationsRequest]) (*connect.Response[api.ListUserSpaceInvitationsResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.ListUserSpaceInvitations is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) DeclineSpaceInvitation(context.Context, *connect.Request[v1.DeclineSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.DeclineSpaceInvitation is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) GetSpaceInvitation(context.Context, *connect.Request[api.GetSpaceInvitationRequest]) (*connect.Response[api.SpaceInvitation], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.GetSpaceInvitation is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) ListSpaceMembers(context.Context, *connect.Request[v1.ListSpaceMembersRequest]) (*connect.Response[v1.ListSpaceMembersResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.ListSpaceMembers is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) CreateSpaceInvitation(context.Context, *connect.Request[api.CreateSpaceInvitationRequest]) (*connect.Response[api.SpaceInvitation], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.CreateSpaceInvitation is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) GetSpaceMember(context.Context, *connect.Request[v1.GetSpaceMemberRequest]) (*connect.Response[v1.SpaceMember], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.GetSpaceMember is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) DeleteSpaceInvitation(context.Context, *connect.Request[api.DeleteSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.DeleteSpaceInvitation is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) UpdateSpaceMember(context.Context, *connect.Request[v1.UpdateSpaceMemberRequest]) (*connect.Response[v1.SpaceMember], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.UpdateSpaceMember is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) AcceptSpaceInvitation(context.Context, *connect.Request[api.AcceptSpaceInvitationRequest]) (*connect.Response[api.SpaceMember], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.AcceptSpaceInvitation is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedSpaceServiceHandler) DeleteSpaceMember(context.Context, *connect.Request[v1.DeleteSpaceMemberRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.SpaceService.DeleteSpaceMember is not implemented"))
|
||||
func (UnimplementedSpaceServiceHandler) DeclineSpaceInvitation(context.Context, *connect.Request[api.DeclineSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.SpaceService.DeclineSpaceInvitation is not implemented"))
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+1053
-1021
File diff suppressed because it is too large
Load Diff
+164
-164
@@ -1,12 +1,12 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: api/v1/attachment_service.proto
|
||||
// source: api/attachment_service.proto
|
||||
|
||||
/*
|
||||
Package apiv1 is a reverse proxy.
|
||||
Package api is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -35,74 +35,6 @@ var (
|
||||
_ = metadata.Join
|
||||
)
|
||||
|
||||
var filter_AttachmentService_CreateAttachment_0 = &utilities.DoubleArray{Encoding: map[string]int{"attachment": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
|
||||
func request_AttachmentService_CreateAttachment_0(ctx context.Context, marshaler runtime.Marshaler, client AttachmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq CreateAttachmentRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Attachment); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AttachmentService_CreateAttachment_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.CreateAttachment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_AttachmentService_CreateAttachment_0(ctx context.Context, marshaler runtime.Marshaler, server AttachmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq CreateAttachmentRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Attachment); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AttachmentService_CreateAttachment_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := server.CreateAttachment(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_AttachmentService_UploadAttachment_0(ctx context.Context, marshaler runtime.Marshaler, client AttachmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq UploadAttachmentRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.UploadAttachment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_AttachmentService_UploadAttachment_0(ctx context.Context, marshaler runtime.Marshaler, server AttachmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq UploadAttachmentRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := server.UploadAttachment(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
var filter_AttachmentService_ListAttachments_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
|
||||
func request_AttachmentService_ListAttachments_0(ctx context.Context, marshaler runtime.Marshaler, client AttachmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
@@ -177,6 +109,47 @@ func local_request_AttachmentService_GetAttachment_0(ctx context.Context, marsha
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
var filter_AttachmentService_CreateAttachment_0 = &utilities.DoubleArray{Encoding: map[string]int{"attachment": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
|
||||
func request_AttachmentService_CreateAttachment_0(ctx context.Context, marshaler runtime.Marshaler, client AttachmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq CreateAttachmentRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Attachment); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AttachmentService_CreateAttachment_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.CreateAttachment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_AttachmentService_CreateAttachment_0(ctx context.Context, marshaler runtime.Marshaler, server AttachmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq CreateAttachmentRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Attachment); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AttachmentService_CreateAttachment_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := server.CreateAttachment(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
var filter_AttachmentService_UpdateAttachment_0 = &utilities.DoubleArray{Encoding: map[string]int{"attachment": 0, "name": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}}
|
||||
|
||||
func request_AttachmentService_UpdateAttachment_0(ctx context.Context, marshaler runtime.Marshaler, client AttachmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
@@ -324,59 +297,46 @@ func local_request_AttachmentService_BatchDeleteAttachments_0(ctx context.Contex
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_AttachmentService_UploadAttachment_0(ctx context.Context, marshaler runtime.Marshaler, client AttachmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq UploadAttachmentRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.UploadAttachment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_AttachmentService_UploadAttachment_0(ctx context.Context, marshaler runtime.Marshaler, server AttachmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq UploadAttachmentRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := server.UploadAttachment(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
// RegisterAttachmentServiceHandlerServer registers the http handlers for service AttachmentService to "mux".
|
||||
// UnaryRPC :call AttachmentServiceServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAttachmentServiceHandlerFromEndpoint instead.
|
||||
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
|
||||
func RegisterAttachmentServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AttachmentServiceServer) error {
|
||||
mux.Handle(http.MethodPost, pattern_AttachmentService_CreateAttachment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AttachmentService/CreateAttachment", runtime.WithHTTPPathPattern("/api/v1/attachments"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_AttachmentService_CreateAttachment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AttachmentService_CreateAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AttachmentService_UploadAttachment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AttachmentService/UploadAttachment", runtime.WithHTTPPathPattern("/api/v1/attachments:upload"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_AttachmentService_UploadAttachment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AttachmentService_UploadAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_AttachmentService_ListAttachments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AttachmentService/ListAttachments", runtime.WithHTTPPathPattern("/api/v1/attachments"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.AttachmentService/ListAttachments", runtime.WithHTTPPathPattern("/api/attachments"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -396,7 +356,7 @@ func RegisterAttachmentServiceHandlerServer(ctx context.Context, mux *runtime.Se
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AttachmentService/GetAttachment", runtime.WithHTTPPathPattern("/api/v1/{name=attachments/*}"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.AttachmentService/GetAttachment", runtime.WithHTTPPathPattern("/api/{name=attachments/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -410,13 +370,33 @@ func RegisterAttachmentServiceHandlerServer(ctx context.Context, mux *runtime.Se
|
||||
}
|
||||
forward_AttachmentService_GetAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AttachmentService_CreateAttachment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.AttachmentService/CreateAttachment", runtime.WithHTTPPathPattern("/api/attachments"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_AttachmentService_CreateAttachment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AttachmentService_CreateAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPatch, pattern_AttachmentService_UpdateAttachment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AttachmentService/UpdateAttachment", runtime.WithHTTPPathPattern("/api/v1/{attachment.name=attachments/*}"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.AttachmentService/UpdateAttachment", runtime.WithHTTPPathPattern("/api/{attachment.name=attachments/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -436,7 +416,7 @@ func RegisterAttachmentServiceHandlerServer(ctx context.Context, mux *runtime.Se
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AttachmentService/DeleteAttachment", runtime.WithHTTPPathPattern("/api/v1/{name=attachments/*}"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.AttachmentService/DeleteAttachment", runtime.WithHTTPPathPattern("/api/{name=attachments/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -456,7 +436,7 @@ func RegisterAttachmentServiceHandlerServer(ctx context.Context, mux *runtime.Se
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AttachmentService/BatchDeleteAttachments", runtime.WithHTTPPathPattern("/api/v1/attachments:batchDelete"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.AttachmentService/BatchDeleteAttachments", runtime.WithHTTPPathPattern("/api/attachments:batchDelete"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -470,6 +450,26 @@ func RegisterAttachmentServiceHandlerServer(ctx context.Context, mux *runtime.Se
|
||||
}
|
||||
forward_AttachmentService_BatchDeleteAttachments_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AttachmentService_UploadAttachment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.AttachmentService/UploadAttachment", runtime.WithHTTPPathPattern("/api/attachments:upload"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_AttachmentService_UploadAttachment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AttachmentService_UploadAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -510,45 +510,11 @@ func RegisterAttachmentServiceHandler(ctx context.Context, mux *runtime.ServeMux
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "AttachmentServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares.
|
||||
func RegisterAttachmentServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AttachmentServiceClient) error {
|
||||
mux.Handle(http.MethodPost, pattern_AttachmentService_CreateAttachment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AttachmentService/CreateAttachment", runtime.WithHTTPPathPattern("/api/v1/attachments"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_AttachmentService_CreateAttachment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AttachmentService_CreateAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AttachmentService_UploadAttachment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AttachmentService/UploadAttachment", runtime.WithHTTPPathPattern("/api/v1/attachments:upload"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_AttachmentService_UploadAttachment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AttachmentService_UploadAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_AttachmentService_ListAttachments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AttachmentService/ListAttachments", runtime.WithHTTPPathPattern("/api/v1/attachments"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.AttachmentService/ListAttachments", runtime.WithHTTPPathPattern("/api/attachments"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -565,7 +531,7 @@ func RegisterAttachmentServiceHandlerClient(ctx context.Context, mux *runtime.Se
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AttachmentService/GetAttachment", runtime.WithHTTPPathPattern("/api/v1/{name=attachments/*}"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.AttachmentService/GetAttachment", runtime.WithHTTPPathPattern("/api/{name=attachments/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -578,11 +544,28 @@ func RegisterAttachmentServiceHandlerClient(ctx context.Context, mux *runtime.Se
|
||||
}
|
||||
forward_AttachmentService_GetAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AttachmentService_CreateAttachment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.AttachmentService/CreateAttachment", runtime.WithHTTPPathPattern("/api/attachments"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_AttachmentService_CreateAttachment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AttachmentService_CreateAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPatch, pattern_AttachmentService_UpdateAttachment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AttachmentService/UpdateAttachment", runtime.WithHTTPPathPattern("/api/v1/{attachment.name=attachments/*}"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.AttachmentService/UpdateAttachment", runtime.WithHTTPPathPattern("/api/{attachment.name=attachments/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -599,7 +582,7 @@ func RegisterAttachmentServiceHandlerClient(ctx context.Context, mux *runtime.Se
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AttachmentService/DeleteAttachment", runtime.WithHTTPPathPattern("/api/v1/{name=attachments/*}"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.AttachmentService/DeleteAttachment", runtime.WithHTTPPathPattern("/api/{name=attachments/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -616,7 +599,7 @@ func RegisterAttachmentServiceHandlerClient(ctx context.Context, mux *runtime.Se
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AttachmentService/BatchDeleteAttachments", runtime.WithHTTPPathPattern("/api/v1/attachments:batchDelete"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.AttachmentService/BatchDeleteAttachments", runtime.WithHTTPPathPattern("/api/attachments:batchDelete"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -629,25 +612,42 @@ func RegisterAttachmentServiceHandlerClient(ctx context.Context, mux *runtime.Se
|
||||
}
|
||||
forward_AttachmentService_BatchDeleteAttachments_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AttachmentService_UploadAttachment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.AttachmentService/UploadAttachment", runtime.WithHTTPPathPattern("/api/attachments:upload"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_AttachmentService_UploadAttachment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AttachmentService_UploadAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_AttachmentService_CreateAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "attachments"}, ""))
|
||||
pattern_AttachmentService_UploadAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "attachments"}, "upload"))
|
||||
pattern_AttachmentService_ListAttachments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "attachments"}, ""))
|
||||
pattern_AttachmentService_GetAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v1", "attachments", "name"}, ""))
|
||||
pattern_AttachmentService_UpdateAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v1", "attachments", "attachment.name"}, ""))
|
||||
pattern_AttachmentService_DeleteAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v1", "attachments", "name"}, ""))
|
||||
pattern_AttachmentService_BatchDeleteAttachments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "attachments"}, "batchDelete"))
|
||||
pattern_AttachmentService_ListAttachments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "attachments"}, ""))
|
||||
pattern_AttachmentService_GetAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"api", "attachments", "name"}, ""))
|
||||
pattern_AttachmentService_CreateAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "attachments"}, ""))
|
||||
pattern_AttachmentService_UpdateAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"api", "attachments", "attachment.name"}, ""))
|
||||
pattern_AttachmentService_DeleteAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"api", "attachments", "name"}, ""))
|
||||
pattern_AttachmentService_BatchDeleteAttachments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "attachments"}, "batchDelete"))
|
||||
pattern_AttachmentService_UploadAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "attachments"}, "upload"))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_AttachmentService_CreateAttachment_0 = runtime.ForwardResponseMessage
|
||||
forward_AttachmentService_UploadAttachment_0 = runtime.ForwardResponseMessage
|
||||
forward_AttachmentService_ListAttachments_0 = runtime.ForwardResponseMessage
|
||||
forward_AttachmentService_GetAttachment_0 = runtime.ForwardResponseMessage
|
||||
forward_AttachmentService_CreateAttachment_0 = runtime.ForwardResponseMessage
|
||||
forward_AttachmentService_UpdateAttachment_0 = runtime.ForwardResponseMessage
|
||||
forward_AttachmentService_DeleteAttachment_0 = runtime.ForwardResponseMessage
|
||||
forward_AttachmentService_BatchDeleteAttachments_0 = runtime.ForwardResponseMessage
|
||||
forward_AttachmentService_UploadAttachment_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
+117
-109
@@ -2,9 +2,9 @@
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc (unknown)
|
||||
// source: api/v1/attachment_service.proto
|
||||
// source: api/attachment_service.proto
|
||||
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
context "context"
|
||||
@@ -20,36 +20,40 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
AttachmentService_CreateAttachment_FullMethodName = "/memos.api.v1.AttachmentService/CreateAttachment"
|
||||
AttachmentService_UploadAttachment_FullMethodName = "/memos.api.v1.AttachmentService/UploadAttachment"
|
||||
AttachmentService_ListAttachments_FullMethodName = "/memos.api.v1.AttachmentService/ListAttachments"
|
||||
AttachmentService_GetAttachment_FullMethodName = "/memos.api.v1.AttachmentService/GetAttachment"
|
||||
AttachmentService_UpdateAttachment_FullMethodName = "/memos.api.v1.AttachmentService/UpdateAttachment"
|
||||
AttachmentService_DeleteAttachment_FullMethodName = "/memos.api.v1.AttachmentService/DeleteAttachment"
|
||||
AttachmentService_BatchDeleteAttachments_FullMethodName = "/memos.api.v1.AttachmentService/BatchDeleteAttachments"
|
||||
AttachmentService_ListAttachments_FullMethodName = "/memos.api.AttachmentService/ListAttachments"
|
||||
AttachmentService_GetAttachment_FullMethodName = "/memos.api.AttachmentService/GetAttachment"
|
||||
AttachmentService_CreateAttachment_FullMethodName = "/memos.api.AttachmentService/CreateAttachment"
|
||||
AttachmentService_UpdateAttachment_FullMethodName = "/memos.api.AttachmentService/UpdateAttachment"
|
||||
AttachmentService_DeleteAttachment_FullMethodName = "/memos.api.AttachmentService/DeleteAttachment"
|
||||
AttachmentService_BatchDeleteAttachments_FullMethodName = "/memos.api.AttachmentService/BatchDeleteAttachments"
|
||||
AttachmentService_UploadAttachment_FullMethodName = "/memos.api.AttachmentService/UploadAttachment"
|
||||
)
|
||||
|
||||
// AttachmentServiceClient is the client API for AttachmentService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
//
|
||||
// AttachmentService manages files attached to memos.
|
||||
type AttachmentServiceClient interface {
|
||||
// CreateAttachment creates a new attachment.
|
||||
// ListAttachments lists attachments linked to memos the caller can read, plus the caller's unlinked uploads.
|
||||
ListAttachments(ctx context.Context, in *ListAttachmentsRequest, opts ...grpc.CallOption) (*ListAttachmentsResponse, error)
|
||||
// GetAttachment gets an attachment by name. An unlinked attachment is visible only to its uploader and admins;
|
||||
// a linked attachment follows the read access of its memo.
|
||||
GetAttachment(ctx context.Context, in *GetAttachmentRequest, opts ...grpc.CallOption) (*Attachment, error)
|
||||
// CreateAttachment creates an attachment from inline content.
|
||||
CreateAttachment(ctx context.Context, in *CreateAttachmentRequest, opts ...grpc.CallOption) (*Attachment, error)
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries
|
||||
// the spec and returns an upload_id; later calls carry that upload_id.
|
||||
// Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// UpdateAttachment updates an attachment. Only `filename` can be updated. The caller must be the uploader or an
|
||||
// admin.
|
||||
UpdateAttachment(ctx context.Context, in *UpdateAttachmentRequest, opts ...grpc.CallOption) (*Attachment, error)
|
||||
// DeleteAttachment deletes an attachment uploaded by the caller.
|
||||
DeleteAttachment(ctx context.Context, in *DeleteAttachmentRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// BatchDeleteAttachments deletes up to 100 attachments in one atomic request. The caller must be the uploader of
|
||||
// each attachment or an admin.
|
||||
BatchDeleteAttachments(ctx context.Context, in *BatchDeleteAttachmentsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries the spec and returns an upload_id;
|
||||
// later calls carry that upload_id. Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// inactivity, and do not survive a server restart.
|
||||
UploadAttachment(ctx context.Context, in *UploadAttachmentRequest, opts ...grpc.CallOption) (*UploadAttachmentResponse, error)
|
||||
// ListAttachments lists attachments linked to readable memos and the caller's unlinked uploads.
|
||||
ListAttachments(ctx context.Context, in *ListAttachmentsRequest, opts ...grpc.CallOption) (*ListAttachmentsResponse, error)
|
||||
// GetAttachment returns an attachment by name.
|
||||
GetAttachment(ctx context.Context, in *GetAttachmentRequest, opts ...grpc.CallOption) (*Attachment, error)
|
||||
// UpdateAttachment updates an attachment.
|
||||
UpdateAttachment(ctx context.Context, in *UpdateAttachmentRequest, opts ...grpc.CallOption) (*Attachment, error)
|
||||
// DeleteAttachment deletes an attachment by name.
|
||||
DeleteAttachment(ctx context.Context, in *DeleteAttachmentRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// BatchDeleteAttachments deletes multiple attachments in one request.
|
||||
BatchDeleteAttachments(ctx context.Context, in *BatchDeleteAttachmentsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
}
|
||||
|
||||
type attachmentServiceClient struct {
|
||||
@@ -60,26 +64,6 @@ func NewAttachmentServiceClient(cc grpc.ClientConnInterface) AttachmentServiceCl
|
||||
return &attachmentServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *attachmentServiceClient) CreateAttachment(ctx context.Context, in *CreateAttachmentRequest, opts ...grpc.CallOption) (*Attachment, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Attachment)
|
||||
err := c.cc.Invoke(ctx, AttachmentService_CreateAttachment_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *attachmentServiceClient) UploadAttachment(ctx context.Context, in *UploadAttachmentRequest, opts ...grpc.CallOption) (*UploadAttachmentResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(UploadAttachmentResponse)
|
||||
err := c.cc.Invoke(ctx, AttachmentService_UploadAttachment_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *attachmentServiceClient) ListAttachments(ctx context.Context, in *ListAttachmentsRequest, opts ...grpc.CallOption) (*ListAttachmentsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListAttachmentsResponse)
|
||||
@@ -100,6 +84,16 @@ func (c *attachmentServiceClient) GetAttachment(ctx context.Context, in *GetAtta
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *attachmentServiceClient) CreateAttachment(ctx context.Context, in *CreateAttachmentRequest, opts ...grpc.CallOption) (*Attachment, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Attachment)
|
||||
err := c.cc.Invoke(ctx, AttachmentService_CreateAttachment_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *attachmentServiceClient) UpdateAttachment(ctx context.Context, in *UpdateAttachmentRequest, opts ...grpc.CallOption) (*Attachment, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Attachment)
|
||||
@@ -130,27 +124,41 @@ func (c *attachmentServiceClient) BatchDeleteAttachments(ctx context.Context, in
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *attachmentServiceClient) UploadAttachment(ctx context.Context, in *UploadAttachmentRequest, opts ...grpc.CallOption) (*UploadAttachmentResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(UploadAttachmentResponse)
|
||||
err := c.cc.Invoke(ctx, AttachmentService_UploadAttachment_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AttachmentServiceServer is the server API for AttachmentService service.
|
||||
// All implementations must embed UnimplementedAttachmentServiceServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// AttachmentService manages files attached to memos.
|
||||
type AttachmentServiceServer interface {
|
||||
// CreateAttachment creates a new attachment.
|
||||
// ListAttachments lists attachments linked to memos the caller can read, plus the caller's unlinked uploads.
|
||||
ListAttachments(context.Context, *ListAttachmentsRequest) (*ListAttachmentsResponse, error)
|
||||
// GetAttachment gets an attachment by name. An unlinked attachment is visible only to its uploader and admins;
|
||||
// a linked attachment follows the read access of its memo.
|
||||
GetAttachment(context.Context, *GetAttachmentRequest) (*Attachment, error)
|
||||
// CreateAttachment creates an attachment from inline content.
|
||||
CreateAttachment(context.Context, *CreateAttachmentRequest) (*Attachment, error)
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries
|
||||
// the spec and returns an upload_id; later calls carry that upload_id.
|
||||
// Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// UpdateAttachment updates an attachment. Only `filename` can be updated. The caller must be the uploader or an
|
||||
// admin.
|
||||
UpdateAttachment(context.Context, *UpdateAttachmentRequest) (*Attachment, error)
|
||||
// DeleteAttachment deletes an attachment uploaded by the caller.
|
||||
DeleteAttachment(context.Context, *DeleteAttachmentRequest) (*emptypb.Empty, error)
|
||||
// BatchDeleteAttachments deletes up to 100 attachments in one atomic request. The caller must be the uploader of
|
||||
// each attachment or an admin.
|
||||
BatchDeleteAttachments(context.Context, *BatchDeleteAttachmentsRequest) (*emptypb.Empty, error)
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries the spec and returns an upload_id;
|
||||
// later calls carry that upload_id. Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// inactivity, and do not survive a server restart.
|
||||
UploadAttachment(context.Context, *UploadAttachmentRequest) (*UploadAttachmentResponse, error)
|
||||
// ListAttachments lists attachments linked to readable memos and the caller's unlinked uploads.
|
||||
ListAttachments(context.Context, *ListAttachmentsRequest) (*ListAttachmentsResponse, error)
|
||||
// GetAttachment returns an attachment by name.
|
||||
GetAttachment(context.Context, *GetAttachmentRequest) (*Attachment, error)
|
||||
// UpdateAttachment updates an attachment.
|
||||
UpdateAttachment(context.Context, *UpdateAttachmentRequest) (*Attachment, error)
|
||||
// DeleteAttachment deletes an attachment by name.
|
||||
DeleteAttachment(context.Context, *DeleteAttachmentRequest) (*emptypb.Empty, error)
|
||||
// BatchDeleteAttachments deletes multiple attachments in one request.
|
||||
BatchDeleteAttachments(context.Context, *BatchDeleteAttachmentsRequest) (*emptypb.Empty, error)
|
||||
mustEmbedUnimplementedAttachmentServiceServer()
|
||||
}
|
||||
|
||||
@@ -161,18 +169,15 @@ type AttachmentServiceServer interface {
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedAttachmentServiceServer struct{}
|
||||
|
||||
func (UnimplementedAttachmentServiceServer) CreateAttachment(context.Context, *CreateAttachmentRequest) (*Attachment, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateAttachment not implemented")
|
||||
}
|
||||
func (UnimplementedAttachmentServiceServer) UploadAttachment(context.Context, *UploadAttachmentRequest) (*UploadAttachmentResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UploadAttachment not implemented")
|
||||
}
|
||||
func (UnimplementedAttachmentServiceServer) ListAttachments(context.Context, *ListAttachmentsRequest) (*ListAttachmentsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListAttachments not implemented")
|
||||
}
|
||||
func (UnimplementedAttachmentServiceServer) GetAttachment(context.Context, *GetAttachmentRequest) (*Attachment, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetAttachment not implemented")
|
||||
}
|
||||
func (UnimplementedAttachmentServiceServer) CreateAttachment(context.Context, *CreateAttachmentRequest) (*Attachment, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateAttachment not implemented")
|
||||
}
|
||||
func (UnimplementedAttachmentServiceServer) UpdateAttachment(context.Context, *UpdateAttachmentRequest) (*Attachment, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UpdateAttachment not implemented")
|
||||
}
|
||||
@@ -182,6 +187,9 @@ func (UnimplementedAttachmentServiceServer) DeleteAttachment(context.Context, *D
|
||||
func (UnimplementedAttachmentServiceServer) BatchDeleteAttachments(context.Context, *BatchDeleteAttachmentsRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method BatchDeleteAttachments not implemented")
|
||||
}
|
||||
func (UnimplementedAttachmentServiceServer) UploadAttachment(context.Context, *UploadAttachmentRequest) (*UploadAttachmentResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UploadAttachment not implemented")
|
||||
}
|
||||
func (UnimplementedAttachmentServiceServer) mustEmbedUnimplementedAttachmentServiceServer() {}
|
||||
func (UnimplementedAttachmentServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
@@ -203,42 +211,6 @@ func RegisterAttachmentServiceServer(s grpc.ServiceRegistrar, srv AttachmentServ
|
||||
s.RegisterService(&AttachmentService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _AttachmentService_CreateAttachment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateAttachmentRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AttachmentServiceServer).CreateAttachment(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AttachmentService_CreateAttachment_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AttachmentServiceServer).CreateAttachment(ctx, req.(*CreateAttachmentRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AttachmentService_UploadAttachment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UploadAttachmentRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AttachmentServiceServer).UploadAttachment(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AttachmentService_UploadAttachment_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AttachmentServiceServer).UploadAttachment(ctx, req.(*UploadAttachmentRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AttachmentService_ListAttachments_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListAttachmentsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -275,6 +247,24 @@ func _AttachmentService_GetAttachment_Handler(srv interface{}, ctx context.Conte
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AttachmentService_CreateAttachment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateAttachmentRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AttachmentServiceServer).CreateAttachment(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AttachmentService_CreateAttachment_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AttachmentServiceServer).CreateAttachment(ctx, req.(*CreateAttachmentRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AttachmentService_UpdateAttachment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateAttachmentRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -329,21 +319,31 @@ func _AttachmentService_BatchDeleteAttachments_Handler(srv interface{}, ctx cont
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AttachmentService_UploadAttachment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UploadAttachmentRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AttachmentServiceServer).UploadAttachment(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AttachmentService_UploadAttachment_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AttachmentServiceServer).UploadAttachment(ctx, req.(*UploadAttachmentRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// AttachmentService_ServiceDesc is the grpc.ServiceDesc for AttachmentService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var AttachmentService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "memos.api.v1.AttachmentService",
|
||||
ServiceName: "memos.api.AttachmentService",
|
||||
HandlerType: (*AttachmentServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "CreateAttachment",
|
||||
Handler: _AttachmentService_CreateAttachment_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UploadAttachment",
|
||||
Handler: _AttachmentService_UploadAttachment_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListAttachments",
|
||||
Handler: _AttachmentService_ListAttachments_Handler,
|
||||
@@ -352,6 +352,10 @@ var AttachmentService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetAttachment",
|
||||
Handler: _AttachmentService_GetAttachment_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateAttachment",
|
||||
Handler: _AttachmentService_CreateAttachment_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateAttachment",
|
||||
Handler: _AttachmentService_UpdateAttachment_Handler,
|
||||
@@ -364,7 +368,11 @@ var AttachmentService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "BatchDeleteAttachments",
|
||||
Handler: _AttachmentService_BatchDeleteAttachments_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UploadAttachment",
|
||||
Handler: _AttachmentService_UploadAttachment_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v1/attachment_service.proto",
|
||||
Metadata: "api/attachment_service.proto",
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.12
|
||||
// protoc (unknown)
|
||||
// source: api/v1/auth_service.proto
|
||||
// source: api/auth_service.proto
|
||||
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
@@ -24,95 +24,15 @@ const (
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type GetCurrentUserRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetCurrentUserRequest) Reset() {
|
||||
*x = GetCurrentUserRequest{}
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetCurrentUserRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetCurrentUserRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetCurrentUserRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetCurrentUserRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetCurrentUserRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_auth_service_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type GetCurrentUserResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The authenticated user's information.
|
||||
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetCurrentUserResponse) Reset() {
|
||||
*x = GetCurrentUserResponse{}
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetCurrentUserResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetCurrentUserResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetCurrentUserResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetCurrentUserResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetCurrentUserResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_auth_service_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *GetCurrentUserResponse) GetUser() *User {
|
||||
if x != nil {
|
||||
return x.User
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Request message for AuthService.SignIn.
|
||||
type SignInRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Authentication credentials. Provide one method.
|
||||
// The credentials to authenticate with. Provide exactly one.
|
||||
//
|
||||
// Types that are valid to be assigned to Credentials:
|
||||
//
|
||||
// *SignInRequest_PasswordCredentials_
|
||||
// *SignInRequest_SsoCredentials
|
||||
// *SignInRequest_SsoCredentials_
|
||||
Credentials isSignInRequest_Credentials `protobuf_oneof:"credentials"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -120,7 +40,7 @@ type SignInRequest struct {
|
||||
|
||||
func (x *SignInRequest) Reset() {
|
||||
*x = SignInRequest{}
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[2]
|
||||
mi := &file_api_auth_service_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -132,7 +52,7 @@ func (x *SignInRequest) String() string {
|
||||
func (*SignInRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SignInRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[2]
|
||||
mi := &file_api_auth_service_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -145,7 +65,7 @@ func (x *SignInRequest) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use SignInRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SignInRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_auth_service_proto_rawDescGZIP(), []int{2}
|
||||
return file_api_auth_service_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *SignInRequest) GetCredentials() isSignInRequest_Credentials {
|
||||
@@ -164,9 +84,9 @@ func (x *SignInRequest) GetPasswordCredentials() *SignInRequest_PasswordCredenti
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SignInRequest) GetSsoCredentials() *SignInRequest_SSOCredentials {
|
||||
func (x *SignInRequest) GetSsoCredentials() *SignInRequest_SsoCredentials {
|
||||
if x != nil {
|
||||
if x, ok := x.Credentials.(*SignInRequest_SsoCredentials); ok {
|
||||
if x, ok := x.Credentials.(*SignInRequest_SsoCredentials_); ok {
|
||||
return x.SsoCredentials
|
||||
}
|
||||
}
|
||||
@@ -178,36 +98,37 @@ type isSignInRequest_Credentials interface {
|
||||
}
|
||||
|
||||
type SignInRequest_PasswordCredentials_ struct {
|
||||
// Username and password authentication.
|
||||
// Username and password credentials.
|
||||
PasswordCredentials *SignInRequest_PasswordCredentials `protobuf:"bytes,1,opt,name=password_credentials,json=passwordCredentials,proto3,oneof"`
|
||||
}
|
||||
|
||||
type SignInRequest_SsoCredentials struct {
|
||||
// SSO provider authentication.
|
||||
SsoCredentials *SignInRequest_SSOCredentials `protobuf:"bytes,2,opt,name=sso_credentials,json=ssoCredentials,proto3,oneof"`
|
||||
type SignInRequest_SsoCredentials_ struct {
|
||||
// SSO credentials from an OAuth2 authorization code flow.
|
||||
SsoCredentials *SignInRequest_SsoCredentials `protobuf:"bytes,2,opt,name=sso_credentials,json=ssoCredentials,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*SignInRequest_PasswordCredentials_) isSignInRequest_Credentials() {}
|
||||
|
||||
func (*SignInRequest_SsoCredentials) isSignInRequest_Credentials() {}
|
||||
func (*SignInRequest_SsoCredentials_) isSignInRequest_Credentials() {}
|
||||
|
||||
// Response message for AuthService.SignIn.
|
||||
type SignInResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The authenticated user's information.
|
||||
// The signed-in user.
|
||||
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
|
||||
// The short-lived access token for API requests.
|
||||
// Store in memory only, not in localStorage.
|
||||
// Keep it in memory only, not in localStorage.
|
||||
AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
|
||||
// When the access token expires.
|
||||
// Client should call RefreshToken before this time.
|
||||
AccessTokenExpiresAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=access_token_expires_at,json=accessTokenExpiresAt,proto3" json:"access_token_expires_at,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
// Call RefreshToken before this time.
|
||||
AccessTokenExpireTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=access_token_expire_time,json=accessTokenExpireTime,proto3" json:"access_token_expire_time,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SignInResponse) Reset() {
|
||||
*x = SignInResponse{}
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[3]
|
||||
mi := &file_api_auth_service_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -219,7 +140,7 @@ func (x *SignInResponse) String() string {
|
||||
func (*SignInResponse) ProtoMessage() {}
|
||||
|
||||
func (x *SignInResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[3]
|
||||
mi := &file_api_auth_service_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -232,7 +153,7 @@ func (x *SignInResponse) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use SignInResponse.ProtoReflect.Descriptor instead.
|
||||
func (*SignInResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_auth_service_proto_rawDescGZIP(), []int{3}
|
||||
return file_api_auth_service_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *SignInResponse) GetUser() *User {
|
||||
@@ -249,49 +170,15 @@ func (x *SignInResponse) GetAccessToken() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SignInResponse) GetAccessTokenExpiresAt() *timestamppb.Timestamp {
|
||||
func (x *SignInResponse) GetAccessTokenExpireTime() *timestamppb.Timestamp {
|
||||
if x != nil {
|
||||
return x.AccessTokenExpiresAt
|
||||
return x.AccessTokenExpireTime
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SignOutRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SignOutRequest) Reset() {
|
||||
*x = SignOutRequest{}
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SignOutRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SignOutRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SignOutRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SignOutRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SignOutRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_auth_service_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
// Request message for AuthService.RefreshToken.
|
||||
// It has no fields: the refresh token is read from the HttpOnly cookie.
|
||||
type RefreshTokenRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
@@ -300,7 +187,7 @@ type RefreshTokenRequest struct {
|
||||
|
||||
func (x *RefreshTokenRequest) Reset() {
|
||||
*x = RefreshTokenRequest{}
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[5]
|
||||
mi := &file_api_auth_service_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -312,7 +199,7 @@ func (x *RefreshTokenRequest) String() string {
|
||||
func (*RefreshTokenRequest) ProtoMessage() {}
|
||||
|
||||
func (x *RefreshTokenRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[5]
|
||||
mi := &file_api_auth_service_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -325,22 +212,23 @@ func (x *RefreshTokenRequest) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use RefreshTokenRequest.ProtoReflect.Descriptor instead.
|
||||
func (*RefreshTokenRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_auth_service_proto_rawDescGZIP(), []int{5}
|
||||
return file_api_auth_service_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
// Response message for AuthService.RefreshToken.
|
||||
type RefreshTokenResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The new short-lived access token.
|
||||
AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
|
||||
// When the access token expires.
|
||||
ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
// When the new access token expires.
|
||||
AccessTokenExpireTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=access_token_expire_time,json=accessTokenExpireTime,proto3" json:"access_token_expire_time,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RefreshTokenResponse) Reset() {
|
||||
*x = RefreshTokenResponse{}
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[6]
|
||||
mi := &file_api_auth_service_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -352,7 +240,7 @@ func (x *RefreshTokenResponse) String() string {
|
||||
func (*RefreshTokenResponse) ProtoMessage() {}
|
||||
|
||||
func (x *RefreshTokenResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[6]
|
||||
mi := &file_api_auth_service_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -365,7 +253,7 @@ func (x *RefreshTokenResponse) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use RefreshTokenResponse.ProtoReflect.Descriptor instead.
|
||||
func (*RefreshTokenResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_auth_service_proto_rawDescGZIP(), []int{6}
|
||||
return file_api_auth_service_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *RefreshTokenResponse) GetAccessToken() string {
|
||||
@@ -375,19 +263,140 @@ func (x *RefreshTokenResponse) GetAccessToken() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RefreshTokenResponse) GetExpiresAt() *timestamppb.Timestamp {
|
||||
func (x *RefreshTokenResponse) GetAccessTokenExpireTime() *timestamppb.Timestamp {
|
||||
if x != nil {
|
||||
return x.ExpiresAt
|
||||
return x.AccessTokenExpireTime
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Nested message for password-based authentication credentials.
|
||||
// Request message for AuthService.GetCurrentUser.
|
||||
type GetCurrentUserRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetCurrentUserRequest) Reset() {
|
||||
*x = GetCurrentUserRequest{}
|
||||
mi := &file_api_auth_service_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetCurrentUserRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetCurrentUserRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetCurrentUserRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_auth_service_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetCurrentUserRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetCurrentUserRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_auth_service_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
// Response message for AuthService.GetCurrentUser.
|
||||
type GetCurrentUserResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The authenticated user.
|
||||
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetCurrentUserResponse) Reset() {
|
||||
*x = GetCurrentUserResponse{}
|
||||
mi := &file_api_auth_service_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetCurrentUserResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetCurrentUserResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetCurrentUserResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_auth_service_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetCurrentUserResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetCurrentUserResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_auth_service_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *GetCurrentUserResponse) GetUser() *User {
|
||||
if x != nil {
|
||||
return x.User
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Request message for AuthService.SignOut.
|
||||
type SignOutRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SignOutRequest) Reset() {
|
||||
*x = SignOutRequest{}
|
||||
mi := &file_api_auth_service_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SignOutRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SignOutRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SignOutRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_auth_service_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SignOutRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SignOutRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_auth_service_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
// PasswordCredentials are a username and password.
|
||||
// Regular users cannot use them when the instance disallows password sign-in.
|
||||
type SignInRequest_PasswordCredentials struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The username to sign in with.
|
||||
// Required. The username to sign in with.
|
||||
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
|
||||
// The password to sign in with.
|
||||
// Required. The password to sign in with.
|
||||
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -395,7 +404,7 @@ type SignInRequest_PasswordCredentials struct {
|
||||
|
||||
func (x *SignInRequest_PasswordCredentials) Reset() {
|
||||
*x = SignInRequest_PasswordCredentials{}
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[7]
|
||||
mi := &file_api_auth_service_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -407,7 +416,7 @@ func (x *SignInRequest_PasswordCredentials) String() string {
|
||||
func (*SignInRequest_PasswordCredentials) ProtoMessage() {}
|
||||
|
||||
func (x *SignInRequest_PasswordCredentials) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[7]
|
||||
mi := &file_api_auth_service_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -420,7 +429,7 @@ func (x *SignInRequest_PasswordCredentials) ProtoReflect() protoreflect.Message
|
||||
|
||||
// Deprecated: Use SignInRequest_PasswordCredentials.ProtoReflect.Descriptor instead.
|
||||
func (*SignInRequest_PasswordCredentials) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_auth_service_proto_rawDescGZIP(), []int{2, 0}
|
||||
return file_api_auth_service_proto_rawDescGZIP(), []int{0, 0}
|
||||
}
|
||||
|
||||
func (x *SignInRequest_PasswordCredentials) GetUsername() string {
|
||||
@@ -437,38 +446,38 @@ func (x *SignInRequest_PasswordCredentials) GetPassword() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Nested message for SSO authentication credentials.
|
||||
type SignInRequest_SSOCredentials struct {
|
||||
// SsoCredentials are the result of an OAuth2 authorization code flow with an identity provider.
|
||||
// A first sign-in creates a local user unless the instance disallows user registration.
|
||||
type SignInRequest_SsoCredentials struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The resource name of the SSO provider.
|
||||
// Required. The resource name of the identity provider.
|
||||
// Format: identity-providers/{idp}
|
||||
IdpName string `protobuf:"bytes,1,opt,name=idp_name,json=idpName,proto3" json:"idp_name,omitempty"`
|
||||
// The authorization code from the SSO provider.
|
||||
IdentityProvider string `protobuf:"bytes,1,opt,name=identity_provider,json=identityProvider,proto3" json:"identity_provider,omitempty"`
|
||||
// Required. The authorization code returned by the identity provider.
|
||||
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
|
||||
// The redirect URI used in the SSO flow.
|
||||
// Required. The redirect URI used in the authorization request.
|
||||
RedirectUri string `protobuf:"bytes,3,opt,name=redirect_uri,json=redirectUri,proto3" json:"redirect_uri,omitempty"`
|
||||
// The PKCE code verifier for enhanced security (RFC 7636).
|
||||
// Optional - enables PKCE flow protection against authorization code interception.
|
||||
// Optional. The PKCE code verifier (RFC 7636). Set it when the authorization request used a code challenge.
|
||||
CodeVerifier string `protobuf:"bytes,4,opt,name=code_verifier,json=codeVerifier,proto3" json:"code_verifier,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SignInRequest_SSOCredentials) Reset() {
|
||||
*x = SignInRequest_SSOCredentials{}
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[8]
|
||||
func (x *SignInRequest_SsoCredentials) Reset() {
|
||||
*x = SignInRequest_SsoCredentials{}
|
||||
mi := &file_api_auth_service_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SignInRequest_SSOCredentials) String() string {
|
||||
func (x *SignInRequest_SsoCredentials) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SignInRequest_SSOCredentials) ProtoMessage() {}
|
||||
func (*SignInRequest_SsoCredentials) ProtoMessage() {}
|
||||
|
||||
func (x *SignInRequest_SSOCredentials) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_auth_service_proto_msgTypes[8]
|
||||
func (x *SignInRequest_SsoCredentials) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_auth_service_proto_msgTypes[8]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -479,118 +488,119 @@ func (x *SignInRequest_SSOCredentials) ProtoReflect() protoreflect.Message {
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SignInRequest_SSOCredentials.ProtoReflect.Descriptor instead.
|
||||
func (*SignInRequest_SSOCredentials) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_auth_service_proto_rawDescGZIP(), []int{2, 1}
|
||||
// Deprecated: Use SignInRequest_SsoCredentials.ProtoReflect.Descriptor instead.
|
||||
func (*SignInRequest_SsoCredentials) Descriptor() ([]byte, []int) {
|
||||
return file_api_auth_service_proto_rawDescGZIP(), []int{0, 1}
|
||||
}
|
||||
|
||||
func (x *SignInRequest_SSOCredentials) GetIdpName() string {
|
||||
func (x *SignInRequest_SsoCredentials) GetIdentityProvider() string {
|
||||
if x != nil {
|
||||
return x.IdpName
|
||||
return x.IdentityProvider
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SignInRequest_SSOCredentials) GetCode() string {
|
||||
func (x *SignInRequest_SsoCredentials) GetCode() string {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SignInRequest_SSOCredentials) GetRedirectUri() string {
|
||||
func (x *SignInRequest_SsoCredentials) GetRedirectUri() string {
|
||||
if x != nil {
|
||||
return x.RedirectUri
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SignInRequest_SSOCredentials) GetCodeVerifier() string {
|
||||
func (x *SignInRequest_SsoCredentials) GetCodeVerifier() string {
|
||||
if x != nil {
|
||||
return x.CodeVerifier
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_api_v1_auth_service_proto protoreflect.FileDescriptor
|
||||
var File_api_auth_service_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_api_v1_auth_service_proto_rawDesc = "" +
|
||||
const file_api_auth_service_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x19api/v1/auth_service.proto\x12\fmemos.api.v1\x1a\x19api/v1/user_service.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x17\n" +
|
||||
"\x15GetCurrentUserRequest\"@\n" +
|
||||
"\x16GetCurrentUserResponse\x12&\n" +
|
||||
"\x04user\x18\x01 \x01(\v2\x12.memos.api.v1.UserR\x04user\"\xd2\x03\n" +
|
||||
"\rSignInRequest\x12d\n" +
|
||||
"\x14password_credentials\x18\x01 \x01(\v2/.memos.api.v1.SignInRequest.PasswordCredentialsH\x00R\x13passwordCredentials\x12U\n" +
|
||||
"\x0fsso_credentials\x18\x02 \x01(\v2*.memos.api.v1.SignInRequest.SSOCredentialsH\x00R\x0essoCredentials\x1aW\n" +
|
||||
"\x16api/auth_service.proto\x12\tmemos.api\x1a\x16api/user_service.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xfd\x03\n" +
|
||||
"\rSignInRequest\x12a\n" +
|
||||
"\x14password_credentials\x18\x01 \x01(\v2,.memos.api.SignInRequest.PasswordCredentialsH\x00R\x13passwordCredentials\x12R\n" +
|
||||
"\x0fsso_credentials\x18\x02 \x01(\v2'.memos.api.SignInRequest.SsoCredentialsH\x00R\x0essoCredentials\x1aW\n" +
|
||||
"\x13PasswordCredentials\x12\x1f\n" +
|
||||
"\busername\x18\x01 \x01(\tB\x03\xe0A\x02R\busername\x12\x1f\n" +
|
||||
"\bpassword\x18\x02 \x01(\tB\x03\xe0A\x02R\bpassword\x1a\x9b\x01\n" +
|
||||
"\x0eSSOCredentials\x12\x1e\n" +
|
||||
"\bidp_name\x18\x01 \x01(\tB\x03\xe0A\x02R\aidpName\x12\x17\n" +
|
||||
"\bpassword\x18\x02 \x01(\tB\x03\xe0A\x02R\bpassword\x1a\xcc\x01\n" +
|
||||
"\x0eSsoCredentials\x12O\n" +
|
||||
"\x11identity_provider\x18\x01 \x01(\tB\"\xe0A\x02\xfaA\x1c\n" +
|
||||
"\x1amemos.api/IdentityProviderR\x10identityProvider\x12\x17\n" +
|
||||
"\x04code\x18\x02 \x01(\tB\x03\xe0A\x02R\x04code\x12&\n" +
|
||||
"\fredirect_uri\x18\x03 \x01(\tB\x03\xe0A\x02R\vredirectUri\x12(\n" +
|
||||
"\rcode_verifier\x18\x04 \x01(\tB\x03\xe0A\x01R\fcodeVerifierB\r\n" +
|
||||
"\vcredentials\"\xae\x01\n" +
|
||||
"\x0eSignInResponse\x12&\n" +
|
||||
"\x04user\x18\x01 \x01(\v2\x12.memos.api.v1.UserR\x04user\x12!\n" +
|
||||
"\faccess_token\x18\x02 \x01(\tR\vaccessToken\x12Q\n" +
|
||||
"\x17access_token_expires_at\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\x14accessTokenExpiresAt\"\x10\n" +
|
||||
"\x0eSignOutRequest\"\x15\n" +
|
||||
"\x13RefreshTokenRequest\"t\n" +
|
||||
"\vcredentials\"\xad\x01\n" +
|
||||
"\x0eSignInResponse\x12#\n" +
|
||||
"\x04user\x18\x01 \x01(\v2\x0f.memos.api.UserR\x04user\x12!\n" +
|
||||
"\faccess_token\x18\x02 \x01(\tR\vaccessToken\x12S\n" +
|
||||
"\x18access_token_expire_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\x15accessTokenExpireTime\"\x15\n" +
|
||||
"\x13RefreshTokenRequest\"\x8e\x01\n" +
|
||||
"\x14RefreshTokenResponse\x12!\n" +
|
||||
"\faccess_token\x18\x01 \x01(\tR\vaccessToken\x129\n" +
|
||||
"\n" +
|
||||
"expires_at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt2\xbf\x03\n" +
|
||||
"\vAuthService\x12t\n" +
|
||||
"\x0eGetCurrentUser\x12#.memos.api.v1.GetCurrentUserRequest\x1a$.memos.api.v1.GetCurrentUserResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/api/v1/auth/me\x12c\n" +
|
||||
"\x06SignIn\x12\x1b.memos.api.v1.SignInRequest\x1a\x1c.memos.api.v1.SignInResponse\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\"\x13/api/v1/auth/signin\x12]\n" +
|
||||
"\aSignOut\x12\x1c.memos.api.v1.SignOutRequest\x1a\x16.google.protobuf.Empty\"\x1c\x82\xd3\xe4\x93\x02\x16\"\x14/api/v1/auth/signout\x12v\n" +
|
||||
"\fRefreshToken\x12!.memos.api.v1.RefreshTokenRequest\x1a\".memos.api.v1.RefreshTokenResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\"\x14/api/v1/auth/refreshB\xa8\x01\n" +
|
||||
"\x10com.memos.api.v1B\x10AuthServiceProtoP\x01Z0github.com/usememos/memos/proto/gen/api/v1;apiv1\xa2\x02\x03MAX\xaa\x02\fMemos.Api.V1\xca\x02\fMemos\\Api\\V1\xe2\x02\x18Memos\\Api\\V1\\GPBMetadata\xea\x02\x0eMemos::Api::V1b\x06proto3"
|
||||
"\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12S\n" +
|
||||
"\x18access_token_expire_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\x15accessTokenExpireTime\"\x17\n" +
|
||||
"\x15GetCurrentUserRequest\"=\n" +
|
||||
"\x16GetCurrentUserResponse\x12#\n" +
|
||||
"\x04user\x18\x01 \x01(\v2\x0f.memos.api.UserR\x04user\"\x10\n" +
|
||||
"\x0eSignOutRequest2\x9e\x03\n" +
|
||||
"\vAuthService\x12Z\n" +
|
||||
"\x06SignIn\x12\x18.memos.api.SignInRequest\x1a\x19.memos.api.SignInResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/api/auth/signin\x12m\n" +
|
||||
"\fRefreshToken\x12\x1e.memos.api.RefreshTokenRequest\x1a\x1f.memos.api.RefreshTokenResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\"\x11/api/auth/refresh\x12k\n" +
|
||||
"\x0eGetCurrentUser\x12 .memos.api.GetCurrentUserRequest\x1a!.memos.api.GetCurrentUserResponse\"\x14\x82\xd3\xe4\x93\x02\x0e\x12\f/api/auth/me\x12W\n" +
|
||||
"\aSignOut\x12\x19.memos.api.SignOutRequest\x1a\x16.google.protobuf.Empty\"\x19\x82\xd3\xe4\x93\x02\x13\"\x11/api/auth/signoutB\x8f\x01\n" +
|
||||
"\rcom.memos.apiB\x10AuthServiceProtoP\x01Z'github.com/usememos/memos/proto/gen/api\xa2\x02\x03MAX\xaa\x02\tMemos.Api\xca\x02\tMemos\\Api\xe2\x02\x15Memos\\Api\\GPBMetadata\xea\x02\n" +
|
||||
"Memos::Apib\x06proto3"
|
||||
|
||||
var (
|
||||
file_api_v1_auth_service_proto_rawDescOnce sync.Once
|
||||
file_api_v1_auth_service_proto_rawDescData []byte
|
||||
file_api_auth_service_proto_rawDescOnce sync.Once
|
||||
file_api_auth_service_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_api_v1_auth_service_proto_rawDescGZIP() []byte {
|
||||
file_api_v1_auth_service_proto_rawDescOnce.Do(func() {
|
||||
file_api_v1_auth_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_v1_auth_service_proto_rawDesc), len(file_api_v1_auth_service_proto_rawDesc)))
|
||||
func file_api_auth_service_proto_rawDescGZIP() []byte {
|
||||
file_api_auth_service_proto_rawDescOnce.Do(func() {
|
||||
file_api_auth_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_auth_service_proto_rawDesc), len(file_api_auth_service_proto_rawDesc)))
|
||||
})
|
||||
return file_api_v1_auth_service_proto_rawDescData
|
||||
return file_api_auth_service_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_api_v1_auth_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
||||
var file_api_v1_auth_service_proto_goTypes = []any{
|
||||
(*GetCurrentUserRequest)(nil), // 0: memos.api.v1.GetCurrentUserRequest
|
||||
(*GetCurrentUserResponse)(nil), // 1: memos.api.v1.GetCurrentUserResponse
|
||||
(*SignInRequest)(nil), // 2: memos.api.v1.SignInRequest
|
||||
(*SignInResponse)(nil), // 3: memos.api.v1.SignInResponse
|
||||
(*SignOutRequest)(nil), // 4: memos.api.v1.SignOutRequest
|
||||
(*RefreshTokenRequest)(nil), // 5: memos.api.v1.RefreshTokenRequest
|
||||
(*RefreshTokenResponse)(nil), // 6: memos.api.v1.RefreshTokenResponse
|
||||
(*SignInRequest_PasswordCredentials)(nil), // 7: memos.api.v1.SignInRequest.PasswordCredentials
|
||||
(*SignInRequest_SSOCredentials)(nil), // 8: memos.api.v1.SignInRequest.SSOCredentials
|
||||
(*User)(nil), // 9: memos.api.v1.User
|
||||
var file_api_auth_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
||||
var file_api_auth_service_proto_goTypes = []any{
|
||||
(*SignInRequest)(nil), // 0: memos.api.SignInRequest
|
||||
(*SignInResponse)(nil), // 1: memos.api.SignInResponse
|
||||
(*RefreshTokenRequest)(nil), // 2: memos.api.RefreshTokenRequest
|
||||
(*RefreshTokenResponse)(nil), // 3: memos.api.RefreshTokenResponse
|
||||
(*GetCurrentUserRequest)(nil), // 4: memos.api.GetCurrentUserRequest
|
||||
(*GetCurrentUserResponse)(nil), // 5: memos.api.GetCurrentUserResponse
|
||||
(*SignOutRequest)(nil), // 6: memos.api.SignOutRequest
|
||||
(*SignInRequest_PasswordCredentials)(nil), // 7: memos.api.SignInRequest.PasswordCredentials
|
||||
(*SignInRequest_SsoCredentials)(nil), // 8: memos.api.SignInRequest.SsoCredentials
|
||||
(*User)(nil), // 9: memos.api.User
|
||||
(*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp
|
||||
(*emptypb.Empty)(nil), // 11: google.protobuf.Empty
|
||||
}
|
||||
var file_api_v1_auth_service_proto_depIdxs = []int32{
|
||||
9, // 0: memos.api.v1.GetCurrentUserResponse.user:type_name -> memos.api.v1.User
|
||||
7, // 1: memos.api.v1.SignInRequest.password_credentials:type_name -> memos.api.v1.SignInRequest.PasswordCredentials
|
||||
8, // 2: memos.api.v1.SignInRequest.sso_credentials:type_name -> memos.api.v1.SignInRequest.SSOCredentials
|
||||
9, // 3: memos.api.v1.SignInResponse.user:type_name -> memos.api.v1.User
|
||||
10, // 4: memos.api.v1.SignInResponse.access_token_expires_at:type_name -> google.protobuf.Timestamp
|
||||
10, // 5: memos.api.v1.RefreshTokenResponse.expires_at:type_name -> google.protobuf.Timestamp
|
||||
0, // 6: memos.api.v1.AuthService.GetCurrentUser:input_type -> memos.api.v1.GetCurrentUserRequest
|
||||
2, // 7: memos.api.v1.AuthService.SignIn:input_type -> memos.api.v1.SignInRequest
|
||||
4, // 8: memos.api.v1.AuthService.SignOut:input_type -> memos.api.v1.SignOutRequest
|
||||
5, // 9: memos.api.v1.AuthService.RefreshToken:input_type -> memos.api.v1.RefreshTokenRequest
|
||||
1, // 10: memos.api.v1.AuthService.GetCurrentUser:output_type -> memos.api.v1.GetCurrentUserResponse
|
||||
3, // 11: memos.api.v1.AuthService.SignIn:output_type -> memos.api.v1.SignInResponse
|
||||
11, // 12: memos.api.v1.AuthService.SignOut:output_type -> google.protobuf.Empty
|
||||
6, // 13: memos.api.v1.AuthService.RefreshToken:output_type -> memos.api.v1.RefreshTokenResponse
|
||||
var file_api_auth_service_proto_depIdxs = []int32{
|
||||
7, // 0: memos.api.SignInRequest.password_credentials:type_name -> memos.api.SignInRequest.PasswordCredentials
|
||||
8, // 1: memos.api.SignInRequest.sso_credentials:type_name -> memos.api.SignInRequest.SsoCredentials
|
||||
9, // 2: memos.api.SignInResponse.user:type_name -> memos.api.User
|
||||
10, // 3: memos.api.SignInResponse.access_token_expire_time:type_name -> google.protobuf.Timestamp
|
||||
10, // 4: memos.api.RefreshTokenResponse.access_token_expire_time:type_name -> google.protobuf.Timestamp
|
||||
9, // 5: memos.api.GetCurrentUserResponse.user:type_name -> memos.api.User
|
||||
0, // 6: memos.api.AuthService.SignIn:input_type -> memos.api.SignInRequest
|
||||
2, // 7: memos.api.AuthService.RefreshToken:input_type -> memos.api.RefreshTokenRequest
|
||||
4, // 8: memos.api.AuthService.GetCurrentUser:input_type -> memos.api.GetCurrentUserRequest
|
||||
6, // 9: memos.api.AuthService.SignOut:input_type -> memos.api.SignOutRequest
|
||||
1, // 10: memos.api.AuthService.SignIn:output_type -> memos.api.SignInResponse
|
||||
3, // 11: memos.api.AuthService.RefreshToken:output_type -> memos.api.RefreshTokenResponse
|
||||
5, // 12: memos.api.AuthService.GetCurrentUser:output_type -> memos.api.GetCurrentUserResponse
|
||||
11, // 13: memos.api.AuthService.SignOut:output_type -> google.protobuf.Empty
|
||||
10, // [10:14] is the sub-list for method output_type
|
||||
6, // [6:10] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
@@ -598,31 +608,31 @@ var file_api_v1_auth_service_proto_depIdxs = []int32{
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_v1_auth_service_proto_init() }
|
||||
func file_api_v1_auth_service_proto_init() {
|
||||
if File_api_v1_auth_service_proto != nil {
|
||||
func init() { file_api_auth_service_proto_init() }
|
||||
func file_api_auth_service_proto_init() {
|
||||
if File_api_auth_service_proto != nil {
|
||||
return
|
||||
}
|
||||
file_api_v1_user_service_proto_init()
|
||||
file_api_v1_auth_service_proto_msgTypes[2].OneofWrappers = []any{
|
||||
file_api_user_service_proto_init()
|
||||
file_api_auth_service_proto_msgTypes[0].OneofWrappers = []any{
|
||||
(*SignInRequest_PasswordCredentials_)(nil),
|
||||
(*SignInRequest_SsoCredentials)(nil),
|
||||
(*SignInRequest_SsoCredentials_)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_v1_auth_service_proto_rawDesc), len(file_api_v1_auth_service_proto_rawDesc)),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_auth_service_proto_rawDesc), len(file_api_auth_service_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 9,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_api_v1_auth_service_proto_goTypes,
|
||||
DependencyIndexes: file_api_v1_auth_service_proto_depIdxs,
|
||||
MessageInfos: file_api_v1_auth_service_proto_msgTypes,
|
||||
GoTypes: file_api_auth_service_proto_goTypes,
|
||||
DependencyIndexes: file_api_auth_service_proto_depIdxs,
|
||||
MessageInfos: file_api_auth_service_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_v1_auth_service_proto = out.File
|
||||
file_api_v1_auth_service_proto_goTypes = nil
|
||||
file_api_v1_auth_service_proto_depIdxs = nil
|
||||
File_api_auth_service_proto = out.File
|
||||
file_api_auth_service_proto_goTypes = nil
|
||||
file_api_auth_service_proto_depIdxs = nil
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: api/v1/auth_service.proto
|
||||
// source: api/auth_service.proto
|
||||
|
||||
/*
|
||||
Package apiv1 is a reverse proxy.
|
||||
Package api is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -35,27 +35,6 @@ var (
|
||||
_ = metadata.Join
|
||||
)
|
||||
|
||||
func request_AuthService_GetCurrentUser_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq GetCurrentUserRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.GetCurrentUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_AuthService_GetCurrentUser_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq GetCurrentUserRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
msg, err := server.GetCurrentUser(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_AuthService_SignIn_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq SignInRequest
|
||||
@@ -83,27 +62,6 @@ func local_request_AuthService_SignIn_0(ctx context.Context, marshaler runtime.M
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_AuthService_SignOut_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq SignOutRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.SignOut(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_AuthService_SignOut_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq SignOutRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
msg, err := server.SignOut(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_AuthService_RefreshToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq RefreshTokenRequest
|
||||
@@ -131,39 +89,61 @@ func local_request_AuthService_RefreshToken_0(ctx context.Context, marshaler run
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_AuthService_GetCurrentUser_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq GetCurrentUserRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.GetCurrentUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_AuthService_GetCurrentUser_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq GetCurrentUserRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
msg, err := server.GetCurrentUser(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_AuthService_SignOut_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq SignOutRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.SignOut(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_AuthService_SignOut_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq SignOutRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
msg, err := server.SignOut(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
// RegisterAuthServiceHandlerServer registers the http handlers for service AuthService to "mux".
|
||||
// UnaryRPC :call AuthServiceServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAuthServiceHandlerFromEndpoint instead.
|
||||
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
|
||||
func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthServiceServer) error {
|
||||
mux.Handle(http.MethodGet, pattern_AuthService_GetCurrentUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/GetCurrentUser", runtime.WithHTTPPathPattern("/api/v1/auth/me"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_AuthService_GetCurrentUser_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AuthService_GetCurrentUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AuthService_SignIn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/SignIn", runtime.WithHTTPPathPattern("/api/v1/auth/signin"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.AuthService/SignIn", runtime.WithHTTPPathPattern("/api/auth/signin"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -177,33 +157,13 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
|
||||
}
|
||||
forward_AuthService_SignIn_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AuthService_SignOut_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/SignOut", runtime.WithHTTPPathPattern("/api/v1/auth/signout"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_AuthService_SignOut_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AuthService_SignOut_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AuthService_RefreshToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/api/v1/auth/refresh"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/api/auth/refresh"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -217,6 +177,46 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
|
||||
}
|
||||
forward_AuthService_RefreshToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_AuthService_GetCurrentUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.AuthService/GetCurrentUser", runtime.WithHTTPPathPattern("/api/auth/me"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_AuthService_GetCurrentUser_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AuthService_GetCurrentUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AuthService_SignOut_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.AuthService/SignOut", runtime.WithHTTPPathPattern("/api/auth/signout"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_AuthService_SignOut_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AuthService_SignOut_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -257,28 +257,11 @@ func RegisterAuthServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "AuthServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares.
|
||||
func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthServiceClient) error {
|
||||
mux.Handle(http.MethodGet, pattern_AuthService_GetCurrentUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/GetCurrentUser", runtime.WithHTTPPathPattern("/api/v1/auth/me"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_AuthService_GetCurrentUser_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AuthService_GetCurrentUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AuthService_SignIn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/SignIn", runtime.WithHTTPPathPattern("/api/v1/auth/signin"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.AuthService/SignIn", runtime.WithHTTPPathPattern("/api/auth/signin"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -291,28 +274,11 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
|
||||
}
|
||||
forward_AuthService_SignIn_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AuthService_SignOut_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/SignOut", runtime.WithHTTPPathPattern("/api/v1/auth/signout"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_AuthService_SignOut_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AuthService_SignOut_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AuthService_RefreshToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/api/v1/auth/refresh"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/api/auth/refresh"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -325,19 +291,53 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
|
||||
}
|
||||
forward_AuthService_RefreshToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_AuthService_GetCurrentUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.AuthService/GetCurrentUser", runtime.WithHTTPPathPattern("/api/auth/me"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_AuthService_GetCurrentUser_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AuthService_GetCurrentUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AuthService_SignOut_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.AuthService/SignOut", runtime.WithHTTPPathPattern("/api/auth/signout"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_AuthService_SignOut_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AuthService_SignOut_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_AuthService_GetCurrentUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "me"}, ""))
|
||||
pattern_AuthService_SignIn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "signin"}, ""))
|
||||
pattern_AuthService_SignOut_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "signout"}, ""))
|
||||
pattern_AuthService_RefreshToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "refresh"}, ""))
|
||||
pattern_AuthService_SignIn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "auth", "signin"}, ""))
|
||||
pattern_AuthService_RefreshToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "auth", "refresh"}, ""))
|
||||
pattern_AuthService_GetCurrentUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "auth", "me"}, ""))
|
||||
pattern_AuthService_SignOut_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "auth", "signout"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_AuthService_GetCurrentUser_0 = runtime.ForwardResponseMessage
|
||||
forward_AuthService_SignIn_0 = runtime.ForwardResponseMessage
|
||||
forward_AuthService_SignOut_0 = runtime.ForwardResponseMessage
|
||||
forward_AuthService_RefreshToken_0 = runtime.ForwardResponseMessage
|
||||
forward_AuthService_GetCurrentUser_0 = runtime.ForwardResponseMessage
|
||||
forward_AuthService_SignOut_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
+110
-104
@@ -2,9 +2,9 @@
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc (unknown)
|
||||
// source: api/v1/auth_service.proto
|
||||
// source: api/auth_service.proto
|
||||
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
context "context"
|
||||
@@ -20,31 +20,34 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
AuthService_GetCurrentUser_FullMethodName = "/memos.api.v1.AuthService/GetCurrentUser"
|
||||
AuthService_SignIn_FullMethodName = "/memos.api.v1.AuthService/SignIn"
|
||||
AuthService_SignOut_FullMethodName = "/memos.api.v1.AuthService/SignOut"
|
||||
AuthService_RefreshToken_FullMethodName = "/memos.api.v1.AuthService/RefreshToken"
|
||||
AuthService_SignIn_FullMethodName = "/memos.api.AuthService/SignIn"
|
||||
AuthService_RefreshToken_FullMethodName = "/memos.api.AuthService/RefreshToken"
|
||||
AuthService_GetCurrentUser_FullMethodName = "/memos.api.AuthService/GetCurrentUser"
|
||||
AuthService_SignOut_FullMethodName = "/memos.api.AuthService/SignOut"
|
||||
)
|
||||
|
||||
// AuthServiceClient is the client API for AuthService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
//
|
||||
// AuthService manages sign-in sessions: it issues, refreshes, and revokes the tokens that authenticate API calls.
|
||||
type AuthServiceClient interface {
|
||||
// GetCurrentUser returns the authenticated user's information.
|
||||
// Validates the access token and returns user details.
|
||||
// Similar to OIDC's /userinfo endpoint.
|
||||
GetCurrentUser(ctx context.Context, in *GetCurrentUserRequest, opts ...grpc.CallOption) (*GetCurrentUserResponse, error)
|
||||
// SignIn authenticates a user with credentials and returns tokens.
|
||||
// On success, returns an access token and sets a refresh token cookie.
|
||||
// Supports password-based and SSO authentication methods.
|
||||
// SignIn authenticates a user with password or SSO credentials.
|
||||
// On success, returns a short-lived access token and sets a refresh token in an HttpOnly cookie.
|
||||
// Public. Attempts are rate limited. Archived users cannot sign in.
|
||||
SignIn(ctx context.Context, in *SignInRequest, opts ...grpc.CallOption) (*SignInResponse, error)
|
||||
// SignOut terminates the user's authentication.
|
||||
// Revokes the refresh token and clears the authentication cookie.
|
||||
SignOut(ctx context.Context, in *SignOutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// RefreshToken exchanges a valid refresh token for a new access token.
|
||||
// The refresh token is read from the HttpOnly cookie.
|
||||
// Returns a new short-lived access token.
|
||||
// RefreshToken exchanges the refresh token for a new access token.
|
||||
// The refresh token is read from the HttpOnly cookie and rotated: the old token is revoked and a new one with a
|
||||
// fresh 30-day expiry is set in the cookie.
|
||||
// Public, so it can be called after the access token has expired.
|
||||
RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error)
|
||||
// GetCurrentUser returns the authenticated user, similar to OIDC's /userinfo endpoint.
|
||||
// When the caller is not signed in or the account is no longer active, clears the refresh token cookie and returns
|
||||
// UNAUTHENTICATED.
|
||||
GetCurrentUser(ctx context.Context, in *GetCurrentUserRequest, opts ...grpc.CallOption) (*GetCurrentUserResponse, error)
|
||||
// SignOut ends the current session.
|
||||
// Revokes the refresh token from the cookie and clears the cookie.
|
||||
SignOut(ctx context.Context, in *SignOutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
}
|
||||
|
||||
type authServiceClient struct {
|
||||
@@ -55,16 +58,6 @@ func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient {
|
||||
return &authServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *authServiceClient) GetCurrentUser(ctx context.Context, in *GetCurrentUserRequest, opts ...grpc.CallOption) (*GetCurrentUserResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetCurrentUserResponse)
|
||||
err := c.cc.Invoke(ctx, AuthService_GetCurrentUser_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authServiceClient) SignIn(ctx context.Context, in *SignInRequest, opts ...grpc.CallOption) (*SignInResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SignInResponse)
|
||||
@@ -75,16 +68,6 @@ func (c *authServiceClient) SignIn(ctx context.Context, in *SignInRequest, opts
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authServiceClient) SignOut(ctx context.Context, in *SignOutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, AuthService_SignOut_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authServiceClient) RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RefreshTokenResponse)
|
||||
@@ -95,25 +78,48 @@ func (c *authServiceClient) RefreshToken(ctx context.Context, in *RefreshTokenRe
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authServiceClient) GetCurrentUser(ctx context.Context, in *GetCurrentUserRequest, opts ...grpc.CallOption) (*GetCurrentUserResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetCurrentUserResponse)
|
||||
err := c.cc.Invoke(ctx, AuthService_GetCurrentUser_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authServiceClient) SignOut(ctx context.Context, in *SignOutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, AuthService_SignOut_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AuthServiceServer is the server API for AuthService service.
|
||||
// All implementations must embed UnimplementedAuthServiceServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// AuthService manages sign-in sessions: it issues, refreshes, and revokes the tokens that authenticate API calls.
|
||||
type AuthServiceServer interface {
|
||||
// GetCurrentUser returns the authenticated user's information.
|
||||
// Validates the access token and returns user details.
|
||||
// Similar to OIDC's /userinfo endpoint.
|
||||
GetCurrentUser(context.Context, *GetCurrentUserRequest) (*GetCurrentUserResponse, error)
|
||||
// SignIn authenticates a user with credentials and returns tokens.
|
||||
// On success, returns an access token and sets a refresh token cookie.
|
||||
// Supports password-based and SSO authentication methods.
|
||||
// SignIn authenticates a user with password or SSO credentials.
|
||||
// On success, returns a short-lived access token and sets a refresh token in an HttpOnly cookie.
|
||||
// Public. Attempts are rate limited. Archived users cannot sign in.
|
||||
SignIn(context.Context, *SignInRequest) (*SignInResponse, error)
|
||||
// SignOut terminates the user's authentication.
|
||||
// Revokes the refresh token and clears the authentication cookie.
|
||||
SignOut(context.Context, *SignOutRequest) (*emptypb.Empty, error)
|
||||
// RefreshToken exchanges a valid refresh token for a new access token.
|
||||
// The refresh token is read from the HttpOnly cookie.
|
||||
// Returns a new short-lived access token.
|
||||
// RefreshToken exchanges the refresh token for a new access token.
|
||||
// The refresh token is read from the HttpOnly cookie and rotated: the old token is revoked and a new one with a
|
||||
// fresh 30-day expiry is set in the cookie.
|
||||
// Public, so it can be called after the access token has expired.
|
||||
RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error)
|
||||
// GetCurrentUser returns the authenticated user, similar to OIDC's /userinfo endpoint.
|
||||
// When the caller is not signed in or the account is no longer active, clears the refresh token cookie and returns
|
||||
// UNAUTHENTICATED.
|
||||
GetCurrentUser(context.Context, *GetCurrentUserRequest) (*GetCurrentUserResponse, error)
|
||||
// SignOut ends the current session.
|
||||
// Revokes the refresh token from the cookie and clears the cookie.
|
||||
SignOut(context.Context, *SignOutRequest) (*emptypb.Empty, error)
|
||||
mustEmbedUnimplementedAuthServiceServer()
|
||||
}
|
||||
|
||||
@@ -124,18 +130,18 @@ type AuthServiceServer interface {
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedAuthServiceServer struct{}
|
||||
|
||||
func (UnimplementedAuthServiceServer) GetCurrentUser(context.Context, *GetCurrentUserRequest) (*GetCurrentUserResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetCurrentUser not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) SignIn(context.Context, *SignInRequest) (*SignInResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method SignIn not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) SignOut(context.Context, *SignOutRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method SignOut not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method RefreshToken not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) GetCurrentUser(context.Context, *GetCurrentUserRequest) (*GetCurrentUserResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetCurrentUser not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) SignOut(context.Context, *SignOutRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method SignOut not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {}
|
||||
func (UnimplementedAuthServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
@@ -157,24 +163,6 @@ func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) {
|
||||
s.RegisterService(&AuthService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _AuthService_GetCurrentUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetCurrentUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServiceServer).GetCurrentUser(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AuthService_GetCurrentUser_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServiceServer).GetCurrentUser(ctx, req.(*GetCurrentUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AuthService_SignIn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SignInRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -193,24 +181,6 @@ func _AuthService_SignIn_Handler(srv interface{}, ctx context.Context, dec func(
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AuthService_SignOut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SignOutRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServiceServer).SignOut(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AuthService_SignOut_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServiceServer).SignOut(ctx, req.(*SignOutRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AuthService_RefreshToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RefreshTokenRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -229,30 +199,66 @@ func _AuthService_RefreshToken_Handler(srv interface{}, ctx context.Context, dec
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AuthService_GetCurrentUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetCurrentUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServiceServer).GetCurrentUser(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AuthService_GetCurrentUser_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServiceServer).GetCurrentUser(ctx, req.(*GetCurrentUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AuthService_SignOut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SignOutRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServiceServer).SignOut(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AuthService_SignOut_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServiceServer).SignOut(ctx, req.(*SignOutRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var AuthService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "memos.api.v1.AuthService",
|
||||
ServiceName: "memos.api.AuthService",
|
||||
HandlerType: (*AuthServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetCurrentUser",
|
||||
Handler: _AuthService_GetCurrentUser_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SignIn",
|
||||
Handler: _AuthService_SignIn_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SignOut",
|
||||
Handler: _AuthService_SignOut_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "RefreshToken",
|
||||
Handler: _AuthService_RefreshToken_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetCurrentUser",
|
||||
Handler: _AuthService_GetCurrentUser_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SignOut",
|
||||
Handler: _AuthService_SignOut_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v1/auth_service.proto",
|
||||
Metadata: "api/auth_service.proto",
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.12
|
||||
// protoc (unknown)
|
||||
// source: api/v1/common.proto
|
||||
// source: api/common.proto
|
||||
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
@@ -21,12 +21,15 @@ const (
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// State is the lifecycle state of a resource.
|
||||
type State int32
|
||||
|
||||
const (
|
||||
State_STATE_UNSPECIFIED State = 0
|
||||
State_NORMAL State = 1
|
||||
State_ARCHIVED State = 2
|
||||
// The resource is active.
|
||||
State_NORMAL State = 1
|
||||
// The resource is archived.
|
||||
State_ARCHIVED State = 2
|
||||
)
|
||||
|
||||
// Enum value maps for State.
|
||||
@@ -54,11 +57,11 @@ func (x State) String() string {
|
||||
}
|
||||
|
||||
func (State) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_api_v1_common_proto_enumTypes[0].Descriptor()
|
||||
return file_api_common_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (State) Type() protoreflect.EnumType {
|
||||
return &file_api_v1_common_proto_enumTypes[0]
|
||||
return &file_api_common_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x State) Number() protoreflect.EnumNumber {
|
||||
@@ -67,15 +70,18 @@ func (x State) Number() protoreflect.EnumNumber {
|
||||
|
||||
// Deprecated: Use State.Descriptor instead.
|
||||
func (State) EnumDescriptor() ([]byte, []int) {
|
||||
return file_api_v1_common_proto_rawDescGZIP(), []int{0}
|
||||
return file_api_common_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
// Direction is a sort direction.
|
||||
type Direction int32
|
||||
|
||||
const (
|
||||
Direction_DIRECTION_UNSPECIFIED Direction = 0
|
||||
Direction_ASC Direction = 1
|
||||
Direction_DESC Direction = 2
|
||||
// Ascending order.
|
||||
Direction_ASC Direction = 1
|
||||
// Descending order.
|
||||
Direction_DESC Direction = 2
|
||||
)
|
||||
|
||||
// Enum value maps for Direction.
|
||||
@@ -103,11 +109,11 @@ func (x Direction) String() string {
|
||||
}
|
||||
|
||||
func (Direction) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_api_v1_common_proto_enumTypes[1].Descriptor()
|
||||
return file_api_common_proto_enumTypes[1].Descriptor()
|
||||
}
|
||||
|
||||
func (Direction) Type() protoreflect.EnumType {
|
||||
return &file_api_v1_common_proto_enumTypes[1]
|
||||
return &file_api_common_proto_enumTypes[1]
|
||||
}
|
||||
|
||||
func (x Direction) Number() protoreflect.EnumNumber {
|
||||
@@ -116,21 +122,24 @@ func (x Direction) Number() protoreflect.EnumNumber {
|
||||
|
||||
// Deprecated: Use Direction.Descriptor instead.
|
||||
func (Direction) EnumDescriptor() ([]byte, []int) {
|
||||
return file_api_v1_common_proto_rawDescGZIP(), []int{1}
|
||||
return file_api_common_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
// Used internally for obfuscating the page token.
|
||||
// PageToken is the internal content of an opaque page token. The service
|
||||
// serializes it and encodes it as base64; clients must not parse it.
|
||||
type PageToken struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Limit int32 `protobuf:"varint,1,opt,name=limit,proto3" json:"limit,omitempty"`
|
||||
Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"`
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The page size used for the next page.
|
||||
Limit int32 `protobuf:"varint,1,opt,name=limit,proto3" json:"limit,omitempty"`
|
||||
// The number of items to skip before the next page.
|
||||
Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *PageToken) Reset() {
|
||||
*x = PageToken{}
|
||||
mi := &file_api_v1_common_proto_msgTypes[0]
|
||||
mi := &file_api_common_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -142,7 +151,7 @@ func (x *PageToken) String() string {
|
||||
func (*PageToken) ProtoMessage() {}
|
||||
|
||||
func (x *PageToken) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_common_proto_msgTypes[0]
|
||||
mi := &file_api_common_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -155,7 +164,7 @@ func (x *PageToken) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use PageToken.ProtoReflect.Descriptor instead.
|
||||
func (*PageToken) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_common_proto_rawDescGZIP(), []int{0}
|
||||
return file_api_common_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *PageToken) GetLimit() int32 {
|
||||
@@ -172,11 +181,11 @@ func (x *PageToken) GetOffset() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_api_v1_common_proto protoreflect.FileDescriptor
|
||||
var File_api_common_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_api_v1_common_proto_rawDesc = "" +
|
||||
const file_api_common_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x13api/v1/common.proto\x12\fmemos.api.v1\"9\n" +
|
||||
"\x10api/common.proto\x12\tmemos.api\"9\n" +
|
||||
"\tPageToken\x12\x14\n" +
|
||||
"\x05limit\x18\x01 \x01(\x05R\x05limit\x12\x16\n" +
|
||||
"\x06offset\x18\x02 \x01(\x05R\x06offset*8\n" +
|
||||
@@ -188,29 +197,30 @@ const file_api_v1_common_proto_rawDesc = "" +
|
||||
"\tDirection\x12\x19\n" +
|
||||
"\x15DIRECTION_UNSPECIFIED\x10\x00\x12\a\n" +
|
||||
"\x03ASC\x10\x01\x12\b\n" +
|
||||
"\x04DESC\x10\x02B\xa3\x01\n" +
|
||||
"\x10com.memos.api.v1B\vCommonProtoP\x01Z0github.com/usememos/memos/proto/gen/api/v1;apiv1\xa2\x02\x03MAX\xaa\x02\fMemos.Api.V1\xca\x02\fMemos\\Api\\V1\xe2\x02\x18Memos\\Api\\V1\\GPBMetadata\xea\x02\x0eMemos::Api::V1b\x06proto3"
|
||||
"\x04DESC\x10\x02B\x8a\x01\n" +
|
||||
"\rcom.memos.apiB\vCommonProtoP\x01Z'github.com/usememos/memos/proto/gen/api\xa2\x02\x03MAX\xaa\x02\tMemos.Api\xca\x02\tMemos\\Api\xe2\x02\x15Memos\\Api\\GPBMetadata\xea\x02\n" +
|
||||
"Memos::Apib\x06proto3"
|
||||
|
||||
var (
|
||||
file_api_v1_common_proto_rawDescOnce sync.Once
|
||||
file_api_v1_common_proto_rawDescData []byte
|
||||
file_api_common_proto_rawDescOnce sync.Once
|
||||
file_api_common_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_api_v1_common_proto_rawDescGZIP() []byte {
|
||||
file_api_v1_common_proto_rawDescOnce.Do(func() {
|
||||
file_api_v1_common_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_v1_common_proto_rawDesc), len(file_api_v1_common_proto_rawDesc)))
|
||||
func file_api_common_proto_rawDescGZIP() []byte {
|
||||
file_api_common_proto_rawDescOnce.Do(func() {
|
||||
file_api_common_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_common_proto_rawDesc), len(file_api_common_proto_rawDesc)))
|
||||
})
|
||||
return file_api_v1_common_proto_rawDescData
|
||||
return file_api_common_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_api_v1_common_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_api_v1_common_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_api_v1_common_proto_goTypes = []any{
|
||||
(State)(0), // 0: memos.api.v1.State
|
||||
(Direction)(0), // 1: memos.api.v1.Direction
|
||||
(*PageToken)(nil), // 2: memos.api.v1.PageToken
|
||||
var file_api_common_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_api_common_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_api_common_proto_goTypes = []any{
|
||||
(State)(0), // 0: memos.api.State
|
||||
(Direction)(0), // 1: memos.api.Direction
|
||||
(*PageToken)(nil), // 2: memos.api.PageToken
|
||||
}
|
||||
var file_api_v1_common_proto_depIdxs = []int32{
|
||||
var file_api_common_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
@@ -218,27 +228,27 @@ var file_api_v1_common_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_v1_common_proto_init() }
|
||||
func file_api_v1_common_proto_init() {
|
||||
if File_api_v1_common_proto != nil {
|
||||
func init() { file_api_common_proto_init() }
|
||||
func file_api_common_proto_init() {
|
||||
if File_api_common_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_v1_common_proto_rawDesc), len(file_api_v1_common_proto_rawDesc)),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_common_proto_rawDesc), len(file_api_common_proto_rawDesc)),
|
||||
NumEnums: 2,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_api_v1_common_proto_goTypes,
|
||||
DependencyIndexes: file_api_v1_common_proto_depIdxs,
|
||||
EnumInfos: file_api_v1_common_proto_enumTypes,
|
||||
MessageInfos: file_api_v1_common_proto_msgTypes,
|
||||
GoTypes: file_api_common_proto_goTypes,
|
||||
DependencyIndexes: file_api_common_proto_depIdxs,
|
||||
EnumInfos: file_api_common_proto_enumTypes,
|
||||
MessageInfos: file_api_common_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_v1_common_proto = out.File
|
||||
file_api_v1_common_proto_goTypes = nil
|
||||
file_api_v1_common_proto_depIdxs = nil
|
||||
File_api_common_proto = out.File
|
||||
file_api_common_proto_goTypes = nil
|
||||
file_api_common_proto_depIdxs = nil
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,12 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: api/v1/idp_service.proto
|
||||
// source: api/idp_service.proto
|
||||
|
||||
/*
|
||||
Package apiv1 is a reverse proxy.
|
||||
Package api is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -268,7 +268,7 @@ func RegisterIdentityProviderServiceHandlerServer(ctx context.Context, mux *runt
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.IdentityProviderService/ListIdentityProviders", runtime.WithHTTPPathPattern("/api/v1/identity-providers"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.IdentityProviderService/ListIdentityProviders", runtime.WithHTTPPathPattern("/api/identity-providers"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -288,7 +288,7 @@ func RegisterIdentityProviderServiceHandlerServer(ctx context.Context, mux *runt
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.IdentityProviderService/GetIdentityProvider", runtime.WithHTTPPathPattern("/api/v1/{name=identity-providers/*}"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.IdentityProviderService/GetIdentityProvider", runtime.WithHTTPPathPattern("/api/{name=identity-providers/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -308,7 +308,7 @@ func RegisterIdentityProviderServiceHandlerServer(ctx context.Context, mux *runt
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.IdentityProviderService/CreateIdentityProvider", runtime.WithHTTPPathPattern("/api/v1/identity-providers"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.IdentityProviderService/CreateIdentityProvider", runtime.WithHTTPPathPattern("/api/identity-providers"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -328,7 +328,7 @@ func RegisterIdentityProviderServiceHandlerServer(ctx context.Context, mux *runt
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.IdentityProviderService/UpdateIdentityProvider", runtime.WithHTTPPathPattern("/api/v1/{identity_provider.name=identity-providers/*}"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.IdentityProviderService/UpdateIdentityProvider", runtime.WithHTTPPathPattern("/api/{identity_provider.name=identity-providers/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -348,7 +348,7 @@ func RegisterIdentityProviderServiceHandlerServer(ctx context.Context, mux *runt
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.IdentityProviderService/DeleteIdentityProvider", runtime.WithHTTPPathPattern("/api/v1/{name=identity-providers/*}"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.IdentityProviderService/DeleteIdentityProvider", runtime.WithHTTPPathPattern("/api/{name=identity-providers/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -406,7 +406,7 @@ func RegisterIdentityProviderServiceHandlerClient(ctx context.Context, mux *runt
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.IdentityProviderService/ListIdentityProviders", runtime.WithHTTPPathPattern("/api/v1/identity-providers"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.IdentityProviderService/ListIdentityProviders", runtime.WithHTTPPathPattern("/api/identity-providers"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -423,7 +423,7 @@ func RegisterIdentityProviderServiceHandlerClient(ctx context.Context, mux *runt
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.IdentityProviderService/GetIdentityProvider", runtime.WithHTTPPathPattern("/api/v1/{name=identity-providers/*}"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.IdentityProviderService/GetIdentityProvider", runtime.WithHTTPPathPattern("/api/{name=identity-providers/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -440,7 +440,7 @@ func RegisterIdentityProviderServiceHandlerClient(ctx context.Context, mux *runt
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.IdentityProviderService/CreateIdentityProvider", runtime.WithHTTPPathPattern("/api/v1/identity-providers"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.IdentityProviderService/CreateIdentityProvider", runtime.WithHTTPPathPattern("/api/identity-providers"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -457,7 +457,7 @@ func RegisterIdentityProviderServiceHandlerClient(ctx context.Context, mux *runt
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.IdentityProviderService/UpdateIdentityProvider", runtime.WithHTTPPathPattern("/api/v1/{identity_provider.name=identity-providers/*}"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.IdentityProviderService/UpdateIdentityProvider", runtime.WithHTTPPathPattern("/api/{identity_provider.name=identity-providers/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -474,7 +474,7 @@ func RegisterIdentityProviderServiceHandlerClient(ctx context.Context, mux *runt
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.IdentityProviderService/DeleteIdentityProvider", runtime.WithHTTPPathPattern("/api/v1/{name=identity-providers/*}"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.IdentityProviderService/DeleteIdentityProvider", runtime.WithHTTPPathPattern("/api/{name=identity-providers/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -491,11 +491,11 @@ func RegisterIdentityProviderServiceHandlerClient(ctx context.Context, mux *runt
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_IdentityProviderService_ListIdentityProviders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "identity-providers"}, ""))
|
||||
pattern_IdentityProviderService_GetIdentityProvider_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v1", "identity-providers", "name"}, ""))
|
||||
pattern_IdentityProviderService_CreateIdentityProvider_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "identity-providers"}, ""))
|
||||
pattern_IdentityProviderService_UpdateIdentityProvider_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v1", "identity-providers", "identity_provider.name"}, ""))
|
||||
pattern_IdentityProviderService_DeleteIdentityProvider_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v1", "identity-providers", "name"}, ""))
|
||||
pattern_IdentityProviderService_ListIdentityProviders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "identity-providers"}, ""))
|
||||
pattern_IdentityProviderService_GetIdentityProvider_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"api", "identity-providers", "name"}, ""))
|
||||
pattern_IdentityProviderService_CreateIdentityProvider_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "identity-providers"}, ""))
|
||||
pattern_IdentityProviderService_UpdateIdentityProvider_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"api", "identity-providers", "identity_provider.name"}, ""))
|
||||
pattern_IdentityProviderService_DeleteIdentityProvider_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"api", "identity-providers", "name"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -2,9 +2,9 @@
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc (unknown)
|
||||
// source: api/v1/idp_service.proto
|
||||
// source: api/idp_service.proto
|
||||
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
context "context"
|
||||
@@ -20,26 +20,35 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
IdentityProviderService_ListIdentityProviders_FullMethodName = "/memos.api.v1.IdentityProviderService/ListIdentityProviders"
|
||||
IdentityProviderService_GetIdentityProvider_FullMethodName = "/memos.api.v1.IdentityProviderService/GetIdentityProvider"
|
||||
IdentityProviderService_CreateIdentityProvider_FullMethodName = "/memos.api.v1.IdentityProviderService/CreateIdentityProvider"
|
||||
IdentityProviderService_UpdateIdentityProvider_FullMethodName = "/memos.api.v1.IdentityProviderService/UpdateIdentityProvider"
|
||||
IdentityProviderService_DeleteIdentityProvider_FullMethodName = "/memos.api.v1.IdentityProviderService/DeleteIdentityProvider"
|
||||
IdentityProviderService_ListIdentityProviders_FullMethodName = "/memos.api.IdentityProviderService/ListIdentityProviders"
|
||||
IdentityProviderService_GetIdentityProvider_FullMethodName = "/memos.api.IdentityProviderService/GetIdentityProvider"
|
||||
IdentityProviderService_CreateIdentityProvider_FullMethodName = "/memos.api.IdentityProviderService/CreateIdentityProvider"
|
||||
IdentityProviderService_UpdateIdentityProvider_FullMethodName = "/memos.api.IdentityProviderService/UpdateIdentityProvider"
|
||||
IdentityProviderService_DeleteIdentityProvider_FullMethodName = "/memos.api.IdentityProviderService/DeleteIdentityProvider"
|
||||
)
|
||||
|
||||
// IdentityProviderServiceClient is the client API for IdentityProviderService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
//
|
||||
// IdentityProviderService manages the external identity providers users can sign in with.
|
||||
type IdentityProviderServiceClient interface {
|
||||
// ListIdentityProviders lists identity providers.
|
||||
// Public, so the sign-in page can show SSO options. Client secrets are never returned.
|
||||
ListIdentityProviders(ctx context.Context, in *ListIdentityProvidersRequest, opts ...grpc.CallOption) (*ListIdentityProvidersResponse, error)
|
||||
// GetIdentityProvider gets an identity provider.
|
||||
// The client secret is never returned.
|
||||
GetIdentityProvider(ctx context.Context, in *GetIdentityProviderRequest, opts ...grpc.CallOption) (*IdentityProvider, error)
|
||||
// CreateIdentityProvider creates an identity provider.
|
||||
// Requires the admin role. Fails with FAILED_PRECONDITION when the ID belongs to a provider configured by the
|
||||
// deployment.
|
||||
CreateIdentityProvider(ctx context.Context, in *CreateIdentityProviderRequest, opts ...grpc.CallOption) (*IdentityProvider, error)
|
||||
// UpdateIdentityProvider updates an identity provider.
|
||||
// Requires the admin role. Providers configured by the deployment cannot be updated.
|
||||
UpdateIdentityProvider(ctx context.Context, in *UpdateIdentityProviderRequest, opts ...grpc.CallOption) (*IdentityProvider, error)
|
||||
// DeleteIdentityProvider deletes an identity provider.
|
||||
// Requires the admin role. Providers configured by the deployment cannot be deleted. Fails with
|
||||
// FAILED_PRECONDITION when password sign-in is disabled for regular users and no other effective provider remains.
|
||||
DeleteIdentityProvider(ctx context.Context, in *DeleteIdentityProviderRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
}
|
||||
|
||||
@@ -104,16 +113,25 @@ func (c *identityProviderServiceClient) DeleteIdentityProvider(ctx context.Conte
|
||||
// IdentityProviderServiceServer is the server API for IdentityProviderService service.
|
||||
// All implementations must embed UnimplementedIdentityProviderServiceServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// IdentityProviderService manages the external identity providers users can sign in with.
|
||||
type IdentityProviderServiceServer interface {
|
||||
// ListIdentityProviders lists identity providers.
|
||||
// Public, so the sign-in page can show SSO options. Client secrets are never returned.
|
||||
ListIdentityProviders(context.Context, *ListIdentityProvidersRequest) (*ListIdentityProvidersResponse, error)
|
||||
// GetIdentityProvider gets an identity provider.
|
||||
// The client secret is never returned.
|
||||
GetIdentityProvider(context.Context, *GetIdentityProviderRequest) (*IdentityProvider, error)
|
||||
// CreateIdentityProvider creates an identity provider.
|
||||
// Requires the admin role. Fails with FAILED_PRECONDITION when the ID belongs to a provider configured by the
|
||||
// deployment.
|
||||
CreateIdentityProvider(context.Context, *CreateIdentityProviderRequest) (*IdentityProvider, error)
|
||||
// UpdateIdentityProvider updates an identity provider.
|
||||
// Requires the admin role. Providers configured by the deployment cannot be updated.
|
||||
UpdateIdentityProvider(context.Context, *UpdateIdentityProviderRequest) (*IdentityProvider, error)
|
||||
// DeleteIdentityProvider deletes an identity provider.
|
||||
// Requires the admin role. Providers configured by the deployment cannot be deleted. Fails with
|
||||
// FAILED_PRECONDITION when password sign-in is disabled for regular users and no other effective provider remains.
|
||||
DeleteIdentityProvider(context.Context, *DeleteIdentityProviderRequest) (*emptypb.Empty, error)
|
||||
mustEmbedUnimplementedIdentityProviderServiceServer()
|
||||
}
|
||||
@@ -256,7 +274,7 @@ func _IdentityProviderService_DeleteIdentityProvider_Handler(srv interface{}, ct
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var IdentityProviderService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "memos.api.v1.IdentityProviderService",
|
||||
ServiceName: "memos.api.IdentityProviderService",
|
||||
HandlerType: (*IdentityProviderServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
@@ -281,5 +299,5 @@ var IdentityProviderService_ServiceDesc = grpc.ServiceDesc{
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v1/idp_service.proto",
|
||||
Metadata: "api/idp_service.proto",
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+34
-34
@@ -1,12 +1,12 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: api/v1/instance_service.proto
|
||||
// source: api/instance_service.proto
|
||||
|
||||
/*
|
||||
Package apiv1 is a reverse proxy.
|
||||
Package api is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -122,7 +122,7 @@ func local_request_InstanceService_BatchGetInstanceSettings_0(ctx context.Contex
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
var filter_InstanceService_UpdateInstanceSetting_0 = &utilities.DoubleArray{Encoding: map[string]int{"setting": 0, "name": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}}
|
||||
var filter_InstanceService_UpdateInstanceSetting_0 = &utilities.DoubleArray{Encoding: map[string]int{"instance_setting": 0, "name": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}}
|
||||
|
||||
func request_InstanceService_UpdateInstanceSetting_0(ctx context.Context, marshaler runtime.Marshaler, client InstanceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
@@ -134,23 +134,23 @@ func request_InstanceService_UpdateInstanceSetting_0(ctx context.Context, marsha
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Setting); err != nil && !errors.Is(err, io.EOF) {
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.InstanceSetting); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
|
||||
if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Setting); err != nil {
|
||||
if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.InstanceSetting); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
} else {
|
||||
protoReq.UpdateMask = fieldMask
|
||||
}
|
||||
}
|
||||
val, ok := pathParams["setting.name"]
|
||||
val, ok := pathParams["instance_setting.name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "setting.name")
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "instance_setting.name")
|
||||
}
|
||||
err = runtime.PopulateFieldFromPath(&protoReq, "setting.name", val)
|
||||
err = runtime.PopulateFieldFromPath(&protoReq, "instance_setting.name", val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "setting.name", err)
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "instance_setting.name", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
@@ -175,23 +175,23 @@ func local_request_InstanceService_UpdateInstanceSetting_0(ctx context.Context,
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Setting); err != nil && !errors.Is(err, io.EOF) {
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.InstanceSetting); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
|
||||
if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Setting); err != nil {
|
||||
if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.InstanceSetting); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
} else {
|
||||
protoReq.UpdateMask = fieldMask
|
||||
}
|
||||
}
|
||||
val, ok := pathParams["setting.name"]
|
||||
val, ok := pathParams["instance_setting.name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "setting.name")
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "instance_setting.name")
|
||||
}
|
||||
err = runtime.PopulateFieldFromPath(&protoReq, "setting.name", val)
|
||||
err = runtime.PopulateFieldFromPath(&protoReq, "instance_setting.name", val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "setting.name", err)
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "instance_setting.name", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
@@ -263,7 +263,7 @@ func RegisterInstanceServiceHandlerServer(ctx context.Context, mux *runtime.Serv
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.InstanceService/GetInstanceProfile", runtime.WithHTTPPathPattern("/api/v1/instance/profile"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.InstanceService/GetInstanceProfile", runtime.WithHTTPPathPattern("/api/instance/profile"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -283,7 +283,7 @@ func RegisterInstanceServiceHandlerServer(ctx context.Context, mux *runtime.Serv
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.InstanceService/GetInstanceSetting", runtime.WithHTTPPathPattern("/api/v1/{name=instance/settings/*}"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.InstanceService/GetInstanceSetting", runtime.WithHTTPPathPattern("/api/{name=instance/settings/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -303,7 +303,7 @@ func RegisterInstanceServiceHandlerServer(ctx context.Context, mux *runtime.Serv
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.InstanceService/BatchGetInstanceSettings", runtime.WithHTTPPathPattern("/api/v1/instance/settings:batchGet"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.InstanceService/BatchGetInstanceSettings", runtime.WithHTTPPathPattern("/api/instance/settings:batchGet"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -323,7 +323,7 @@ func RegisterInstanceServiceHandlerServer(ctx context.Context, mux *runtime.Serv
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.InstanceService/UpdateInstanceSetting", runtime.WithHTTPPathPattern("/api/v1/{setting.name=instance/settings/*}"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.InstanceService/UpdateInstanceSetting", runtime.WithHTTPPathPattern("/api/{instance_setting.name=instance/settings/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -343,7 +343,7 @@ func RegisterInstanceServiceHandlerServer(ctx context.Context, mux *runtime.Serv
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.InstanceService/TestInstanceEmailSetting", runtime.WithHTTPPathPattern("/api/v1/instance/settings/notification:testEmail"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.InstanceService/TestInstanceEmailSetting", runtime.WithHTTPPathPattern("/api/instance/settings/notification:testEmail"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -363,7 +363,7 @@ func RegisterInstanceServiceHandlerServer(ctx context.Context, mux *runtime.Serv
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.InstanceService/GetInstanceStats", runtime.WithHTTPPathPattern("/api/v1/instance/stats"))
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.InstanceService/GetInstanceStats", runtime.WithHTTPPathPattern("/api/instance/stats"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -421,7 +421,7 @@ func RegisterInstanceServiceHandlerClient(ctx context.Context, mux *runtime.Serv
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.InstanceService/GetInstanceProfile", runtime.WithHTTPPathPattern("/api/v1/instance/profile"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.InstanceService/GetInstanceProfile", runtime.WithHTTPPathPattern("/api/instance/profile"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -438,7 +438,7 @@ func RegisterInstanceServiceHandlerClient(ctx context.Context, mux *runtime.Serv
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.InstanceService/GetInstanceSetting", runtime.WithHTTPPathPattern("/api/v1/{name=instance/settings/*}"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.InstanceService/GetInstanceSetting", runtime.WithHTTPPathPattern("/api/{name=instance/settings/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -455,7 +455,7 @@ func RegisterInstanceServiceHandlerClient(ctx context.Context, mux *runtime.Serv
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.InstanceService/BatchGetInstanceSettings", runtime.WithHTTPPathPattern("/api/v1/instance/settings:batchGet"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.InstanceService/BatchGetInstanceSettings", runtime.WithHTTPPathPattern("/api/instance/settings:batchGet"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -472,7 +472,7 @@ func RegisterInstanceServiceHandlerClient(ctx context.Context, mux *runtime.Serv
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.InstanceService/UpdateInstanceSetting", runtime.WithHTTPPathPattern("/api/v1/{setting.name=instance/settings/*}"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.InstanceService/UpdateInstanceSetting", runtime.WithHTTPPathPattern("/api/{instance_setting.name=instance/settings/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -489,7 +489,7 @@ func RegisterInstanceServiceHandlerClient(ctx context.Context, mux *runtime.Serv
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.InstanceService/TestInstanceEmailSetting", runtime.WithHTTPPathPattern("/api/v1/instance/settings/notification:testEmail"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.InstanceService/TestInstanceEmailSetting", runtime.WithHTTPPathPattern("/api/instance/settings/notification:testEmail"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -506,7 +506,7 @@ func RegisterInstanceServiceHandlerClient(ctx context.Context, mux *runtime.Serv
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.InstanceService/GetInstanceStats", runtime.WithHTTPPathPattern("/api/v1/instance/stats"))
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.InstanceService/GetInstanceStats", runtime.WithHTTPPathPattern("/api/instance/stats"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
@@ -523,12 +523,12 @@ func RegisterInstanceServiceHandlerClient(ctx context.Context, mux *runtime.Serv
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_InstanceService_GetInstanceProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "instance", "profile"}, ""))
|
||||
pattern_InstanceService_GetInstanceSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 3, 5, 4}, []string{"api", "v1", "instance", "settings", "name"}, ""))
|
||||
pattern_InstanceService_BatchGetInstanceSettings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "instance", "settings"}, "batchGet"))
|
||||
pattern_InstanceService_UpdateInstanceSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 3, 5, 4}, []string{"api", "v1", "instance", "settings", "setting.name"}, ""))
|
||||
pattern_InstanceService_TestInstanceEmailSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"api", "v1", "instance", "settings", "notification"}, "testEmail"))
|
||||
pattern_InstanceService_GetInstanceStats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "instance", "stats"}, ""))
|
||||
pattern_InstanceService_GetInstanceProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "instance", "profile"}, ""))
|
||||
pattern_InstanceService_GetInstanceSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 3, 5, 3}, []string{"api", "instance", "settings", "name"}, ""))
|
||||
pattern_InstanceService_BatchGetInstanceSettings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "instance", "settings"}, "batchGet"))
|
||||
pattern_InstanceService_UpdateInstanceSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 3, 5, 3}, []string{"api", "instance", "settings", "instance_setting.name"}, ""))
|
||||
pattern_InstanceService_TestInstanceEmailSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "instance", "settings", "notification"}, "testEmail"))
|
||||
pattern_InstanceService_GetInstanceStats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "instance", "stats"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
+32
-22
@@ -2,9 +2,9 @@
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc (unknown)
|
||||
// source: api/v1/instance_service.proto
|
||||
// source: api/instance_service.proto
|
||||
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
context "context"
|
||||
@@ -20,29 +20,34 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
InstanceService_GetInstanceProfile_FullMethodName = "/memos.api.v1.InstanceService/GetInstanceProfile"
|
||||
InstanceService_GetInstanceSetting_FullMethodName = "/memos.api.v1.InstanceService/GetInstanceSetting"
|
||||
InstanceService_BatchGetInstanceSettings_FullMethodName = "/memos.api.v1.InstanceService/BatchGetInstanceSettings"
|
||||
InstanceService_UpdateInstanceSetting_FullMethodName = "/memos.api.v1.InstanceService/UpdateInstanceSetting"
|
||||
InstanceService_TestInstanceEmailSetting_FullMethodName = "/memos.api.v1.InstanceService/TestInstanceEmailSetting"
|
||||
InstanceService_GetInstanceStats_FullMethodName = "/memos.api.v1.InstanceService/GetInstanceStats"
|
||||
InstanceService_GetInstanceProfile_FullMethodName = "/memos.api.InstanceService/GetInstanceProfile"
|
||||
InstanceService_GetInstanceSetting_FullMethodName = "/memos.api.InstanceService/GetInstanceSetting"
|
||||
InstanceService_BatchGetInstanceSettings_FullMethodName = "/memos.api.InstanceService/BatchGetInstanceSettings"
|
||||
InstanceService_UpdateInstanceSetting_FullMethodName = "/memos.api.InstanceService/UpdateInstanceSetting"
|
||||
InstanceService_TestInstanceEmailSetting_FullMethodName = "/memos.api.InstanceService/TestInstanceEmailSetting"
|
||||
InstanceService_GetInstanceStats_FullMethodName = "/memos.api.InstanceService/GetInstanceStats"
|
||||
)
|
||||
|
||||
// InstanceServiceClient is the client API for InstanceService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
//
|
||||
// InstanceService exposes the instance profile, instance-wide settings and usage statistics.
|
||||
type InstanceServiceClient interface {
|
||||
// Gets the instance profile.
|
||||
// GetInstanceProfile gets the instance profile. Available without authentication, including on a private instance.
|
||||
GetInstanceProfile(ctx context.Context, in *GetInstanceProfileRequest, opts ...grpc.CallOption) (*InstanceProfile, error)
|
||||
// Gets an instance setting.
|
||||
// GetInstanceSetting gets an instance setting. Available without authentication, except STORAGE and NOTIFICATION,
|
||||
// which are admin only, and AI, which requires a signed-in user and hides transcription defaults from non-admins.
|
||||
GetInstanceSetting(ctx context.Context, in *GetInstanceSettingRequest, opts ...grpc.CallOption) (*InstanceSetting, error)
|
||||
// Batch gets instance settings.
|
||||
// BatchGetInstanceSettings gets up to 100 instance settings in request order, with the same access rules as
|
||||
// GetInstanceSetting. The call fails if any setting cannot be returned.
|
||||
BatchGetInstanceSettings(ctx context.Context, in *BatchGetInstanceSettingsRequest, opts ...grpc.CallOption) (*BatchGetInstanceSettingsResponse, error)
|
||||
// Updates an instance setting.
|
||||
// UpdateInstanceSetting replaces an instance setting. Admin only. Settings configured by the deployment cannot be
|
||||
// updated. Empty write-only credentials keep the stored values.
|
||||
UpdateInstanceSetting(ctx context.Context, in *UpdateInstanceSettingRequest, opts ...grpc.CallOption) (*InstanceSetting, error)
|
||||
// Tests notification email delivery with the provided or stored SMTP settings.
|
||||
// TestInstanceEmailSetting sends a test email with the provided or stored SMTP settings. Admin only.
|
||||
TestInstanceEmailSetting(ctx context.Context, in *TestInstanceEmailSettingRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// GetInstanceStats returns resource usage statistics for the instance. Admin only.
|
||||
// GetInstanceStats gets resource usage statistics for the instance. Admin only. Results are cached for 60 seconds.
|
||||
GetInstanceStats(ctx context.Context, in *GetInstanceStatsRequest, opts ...grpc.CallOption) (*InstanceStats, error)
|
||||
}
|
||||
|
||||
@@ -117,18 +122,23 @@ func (c *instanceServiceClient) GetInstanceStats(ctx context.Context, in *GetIns
|
||||
// InstanceServiceServer is the server API for InstanceService service.
|
||||
// All implementations must embed UnimplementedInstanceServiceServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// InstanceService exposes the instance profile, instance-wide settings and usage statistics.
|
||||
type InstanceServiceServer interface {
|
||||
// Gets the instance profile.
|
||||
// GetInstanceProfile gets the instance profile. Available without authentication, including on a private instance.
|
||||
GetInstanceProfile(context.Context, *GetInstanceProfileRequest) (*InstanceProfile, error)
|
||||
// Gets an instance setting.
|
||||
// GetInstanceSetting gets an instance setting. Available without authentication, except STORAGE and NOTIFICATION,
|
||||
// which are admin only, and AI, which requires a signed-in user and hides transcription defaults from non-admins.
|
||||
GetInstanceSetting(context.Context, *GetInstanceSettingRequest) (*InstanceSetting, error)
|
||||
// Batch gets instance settings.
|
||||
// BatchGetInstanceSettings gets up to 100 instance settings in request order, with the same access rules as
|
||||
// GetInstanceSetting. The call fails if any setting cannot be returned.
|
||||
BatchGetInstanceSettings(context.Context, *BatchGetInstanceSettingsRequest) (*BatchGetInstanceSettingsResponse, error)
|
||||
// Updates an instance setting.
|
||||
// UpdateInstanceSetting replaces an instance setting. Admin only. Settings configured by the deployment cannot be
|
||||
// updated. Empty write-only credentials keep the stored values.
|
||||
UpdateInstanceSetting(context.Context, *UpdateInstanceSettingRequest) (*InstanceSetting, error)
|
||||
// Tests notification email delivery with the provided or stored SMTP settings.
|
||||
// TestInstanceEmailSetting sends a test email with the provided or stored SMTP settings. Admin only.
|
||||
TestInstanceEmailSetting(context.Context, *TestInstanceEmailSettingRequest) (*emptypb.Empty, error)
|
||||
// GetInstanceStats returns resource usage statistics for the instance. Admin only.
|
||||
// GetInstanceStats gets resource usage statistics for the instance. Admin only. Results are cached for 60 seconds.
|
||||
GetInstanceStats(context.Context, *GetInstanceStatsRequest) (*InstanceStats, error)
|
||||
mustEmbedUnimplementedInstanceServiceServer()
|
||||
}
|
||||
@@ -291,7 +301,7 @@ func _InstanceService_GetInstanceStats_Handler(srv interface{}, ctx context.Cont
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var InstanceService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "memos.api.v1.InstanceService",
|
||||
ServiceName: "memos.api.InstanceService",
|
||||
HandlerType: (*InstanceServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
@@ -320,5 +330,5 @@ var InstanceService_ServiceDesc = grpc.ServiceDesc{
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v1/instance_service.proto",
|
||||
Metadata: "api/instance_service.proto",
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+252
-218
@@ -2,9 +2,9 @@
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc (unknown)
|
||||
// source: api/v1/memo_service.proto
|
||||
// source: api/memo_service.proto
|
||||
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
context "context"
|
||||
@@ -20,83 +20,100 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
MemoService_CreateMemo_FullMethodName = "/memos.api.v1.MemoService/CreateMemo"
|
||||
MemoService_ListMemos_FullMethodName = "/memos.api.v1.MemoService/ListMemos"
|
||||
MemoService_GetMemo_FullMethodName = "/memos.api.v1.MemoService/GetMemo"
|
||||
MemoService_UpdateMemo_FullMethodName = "/memos.api.v1.MemoService/UpdateMemo"
|
||||
MemoService_DeleteMemo_FullMethodName = "/memos.api.v1.MemoService/DeleteMemo"
|
||||
MemoService_SetMemoAttachments_FullMethodName = "/memos.api.v1.MemoService/SetMemoAttachments"
|
||||
MemoService_ListMemoAttachments_FullMethodName = "/memos.api.v1.MemoService/ListMemoAttachments"
|
||||
MemoService_SetMemoRelations_FullMethodName = "/memos.api.v1.MemoService/SetMemoRelations"
|
||||
MemoService_ListMemoRelations_FullMethodName = "/memos.api.v1.MemoService/ListMemoRelations"
|
||||
MemoService_CreateMemoComment_FullMethodName = "/memos.api.v1.MemoService/CreateMemoComment"
|
||||
MemoService_ListMemoComments_FullMethodName = "/memos.api.v1.MemoService/ListMemoComments"
|
||||
MemoService_ListMemoReactions_FullMethodName = "/memos.api.v1.MemoService/ListMemoReactions"
|
||||
MemoService_UpsertMemoReaction_FullMethodName = "/memos.api.v1.MemoService/UpsertMemoReaction"
|
||||
MemoService_DeleteMemoReaction_FullMethodName = "/memos.api.v1.MemoService/DeleteMemoReaction"
|
||||
MemoService_CreateMemoShare_FullMethodName = "/memos.api.v1.MemoService/CreateMemoShare"
|
||||
MemoService_ListMemoShares_FullMethodName = "/memos.api.v1.MemoService/ListMemoShares"
|
||||
MemoService_DeleteMemoShare_FullMethodName = "/memos.api.v1.MemoService/DeleteMemoShare"
|
||||
MemoService_GetSharedMemo_FullMethodName = "/memos.api.v1.MemoService/GetSharedMemo"
|
||||
MemoService_GetLinkMetadata_FullMethodName = "/memos.api.v1.MemoService/GetLinkMetadata"
|
||||
MemoService_BatchGetLinkMetadata_FullMethodName = "/memos.api.v1.MemoService/BatchGetLinkMetadata"
|
||||
MemoService_ListMemos_FullMethodName = "/memos.api.MemoService/ListMemos"
|
||||
MemoService_GetMemo_FullMethodName = "/memos.api.MemoService/GetMemo"
|
||||
MemoService_CreateMemo_FullMethodName = "/memos.api.MemoService/CreateMemo"
|
||||
MemoService_UpdateMemo_FullMethodName = "/memos.api.MemoService/UpdateMemo"
|
||||
MemoService_DeleteMemo_FullMethodName = "/memos.api.MemoService/DeleteMemo"
|
||||
MemoService_ListMemoAttachments_FullMethodName = "/memos.api.MemoService/ListMemoAttachments"
|
||||
MemoService_SetMemoAttachments_FullMethodName = "/memos.api.MemoService/SetMemoAttachments"
|
||||
MemoService_ListMemoRelations_FullMethodName = "/memos.api.MemoService/ListMemoRelations"
|
||||
MemoService_SetMemoRelations_FullMethodName = "/memos.api.MemoService/SetMemoRelations"
|
||||
MemoService_ListMemoComments_FullMethodName = "/memos.api.MemoService/ListMemoComments"
|
||||
MemoService_CreateMemoComment_FullMethodName = "/memos.api.MemoService/CreateMemoComment"
|
||||
MemoService_ListMemoReactions_FullMethodName = "/memos.api.MemoService/ListMemoReactions"
|
||||
MemoService_DeleteMemoReaction_FullMethodName = "/memos.api.MemoService/DeleteMemoReaction"
|
||||
MemoService_UpsertMemoReaction_FullMethodName = "/memos.api.MemoService/UpsertMemoReaction"
|
||||
MemoService_ListMemoShares_FullMethodName = "/memos.api.MemoService/ListMemoShares"
|
||||
MemoService_CreateMemoShare_FullMethodName = "/memos.api.MemoService/CreateMemoShare"
|
||||
MemoService_DeleteMemoShare_FullMethodName = "/memos.api.MemoService/DeleteMemoShare"
|
||||
MemoService_GetSharedMemo_FullMethodName = "/memos.api.MemoService/GetSharedMemo"
|
||||
MemoService_GetLinkMetadata_FullMethodName = "/memos.api.MemoService/GetLinkMetadata"
|
||||
MemoService_BatchGetLinkMetadata_FullMethodName = "/memos.api.MemoService/BatchGetLinkMetadata"
|
||||
)
|
||||
|
||||
// MemoServiceClient is the client API for MemoService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
//
|
||||
// MemoService manages memos and their attachments, relations, comments,
|
||||
// reactions, and share links.
|
||||
type MemoServiceClient interface {
|
||||
// CreateMemo creates a memo. The request body is a Memo; set its content
|
||||
// (Markdown) and visibility (PRIVATE | PROTECTED | PUBLIC | SPACE,
|
||||
// default PRIVATE).
|
||||
// The memo is owned by the authenticated user; requires authentication.
|
||||
CreateMemo(ctx context.Context, in *CreateMemoRequest, opts ...grpc.CallOption) (*Memo, error)
|
||||
// ListMemos lists readable non-comment memos with pagination and filter.
|
||||
// ListMemos lists the memos the caller can read, excluding comments.
|
||||
// Anonymous callers can list only when the instance allows public access.
|
||||
ListMemos(ctx context.Context, in *ListMemosRequest, opts ...grpc.CallOption) (*ListMemosResponse, error)
|
||||
// GetMemo gets a memo.
|
||||
// GetMemo gets a memo. Requires read access to the memo.
|
||||
GetMemo(ctx context.Context, in *GetMemoRequest, opts ...grpc.CallOption) (*Memo, error)
|
||||
// UpdateMemo updates a memo.
|
||||
// CreateMemo creates a memo owned by the authenticated user. The request body
|
||||
// is a Memo; set its Markdown content and visibility (defaults to PRIVATE).
|
||||
// Requires authentication.
|
||||
CreateMemo(ctx context.Context, in *CreateMemoRequest, opts ...grpc.CallOption) (*Memo, error)
|
||||
// UpdateMemo updates the memo fields listed in update_mask. Requires the memo
|
||||
// creator or an instance administrator.
|
||||
UpdateMemo(ctx context.Context, in *UpdateMemoRequest, opts ...grpc.CallOption) (*Memo, error)
|
||||
// DeleteMemo deletes the named memo and its comment subtree, including nested
|
||||
// replies and their owned resources. It removes incident relations for all
|
||||
// deleted memos.
|
||||
// deleted memos. Requires the memo creator or an instance administrator.
|
||||
DeleteMemo(ctx context.Context, in *DeleteMemoRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// ListMemoAttachments lists the attachments of a memo. Requires read access
|
||||
// to the memo.
|
||||
ListMemoAttachments(ctx context.Context, in *ListMemoAttachmentsRequest, opts ...grpc.CallOption) (*ListMemoAttachmentsResponse, error)
|
||||
// SetMemoAttachments replaces the full set of attachments on a memo with the
|
||||
// provided list (not an append). Pass the complete desired set; an empty list
|
||||
// clears all attachments. Idempotent.
|
||||
// clears all attachments. Idempotent. Requires the memo creator or an
|
||||
// instance administrator.
|
||||
SetMemoAttachments(ctx context.Context, in *SetMemoAttachmentsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// ListMemoAttachments lists attachments for a memo.
|
||||
ListMemoAttachments(ctx context.Context, in *ListMemoAttachmentsRequest, opts ...grpc.CallOption) (*ListMemoAttachmentsResponse, error)
|
||||
// ListMemoRelations lists the relations of a memo in both directions.
|
||||
// Requires read access to the memo.
|
||||
ListMemoRelations(ctx context.Context, in *ListMemoRelationsRequest, opts ...grpc.CallOption) (*ListMemoRelationsResponse, error)
|
||||
// SetMemoRelations replaces the full set of mutable REFERENCE relations on a
|
||||
// memo. COMMENT relations are immutable creation context and are rejected by
|
||||
// this RPC. An empty list clears references without changing COMMENT.
|
||||
// Requires the memo creator or an instance administrator.
|
||||
SetMemoRelations(ctx context.Context, in *SetMemoRelationsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// ListMemoRelations lists relations for a memo.
|
||||
ListMemoRelations(ctx context.Context, in *ListMemoRelationsRequest, opts ...grpc.CallOption) (*ListMemoRelationsResponse, error)
|
||||
// ListMemoComments lists the active comments on a memo that the caller can
|
||||
// read. Requires read access to the memo.
|
||||
ListMemoComments(ctx context.Context, in *ListMemoCommentsRequest, opts ...grpc.CallOption) (*ListMemoCommentsResponse, error)
|
||||
// CreateMemoComment atomically creates an independent memo plus one immutable
|
||||
// COMMENT context relation to the named memo. The new memo keeps its own
|
||||
// placement, visibility, authorship, and lifecycle.
|
||||
// placement, visibility, authorship, and lifecycle. The named memo must be
|
||||
// readable by the caller and not archived.
|
||||
CreateMemoComment(ctx context.Context, in *CreateMemoCommentRequest, opts ...grpc.CallOption) (*Memo, error)
|
||||
// ListMemoComments lists comments for a memo.
|
||||
ListMemoComments(ctx context.Context, in *ListMemoCommentsRequest, opts ...grpc.CallOption) (*ListMemoCommentsResponse, error)
|
||||
// ListMemoReactions lists reactions for a memo.
|
||||
// ListMemoReactions lists the reactions on a memo. Requires read access to
|
||||
// the memo.
|
||||
ListMemoReactions(ctx context.Context, in *ListMemoReactionsRequest, opts ...grpc.CallOption) (*ListMemoReactionsResponse, error)
|
||||
// UpsertMemoReaction adds or updates the authenticated user's reaction on a memo.
|
||||
UpsertMemoReaction(ctx context.Context, in *UpsertMemoReactionRequest, opts ...grpc.CallOption) (*Reaction, error)
|
||||
// DeleteMemoReaction deletes a reaction for a memo.
|
||||
// DeleteMemoReaction deletes a reaction. Requires the reaction creator or an
|
||||
// instance administrator.
|
||||
DeleteMemoReaction(ctx context.Context, in *DeleteMemoReactionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// CreateMemoShare creates a share link for a memo. Requires the memo creator or an instance administrator.
|
||||
CreateMemoShare(ctx context.Context, in *CreateMemoShareRequest, opts ...grpc.CallOption) (*MemoShare, error)
|
||||
// ListMemoShares lists all share links for a memo. Requires the memo creator or an instance administrator.
|
||||
// UpsertMemoReaction adds or updates the authenticated user's reaction on a
|
||||
// memo. Requires read access to the memo.
|
||||
UpsertMemoReaction(ctx context.Context, in *UpsertMemoReactionRequest, opts ...grpc.CallOption) (*Reaction, error)
|
||||
// ListMemoShares lists all share links for a memo. Requires the memo creator
|
||||
// or an instance administrator.
|
||||
ListMemoShares(ctx context.Context, in *ListMemoSharesRequest, opts ...grpc.CallOption) (*ListMemoSharesResponse, error)
|
||||
// DeleteMemoShare revokes a share link. Requires the memo creator or an instance administrator.
|
||||
// CreateMemoShare creates a share link for a memo. Requires the memo creator
|
||||
// or an instance administrator. Only active memos without SPACE visibility
|
||||
// can be shared.
|
||||
CreateMemoShare(ctx context.Context, in *CreateMemoShareRequest, opts ...grpc.CallOption) (*MemoShare, error)
|
||||
// DeleteMemoShare revokes a share link. Requires the memo creator or an
|
||||
// instance administrator.
|
||||
DeleteMemoShare(ctx context.Context, in *DeleteMemoShareRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// GetSharedMemo resolves a share token to its memo. No authentication required.
|
||||
// Returns NOT_FOUND if the token is invalid or expired.
|
||||
// GetSharedMemo resolves a share token to its memo. No authentication is
|
||||
// required. Returns NOT_FOUND if the token is invalid or expired.
|
||||
GetSharedMemo(ctx context.Context, in *GetSharedMemoRequest, opts ...grpc.CallOption) (*Memo, error)
|
||||
// GetLinkMetadata gets metadata for a link.
|
||||
// GetLinkMetadata fetches the title, description, and image of a link.
|
||||
GetLinkMetadata(ctx context.Context, in *GetLinkMetadataRequest, opts ...grpc.CallOption) (*LinkMetadata, error)
|
||||
// BatchGetLinkMetadata gets metadata for links.
|
||||
// BatchGetLinkMetadata fetches the metadata of up to 10 links.
|
||||
BatchGetLinkMetadata(ctx context.Context, in *BatchGetLinkMetadataRequest, opts ...grpc.CallOption) (*BatchGetLinkMetadataResponse, error)
|
||||
}
|
||||
|
||||
@@ -108,16 +125,6 @@ func NewMemoServiceClient(cc grpc.ClientConnInterface) MemoServiceClient {
|
||||
return &memoServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) CreateMemo(ctx context.Context, in *CreateMemoRequest, opts ...grpc.CallOption) (*Memo, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Memo)
|
||||
err := c.cc.Invoke(ctx, MemoService_CreateMemo_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) ListMemos(ctx context.Context, in *ListMemosRequest, opts ...grpc.CallOption) (*ListMemosResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListMemosResponse)
|
||||
@@ -138,6 +145,16 @@ func (c *memoServiceClient) GetMemo(ctx context.Context, in *GetMemoRequest, opt
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) CreateMemo(ctx context.Context, in *CreateMemoRequest, opts ...grpc.CallOption) (*Memo, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Memo)
|
||||
err := c.cc.Invoke(ctx, MemoService_CreateMemo_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) UpdateMemo(ctx context.Context, in *UpdateMemoRequest, opts ...grpc.CallOption) (*Memo, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Memo)
|
||||
@@ -158,16 +175,6 @@ func (c *memoServiceClient) DeleteMemo(ctx context.Context, in *DeleteMemoReques
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) SetMemoAttachments(ctx context.Context, in *SetMemoAttachmentsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, MemoService_SetMemoAttachments_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) ListMemoAttachments(ctx context.Context, in *ListMemoAttachmentsRequest, opts ...grpc.CallOption) (*ListMemoAttachmentsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListMemoAttachmentsResponse)
|
||||
@@ -178,10 +185,10 @@ func (c *memoServiceClient) ListMemoAttachments(ctx context.Context, in *ListMem
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) SetMemoRelations(ctx context.Context, in *SetMemoRelationsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
func (c *memoServiceClient) SetMemoAttachments(ctx context.Context, in *SetMemoAttachmentsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, MemoService_SetMemoRelations_FullMethodName, in, out, cOpts...)
|
||||
err := c.cc.Invoke(ctx, MemoService_SetMemoAttachments_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -198,10 +205,10 @@ func (c *memoServiceClient) ListMemoRelations(ctx context.Context, in *ListMemoR
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) CreateMemoComment(ctx context.Context, in *CreateMemoCommentRequest, opts ...grpc.CallOption) (*Memo, error) {
|
||||
func (c *memoServiceClient) SetMemoRelations(ctx context.Context, in *SetMemoRelationsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Memo)
|
||||
err := c.cc.Invoke(ctx, MemoService_CreateMemoComment_FullMethodName, in, out, cOpts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, MemoService_SetMemoRelations_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -218,20 +225,20 @@ func (c *memoServiceClient) ListMemoComments(ctx context.Context, in *ListMemoCo
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) ListMemoReactions(ctx context.Context, in *ListMemoReactionsRequest, opts ...grpc.CallOption) (*ListMemoReactionsResponse, error) {
|
||||
func (c *memoServiceClient) CreateMemoComment(ctx context.Context, in *CreateMemoCommentRequest, opts ...grpc.CallOption) (*Memo, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListMemoReactionsResponse)
|
||||
err := c.cc.Invoke(ctx, MemoService_ListMemoReactions_FullMethodName, in, out, cOpts...)
|
||||
out := new(Memo)
|
||||
err := c.cc.Invoke(ctx, MemoService_CreateMemoComment_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) UpsertMemoReaction(ctx context.Context, in *UpsertMemoReactionRequest, opts ...grpc.CallOption) (*Reaction, error) {
|
||||
func (c *memoServiceClient) ListMemoReactions(ctx context.Context, in *ListMemoReactionsRequest, opts ...grpc.CallOption) (*ListMemoReactionsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Reaction)
|
||||
err := c.cc.Invoke(ctx, MemoService_UpsertMemoReaction_FullMethodName, in, out, cOpts...)
|
||||
out := new(ListMemoReactionsResponse)
|
||||
err := c.cc.Invoke(ctx, MemoService_ListMemoReactions_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -248,10 +255,10 @@ func (c *memoServiceClient) DeleteMemoReaction(ctx context.Context, in *DeleteMe
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) CreateMemoShare(ctx context.Context, in *CreateMemoShareRequest, opts ...grpc.CallOption) (*MemoShare, error) {
|
||||
func (c *memoServiceClient) UpsertMemoReaction(ctx context.Context, in *UpsertMemoReactionRequest, opts ...grpc.CallOption) (*Reaction, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MemoShare)
|
||||
err := c.cc.Invoke(ctx, MemoService_CreateMemoShare_FullMethodName, in, out, cOpts...)
|
||||
out := new(Reaction)
|
||||
err := c.cc.Invoke(ctx, MemoService_UpsertMemoReaction_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -268,6 +275,16 @@ func (c *memoServiceClient) ListMemoShares(ctx context.Context, in *ListMemoShar
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) CreateMemoShare(ctx context.Context, in *CreateMemoShareRequest, opts ...grpc.CallOption) (*MemoShare, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MemoShare)
|
||||
err := c.cc.Invoke(ctx, MemoService_CreateMemoShare_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoServiceClient) DeleteMemoShare(ctx context.Context, in *DeleteMemoShareRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
@@ -311,58 +328,75 @@ func (c *memoServiceClient) BatchGetLinkMetadata(ctx context.Context, in *BatchG
|
||||
// MemoServiceServer is the server API for MemoService service.
|
||||
// All implementations must embed UnimplementedMemoServiceServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// MemoService manages memos and their attachments, relations, comments,
|
||||
// reactions, and share links.
|
||||
type MemoServiceServer interface {
|
||||
// CreateMemo creates a memo. The request body is a Memo; set its content
|
||||
// (Markdown) and visibility (PRIVATE | PROTECTED | PUBLIC | SPACE,
|
||||
// default PRIVATE).
|
||||
// The memo is owned by the authenticated user; requires authentication.
|
||||
CreateMemo(context.Context, *CreateMemoRequest) (*Memo, error)
|
||||
// ListMemos lists readable non-comment memos with pagination and filter.
|
||||
// ListMemos lists the memos the caller can read, excluding comments.
|
||||
// Anonymous callers can list only when the instance allows public access.
|
||||
ListMemos(context.Context, *ListMemosRequest) (*ListMemosResponse, error)
|
||||
// GetMemo gets a memo.
|
||||
// GetMemo gets a memo. Requires read access to the memo.
|
||||
GetMemo(context.Context, *GetMemoRequest) (*Memo, error)
|
||||
// UpdateMemo updates a memo.
|
||||
// CreateMemo creates a memo owned by the authenticated user. The request body
|
||||
// is a Memo; set its Markdown content and visibility (defaults to PRIVATE).
|
||||
// Requires authentication.
|
||||
CreateMemo(context.Context, *CreateMemoRequest) (*Memo, error)
|
||||
// UpdateMemo updates the memo fields listed in update_mask. Requires the memo
|
||||
// creator or an instance administrator.
|
||||
UpdateMemo(context.Context, *UpdateMemoRequest) (*Memo, error)
|
||||
// DeleteMemo deletes the named memo and its comment subtree, including nested
|
||||
// replies and their owned resources. It removes incident relations for all
|
||||
// deleted memos.
|
||||
// deleted memos. Requires the memo creator or an instance administrator.
|
||||
DeleteMemo(context.Context, *DeleteMemoRequest) (*emptypb.Empty, error)
|
||||
// ListMemoAttachments lists the attachments of a memo. Requires read access
|
||||
// to the memo.
|
||||
ListMemoAttachments(context.Context, *ListMemoAttachmentsRequest) (*ListMemoAttachmentsResponse, error)
|
||||
// SetMemoAttachments replaces the full set of attachments on a memo with the
|
||||
// provided list (not an append). Pass the complete desired set; an empty list
|
||||
// clears all attachments. Idempotent.
|
||||
// clears all attachments. Idempotent. Requires the memo creator or an
|
||||
// instance administrator.
|
||||
SetMemoAttachments(context.Context, *SetMemoAttachmentsRequest) (*emptypb.Empty, error)
|
||||
// ListMemoAttachments lists attachments for a memo.
|
||||
ListMemoAttachments(context.Context, *ListMemoAttachmentsRequest) (*ListMemoAttachmentsResponse, error)
|
||||
// ListMemoRelations lists the relations of a memo in both directions.
|
||||
// Requires read access to the memo.
|
||||
ListMemoRelations(context.Context, *ListMemoRelationsRequest) (*ListMemoRelationsResponse, error)
|
||||
// SetMemoRelations replaces the full set of mutable REFERENCE relations on a
|
||||
// memo. COMMENT relations are immutable creation context and are rejected by
|
||||
// this RPC. An empty list clears references without changing COMMENT.
|
||||
// Requires the memo creator or an instance administrator.
|
||||
SetMemoRelations(context.Context, *SetMemoRelationsRequest) (*emptypb.Empty, error)
|
||||
// ListMemoRelations lists relations for a memo.
|
||||
ListMemoRelations(context.Context, *ListMemoRelationsRequest) (*ListMemoRelationsResponse, error)
|
||||
// ListMemoComments lists the active comments on a memo that the caller can
|
||||
// read. Requires read access to the memo.
|
||||
ListMemoComments(context.Context, *ListMemoCommentsRequest) (*ListMemoCommentsResponse, error)
|
||||
// CreateMemoComment atomically creates an independent memo plus one immutable
|
||||
// COMMENT context relation to the named memo. The new memo keeps its own
|
||||
// placement, visibility, authorship, and lifecycle.
|
||||
// placement, visibility, authorship, and lifecycle. The named memo must be
|
||||
// readable by the caller and not archived.
|
||||
CreateMemoComment(context.Context, *CreateMemoCommentRequest) (*Memo, error)
|
||||
// ListMemoComments lists comments for a memo.
|
||||
ListMemoComments(context.Context, *ListMemoCommentsRequest) (*ListMemoCommentsResponse, error)
|
||||
// ListMemoReactions lists reactions for a memo.
|
||||
// ListMemoReactions lists the reactions on a memo. Requires read access to
|
||||
// the memo.
|
||||
ListMemoReactions(context.Context, *ListMemoReactionsRequest) (*ListMemoReactionsResponse, error)
|
||||
// UpsertMemoReaction adds or updates the authenticated user's reaction on a memo.
|
||||
UpsertMemoReaction(context.Context, *UpsertMemoReactionRequest) (*Reaction, error)
|
||||
// DeleteMemoReaction deletes a reaction for a memo.
|
||||
// DeleteMemoReaction deletes a reaction. Requires the reaction creator or an
|
||||
// instance administrator.
|
||||
DeleteMemoReaction(context.Context, *DeleteMemoReactionRequest) (*emptypb.Empty, error)
|
||||
// CreateMemoShare creates a share link for a memo. Requires the memo creator or an instance administrator.
|
||||
CreateMemoShare(context.Context, *CreateMemoShareRequest) (*MemoShare, error)
|
||||
// ListMemoShares lists all share links for a memo. Requires the memo creator or an instance administrator.
|
||||
// UpsertMemoReaction adds or updates the authenticated user's reaction on a
|
||||
// memo. Requires read access to the memo.
|
||||
UpsertMemoReaction(context.Context, *UpsertMemoReactionRequest) (*Reaction, error)
|
||||
// ListMemoShares lists all share links for a memo. Requires the memo creator
|
||||
// or an instance administrator.
|
||||
ListMemoShares(context.Context, *ListMemoSharesRequest) (*ListMemoSharesResponse, error)
|
||||
// DeleteMemoShare revokes a share link. Requires the memo creator or an instance administrator.
|
||||
// CreateMemoShare creates a share link for a memo. Requires the memo creator
|
||||
// or an instance administrator. Only active memos without SPACE visibility
|
||||
// can be shared.
|
||||
CreateMemoShare(context.Context, *CreateMemoShareRequest) (*MemoShare, error)
|
||||
// DeleteMemoShare revokes a share link. Requires the memo creator or an
|
||||
// instance administrator.
|
||||
DeleteMemoShare(context.Context, *DeleteMemoShareRequest) (*emptypb.Empty, error)
|
||||
// GetSharedMemo resolves a share token to its memo. No authentication required.
|
||||
// Returns NOT_FOUND if the token is invalid or expired.
|
||||
// GetSharedMemo resolves a share token to its memo. No authentication is
|
||||
// required. Returns NOT_FOUND if the token is invalid or expired.
|
||||
GetSharedMemo(context.Context, *GetSharedMemoRequest) (*Memo, error)
|
||||
// GetLinkMetadata gets metadata for a link.
|
||||
// GetLinkMetadata fetches the title, description, and image of a link.
|
||||
GetLinkMetadata(context.Context, *GetLinkMetadataRequest) (*LinkMetadata, error)
|
||||
// BatchGetLinkMetadata gets metadata for links.
|
||||
// BatchGetLinkMetadata fetches the metadata of up to 10 links.
|
||||
BatchGetLinkMetadata(context.Context, *BatchGetLinkMetadataRequest) (*BatchGetLinkMetadataResponse, error)
|
||||
mustEmbedUnimplementedMemoServiceServer()
|
||||
}
|
||||
@@ -374,54 +408,54 @@ type MemoServiceServer interface {
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedMemoServiceServer struct{}
|
||||
|
||||
func (UnimplementedMemoServiceServer) CreateMemo(context.Context, *CreateMemoRequest) (*Memo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateMemo not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) ListMemos(context.Context, *ListMemosRequest) (*ListMemosResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListMemos not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) GetMemo(context.Context, *GetMemoRequest) (*Memo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetMemo not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) CreateMemo(context.Context, *CreateMemoRequest) (*Memo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateMemo not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) UpdateMemo(context.Context, *UpdateMemoRequest) (*Memo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UpdateMemo not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) DeleteMemo(context.Context, *DeleteMemoRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeleteMemo not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) SetMemoAttachments(context.Context, *SetMemoAttachmentsRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method SetMemoAttachments not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) ListMemoAttachments(context.Context, *ListMemoAttachmentsRequest) (*ListMemoAttachmentsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListMemoAttachments not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) SetMemoRelations(context.Context, *SetMemoRelationsRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method SetMemoRelations not implemented")
|
||||
func (UnimplementedMemoServiceServer) SetMemoAttachments(context.Context, *SetMemoAttachmentsRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method SetMemoAttachments not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) ListMemoRelations(context.Context, *ListMemoRelationsRequest) (*ListMemoRelationsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListMemoRelations not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) CreateMemoComment(context.Context, *CreateMemoCommentRequest) (*Memo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateMemoComment not implemented")
|
||||
func (UnimplementedMemoServiceServer) SetMemoRelations(context.Context, *SetMemoRelationsRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method SetMemoRelations not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) ListMemoComments(context.Context, *ListMemoCommentsRequest) (*ListMemoCommentsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListMemoComments not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) CreateMemoComment(context.Context, *CreateMemoCommentRequest) (*Memo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateMemoComment not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) ListMemoReactions(context.Context, *ListMemoReactionsRequest) (*ListMemoReactionsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListMemoReactions not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) UpsertMemoReaction(context.Context, *UpsertMemoReactionRequest) (*Reaction, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UpsertMemoReaction not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) DeleteMemoReaction(context.Context, *DeleteMemoReactionRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeleteMemoReaction not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) CreateMemoShare(context.Context, *CreateMemoShareRequest) (*MemoShare, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateMemoShare not implemented")
|
||||
func (UnimplementedMemoServiceServer) UpsertMemoReaction(context.Context, *UpsertMemoReactionRequest) (*Reaction, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UpsertMemoReaction not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) ListMemoShares(context.Context, *ListMemoSharesRequest) (*ListMemoSharesResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListMemoShares not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) CreateMemoShare(context.Context, *CreateMemoShareRequest) (*MemoShare, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateMemoShare not implemented")
|
||||
}
|
||||
func (UnimplementedMemoServiceServer) DeleteMemoShare(context.Context, *DeleteMemoShareRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeleteMemoShare not implemented")
|
||||
}
|
||||
@@ -455,24 +489,6 @@ func RegisterMemoServiceServer(s grpc.ServiceRegistrar, srv MemoServiceServer) {
|
||||
s.RegisterService(&MemoService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _MemoService_CreateMemo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateMemoRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoServiceServer).CreateMemo(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoService_CreateMemo_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoServiceServer).CreateMemo(ctx, req.(*CreateMemoRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_ListMemos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListMemosRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -509,6 +525,24 @@ func _MemoService_GetMemo_Handler(srv interface{}, ctx context.Context, dec func
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_CreateMemo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateMemoRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoServiceServer).CreateMemo(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoService_CreateMemo_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoServiceServer).CreateMemo(ctx, req.(*CreateMemoRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_UpdateMemo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateMemoRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -545,24 +579,6 @@ func _MemoService_DeleteMemo_Handler(srv interface{}, ctx context.Context, dec f
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_SetMemoAttachments_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SetMemoAttachmentsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoServiceServer).SetMemoAttachments(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoService_SetMemoAttachments_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoServiceServer).SetMemoAttachments(ctx, req.(*SetMemoAttachmentsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_ListMemoAttachments_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListMemoAttachmentsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -581,20 +597,20 @@ func _MemoService_ListMemoAttachments_Handler(srv interface{}, ctx context.Conte
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_SetMemoRelations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SetMemoRelationsRequest)
|
||||
func _MemoService_SetMemoAttachments_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SetMemoAttachmentsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoServiceServer).SetMemoRelations(ctx, in)
|
||||
return srv.(MemoServiceServer).SetMemoAttachments(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoService_SetMemoRelations_FullMethodName,
|
||||
FullMethod: MemoService_SetMemoAttachments_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoServiceServer).SetMemoRelations(ctx, req.(*SetMemoRelationsRequest))
|
||||
return srv.(MemoServiceServer).SetMemoAttachments(ctx, req.(*SetMemoAttachmentsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
@@ -617,20 +633,20 @@ func _MemoService_ListMemoRelations_Handler(srv interface{}, ctx context.Context
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_CreateMemoComment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateMemoCommentRequest)
|
||||
func _MemoService_SetMemoRelations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SetMemoRelationsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoServiceServer).CreateMemoComment(ctx, in)
|
||||
return srv.(MemoServiceServer).SetMemoRelations(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoService_CreateMemoComment_FullMethodName,
|
||||
FullMethod: MemoService_SetMemoRelations_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoServiceServer).CreateMemoComment(ctx, req.(*CreateMemoCommentRequest))
|
||||
return srv.(MemoServiceServer).SetMemoRelations(ctx, req.(*SetMemoRelationsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
@@ -653,6 +669,24 @@ func _MemoService_ListMemoComments_Handler(srv interface{}, ctx context.Context,
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_CreateMemoComment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateMemoCommentRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoServiceServer).CreateMemoComment(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoService_CreateMemoComment_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoServiceServer).CreateMemoComment(ctx, req.(*CreateMemoCommentRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_ListMemoReactions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListMemoReactionsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -671,24 +705,6 @@ func _MemoService_ListMemoReactions_Handler(srv interface{}, ctx context.Context
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_UpsertMemoReaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpsertMemoReactionRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoServiceServer).UpsertMemoReaction(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoService_UpsertMemoReaction_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoServiceServer).UpsertMemoReaction(ctx, req.(*UpsertMemoReactionRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_DeleteMemoReaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteMemoReactionRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -707,20 +723,20 @@ func _MemoService_DeleteMemoReaction_Handler(srv interface{}, ctx context.Contex
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_CreateMemoShare_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateMemoShareRequest)
|
||||
func _MemoService_UpsertMemoReaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpsertMemoReactionRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoServiceServer).CreateMemoShare(ctx, in)
|
||||
return srv.(MemoServiceServer).UpsertMemoReaction(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoService_CreateMemoShare_FullMethodName,
|
||||
FullMethod: MemoService_UpsertMemoReaction_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoServiceServer).CreateMemoShare(ctx, req.(*CreateMemoShareRequest))
|
||||
return srv.(MemoServiceServer).UpsertMemoReaction(ctx, req.(*UpsertMemoReactionRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
@@ -743,6 +759,24 @@ func _MemoService_ListMemoShares_Handler(srv interface{}, ctx context.Context, d
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_CreateMemoShare_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateMemoShareRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoServiceServer).CreateMemoShare(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoService_CreateMemoShare_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoServiceServer).CreateMemoShare(ctx, req.(*CreateMemoShareRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoService_DeleteMemoShare_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteMemoShareRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -819,13 +853,9 @@ func _MemoService_BatchGetLinkMetadata_Handler(srv interface{}, ctx context.Cont
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var MemoService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "memos.api.v1.MemoService",
|
||||
ServiceName: "memos.api.MemoService",
|
||||
HandlerType: (*MemoServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "CreateMemo",
|
||||
Handler: _MemoService_CreateMemo_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListMemos",
|
||||
Handler: _MemoService_ListMemos_Handler,
|
||||
@@ -834,6 +864,10 @@ var MemoService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetMemo",
|
||||
Handler: _MemoService_GetMemo_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateMemo",
|
||||
Handler: _MemoService_CreateMemo_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateMemo",
|
||||
Handler: _MemoService_UpdateMemo_Handler,
|
||||
@@ -842,50 +876,50 @@ var MemoService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "DeleteMemo",
|
||||
Handler: _MemoService_DeleteMemo_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SetMemoAttachments",
|
||||
Handler: _MemoService_SetMemoAttachments_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListMemoAttachments",
|
||||
Handler: _MemoService_ListMemoAttachments_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SetMemoRelations",
|
||||
Handler: _MemoService_SetMemoRelations_Handler,
|
||||
MethodName: "SetMemoAttachments",
|
||||
Handler: _MemoService_SetMemoAttachments_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListMemoRelations",
|
||||
Handler: _MemoService_ListMemoRelations_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateMemoComment",
|
||||
Handler: _MemoService_CreateMemoComment_Handler,
|
||||
MethodName: "SetMemoRelations",
|
||||
Handler: _MemoService_SetMemoRelations_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListMemoComments",
|
||||
Handler: _MemoService_ListMemoComments_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListMemoReactions",
|
||||
Handler: _MemoService_ListMemoReactions_Handler,
|
||||
MethodName: "CreateMemoComment",
|
||||
Handler: _MemoService_CreateMemoComment_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpsertMemoReaction",
|
||||
Handler: _MemoService_UpsertMemoReaction_Handler,
|
||||
MethodName: "ListMemoReactions",
|
||||
Handler: _MemoService_ListMemoReactions_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteMemoReaction",
|
||||
Handler: _MemoService_DeleteMemoReaction_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateMemoShare",
|
||||
Handler: _MemoService_CreateMemoShare_Handler,
|
||||
MethodName: "UpsertMemoReaction",
|
||||
Handler: _MemoService_UpsertMemoReaction_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListMemoShares",
|
||||
Handler: _MemoService_ListMemoShares_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateMemoShare",
|
||||
Handler: _MemoService_CreateMemoShare_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteMemoShare",
|
||||
Handler: _MemoService_DeleteMemoShare_Handler,
|
||||
@@ -904,5 +938,5 @@ var MemoService_ServiceDesc = grpc.ServiceDesc{
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v1/memo_service.proto",
|
||||
Metadata: "api/memo_service.proto",
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+382
-352
@@ -2,9 +2,9 @@
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc (unknown)
|
||||
// source: api/v1/space_service.proto
|
||||
// source: api/space_service.proto
|
||||
|
||||
package apiv1
|
||||
package api
|
||||
|
||||
import (
|
||||
context "context"
|
||||
@@ -20,65 +20,80 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
SpaceService_CreateSpace_FullMethodName = "/memos.api.v1.SpaceService/CreateSpace"
|
||||
SpaceService_ListSpaces_FullMethodName = "/memos.api.v1.SpaceService/ListSpaces"
|
||||
SpaceService_GetSpace_FullMethodName = "/memos.api.v1.SpaceService/GetSpace"
|
||||
SpaceService_UpdateSpace_FullMethodName = "/memos.api.v1.SpaceService/UpdateSpace"
|
||||
SpaceService_DeleteSpace_FullMethodName = "/memos.api.v1.SpaceService/DeleteSpace"
|
||||
SpaceService_CreateSpaceInvitation_FullMethodName = "/memos.api.v1.SpaceService/CreateSpaceInvitation"
|
||||
SpaceService_ListSpaceInvitations_FullMethodName = "/memos.api.v1.SpaceService/ListSpaceInvitations"
|
||||
SpaceService_ListUserSpaceInvitations_FullMethodName = "/memos.api.v1.SpaceService/ListUserSpaceInvitations"
|
||||
SpaceService_GetSpaceInvitation_FullMethodName = "/memos.api.v1.SpaceService/GetSpaceInvitation"
|
||||
SpaceService_DeleteSpaceInvitation_FullMethodName = "/memos.api.v1.SpaceService/DeleteSpaceInvitation"
|
||||
SpaceService_AcceptSpaceInvitation_FullMethodName = "/memos.api.v1.SpaceService/AcceptSpaceInvitation"
|
||||
SpaceService_DeclineSpaceInvitation_FullMethodName = "/memos.api.v1.SpaceService/DeclineSpaceInvitation"
|
||||
SpaceService_ListSpaceMembers_FullMethodName = "/memos.api.v1.SpaceService/ListSpaceMembers"
|
||||
SpaceService_GetSpaceMember_FullMethodName = "/memos.api.v1.SpaceService/GetSpaceMember"
|
||||
SpaceService_UpdateSpaceMember_FullMethodName = "/memos.api.v1.SpaceService/UpdateSpaceMember"
|
||||
SpaceService_DeleteSpaceMember_FullMethodName = "/memos.api.v1.SpaceService/DeleteSpaceMember"
|
||||
SpaceService_ListSpaces_FullMethodName = "/memos.api.SpaceService/ListSpaces"
|
||||
SpaceService_GetSpace_FullMethodName = "/memos.api.SpaceService/GetSpace"
|
||||
SpaceService_CreateSpace_FullMethodName = "/memos.api.SpaceService/CreateSpace"
|
||||
SpaceService_UpdateSpace_FullMethodName = "/memos.api.SpaceService/UpdateSpace"
|
||||
SpaceService_DeleteSpace_FullMethodName = "/memos.api.SpaceService/DeleteSpace"
|
||||
SpaceService_ListSpaceMembers_FullMethodName = "/memos.api.SpaceService/ListSpaceMembers"
|
||||
SpaceService_GetSpaceMember_FullMethodName = "/memos.api.SpaceService/GetSpaceMember"
|
||||
SpaceService_UpdateSpaceMember_FullMethodName = "/memos.api.SpaceService/UpdateSpaceMember"
|
||||
SpaceService_DeleteSpaceMember_FullMethodName = "/memos.api.SpaceService/DeleteSpaceMember"
|
||||
SpaceService_ListSpaceInvitations_FullMethodName = "/memos.api.SpaceService/ListSpaceInvitations"
|
||||
SpaceService_ListUserSpaceInvitations_FullMethodName = "/memos.api.SpaceService/ListUserSpaceInvitations"
|
||||
SpaceService_GetSpaceInvitation_FullMethodName = "/memos.api.SpaceService/GetSpaceInvitation"
|
||||
SpaceService_CreateSpaceInvitation_FullMethodName = "/memos.api.SpaceService/CreateSpaceInvitation"
|
||||
SpaceService_DeleteSpaceInvitation_FullMethodName = "/memos.api.SpaceService/DeleteSpaceInvitation"
|
||||
SpaceService_AcceptSpaceInvitation_FullMethodName = "/memos.api.SpaceService/AcceptSpaceInvitation"
|
||||
SpaceService_DeclineSpaceInvitation_FullMethodName = "/memos.api.SpaceService/DeclineSpaceInvitation"
|
||||
)
|
||||
|
||||
// SpaceServiceClient is the client API for SpaceService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
//
|
||||
// SpaceService manages collaborative spaces and their memberships.
|
||||
// SpaceService manages collaborative spaces, their members and their invitations.
|
||||
type SpaceServiceClient interface {
|
||||
// ListSpaces lists the spaces of which the authenticated caller is a member.
|
||||
ListSpaces(ctx context.Context, in *ListSpacesRequest, opts ...grpc.CallOption) (*ListSpacesResponse, error)
|
||||
// GetSpace gets a space of which the authenticated caller is a member.
|
||||
// Spaces the caller is not a member of are reported as not found.
|
||||
GetSpace(ctx context.Context, in *GetSpaceRequest, opts ...grpc.CallOption) (*Space, error)
|
||||
// CreateSpace creates a space and makes the authenticated caller its first
|
||||
// administrator.
|
||||
CreateSpace(ctx context.Context, in *CreateSpaceRequest, opts ...grpc.CallOption) (*Space, error)
|
||||
// ListSpaces lists spaces of which the authenticated caller is a member.
|
||||
ListSpaces(ctx context.Context, in *ListSpacesRequest, opts ...grpc.CallOption) (*ListSpacesResponse, error)
|
||||
// GetSpace gets a space of which the authenticated caller is a member.
|
||||
GetSpace(ctx context.Context, in *GetSpaceRequest, opts ...grpc.CallOption) (*Space, error)
|
||||
// UpdateSpace updates space metadata.
|
||||
// UpdateSpace updates space metadata. Only a space administrator can update
|
||||
// a space.
|
||||
UpdateSpace(ctx context.Context, in *UpdateSpaceRequest, opts ...grpc.CallOption) (*Space, error)
|
||||
// DeleteSpace permanently deletes a space and every memo currently placed
|
||||
// in it. It never follows memo relations to other memos.
|
||||
// in it. It never follows memo relations to other memos. Only a space
|
||||
// administrator can delete a space.
|
||||
DeleteSpace(ctx context.Context, in *DeleteSpaceRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// CreateSpaceInvitation invites an existing active user to a space.
|
||||
CreateSpaceInvitation(ctx context.Context, in *CreateSpaceInvitationRequest, opts ...grpc.CallOption) (*SpaceInvitation, error)
|
||||
// ListSpaceInvitations lists the pending invitations for a space.
|
||||
ListSpaceInvitations(ctx context.Context, in *ListSpaceInvitationsRequest, opts ...grpc.CallOption) (*ListSpaceInvitationsResponse, error)
|
||||
// ListUserSpaceInvitations lists the authenticated user's pending space invitations.
|
||||
ListUserSpaceInvitations(ctx context.Context, in *ListUserSpaceInvitationsRequest, opts ...grpc.CallOption) (*ListUserSpaceInvitationsResponse, error)
|
||||
// GetSpaceInvitation gets one pending invitation.
|
||||
GetSpaceInvitation(ctx context.Context, in *GetSpaceInvitationRequest, opts ...grpc.CallOption) (*SpaceInvitation, error)
|
||||
// DeleteSpaceInvitation revokes a pending invitation.
|
||||
DeleteSpaceInvitation(ctx context.Context, in *DeleteSpaceInvitationRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// AcceptSpaceInvitation accepts a pending invitation and creates a membership.
|
||||
AcceptSpaceInvitation(ctx context.Context, in *AcceptSpaceInvitationRequest, opts ...grpc.CallOption) (*SpaceMember, error)
|
||||
// DeclineSpaceInvitation declines a pending invitation.
|
||||
DeclineSpaceInvitation(ctx context.Context, in *DeclineSpaceInvitationRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// ListSpaceMembers lists the members of a space.
|
||||
// ListSpaceMembers lists the members of a space. The caller must be a member
|
||||
// of the space.
|
||||
ListSpaceMembers(ctx context.Context, in *ListSpaceMembersRequest, opts ...grpc.CallOption) (*ListSpaceMembersResponse, error)
|
||||
// GetSpaceMember gets one membership in a space.
|
||||
// GetSpaceMember gets one membership in a space. The caller must be a member
|
||||
// of the space.
|
||||
GetSpaceMember(ctx context.Context, in *GetSpaceMemberRequest, opts ...grpc.CallOption) (*SpaceMember, error)
|
||||
// UpdateSpaceMember changes a member's space role.
|
||||
// UpdateSpaceMember changes a member's space role. Only a space administrator
|
||||
// can change roles, and a space must keep at least one administrator.
|
||||
UpdateSpaceMember(ctx context.Context, in *UpdateSpaceMemberRequest, opts ...grpc.CallOption) (*SpaceMember, error)
|
||||
// DeleteSpaceMember removes a member. A member may delete their own
|
||||
// membership to leave the space.
|
||||
// DeleteSpaceMember removes a member. A space administrator can remove any
|
||||
// member, and a member may delete their own membership to leave the space.
|
||||
// A space must keep at least one administrator.
|
||||
DeleteSpaceMember(ctx context.Context, in *DeleteSpaceMemberRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// ListSpaceInvitations lists the pending invitations for a space. Only a
|
||||
// space administrator can list them.
|
||||
ListSpaceInvitations(ctx context.Context, in *ListSpaceInvitationsRequest, opts ...grpc.CallOption) (*ListSpaceInvitationsResponse, error)
|
||||
// ListUserSpaceInvitations lists the authenticated user's pending space
|
||||
// invitations. A user cannot list another user's invitations.
|
||||
ListUserSpaceInvitations(ctx context.Context, in *ListUserSpaceInvitationsRequest, opts ...grpc.CallOption) (*ListUserSpaceInvitationsResponse, error)
|
||||
// GetSpaceInvitation gets one pending invitation. Only the invitee or a
|
||||
// space administrator can get it.
|
||||
GetSpaceInvitation(ctx context.Context, in *GetSpaceInvitationRequest, opts ...grpc.CallOption) (*SpaceInvitation, error)
|
||||
// CreateSpaceInvitation invites an existing active user to a space. Only a
|
||||
// space administrator can invite. The invitee gets no space access until
|
||||
// they accept.
|
||||
CreateSpaceInvitation(ctx context.Context, in *CreateSpaceInvitationRequest, opts ...grpc.CallOption) (*SpaceInvitation, error)
|
||||
// DeleteSpaceInvitation revokes a pending invitation. Only a space
|
||||
// administrator can revoke it.
|
||||
DeleteSpaceInvitation(ctx context.Context, in *DeleteSpaceInvitationRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// AcceptSpaceInvitation accepts a pending invitation and creates a
|
||||
// membership with the invited role. Only the invitee can accept it.
|
||||
AcceptSpaceInvitation(ctx context.Context, in *AcceptSpaceInvitationRequest, opts ...grpc.CallOption) (*SpaceMember, error)
|
||||
// DeclineSpaceInvitation declines a pending invitation without creating a
|
||||
// membership. Only the invitee can decline it.
|
||||
DeclineSpaceInvitation(ctx context.Context, in *DeclineSpaceInvitationRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
}
|
||||
|
||||
type spaceServiceClient struct {
|
||||
@@ -89,16 +104,6 @@ func NewSpaceServiceClient(cc grpc.ClientConnInterface) SpaceServiceClient {
|
||||
return &spaceServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) CreateSpace(ctx context.Context, in *CreateSpaceRequest, opts ...grpc.CallOption) (*Space, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Space)
|
||||
err := c.cc.Invoke(ctx, SpaceService_CreateSpace_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) ListSpaces(ctx context.Context, in *ListSpacesRequest, opts ...grpc.CallOption) (*ListSpacesResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListSpacesResponse)
|
||||
@@ -119,6 +124,16 @@ func (c *spaceServiceClient) GetSpace(ctx context.Context, in *GetSpaceRequest,
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) CreateSpace(ctx context.Context, in *CreateSpaceRequest, opts ...grpc.CallOption) (*Space, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Space)
|
||||
err := c.cc.Invoke(ctx, SpaceService_CreateSpace_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) UpdateSpace(ctx context.Context, in *UpdateSpaceRequest, opts ...grpc.CallOption) (*Space, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Space)
|
||||
@@ -139,76 +154,6 @@ func (c *spaceServiceClient) DeleteSpace(ctx context.Context, in *DeleteSpaceReq
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) CreateSpaceInvitation(ctx context.Context, in *CreateSpaceInvitationRequest, opts ...grpc.CallOption) (*SpaceInvitation, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SpaceInvitation)
|
||||
err := c.cc.Invoke(ctx, SpaceService_CreateSpaceInvitation_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) ListSpaceInvitations(ctx context.Context, in *ListSpaceInvitationsRequest, opts ...grpc.CallOption) (*ListSpaceInvitationsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListSpaceInvitationsResponse)
|
||||
err := c.cc.Invoke(ctx, SpaceService_ListSpaceInvitations_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) ListUserSpaceInvitations(ctx context.Context, in *ListUserSpaceInvitationsRequest, opts ...grpc.CallOption) (*ListUserSpaceInvitationsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListUserSpaceInvitationsResponse)
|
||||
err := c.cc.Invoke(ctx, SpaceService_ListUserSpaceInvitations_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) GetSpaceInvitation(ctx context.Context, in *GetSpaceInvitationRequest, opts ...grpc.CallOption) (*SpaceInvitation, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SpaceInvitation)
|
||||
err := c.cc.Invoke(ctx, SpaceService_GetSpaceInvitation_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) DeleteSpaceInvitation(ctx context.Context, in *DeleteSpaceInvitationRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, SpaceService_DeleteSpaceInvitation_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) AcceptSpaceInvitation(ctx context.Context, in *AcceptSpaceInvitationRequest, opts ...grpc.CallOption) (*SpaceMember, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SpaceMember)
|
||||
err := c.cc.Invoke(ctx, SpaceService_AcceptSpaceInvitation_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) DeclineSpaceInvitation(ctx context.Context, in *DeclineSpaceInvitationRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, SpaceService_DeclineSpaceInvitation_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) ListSpaceMembers(ctx context.Context, in *ListSpaceMembersRequest, opts ...grpc.CallOption) (*ListSpaceMembersResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListSpaceMembersResponse)
|
||||
@@ -249,47 +194,132 @@ func (c *spaceServiceClient) DeleteSpaceMember(ctx context.Context, in *DeleteSp
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) ListSpaceInvitations(ctx context.Context, in *ListSpaceInvitationsRequest, opts ...grpc.CallOption) (*ListSpaceInvitationsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListSpaceInvitationsResponse)
|
||||
err := c.cc.Invoke(ctx, SpaceService_ListSpaceInvitations_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) ListUserSpaceInvitations(ctx context.Context, in *ListUserSpaceInvitationsRequest, opts ...grpc.CallOption) (*ListUserSpaceInvitationsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListUserSpaceInvitationsResponse)
|
||||
err := c.cc.Invoke(ctx, SpaceService_ListUserSpaceInvitations_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) GetSpaceInvitation(ctx context.Context, in *GetSpaceInvitationRequest, opts ...grpc.CallOption) (*SpaceInvitation, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SpaceInvitation)
|
||||
err := c.cc.Invoke(ctx, SpaceService_GetSpaceInvitation_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) CreateSpaceInvitation(ctx context.Context, in *CreateSpaceInvitationRequest, opts ...grpc.CallOption) (*SpaceInvitation, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SpaceInvitation)
|
||||
err := c.cc.Invoke(ctx, SpaceService_CreateSpaceInvitation_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) DeleteSpaceInvitation(ctx context.Context, in *DeleteSpaceInvitationRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, SpaceService_DeleteSpaceInvitation_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) AcceptSpaceInvitation(ctx context.Context, in *AcceptSpaceInvitationRequest, opts ...grpc.CallOption) (*SpaceMember, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SpaceMember)
|
||||
err := c.cc.Invoke(ctx, SpaceService_AcceptSpaceInvitation_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *spaceServiceClient) DeclineSpaceInvitation(ctx context.Context, in *DeclineSpaceInvitationRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, SpaceService_DeclineSpaceInvitation_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// SpaceServiceServer is the server API for SpaceService service.
|
||||
// All implementations must embed UnimplementedSpaceServiceServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// SpaceService manages collaborative spaces and their memberships.
|
||||
// SpaceService manages collaborative spaces, their members and their invitations.
|
||||
type SpaceServiceServer interface {
|
||||
// ListSpaces lists the spaces of which the authenticated caller is a member.
|
||||
ListSpaces(context.Context, *ListSpacesRequest) (*ListSpacesResponse, error)
|
||||
// GetSpace gets a space of which the authenticated caller is a member.
|
||||
// Spaces the caller is not a member of are reported as not found.
|
||||
GetSpace(context.Context, *GetSpaceRequest) (*Space, error)
|
||||
// CreateSpace creates a space and makes the authenticated caller its first
|
||||
// administrator.
|
||||
CreateSpace(context.Context, *CreateSpaceRequest) (*Space, error)
|
||||
// ListSpaces lists spaces of which the authenticated caller is a member.
|
||||
ListSpaces(context.Context, *ListSpacesRequest) (*ListSpacesResponse, error)
|
||||
// GetSpace gets a space of which the authenticated caller is a member.
|
||||
GetSpace(context.Context, *GetSpaceRequest) (*Space, error)
|
||||
// UpdateSpace updates space metadata.
|
||||
// UpdateSpace updates space metadata. Only a space administrator can update
|
||||
// a space.
|
||||
UpdateSpace(context.Context, *UpdateSpaceRequest) (*Space, error)
|
||||
// DeleteSpace permanently deletes a space and every memo currently placed
|
||||
// in it. It never follows memo relations to other memos.
|
||||
// in it. It never follows memo relations to other memos. Only a space
|
||||
// administrator can delete a space.
|
||||
DeleteSpace(context.Context, *DeleteSpaceRequest) (*emptypb.Empty, error)
|
||||
// CreateSpaceInvitation invites an existing active user to a space.
|
||||
CreateSpaceInvitation(context.Context, *CreateSpaceInvitationRequest) (*SpaceInvitation, error)
|
||||
// ListSpaceInvitations lists the pending invitations for a space.
|
||||
ListSpaceInvitations(context.Context, *ListSpaceInvitationsRequest) (*ListSpaceInvitationsResponse, error)
|
||||
// ListUserSpaceInvitations lists the authenticated user's pending space invitations.
|
||||
ListUserSpaceInvitations(context.Context, *ListUserSpaceInvitationsRequest) (*ListUserSpaceInvitationsResponse, error)
|
||||
// GetSpaceInvitation gets one pending invitation.
|
||||
GetSpaceInvitation(context.Context, *GetSpaceInvitationRequest) (*SpaceInvitation, error)
|
||||
// DeleteSpaceInvitation revokes a pending invitation.
|
||||
DeleteSpaceInvitation(context.Context, *DeleteSpaceInvitationRequest) (*emptypb.Empty, error)
|
||||
// AcceptSpaceInvitation accepts a pending invitation and creates a membership.
|
||||
AcceptSpaceInvitation(context.Context, *AcceptSpaceInvitationRequest) (*SpaceMember, error)
|
||||
// DeclineSpaceInvitation declines a pending invitation.
|
||||
DeclineSpaceInvitation(context.Context, *DeclineSpaceInvitationRequest) (*emptypb.Empty, error)
|
||||
// ListSpaceMembers lists the members of a space.
|
||||
// ListSpaceMembers lists the members of a space. The caller must be a member
|
||||
// of the space.
|
||||
ListSpaceMembers(context.Context, *ListSpaceMembersRequest) (*ListSpaceMembersResponse, error)
|
||||
// GetSpaceMember gets one membership in a space.
|
||||
// GetSpaceMember gets one membership in a space. The caller must be a member
|
||||
// of the space.
|
||||
GetSpaceMember(context.Context, *GetSpaceMemberRequest) (*SpaceMember, error)
|
||||
// UpdateSpaceMember changes a member's space role.
|
||||
// UpdateSpaceMember changes a member's space role. Only a space administrator
|
||||
// can change roles, and a space must keep at least one administrator.
|
||||
UpdateSpaceMember(context.Context, *UpdateSpaceMemberRequest) (*SpaceMember, error)
|
||||
// DeleteSpaceMember removes a member. A member may delete their own
|
||||
// membership to leave the space.
|
||||
// DeleteSpaceMember removes a member. A space administrator can remove any
|
||||
// member, and a member may delete their own membership to leave the space.
|
||||
// A space must keep at least one administrator.
|
||||
DeleteSpaceMember(context.Context, *DeleteSpaceMemberRequest) (*emptypb.Empty, error)
|
||||
// ListSpaceInvitations lists the pending invitations for a space. Only a
|
||||
// space administrator can list them.
|
||||
ListSpaceInvitations(context.Context, *ListSpaceInvitationsRequest) (*ListSpaceInvitationsResponse, error)
|
||||
// ListUserSpaceInvitations lists the authenticated user's pending space
|
||||
// invitations. A user cannot list another user's invitations.
|
||||
ListUserSpaceInvitations(context.Context, *ListUserSpaceInvitationsRequest) (*ListUserSpaceInvitationsResponse, error)
|
||||
// GetSpaceInvitation gets one pending invitation. Only the invitee or a
|
||||
// space administrator can get it.
|
||||
GetSpaceInvitation(context.Context, *GetSpaceInvitationRequest) (*SpaceInvitation, error)
|
||||
// CreateSpaceInvitation invites an existing active user to a space. Only a
|
||||
// space administrator can invite. The invitee gets no space access until
|
||||
// they accept.
|
||||
CreateSpaceInvitation(context.Context, *CreateSpaceInvitationRequest) (*SpaceInvitation, error)
|
||||
// DeleteSpaceInvitation revokes a pending invitation. Only a space
|
||||
// administrator can revoke it.
|
||||
DeleteSpaceInvitation(context.Context, *DeleteSpaceInvitationRequest) (*emptypb.Empty, error)
|
||||
// AcceptSpaceInvitation accepts a pending invitation and creates a
|
||||
// membership with the invited role. Only the invitee can accept it.
|
||||
AcceptSpaceInvitation(context.Context, *AcceptSpaceInvitationRequest) (*SpaceMember, error)
|
||||
// DeclineSpaceInvitation declines a pending invitation without creating a
|
||||
// membership. Only the invitee can decline it.
|
||||
DeclineSpaceInvitation(context.Context, *DeclineSpaceInvitationRequest) (*emptypb.Empty, error)
|
||||
mustEmbedUnimplementedSpaceServiceServer()
|
||||
}
|
||||
|
||||
@@ -300,42 +330,21 @@ type SpaceServiceServer interface {
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedSpaceServiceServer struct{}
|
||||
|
||||
func (UnimplementedSpaceServiceServer) CreateSpace(context.Context, *CreateSpaceRequest) (*Space, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateSpace not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) ListSpaces(context.Context, *ListSpacesRequest) (*ListSpacesResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListSpaces not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) GetSpace(context.Context, *GetSpaceRequest) (*Space, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetSpace not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) CreateSpace(context.Context, *CreateSpaceRequest) (*Space, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateSpace not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) UpdateSpace(context.Context, *UpdateSpaceRequest) (*Space, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UpdateSpace not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) DeleteSpace(context.Context, *DeleteSpaceRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeleteSpace not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) CreateSpaceInvitation(context.Context, *CreateSpaceInvitationRequest) (*SpaceInvitation, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateSpaceInvitation not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) ListSpaceInvitations(context.Context, *ListSpaceInvitationsRequest) (*ListSpaceInvitationsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListSpaceInvitations not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) ListUserSpaceInvitations(context.Context, *ListUserSpaceInvitationsRequest) (*ListUserSpaceInvitationsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListUserSpaceInvitations not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) GetSpaceInvitation(context.Context, *GetSpaceInvitationRequest) (*SpaceInvitation, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetSpaceInvitation not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) DeleteSpaceInvitation(context.Context, *DeleteSpaceInvitationRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeleteSpaceInvitation not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) AcceptSpaceInvitation(context.Context, *AcceptSpaceInvitationRequest) (*SpaceMember, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method AcceptSpaceInvitation not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) DeclineSpaceInvitation(context.Context, *DeclineSpaceInvitationRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeclineSpaceInvitation not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) ListSpaceMembers(context.Context, *ListSpaceMembersRequest) (*ListSpaceMembersResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListSpaceMembers not implemented")
|
||||
}
|
||||
@@ -348,6 +357,27 @@ func (UnimplementedSpaceServiceServer) UpdateSpaceMember(context.Context, *Updat
|
||||
func (UnimplementedSpaceServiceServer) DeleteSpaceMember(context.Context, *DeleteSpaceMemberRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeleteSpaceMember not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) ListSpaceInvitations(context.Context, *ListSpaceInvitationsRequest) (*ListSpaceInvitationsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListSpaceInvitations not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) ListUserSpaceInvitations(context.Context, *ListUserSpaceInvitationsRequest) (*ListUserSpaceInvitationsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListUserSpaceInvitations not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) GetSpaceInvitation(context.Context, *GetSpaceInvitationRequest) (*SpaceInvitation, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetSpaceInvitation not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) CreateSpaceInvitation(context.Context, *CreateSpaceInvitationRequest) (*SpaceInvitation, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateSpaceInvitation not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) DeleteSpaceInvitation(context.Context, *DeleteSpaceInvitationRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeleteSpaceInvitation not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) AcceptSpaceInvitation(context.Context, *AcceptSpaceInvitationRequest) (*SpaceMember, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method AcceptSpaceInvitation not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) DeclineSpaceInvitation(context.Context, *DeclineSpaceInvitationRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeclineSpaceInvitation not implemented")
|
||||
}
|
||||
func (UnimplementedSpaceServiceServer) mustEmbedUnimplementedSpaceServiceServer() {}
|
||||
func (UnimplementedSpaceServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
@@ -369,24 +399,6 @@ func RegisterSpaceServiceServer(s grpc.ServiceRegistrar, srv SpaceServiceServer)
|
||||
s.RegisterService(&SpaceService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _SpaceService_CreateSpace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateSpaceRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).CreateSpace(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_CreateSpace_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).CreateSpace(ctx, req.(*CreateSpaceRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_ListSpaces_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListSpacesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -423,6 +435,24 @@ func _SpaceService_GetSpace_Handler(srv interface{}, ctx context.Context, dec fu
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_CreateSpace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateSpaceRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).CreateSpace(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_CreateSpace_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).CreateSpace(ctx, req.(*CreateSpaceRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_UpdateSpace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateSpaceRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -459,132 +489,6 @@ func _SpaceService_DeleteSpace_Handler(srv interface{}, ctx context.Context, dec
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_CreateSpaceInvitation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateSpaceInvitationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).CreateSpaceInvitation(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_CreateSpaceInvitation_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).CreateSpaceInvitation(ctx, req.(*CreateSpaceInvitationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_ListSpaceInvitations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListSpaceInvitationsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).ListSpaceInvitations(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_ListSpaceInvitations_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).ListSpaceInvitations(ctx, req.(*ListSpaceInvitationsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_ListUserSpaceInvitations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListUserSpaceInvitationsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).ListUserSpaceInvitations(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_ListUserSpaceInvitations_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).ListUserSpaceInvitations(ctx, req.(*ListUserSpaceInvitationsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_GetSpaceInvitation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetSpaceInvitationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).GetSpaceInvitation(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_GetSpaceInvitation_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).GetSpaceInvitation(ctx, req.(*GetSpaceInvitationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_DeleteSpaceInvitation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteSpaceInvitationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).DeleteSpaceInvitation(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_DeleteSpaceInvitation_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).DeleteSpaceInvitation(ctx, req.(*DeleteSpaceInvitationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_AcceptSpaceInvitation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AcceptSpaceInvitationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).AcceptSpaceInvitation(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_AcceptSpaceInvitation_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).AcceptSpaceInvitation(ctx, req.(*AcceptSpaceInvitationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_DeclineSpaceInvitation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeclineSpaceInvitationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).DeclineSpaceInvitation(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_DeclineSpaceInvitation_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).DeclineSpaceInvitation(ctx, req.(*DeclineSpaceInvitationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_ListSpaceMembers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListSpaceMembersRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -657,17 +561,139 @@ func _SpaceService_DeleteSpaceMember_Handler(srv interface{}, ctx context.Contex
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_ListSpaceInvitations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListSpaceInvitationsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).ListSpaceInvitations(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_ListSpaceInvitations_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).ListSpaceInvitations(ctx, req.(*ListSpaceInvitationsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_ListUserSpaceInvitations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListUserSpaceInvitationsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).ListUserSpaceInvitations(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_ListUserSpaceInvitations_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).ListUserSpaceInvitations(ctx, req.(*ListUserSpaceInvitationsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_GetSpaceInvitation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetSpaceInvitationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).GetSpaceInvitation(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_GetSpaceInvitation_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).GetSpaceInvitation(ctx, req.(*GetSpaceInvitationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_CreateSpaceInvitation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateSpaceInvitationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).CreateSpaceInvitation(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_CreateSpaceInvitation_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).CreateSpaceInvitation(ctx, req.(*CreateSpaceInvitationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_DeleteSpaceInvitation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteSpaceInvitationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).DeleteSpaceInvitation(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_DeleteSpaceInvitation_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).DeleteSpaceInvitation(ctx, req.(*DeleteSpaceInvitationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_AcceptSpaceInvitation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AcceptSpaceInvitationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).AcceptSpaceInvitation(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_AcceptSpaceInvitation_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).AcceptSpaceInvitation(ctx, req.(*AcceptSpaceInvitationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SpaceService_DeclineSpaceInvitation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeclineSpaceInvitationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SpaceServiceServer).DeclineSpaceInvitation(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SpaceService_DeclineSpaceInvitation_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SpaceServiceServer).DeclineSpaceInvitation(ctx, req.(*DeclineSpaceInvitationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// SpaceService_ServiceDesc is the grpc.ServiceDesc for SpaceService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var SpaceService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "memos.api.v1.SpaceService",
|
||||
ServiceName: "memos.api.SpaceService",
|
||||
HandlerType: (*SpaceServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "CreateSpace",
|
||||
Handler: _SpaceService_CreateSpace_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListSpaces",
|
||||
Handler: _SpaceService_ListSpaces_Handler,
|
||||
@@ -676,6 +702,10 @@ var SpaceService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetSpace",
|
||||
Handler: _SpaceService_GetSpace_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateSpace",
|
||||
Handler: _SpaceService_CreateSpace_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateSpace",
|
||||
Handler: _SpaceService_UpdateSpace_Handler,
|
||||
@@ -684,34 +714,6 @@ var SpaceService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "DeleteSpace",
|
||||
Handler: _SpaceService_DeleteSpace_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateSpaceInvitation",
|
||||
Handler: _SpaceService_CreateSpaceInvitation_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListSpaceInvitations",
|
||||
Handler: _SpaceService_ListSpaceInvitations_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListUserSpaceInvitations",
|
||||
Handler: _SpaceService_ListUserSpaceInvitations_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetSpaceInvitation",
|
||||
Handler: _SpaceService_GetSpaceInvitation_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteSpaceInvitation",
|
||||
Handler: _SpaceService_DeleteSpaceInvitation_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "AcceptSpaceInvitation",
|
||||
Handler: _SpaceService_AcceptSpaceInvitation_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeclineSpaceInvitation",
|
||||
Handler: _SpaceService_DeclineSpaceInvitation_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListSpaceMembers",
|
||||
Handler: _SpaceService_ListSpaceMembers_Handler,
|
||||
@@ -728,7 +730,35 @@ var SpaceService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "DeleteSpaceMember",
|
||||
Handler: _SpaceService_DeleteSpaceMember_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListSpaceInvitations",
|
||||
Handler: _SpaceService_ListSpaceInvitations_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListUserSpaceInvitations",
|
||||
Handler: _SpaceService_ListUserSpaceInvitations_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetSpaceInvitation",
|
||||
Handler: _SpaceService_GetSpaceInvitation_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateSpaceInvitation",
|
||||
Handler: _SpaceService_CreateSpaceInvitation_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteSpaceInvitation",
|
||||
Handler: _SpaceService_DeleteSpaceInvitation_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "AcceptSpaceInvitation",
|
||||
Handler: _SpaceService_AcceptSpaceInvitation_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeclineSpaceInvitation",
|
||||
Handler: _SpaceService_DeclineSpaceInvitation_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v1/space_service.proto",
|
||||
Metadata: "api/space_service.proto",
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+591
-537
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1359
-932
File diff suppressed because it is too large
Load Diff
@@ -218,6 +218,16 @@ set_current_base_url() {
|
||||
current_base_url="http://127.0.0.1:$port"
|
||||
}
|
||||
|
||||
# api_url prints the API root of the running container. Older releases serve the
|
||||
# API under /api/v1; current releases serve it under /api.
|
||||
api_url() {
|
||||
if curl --fail --silent --output /dev/null --max-time 2 "$current_base_url/api/instance/profile"; then
|
||||
printf '%s/api\n' "$current_base_url"
|
||||
else
|
||||
printf '%s/api/v1\n' "$current_base_url"
|
||||
fi
|
||||
}
|
||||
|
||||
start_container() {
|
||||
local container_name="$1"
|
||||
local image="$2"
|
||||
@@ -257,7 +267,7 @@ create_admin() {
|
||||
response="$(curl --fail --silent --show-error \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data "$payload" \
|
||||
"$current_base_url/api/v1/users")"
|
||||
"$(api_url)/users")"
|
||||
jq -e '.username == "smoke-admin" and .role == "ADMIN"' <<<"$response" >/dev/null
|
||||
}
|
||||
|
||||
@@ -267,7 +277,7 @@ sign_in() {
|
||||
curl --fail --silent --show-error \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data "$payload" \
|
||||
"$current_base_url/api/v1/auth/signin" | jq -er '.accessToken'
|
||||
"$(api_url)/auth/signin" | jq -er '.accessToken'
|
||||
}
|
||||
|
||||
create_memo() {
|
||||
@@ -280,7 +290,7 @@ create_memo() {
|
||||
--header "Authorization: Bearer $token" \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data "$payload" \
|
||||
"$current_base_url/api/v1/memos?memoId=$memo_id")"
|
||||
"$(api_url)/memos?memoId=$memo_id")"
|
||||
jq -e --arg name "memos/$memo_id" --arg content "$content" '.name == $name and .content == $content' <<<"$response" >/dev/null
|
||||
}
|
||||
|
||||
@@ -290,7 +300,7 @@ assert_memo() {
|
||||
local content="$3"
|
||||
curl --fail --silent --show-error \
|
||||
--header "Authorization: Bearer $token" \
|
||||
"$current_base_url/api/v1/memos/$memo_id" |
|
||||
"$(api_url)/memos/$memo_id" |
|
||||
jq -e --arg content "$content" '.content == $content' >/dev/null
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
// PublicMethods defines API endpoints that don't require authentication.
|
||||
// All other endpoints require a valid session or access token.
|
||||
@@ -10,40 +10,40 @@ package v1
|
||||
// or info.FullMethod (gRPC interceptor).
|
||||
var PublicMethods = map[string]struct{}{
|
||||
// Auth Service - login/token endpoints must be accessible without auth
|
||||
"/memos.api.v1.AuthService/SignIn": {},
|
||||
"/memos.api.v1.AuthService/RefreshToken": {}, // Token refresh uses cookie, must be accessible when access token expired
|
||||
"/memos.api.AuthService/SignIn": {},
|
||||
"/memos.api.AuthService/RefreshToken": {}, // Token refresh uses cookie, must be accessible when access token expired
|
||||
|
||||
// Instance Service - needed before login to show instance info
|
||||
"/memos.api.v1.InstanceService/GetInstanceProfile": {},
|
||||
"/memos.api.v1.InstanceService/GetInstanceSetting": {},
|
||||
"/memos.api.v1.InstanceService/BatchGetInstanceSettings": {},
|
||||
"/memos.api.InstanceService/GetInstanceProfile": {},
|
||||
"/memos.api.InstanceService/GetInstanceSetting": {},
|
||||
"/memos.api.InstanceService/BatchGetInstanceSettings": {},
|
||||
|
||||
// User Service - public user profiles and stats
|
||||
"/memos.api.v1.UserService/CreateUser": {}, // Registration policy is enforced in UserService
|
||||
"/memos.api.v1.UserService/GetUser": {},
|
||||
"/memos.api.v1.UserService/BatchGetUsers": {},
|
||||
"/memos.api.v1.UserService/GetUserAvatar": {},
|
||||
"/memos.api.v1.UserService/GetUserStats": {},
|
||||
"/memos.api.v1.UserService/ListAllUserStats": {},
|
||||
"/memos.api.UserService/CreateUser": {}, // Registration policy is enforced in UserService
|
||||
"/memos.api.UserService/GetUser": {},
|
||||
"/memos.api.UserService/BatchGetUsers": {},
|
||||
"/memos.api.UserService/GetUserAvatar": {},
|
||||
"/memos.api.UserService/GetUserStats": {},
|
||||
"/memos.api.UserService/ListUserStats": {},
|
||||
|
||||
// Identity Provider Service - SSO buttons on login page
|
||||
"/memos.api.v1.IdentityProviderService/ListIdentityProviders": {},
|
||||
"/memos.api.IdentityProviderService/ListIdentityProviders": {},
|
||||
|
||||
// Memo Service - public memos (visibility filtering done in service layer)
|
||||
"/memos.api.v1.MemoService/GetMemo": {},
|
||||
"/memos.api.v1.MemoService/ListMemos": {},
|
||||
"/memos.api.v1.MemoService/ListMemoComments": {},
|
||||
"/memos.api.v1.MemoService/ListMemoAttachments": {},
|
||||
"/memos.api.v1.MemoService/ListMemoReactions": {},
|
||||
"/memos.api.v1.MemoService/ListMemoRelations": {},
|
||||
"/memos.api.v1.MemoService/GetLinkMetadata": {},
|
||||
"/memos.api.v1.MemoService/BatchGetLinkMetadata": {},
|
||||
"/memos.api.MemoService/GetMemo": {},
|
||||
"/memos.api.MemoService/ListMemos": {},
|
||||
"/memos.api.MemoService/ListMemoComments": {},
|
||||
"/memos.api.MemoService/ListMemoAttachments": {},
|
||||
"/memos.api.MemoService/ListMemoReactions": {},
|
||||
"/memos.api.MemoService/ListMemoRelations": {},
|
||||
"/memos.api.MemoService/GetLinkMetadata": {},
|
||||
"/memos.api.MemoService/BatchGetLinkMetadata": {},
|
||||
|
||||
// Attachment metadata follows the visibility of its linked memo.
|
||||
"/memos.api.v1.AttachmentService/GetAttachment": {},
|
||||
"/memos.api.AttachmentService/GetAttachment": {},
|
||||
|
||||
// Memo sharing - share-token endpoints require no authentication
|
||||
"/memos.api.v1.MemoService/GetSharedMemo": {},
|
||||
"/memos.api.MemoService/GetSharedMemo": {},
|
||||
}
|
||||
|
||||
// IsPublicMethod checks if a procedure path is public (no authentication required).
|
||||
@@ -61,22 +61,22 @@ func IsPublicMethod(procedure string) bool {
|
||||
// MUST also exist in PublicMethods.
|
||||
var AuthBootstrapMethods = map[string]struct{}{
|
||||
// Auth Service - sign-in and token refresh.
|
||||
"/memos.api.v1.AuthService/SignIn": {},
|
||||
"/memos.api.v1.AuthService/RefreshToken": {},
|
||||
"/memos.api.AuthService/SignIn": {},
|
||||
"/memos.api.AuthService/RefreshToken": {},
|
||||
|
||||
// Instance Service - needed to render the sign-in page (branding, auth options).
|
||||
"/memos.api.v1.InstanceService/GetInstanceProfile": {},
|
||||
"/memos.api.v1.InstanceService/GetInstanceSetting": {},
|
||||
"/memos.api.v1.InstanceService/BatchGetInstanceSettings": {},
|
||||
"/memos.api.InstanceService/GetInstanceProfile": {},
|
||||
"/memos.api.InstanceService/GetInstanceSetting": {},
|
||||
"/memos.api.InstanceService/BatchGetInstanceSettings": {},
|
||||
|
||||
// Identity Provider Service - SSO buttons on the sign-in page.
|
||||
"/memos.api.v1.IdentityProviderService/ListIdentityProviders": {},
|
||||
"/memos.api.IdentityProviderService/ListIdentityProviders": {},
|
||||
|
||||
// User Service - CreateUser applies registration and password-auth settings.
|
||||
"/memos.api.v1.UserService/CreateUser": {},
|
||||
"/memos.api.UserService/CreateUser": {},
|
||||
|
||||
// Memo sharing - share-token access stays public even on a private instance.
|
||||
"/memos.api.v1.MemoService/GetSharedMemo": {},
|
||||
"/memos.api.MemoService/GetSharedMemo": {},
|
||||
}
|
||||
|
||||
// IsAuthBootstrapMethod reports whether an anonymous request to procedure is one
|
||||
@@ -0,0 +1,165 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// TestPublicMethodsArePublic verifies that methods in PublicMethods are recognized as public.
|
||||
func TestPublicMethodsArePublic(t *testing.T) {
|
||||
publicMethods := []string{
|
||||
// Auth Service
|
||||
"/memos.api.AuthService/SignIn",
|
||||
"/memos.api.AuthService/RefreshToken",
|
||||
// Instance Service
|
||||
"/memos.api.InstanceService/GetInstanceProfile",
|
||||
"/memos.api.InstanceService/GetInstanceSetting",
|
||||
"/memos.api.InstanceService/BatchGetInstanceSettings",
|
||||
// User Service
|
||||
"/memos.api.UserService/CreateUser",
|
||||
"/memos.api.UserService/GetUser",
|
||||
"/memos.api.UserService/BatchGetUsers",
|
||||
"/memos.api.UserService/GetUserAvatar",
|
||||
"/memos.api.UserService/GetUserStats",
|
||||
"/memos.api.UserService/ListUserStats",
|
||||
// Identity Provider Service
|
||||
"/memos.api.IdentityProviderService/ListIdentityProviders",
|
||||
// Memo Service
|
||||
"/memos.api.MemoService/GetMemo",
|
||||
"/memos.api.MemoService/ListMemos",
|
||||
"/memos.api.MemoService/ListMemoComments",
|
||||
"/memos.api.MemoService/ListMemoAttachments",
|
||||
"/memos.api.MemoService/ListMemoReactions",
|
||||
"/memos.api.MemoService/ListMemoRelations",
|
||||
"/memos.api.MemoService/GetLinkMetadata",
|
||||
"/memos.api.MemoService/BatchGetLinkMetadata",
|
||||
// Attachment Service metadata follows linked memo visibility.
|
||||
"/memos.api.AttachmentService/GetAttachment",
|
||||
}
|
||||
|
||||
for _, method := range publicMethods {
|
||||
t.Run(method, func(t *testing.T) {
|
||||
assert.True(t, IsPublicMethod(method), "Expected %s to be public", method)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestProtectedMethodsRequireAuth verifies that non-public methods are recognized as protected.
|
||||
func TestProtectedMethodsRequireAuth(t *testing.T) {
|
||||
protectedMethods := []string{
|
||||
"/memos.api.AttachmentService/UploadAttachment",
|
||||
// Auth Service - logout and get current user require auth
|
||||
"/memos.api.AuthService/SignOut",
|
||||
"/memos.api.AuthService/GetCurrentUser",
|
||||
// Instance Service - admin operations
|
||||
"/memos.api.InstanceService/UpdateInstanceSetting",
|
||||
"/memos.api.InstanceService/TestInstanceEmailSetting",
|
||||
// User Service - modification operations
|
||||
"/memos.api.UserService/ListUsers",
|
||||
"/memos.api.UserService/UpdateUser",
|
||||
"/memos.api.UserService/DeleteUser",
|
||||
// Memo Service - write operations
|
||||
"/memos.api.MemoService/CreateMemo",
|
||||
"/memos.api.MemoService/UpdateMemo",
|
||||
"/memos.api.MemoService/DeleteMemo",
|
||||
// Space Service - every operation requires an authenticated member.
|
||||
"/memos.api.SpaceService/CreateSpace",
|
||||
"/memos.api.SpaceService/ListSpaces",
|
||||
"/memos.api.SpaceService/GetSpace",
|
||||
"/memos.api.SpaceService/UpdateSpace",
|
||||
"/memos.api.SpaceService/DeleteSpace",
|
||||
"/memos.api.SpaceService/CreateSpaceInvitation",
|
||||
"/memos.api.SpaceService/ListSpaceInvitations",
|
||||
"/memos.api.SpaceService/ListUserSpaceInvitations",
|
||||
"/memos.api.SpaceService/GetSpaceInvitation",
|
||||
"/memos.api.SpaceService/DeleteSpaceInvitation",
|
||||
"/memos.api.SpaceService/AcceptSpaceInvitation",
|
||||
"/memos.api.SpaceService/DeclineSpaceInvitation",
|
||||
"/memos.api.SpaceService/ListSpaceMembers",
|
||||
"/memos.api.SpaceService/GetSpaceMember",
|
||||
"/memos.api.SpaceService/UpdateSpaceMember",
|
||||
"/memos.api.SpaceService/DeleteSpaceMember",
|
||||
// Attachment Service - write operations
|
||||
"/memos.api.AttachmentService/CreateAttachment",
|
||||
"/memos.api.AttachmentService/DeleteAttachment",
|
||||
// User Service - saved memo views
|
||||
"/memos.api.UserService/CreateMemoView",
|
||||
"/memos.api.UserService/GetMemoView",
|
||||
"/memos.api.UserService/ListMemoViews",
|
||||
"/memos.api.UserService/UpdateMemoView",
|
||||
"/memos.api.UserService/DeleteMemoView",
|
||||
}
|
||||
|
||||
for _, method := range protectedMethods {
|
||||
t.Run(method, func(t *testing.T) {
|
||||
assert.False(t, IsPublicMethod(method), "Expected %s to require auth", method)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestUnknownMethodsRequireAuth verifies that unknown methods default to requiring auth.
|
||||
func TestUnknownMethodsRequireAuth(t *testing.T) {
|
||||
unknownMethods := []string{
|
||||
"/unknown.Service/Method",
|
||||
"/memos.api.UnknownService/Method",
|
||||
"",
|
||||
"invalid",
|
||||
}
|
||||
|
||||
for _, method := range unknownMethods {
|
||||
t.Run(method, func(t *testing.T) {
|
||||
assert.False(t, IsPublicMethod(method), "Unknown method %q should require auth", method)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestAuthBootstrapMethodsAreSubsetOfPublic verifies every auth-bootstrap method is
|
||||
// also a public method. A bootstrap method that wasn't public would be rejected before
|
||||
// the private-instance check runs, breaking sign-in on a private instance.
|
||||
func TestAuthBootstrapMethodsAreSubsetOfPublic(t *testing.T) {
|
||||
for method := range AuthBootstrapMethods {
|
||||
t.Run(method, func(t *testing.T) {
|
||||
assert.True(t, IsPublicMethod(method), "auth-bootstrap method %s must also be a public method", method)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestAuthBootstrapClassification verifies which endpoints remain reachable by
|
||||
// anonymous callers when the instance access mode is PRIVATE.
|
||||
func TestAuthBootstrapClassification(t *testing.T) {
|
||||
// Reachable while private: sign-in flow, registration, instance metadata, SSO, share links.
|
||||
bootstrap := []string{
|
||||
"/memos.api.AuthService/SignIn",
|
||||
"/memos.api.AuthService/RefreshToken",
|
||||
"/memos.api.UserService/CreateUser",
|
||||
"/memos.api.InstanceService/GetInstanceProfile",
|
||||
"/memos.api.InstanceService/GetInstanceSetting",
|
||||
"/memos.api.InstanceService/BatchGetInstanceSettings",
|
||||
"/memos.api.IdentityProviderService/ListIdentityProviders",
|
||||
"/memos.api.MemoService/GetSharedMemo",
|
||||
}
|
||||
for _, method := range bootstrap {
|
||||
t.Run("bootstrap/"+method, func(t *testing.T) {
|
||||
assert.True(t, IsAuthBootstrapMethod(method), "expected %s to be reachable on a private instance", method)
|
||||
})
|
||||
}
|
||||
|
||||
// Public in PUBLIC mode, but gated in PRIVATE mode: browsing and profiles.
|
||||
gatedWhilePrivate := []string{
|
||||
"/memos.api.MemoService/ListMemos",
|
||||
"/memos.api.MemoService/GetMemo",
|
||||
"/memos.api.MemoService/ListMemoComments",
|
||||
"/memos.api.MemoService/ListMemoAttachments",
|
||||
"/memos.api.MemoService/ListMemoReactions",
|
||||
"/memos.api.MemoService/ListMemoRelations",
|
||||
"/memos.api.AttachmentService/GetAttachment",
|
||||
"/memos.api.UserService/GetUser",
|
||||
"/memos.api.UserService/ListUserStats",
|
||||
}
|
||||
for _, method := range gatedWhilePrivate {
|
||||
t.Run("gated/"+method, func(t *testing.T) {
|
||||
assert.False(t, IsAuthBootstrapMethod(method), "expected %s to be gated on a private instance", method)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/usememos/memos/internal/ratelimit"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/provider/ai"
|
||||
"github.com/usememos/memos/provider/ai/audiollm"
|
||||
@@ -46,7 +46,7 @@ var supportedTranscriptionContentTypes = map[string]bool{
|
||||
}
|
||||
|
||||
// Transcribe transcribes an audio file using an instance AI provider.
|
||||
func (s *APIV1Service) Transcribe(ctx context.Context, request *v1pb.TranscribeRequest) (*v1pb.TranscribeResponse, error) {
|
||||
func (s *APIService) Transcribe(ctx context.Context, request *apipb.TranscribeRequest) (*apipb.TranscribeResponse, error) {
|
||||
user, err := s.fetchCurrentUser(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get current user: %v", err)
|
||||
@@ -121,10 +121,10 @@ func (s *APIV1Service) Transcribe(ctx context.Context, request *v1pb.TranscribeR
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to transcribe audio: %v", err)
|
||||
}
|
||||
return &v1pb.TranscribeResponse{Text: text}, nil
|
||||
return &apipb.TranscribeResponse{Text: text}, nil
|
||||
}
|
||||
|
||||
func (*APIV1Service) transcribeViaSTT(
|
||||
func (*APIService) transcribeViaSTT(
|
||||
ctx context.Context,
|
||||
provider ai.ProviderConfig,
|
||||
persisted *storepb.TranscriptionConfig,
|
||||
@@ -152,7 +152,7 @@ func (*APIV1Service) transcribeViaSTT(
|
||||
return resp.Text, nil
|
||||
}
|
||||
|
||||
func (*APIV1Service) transcribeViaAudioLLM(
|
||||
func (*APIService) transcribeViaAudioLLM(
|
||||
ctx context.Context,
|
||||
provider ai.ProviderConfig,
|
||||
persisted *storepb.TranscriptionConfig,
|
||||
@@ -197,7 +197,7 @@ func buildTranscriptionInstructions(prompt, language string) string {
|
||||
return strings.Join(parts, "\n\n")
|
||||
}
|
||||
|
||||
func (*APIV1Service) resolveAIProvider(setting *storepb.InstanceAISetting, providerID string) (ai.ProviderConfig, error) {
|
||||
func (*APIService) resolveAIProvider(setting *storepb.InstanceAISetting, providerID string) (ai.ProviderConfig, error) {
|
||||
providers := make([]ai.ProviderConfig, 0, len(setting.GetProviders()))
|
||||
for _, provider := range setting.GetProviders() {
|
||||
if provider == nil {
|
||||
@@ -1,10 +1,11 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
|
||||
@@ -19,7 +20,7 @@ import (
|
||||
"github.com/usememos/memos/internal/profile"
|
||||
"github.com/usememos/memos/internal/ratelimit"
|
||||
"github.com/usememos/memos/markdown"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
"github.com/usememos/memos/server/auth"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
@@ -39,8 +40,8 @@ const maxGeneralRequestBytes = 16 << 20
|
||||
// the large cap; the size of that content is checked again by the handler
|
||||
// against the instance upload limit.
|
||||
var inlineContentProcedures = map[string]struct{}{
|
||||
"/memos.api.v1.AttachmentService/CreateAttachment": {},
|
||||
"/memos.api.v1.AIService/Transcribe": {},
|
||||
"/memos.api.AttachmentService/CreateAttachment": {},
|
||||
"/memos.api.AIService/Transcribe": {},
|
||||
}
|
||||
|
||||
// requestBodyLimit returns the request body cap for a procedure. Chunked
|
||||
@@ -55,15 +56,15 @@ func requestBodyLimit(procedure string) int64 {
|
||||
return maxGeneralRequestBytes
|
||||
}
|
||||
|
||||
type APIV1Service struct {
|
||||
v1pb.UnimplementedInstanceServiceServer
|
||||
v1pb.UnimplementedAuthServiceServer
|
||||
v1pb.UnimplementedUserServiceServer
|
||||
v1pb.UnimplementedMemoServiceServer
|
||||
v1pb.UnimplementedSpaceServiceServer
|
||||
v1pb.UnimplementedAttachmentServiceServer
|
||||
v1pb.UnimplementedAIServiceServer
|
||||
v1pb.UnimplementedIdentityProviderServiceServer
|
||||
type APIService struct {
|
||||
apipb.UnimplementedInstanceServiceServer
|
||||
apipb.UnimplementedAuthServiceServer
|
||||
apipb.UnimplementedUserServiceServer
|
||||
apipb.UnimplementedMemoServiceServer
|
||||
apipb.UnimplementedSpaceServiceServer
|
||||
apipb.UnimplementedAttachmentServiceServer
|
||||
apipb.UnimplementedAIServiceServer
|
||||
apipb.UnimplementedIdentityProviderServiceServer
|
||||
|
||||
Secret string
|
||||
Profile *profile.Profile
|
||||
@@ -93,13 +94,13 @@ type APIV1Service struct {
|
||||
memoImports memoImports
|
||||
}
|
||||
|
||||
// NewAPIV1Service creates an API v1 service with its shared dependencies.
|
||||
func NewAPIV1Service(secret string, profile *profile.Profile, store *store.Store) *APIV1Service {
|
||||
// NewAPIService creates an API v1 service with its shared dependencies.
|
||||
func NewAPIService(secret string, profile *profile.Profile, store *store.Store) *APIService {
|
||||
markdownService := markdown.NewService(
|
||||
markdown.WithTagExtension(),
|
||||
markdown.WithMentionExtension(),
|
||||
)
|
||||
service := &APIV1Service{
|
||||
service := &APIService{
|
||||
Secret: secret,
|
||||
Profile: profile,
|
||||
Store: store,
|
||||
@@ -134,7 +135,7 @@ func newGatewayMarshaler() *runtime.HTTPBodyMarshaler {
|
||||
}
|
||||
|
||||
// RegisterGateway registers the gRPC-Gateway and Connect handlers with the given Echo instance.
|
||||
func (s *APIV1Service) RegisterGateway(ctx context.Context, echoServer *echo.Echo) error {
|
||||
func (s *APIService) RegisterGateway(ctx context.Context, echoServer *echo.Echo) error {
|
||||
// Shared authorizer: one source of truth for authentication and anonymous-access
|
||||
// policy, used by both the gRPC-Gateway middleware and the Connect interceptor.
|
||||
authorizer := NewAuthorizer(s.Store, s.Secret).WithRateLimiter(s.RateLimiter)
|
||||
@@ -190,37 +191,38 @@ func (s *APIV1Service) RegisterGateway(ctx context.Context, echoServer *echo.Ech
|
||||
runtime.WithErrorHandler(gatewayErrorHandler),
|
||||
runtime.WithIncomingHeaderMatcher(gatewayIncomingHeaderMatcher),
|
||||
)
|
||||
if err := v1pb.RegisterInstanceServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
if err := apipb.RegisterInstanceServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := v1pb.RegisterAuthServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
if err := apipb.RegisterAuthServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := v1pb.RegisterUserServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
if err := apipb.RegisterUserServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := v1pb.RegisterMemoServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
if err := apipb.RegisterMemoServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := v1pb.RegisterSpaceServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
if err := apipb.RegisterSpaceServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := v1pb.RegisterAttachmentServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
if err := apipb.RegisterAttachmentServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := v1pb.RegisterAIServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
if err := apipb.RegisterAIServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := v1pb.RegisterIdentityProviderServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
if err := apipb.RegisterIdentityProviderServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
return err
|
||||
}
|
||||
gwGroup := echoServer.Group("")
|
||||
// Register SSE endpoint with same CORS as rest of /api/v1.
|
||||
// Register SSE endpoint with same CORS as rest of /api.
|
||||
RegisterSSERoutes(gwGroup, s.SSEHub, s.Store, s.Secret)
|
||||
handler := echo.WrapHandler(gwMux)
|
||||
|
||||
gwGroup.Any("/api/v1/*", handler)
|
||||
gwGroup.Any("/api/*", handler)
|
||||
gwGroup.Any("/file/*", handler)
|
||||
gwGroup.Any("/api/v1/*", removedAPIVersionHandler(false))
|
||||
|
||||
// Connect handlers for browser clients (replaces grpc-web).
|
||||
logStacktraces := s.Profile.Demo
|
||||
@@ -239,14 +241,32 @@ func (s *APIV1Service) RegisterGateway(ctx context.Context, echoServer *echo.Ech
|
||||
}))
|
||||
|
||||
connectGroup := echoServer.Group("")
|
||||
connectGroup.Any("/memos.api.v1.*", echo.WrapHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
connectGroup.Any("/memos.api.*", echo.WrapHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Body = http.MaxBytesReader(w, r.Body, requestBodyLimit(r.URL.Path))
|
||||
connectMux.ServeHTTP(w, r)
|
||||
})))
|
||||
connectGroup.Any("/memos.api.v1.*", removedAPIVersionHandler(true))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// removedAPIMessage tells clients of the removed v1 API where it went.
|
||||
const removedAPIMessage = "API v1 has been removed. Use /api/... for REST and /memos.api.<Service>/<Method> for Connect. " +
|
||||
"See https://github.com/usememos/memos/blob/main/proto/api/CHANGELOG.md"
|
||||
|
||||
// removedAPIVersionHandler answers requests to the removed /api/v1 and
|
||||
// memos.api.v1 routes with 410 Gone, in the error body shape each transport's
|
||||
// clients decode. It exists for one release so old clients fail with a
|
||||
// pointer to the migration; delete it in the release after.
|
||||
func removedAPIVersionHandler(connectProtocol bool) echo.HandlerFunc {
|
||||
return func(c *echo.Context) error {
|
||||
if connectProtocol {
|
||||
return c.JSON(http.StatusGone, map[string]string{"code": connect.CodeUnimplemented.String(), "message": removedAPIMessage})
|
||||
}
|
||||
return c.JSON(http.StatusGone, map[string]any{"code": int(codes.Unimplemented), "message": removedAPIMessage})
|
||||
}
|
||||
}
|
||||
|
||||
func setAPIResponseNoStoreHeaders(header http.Header) {
|
||||
header.Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
header.Set("Pragma", "no-cache")
|
||||
@@ -0,0 +1,49 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestRemovedAPIVersionRoutesReturnGone(t *testing.T) {
|
||||
svc, _ := newUploadTestService(t)
|
||||
e := echo.New()
|
||||
require.NoError(t, svc.RegisterGateway(context.Background(), e))
|
||||
|
||||
tests := []struct {
|
||||
method string
|
||||
path string
|
||||
wantCode any
|
||||
}{
|
||||
{http.MethodGet, "/api/v1/memos", float64(12)},
|
||||
{http.MethodPost, "/api/v1/auth/signin", float64(12)},
|
||||
{http.MethodPost, "/memos.api.v1.MemoService/ListMemos", "unimplemented"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.path, func(t *testing.T) {
|
||||
req := httptest.NewRequest(tt.method, tt.path, strings.NewReader("{}"))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
rec := httptest.NewRecorder()
|
||||
e.ServeHTTP(rec, req)
|
||||
|
||||
require.Equal(t, http.StatusGone, rec.Code)
|
||||
var body map[string]any
|
||||
require.NoError(t, json.Unmarshal(rec.Body.Bytes(), &body))
|
||||
require.Equal(t, tt.wantCode, body["code"])
|
||||
require.Equal(t, removedAPIMessage, body["message"])
|
||||
})
|
||||
}
|
||||
|
||||
// The current routes are unaffected.
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/instance/profile", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
e.ServeHTTP(rec, req)
|
||||
require.Equal(t, http.StatusOK, rec.Code)
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestCreateAttachmentStripsExifFromMislabeledJPEG(t *testing.T) {
|
||||
content := jpegWithExifMarker(t)
|
||||
require.Contains(t, string(content), exifTestMarker)
|
||||
|
||||
created, err := svc.CreateAttachment(userCtx(ctx, user.ID), &v1pb.CreateAttachmentRequest{Attachment: &v1pb.Attachment{
|
||||
created, err := svc.CreateAttachment(userCtx(ctx, user.ID), &apipb.CreateAttachmentRequest{Attachment: &apipb.Attachment{
|
||||
Filename: "photo.bin", Type: "application/octet-stream", Content: content,
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
+10
-10
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"math"
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
)
|
||||
|
||||
@@ -24,7 +24,7 @@ var (
|
||||
mediaUTCOffsetPattern = regexp.MustCompile(`^[+-](\d{2}):(\d{2})$`)
|
||||
)
|
||||
|
||||
func validateClientMediaMetadata(metadata *v1pb.MediaMetadata, mimeType string) (*storepb.MediaMetadata, error) {
|
||||
func validateClientMediaMetadata(metadata *apipb.MediaMetadata, mimeType string) (*storepb.MediaMetadata, error) {
|
||||
if metadata == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -48,7 +48,7 @@ func validateClientMediaMetadata(metadata *v1pb.MediaMetadata, mimeType string)
|
||||
if metadata.Width == nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "media_metadata must contain at least one value")
|
||||
}
|
||||
case *v1pb.MediaMetadata_Photo:
|
||||
case *apipb.MediaMetadata_Photo:
|
||||
if !isImage {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "photo metadata requires an image MIME type")
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func validateClientMediaMetadata(metadata *v1pb.MediaMetadata, mimeType string)
|
||||
if err := validatePhotoMetadata(details.Photo); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case *v1pb.MediaMetadata_Video:
|
||||
case *apipb.MediaMetadata_Video:
|
||||
if !isVideo {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "video metadata requires a video MIME type")
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func validateClientMediaMetadata(metadata *v1pb.MediaMetadata, mimeType string)
|
||||
return storeMetadata, nil
|
||||
}
|
||||
|
||||
func validatePhotoMetadata(photo *v1pb.PhotoMetadata) error {
|
||||
func validatePhotoMetadata(photo *apipb.PhotoMetadata) error {
|
||||
if photo.SourceExifOrientation != nil && (*photo.SourceExifOrientation < 1 || *photo.SourceExifOrientation > 8) {
|
||||
return status.Errorf(codes.InvalidArgument, "photo source_exif_orientation must be between 1 and 8")
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func validatePhotoMetadata(photo *v1pb.PhotoMetadata) error {
|
||||
return validateMediaLocation(photo.Location)
|
||||
}
|
||||
|
||||
func validateMediaCaptureTime(captureTime *v1pb.MediaCaptureTime) error {
|
||||
func validateMediaCaptureTime(captureTime *apipb.MediaCaptureTime) error {
|
||||
if captureTime == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -154,7 +154,7 @@ func validateMediaCaptureTime(captureTime *v1pb.MediaCaptureTime) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateMediaLocation(location *v1pb.MediaLocation) error {
|
||||
func validateMediaLocation(location *apipb.MediaLocation) error {
|
||||
if location == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -192,11 +192,11 @@ func transcodeProto(src, dst proto.Message) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertMediaMetadataFromStore(metadata *storepb.MediaMetadata) *v1pb.MediaMetadata {
|
||||
func convertMediaMetadataFromStore(metadata *storepb.MediaMetadata) *apipb.MediaMetadata {
|
||||
if metadata == nil {
|
||||
return nil
|
||||
}
|
||||
apiMetadata := &v1pb.MediaMetadata{}
|
||||
apiMetadata := &apipb.MediaMetadata{}
|
||||
if err := transcodeProto(metadata, apiMetadata); err != nil {
|
||||
return nil
|
||||
}
|
||||
+36
-36
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"math"
|
||||
@@ -10,22 +10,22 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
)
|
||||
|
||||
func TestValidateClientMediaMetadata(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
validPhoto := func() *v1pb.MediaMetadata {
|
||||
return &v1pb.MediaMetadata{
|
||||
validPhoto := func() *apipb.MediaMetadata {
|
||||
return &apipb.MediaMetadata{
|
||||
Width: proto.Int32(4032),
|
||||
Height: proto.Int32(3024),
|
||||
Details: &v1pb.MediaMetadata_Photo{Photo: &v1pb.PhotoMetadata{
|
||||
CaptureTime: &v1pb.MediaCaptureTime{
|
||||
Details: &apipb.MediaMetadata_Photo{Photo: &apipb.PhotoMetadata{
|
||||
CaptureTime: &apipb.MediaCaptureTime{
|
||||
LocalDateTime: "2026-08-10T14:32:18.123",
|
||||
UtcOffset: proto.String("+08:00"),
|
||||
},
|
||||
Location: &v1pb.MediaLocation{
|
||||
Location: &apipb.MediaLocation{
|
||||
Latitude: proto.Float64(1.3521),
|
||||
Longitude: proto.Float64(103.8198),
|
||||
AltitudeMeters: proto.Float64(18.4),
|
||||
@@ -50,7 +50,7 @@ func TestValidateClientMediaMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("accepts dimensions without details", func(t *testing.T) {
|
||||
metadata, err := validateClientMediaMetadata(&v1pb.MediaMetadata{
|
||||
metadata, err := validateClientMediaMetadata(&apipb.MediaMetadata{
|
||||
Width: proto.Int32(1920), Height: proto.Int32(1080),
|
||||
}, "video/mp4")
|
||||
require.NoError(t, err)
|
||||
@@ -58,8 +58,8 @@ func TestValidateClientMediaMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("accepts video metadata", func(t *testing.T) {
|
||||
metadata, err := validateClientMediaMetadata(&v1pb.MediaMetadata{
|
||||
Details: &v1pb.MediaMetadata_Video{Video: &v1pb.VideoMetadata{DurationSeconds: proto.Float64(12.5)}},
|
||||
metadata, err := validateClientMediaMetadata(&apipb.MediaMetadata{
|
||||
Details: &apipb.MediaMetadata_Video{Video: &apipb.VideoMetadata{DurationSeconds: proto.Float64(12.5)}},
|
||||
}, "video/mp4")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 12.5, metadata.GetVideo().GetDurationSeconds())
|
||||
@@ -72,8 +72,8 @@ func TestValidateClientMediaMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("accepts Z UTC offset", func(t *testing.T) {
|
||||
metadata, err := validateClientMediaMetadata(photoOnly(&v1pb.PhotoMetadata{
|
||||
CaptureTime: &v1pb.MediaCaptureTime{LocalDateTime: "2026-08-10T14:32:18", UtcOffset: proto.String("Z")},
|
||||
metadata, err := validateClientMediaMetadata(photoOnly(&apipb.PhotoMetadata{
|
||||
CaptureTime: &apipb.MediaCaptureTime{LocalDateTime: "2026-08-10T14:32:18", UtcOffset: proto.String("Z")},
|
||||
}), "image/jpeg")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Z", metadata.GetPhoto().GetCaptureTime().GetUtcOffset())
|
||||
@@ -82,31 +82,31 @@ func TestValidateClientMediaMetadata(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
mimeType string
|
||||
metadata *v1pb.MediaMetadata
|
||||
metadata *apipb.MediaMetadata
|
||||
}{
|
||||
{name: "empty", mimeType: "image/jpeg", metadata: &v1pb.MediaMetadata{}},
|
||||
{name: "empty", mimeType: "image/jpeg", metadata: &apipb.MediaMetadata{}},
|
||||
{name: "non-media MIME", mimeType: "application/pdf", metadata: validPhoto()},
|
||||
{name: "width without height", mimeType: "image/jpeg", metadata: &v1pb.MediaMetadata{Width: proto.Int32(100)}},
|
||||
{name: "non-positive dimension", mimeType: "image/jpeg", metadata: &v1pb.MediaMetadata{Width: proto.Int32(0), Height: proto.Int32(100)}},
|
||||
{name: "width without height", mimeType: "image/jpeg", metadata: &apipb.MediaMetadata{Width: proto.Int32(100)}},
|
||||
{name: "non-positive dimension", mimeType: "image/jpeg", metadata: &apipb.MediaMetadata{Width: proto.Int32(0), Height: proto.Int32(100)}},
|
||||
{name: "photo on video", mimeType: "video/mp4", metadata: validPhoto()},
|
||||
{name: "empty photo", mimeType: "image/jpeg", metadata: &v1pb.MediaMetadata{Details: &v1pb.MediaMetadata_Photo{Photo: &v1pb.PhotoMetadata{}}}},
|
||||
{name: "video on image", mimeType: "image/jpeg", metadata: &v1pb.MediaMetadata{Details: &v1pb.MediaMetadata_Video{Video: &v1pb.VideoMetadata{DurationSeconds: proto.Float64(1)}}}},
|
||||
{name: "empty video", mimeType: "video/mp4", metadata: &v1pb.MediaMetadata{Details: &v1pb.MediaMetadata_Video{Video: &v1pb.VideoMetadata{}}}},
|
||||
{name: "invalid source EXIF orientation", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{SourceExifOrientation: proto.Int32(9)})},
|
||||
{name: "blank camera make", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{CameraMake: " "})},
|
||||
{name: "control character in camera make", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{CameraMake: "Apple\nCo"})},
|
||||
{name: "null byte in lens model", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{LensModel: "Main\x00Camera"})},
|
||||
{name: "long camera model", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{CameraModel: strings.Repeat("x", maxMediaMetadataStringBytes+1)})},
|
||||
{name: "non-finite aperture", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{FNumber: proto.Float64(math.NaN())})},
|
||||
{name: "zero exposure", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{ExposureTimeSeconds: proto.Float64(0)})},
|
||||
{name: "zero ISO", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{Iso: proto.Int32(0)})},
|
||||
{name: "invalid capture format", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{CaptureTime: &v1pb.MediaCaptureTime{LocalDateTime: "2026:08:10 14:32:18"}})},
|
||||
{name: "invalid calendar date", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{CaptureTime: &v1pb.MediaCaptureTime{LocalDateTime: "2026-02-30T14:32:18"}})},
|
||||
{name: "invalid offset", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{CaptureTime: &v1pb.MediaCaptureTime{LocalDateTime: "2026-08-10T14:32:18", UtcOffset: proto.String("+14:30")}})},
|
||||
{name: "missing longitude", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{Location: &v1pb.MediaLocation{Latitude: proto.Float64(1)}})},
|
||||
{name: "latitude out of range", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{Location: &v1pb.MediaLocation{Latitude: proto.Float64(91), Longitude: proto.Float64(1)}})},
|
||||
{name: "non-finite altitude", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{Location: &v1pb.MediaLocation{Latitude: proto.Float64(1), Longitude: proto.Float64(1), AltitudeMeters: proto.Float64(math.Inf(1))}})},
|
||||
{name: "negative duration", mimeType: "video/mp4", metadata: &v1pb.MediaMetadata{Details: &v1pb.MediaMetadata_Video{Video: &v1pb.VideoMetadata{DurationSeconds: proto.Float64(-1)}}}},
|
||||
{name: "empty photo", mimeType: "image/jpeg", metadata: &apipb.MediaMetadata{Details: &apipb.MediaMetadata_Photo{Photo: &apipb.PhotoMetadata{}}}},
|
||||
{name: "video on image", mimeType: "image/jpeg", metadata: &apipb.MediaMetadata{Details: &apipb.MediaMetadata_Video{Video: &apipb.VideoMetadata{DurationSeconds: proto.Float64(1)}}}},
|
||||
{name: "empty video", mimeType: "video/mp4", metadata: &apipb.MediaMetadata{Details: &apipb.MediaMetadata_Video{Video: &apipb.VideoMetadata{}}}},
|
||||
{name: "invalid source EXIF orientation", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{SourceExifOrientation: proto.Int32(9)})},
|
||||
{name: "blank camera make", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{CameraMake: " "})},
|
||||
{name: "control character in camera make", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{CameraMake: "Apple\nCo"})},
|
||||
{name: "null byte in lens model", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{LensModel: "Main\x00Camera"})},
|
||||
{name: "long camera model", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{CameraModel: strings.Repeat("x", maxMediaMetadataStringBytes+1)})},
|
||||
{name: "non-finite aperture", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{FNumber: proto.Float64(math.NaN())})},
|
||||
{name: "zero exposure", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{ExposureTimeSeconds: proto.Float64(0)})},
|
||||
{name: "zero ISO", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{Iso: proto.Int32(0)})},
|
||||
{name: "invalid capture format", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{CaptureTime: &apipb.MediaCaptureTime{LocalDateTime: "2026:08:10 14:32:18"}})},
|
||||
{name: "invalid calendar date", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{CaptureTime: &apipb.MediaCaptureTime{LocalDateTime: "2026-02-30T14:32:18"}})},
|
||||
{name: "invalid offset", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{CaptureTime: &apipb.MediaCaptureTime{LocalDateTime: "2026-08-10T14:32:18", UtcOffset: proto.String("+14:30")}})},
|
||||
{name: "missing longitude", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{Location: &apipb.MediaLocation{Latitude: proto.Float64(1)}})},
|
||||
{name: "latitude out of range", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{Location: &apipb.MediaLocation{Latitude: proto.Float64(91), Longitude: proto.Float64(1)}})},
|
||||
{name: "non-finite altitude", mimeType: "image/jpeg", metadata: photoOnly(&apipb.PhotoMetadata{Location: &apipb.MediaLocation{Latitude: proto.Float64(1), Longitude: proto.Float64(1), AltitudeMeters: proto.Float64(math.Inf(1))}})},
|
||||
{name: "negative duration", mimeType: "video/mp4", metadata: &apipb.MediaMetadata{Details: &apipb.MediaMetadata_Video{Video: &apipb.VideoMetadata{DurationSeconds: proto.Float64(-1)}}}},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
@@ -118,6 +118,6 @@ func TestValidateClientMediaMetadata(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func photoOnly(photo *v1pb.PhotoMetadata) *v1pb.MediaMetadata {
|
||||
return &v1pb.MediaMetadata{Details: &v1pb.MediaMetadata_Photo{Photo: photo}}
|
||||
func photoOnly(photo *apipb.PhotoMetadata) *apipb.MediaMetadata {
|
||||
return &apipb.MediaMetadata{Details: &apipb.MediaMetadata_Photo{Photo: photo}}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -1,26 +1,26 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func convertMotionMediaFromStore(motion *storepb.MotionMedia) *v1pb.MotionMedia {
|
||||
func convertMotionMediaFromStore(motion *storepb.MotionMedia) *apipb.MotionMedia {
|
||||
if motion == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &v1pb.MotionMedia{
|
||||
Family: v1pb.MotionMediaFamily(motion.Family),
|
||||
Role: v1pb.MotionMediaRole(motion.Role),
|
||||
return &apipb.MotionMedia{
|
||||
Family: apipb.MotionMediaFamily(motion.Family),
|
||||
Role: apipb.MotionMediaRole(motion.Role),
|
||||
GroupId: motion.GroupId,
|
||||
PresentationTimestampUs: motion.PresentationTimestampUs,
|
||||
HasEmbeddedVideo: motion.HasEmbeddedVideo,
|
||||
}
|
||||
}
|
||||
|
||||
func convertMotionMediaToStore(motion *v1pb.MotionMedia) *storepb.MotionMedia {
|
||||
func convertMotionMediaToStore(motion *apipb.MotionMedia) *storepb.MotionMedia {
|
||||
if motion == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"github.com/usememos/memos/core/access"
|
||||
"github.com/usememos/memos/internal/motionphoto"
|
||||
"github.com/usememos/memos/internal/ratelimit"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
@@ -74,7 +74,7 @@ func detectAttachmentMimeType(filename string, content []byte) string {
|
||||
return http.DetectContentType(content)
|
||||
}
|
||||
|
||||
func (s *APIV1Service) prepareAttachment(ctx context.Context, request *v1pb.CreateAttachmentRequest) (*store.Attachment, error) {
|
||||
func (s *APIService) prepareAttachment(ctx context.Context, request *apipb.CreateAttachmentRequest) (*store.Attachment, error) {
|
||||
user, err := s.fetchCurrentUser(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get current user: %v", err)
|
||||
@@ -164,7 +164,7 @@ func (s *APIV1Service) prepareAttachment(ctx context.Context, request *v1pb.Crea
|
||||
return create, nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) CreateAttachment(ctx context.Context, request *v1pb.CreateAttachmentRequest) (*v1pb.Attachment, error) {
|
||||
func (s *APIService) CreateAttachment(ctx context.Context, request *apipb.CreateAttachmentRequest) (*apipb.Attachment, error) {
|
||||
create, err := s.prepareAttachment(ctx, request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -208,7 +208,7 @@ type attachmentSource interface {
|
||||
// processAndSaveAttachment detects motion photos, strips EXIF metadata, stores
|
||||
// the content, and creates the database row. create.Size must hold the source
|
||||
// length on entry; it is updated when stripping re-encodes the image.
|
||||
func (s *APIV1Service) processAndSaveAttachment(ctx context.Context, create *store.Attachment, instanceStorageSetting *storepb.InstanceStorageSetting, source attachmentSource) (*v1pb.Attachment, error) {
|
||||
func (s *APIService) processAndSaveAttachment(ctx context.Context, create *store.Attachment, instanceStorageSetting *storepb.InstanceStorageSetting, source attachmentSource) (*apipb.Attachment, error) {
|
||||
if create.Payload.GetMotionMedia() == nil && (create.Type == "image/jpeg" || create.Type == "image/jpg") {
|
||||
detected, err := motionphoto.DetectJPEGReader(source, create.Size)
|
||||
if err != nil {
|
||||
@@ -263,7 +263,7 @@ func (s *APIV1Service) processAndSaveAttachment(ctx context.Context, create *sto
|
||||
return s.persistAttachment(ctx, create, instanceStorageSetting)
|
||||
}
|
||||
|
||||
func (s *APIV1Service) persistAttachment(ctx context.Context, create *store.Attachment, instanceStorageSetting *storepb.InstanceStorageSetting) (*v1pb.Attachment, error) {
|
||||
func (s *APIService) persistAttachment(ctx context.Context, create *store.Attachment, instanceStorageSetting *storepb.InstanceStorageSetting) (*apipb.Attachment, error) {
|
||||
attachment, err := s.Store.CreateAttachment(ctx, create)
|
||||
if err != nil {
|
||||
createErr := mapMemoWriteError(err, "failed to create attachment")
|
||||
@@ -289,7 +289,7 @@ func (s *APIV1Service) persistAttachment(ctx context.Context, create *store.Atta
|
||||
return convertAttachmentFromStore(attachment), nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) ListAttachments(ctx context.Context, request *v1pb.ListAttachmentsRequest) (*v1pb.ListAttachmentsResponse, error) {
|
||||
func (s *APIService) ListAttachments(ctx context.Context, request *apipb.ListAttachmentsRequest) (*apipb.ListAttachmentsResponse, error) {
|
||||
user, err := s.fetchCurrentUser(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get current user: %v", err)
|
||||
@@ -328,7 +328,7 @@ func (s *APIV1Service) ListAttachments(ctx context.Context, request *v1pb.ListAt
|
||||
return nil, status.Errorf(codes.Internal, "failed to list attachments: %v", err)
|
||||
}
|
||||
|
||||
response := &v1pb.ListAttachmentsResponse{}
|
||||
response := &apipb.ListAttachmentsResponse{}
|
||||
|
||||
for _, attachment := range attachments {
|
||||
response.Attachments = append(response.Attachments, convertAttachmentFromStore(attachment))
|
||||
@@ -342,7 +342,7 @@ func (s *APIV1Service) ListAttachments(ctx context.Context, request *v1pb.ListAt
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) GetAttachment(ctx context.Context, request *v1pb.GetAttachmentRequest) (*v1pb.Attachment, error) {
|
||||
func (s *APIService) GetAttachment(ctx context.Context, request *apipb.GetAttachmentRequest) (*apipb.Attachment, error) {
|
||||
attachmentUID, err := ExtractAttachmentUIDFromName(request.Name)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid attachment id: %v", err)
|
||||
@@ -363,7 +363,7 @@ func (s *APIV1Service) GetAttachment(ctx context.Context, request *v1pb.GetAttac
|
||||
return convertAttachmentFromStore(attachment), nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) UpdateAttachment(ctx context.Context, request *v1pb.UpdateAttachmentRequest) (*v1pb.Attachment, error) {
|
||||
func (s *APIService) UpdateAttachment(ctx context.Context, request *apipb.UpdateAttachmentRequest) (*apipb.Attachment, error) {
|
||||
attachmentUID, err := ExtractAttachmentUIDFromName(request.Attachment.Name)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid attachment id: %v", err)
|
||||
@@ -424,7 +424,7 @@ func (s *APIV1Service) UpdateAttachment(ctx context.Context, request *v1pb.Updat
|
||||
return convertAttachmentFromStore(updatedAttachment), nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) DeleteAttachment(ctx context.Context, request *v1pb.DeleteAttachmentRequest) (*emptypb.Empty, error) {
|
||||
func (s *APIService) DeleteAttachment(ctx context.Context, request *apipb.DeleteAttachmentRequest) (*emptypb.Empty, error) {
|
||||
attachmentUID, err := ExtractAttachmentUIDFromName(request.Name)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid attachment id: %v", err)
|
||||
@@ -453,7 +453,7 @@ func (s *APIV1Service) DeleteAttachment(ctx context.Context, request *v1pb.Delet
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) BatchDeleteAttachments(ctx context.Context, request *v1pb.BatchDeleteAttachmentsRequest) (*emptypb.Empty, error) {
|
||||
func (s *APIService) BatchDeleteAttachments(ctx context.Context, request *apipb.BatchDeleteAttachmentsRequest) (*emptypb.Empty, error) {
|
||||
user, err := s.fetchCurrentUser(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get current user: %v", err)
|
||||
@@ -502,7 +502,7 @@ func (s *APIV1Service) BatchDeleteAttachments(ctx context.Context, request *v1pb
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) validateAttachmentDeletionPreflight(ctx context.Context, user *store.User, attachments []*store.Attachment) (map[int32]string, error) {
|
||||
func (s *APIService) validateAttachmentDeletionPreflight(ctx context.Context, user *store.User, attachments []*store.Attachment) (map[int32]string, error) {
|
||||
deletingUIDs, err := s.validateAttachmentMotionGroupDeletion(ctx, user, attachments)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -546,7 +546,7 @@ func (s *APIV1Service) validateAttachmentDeletionPreflight(ctx context.Context,
|
||||
return expectedMemoContents, nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) validateAttachmentMotionGroupDeletion(
|
||||
func (s *APIService) validateAttachmentMotionGroupDeletion(
|
||||
ctx context.Context,
|
||||
user *store.User,
|
||||
attachments []*store.Attachment,
|
||||
@@ -591,7 +591,7 @@ func (s *APIV1Service) validateAttachmentMotionGroupDeletion(
|
||||
return deletingUIDs, nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) deleteAttachmentsAtomically(ctx context.Context, user *store.User, attachments []*store.Attachment) error {
|
||||
func (s *APIService) deleteAttachmentsAtomically(ctx context.Context, user *store.User, attachments []*store.Attachment) error {
|
||||
expectedMemoContents, err := s.validateAttachmentDeletionPreflight(ctx, user, attachments)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -627,7 +627,7 @@ func attachmentsIncludeMemo(attachments []*store.Attachment) bool {
|
||||
// checkAttachmentAccess verifies the user has permission to access the attachment.
|
||||
// For unlinked attachments (no memo), only the creator can access.
|
||||
// For linked attachments, access follows the memo's visibility rules.
|
||||
func (s *APIV1Service) checkAttachmentAccess(ctx context.Context, attachment *store.Attachment) error {
|
||||
func (s *APIService) checkAttachmentAccess(ctx context.Context, attachment *store.Attachment) error {
|
||||
// For unlinked attachments, only the creator can access.
|
||||
if attachment.MemoID == nil {
|
||||
user, err := s.fetchCurrentUser(ctx)
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -12,19 +12,19 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/usememos/memos/internal/imagelimit"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
)
|
||||
|
||||
func validateClientMotionMedia(motion *v1pb.MotionMedia, attachmentUID string) (*storepb.MotionMedia, error) {
|
||||
func validateClientMotionMedia(motion *apipb.MotionMedia, attachmentUID string) (*storepb.MotionMedia, error) {
|
||||
if motion == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if motion.Family != v1pb.MotionMediaFamily_APPLE_LIVE_PHOTO {
|
||||
if motion.Family != apipb.MotionMediaFamily_APPLE_LIVE_PHOTO {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "only Apple Live Photo motion metadata can be provided by clients")
|
||||
}
|
||||
if motion.Role != v1pb.MotionMediaRole_STILL && motion.Role != v1pb.MotionMediaRole_VIDEO {
|
||||
if motion.Role != apipb.MotionMediaRole_STILL && motion.Role != apipb.MotionMediaRole_VIDEO {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid Apple Live Photo motion role")
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func shouldStripExifContent(source io.ReadSeeker, declaredType string) (bool, er
|
||||
return ok && shouldStripExif(sniffed), nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) acquireImageProcessingSlot(ctx context.Context) (func(), error) {
|
||||
func (s *APIService) acquireImageProcessingSlot(ctx context.Context) (func(), error) {
|
||||
if s.imageProcessingSemaphore == nil {
|
||||
return func() {}, nil
|
||||
}
|
||||
+7
-7
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -17,13 +17,13 @@ import (
|
||||
|
||||
"github.com/usememos/memos/internal/profile"
|
||||
"github.com/usememos/memos/internal/random"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func convertAttachmentFromStore(attachment *store.Attachment) *v1pb.Attachment {
|
||||
attachmentMessage := &v1pb.Attachment{
|
||||
func convertAttachmentFromStore(attachment *store.Attachment) *apipb.Attachment {
|
||||
attachmentMessage := &apipb.Attachment{
|
||||
Name: fmt.Sprintf("%s%s", AttachmentNamePrefix, attachment.UID),
|
||||
CreateTime: timestamppb.New(time.Unix(attachment.CreatedTs, 0)),
|
||||
Filename: attachment.Filename,
|
||||
@@ -223,7 +223,7 @@ func hasSameManagedStorageObject(left, right *store.Attachment) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *APIV1Service) cleanupDeletedAttachmentStorage(ctx context.Context, attachments []*store.Attachment) error {
|
||||
func (s *APIService) cleanupDeletedAttachmentStorage(ctx context.Context, attachments []*store.Attachment) error {
|
||||
var instanceStorageSetting *storepb.InstanceStorageSetting
|
||||
var instanceStorageSettingErr error
|
||||
for _, attachment := range attachments {
|
||||
@@ -252,7 +252,7 @@ func (s *APIV1Service) cleanupDeletedAttachmentStorage(ctx context.Context, atta
|
||||
}
|
||||
|
||||
// GetAttachmentBlob reads an attachment from its configured storage.
|
||||
func (s *APIV1Service) GetAttachmentBlob(ctx context.Context, attachment *store.Attachment) ([]byte, error) {
|
||||
func (s *APIService) GetAttachmentBlob(ctx context.Context, attachment *store.Attachment) ([]byte, error) {
|
||||
content, err := s.openAttachmentContent(ctx, attachment)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -268,7 +268,7 @@ func (s *APIV1Service) GetAttachmentBlob(ctx context.Context, attachment *store.
|
||||
// openAttachmentContent streams an attachment from its configured storage.
|
||||
// Database-backed attachments are re-read with their blob when the caller
|
||||
// listed them without it.
|
||||
func (s *APIV1Service) openAttachmentContent(ctx context.Context, attachment *store.Attachment) (io.ReadCloser, error) {
|
||||
func (s *APIService) openAttachmentContent(ctx context.Context, attachment *store.Attachment) (io.ReadCloser, error) {
|
||||
switch attachment.StorageType {
|
||||
case storepb.AttachmentStorageType_LOCAL:
|
||||
attachmentPath := filepath.FromSlash(attachment.Reference)
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -11,20 +11,20 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/usememos/memos/internal/ratelimit"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
const (
|
||||
attachmentUploadMetadataLimit = 64 << 10
|
||||
attachmentUploadTempPrefix = ".memos-rpc-upload-"
|
||||
attachmentUploadProcedure = "/memos.api.v1.AttachmentService/UploadAttachment"
|
||||
attachmentUploadProcedure = "/memos.api.AttachmentService/UploadAttachment"
|
||||
)
|
||||
|
||||
// attachmentUploadState is what an attachment upload carries besides its
|
||||
// bytes. Only Attachment is an API resource.
|
||||
type attachmentUploadState struct {
|
||||
metadata *v1pb.Attachment
|
||||
metadata *apipb.Attachment
|
||||
uid string
|
||||
finalizeAttempted bool
|
||||
}
|
||||
@@ -37,7 +37,7 @@ type (
|
||||
// UploadAttachment accepts bounded unary chunks. A call carrying a spec opens
|
||||
// a new upload; a call carrying an upload ID continues one. Either kind may
|
||||
// write data and finalize.
|
||||
func (s *APIV1Service) UploadAttachment(ctx context.Context, request *v1pb.UploadAttachmentRequest) (*v1pb.UploadAttachmentResponse, error) {
|
||||
func (s *APIService) UploadAttachment(ctx context.Context, request *apipb.UploadAttachmentRequest) (*apipb.UploadAttachmentResponse, error) {
|
||||
user, err := s.requireCurrentSpaceUser(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -48,7 +48,7 @@ func (s *APIV1Service) UploadAttachment(ctx context.Context, request *v1pb.Uploa
|
||||
var id string
|
||||
var upload *attachmentUpload
|
||||
switch u := request.Upload.(type) {
|
||||
case *v1pb.UploadAttachmentRequest_Spec:
|
||||
case *apipb.UploadAttachmentRequest_Spec:
|
||||
if err := s.throttleAndCharge(ratelimit.ScopeUploadUser, userKey(user.ID), 1); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func (s *APIV1Service) UploadAttachment(ctx context.Context, request *v1pb.Uploa
|
||||
return nil, err
|
||||
}
|
||||
upload.mu.Lock()
|
||||
case *v1pb.UploadAttachmentRequest_UploadId:
|
||||
case *apipb.UploadAttachmentRequest_UploadId:
|
||||
id = u.UploadId
|
||||
upload, err = s.attachmentUploads.resume(id, user.ID)
|
||||
if err != nil {
|
||||
@@ -73,11 +73,11 @@ func (s *APIV1Service) UploadAttachment(ctx context.Context, request *v1pb.Uploa
|
||||
if err := upload.write(request.WriteOffset, request.Data, request.FinishWrite); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var attachment *v1pb.Attachment
|
||||
var attachment *apipb.Attachment
|
||||
if upload.complete {
|
||||
// Recheck access and existence; a completed upload must not resurrect a
|
||||
// deleted attachment or disclose metadata after access is revoked.
|
||||
attachment, err = s.GetAttachment(ctx, &v1pb.GetAttachmentRequest{Name: "attachments/" + upload.state.uid})
|
||||
attachment, err = s.GetAttachment(ctx, &apipb.GetAttachmentRequest{Name: "attachments/" + upload.state.uid})
|
||||
} else if request.FinishWrite {
|
||||
if upload.committedSize != upload.totalSize {
|
||||
return nil, status.Errorf(codes.FailedPrecondition, "upload is incomplete")
|
||||
@@ -92,7 +92,7 @@ func (s *APIV1Service) UploadAttachment(ctx context.Context, request *v1pb.Uploa
|
||||
return nil, err
|
||||
}
|
||||
upload.expireTime = time.Now().Add(uploadTTL)
|
||||
return &v1pb.UploadAttachmentResponse{
|
||||
return &apipb.UploadAttachmentResponse{
|
||||
UploadId: id, CommittedSize: upload.committedSize, Attachment: attachment, MaxChunkSize: uploadChunkSize,
|
||||
}, nil
|
||||
}
|
||||
@@ -100,7 +100,7 @@ func (s *APIV1Service) UploadAttachment(ctx context.Context, request *v1pb.Uploa
|
||||
// startAttachmentUpload validates the spec and registers a new upload. Every
|
||||
// check that can fail on the accompanying data runs first, so a rejected call
|
||||
// never leaves an orphaned upload behind.
|
||||
func (s *APIV1Service) startAttachmentUpload(ctx context.Context, request *v1pb.UploadAttachmentRequest, spec *v1pb.UploadAttachmentSpec, ownerID int32) (string, *attachmentUpload, error) {
|
||||
func (s *APIService) startAttachmentUpload(ctx context.Context, request *apipb.UploadAttachmentRequest, spec *apipb.UploadAttachmentSpec, ownerID int32) (string, *attachmentUpload, error) {
|
||||
if spec.Attachment == nil {
|
||||
return "", nil, status.Errorf(codes.InvalidArgument, "spec.attachment is required")
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func (s *APIV1Service) startAttachmentUpload(ctx context.Context, request *v1pb.
|
||||
// Type-dependent metadata validation must wait for content sniffing.
|
||||
validationMetadata.MediaMetadata = nil
|
||||
}
|
||||
create, err := s.prepareAttachment(ctx, &v1pb.CreateAttachmentRequest{Attachment: validationMetadata, AttachmentId: spec.AttachmentId})
|
||||
create, err := s.prepareAttachment(ctx, &apipb.CreateAttachmentRequest{Attachment: validationMetadata, AttachmentId: spec.AttachmentId})
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
@@ -139,7 +139,7 @@ func (s *APIV1Service) startAttachmentUpload(ctx context.Context, request *v1pb.
|
||||
return s.attachmentUploads.create(s.Profile.Data, attachmentUploadTempPrefix, ownerID, spec.TotalSize, state)
|
||||
}
|
||||
|
||||
func (s *APIV1Service) finishAttachmentUpload(ctx context.Context, upload *attachmentUpload) (*v1pb.Attachment, error) {
|
||||
func (s *APIService) finishAttachmentUpload(ctx context.Context, upload *attachmentUpload) (*apipb.Attachment, error) {
|
||||
if upload.state.finalizeAttempted {
|
||||
// A database operation may commit before returning an error. Resolve that
|
||||
// outcome before saving another object under the upload's stable UID.
|
||||
@@ -151,7 +151,7 @@ func (s *APIV1Service) finishAttachmentUpload(ctx context.Context, upload *attac
|
||||
if persisted.CreatorID != upload.ownerID {
|
||||
return nil, status.Errorf(codes.AlreadyExists, "attachment ID already exists")
|
||||
}
|
||||
return s.GetAttachment(ctx, &v1pb.GetAttachmentRequest{Name: "attachments/" + upload.state.uid})
|
||||
return s.GetAttachment(ctx, &apipb.GetAttachmentRequest{Name: "attachments/" + upload.state.uid})
|
||||
}
|
||||
}
|
||||
setting, err := s.Store.GetInstanceStorageSetting(ctx)
|
||||
@@ -172,7 +172,7 @@ func (s *APIV1Service) finishAttachmentUpload(ctx context.Context, upload *attac
|
||||
return nil, status.Errorf(codes.Internal, "failed to read attachment header: %v", err)
|
||||
}
|
||||
// Revalidate memo permissions and media metadata with the actual MIME type.
|
||||
create, err := s.prepareAttachment(ctx, &v1pb.CreateAttachmentRequest{Attachment: metadata, AttachmentId: upload.state.uid})
|
||||
create, err := s.prepareAttachment(ctx, &apipb.CreateAttachmentRequest{Attachment: metadata, AttachmentId: upload.state.uid})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -17,12 +17,12 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/usememos/memos/internal/testutil"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func newUploadTestService(t *testing.T) (*APIV1Service, context.Context) {
|
||||
func newUploadTestService(t *testing.T) (*APIService, context.Context) {
|
||||
t.Helper()
|
||||
svc := newIntegrationService(t)
|
||||
t.Cleanup(svc.CloseUploads)
|
||||
@@ -30,19 +30,19 @@ func newUploadTestService(t *testing.T) (*APIV1Service, context.Context) {
|
||||
return svc, userCtx(context.Background(), user.ID)
|
||||
}
|
||||
|
||||
func uploadSpec(filename string, size int64) *v1pb.UploadAttachmentRequest_Spec {
|
||||
return &v1pb.UploadAttachmentRequest_Spec{Spec: &v1pb.UploadAttachmentSpec{Attachment: &v1pb.Attachment{Filename: filename}, TotalSize: size}}
|
||||
func uploadSpec(filename string, size int64) *apipb.UploadAttachmentRequest_Spec {
|
||||
return &apipb.UploadAttachmentRequest_Spec{Spec: &apipb.UploadAttachmentSpec{Attachment: &apipb.Attachment{Filename: filename}, TotalSize: size}}
|
||||
}
|
||||
|
||||
func uploadID(id string) *v1pb.UploadAttachmentRequest_UploadId {
|
||||
return &v1pb.UploadAttachmentRequest_UploadId{UploadId: id}
|
||||
func uploadID(id string) *apipb.UploadAttachmentRequest_UploadId {
|
||||
return &apipb.UploadAttachmentRequest_UploadId{UploadId: id}
|
||||
}
|
||||
|
||||
func startTestUpload(ctx context.Context, t *testing.T, svc *APIV1Service, size int64) string {
|
||||
func startTestUpload(ctx context.Context, t *testing.T, svc *APIService, size int64) string {
|
||||
t.Helper()
|
||||
spec := uploadSpec("file.bin", size)
|
||||
spec.Spec.Attachment.Type = "application/octet-stream"
|
||||
response, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: spec})
|
||||
response, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: spec})
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, response.UploadId)
|
||||
require.EqualValues(t, uploadChunkSize, response.MaxChunkSize)
|
||||
@@ -54,14 +54,14 @@ func startTestUpload(ctx context.Context, t *testing.T, svc *APIV1Service, size
|
||||
func TestUploadAttachmentChunksAndRetries(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
id := startTestUpload(ctx, t, svc, 6)
|
||||
first := &v1pb.UploadAttachmentRequest{Upload: uploadID(id), Data: []byte("abc")}
|
||||
first := &apipb.UploadAttachmentRequest{Upload: uploadID(id), Data: []byte("abc")}
|
||||
for range 2 {
|
||||
response, err := svc.UploadAttachment(ctx, first)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, id, response.UploadId)
|
||||
require.EqualValues(t, 3, response.CommittedSize)
|
||||
}
|
||||
for _, request := range []*v1pb.UploadAttachmentRequest{
|
||||
for _, request := range []*apipb.UploadAttachmentRequest{
|
||||
{Upload: uploadID(id), Data: []byte("xyz")},
|
||||
{Upload: uploadID(id), WriteOffset: 4, Data: []byte("d")},
|
||||
{Upload: uploadID(id), WriteOffset: -1, Data: []byte("d")},
|
||||
@@ -69,17 +69,17 @@ func TestUploadAttachmentChunksAndRetries(t *testing.T) {
|
||||
_, err := svc.UploadAttachment(ctx, request)
|
||||
require.Equal(t, codes.OutOfRange, status.Code(err))
|
||||
}
|
||||
progress, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), WriteOffset: -1})
|
||||
progress, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(id), WriteOffset: -1})
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, 3, progress.CommittedSize)
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), WriteOffset: 3, FinishWrite: true})
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(id), WriteOffset: 3, FinishWrite: true})
|
||||
require.Equal(t, codes.FailedPrecondition, status.Code(err))
|
||||
|
||||
last := &v1pb.UploadAttachmentRequest{Upload: uploadID(id), WriteOffset: 3, Data: []byte("def"), FinishWrite: true}
|
||||
last := &apipb.UploadAttachmentRequest{Upload: uploadID(id), WriteOffset: 3, Data: []byte("def"), FinishWrite: true}
|
||||
result, err := svc.UploadAttachment(ctx, last)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, 6, result.Attachment.Size)
|
||||
for _, request := range []*v1pb.UploadAttachmentRequest{last, {Upload: uploadID(id)}, {Upload: uploadID(id), WriteOffset: 6, FinishWrite: true}} {
|
||||
for _, request := range []*apipb.UploadAttachmentRequest{last, {Upload: uploadID(id)}, {Upload: uploadID(id), WriteOffset: 6, FinishWrite: true}} {
|
||||
repeated, err := svc.UploadAttachment(ctx, request)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, result.Attachment.Name, repeated.Attachment.Name)
|
||||
@@ -92,7 +92,7 @@ func TestUploadAttachmentChunksAndRetries(t *testing.T) {
|
||||
require.Equal(t, "abcdef", string(content))
|
||||
require.NoFileExists(t, svc.attachmentUploads.entries[id].path)
|
||||
|
||||
_, err = svc.DeleteAttachment(ctx, &v1pb.DeleteAttachmentRequest{Name: result.Attachment.Name})
|
||||
_, err = svc.DeleteAttachment(ctx, &apipb.DeleteAttachmentRequest{Name: result.Attachment.Name})
|
||||
require.NoError(t, err)
|
||||
_, err = svc.UploadAttachment(ctx, last)
|
||||
require.Equal(t, codes.NotFound, status.Code(err))
|
||||
@@ -102,22 +102,22 @@ func TestUploadAttachmentSingleCall(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
spec := uploadSpec("note.txt", 3)
|
||||
spec.Spec.AttachmentId = "chosen-id"
|
||||
result, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: spec, Data: []byte("abc"), FinishWrite: true})
|
||||
result, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: spec, Data: []byte("abc"), FinishWrite: true})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "attachments/chosen-id", result.Attachment.Name)
|
||||
require.EqualValues(t, 3, result.Attachment.Size)
|
||||
require.EqualValues(t, 3, result.CommittedSize)
|
||||
|
||||
empty, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadSpec("empty.txt", 0), FinishWrite: true})
|
||||
empty, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadSpec("empty.txt", 0), FinishWrite: true})
|
||||
require.NoError(t, err)
|
||||
require.Zero(t, empty.Attachment.Size)
|
||||
|
||||
// A spec call may carry the first chunk without finishing.
|
||||
partial, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadSpec("two.bin", 4), Data: []byte("ab")})
|
||||
partial, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadSpec("two.bin", 4), Data: []byte("ab")})
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, partial.Attachment)
|
||||
require.EqualValues(t, 2, partial.CommittedSize)
|
||||
done, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(partial.UploadId), WriteOffset: 2, Data: []byte("cd"), FinishWrite: true})
|
||||
done, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(partial.UploadId), WriteOffset: 2, Data: []byte("cd"), FinishWrite: true})
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, 4, done.Attachment.Size)
|
||||
|
||||
@@ -128,15 +128,15 @@ func TestUploadAttachmentSingleCall(t *testing.T) {
|
||||
|
||||
func TestUploadAttachmentValidation(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
_, err := svc.UploadAttachment(context.Background(), &v1pb.UploadAttachmentRequest{})
|
||||
_, err := svc.UploadAttachment(context.Background(), &apipb.UploadAttachmentRequest{})
|
||||
require.Equal(t, codes.Unauthenticated, status.Code(err))
|
||||
badID := uploadSpec("file", 0)
|
||||
badID.Spec.AttachmentId = "bad id!"
|
||||
withContent := uploadSpec("file", 0)
|
||||
withContent.Spec.Attachment.Content = []byte("not metadata")
|
||||
for _, request := range []*v1pb.UploadAttachmentRequest{
|
||||
for _, request := range []*apipb.UploadAttachmentRequest{
|
||||
{},
|
||||
{Upload: &v1pb.UploadAttachmentRequest_Spec{Spec: &v1pb.UploadAttachmentSpec{}}},
|
||||
{Upload: &apipb.UploadAttachmentRequest_Spec{Spec: &apipb.UploadAttachmentSpec{}}},
|
||||
{Upload: uploadSpec("file", -1)},
|
||||
{Upload: uploadSpec("../file", 0)},
|
||||
{Upload: withContent},
|
||||
@@ -147,27 +147,27 @@ func TestUploadAttachmentValidation(t *testing.T) {
|
||||
_, err := svc.UploadAttachment(ctx, request)
|
||||
require.Equal(t, codes.InvalidArgument, status.Code(err), request.String())
|
||||
}
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadSpec("file", 3), WriteOffset: 1, Data: []byte("abc")})
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadSpec("file", 3), WriteOffset: 1, Data: []byte("abc")})
|
||||
require.Equal(t, codes.OutOfRange, status.Code(err))
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadSpec("file", 1<<60)})
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadSpec("file", 1<<60)})
|
||||
require.Equal(t, codes.ResourceExhausted, status.Code(err))
|
||||
require.Empty(t, svc.attachmentUploads.entries, "rejected spec calls must not register uploads")
|
||||
|
||||
id := startTestUpload(ctx, t, svc, 3)
|
||||
other := createSpaceTestUser(context.Background(), t, svc, "other-uploader", store.RoleUser)
|
||||
_, err = svc.UploadAttachment(userCtx(context.Background(), other.ID), &v1pb.UploadAttachmentRequest{Upload: uploadID(id)})
|
||||
_, err = svc.UploadAttachment(userCtx(context.Background(), other.ID), &apipb.UploadAttachmentRequest{Upload: uploadID(id)})
|
||||
require.Equal(t, codes.NotFound, status.Code(err))
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID("unknown")})
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID("unknown")})
|
||||
require.Equal(t, codes.NotFound, status.Code(err))
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), Data: make([]byte, uploadChunkSize+1)})
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(id), Data: make([]byte, uploadChunkSize+1)})
|
||||
require.Equal(t, codes.ResourceExhausted, status.Code(err))
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), Data: []byte("four")})
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(id), Data: []byte("four")})
|
||||
require.Equal(t, codes.InvalidArgument, status.Code(err))
|
||||
canceled, cancel := context.WithCancel(ctx)
|
||||
cancel()
|
||||
_, err = svc.UploadAttachment(canceled, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), Data: []byte("abc")})
|
||||
_, err = svc.UploadAttachment(canceled, &apipb.UploadAttachmentRequest{Upload: uploadID(id), Data: []byte("abc")})
|
||||
require.Error(t, err)
|
||||
progress, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id)})
|
||||
progress, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(id)})
|
||||
require.NoError(t, err)
|
||||
require.Zero(t, progress.CommittedSize)
|
||||
}
|
||||
@@ -176,11 +176,11 @@ func TestUploadAttachmentEmptyAndConcurrentFinish(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
id := startTestUpload(ctx, t, svc, 0)
|
||||
var wg sync.WaitGroup
|
||||
results := make(chan *v1pb.UploadAttachmentResponse, 8)
|
||||
results := make(chan *apipb.UploadAttachmentResponse, 8)
|
||||
errs := make(chan error, 8)
|
||||
for range 8 {
|
||||
wg.Go(func() {
|
||||
response, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), FinishWrite: true})
|
||||
response, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(id), FinishWrite: true})
|
||||
results <- response
|
||||
errs <- err
|
||||
})
|
||||
@@ -207,7 +207,7 @@ func TestUploadAttachmentEmptyAndConcurrentFinish(t *testing.T) {
|
||||
func TestUploadAttachmentFinalizationRecovery(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
id := startTestUpload(ctx, t, svc, 3)
|
||||
last := &v1pb.UploadAttachmentRequest{Upload: uploadID(id), Data: []byte("abc"), FinishWrite: true}
|
||||
last := &apipb.UploadAttachmentRequest{Upload: uploadID(id), Data: []byte("abc"), FinishWrite: true}
|
||||
_, err := svc.UploadAttachment(store.WithCreateAttachmentPostCommitFailpoint(ctx), last)
|
||||
require.Equal(t, codes.Internal, status.Code(err))
|
||||
result, err := svc.UploadAttachment(ctx, last)
|
||||
@@ -223,15 +223,15 @@ func TestUploadAttachmentFinalizationRecovery(t *testing.T) {
|
||||
|
||||
func TestUploadAttachmentRechecksMemoAndSize(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
memo, err := svc.CreateMemo(ctx, &v1pb.CreateMemoRequest{Memo: &v1pb.Memo{Content: "upload target"}})
|
||||
memo, err := svc.CreateMemo(ctx, &apipb.CreateMemoRequest{Memo: &apipb.Memo{Content: "upload target"}})
|
||||
require.NoError(t, err)
|
||||
spec := uploadSpec("file.txt", 3)
|
||||
spec.Spec.Attachment.Memo = &memo.Name
|
||||
initial, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: spec})
|
||||
initial, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: spec})
|
||||
require.NoError(t, err)
|
||||
_, err = svc.DeleteMemo(ctx, &v1pb.DeleteMemoRequest{Name: memo.Name, Force: true})
|
||||
_, err = svc.DeleteMemo(ctx, &apipb.DeleteMemoRequest{Name: memo.Name, Force: true})
|
||||
require.NoError(t, err)
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(initial.UploadId), Data: []byte("abc"), FinishWrite: true})
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(initial.UploadId), Data: []byte("abc"), FinishWrite: true})
|
||||
require.Equal(t, codes.NotFound, status.Code(err))
|
||||
|
||||
id := startTestUpload(ctx, t, svc, 2*MebiByte)
|
||||
@@ -239,7 +239,7 @@ func TestUploadAttachmentRechecksMemoAndSize(t *testing.T) {
|
||||
Value: &storepb.InstanceSetting_StorageSetting{StorageSetting: &storepb.InstanceStorageSetting{UploadSizeLimitMb: 1}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), Data: make([]byte, 2*MebiByte), FinishWrite: true})
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(id), Data: make([]byte, 2*MebiByte), FinishWrite: true})
|
||||
require.Equal(t, codes.ResourceExhausted, status.Code(err))
|
||||
rows, err := svc.Store.ListAttachments(ctx, &store.FindAttachment{})
|
||||
require.NoError(t, err)
|
||||
@@ -252,16 +252,16 @@ func TestUploadAttachmentExpiryAndLimits(t *testing.T) {
|
||||
for i := range ids {
|
||||
ids[i] = startTestUpload(ctx, t, svc, 0)
|
||||
}
|
||||
_, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadSpec("too-many", 0)})
|
||||
_, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadSpec("too-many", 0)})
|
||||
require.Equal(t, codes.ResourceExhausted, status.Code(err))
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(ids[0]), FinishWrite: true})
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(ids[0]), FinishWrite: true})
|
||||
require.NoError(t, err)
|
||||
startTestUpload(ctx, t, svc, 0) // Completed uploads do not consume an active slot.
|
||||
upload := svc.attachmentUploads.entries[ids[1]]
|
||||
upload.mu.Lock()
|
||||
upload.expireTime = time.Now().Add(-time.Second)
|
||||
upload.mu.Unlock()
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(ids[1])})
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(ids[1])})
|
||||
require.Equal(t, codes.NotFound, status.Code(err))
|
||||
|
||||
orphan := filepath.Join(svc.Profile.Data, attachmentUploadTempPrefix+"orphan")
|
||||
@@ -294,9 +294,9 @@ func TestUploadAttachmentAboveLegacyRequestLimit(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
id := startTestUpload(ctx, t, svc, size)
|
||||
chunk := bytes.Repeat([]byte{0x5a}, uploadChunkSize)
|
||||
var response *v1pb.UploadAttachmentResponse
|
||||
var response *apipb.UploadAttachmentResponse
|
||||
for offset := int64(0); offset < size; offset += int64(len(chunk)) {
|
||||
response, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{
|
||||
response, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{
|
||||
Upload: uploadID(id), WriteOffset: offset, Data: chunk, FinishWrite: offset+int64(len(chunk)) == size,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -330,11 +330,11 @@ func TestUploadAttachmentMediaProcessing(t *testing.T) {
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
metadata := &v1pb.Attachment{Filename: "image.unknown", MediaMetadata: &v1pb.MediaMetadata{Width: proto.Int32(20), Height: proto.Int32(10)}}
|
||||
spec := &v1pb.UploadAttachmentRequest_Spec{Spec: &v1pb.UploadAttachmentSpec{Attachment: metadata, TotalSize: int64(len(tc.content))}}
|
||||
initial, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: spec})
|
||||
metadata := &apipb.Attachment{Filename: "image.unknown", MediaMetadata: &apipb.MediaMetadata{Width: proto.Int32(20), Height: proto.Int32(10)}}
|
||||
spec := &apipb.UploadAttachmentRequest_Spec{Spec: &apipb.UploadAttachmentSpec{Attachment: metadata, TotalSize: int64(len(tc.content))}}
|
||||
initial, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: spec})
|
||||
require.NoError(t, err)
|
||||
result, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(initial.UploadId), Data: tc.content, FinishWrite: true})
|
||||
result, err := svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(initial.UploadId), Data: tc.content, FinishWrite: true})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "image/jpeg", result.Attachment.Type)
|
||||
require.True(t, proto.Equal(metadata.MediaMetadata, result.Attachment.MediaMetadata))
|
||||
+12
-12
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
"github.com/usememos/memos/proto/gen/api/v1/apiv1connect"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
"github.com/usememos/memos/proto/gen/api/apiconnect"
|
||||
"github.com/usememos/memos/server/auth"
|
||||
)
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestUploadAttachmentTransports(t *testing.T) {
|
||||
e := echo.New()
|
||||
require.NoError(t, svc.RegisterGateway(context.Background(), e))
|
||||
|
||||
for _, path := range []string{"/api/v1/attachments:upload", attachmentUploadProcedure} {
|
||||
for _, path := range []string{"/api/attachments:upload", attachmentUploadProcedure} {
|
||||
t.Run(path, func(t *testing.T) {
|
||||
call := func(message proto.Message, authenticated bool) *httptest.ResponseRecorder {
|
||||
t.Helper()
|
||||
@@ -55,18 +55,18 @@ func TestUploadAttachmentTransports(t *testing.T) {
|
||||
e.ServeHTTP(rec, req)
|
||||
return rec
|
||||
}
|
||||
initial := &v1pb.UploadAttachmentRequest{Upload: uploadSpec("file.txt", 3)}
|
||||
initial := &apipb.UploadAttachmentRequest{Upload: uploadSpec("file.txt", 3)}
|
||||
require.Equal(t, http.StatusUnauthorized, call(initial, false).Code)
|
||||
rec := call(initial, true)
|
||||
require.Equal(t, http.StatusOK, rec.Code, rec.Body.String())
|
||||
response := &v1pb.UploadAttachmentResponse{}
|
||||
response := &apipb.UploadAttachmentResponse{}
|
||||
require.NoError(t, protojson.Unmarshal(rec.Body.Bytes(), response))
|
||||
rec = call(&v1pb.UploadAttachmentRequest{Upload: uploadID(response.UploadId), Data: []byte("abc"), FinishWrite: true}, true)
|
||||
rec = call(&apipb.UploadAttachmentRequest{Upload: uploadID(response.UploadId), Data: []byte("abc"), FinishWrite: true}, true)
|
||||
require.Equal(t, http.StatusOK, rec.Code, rec.Body.String())
|
||||
require.NoError(t, protojson.Unmarshal(rec.Body.Bytes(), response))
|
||||
require.NotNil(t, response.Attachment)
|
||||
|
||||
oversized, err := protojson.Marshal(&v1pb.UploadAttachmentRequest{Data: make([]byte, uploadRequestLimit)})
|
||||
oversized, err := protojson.Marshal(&apipb.UploadAttachmentRequest{Data: make([]byte, uploadRequestLimit)})
|
||||
require.NoError(t, err)
|
||||
reader := &uploadCountingReader{reader: bytes.NewReader(oversized)}
|
||||
req := httptest.NewRequest(http.MethodPost, path, reader)
|
||||
@@ -81,18 +81,18 @@ func TestUploadAttachmentTransports(t *testing.T) {
|
||||
|
||||
t.Run("Connect protobuf and compressed message limit", func(t *testing.T) {
|
||||
server := httptest.NewTestServer(t, e)
|
||||
client := apiv1connect.NewAttachmentServiceClient(server.Client(), server.URL)
|
||||
initial := connect.NewRequest(&v1pb.UploadAttachmentRequest{Upload: uploadSpec("binary.bin", uploadChunkSize)})
|
||||
client := apiconnect.NewAttachmentServiceClient(server.Client(), server.URL)
|
||||
initial := connect.NewRequest(&apipb.UploadAttachmentRequest{Upload: uploadSpec("binary.bin", uploadChunkSize)})
|
||||
initial.Header().Set("Authorization", "Bearer "+token)
|
||||
response, err := client.UploadAttachment(context.Background(), initial)
|
||||
require.NoError(t, err)
|
||||
last := connect.NewRequest(&v1pb.UploadAttachmentRequest{Upload: uploadID(response.Msg.UploadId), Data: make([]byte, uploadChunkSize), FinishWrite: true})
|
||||
last := connect.NewRequest(&apipb.UploadAttachmentRequest{Upload: uploadID(response.Msg.UploadId), Data: make([]byte, uploadChunkSize), FinishWrite: true})
|
||||
last.Header().Set("Authorization", "Bearer "+token)
|
||||
finished, err := client.UploadAttachment(context.Background(), last)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, uploadChunkSize, finished.Msg.Attachment.Size)
|
||||
|
||||
data, err := proto.Marshal(&v1pb.UploadAttachmentRequest{Data: make([]byte, uploadRequestLimit+1)})
|
||||
data, err := proto.Marshal(&apipb.UploadAttachmentRequest{Data: make([]byte, uploadRequestLimit+1)})
|
||||
require.NoError(t, err)
|
||||
var compressed bytes.Buffer
|
||||
writer := gzip.NewWriter(&compressed)
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/usememos/memos/internal/clientip"
|
||||
"github.com/usememos/memos/internal/ratelimit"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ const (
|
||||
//
|
||||
// Authentication: Required (access token).
|
||||
// Returns: User information.
|
||||
func (s *APIV1Service) GetCurrentUser(ctx context.Context, _ *v1pb.GetCurrentUserRequest) (*v1pb.GetCurrentUserResponse, error) {
|
||||
func (s *APIService) GetCurrentUser(ctx context.Context, _ *apipb.GetCurrentUserRequest) (*apipb.GetCurrentUserResponse, error) {
|
||||
user, err := s.fetchCurrentUser(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "failed to get current user: %v", err)
|
||||
@@ -36,7 +36,7 @@ func (s *APIV1Service) GetCurrentUser(ctx context.Context, _ *v1pb.GetCurrentUse
|
||||
return nil, status.Errorf(codes.Unauthenticated, "user not found")
|
||||
}
|
||||
|
||||
return &v1pb.GetCurrentUserResponse{
|
||||
return &apipb.GetCurrentUserResponse{
|
||||
User: convertUserFromStore(user, user),
|
||||
}, nil
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func (s *APIV1Service) GetCurrentUser(ctx context.Context, _ *v1pb.GetCurrentUse
|
||||
//
|
||||
// Authentication: Not required (public endpoint).
|
||||
// Returns: User info, access token, and token expiry.
|
||||
func (s *APIV1Service) SignIn(ctx context.Context, request *v1pb.SignInRequest) (*v1pb.SignInResponse, error) {
|
||||
func (s *APIService) SignIn(ctx context.Context, request *apipb.SignInRequest) (*apipb.SignInResponse, error) {
|
||||
var existingUser *store.User
|
||||
|
||||
// Rate limits run before any lookup or hashing so a flood costs nothing.
|
||||
@@ -97,7 +97,7 @@ func (s *APIV1Service) SignIn(ctx context.Context, request *v1pb.SignInRequest)
|
||||
existingUser = user
|
||||
} else if ssoCredentials := request.GetSsoCredentials(); ssoCredentials != nil {
|
||||
// Authentication Method 2: SSO (OAuth2) authentication
|
||||
identityProvider, userInfo, err := s.resolveSSOIdentity(ctx, ssoCredentials.IdpName, ssoCredentials.Code, ssoCredentials.RedirectUri, ssoCredentials.CodeVerifier)
|
||||
identityProvider, userInfo, err := s.resolveSSOIdentity(ctx, ssoCredentials.IdentityProvider, ssoCredentials.Code, ssoCredentials.RedirectUri, ssoCredentials.CodeVerifier)
|
||||
if err != nil {
|
||||
// A rejected exchange is a credential failure and stays counted.
|
||||
return nil, err
|
||||
@@ -127,10 +127,10 @@ func (s *APIV1Service) SignIn(ctx context.Context, request *v1pb.SignInRequest)
|
||||
return nil, status.Errorf(codes.Internal, "failed to sign in: %v", err)
|
||||
}
|
||||
|
||||
return &v1pb.SignInResponse{
|
||||
User: convertUserFromStore(existingUser, existingUser),
|
||||
AccessToken: accessToken,
|
||||
AccessTokenExpiresAt: timestamppb.New(accessExpiresAt),
|
||||
return &apipb.SignInResponse{
|
||||
User: convertUserFromStore(existingUser, existingUser),
|
||||
AccessToken: accessToken,
|
||||
AccessTokenExpireTime: timestamppb.New(accessExpiresAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestParseUserAgent(t *testing.T) {
|
||||
service := &APIV1Service{}
|
||||
service := &APIService{}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -93,7 +93,7 @@ func TestParseUserAgent(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExtractClientInfo(t *testing.T) {
|
||||
service := &APIV1Service{}
|
||||
service := &APIService{}
|
||||
|
||||
// The user agent comes from metadata; the address comes only from the
|
||||
// trusted-proxy resolver, so forwarding headers in metadata are ignored.
|
||||
@@ -126,7 +126,7 @@ func TestExtractClientInfo(t *testing.T) {
|
||||
|
||||
// TestClientInfoExamples demonstrates the enhanced client info extraction with various user agents.
|
||||
func TestClientInfoExamples(t *testing.T) {
|
||||
service := &APIV1Service{}
|
||||
service := &APIService{}
|
||||
|
||||
examples := []struct {
|
||||
description string
|
||||
@@ -184,7 +184,7 @@ func TestClientInfoExamples(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuildRefreshTokenCookieSecureFlag(t *testing.T) {
|
||||
service := &APIV1Service{}
|
||||
service := &APIService{}
|
||||
|
||||
t.Run("sets Secure for https origin", func(t *testing.T) {
|
||||
ctx := metadata.NewIncomingContext(context.Background(), metadata.Pairs(
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -16,13 +16,13 @@ import (
|
||||
|
||||
"github.com/usememos/memos/internal/clientip"
|
||||
"github.com/usememos/memos/internal/random"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/server/auth"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func (s *APIV1Service) doSignIn(ctx context.Context, user *store.User) (string, time.Time, error) {
|
||||
func (s *APIService) doSignIn(ctx context.Context, user *store.User) (string, time.Time, error) {
|
||||
// Generate refresh token
|
||||
tokenID := random.UUID()
|
||||
refreshToken, refreshExpiresAt, err := auth.GenerateRefreshToken(user.ID, tokenID, []byte(s.Secret))
|
||||
@@ -68,7 +68,7 @@ func (s *APIV1Service) doSignIn(ctx context.Context, user *store.User) (string,
|
||||
//
|
||||
// Authentication: Required (access token).
|
||||
// Returns: Empty response on success.
|
||||
func (s *APIV1Service) SignOut(ctx context.Context, _ *v1pb.SignOutRequest) (*emptypb.Empty, error) {
|
||||
func (s *APIService) SignOut(ctx context.Context, _ *apipb.SignOutRequest) (*emptypb.Empty, error) {
|
||||
// Get user from access token claims
|
||||
claims := auth.GetUserClaims(ctx)
|
||||
if claims != nil {
|
||||
@@ -111,7 +111,7 @@ func (s *APIV1Service) SignOut(ctx context.Context, _ *v1pb.SignOutRequest) (*em
|
||||
//
|
||||
// Authentication: Requires valid refresh token in cookie (public endpoint)
|
||||
// Returns: New access token and expiry timestamp.
|
||||
func (s *APIV1Service) RefreshToken(ctx context.Context, _ *v1pb.RefreshTokenRequest) (*v1pb.RefreshTokenResponse, error) {
|
||||
func (s *APIService) RefreshToken(ctx context.Context, _ *apipb.RefreshTokenRequest) (*apipb.RefreshTokenResponse, error) {
|
||||
// Extract refresh token from cookie
|
||||
refreshToken := ""
|
||||
if md, ok := metadata.FromIncomingContext(ctx); ok {
|
||||
@@ -176,9 +176,9 @@ func (s *APIV1Service) RefreshToken(ctx context.Context, _ *v1pb.RefreshTokenReq
|
||||
return nil, status.Errorf(codes.Internal, "failed to generate access token: %v", err)
|
||||
}
|
||||
|
||||
return &v1pb.RefreshTokenResponse{
|
||||
AccessToken: accessToken,
|
||||
ExpiresAt: timestamppb.New(expiresAt),
|
||||
return &apipb.RefreshTokenResponse{
|
||||
AccessToken: accessToken,
|
||||
AccessTokenExpireTime: timestamppb.New(expiresAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ func currentRefreshTokenID(ctx context.Context, secret string) string {
|
||||
return claims.TokenID
|
||||
}
|
||||
|
||||
func (s *APIV1Service) clearAuthCookies(ctx context.Context) error {
|
||||
func (s *APIService) clearAuthCookies(ctx context.Context) error {
|
||||
// Clear refresh token cookie
|
||||
refreshCookie := s.buildRefreshTokenCookie(ctx, "", time.Time{})
|
||||
if err := SetResponseHeader(ctx, "Set-Cookie", refreshCookie); err != nil {
|
||||
@@ -244,7 +244,7 @@ func isSecureRequest(ctx context.Context) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (*APIV1Service) buildRefreshTokenCookie(ctx context.Context, refreshToken string, expireTime time.Time) string {
|
||||
func (*APIService) buildRefreshTokenCookie(ctx context.Context, refreshToken string, expireTime time.Time) string {
|
||||
attrs := []string{
|
||||
fmt.Sprintf("%s=%s", auth.RefreshTokenCookieName, refreshToken),
|
||||
"Path=/",
|
||||
@@ -266,7 +266,7 @@ func (*APIV1Service) buildRefreshTokenCookie(ctx context.Context, refreshToken s
|
||||
return strings.Join(attrs, "; ")
|
||||
}
|
||||
|
||||
func (s *APIV1Service) fetchCurrentUser(ctx context.Context) (*store.User, error) {
|
||||
func (s *APIService) fetchCurrentUser(ctx context.Context) (*store.User, error) {
|
||||
userID := auth.GetUserID(ctx)
|
||||
if userID == 0 {
|
||||
return nil, nil
|
||||
@@ -303,7 +303,7 @@ func isActiveCurrentUser(user *store.User) bool {
|
||||
// - See all active sessions with device details
|
||||
// - Identify suspicious login attempts
|
||||
// - Revoke specific sessions from unknown devices.
|
||||
func (s *APIV1Service) extractClientInfo(ctx context.Context) *storepb.RefreshTokensUserSetting_ClientInfo {
|
||||
func (s *APIService) extractClientInfo(ctx context.Context) *storepb.RefreshTokensUserSetting_ClientInfo {
|
||||
clientInfo := &storepb.RefreshTokensUserSetting_ClientInfo{}
|
||||
|
||||
// Extract user agent from metadata if available
|
||||
@@ -332,7 +332,7 @@ func (s *APIV1Service) extractClientInfo(ctx context.Context) *storepb.RefreshTo
|
||||
//
|
||||
// Note: This is a simplified parser. For production use with high accuracy requirements,
|
||||
// consider using a dedicated user agent parsing library.
|
||||
func (*APIV1Service) parseUserAgent(userAgent string, clientInfo *storepb.RefreshTokensUserSetting_ClientInfo) {
|
||||
func (*APIService) parseUserAgent(userAgent string, clientInfo *storepb.RefreshTokensUserSetting_ClientInfo) {
|
||||
if userAgent == "" {
|
||||
return
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func (s *APIV1Service) resolveSSOUser(ctx context.Context, currentUser *store.User, identityProvider *storepb.IdentityProvider, userInfo *idp.IdentityProviderUserInfo) (*store.User, error) {
|
||||
func (s *APIService) resolveSSOUser(ctx context.Context, currentUser *store.User, identityProvider *storepb.IdentityProvider, userInfo *idp.IdentityProviderUserInfo) (*store.User, error) {
|
||||
provider := identityProvider.Uid
|
||||
externUID := userInfo.Identifier
|
||||
// Defense in depth: an empty subject must never key a lookup or provision an
|
||||
@@ -72,7 +72,7 @@ func (s *APIV1Service) resolveSSOUser(ctx context.Context, currentUser *store.Us
|
||||
// instance, so the new account is never linked to the existing holder. The
|
||||
// database index remains the guarantee; a concurrent claim between this check
|
||||
// and the insert is handled by createSSOUser.
|
||||
func (s *APIV1Service) resolveSSOEmail(ctx context.Context, rawEmail, provider, externUID string) string {
|
||||
func (s *APIService) resolveSSOEmail(ctx context.Context, rawEmail, provider, externUID string) string {
|
||||
email, err := store.NormalizeEmail(rawEmail)
|
||||
if err != nil {
|
||||
slog.Warn("ignoring malformed email from identity provider",
|
||||
@@ -112,7 +112,7 @@ func (s *APIV1Service) resolveSSOEmail(ctx context.Context, rawEmail, provider,
|
||||
// tryUsername returns a non-nil user when the identity is resolved (either newly
|
||||
// created or reconciled to a concurrent winner) and (nil, nil) when the username
|
||||
// is already taken and the caller should retry with a different one.
|
||||
func (s *APIV1Service) createSSOUser(
|
||||
func (s *APIService) createSSOUser(
|
||||
ctx context.Context,
|
||||
userInfo *idp.IdentityProviderUserInfo,
|
||||
email string,
|
||||
@@ -190,7 +190,7 @@ func (s *APIV1Service) createSSOUser(
|
||||
return nil, errors.Errorf("exhausted %d UUID username attempts", ssoUsernameFallbackAttempts)
|
||||
}
|
||||
|
||||
func (s *APIV1Service) resolveSSOIdentity(ctx context.Context, idpName, code, redirectURI, codeVerifier string) (*storepb.IdentityProvider, *idp.IdentityProviderUserInfo, error) {
|
||||
func (s *APIService) resolveSSOIdentity(ctx context.Context, idpName, code, redirectURI, codeVerifier string) (*storepb.IdentityProvider, *idp.IdentityProviderUserInfo, error) {
|
||||
idpUID, err := ExtractIdentityProviderUIDFromName(idpName)
|
||||
if err != nil {
|
||||
return nil, nil, status.Errorf(codes.InvalidArgument, "invalid identity provider name: %v", err)
|
||||
@@ -236,7 +236,7 @@ func (s *APIV1Service) resolveSSOIdentity(ctx context.Context, idpName, code, re
|
||||
return identityProvider, userInfo, nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) getLinkedSSOUser(ctx context.Context, provider, externUID string) (*store.User, error) {
|
||||
func (s *APIService) getLinkedSSOUser(ctx context.Context, provider, externUID string) (*store.User, error) {
|
||||
identity, err := s.Store.GetUserIdentity(ctx, &store.FindUserIdentity{
|
||||
Provider: &provider,
|
||||
ExternUID: &externUID,
|
||||
@@ -257,7 +257,7 @@ func (s *APIV1Service) getLinkedSSOUser(ctx context.Context, provider, externUID
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) bindSSOIdentityToUser(ctx context.Context, currentUser *store.User, provider, externUID string) (*store.User, error) {
|
||||
func (s *APIService) bindSSOIdentityToUser(ctx context.Context, currentUser *store.User, provider, externUID string) (*store.User, error) {
|
||||
existingForProvider, err := s.Store.GetUserIdentity(ctx, &store.FindUserIdentity{
|
||||
UserID: ¤tUser.ID,
|
||||
Provider: &provider,
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -43,13 +43,13 @@ func TestAuthorizerCheckAccess(t *testing.T) {
|
||||
unavailableInstance := &Authorizer{accessStore: stubAnonymousAccessStore{err: accessStoreError}}
|
||||
|
||||
const (
|
||||
protectedMethod = "/memos.api.v1.MemoService/CreateMemo"
|
||||
publicMethod = "/memos.api.v1.MemoService/ListMemos"
|
||||
listReactions = "/memos.api.v1.MemoService/ListMemoReactions"
|
||||
listRelations = "/memos.api.v1.MemoService/ListMemoRelations"
|
||||
bootstrapMethod = "/memos.api.v1.AuthService/SignIn"
|
||||
createUser = "/memos.api.v1.UserService/CreateUser"
|
||||
shareMethod = "/memos.api.v1.MemoService/GetSharedMemo"
|
||||
protectedMethod = "/memos.api.MemoService/CreateMemo"
|
||||
publicMethod = "/memos.api.MemoService/ListMemos"
|
||||
listReactions = "/memos.api.MemoService/ListMemoReactions"
|
||||
listRelations = "/memos.api.MemoService/ListMemoRelations"
|
||||
bootstrapMethod = "/memos.api.AuthService/SignIn"
|
||||
createUser = "/memos.api.UserService/CreateUser"
|
||||
shareMethod = "/memos.api.MemoService/GetSharedMemo"
|
||||
)
|
||||
|
||||
cases := []struct {
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
@@ -17,20 +17,20 @@ const (
|
||||
MaxPageSize = 1000
|
||||
)
|
||||
|
||||
func convertStateFromStore(rowStatus store.RowStatus) v1pb.State {
|
||||
func convertStateFromStore(rowStatus store.RowStatus) apipb.State {
|
||||
switch rowStatus {
|
||||
case store.Normal:
|
||||
return v1pb.State_NORMAL
|
||||
return apipb.State_NORMAL
|
||||
case store.Archived:
|
||||
return v1pb.State_ARCHIVED
|
||||
return apipb.State_ARCHIVED
|
||||
default:
|
||||
return v1pb.State_STATE_UNSPECIFIED
|
||||
return apipb.State_STATE_UNSPECIFIED
|
||||
}
|
||||
}
|
||||
|
||||
func convertStateToStore(state v1pb.State) store.RowStatus {
|
||||
func convertStateToStore(state apipb.State) store.RowStatus {
|
||||
switch state {
|
||||
case v1pb.State_ARCHIVED:
|
||||
case apipb.State_ARCHIVED:
|
||||
return store.Archived
|
||||
default:
|
||||
return store.Normal
|
||||
@@ -38,7 +38,7 @@ func convertStateToStore(state v1pb.State) store.RowStatus {
|
||||
}
|
||||
|
||||
func getPageToken(limit int, offset int) (string, error) {
|
||||
return marshalPageToken(&v1pb.PageToken{
|
||||
return marshalPageToken(&apipb.PageToken{
|
||||
Limit: int32(limit),
|
||||
Offset: int32(offset),
|
||||
})
|
||||
@@ -55,7 +55,7 @@ func normalizePageSize(pageSize int32) int {
|
||||
return limit
|
||||
}
|
||||
|
||||
func marshalPageToken(pageToken *v1pb.PageToken) (string, error) {
|
||||
func marshalPageToken(pageToken *apipb.PageToken) (string, error) {
|
||||
b, err := proto.Marshal(pageToken)
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "failed to marshal page token")
|
||||
@@ -63,7 +63,7 @@ func marshalPageToken(pageToken *v1pb.PageToken) (string, error) {
|
||||
return base64.StdEncoding.EncodeToString(b), nil
|
||||
}
|
||||
|
||||
func unmarshalPageToken(s string, pageToken *v1pb.PageToken) error {
|
||||
func unmarshalPageToken(s string, pageToken *apipb.PageToken) error {
|
||||
b, err := base64.StdEncoding.DecodeString(s)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to decode page token")
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/usememos/memos/proto/gen/api/v1/apiv1connect"
|
||||
"github.com/usememos/memos/proto/gen/api/apiconnect"
|
||||
)
|
||||
|
||||
// ConnectServiceHandler wraps APIV1Service to implement Connect handler interfaces.
|
||||
// ConnectServiceHandler wraps APIService to implement Connect handler interfaces.
|
||||
// It adapts the existing gRPC service implementations to work with Connect's
|
||||
// request/response wrapper types.
|
||||
//
|
||||
@@ -20,12 +20,12 @@ import (
|
||||
// - Support both native gRPC and Connect protocols
|
||||
// - Maintain a single source of truth for business logic.
|
||||
type ConnectServiceHandler struct {
|
||||
*APIV1Service
|
||||
*APIService
|
||||
}
|
||||
|
||||
// NewConnectServiceHandler creates a new Connect service handler.
|
||||
func NewConnectServiceHandler(svc *APIV1Service) *ConnectServiceHandler {
|
||||
return &ConnectServiceHandler{APIV1Service: svc}
|
||||
func NewConnectServiceHandler(svc *APIService) *ConnectServiceHandler {
|
||||
return &ConnectServiceHandler{APIService: svc}
|
||||
}
|
||||
|
||||
// RegisterConnectHandlers registers all Connect service handlers on the given mux.
|
||||
@@ -35,14 +35,14 @@ func (s *ConnectServiceHandler) RegisterConnectHandlers(mux *http.ServeMux, opts
|
||||
path string
|
||||
handler http.Handler
|
||||
}{
|
||||
wrap(apiv1connect.NewInstanceServiceHandler(s, opts...)),
|
||||
wrap(apiv1connect.NewAuthServiceHandler(s, opts...)),
|
||||
wrap(apiv1connect.NewUserServiceHandler(s, opts...)),
|
||||
wrap(apiv1connect.NewMemoServiceHandler(s, opts...)),
|
||||
wrap(apiv1connect.NewSpaceServiceHandler(s, opts...)),
|
||||
wrap(apiv1connect.NewAttachmentServiceHandler(s, opts...)),
|
||||
wrap(apiv1connect.NewAIServiceHandler(s, opts...)),
|
||||
wrap(apiv1connect.NewIdentityProviderServiceHandler(s, opts...)),
|
||||
wrap(apiconnect.NewInstanceServiceHandler(s, opts...)),
|
||||
wrap(apiconnect.NewAuthServiceHandler(s, opts...)),
|
||||
wrap(apiconnect.NewUserServiceHandler(s, opts...)),
|
||||
wrap(apiconnect.NewMemoServiceHandler(s, opts...)),
|
||||
wrap(apiconnect.NewSpaceServiceHandler(s, opts...)),
|
||||
wrap(apiconnect.NewAttachmentServiceHandler(s, opts...)),
|
||||
wrap(apiconnect.NewAIServiceHandler(s, opts...)),
|
||||
wrap(apiconnect.NewIdentityProviderServiceHandler(s, opts...)),
|
||||
}
|
||||
|
||||
for _, h := range handlers {
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"strings"
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"google.golang.org/genproto/googleapis/api/httpbody"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
)
|
||||
|
||||
// This file contains all Connect service handler method implementations.
|
||||
@@ -16,48 +16,48 @@ import (
|
||||
|
||||
// InstanceService
|
||||
|
||||
func (s *ConnectServiceHandler) GetInstanceProfile(ctx context.Context, req *connect.Request[v1pb.GetInstanceProfileRequest]) (*connect.Response[v1pb.InstanceProfile], error) {
|
||||
resp, err := s.APIV1Service.GetInstanceProfile(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetInstanceProfile(ctx context.Context, req *connect.Request[apipb.GetInstanceProfileRequest]) (*connect.Response[apipb.InstanceProfile], error) {
|
||||
resp, err := s.APIService.GetInstanceProfile(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetInstanceSetting(ctx context.Context, req *connect.Request[v1pb.GetInstanceSettingRequest]) (*connect.Response[v1pb.InstanceSetting], error) {
|
||||
resp, err := s.APIV1Service.GetInstanceSetting(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetInstanceSetting(ctx context.Context, req *connect.Request[apipb.GetInstanceSettingRequest]) (*connect.Response[apipb.InstanceSetting], error) {
|
||||
resp, err := s.APIService.GetInstanceSetting(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) BatchGetInstanceSettings(ctx context.Context, req *connect.Request[v1pb.BatchGetInstanceSettingsRequest]) (*connect.Response[v1pb.BatchGetInstanceSettingsResponse], error) {
|
||||
resp, err := s.APIV1Service.BatchGetInstanceSettings(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) BatchGetInstanceSettings(ctx context.Context, req *connect.Request[apipb.BatchGetInstanceSettingsRequest]) (*connect.Response[apipb.BatchGetInstanceSettingsResponse], error) {
|
||||
resp, err := s.APIService.BatchGetInstanceSettings(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) UpdateInstanceSetting(ctx context.Context, req *connect.Request[v1pb.UpdateInstanceSettingRequest]) (*connect.Response[v1pb.InstanceSetting], error) {
|
||||
resp, err := s.APIV1Service.UpdateInstanceSetting(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UpdateInstanceSetting(ctx context.Context, req *connect.Request[apipb.UpdateInstanceSettingRequest]) (*connect.Response[apipb.InstanceSetting], error) {
|
||||
resp, err := s.APIService.UpdateInstanceSetting(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) TestInstanceEmailSetting(ctx context.Context, req *connect.Request[v1pb.TestInstanceEmailSettingRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.TestInstanceEmailSetting(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) TestInstanceEmailSetting(ctx context.Context, req *connect.Request[apipb.TestInstanceEmailSettingRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.TestInstanceEmailSetting(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetInstanceStats(ctx context.Context, req *connect.Request[v1pb.GetInstanceStatsRequest]) (*connect.Response[v1pb.InstanceStats], error) {
|
||||
resp, err := s.APIV1Service.GetInstanceStats(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetInstanceStats(ctx context.Context, req *connect.Request[apipb.GetInstanceStatsRequest]) (*connect.Response[apipb.InstanceStats], error) {
|
||||
resp, err := s.APIService.GetInstanceStats(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
@@ -70,248 +70,248 @@ func (s *ConnectServiceHandler) GetInstanceStats(ctx context.Context, req *conne
|
||||
// We use connectWithHeaderCarrier helper to inject a header carrier into the context,
|
||||
// which allows the service to set headers in a protocol-agnostic way.
|
||||
|
||||
func (s *ConnectServiceHandler) GetCurrentUser(ctx context.Context, req *connect.Request[v1pb.GetCurrentUserRequest]) (*connect.Response[v1pb.GetCurrentUserResponse], error) {
|
||||
return connectWithHeaderCarrier(ctx, func(ctx context.Context) (*v1pb.GetCurrentUserResponse, error) {
|
||||
return s.APIV1Service.GetCurrentUser(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetCurrentUser(ctx context.Context, req *connect.Request[apipb.GetCurrentUserRequest]) (*connect.Response[apipb.GetCurrentUserResponse], error) {
|
||||
return connectWithHeaderCarrier(ctx, func(ctx context.Context) (*apipb.GetCurrentUserResponse, error) {
|
||||
return s.APIService.GetCurrentUser(ctx, req.Msg)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) SignIn(ctx context.Context, req *connect.Request[v1pb.SignInRequest]) (*connect.Response[v1pb.SignInResponse], error) {
|
||||
return connectWithHeaderCarrier(ctx, func(ctx context.Context) (*v1pb.SignInResponse, error) {
|
||||
return s.APIV1Service.SignIn(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) SignIn(ctx context.Context, req *connect.Request[apipb.SignInRequest]) (*connect.Response[apipb.SignInResponse], error) {
|
||||
return connectWithHeaderCarrier(ctx, func(ctx context.Context) (*apipb.SignInResponse, error) {
|
||||
return s.APIService.SignIn(ctx, req.Msg)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) SignOut(ctx context.Context, req *connect.Request[v1pb.SignOutRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
func (s *ConnectServiceHandler) SignOut(ctx context.Context, req *connect.Request[apipb.SignOutRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return connectWithHeaderCarrier(ctx, func(ctx context.Context) (*emptypb.Empty, error) {
|
||||
return s.APIV1Service.SignOut(ctx, req.Msg)
|
||||
return s.APIService.SignOut(ctx, req.Msg)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) RefreshToken(ctx context.Context, req *connect.Request[v1pb.RefreshTokenRequest]) (*connect.Response[v1pb.RefreshTokenResponse], error) {
|
||||
return connectWithHeaderCarrier(ctx, func(ctx context.Context) (*v1pb.RefreshTokenResponse, error) {
|
||||
return s.APIV1Service.RefreshToken(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) RefreshToken(ctx context.Context, req *connect.Request[apipb.RefreshTokenRequest]) (*connect.Response[apipb.RefreshTokenResponse], error) {
|
||||
return connectWithHeaderCarrier(ctx, func(ctx context.Context) (*apipb.RefreshTokenResponse, error) {
|
||||
return s.APIService.RefreshToken(ctx, req.Msg)
|
||||
})
|
||||
}
|
||||
|
||||
// UserService
|
||||
|
||||
func (s *ConnectServiceHandler) ListUsers(ctx context.Context, req *connect.Request[v1pb.ListUsersRequest]) (*connect.Response[v1pb.ListUsersResponse], error) {
|
||||
resp, err := s.APIV1Service.ListUsers(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListUsers(ctx context.Context, req *connect.Request[apipb.ListUsersRequest]) (*connect.Response[apipb.ListUsersResponse], error) {
|
||||
resp, err := s.APIService.ListUsers(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) BatchGetUsers(ctx context.Context, req *connect.Request[v1pb.BatchGetUsersRequest]) (*connect.Response[v1pb.BatchGetUsersResponse], error) {
|
||||
resp, err := s.APIV1Service.BatchGetUsers(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) BatchGetUsers(ctx context.Context, req *connect.Request[apipb.BatchGetUsersRequest]) (*connect.Response[apipb.BatchGetUsersResponse], error) {
|
||||
resp, err := s.APIService.BatchGetUsers(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetUser(ctx context.Context, req *connect.Request[v1pb.GetUserRequest]) (*connect.Response[v1pb.User], error) {
|
||||
resp, err := s.APIV1Service.GetUser(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetUser(ctx context.Context, req *connect.Request[apipb.GetUserRequest]) (*connect.Response[apipb.User], error) {
|
||||
resp, err := s.APIService.GetUser(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) CreateUser(ctx context.Context, req *connect.Request[v1pb.CreateUserRequest]) (*connect.Response[v1pb.User], error) {
|
||||
resp, err := s.APIV1Service.CreateUser(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) CreateUser(ctx context.Context, req *connect.Request[apipb.CreateUserRequest]) (*connect.Response[apipb.User], error) {
|
||||
resp, err := s.APIService.CreateUser(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) UpdateUser(ctx context.Context, req *connect.Request[v1pb.UpdateUserRequest]) (*connect.Response[v1pb.User], error) {
|
||||
resp, err := s.APIV1Service.UpdateUser(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UpdateUser(ctx context.Context, req *connect.Request[apipb.UpdateUserRequest]) (*connect.Response[apipb.User], error) {
|
||||
resp, err := s.APIService.UpdateUser(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeleteUser(ctx context.Context, req *connect.Request[v1pb.DeleteUserRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
func (s *ConnectServiceHandler) DeleteUser(ctx context.Context, req *connect.Request[apipb.DeleteUserRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return connectWithHeaderCarrier(ctx, func(ctx context.Context) (*emptypb.Empty, error) {
|
||||
return s.APIV1Service.DeleteUser(ctx, req.Msg)
|
||||
return s.APIService.DeleteUser(ctx, req.Msg)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListAllUserStats(ctx context.Context, req *connect.Request[v1pb.ListAllUserStatsRequest]) (*connect.Response[v1pb.ListAllUserStatsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListAllUserStats(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListUserStats(ctx context.Context, req *connect.Request[apipb.ListUserStatsRequest]) (*connect.Response[apipb.ListUserStatsResponse], error) {
|
||||
resp, err := s.APIService.ListUserStats(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetUserStats(ctx context.Context, req *connect.Request[v1pb.GetUserStatsRequest]) (*connect.Response[v1pb.UserStats], error) {
|
||||
resp, err := s.APIV1Service.GetUserStats(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetUserStats(ctx context.Context, req *connect.Request[apipb.GetUserStatsRequest]) (*connect.Response[apipb.UserStats], error) {
|
||||
resp, err := s.APIService.GetUserStats(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ExportMemos(ctx context.Context, req *connect.Request[v1pb.ExportMemosRequest]) (*connect.Response[httpbody.HttpBody], error) {
|
||||
resp, err := s.APIV1Service.ExportMemos(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ExportMemos(ctx context.Context, req *connect.Request[apipb.ExportMemosRequest]) (*connect.Response[httpbody.HttpBody], error) {
|
||||
resp, err := s.APIService.ExportMemos(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ImportMemos(ctx context.Context, req *connect.Request[v1pb.ImportMemosRequest]) (*connect.Response[v1pb.ImportMemosResponse], error) {
|
||||
resp, err := s.APIV1Service.ImportMemos(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ImportMemos(ctx context.Context, req *connect.Request[apipb.ImportMemosRequest]) (*connect.Response[apipb.ImportMemosResponse], error) {
|
||||
resp, err := s.APIService.ImportMemos(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetUserSetting(ctx context.Context, req *connect.Request[v1pb.GetUserSettingRequest]) (*connect.Response[v1pb.UserSetting], error) {
|
||||
resp, err := s.APIV1Service.GetUserSetting(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetUserSetting(ctx context.Context, req *connect.Request[apipb.GetUserSettingRequest]) (*connect.Response[apipb.UserSetting], error) {
|
||||
resp, err := s.APIService.GetUserSetting(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) UpdateUserSetting(ctx context.Context, req *connect.Request[v1pb.UpdateUserSettingRequest]) (*connect.Response[v1pb.UserSetting], error) {
|
||||
resp, err := s.APIV1Service.UpdateUserSetting(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UpdateUserSetting(ctx context.Context, req *connect.Request[apipb.UpdateUserSettingRequest]) (*connect.Response[apipb.UserSetting], error) {
|
||||
resp, err := s.APIService.UpdateUserSetting(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListUserSettings(ctx context.Context, req *connect.Request[v1pb.ListUserSettingsRequest]) (*connect.Response[v1pb.ListUserSettingsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListUserSettings(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListUserSettings(ctx context.Context, req *connect.Request[apipb.ListUserSettingsRequest]) (*connect.Response[apipb.ListUserSettingsResponse], error) {
|
||||
resp, err := s.APIService.ListUserSettings(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListLinkedIdentities(ctx context.Context, req *connect.Request[v1pb.ListLinkedIdentitiesRequest]) (*connect.Response[v1pb.ListLinkedIdentitiesResponse], error) {
|
||||
resp, err := s.APIV1Service.ListLinkedIdentities(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListLinkedIdentities(ctx context.Context, req *connect.Request[apipb.ListLinkedIdentitiesRequest]) (*connect.Response[apipb.ListLinkedIdentitiesResponse], error) {
|
||||
resp, err := s.APIService.ListLinkedIdentities(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) CreateLinkedIdentity(ctx context.Context, req *connect.Request[v1pb.CreateLinkedIdentityRequest]) (*connect.Response[v1pb.LinkedIdentity], error) {
|
||||
resp, err := s.APIV1Service.CreateLinkedIdentity(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) CreateLinkedIdentity(ctx context.Context, req *connect.Request[apipb.CreateLinkedIdentityRequest]) (*connect.Response[apipb.LinkedIdentity], error) {
|
||||
resp, err := s.APIService.CreateLinkedIdentity(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetLinkedIdentity(ctx context.Context, req *connect.Request[v1pb.GetLinkedIdentityRequest]) (*connect.Response[v1pb.LinkedIdentity], error) {
|
||||
resp, err := s.APIV1Service.GetLinkedIdentity(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetLinkedIdentity(ctx context.Context, req *connect.Request[apipb.GetLinkedIdentityRequest]) (*connect.Response[apipb.LinkedIdentity], error) {
|
||||
resp, err := s.APIService.GetLinkedIdentity(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeleteLinkedIdentity(ctx context.Context, req *connect.Request[v1pb.DeleteLinkedIdentityRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteLinkedIdentity(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeleteLinkedIdentity(ctx context.Context, req *connect.Request[apipb.DeleteLinkedIdentityRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeleteLinkedIdentity(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListPersonalAccessTokens(ctx context.Context, req *connect.Request[v1pb.ListPersonalAccessTokensRequest]) (*connect.Response[v1pb.ListPersonalAccessTokensResponse], error) {
|
||||
resp, err := s.APIV1Service.ListPersonalAccessTokens(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListPersonalAccessTokens(ctx context.Context, req *connect.Request[apipb.ListPersonalAccessTokensRequest]) (*connect.Response[apipb.ListPersonalAccessTokensResponse], error) {
|
||||
resp, err := s.APIService.ListPersonalAccessTokens(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) CreatePersonalAccessToken(ctx context.Context, req *connect.Request[v1pb.CreatePersonalAccessTokenRequest]) (*connect.Response[v1pb.CreatePersonalAccessTokenResponse], error) {
|
||||
resp, err := s.APIV1Service.CreatePersonalAccessToken(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) CreatePersonalAccessToken(ctx context.Context, req *connect.Request[apipb.CreatePersonalAccessTokenRequest]) (*connect.Response[apipb.CreatePersonalAccessTokenResponse], error) {
|
||||
resp, err := s.APIService.CreatePersonalAccessToken(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeletePersonalAccessToken(ctx context.Context, req *connect.Request[v1pb.DeletePersonalAccessTokenRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeletePersonalAccessToken(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeletePersonalAccessToken(ctx context.Context, req *connect.Request[apipb.DeletePersonalAccessTokenRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeletePersonalAccessToken(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListUserWebhooks(ctx context.Context, req *connect.Request[v1pb.ListUserWebhooksRequest]) (*connect.Response[v1pb.ListUserWebhooksResponse], error) {
|
||||
resp, err := s.APIV1Service.ListUserWebhooks(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListUserWebhooks(ctx context.Context, req *connect.Request[apipb.ListUserWebhooksRequest]) (*connect.Response[apipb.ListUserWebhooksResponse], error) {
|
||||
resp, err := s.APIService.ListUserWebhooks(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) CreateUserWebhook(ctx context.Context, req *connect.Request[v1pb.CreateUserWebhookRequest]) (*connect.Response[v1pb.UserWebhook], error) {
|
||||
resp, err := s.APIV1Service.CreateUserWebhook(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) CreateUserWebhook(ctx context.Context, req *connect.Request[apipb.CreateUserWebhookRequest]) (*connect.Response[apipb.UserWebhook], error) {
|
||||
resp, err := s.APIService.CreateUserWebhook(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) UpdateUserWebhook(ctx context.Context, req *connect.Request[v1pb.UpdateUserWebhookRequest]) (*connect.Response[v1pb.UserWebhook], error) {
|
||||
resp, err := s.APIV1Service.UpdateUserWebhook(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UpdateUserWebhook(ctx context.Context, req *connect.Request[apipb.UpdateUserWebhookRequest]) (*connect.Response[apipb.UserWebhook], error) {
|
||||
resp, err := s.APIService.UpdateUserWebhook(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeleteUserWebhook(ctx context.Context, req *connect.Request[v1pb.DeleteUserWebhookRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteUserWebhook(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeleteUserWebhook(ctx context.Context, req *connect.Request[apipb.DeleteUserWebhookRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeleteUserWebhook(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetUserWebhookSigningSecret(ctx context.Context, req *connect.Request[v1pb.GetUserWebhookSigningSecretRequest]) (*connect.Response[v1pb.GetUserWebhookSigningSecretResponse], error) {
|
||||
resp, err := s.APIV1Service.GetUserWebhookSigningSecret(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetUserWebhookSigningSecret(ctx context.Context, req *connect.Request[apipb.GetUserWebhookSigningSecretRequest]) (*connect.Response[apipb.GetUserWebhookSigningSecretResponse], error) {
|
||||
resp, err := s.APIService.GetUserWebhookSigningSecret(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListUserNotifications(ctx context.Context, req *connect.Request[v1pb.ListUserNotificationsRequest]) (*connect.Response[v1pb.ListUserNotificationsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListUserNotifications(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListUserNotifications(ctx context.Context, req *connect.Request[apipb.ListUserNotificationsRequest]) (*connect.Response[apipb.ListUserNotificationsResponse], error) {
|
||||
resp, err := s.APIService.ListUserNotifications(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) UpdateUserNotification(ctx context.Context, req *connect.Request[v1pb.UpdateUserNotificationRequest]) (*connect.Response[v1pb.UserNotification], error) {
|
||||
resp, err := s.APIV1Service.UpdateUserNotification(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UpdateUserNotification(ctx context.Context, req *connect.Request[apipb.UpdateUserNotificationRequest]) (*connect.Response[apipb.UserNotification], error) {
|
||||
resp, err := s.APIService.UpdateUserNotification(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeleteUserNotification(ctx context.Context, req *connect.Request[v1pb.DeleteUserNotificationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteUserNotification(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeleteUserNotification(ctx context.Context, req *connect.Request[apipb.DeleteUserNotificationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeleteUserNotification(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
@@ -319,8 +319,8 @@ func (s *ConnectServiceHandler) DeleteUserNotification(ctx context.Context, req
|
||||
}
|
||||
|
||||
// ListMemoViews lists the saved memo views owned by a user.
|
||||
func (s *ConnectServiceHandler) ListMemoViews(ctx context.Context, req *connect.Request[v1pb.ListMemoViewsRequest]) (*connect.Response[v1pb.ListMemoViewsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListMemoViews(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListMemoViews(ctx context.Context, req *connect.Request[apipb.ListMemoViewsRequest]) (*connect.Response[apipb.ListMemoViewsResponse], error) {
|
||||
resp, err := s.APIService.ListMemoViews(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
@@ -328,8 +328,8 @@ func (s *ConnectServiceHandler) ListMemoViews(ctx context.Context, req *connect.
|
||||
}
|
||||
|
||||
// GetMemoView returns a saved memo view by resource name.
|
||||
func (s *ConnectServiceHandler) GetMemoView(ctx context.Context, req *connect.Request[v1pb.GetMemoViewRequest]) (*connect.Response[v1pb.MemoView], error) {
|
||||
resp, err := s.APIV1Service.GetMemoView(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetMemoView(ctx context.Context, req *connect.Request[apipb.GetMemoViewRequest]) (*connect.Response[apipb.MemoView], error) {
|
||||
resp, err := s.APIService.GetMemoView(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
@@ -337,8 +337,8 @@ func (s *ConnectServiceHandler) GetMemoView(ctx context.Context, req *connect.Re
|
||||
}
|
||||
|
||||
// CreateMemoView creates a saved memo view for a user.
|
||||
func (s *ConnectServiceHandler) CreateMemoView(ctx context.Context, req *connect.Request[v1pb.CreateMemoViewRequest]) (*connect.Response[v1pb.MemoView], error) {
|
||||
resp, err := s.APIV1Service.CreateMemoView(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) CreateMemoView(ctx context.Context, req *connect.Request[apipb.CreateMemoViewRequest]) (*connect.Response[apipb.MemoView], error) {
|
||||
resp, err := s.APIService.CreateMemoView(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
@@ -346,8 +346,8 @@ func (s *ConnectServiceHandler) CreateMemoView(ctx context.Context, req *connect
|
||||
}
|
||||
|
||||
// UpdateMemoView updates the selected fields of a saved memo view.
|
||||
func (s *ConnectServiceHandler) UpdateMemoView(ctx context.Context, req *connect.Request[v1pb.UpdateMemoViewRequest]) (*connect.Response[v1pb.MemoView], error) {
|
||||
resp, err := s.APIV1Service.UpdateMemoView(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UpdateMemoView(ctx context.Context, req *connect.Request[apipb.UpdateMemoViewRequest]) (*connect.Response[apipb.MemoView], error) {
|
||||
resp, err := s.APIService.UpdateMemoView(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
@@ -355,8 +355,8 @@ func (s *ConnectServiceHandler) UpdateMemoView(ctx context.Context, req *connect
|
||||
}
|
||||
|
||||
// DeleteMemoView deletes a saved memo view by resource name.
|
||||
func (s *ConnectServiceHandler) DeleteMemoView(ctx context.Context, req *connect.Request[v1pb.DeleteMemoViewRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteMemoView(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeleteMemoView(ctx context.Context, req *connect.Request[apipb.DeleteMemoViewRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeleteMemoView(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
@@ -365,160 +365,160 @@ func (s *ConnectServiceHandler) DeleteMemoView(ctx context.Context, req *connect
|
||||
|
||||
// MemoService
|
||||
|
||||
func (s *ConnectServiceHandler) CreateMemo(ctx context.Context, req *connect.Request[v1pb.CreateMemoRequest]) (*connect.Response[v1pb.Memo], error) {
|
||||
resp, err := s.APIV1Service.CreateMemo(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) CreateMemo(ctx context.Context, req *connect.Request[apipb.CreateMemoRequest]) (*connect.Response[apipb.Memo], error) {
|
||||
resp, err := s.APIService.CreateMemo(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListMemos(ctx context.Context, req *connect.Request[v1pb.ListMemosRequest]) (*connect.Response[v1pb.ListMemosResponse], error) {
|
||||
resp, err := s.APIV1Service.ListMemos(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListMemos(ctx context.Context, req *connect.Request[apipb.ListMemosRequest]) (*connect.Response[apipb.ListMemosResponse], error) {
|
||||
resp, err := s.APIService.ListMemos(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetMemo(ctx context.Context, req *connect.Request[v1pb.GetMemoRequest]) (*connect.Response[v1pb.Memo], error) {
|
||||
resp, err := s.APIV1Service.GetMemo(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetMemo(ctx context.Context, req *connect.Request[apipb.GetMemoRequest]) (*connect.Response[apipb.Memo], error) {
|
||||
resp, err := s.APIService.GetMemo(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) UpdateMemo(ctx context.Context, req *connect.Request[v1pb.UpdateMemoRequest]) (*connect.Response[v1pb.Memo], error) {
|
||||
resp, err := s.APIV1Service.UpdateMemo(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UpdateMemo(ctx context.Context, req *connect.Request[apipb.UpdateMemoRequest]) (*connect.Response[apipb.Memo], error) {
|
||||
resp, err := s.APIService.UpdateMemo(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeleteMemo(ctx context.Context, req *connect.Request[v1pb.DeleteMemoRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteMemo(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeleteMemo(ctx context.Context, req *connect.Request[apipb.DeleteMemoRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeleteMemo(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) SetMemoAttachments(ctx context.Context, req *connect.Request[v1pb.SetMemoAttachmentsRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.SetMemoAttachments(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) SetMemoAttachments(ctx context.Context, req *connect.Request[apipb.SetMemoAttachmentsRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.SetMemoAttachments(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListMemoAttachments(ctx context.Context, req *connect.Request[v1pb.ListMemoAttachmentsRequest]) (*connect.Response[v1pb.ListMemoAttachmentsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListMemoAttachments(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListMemoAttachments(ctx context.Context, req *connect.Request[apipb.ListMemoAttachmentsRequest]) (*connect.Response[apipb.ListMemoAttachmentsResponse], error) {
|
||||
resp, err := s.APIService.ListMemoAttachments(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) SetMemoRelations(ctx context.Context, req *connect.Request[v1pb.SetMemoRelationsRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.SetMemoRelations(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) SetMemoRelations(ctx context.Context, req *connect.Request[apipb.SetMemoRelationsRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.SetMemoRelations(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListMemoRelations(ctx context.Context, req *connect.Request[v1pb.ListMemoRelationsRequest]) (*connect.Response[v1pb.ListMemoRelationsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListMemoRelations(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListMemoRelations(ctx context.Context, req *connect.Request[apipb.ListMemoRelationsRequest]) (*connect.Response[apipb.ListMemoRelationsResponse], error) {
|
||||
resp, err := s.APIService.ListMemoRelations(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) CreateMemoComment(ctx context.Context, req *connect.Request[v1pb.CreateMemoCommentRequest]) (*connect.Response[v1pb.Memo], error) {
|
||||
resp, err := s.APIV1Service.CreateMemoComment(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) CreateMemoComment(ctx context.Context, req *connect.Request[apipb.CreateMemoCommentRequest]) (*connect.Response[apipb.Memo], error) {
|
||||
resp, err := s.APIService.CreateMemoComment(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListMemoComments(ctx context.Context, req *connect.Request[v1pb.ListMemoCommentsRequest]) (*connect.Response[v1pb.ListMemoCommentsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListMemoComments(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListMemoComments(ctx context.Context, req *connect.Request[apipb.ListMemoCommentsRequest]) (*connect.Response[apipb.ListMemoCommentsResponse], error) {
|
||||
resp, err := s.APIService.ListMemoComments(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListMemoReactions(ctx context.Context, req *connect.Request[v1pb.ListMemoReactionsRequest]) (*connect.Response[v1pb.ListMemoReactionsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListMemoReactions(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListMemoReactions(ctx context.Context, req *connect.Request[apipb.ListMemoReactionsRequest]) (*connect.Response[apipb.ListMemoReactionsResponse], error) {
|
||||
resp, err := s.APIService.ListMemoReactions(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) UpsertMemoReaction(ctx context.Context, req *connect.Request[v1pb.UpsertMemoReactionRequest]) (*connect.Response[v1pb.Reaction], error) {
|
||||
resp, err := s.APIV1Service.UpsertMemoReaction(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UpsertMemoReaction(ctx context.Context, req *connect.Request[apipb.UpsertMemoReactionRequest]) (*connect.Response[apipb.Reaction], error) {
|
||||
resp, err := s.APIService.UpsertMemoReaction(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeleteMemoReaction(ctx context.Context, req *connect.Request[v1pb.DeleteMemoReactionRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteMemoReaction(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeleteMemoReaction(ctx context.Context, req *connect.Request[apipb.DeleteMemoReactionRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeleteMemoReaction(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) CreateMemoShare(ctx context.Context, req *connect.Request[v1pb.CreateMemoShareRequest]) (*connect.Response[v1pb.MemoShare], error) {
|
||||
resp, err := s.APIV1Service.CreateMemoShare(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) CreateMemoShare(ctx context.Context, req *connect.Request[apipb.CreateMemoShareRequest]) (*connect.Response[apipb.MemoShare], error) {
|
||||
resp, err := s.APIService.CreateMemoShare(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListMemoShares(ctx context.Context, req *connect.Request[v1pb.ListMemoSharesRequest]) (*connect.Response[v1pb.ListMemoSharesResponse], error) {
|
||||
resp, err := s.APIV1Service.ListMemoShares(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListMemoShares(ctx context.Context, req *connect.Request[apipb.ListMemoSharesRequest]) (*connect.Response[apipb.ListMemoSharesResponse], error) {
|
||||
resp, err := s.APIService.ListMemoShares(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeleteMemoShare(ctx context.Context, req *connect.Request[v1pb.DeleteMemoShareRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteMemoShare(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeleteMemoShare(ctx context.Context, req *connect.Request[apipb.DeleteMemoShareRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeleteMemoShare(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetSharedMemo(ctx context.Context, req *connect.Request[v1pb.GetSharedMemoRequest]) (*connect.Response[v1pb.Memo], error) {
|
||||
resp, err := s.APIV1Service.GetSharedMemo(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetSharedMemo(ctx context.Context, req *connect.Request[apipb.GetSharedMemoRequest]) (*connect.Response[apipb.Memo], error) {
|
||||
resp, err := s.APIService.GetSharedMemo(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetLinkMetadata(ctx context.Context, req *connect.Request[v1pb.GetLinkMetadataRequest]) (*connect.Response[v1pb.LinkMetadata], error) {
|
||||
resp, err := s.APIV1Service.GetLinkMetadata(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetLinkMetadata(ctx context.Context, req *connect.Request[apipb.GetLinkMetadataRequest]) (*connect.Response[apipb.LinkMetadata], error) {
|
||||
resp, err := s.APIService.GetLinkMetadata(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) BatchGetLinkMetadata(ctx context.Context, req *connect.Request[v1pb.BatchGetLinkMetadataRequest]) (*connect.Response[v1pb.BatchGetLinkMetadataResponse], error) {
|
||||
resp, err := s.APIV1Service.BatchGetLinkMetadata(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) BatchGetLinkMetadata(ctx context.Context, req *connect.Request[apipb.BatchGetLinkMetadataRequest]) (*connect.Response[apipb.BatchGetLinkMetadataResponse], error) {
|
||||
resp, err := s.APIService.BatchGetLinkMetadata(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
@@ -527,128 +527,128 @@ func (s *ConnectServiceHandler) BatchGetLinkMetadata(ctx context.Context, req *c
|
||||
|
||||
// SpaceService
|
||||
|
||||
func (s *ConnectServiceHandler) CreateSpace(ctx context.Context, req *connect.Request[v1pb.CreateSpaceRequest]) (*connect.Response[v1pb.Space], error) {
|
||||
resp, err := s.APIV1Service.CreateSpace(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) CreateSpace(ctx context.Context, req *connect.Request[apipb.CreateSpaceRequest]) (*connect.Response[apipb.Space], error) {
|
||||
resp, err := s.APIService.CreateSpace(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListSpaces(ctx context.Context, req *connect.Request[v1pb.ListSpacesRequest]) (*connect.Response[v1pb.ListSpacesResponse], error) {
|
||||
resp, err := s.APIV1Service.ListSpaces(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListSpaces(ctx context.Context, req *connect.Request[apipb.ListSpacesRequest]) (*connect.Response[apipb.ListSpacesResponse], error) {
|
||||
resp, err := s.APIService.ListSpaces(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetSpace(ctx context.Context, req *connect.Request[v1pb.GetSpaceRequest]) (*connect.Response[v1pb.Space], error) {
|
||||
resp, err := s.APIV1Service.GetSpace(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetSpace(ctx context.Context, req *connect.Request[apipb.GetSpaceRequest]) (*connect.Response[apipb.Space], error) {
|
||||
resp, err := s.APIService.GetSpace(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) UpdateSpace(ctx context.Context, req *connect.Request[v1pb.UpdateSpaceRequest]) (*connect.Response[v1pb.Space], error) {
|
||||
resp, err := s.APIV1Service.UpdateSpace(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UpdateSpace(ctx context.Context, req *connect.Request[apipb.UpdateSpaceRequest]) (*connect.Response[apipb.Space], error) {
|
||||
resp, err := s.APIService.UpdateSpace(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeleteSpace(ctx context.Context, req *connect.Request[v1pb.DeleteSpaceRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteSpace(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeleteSpace(ctx context.Context, req *connect.Request[apipb.DeleteSpaceRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeleteSpace(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) CreateSpaceInvitation(ctx context.Context, req *connect.Request[v1pb.CreateSpaceInvitationRequest]) (*connect.Response[v1pb.SpaceInvitation], error) {
|
||||
resp, err := s.APIV1Service.CreateSpaceInvitation(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) CreateSpaceInvitation(ctx context.Context, req *connect.Request[apipb.CreateSpaceInvitationRequest]) (*connect.Response[apipb.SpaceInvitation], error) {
|
||||
resp, err := s.APIService.CreateSpaceInvitation(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListSpaceInvitations(ctx context.Context, req *connect.Request[v1pb.ListSpaceInvitationsRequest]) (*connect.Response[v1pb.ListSpaceInvitationsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListSpaceInvitations(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListSpaceInvitations(ctx context.Context, req *connect.Request[apipb.ListSpaceInvitationsRequest]) (*connect.Response[apipb.ListSpaceInvitationsResponse], error) {
|
||||
resp, err := s.APIService.ListSpaceInvitations(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListUserSpaceInvitations(ctx context.Context, req *connect.Request[v1pb.ListUserSpaceInvitationsRequest]) (*connect.Response[v1pb.ListUserSpaceInvitationsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListUserSpaceInvitations(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListUserSpaceInvitations(ctx context.Context, req *connect.Request[apipb.ListUserSpaceInvitationsRequest]) (*connect.Response[apipb.ListUserSpaceInvitationsResponse], error) {
|
||||
resp, err := s.APIService.ListUserSpaceInvitations(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetSpaceInvitation(ctx context.Context, req *connect.Request[v1pb.GetSpaceInvitationRequest]) (*connect.Response[v1pb.SpaceInvitation], error) {
|
||||
resp, err := s.APIV1Service.GetSpaceInvitation(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetSpaceInvitation(ctx context.Context, req *connect.Request[apipb.GetSpaceInvitationRequest]) (*connect.Response[apipb.SpaceInvitation], error) {
|
||||
resp, err := s.APIService.GetSpaceInvitation(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeleteSpaceInvitation(ctx context.Context, req *connect.Request[v1pb.DeleteSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteSpaceInvitation(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeleteSpaceInvitation(ctx context.Context, req *connect.Request[apipb.DeleteSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeleteSpaceInvitation(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) AcceptSpaceInvitation(ctx context.Context, req *connect.Request[v1pb.AcceptSpaceInvitationRequest]) (*connect.Response[v1pb.SpaceMember], error) {
|
||||
resp, err := s.APIV1Service.AcceptSpaceInvitation(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) AcceptSpaceInvitation(ctx context.Context, req *connect.Request[apipb.AcceptSpaceInvitationRequest]) (*connect.Response[apipb.SpaceMember], error) {
|
||||
resp, err := s.APIService.AcceptSpaceInvitation(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeclineSpaceInvitation(ctx context.Context, req *connect.Request[v1pb.DeclineSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeclineSpaceInvitation(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeclineSpaceInvitation(ctx context.Context, req *connect.Request[apipb.DeclineSpaceInvitationRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeclineSpaceInvitation(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListSpaceMembers(ctx context.Context, req *connect.Request[v1pb.ListSpaceMembersRequest]) (*connect.Response[v1pb.ListSpaceMembersResponse], error) {
|
||||
resp, err := s.APIV1Service.ListSpaceMembers(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListSpaceMembers(ctx context.Context, req *connect.Request[apipb.ListSpaceMembersRequest]) (*connect.Response[apipb.ListSpaceMembersResponse], error) {
|
||||
resp, err := s.APIService.ListSpaceMembers(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetSpaceMember(ctx context.Context, req *connect.Request[v1pb.GetSpaceMemberRequest]) (*connect.Response[v1pb.SpaceMember], error) {
|
||||
resp, err := s.APIV1Service.GetSpaceMember(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetSpaceMember(ctx context.Context, req *connect.Request[apipb.GetSpaceMemberRequest]) (*connect.Response[apipb.SpaceMember], error) {
|
||||
resp, err := s.APIService.GetSpaceMember(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) UpdateSpaceMember(ctx context.Context, req *connect.Request[v1pb.UpdateSpaceMemberRequest]) (*connect.Response[v1pb.SpaceMember], error) {
|
||||
resp, err := s.APIV1Service.UpdateSpaceMember(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UpdateSpaceMember(ctx context.Context, req *connect.Request[apipb.UpdateSpaceMemberRequest]) (*connect.Response[apipb.SpaceMember], error) {
|
||||
resp, err := s.APIService.UpdateSpaceMember(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeleteSpaceMember(ctx context.Context, req *connect.Request[v1pb.DeleteSpaceMemberRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteSpaceMember(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeleteSpaceMember(ctx context.Context, req *connect.Request[apipb.DeleteSpaceMemberRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeleteSpaceMember(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
@@ -657,56 +657,56 @@ func (s *ConnectServiceHandler) DeleteSpaceMember(ctx context.Context, req *conn
|
||||
|
||||
// AttachmentService
|
||||
|
||||
func (s *ConnectServiceHandler) UploadAttachment(ctx context.Context, req *connect.Request[v1pb.UploadAttachmentRequest]) (*connect.Response[v1pb.UploadAttachmentResponse], error) {
|
||||
resp, err := s.APIV1Service.UploadAttachment(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UploadAttachment(ctx context.Context, req *connect.Request[apipb.UploadAttachmentRequest]) (*connect.Response[apipb.UploadAttachmentResponse], error) {
|
||||
resp, err := s.APIService.UploadAttachment(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) CreateAttachment(ctx context.Context, req *connect.Request[v1pb.CreateAttachmentRequest]) (*connect.Response[v1pb.Attachment], error) {
|
||||
resp, err := s.APIV1Service.CreateAttachment(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) CreateAttachment(ctx context.Context, req *connect.Request[apipb.CreateAttachmentRequest]) (*connect.Response[apipb.Attachment], error) {
|
||||
resp, err := s.APIService.CreateAttachment(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) ListAttachments(ctx context.Context, req *connect.Request[v1pb.ListAttachmentsRequest]) (*connect.Response[v1pb.ListAttachmentsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListAttachments(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListAttachments(ctx context.Context, req *connect.Request[apipb.ListAttachmentsRequest]) (*connect.Response[apipb.ListAttachmentsResponse], error) {
|
||||
resp, err := s.APIService.ListAttachments(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetAttachment(ctx context.Context, req *connect.Request[v1pb.GetAttachmentRequest]) (*connect.Response[v1pb.Attachment], error) {
|
||||
resp, err := s.APIV1Service.GetAttachment(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetAttachment(ctx context.Context, req *connect.Request[apipb.GetAttachmentRequest]) (*connect.Response[apipb.Attachment], error) {
|
||||
resp, err := s.APIService.GetAttachment(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) UpdateAttachment(ctx context.Context, req *connect.Request[v1pb.UpdateAttachmentRequest]) (*connect.Response[v1pb.Attachment], error) {
|
||||
resp, err := s.APIV1Service.UpdateAttachment(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UpdateAttachment(ctx context.Context, req *connect.Request[apipb.UpdateAttachmentRequest]) (*connect.Response[apipb.Attachment], error) {
|
||||
resp, err := s.APIService.UpdateAttachment(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeleteAttachment(ctx context.Context, req *connect.Request[v1pb.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteAttachment(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeleteAttachment(ctx context.Context, req *connect.Request[apipb.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeleteAttachment(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) BatchDeleteAttachments(ctx context.Context, req *connect.Request[v1pb.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.BatchDeleteAttachments(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) BatchDeleteAttachments(ctx context.Context, req *connect.Request[apipb.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.BatchDeleteAttachments(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
@@ -715,8 +715,8 @@ func (s *ConnectServiceHandler) BatchDeleteAttachments(ctx context.Context, req
|
||||
|
||||
// AIService
|
||||
|
||||
func (s *ConnectServiceHandler) Transcribe(ctx context.Context, req *connect.Request[v1pb.TranscribeRequest]) (*connect.Response[v1pb.TranscribeResponse], error) {
|
||||
resp, err := s.APIV1Service.Transcribe(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) Transcribe(ctx context.Context, req *connect.Request[apipb.TranscribeRequest]) (*connect.Response[apipb.TranscribeResponse], error) {
|
||||
resp, err := s.APIService.Transcribe(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
@@ -725,40 +725,40 @@ func (s *ConnectServiceHandler) Transcribe(ctx context.Context, req *connect.Req
|
||||
|
||||
// IdentityProviderService
|
||||
|
||||
func (s *ConnectServiceHandler) ListIdentityProviders(ctx context.Context, req *connect.Request[v1pb.ListIdentityProvidersRequest]) (*connect.Response[v1pb.ListIdentityProvidersResponse], error) {
|
||||
resp, err := s.APIV1Service.ListIdentityProviders(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) ListIdentityProviders(ctx context.Context, req *connect.Request[apipb.ListIdentityProvidersRequest]) (*connect.Response[apipb.ListIdentityProvidersResponse], error) {
|
||||
resp, err := s.APIService.ListIdentityProviders(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) GetIdentityProvider(ctx context.Context, req *connect.Request[v1pb.GetIdentityProviderRequest]) (*connect.Response[v1pb.IdentityProvider], error) {
|
||||
resp, err := s.APIV1Service.GetIdentityProvider(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) GetIdentityProvider(ctx context.Context, req *connect.Request[apipb.GetIdentityProviderRequest]) (*connect.Response[apipb.IdentityProvider], error) {
|
||||
resp, err := s.APIService.GetIdentityProvider(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) CreateIdentityProvider(ctx context.Context, req *connect.Request[v1pb.CreateIdentityProviderRequest]) (*connect.Response[v1pb.IdentityProvider], error) {
|
||||
resp, err := s.APIV1Service.CreateIdentityProvider(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) CreateIdentityProvider(ctx context.Context, req *connect.Request[apipb.CreateIdentityProviderRequest]) (*connect.Response[apipb.IdentityProvider], error) {
|
||||
resp, err := s.APIService.CreateIdentityProvider(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) UpdateIdentityProvider(ctx context.Context, req *connect.Request[v1pb.UpdateIdentityProviderRequest]) (*connect.Response[v1pb.IdentityProvider], error) {
|
||||
resp, err := s.APIV1Service.UpdateIdentityProvider(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) UpdateIdentityProvider(ctx context.Context, req *connect.Request[apipb.UpdateIdentityProviderRequest]) (*connect.Response[apipb.IdentityProvider], error) {
|
||||
resp, err := s.APIService.UpdateIdentityProvider(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) DeleteIdentityProvider(ctx context.Context, req *connect.Request[v1pb.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteIdentityProvider(ctx, req.Msg)
|
||||
func (s *ConnectServiceHandler) DeleteIdentityProvider(ctx context.Context, req *connect.Request[apipb.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIService.DeleteIdentityProvider(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func (s *APIV1Service) validateMemoFilterForUser(ctx context.Context, filterText string, user *store.User) error {
|
||||
func (s *APIService) validateMemoFilterForUser(ctx context.Context, filterText string, user *store.User) error {
|
||||
engine, err := filterpkg.DefaultEngine()
|
||||
if err != nil {
|
||||
return status.Errorf(codes.Internal, "failed to initialize filter: %v", err)
|
||||
@@ -20,7 +20,7 @@ func (s *APIV1Service) validateMemoFilterForUser(ctx context.Context, filterText
|
||||
return s.validateFilterSpaceAccess(ctx, filterText, engine, user)
|
||||
}
|
||||
|
||||
func (s *APIV1Service) validateAttachmentFilterForUser(ctx context.Context, filterText string, user *store.User) error {
|
||||
func (s *APIService) validateAttachmentFilterForUser(ctx context.Context, filterText string, user *store.User) error {
|
||||
engine, err := filterpkg.DefaultAttachmentEngine()
|
||||
if err != nil {
|
||||
return status.Errorf(codes.Internal, "failed to initialize filter: %v", err)
|
||||
@@ -28,7 +28,7 @@ func (s *APIV1Service) validateAttachmentFilterForUser(ctx context.Context, filt
|
||||
return s.validateFilterSpaceAccess(ctx, filterText, engine, user)
|
||||
}
|
||||
|
||||
func (s *APIV1Service) validateFilterSpaceAccess(ctx context.Context, filterText string, engine *filterpkg.Engine, user *store.User) error {
|
||||
func (s *APIService) validateFilterSpaceAccess(ctx context.Context, filterText string, engine *filterpkg.Engine, user *store.User) error {
|
||||
program, err := engine.Compile(ctx, filterText)
|
||||
if err != nil {
|
||||
return status.Errorf(codes.InvalidArgument, "invalid filter: %v", err)
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
)
|
||||
|
||||
// TestGatewayMarshalerOmitsUnsetMessageFields pins the REST payload shape the
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
// MCP clients, whose tool outputSchema is that same schema — reject the
|
||||
// response outright.
|
||||
func TestGatewayMarshalerOmitsUnsetMessageFields(t *testing.T) {
|
||||
attachment := &v1pb.Attachment{
|
||||
attachment := &apipb.Attachment{
|
||||
Name: "attachments/plainimage1",
|
||||
CreateTime: timestamppb.New(time.Unix(1700000000, 0).UTC()),
|
||||
Filename: "sunset.png",
|
||||
@@ -39,14 +39,14 @@ func TestGatewayMarshalerOmitsUnsetMessageFields(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGatewayMarshalerKeepsMediaMetadataFieldNames(t *testing.T) {
|
||||
attachment := &v1pb.Attachment{
|
||||
attachment := &apipb.Attachment{
|
||||
Name: "attachments/video1",
|
||||
Filename: "clip.mp4",
|
||||
Type: "video/mp4",
|
||||
MediaMetadata: &v1pb.MediaMetadata{
|
||||
MediaMetadata: &apipb.MediaMetadata{
|
||||
Width: proto.Int32(1920),
|
||||
Height: proto.Int32(1080),
|
||||
Details: &v1pb.MediaMetadata_Video{Video: &v1pb.VideoMetadata{
|
||||
Details: &apipb.MediaMetadata_Video{Video: &apipb.VideoMetadata{
|
||||
DurationSeconds: proto.Float64(12.5),
|
||||
}},
|
||||
},
|
||||
@@ -63,12 +63,12 @@ func TestGatewayMarshalerKeepsMediaMetadataFieldNames(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGatewayMarshalerNamesSourceExifOrientationExplicitly(t *testing.T) {
|
||||
attachment := &v1pb.Attachment{
|
||||
attachment := &apipb.Attachment{
|
||||
Name: "attachments/photo1",
|
||||
Filename: "photo.jpg",
|
||||
Type: "image/jpeg",
|
||||
MediaMetadata: &v1pb.MediaMetadata{
|
||||
Details: &v1pb.MediaMetadata_Photo{Photo: &v1pb.PhotoMetadata{
|
||||
MediaMetadata: &apipb.MediaMetadata{
|
||||
Details: &apipb.MediaMetadata_Photo{Photo: &apipb.PhotoMetadata{
|
||||
SourceExifOrientation: proto.Int32(6),
|
||||
}},
|
||||
},
|
||||
@@ -85,13 +85,13 @@ func TestGatewayMarshalerNamesSourceExifOrientationExplicitly(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGatewayMarshalerKeepsPopulatedMessageFields(t *testing.T) {
|
||||
attachment := &v1pb.Attachment{
|
||||
attachment := &apipb.Attachment{
|
||||
Name: "attachments/livephoto1",
|
||||
Filename: "walk.heic",
|
||||
Type: "image/heic",
|
||||
MotionMedia: &v1pb.MotionMedia{
|
||||
Family: v1pb.MotionMediaFamily_APPLE_LIVE_PHOTO,
|
||||
Role: v1pb.MotionMediaRole_STILL,
|
||||
MotionMedia: &apipb.MotionMedia{
|
||||
Family: apipb.MotionMediaFamily_APPLE_LIVE_PHOTO,
|
||||
Role: apipb.MotionMediaRole_STILL,
|
||||
GroupId: "group1",
|
||||
},
|
||||
}
|
||||
@@ -108,11 +108,11 @@ func TestGatewayMarshalerKeepsPopulatedMessageFields(t *testing.T) {
|
||||
// default-value behaviour: list fields the schema types as arrays must not
|
||||
// disappear when empty.
|
||||
func TestGatewayMarshalerKeepsEmptyCollections(t *testing.T) {
|
||||
memo := &v1pb.Memo{
|
||||
memo := &apipb.Memo{
|
||||
Name: "memos/plainmemo1",
|
||||
Content: "",
|
||||
State: v1pb.State_NORMAL,
|
||||
Visibility: v1pb.Visibility_PRIVATE,
|
||||
State: apipb.State_NORMAL,
|
||||
Visibility: apipb.Visibility_PRIVATE,
|
||||
}
|
||||
|
||||
payload := marshalThroughGateway(t, memo)
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// apiPackage is the proto package whose HTTP bindings the gateway serves.
|
||||
const apiPackage = "memos.api.v1"
|
||||
const apiPackage = "memos.api"
|
||||
|
||||
type gatewayRouteKey struct {
|
||||
httpMethod string
|
||||
+108
-39
@@ -1,17 +1,24 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/genproto/googleapis/api/annotations"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
memosproto "github.com/usememos/memos/proto"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
)
|
||||
|
||||
func TestCanonicalGatewayPattern(t *testing.T) {
|
||||
@@ -23,37 +30,37 @@ func TestCanonicalGatewayPattern(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "literal",
|
||||
template: "/api/v1/users",
|
||||
want: "/api/v1/users",
|
||||
template: "/api/users",
|
||||
want: "/api/users",
|
||||
},
|
||||
{
|
||||
name: "bare variable",
|
||||
template: "/api/v1/shares/{share_token}/memo",
|
||||
want: "/api/v1/shares/{share_token=*}/memo",
|
||||
template: "/api/shares/{share_token}/memo",
|
||||
want: "/api/shares/{share_token=*}/memo",
|
||||
},
|
||||
{
|
||||
name: "resource name variable",
|
||||
template: "/api/v1/{name=users/*}",
|
||||
want: "/api/v1/{name=users/*}",
|
||||
template: "/api/{name=users/*}",
|
||||
want: "/api/{name=users/*}",
|
||||
},
|
||||
{
|
||||
name: "variable with verb",
|
||||
template: "/api/v1/{name=users/*}:getStats",
|
||||
want: "/api/v1/{name=users/*}:getStats",
|
||||
template: "/api/{name=users/*}:getStats",
|
||||
want: "/api/{name=users/*}:getStats",
|
||||
},
|
||||
{
|
||||
name: "missing leading slash",
|
||||
template: "api/v1/users",
|
||||
template: "api/users",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "unclosed variable",
|
||||
template: "/api/v1/{name",
|
||||
template: "/api/{name",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "unexpected closing brace",
|
||||
template: "/api/v1/name}",
|
||||
template: "/api/name}",
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
@@ -84,28 +91,30 @@ func TestGatewayRouteResolverResolvesKnownRoutes(t *testing.T) {
|
||||
path string
|
||||
procedure string
|
||||
}{
|
||||
{http.MethodPost, "/api/v1/auth/signin", "/api/v1/auth/signin", "/memos.api.v1.AuthService/SignIn"},
|
||||
{http.MethodGet, "/api/v1/instance/profile", "/api/v1/instance/profile", "/memos.api.v1.InstanceService/GetInstanceProfile"},
|
||||
{http.MethodPost, "/api/v1/users", "/api/v1/users", "/memos.api.v1.UserService/CreateUser"},
|
||||
{http.MethodGet, "/api/v1/users", "/api/v1/users", "/memos.api.v1.UserService/ListUsers"},
|
||||
{http.MethodGet, "/api/v1/{name=users/*}", "/api/v1/users/1", "/memos.api.v1.UserService/GetUser"},
|
||||
{http.MethodGet, "/api/v1/{parent=users/*}/views", "/api/v1/users/alice/views", "/memos.api.v1.UserService/ListMemoViews"},
|
||||
{http.MethodPost, "/api/v1/{parent=users/*}/views", "/api/v1/users/alice/views", "/memos.api.v1.UserService/CreateMemoView"},
|
||||
{http.MethodGet, "/api/v1/{name=users/*/views/*}", "/api/v1/users/alice/views/work", "/memos.api.v1.UserService/GetMemoView"},
|
||||
{http.MethodPatch, "/api/v1/{memo_view.name=users/*/views/*}", "/api/v1/users/alice/views/work", "/memos.api.v1.UserService/UpdateMemoView"},
|
||||
{http.MethodDelete, "/api/v1/{name=users/*/views/*}", "/api/v1/users/alice/views/work", "/memos.api.v1.UserService/DeleteMemoView"},
|
||||
{http.MethodGet, "/api/v1/memos", "/api/v1/memos", "/memos.api.v1.MemoService/ListMemos"},
|
||||
{http.MethodGet, "/api/v1/{name=memos/*}", "/api/v1/memos/abc", "/memos.api.v1.MemoService/GetMemo"},
|
||||
{http.MethodPost, "/api/v1/memos", "/api/v1/memos", "/memos.api.v1.MemoService/CreateMemo"},
|
||||
{http.MethodPost, "/api/v1/spaces", "/api/v1/spaces", "/memos.api.v1.SpaceService/CreateSpace"},
|
||||
{http.MethodGet, "/api/v1/{name=spaces/*}", "/api/v1/spaces/team", "/memos.api.v1.SpaceService/GetSpace"},
|
||||
{http.MethodDelete, "/api/v1/{name=spaces/*}", "/api/v1/spaces/team", "/memos.api.v1.SpaceService/DeleteSpace"},
|
||||
{http.MethodGet, "/api/v1/{name=spaces/*/members/*}", "/api/v1/spaces/team/members/alice", "/memos.api.v1.SpaceService/GetSpaceMember"},
|
||||
{http.MethodPost, "/api/auth/signin", "/api/auth/signin", "/memos.api.AuthService/SignIn"},
|
||||
{http.MethodGet, "/api/instance/profile", "/api/instance/profile", "/memos.api.InstanceService/GetInstanceProfile"},
|
||||
{http.MethodPost, "/api/users", "/api/users", "/memos.api.UserService/CreateUser"},
|
||||
{http.MethodGet, "/api/users", "/api/users", "/memos.api.UserService/ListUsers"},
|
||||
{http.MethodGet, "/api/{name=users/*}", "/api/users/1", "/memos.api.UserService/GetUser"},
|
||||
{http.MethodGet, "/api/{parent=users/*}/stats", "/api/users/-/stats", "/memos.api.UserService/ListUserStats"},
|
||||
{http.MethodGet, "/api/{parent=users/*}/stats", "/api/users/alice/stats", "/memos.api.UserService/ListUserStats"},
|
||||
{http.MethodGet, "/api/{parent=users/*}/views", "/api/users/alice/views", "/memos.api.UserService/ListMemoViews"},
|
||||
{http.MethodPost, "/api/{parent=users/*}/views", "/api/users/alice/views", "/memos.api.UserService/CreateMemoView"},
|
||||
{http.MethodGet, "/api/{name=users/*/views/*}", "/api/users/alice/views/work", "/memos.api.UserService/GetMemoView"},
|
||||
{http.MethodPatch, "/api/{memo_view.name=users/*/views/*}", "/api/users/alice/views/work", "/memos.api.UserService/UpdateMemoView"},
|
||||
{http.MethodDelete, "/api/{name=users/*/views/*}", "/api/users/alice/views/work", "/memos.api.UserService/DeleteMemoView"},
|
||||
{http.MethodGet, "/api/memos", "/api/memos", "/memos.api.MemoService/ListMemos"},
|
||||
{http.MethodGet, "/api/{name=memos/*}", "/api/memos/abc", "/memos.api.MemoService/GetMemo"},
|
||||
{http.MethodPost, "/api/memos", "/api/memos", "/memos.api.MemoService/CreateMemo"},
|
||||
{http.MethodPost, "/api/spaces", "/api/spaces", "/memos.api.SpaceService/CreateSpace"},
|
||||
{http.MethodGet, "/api/{name=spaces/*}", "/api/spaces/team", "/memos.api.SpaceService/GetSpace"},
|
||||
{http.MethodDelete, "/api/{name=spaces/*}", "/api/spaces/team", "/memos.api.SpaceService/DeleteSpace"},
|
||||
{http.MethodGet, "/api/{name=spaces/*/members/*}", "/api/spaces/team/members/alice", "/memos.api.SpaceService/GetSpaceMember"},
|
||||
{
|
||||
http.MethodGet,
|
||||
"/api/v1/shares/{share_token}/memo",
|
||||
"/api/v1/shares/token:with-colon/memo",
|
||||
"/memos.api.v1.MemoService/GetSharedMemo",
|
||||
"/api/shares/{share_token}/memo",
|
||||
"/api/shares/token:with-colon/memo",
|
||||
"/memos.api.MemoService/GetSharedMemo",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -127,13 +136,13 @@ func TestGatewayRouteResolverResolvesFormPostFallback(t *testing.T) {
|
||||
t,
|
||||
resolver,
|
||||
http.MethodGet,
|
||||
"/api/v1/instance/profile",
|
||||
"/api/instance/profile",
|
||||
http.MethodPost,
|
||||
"/api/v1/instance/profile",
|
||||
"/api/instance/profile",
|
||||
"application/x-www-form-urlencoded",
|
||||
)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, "/memos.api.v1.InstanceService/GetInstanceProfile", procedure)
|
||||
require.Equal(t, "/memos.api.InstanceService/GetInstanceProfile", procedure)
|
||||
})
|
||||
|
||||
t.Run("uses matching POST binding", func(t *testing.T) {
|
||||
@@ -141,13 +150,13 @@ func TestGatewayRouteResolverResolvesFormPostFallback(t *testing.T) {
|
||||
t,
|
||||
resolver,
|
||||
http.MethodPost,
|
||||
"/api/v1/memos",
|
||||
"/api/memos",
|
||||
http.MethodPost,
|
||||
"/api/v1/memos",
|
||||
"/api/memos",
|
||||
"application/x-www-form-urlencoded",
|
||||
)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, "/memos.api.v1.MemoService/CreateMemo", procedure)
|
||||
require.Equal(t, "/memos.api.MemoService/CreateMemo", procedure)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -155,7 +164,7 @@ func TestGatewayRouteResolverRequiresMatchedPattern(t *testing.T) {
|
||||
resolver, err := newGatewayRouteResolver()
|
||||
require.NoError(t, err)
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "/api/v1/memos", nil)
|
||||
request := httptest.NewRequest(http.MethodGet, "/api/memos", nil)
|
||||
_, ok := resolver.resolveRequest(request)
|
||||
require.False(t, ok)
|
||||
}
|
||||
@@ -206,6 +215,66 @@ func TestGatewayRouteResolverCoversEveryBinding(t *testing.T) {
|
||||
t.Logf("verified %d HTTP bindings", checked)
|
||||
}
|
||||
|
||||
// TestOpenAPIPathsReachTheirGatewayMethods checks the published contract: every
|
||||
// path in the generated OpenAPI spec, filled with a sample value per parameter,
|
||||
// must reach the gateway method its operationId names. The OpenAPI generator
|
||||
// rewrites path templates, so a binding the gateway cannot match from the
|
||||
// advertised path (for example a literal inside a variable) fails here.
|
||||
func TestOpenAPIPathsReachTheirGatewayMethods(t *testing.T) {
|
||||
resolver, err := newGatewayRouteResolver()
|
||||
require.NoError(t, err)
|
||||
|
||||
// Register the services in production order with stub servers; the
|
||||
// middleware records the matched procedure without calling a handler.
|
||||
var matched string
|
||||
mux := runtime.NewServeMux(runtime.WithMiddlewares(func(runtime.HandlerFunc) runtime.HandlerFunc {
|
||||
return func(_ http.ResponseWriter, request *http.Request, _ map[string]string) {
|
||||
matched, _ = resolver.resolveRequest(request)
|
||||
}
|
||||
}))
|
||||
ctx := context.Background()
|
||||
require.NoError(t, apipb.RegisterInstanceServiceHandlerServer(ctx, mux, apipb.UnimplementedInstanceServiceServer{}))
|
||||
require.NoError(t, apipb.RegisterAuthServiceHandlerServer(ctx, mux, apipb.UnimplementedAuthServiceServer{}))
|
||||
require.NoError(t, apipb.RegisterUserServiceHandlerServer(ctx, mux, apipb.UnimplementedUserServiceServer{}))
|
||||
require.NoError(t, apipb.RegisterMemoServiceHandlerServer(ctx, mux, apipb.UnimplementedMemoServiceServer{}))
|
||||
require.NoError(t, apipb.RegisterSpaceServiceHandlerServer(ctx, mux, apipb.UnimplementedSpaceServiceServer{}))
|
||||
require.NoError(t, apipb.RegisterAttachmentServiceHandlerServer(ctx, mux, apipb.UnimplementedAttachmentServiceServer{}))
|
||||
require.NoError(t, apipb.RegisterAIServiceHandlerServer(ctx, mux, apipb.UnimplementedAIServiceServer{}))
|
||||
require.NoError(t, apipb.RegisterIdentityProviderServiceHandlerServer(ctx, mux, apipb.UnimplementedIdentityProviderServiceServer{}))
|
||||
|
||||
var spec struct {
|
||||
Paths map[string]map[string]struct {
|
||||
OperationID string `yaml:"operationId"`
|
||||
} `yaml:"paths"`
|
||||
}
|
||||
require.NoError(t, yaml.Unmarshal(memosproto.OpenAPIYAML(), &spec))
|
||||
require.NotEmpty(t, spec.Paths)
|
||||
|
||||
// The generator renders instance/settings/{setting} as /api/instance/{instance}/*,
|
||||
// which no client can call. Fixing it needs a different resource pattern;
|
||||
// remove an entry once its path is correct.
|
||||
knownBroken := map[string]bool{
|
||||
"InstanceService_GetInstanceSetting": true,
|
||||
"InstanceService_UpdateInstanceSetting": true,
|
||||
}
|
||||
|
||||
parameter := regexp.MustCompile(`\{[^}]+\}`)
|
||||
for path, operations := range spec.Paths {
|
||||
for method, operation := range operations {
|
||||
if knownBroken[operation.OperationID] {
|
||||
continue
|
||||
}
|
||||
service, rpc, ok := strings.Cut(operation.OperationID, "_")
|
||||
require.True(t, ok, "operationId %q", operation.OperationID)
|
||||
|
||||
matched = ""
|
||||
request := httptest.NewRequest(strings.ToUpper(method), parameter.ReplaceAllString(path, "sample"), nil)
|
||||
mux.ServeHTTP(httptest.NewRecorder(), request)
|
||||
assert.Equal(t, "/"+apiPackage+"."+service+"/"+rpc, matched, "%s %s", strings.ToUpper(method), path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func resolveThroughGateway(
|
||||
t *testing.T,
|
||||
resolver *gatewayRouteResolver,
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -90,14 +90,14 @@ func SetResponseHeader(ctx context.Context, key, value string) error {
|
||||
// It injects a HeaderCarrier into the context, calls the service method,
|
||||
// and applies any headers from the carrier to the Connect response.
|
||||
//
|
||||
// The generic parameter T is the non-pointer protobuf message type (e.g., v1pb.CreateSessionResponse),
|
||||
// The generic parameter T is the non-pointer protobuf message type (e.g., apipb.CreateSessionResponse),
|
||||
// while fn returns *T (the pointer type) as is standard for protobuf messages.
|
||||
//
|
||||
// Usage in Connect wrappers:
|
||||
//
|
||||
// func (s *ConnectServiceHandler) CreateSession(ctx context.Context, req *connect.Request[v1pb.CreateSessionRequest]) (*connect.Response[v1pb.CreateSessionResponse], error) {
|
||||
// return connectWithHeaderCarrier(ctx, func(ctx context.Context) (*v1pb.CreateSessionResponse, error) {
|
||||
// return s.APIV1Service.CreateSession(ctx, req.Msg)
|
||||
// func (s *ConnectServiceHandler) CreateSession(ctx context.Context, req *connect.Request[apipb.CreateSessionRequest]) (*connect.Response[apipb.CreateSessionResponse], error) {
|
||||
// return connectWithHeaderCarrier(ctx, func(ctx context.Context) (*apipb.CreateSessionResponse, error) {
|
||||
// return s.APIService.CreateSession(ctx, req.Msg)
|
||||
// })
|
||||
// }
|
||||
func connectWithHeaderCarrier[T any](ctx context.Context, fn func(context.Context) (*T, error)) (*connect.Response[T], error) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func (s *APIV1Service) Check(ctx context.Context,
|
||||
func (s *APIService) Check(ctx context.Context,
|
||||
_ *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) {
|
||||
// Check if database is initialized by verifying instance basic setting exists
|
||||
instanceBasicSetting, err := s.Store.GetInstanceBasicSetting(ctx)
|
||||
@@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
apipb "github.com/usememos/memos/proto/gen/api"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func (s *APIV1Service) CreateIdentityProvider(ctx context.Context, request *v1pb.CreateIdentityProviderRequest) (*v1pb.IdentityProvider, error) {
|
||||
func (s *APIService) CreateIdentityProvider(ctx context.Context, request *apipb.CreateIdentityProviderRequest) (*apipb.IdentityProvider, error) {
|
||||
currentUser, err := s.fetchCurrentUser(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get user: %v", err)
|
||||
@@ -44,14 +44,14 @@ func (s *APIV1Service) CreateIdentityProvider(ctx context.Context, request *v1pb
|
||||
return convertIdentityProviderFromStore(identityProvider), nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) ListIdentityProviders(ctx context.Context, _ *v1pb.ListIdentityProvidersRequest) (*v1pb.ListIdentityProvidersResponse, error) {
|
||||
func (s *APIService) ListIdentityProviders(ctx context.Context, _ *apipb.ListIdentityProvidersRequest) (*apipb.ListIdentityProvidersResponse, error) {
|
||||
identityProviders, err := s.Store.ListIdentityProviders(ctx, &store.FindIdentityProvider{})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to list identity providers, error: %+v", err)
|
||||
}
|
||||
|
||||
response := &v1pb.ListIdentityProvidersResponse{
|
||||
IdentityProviders: []*v1pb.IdentityProvider{},
|
||||
response := &apipb.ListIdentityProvidersResponse{
|
||||
IdentityProviders: []*apipb.IdentityProvider{},
|
||||
}
|
||||
for _, identityProvider := range identityProviders {
|
||||
response.IdentityProviders = append(response.IdentityProviders, convertIdentityProviderFromStore(identityProvider))
|
||||
@@ -59,7 +59,7 @@ func (s *APIV1Service) ListIdentityProviders(ctx context.Context, _ *v1pb.ListId
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) GetIdentityProvider(ctx context.Context, request *v1pb.GetIdentityProviderRequest) (*v1pb.IdentityProvider, error) {
|
||||
func (s *APIService) GetIdentityProvider(ctx context.Context, request *apipb.GetIdentityProviderRequest) (*apipb.IdentityProvider, error) {
|
||||
uid, err := ExtractIdentityProviderUIDFromName(request.Name)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid identity provider name: %v", err)
|
||||
@@ -77,7 +77,7 @@ func (s *APIV1Service) GetIdentityProvider(ctx context.Context, request *v1pb.Ge
|
||||
return convertIdentityProviderFromStore(identityProvider), nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) UpdateIdentityProvider(ctx context.Context, request *v1pb.UpdateIdentityProviderRequest) (*v1pb.IdentityProvider, error) {
|
||||
func (s *APIService) UpdateIdentityProvider(ctx context.Context, request *apipb.UpdateIdentityProviderRequest) (*apipb.IdentityProvider, error) {
|
||||
currentUser, err := s.fetchCurrentUser(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get user: %v", err)
|
||||
@@ -143,7 +143,7 @@ func (s *APIV1Service) UpdateIdentityProvider(ctx context.Context, request *v1pb
|
||||
return convertIdentityProviderFromStore(identityProvider), nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) DeleteIdentityProvider(ctx context.Context, request *v1pb.DeleteIdentityProviderRequest) (*emptypb.Empty, error) {
|
||||
func (s *APIService) DeleteIdentityProvider(ctx context.Context, request *apipb.DeleteIdentityProviderRequest) (*emptypb.Empty, error) {
|
||||
currentUser, err := s.fetchCurrentUser(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get user: %v", err)
|
||||
@@ -181,25 +181,25 @@ func (s *APIV1Service) DeleteIdentityProvider(ctx context.Context, request *v1pb
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
|
||||
func convertIdentityProviderFromStore(identityProvider *storepb.IdentityProvider) *v1pb.IdentityProvider {
|
||||
temp := &v1pb.IdentityProvider{
|
||||
func convertIdentityProviderFromStore(identityProvider *storepb.IdentityProvider) *apipb.IdentityProvider {
|
||||
temp := &apipb.IdentityProvider{
|
||||
Name: fmt.Sprintf("%s%s", IdentityProviderNamePrefix, identityProvider.Uid),
|
||||
Title: identityProvider.Name,
|
||||
IdentifierFilter: identityProvider.IdentifierFilter,
|
||||
Type: v1pb.IdentityProvider_Type(v1pb.IdentityProvider_Type_value[identityProvider.Type.String()]),
|
||||
Type: apipb.IdentityProvider_Type(apipb.IdentityProvider_Type_value[identityProvider.Type.String()]),
|
||||
}
|
||||
if identityProvider.Type == storepb.IdentityProvider_OAUTH2 {
|
||||
oauth2Config := identityProvider.Config.GetOauth2Config()
|
||||
temp.Config = &v1pb.IdentityProviderConfig{
|
||||
Config: &v1pb.IdentityProviderConfig_Oauth2Config{
|
||||
Oauth2Config: &v1pb.OAuth2Config{
|
||||
temp.Config = &apipb.IdentityProviderConfig{
|
||||
Config: &apipb.IdentityProviderConfig_Oauth2Config{
|
||||
Oauth2Config: &apipb.OAuth2Config{
|
||||
ClientId: oauth2Config.ClientId,
|
||||
// ClientSecret is write-only: never returned in responses.
|
||||
AuthUrl: oauth2Config.AuthUrl,
|
||||
TokenUrl: oauth2Config.TokenUrl,
|
||||
UserInfoUrl: oauth2Config.UserInfoUrl,
|
||||
Scopes: oauth2Config.Scopes,
|
||||
FieldMapping: &v1pb.FieldMapping{
|
||||
FieldMapping: &apipb.FieldMapping{
|
||||
Identifier: oauth2Config.FieldMapping.Identifier,
|
||||
DisplayName: oauth2Config.FieldMapping.DisplayName,
|
||||
Email: oauth2Config.FieldMapping.Email,
|
||||
@@ -212,7 +212,7 @@ func convertIdentityProviderFromStore(identityProvider *storepb.IdentityProvider
|
||||
return temp
|
||||
}
|
||||
|
||||
func convertIdentityProviderToStore(identityProvider *v1pb.IdentityProvider) *storepb.IdentityProvider {
|
||||
func convertIdentityProviderToStore(identityProvider *apipb.IdentityProvider) *storepb.IdentityProvider {
|
||||
temp := &storepb.IdentityProvider{
|
||||
Name: identityProvider.Title,
|
||||
IdentifierFilter: identityProvider.IdentifierFilter,
|
||||
@@ -222,8 +222,8 @@ func convertIdentityProviderToStore(identityProvider *v1pb.IdentityProvider) *st
|
||||
return temp
|
||||
}
|
||||
|
||||
func convertIdentityProviderConfigToStore(identityProviderType v1pb.IdentityProvider_Type, config *v1pb.IdentityProviderConfig) *storepb.IdentityProviderConfig {
|
||||
if identityProviderType == v1pb.IdentityProvider_OAUTH2 {
|
||||
func convertIdentityProviderConfigToStore(identityProviderType apipb.IdentityProvider_Type, config *apipb.IdentityProviderConfig) *storepb.IdentityProviderConfig {
|
||||
if identityProviderType == apipb.IdentityProvider_OAUTH2 {
|
||||
oauth2Config := config.GetOauth2Config()
|
||||
return &storepb.IdentityProviderConfig{
|
||||
Config: &storepb.IdentityProviderConfig_Oauth2Config{
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user