# 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.executioncontext.v1 import api_pb2 as ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_api__pb2
from ai.stigmer.agentic.executioncontext.v1 import io_pb2 as ai_dot_stigmer_dot_agentic_dot_executioncontext_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 ExecutionContextQueryControllerStub(object):
    """ExecutionContextQueryController provides read operations for ExecutionContext resources.

    Authorization: All RPCs use is_skip_authorization with custom handler-level derived auth.
    ExecutionContext is ephemeral (1:1 with its parent execution) and has no dedicated
    FGA model. Authorization is derived from the parent execution:
    - All read operations check can_view on parent agent_execution or workflow_execution

    The handler loads the ExecutionContext, extracts the execution_id from spec,
    and verifies the caller has permission on whichever parent type matches.
    This avoids FGA tuple churn for short-lived resources while maintaining proper access control.
    """

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

        Args:
            channel: A grpc.Channel.
        """
        self.get = channel.unary_unary(
                '/ai.stigmer.agentic.executioncontext.v1.ExecutionContextQueryController/get',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_io__pb2.ExecutionContextId.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_api__pb2.ExecutionContext.FromString,
                _registered_method=True)
        self.getByReference = channel.unary_unary(
                '/ai.stigmer.agentic.executioncontext.v1.ExecutionContextQueryController/getByReference',
                request_serializer=ai_dot_stigmer_dot_commons_dot_apiresource_dot_io__pb2.ApiResourceReference.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_api__pb2.ExecutionContext.FromString,
                _registered_method=True)
        self.getByExecutionId = channel.unary_unary(
                '/ai.stigmer.agentic.executioncontext.v1.ExecutionContextQueryController/getByExecutionId',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_io__pb2.ExecutionContextExecutionIdInput.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_api__pb2.ExecutionContext.FromString,
                _registered_method=True)


class ExecutionContextQueryControllerServicer(object):
    """ExecutionContextQueryController provides read operations for ExecutionContext resources.

    Authorization: All RPCs use is_skip_authorization with custom handler-level derived auth.
    ExecutionContext is ephemeral (1:1 with its parent execution) and has no dedicated
    FGA model. Authorization is derived from the parent execution:
    - All read operations check can_view on parent agent_execution or workflow_execution

    The handler loads the ExecutionContext, extracts the execution_id from spec,
    and verifies the caller has permission on whichever parent type matches.
    This avoids FGA tuple churn for short-lived resources while maintaining proper access control.
    """

    def get(self, request, context):
        """Get an ExecutionContext by ID.
        Handler-level derived auth: checks can_view on parent agent_execution or workflow_execution.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def getByReference(self, request, context):
        """Get an ExecutionContext by reference (slug-based lookup).
        Handler-level derived auth: checks can_view on parent agent_execution or workflow_execution.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def getByExecutionId(self, request, context):
        """Get an ExecutionContext by the execution ID it belongs to.
        This is the primary lookup method used by runners to retrieve the merged
        environment variables during workflow/agent execution. The returned context
        contains decrypted secrets for runner consumption.

        Handler-level derived auth: checks can_view on parent agent_execution or workflow_execution.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_ExecutionContextQueryControllerServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'get': grpc.unary_unary_rpc_method_handler(
                    servicer.get,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_io__pb2.ExecutionContextId.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_api__pb2.ExecutionContext.SerializeToString,
            ),
            'getByReference': grpc.unary_unary_rpc_method_handler(
                    servicer.getByReference,
                    request_deserializer=ai_dot_stigmer_dot_commons_dot_apiresource_dot_io__pb2.ApiResourceReference.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_api__pb2.ExecutionContext.SerializeToString,
            ),
            'getByExecutionId': grpc.unary_unary_rpc_method_handler(
                    servicer.getByExecutionId,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_io__pb2.ExecutionContextExecutionIdInput.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_api__pb2.ExecutionContext.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'ai.stigmer.agentic.executioncontext.v1.ExecutionContextQueryController', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('ai.stigmer.agentic.executioncontext.v1.ExecutionContextQueryController', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class ExecutionContextQueryController(object):
    """ExecutionContextQueryController provides read operations for ExecutionContext resources.

    Authorization: All RPCs use is_skip_authorization with custom handler-level derived auth.
    ExecutionContext is ephemeral (1:1 with its parent execution) and has no dedicated
    FGA model. Authorization is derived from the parent execution:
    - All read operations check can_view on parent agent_execution or workflow_execution

    The handler loads the ExecutionContext, extracts the execution_id from spec,
    and verifies the caller has permission on whichever parent type matches.
    This avoids FGA tuple churn for short-lived resources while maintaining proper access control.
    """

    @staticmethod
    def get(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.executioncontext.v1.ExecutionContextQueryController/get',
            ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_io__pb2.ExecutionContextId.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_api__pb2.ExecutionContext.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def getByReference(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.executioncontext.v1.ExecutionContextQueryController/getByReference',
            ai_dot_stigmer_dot_commons_dot_apiresource_dot_io__pb2.ApiResourceReference.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_api__pb2.ExecutionContext.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def getByExecutionId(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.executioncontext.v1.ExecutionContextQueryController/getByExecutionId',
            ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_io__pb2.ExecutionContextExecutionIdInput.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_executioncontext_dot_v1_dot_api__pb2.ExecutionContext.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
