Example #1
0
    def __init__(self,
                 client_cert: Optional[str] = None,
                 key: Optional[str] = None,
                 key_id: Optional[str] = None,
                 team_id: Optional[str] = None,
                 topic: Optional[str] = None,
                 max_connections: int = 10,
                 max_connection_attempts: Optional[int] = None,
                 loop: Optional[asyncio.AbstractEventLoop] = None,
                 use_sandbox: bool = False):

        if client_cert is not None and key is not None:
            raise ValueError('cannot specify both client_cert and key')
        elif client_cert:
            self.pool = APNsCertConnectionPool(
                cert_file=client_cert,
                topic=topic,
                max_connections=max_connections,
                max_connection_attempts=max_connection_attempts,
                loop=loop,
                use_sandbox=use_sandbox)
        elif all((key, key_id, team_id, topic)):
            self.pool = APNsKeyConnectionPool(
                key_file=key,
                key_id=key_id,
                team_id=team_id,
                topic=topic,
                max_connections=max_connections,
                max_connection_attempts=max_connection_attempts,
                loop=loop,
                use_sandbox=use_sandbox)
        else:
            raise ValueError('You must provide either APNs cert file path or '
                             'the key credentials')
Example #2
0
    def __init__(
        self,
        client_cert: Optional[str] = None,
        key: Optional[str] = None,
        key_id: Optional[str] = None,
        team_id: Optional[str] = None,
        topic: Optional[str] = None,
        max_connections: int = 10,
        max_connection_attempts: int = 5,
        use_sandbox: bool = False,
        no_cert_validation: bool = False,
        ssl_context: Optional[SSLContext] = None,
    ):

        self.pool: APNsBaseConnectionPool
        if client_cert is not None and key is not None:
            raise ValueError("cannot specify both client_cert and key")
        elif client_cert:
            self.pool = APNsCertConnectionPool(
                cert_file=client_cert,
                topic=topic,
                max_connections=max_connections,
                max_connection_attempts=max_connection_attempts,
                use_sandbox=use_sandbox,
                no_cert_validation=no_cert_validation,
                ssl_context=ssl_context,
            )
        elif key and key_id and team_id and topic:
            self.pool = APNsKeyConnectionPool(
                key_file=key,
                key_id=key_id,
                team_id=team_id,
                topic=topic,
                max_connections=max_connections,
                max_connection_attempts=max_connection_attempts,
                use_sandbox=use_sandbox,
                ssl_context=ssl_context,
            )
        else:
            raise ValueError("You must provide either APNs cert file path or "
                             "the key credentials")
Example #3
0
 def __init__(self,
              client_cert=None,
              team_id=None,
              bundle_id=None,
              auth_key_id=None,
              auth_key=None,
              max_connections=10,
              loop=None,
              use_sandbox=False):
     if client_cert:
         self.pool = APNsCertConnectionPool(client_cert, max_connections,
                                            loop, use_sandbox)
     elif all([team_id, bundle_id, auth_key_id, auth_key]):
         self.pool = APNsKeyConnectionPool(team_id=team_id,
                                           bundle_id=bundle_id,
                                           auth_key_id=auth_key_id,
                                           auth_key=auth_key,
                                           max_connections=max_connections,
                                           loop=loop,
                                           use_sandbox=use_sandbox)
     else:
         raise ImproperlyConfigured(
             'You must provide either APNs cert file path or an auth key credentials'
         )