# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

from ai.stigmer.agentic.mcpserver.v1 import api_pb2 as ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2
from ai.stigmer.agentic.mcpserver.v1 import io_pb2 as ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_io__pb2
from ai.stigmer.commons.apiresource import io_pb2 as ai_dot_stigmer_dot_commons_dot_apiresource_dot_io__pb2


class McpServerCommandControllerStub(object):
    """McpServerCommandController provides write operations for MCP server resources.
    Supports creating, updating, and deleting MCP server definitions.

    Authorization model for writes:
    - Platform-scoped: Only platform operators can create/modify
    - Organization-scoped: Org admins can create/modify
    - Identity-account-scoped: Only the owner can create/modify

    Primary interface: The `apply` method provides Kubernetes-style idempotent
    create-or-update semantics, which is the recommended approach for CLI usage.
    """

    def __init__(self, channel):
        """Constructor.

        Args:
            channel: A grpc.Channel.
        """
        self.apply = channel.unary_unary(
                '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/apply',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
                _registered_method=True)
        self.create = channel.unary_unary(
                '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/create',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
                _registered_method=True)
        self.update = channel.unary_unary(
                '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/update',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
                _registered_method=True)
        self.delete = channel.unary_unary(
                '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/delete',
                request_serializer=ai_dot_stigmer_dot_commons_dot_apiresource_dot_io__pb2.ApiResourceDeleteInput.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
                _registered_method=True)
        self.updateVisibility = channel.unary_unary(
                '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/updateVisibility',
                request_serializer=ai_dot_stigmer_dot_commons_dot_apiresource_dot_io__pb2.UpdateVisibilityInput.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
                _registered_method=True)
        self.updateDiscoveredCapabilities = channel.unary_unary(
                '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/updateDiscoveredCapabilities',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_io__pb2.UpdateDiscoveredCapabilitiesInput.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
                _registered_method=True)
        self.discoverCapabilities = channel.unary_unary(
                '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/discoverCapabilities',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_io__pb2.DiscoverCapabilitiesInput.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
                _registered_method=True)


