# 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.workflowinstance.v1 import api_pb2 as ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2
from ai.stigmer.agentic.workflowinstance.v1 import io_pb2 as ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_io__pb2


class WorkflowInstanceCommandControllerStub(object):
    """WorkflowInstanceCommandController handles write operations (Create, Update, Delete) for WorkflowInstance resources.

    This service provides the CUD (Create, Update, Delete) operations following the
    Command-Query Separation pattern. All RPCs that modify state go through this controller.

    Authorization:
    - create: Custom authorization logic (validates workflow_id access, environment_refs access)
    - update: Standard authorization (requires update permission on the instance)
    - delete: Standard authorization (requires delete permission on the instance)

    All workflow instances belong to an organization.
    """

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

        Args:
            channel: A grpc.Channel.
        """
        self.apply = channel.unary_unary(
                '/ai.stigmer.agentic.workflowinstance.v1.WorkflowInstanceCommandController/apply',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.FromString,
                _registered_method=True)
        self.create = channel.unary_unary(
                '/ai.stigmer.agentic.workflowinstance.v1.WorkflowInstanceCommandController/create',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.FromString,
                _registered_method=True)
        self.update = channel.unary_unary(
                '/ai.stigmer.agentic.workflowinstance.v1.WorkflowInstanceCommandController/update',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.FromString,
                _registered_method=True)
        self.delete = channel.unary_unary(
                '/ai.stigmer.agentic.workflowinstance.v1.WorkflowInstanceCommandController/delete',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_io__pb2.WorkflowInstanceId.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.FromString,
                _registered_method=True)


class WorkflowInstanceCommandControllerServicer(object):
    """WorkflowInstanceCommandController handles write operations (Create, Update, Delete) for WorkflowInstance resources.

    This service provides the CUD (Create, Update, Delete) operations following the
    Command-Query Separation pattern. All RPCs that modify state go through this controller.

    Authorization:
    - create: Custom authorization logic (validates workflow_id access, environment_refs access)
    - update: Standard authorization (requires update permission on the instance)
    - delete: Standard authorization (requires delete permission on the instance)

    All workflow instances belong to an organization.
    """

    def apply(self, request, context):
        """Create or update a workflow instance.
        The authorization and state-operation are determined depending on whether the workflow instance
        is going to be created or updated which is determined as part of the request execution.
        """
        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 workflow instance.

        Creates a configured deployment of a Workflow template with environment bindings.

        Input validation:
        - metadata.org must be specified
        - spec.workflow_id must be a valid Workflow resource ID
        - spec.environment_refs must reference valid Environment resources

        Authorization:
        Uses custom authorization logic to verify:
        1. User has permission to access the referenced Workflow template
        2. User has permission to access all referenced Environment resources
        3. Owner scope is valid for the user's organization/identity

        Returns:
        The created WorkflowInstance with:
        - Assigned resource ID (metadata.id)
        - Created timestamp (status.audit.created_at)
        - Initial version (status.audit.version = 1)

        Example:
        Input: WorkflowInstance with workflow_id="wfl-123", environment_refs=["env-prod"]
        Output: WorkflowInstance with id="wfi-abc456", created_at="2025-01-11T10:00:00Z"
        """
        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 workflow instance.

        Modifies the configuration of an existing WorkflowInstance.
        You can update:
        - spec.description (change descriptive text)
        - spec.environment_refs (add/remove/reorder environment bindings)
        - metadata.labels, metadata.tags, metadata.annotations

        You cannot update:
        - spec.workflow_id (must delete and recreate to change template)
        - metadata.id (immutable resource identifier)
        - metadata.org (immutable after creation)

        Authorization:
        Requires "update" permission on the specific WorkflowInstance resource.
        Field path "metadata.id" identifies which resource to authorize.

        Versioning:
        Each update increments status.audit.version and updates status.audit.updated_at.

        Returns:
        The updated WorkflowInstance with:
        - Incremented version number
        - Updated timestamp
        - Modified spec fields

        Error: PERMISSION_DENIED if user lacks update permission
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def delete(self, request, context):
        """Delete a workflow instance.

        Permanently removes a WorkflowInstance resource.

        Important:
        - Deletion is permanent and cannot be undone
        - Does NOT delete the referenced Workflow template (templates are reusable)
        - Does NOT delete the referenced Environment resources (environments are reusable)
        - DOES cascade delete any dependent WorkflowExecution resources (executions belong to instance)

        Authorization:
        Requires "delete" permission on the specific WorkflowInstance resource.
        Field path "value" extracts the resource ID from WorkflowInstanceId wrapper.

        Use Cases:
        - Remove deprecated instances
        - Clean up test/dev instances
        - Decommission old deployment configurations

        Returns:
        The deleted WorkflowInstance (final state before deletion).
        Useful for audit logs and confirming what was deleted.

        Error: PERMISSION_DENIED if user lacks delete permission
        Error: NOT_FOUND if instance ID doesn't exist
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_WorkflowInstanceCommandControllerServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'apply': grpc.unary_unary_rpc_method_handler(
                    servicer.apply,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.SerializeToString,
            ),
            'create': grpc.unary_unary_rpc_method_handler(
                    servicer.create,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.SerializeToString,
            ),
            'update': grpc.unary_unary_rpc_method_handler(
                    servicer.update,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.SerializeToString,
            ),
            'delete': grpc.unary_unary_rpc_method_handler(
                    servicer.delete,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_io__pb2.WorkflowInstanceId.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'ai.stigmer.agentic.workflowinstance.v1.WorkflowInstanceCommandController', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('ai.stigmer.agentic.workflowinstance.v1.WorkflowInstanceCommandController', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class WorkflowInstanceCommandController(object):
    """WorkflowInstanceCommandController handles write operations (Create, Update, Delete) for WorkflowInstance resources.

    This service provides the CUD (Create, Update, Delete) operations following the
    Command-Query Separation pattern. All RPCs that modify state go through this controller.

    Authorization:
    - create: Custom authorization logic (validates workflow_id access, environment_refs access)
    - update: Standard authorization (requires update permission on the instance)
    - delete: Standard authorization (requires delete permission on the instance)

    All workflow instances belong to an organization.
    """

    @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.workflowinstance.v1.WorkflowInstanceCommandController/apply',
            ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.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.workflowinstance.v1.WorkflowInstanceCommandController/create',
            ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.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.workflowinstance.v1.WorkflowInstanceCommandController/update',
            ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.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.workflowinstance.v1.WorkflowInstanceCommandController/delete',
            ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_io__pb2.WorkflowInstanceId.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_workflowinstance_dot_v1_dot_api__pb2.WorkflowInstance.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
