mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-03 20:40:00 -05:00
Go side: - Log hooks returned by Implemented() - Log each hook name -> ID mapping - Log OnActivate implementation status - Log OnActivate call flow Python side: - Log Implemented() return value - Log OnActivate gRPC receipt and handler invocation This is temporary debug logging to diagnose why OnActivate isn't being called for Python plugins. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
270 lines
10 KiB
Python
270 lines
10 KiB
Python
"""
|
|
@generated by mypy-protobuf. Do not edit manually!
|
|
isort:skip_file
|
|
Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
See LICENSE.txt for license information.
|
|
"""
|
|
|
|
from collections import abc as _abc
|
|
from google.protobuf import descriptor as _descriptor
|
|
from google.protobuf import message as _message
|
|
from google.protobuf import struct_pb2 as _struct_pb2
|
|
from google.protobuf.internal import containers as _containers
|
|
import builtins as _builtins
|
|
import sys
|
|
import typing as _typing
|
|
|
|
if sys.version_info >= (3, 10):
|
|
from typing import TypeAlias as _TypeAlias
|
|
else:
|
|
from typing_extensions import TypeAlias as _TypeAlias
|
|
|
|
DESCRIPTOR: _descriptor.FileDescriptor
|
|
|
|
@_typing.final
|
|
class Empty(_message.Message):
|
|
"""==============================================================================
|
|
RPC ENVELOPE CONVENTIONS
|
|
==============================================================================
|
|
|
|
This file defines the common types and conventions used across all Plugin API
|
|
and Hook RPCs. All service definitions in Phase 2 (API) and Phase 3 (Hooks)
|
|
MUST follow these conventions for consistency.
|
|
|
|
ERROR HANDLING STRATEGY:
|
|
------------------------
|
|
We use Response-embedded AppError (Option B) rather than gRPC status codes.
|
|
- Business errors are encoded in the response message's `error` field
|
|
- gRPC status codes are reserved for transport-level failures only
|
|
(timeouts, connection errors, unavailable plugin, etc.)
|
|
- This preserves full AppError semantics (id, message, detailed_error,
|
|
request_id, status_code, where, params) across language boundaries
|
|
|
|
REQUEST CONVENTIONS:
|
|
--------------------
|
|
Every RPC request message MUST:
|
|
- Be named `{MethodName}Request` (e.g., GetUserRequest, CreatePostRequest)
|
|
- Include `RequestContext context = 1;` as the first field (reserved tag 1)
|
|
- Include method-specific parameters as subsequent fields
|
|
|
|
Example:
|
|
message GetUserRequest {
|
|
RequestContext context = 1; // Required: request metadata
|
|
string user_id = 2; // Method-specific parameter
|
|
}
|
|
|
|
RESPONSE CONVENTIONS:
|
|
---------------------
|
|
Every RPC response message MUST:
|
|
- Be named `{MethodName}Response` (e.g., GetUserResponse, CreatePostResponse)
|
|
- Include `AppError error = 1;` as the first field (reserved tag 1)
|
|
- If error is set (non-null), the operation failed
|
|
- If error is null/empty, the operation succeeded
|
|
- Include the result value(s) as subsequent fields
|
|
|
|
Example:
|
|
message GetUserResponse {
|
|
AppError error = 1; // Null on success, populated on failure
|
|
User user = 2; // Result value (only valid if error is null)
|
|
}
|
|
|
|
For methods returning multiple values or complex results, use additional fields:
|
|
message ListUsersResponse {
|
|
AppError error = 1;
|
|
repeated User users = 2;
|
|
int32 total_count = 3;
|
|
}
|
|
|
|
For methods returning bool + error (like KVCompareAndSet):
|
|
message KVCompareAndSetResponse {
|
|
AppError error = 1;
|
|
bool success = 2;
|
|
}
|
|
|
|
==============================================================================
|
|
|
|
Empty is a placeholder message used for methods with no request/response data.
|
|
"""
|
|
|
|
DESCRIPTOR: _descriptor.Descriptor
|
|
|
|
def __init__(
|
|
self,
|
|
) -> None: ...
|
|
|
|
Global___Empty: _TypeAlias = Empty # noqa: Y015
|
|
|
|
@_typing.final
|
|
class StringMap(_message.Message):
|
|
"""StringMap represents a map of string to string values.
|
|
Used for User.Props, User.NotifyProps, User.Timezone, etc.
|
|
"""
|
|
|
|
DESCRIPTOR: _descriptor.Descriptor
|
|
|
|
@_typing.final
|
|
class ValuesEntry(_message.Message):
|
|
DESCRIPTOR: _descriptor.Descriptor
|
|
|
|
KEY_FIELD_NUMBER: _builtins.int
|
|
VALUE_FIELD_NUMBER: _builtins.int
|
|
key: _builtins.str
|
|
value: _builtins.str
|
|
def __init__(
|
|
self,
|
|
*,
|
|
key: _builtins.str = ...,
|
|
value: _builtins.str = ...,
|
|
) -> None: ...
|
|
_ClearFieldArgType: _TypeAlias = _typing.Literal["key", b"key", "value", b"value"] # noqa: Y015
|
|
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
|
|
|
|
VALUES_FIELD_NUMBER: _builtins.int
|
|
@_builtins.property
|
|
def values(self) -> _containers.ScalarMap[_builtins.str, _builtins.str]: ...
|
|
def __init__(
|
|
self,
|
|
*,
|
|
values: _abc.Mapping[_builtins.str, _builtins.str] | None = ...,
|
|
) -> None: ...
|
|
_ClearFieldArgType: _TypeAlias = _typing.Literal["values", b"values"] # noqa: Y015
|
|
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
|
|
|
|
Global___StringMap: _TypeAlias = StringMap # noqa: Y015
|
|
|
|
@_typing.final
|
|
class RequestContext(_message.Message):
|
|
"""RequestContext contains metadata for every RPC request.
|
|
This MUST be embedded as the first field (tag 1) in every request message.
|
|
Provides correlation IDs for logging, tracing, and debugging across
|
|
the Go server and Python plugin boundary.
|
|
"""
|
|
|
|
DESCRIPTOR: _descriptor.Descriptor
|
|
|
|
PLUGIN_ID_FIELD_NUMBER: _builtins.int
|
|
REQUEST_ID_FIELD_NUMBER: _builtins.int
|
|
SESSION_ID_FIELD_NUMBER: _builtins.int
|
|
USER_ID_FIELD_NUMBER: _builtins.int
|
|
plugin_id: _builtins.str
|
|
"""plugin_id is the logical plugin identifier (from manifest.id).
|
|
Used for routing, logging, and permission checks.
|
|
"""
|
|
request_id: _builtins.str
|
|
"""request_id is a unique identifier for this request.
|
|
Used to correlate logs across Go server and Python plugin.
|
|
Should be generated by the caller and propagated through the call chain.
|
|
"""
|
|
session_id: _builtins.str
|
|
"""session_id is the optional session identifier for the user making the request.
|
|
May be empty for plugin-initiated requests not tied to a user session.
|
|
"""
|
|
user_id: _builtins.str
|
|
"""user_id is the optional user identifier for auditing purposes.
|
|
May be empty for system-level operations.
|
|
"""
|
|
def __init__(
|
|
self,
|
|
*,
|
|
plugin_id: _builtins.str = ...,
|
|
request_id: _builtins.str = ...,
|
|
session_id: _builtins.str = ...,
|
|
user_id: _builtins.str = ...,
|
|
) -> None: ...
|
|
_ClearFieldArgType: _TypeAlias = _typing.Literal["plugin_id", b"plugin_id", "request_id", b"request_id", "session_id", b"session_id", "user_id", b"user_id"] # noqa: Y015
|
|
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
|
|
|
|
Global___RequestContext: _TypeAlias = RequestContext # noqa: Y015
|
|
|
|
@_typing.final
|
|
class AppError(_message.Message):
|
|
"""AppError represents an error returned by the Mattermost server.
|
|
Maps to model.AppError in Go.
|
|
|
|
This is embedded in every response message as field 1 to indicate
|
|
operation failure. A null/empty AppError indicates success.
|
|
"""
|
|
|
|
DESCRIPTOR: _descriptor.Descriptor
|
|
|
|
ID_FIELD_NUMBER: _builtins.int
|
|
MESSAGE_FIELD_NUMBER: _builtins.int
|
|
DETAILED_ERROR_FIELD_NUMBER: _builtins.int
|
|
REQUEST_ID_FIELD_NUMBER: _builtins.int
|
|
STATUS_CODE_FIELD_NUMBER: _builtins.int
|
|
WHERE_FIELD_NUMBER: _builtins.int
|
|
PARAMS_FIELD_NUMBER: _builtins.int
|
|
id: _builtins.str
|
|
"""A unique error identifier (e.g., "api.user.create.email_taken.app_error")
|
|
Used for error categorization and i18n lookup.
|
|
"""
|
|
message: _builtins.str
|
|
"""Human-readable error message (may be translated)
|
|
This is the user-facing message.
|
|
"""
|
|
detailed_error: _builtins.str
|
|
"""Internal error details for debugging
|
|
Contains technical details not shown to end users.
|
|
"""
|
|
request_id: _builtins.str
|
|
"""The request ID for tracing
|
|
Matches RequestContext.request_id for correlation.
|
|
"""
|
|
status_code: _builtins.int
|
|
"""HTTP status code (maps to standard HTTP codes)
|
|
Examples: 400 (Bad Request), 404 (Not Found), 500 (Internal Server Error)
|
|
"""
|
|
where: _builtins.str
|
|
"""The function/method where the error originated (e.g., "UserStore.Get")
|
|
Useful for debugging and error reporting.
|
|
"""
|
|
@_builtins.property
|
|
def params(self) -> _struct_pb2.Struct:
|
|
"""Optional parameters for error message interpolation.
|
|
Used when the error message is a template requiring variable substitution.
|
|
Example: {"field": "email", "value": "invalid@"} for validation errors.
|
|
Uses google.protobuf.Struct for flexible map[string]any representation.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
*,
|
|
id: _builtins.str = ...,
|
|
message: _builtins.str = ...,
|
|
detailed_error: _builtins.str = ...,
|
|
request_id: _builtins.str = ...,
|
|
status_code: _builtins.int = ...,
|
|
where: _builtins.str = ...,
|
|
params: _struct_pb2.Struct | None = ...,
|
|
) -> None: ...
|
|
_HasFieldArgType: _TypeAlias = _typing.Literal["params", b"params"] # noqa: Y015
|
|
def HasField(self, field_name: _HasFieldArgType) -> _builtins.bool: ...
|
|
_ClearFieldArgType: _TypeAlias = _typing.Literal["detailed_error", b"detailed_error", "id", b"id", "message", b"message", "params", b"params", "request_id", b"request_id", "status_code", b"status_code", "where", b"where"] # noqa: Y015
|
|
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
|
|
|
|
Global___AppError: _TypeAlias = AppError # noqa: Y015
|
|
|
|
@_typing.final
|
|
class ViewUsersRestrictions(_message.Message):
|
|
"""ViewUsersRestrictions restricts which users can be viewed.
|
|
Maps to model.ViewUsersRestrictions in Go.
|
|
"""
|
|
|
|
DESCRIPTOR: _descriptor.Descriptor
|
|
|
|
TEAMS_FIELD_NUMBER: _builtins.int
|
|
CHANNELS_FIELD_NUMBER: _builtins.int
|
|
@_builtins.property
|
|
def teams(self) -> _containers.RepeatedScalarFieldContainer[_builtins.str]: ...
|
|
@_builtins.property
|
|
def channels(self) -> _containers.RepeatedScalarFieldContainer[_builtins.str]: ...
|
|
def __init__(
|
|
self,
|
|
*,
|
|
teams: _abc.Iterable[_builtins.str] | None = ...,
|
|
channels: _abc.Iterable[_builtins.str] | None = ...,
|
|
) -> None: ...
|
|
_ClearFieldArgType: _TypeAlias = _typing.Literal["channels", b"channels", "teams", b"teams"] # noqa: Y015
|
|
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
|
|
|
|
Global___ViewUsersRestrictions: _TypeAlias = ViewUsersRestrictions # noqa: Y015
|