class McpServerCommandControllerServicer(object):
    """McpServerCommandController provides write operations for MCP server resources.
    Supports creating, updating, and deleting MCP server definitions.

    Authorization model for writes:
    - Platform-scoped: Only platform operators can create/modify
    - Organization-scoped: Org admins can create/modify
    - Identity-account-scoped: Only the owner can create/modify

    Primary interface: The `apply` method provides Kubernetes-style idempotent
    create-or-update semantics, which is the recommended approach for CLI usage.
    """

    def apply(self, request, context):
        """Create or update an MCP server resource (Kubernetes-style apply).

        This is the primary interface for MCP server management.
        Behavior:
        - If the resource doesn't exist: Creates a new MCP server
        - If the resource exists: Updates the existing MCP server

        The resource is identified by (scope, org, slug) combination.

        Input: Full McpServer resource with metadata and spec.
        Returns: The created/updated McpServer with system-populated fields.

        Authorization: Custom authorization in handler.
        The handler determines whether this is a create or update operation
        and performs appropriate scope-aware authorization:
        - Create: Requires permission to create in the target scope
        - Update: Requires can_edit on the existing resource
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def create(self, request, context):
        """Create a new MCP server resource.

        Use this when you explicitly want to create a new resource
        and want an error if it already exists.

        Input: McpServer with metadata (scope, org, name/slug) and spec.
        Returns: The created McpServer with system-generated ID and status.

        Authorization: Custom authorization in handler.
        Requires permission to create MCP servers in the specified scope:
        - Platform: Requires platform operator role
        - Organization: Requires org admin role or can_create_mcp_server permission
        - Identity Account: Automatically allowed for the authenticated user
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def update(self, request, context):
        """Update an existing MCP server resource.

        Input: McpServer with metadata.id populated and updated spec.
        Returns: The updated McpServer.

        Authorization: Requires can_edit permission on the mcp_server resource.
        Only the owner (based on scope) can update:
        - Platform: Platform operators
        - Organization: Org admins or resource owner
        - Identity Account: The owner
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def delete(self, request, context):
        """Delete an MCP server resource.

        Permanently removes the MCP server definition.
        Agents referencing this MCP server will need to be updated.

        Input: ApiResourceDeleteInput with resource_id and optional version_message.
        Returns: The deleted McpServer (for confirmation/audit).

        Authorization: Requires can_delete permission on the mcp_server resource.
        Only the owner can delete:
        - Platform: Platform operators
        - Organization: Org admins or resource owner
        - Identity Account: The owner
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def updateVisibility(self, request, context):
        """Update the visibility of an existing MCP server.

        This is a targeted metadata update — it only modifies metadata.visibility,
        leaving spec, status, and other metadata fields untouched. Use this to
        make an MCP server publicly accessible (marketplace-style sharing) or to
        revoke public access without sending the entire resource.

        Authorization: Requires can_edit permission on the mcp_server resource.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def updateDiscoveredCapabilities(self, request, context):
        """Update the discovered capabilities (tools and resource templates) for an MCP server.

        This is a targeted status update — it only modifies status.discovered_capabilities,
        leaving spec, validation state, and other status fields untouched.

        Typical flow:
        1. CLI calls getByReference(org/slug) to fetch the McpServer and its ID
        2. CLI connects to the MCP server locally and queries tools/resources
        3. CLI calls this RPC with the ID and discovered capabilities

        Input: UpdateDiscoveredCapabilitiesInput with mcp_server_id and discovered_capabilities.
        Returns: The updated McpServer with the new discovered capabilities.

        Authorization: Requires can_edit permission on the mcp_server resource.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def discoverCapabilities(self, request, context):
        """Discover the capabilities of an MCP server by connecting to it.

        This triggers server-side discovery: the backend resolves credentials from the
        authenticated user's personal environment, delegates the actual MCP connection
        to the agent-runner via a Temporal workflow, and stores the result.

        The RPC blocks until discovery completes (up to ~30 seconds) and returns the
        updated McpServer with populated status.discovered_capabilities.

        Typical flow:
        1. Web console ensures required credentials are saved in the user's personal environment
        2. Web console calls discoverCapabilities with the MCP server ID
        3. Backend resolves env vars from the user's personal environment
        4. Backend starts a Temporal workflow; agent-runner connects to the MCP server
        5. Discovered tools and resource templates are stored and returned

        Input: DiscoverCapabilitiesInput with mcp_server_id.
        Returns: The updated McpServer with discovered capabilities.

        Errors:
        - FAILED_PRECONDITION: Required credentials missing from personal environment
        - DEADLINE_EXCEEDED: Discovery did not complete within the timeout
        - NOT_FOUND: MCP server does not exist

        Authorization: Requires can_edit permission on the mcp_server resource.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_McpServerCommandControllerServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'apply': grpc.unary_unary_rpc_method_handler(
                    servicer.apply,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
            ),
            'create': grpc.unary_unary_rpc_method_handler(
                    servicer.create,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
            ),
            'update': grpc.unary_unary_rpc_method_handler(
                    servicer.update,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
            ),
            'delete': grpc.unary_unary_rpc_method_handler(
                    servicer.delete,
                    request_deserializer=ai_dot_stigmer_dot_commons_dot_apiresource_dot_io__pb2.ApiResourceDeleteInput.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
            ),
            'updateVisibility': grpc.unary_unary_rpc_method_handler(
                    servicer.updateVisibility,
                    request_deserializer=ai_dot_stigmer_dot_commons_dot_apiresource_dot_io__pb2.UpdateVisibilityInput.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
            ),
            'updateDiscoveredCapabilities': grpc.unary_unary_rpc_method_handler(
                    servicer.updateDiscoveredCapabilities,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_io__pb2.UpdateDiscoveredCapabilitiesInput.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
            ),
            'discoverCapabilities': grpc.unary_unary_rpc_method_handler(
                    servicer.discoverCapabilities,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_io__pb2.DiscoverCapabilitiesInput.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'ai.stigmer.agentic.mcpserver.v1.McpServerCommandController', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('ai.stigmer.agentic.mcpserver.v1.McpServerCommandController', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class McpServerCommandController(object):
    """McpServerCommandController provides write operations for MCP server resources.
    Supports creating, updating, and deleting MCP server definitions.

    Authorization model for writes:
    - Platform-scoped: Only platform operators can create/modify
    - Organization-scoped: Org admins can create/modify
    - Identity-account-scoped: Only the owner can create/modify

    Primary interface: The `apply` method provides Kubernetes-style idempotent
    create-or-update semantics, which is the recommended approach for CLI usage.
    """

    @staticmethod
    def apply(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/apply',
            ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def create(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/create',
            ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def update(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/update',
            ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def delete(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/delete',
            ai_dot_stigmer_dot_commons_dot_apiresource_dot_io__pb2.ApiResourceDeleteInput.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def updateVisibility(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/updateVisibility',
            ai_dot_stigmer_dot_commons_dot_apiresource_dot_io__pb2.UpdateVisibilityInput.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def updateDiscoveredCapabilities(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/updateDiscoveredCapabilities',
            ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_io__pb2.UpdateDiscoveredCapabilitiesInput.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def discoverCapabilities(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.mcpserver.v1.McpServerCommandController/discoverCapabilities',
            ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_io__pb2.DiscoverCapabilitiesInput.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_mcpserver_dot_v1_dot_api__pb2.McpServer.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
