# 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.platform.github.v1 import service_pb2 as ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2


class GitHubServiceStub(object):
    """GitHubService provides OAuth integration with GitHub.

    This is a platform utility service — not a domain resource.
    It enables the web console (and SDK consumers) to connect a user's
    GitHub account via OAuth, then browse and select repositories
    for workspace configuration.

    The service handles the server-side OAuth code exchange (protecting
    the client_secret) and provides the authorize URL so the frontend
    does not need to know the client_id or redirect_uri.

    Tokens are ephemeral — they are returned to the caller and never
    persisted by the backend.
    """

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

        Args:
            channel: A grpc.Channel.
        """
        self.getOAuthAuthorizeUrl = channel.unary_unary(
                '/ai.stigmer.platform.github.v1.GitHubService/getOAuthAuthorizeUrl',
                request_serializer=ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2.GetOAuthAuthorizeUrlRequest.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2.GetOAuthAuthorizeUrlResponse.FromString,
                _registered_method=True)
        self.exchangeOAuthCode = channel.unary_unary(
                '/ai.stigmer.platform.github.v1.GitHubService/exchangeOAuthCode',
                request_serializer=ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2.ExchangeOAuthCodeRequest.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2.ExchangeOAuthCodeResponse.FromString,
                _registered_method=True)


class GitHubServiceServicer(object):
    """GitHubService provides OAuth integration with GitHub.

    This is a platform utility service — not a domain resource.
    It enables the web console (and SDK consumers) to connect a user's
    GitHub account via OAuth, then browse and select repositories
    for workspace configuration.

    The service handles the server-side OAuth code exchange (protecting
    the client_secret) and provides the authorize URL so the frontend
    does not need to know the client_id or redirect_uri.

    Tokens are ephemeral — they are returned to the caller and never
    persisted by the backend.
    """

    def getOAuthAuthorizeUrl(self, request, context):
        """Returns the GitHub OAuth authorize URL for initiating the OAuth flow.

        The backend constructs the URL with the registered client_id, requested
        scopes, and a random state parameter for CSRF protection. The frontend
        redirects the user to this URL, and GitHub redirects back to the
        provided redirect_uri with an authorization code.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def exchangeOAuthCode(self, request, context):
        """Exchanges a GitHub OAuth authorization code for an access token.

        The frontend calls this after receiving the authorization code from
        GitHub's OAuth redirect. The backend makes the token exchange request
        to GitHub using the client_secret (which must never be exposed to
        the frontend).

        The returned access_token is NOT stored by the backend. The frontend
        is responsible for persisting it (e.g., in localStorage) and including
        it in subsequent requests that need GitHub access.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_GitHubServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'getOAuthAuthorizeUrl': grpc.unary_unary_rpc_method_handler(
                    servicer.getOAuthAuthorizeUrl,
                    request_deserializer=ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2.GetOAuthAuthorizeUrlRequest.FromString,
                    response_serializer=ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2.GetOAuthAuthorizeUrlResponse.SerializeToString,
            ),
            'exchangeOAuthCode': grpc.unary_unary_rpc_method_handler(
                    servicer.exchangeOAuthCode,
                    request_deserializer=ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2.ExchangeOAuthCodeRequest.FromString,
                    response_serializer=ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2.ExchangeOAuthCodeResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'ai.stigmer.platform.github.v1.GitHubService', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('ai.stigmer.platform.github.v1.GitHubService', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class GitHubService(object):
    """GitHubService provides OAuth integration with GitHub.

    This is a platform utility service — not a domain resource.
    It enables the web console (and SDK consumers) to connect a user's
    GitHub account via OAuth, then browse and select repositories
    for workspace configuration.

    The service handles the server-side OAuth code exchange (protecting
    the client_secret) and provides the authorize URL so the frontend
    does not need to know the client_id or redirect_uri.

    Tokens are ephemeral — they are returned to the caller and never
    persisted by the backend.
    """

    @staticmethod
    def getOAuthAuthorizeUrl(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.platform.github.v1.GitHubService/getOAuthAuthorizeUrl',
            ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2.GetOAuthAuthorizeUrlRequest.SerializeToString,
            ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2.GetOAuthAuthorizeUrlResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def exchangeOAuthCode(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.platform.github.v1.GitHubService/exchangeOAuthCode',
            ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2.ExchangeOAuthCodeRequest.SerializeToString,
            ai_dot_stigmer_dot_platform_dot_github_dot_v1_dot_service__pb2.ExchangeOAuthCodeResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
