django_aws_api_gateway_websockets.models module¶
- class django_aws_api_gateway_websockets.models.ApiGateway(*args, **kwargs)[source]¶
Bases:
ModelStored the API Gateway definitions
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- exception NotUpdated¶
Bases:
ObjectNotUpdated,DatabaseError
- additional_routes¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_reverse_many_to_one_manager()defined below.
- api_created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- api_description¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- api_endpoint¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- api_gateway_domain_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- api_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- api_key_selection_expression¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- api_mapping_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- api_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- certificate_arn¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- create_custom_domain()[source]¶
Uses boto3 to create the custom domain and associate it with the production stage of the loaded API
Should be called after create_gateway() has been run :return:
- created_on¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- custom_domain_created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- default_channel_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- deployment_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- domain_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=True, **kwargs)¶
- get_next_by_updated_on(*, field=<django.db.models.fields.DateTimeField: updated_on>, is_next=True, **kwargs)¶
- get_previous_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=False, **kwargs)¶
- get_previous_by_updated_on(*, field=<django.db.models.fields.DateTimeField: updated_on>, is_next=False, **kwargs)¶
- hosted_zone_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- route_key¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- route_selection_expression¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- sessions¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_reverse_many_to_one_manager()defined below.
- stage_description¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- stage_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- tags¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- target_base_endpoint¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- updated_on¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class django_aws_api_gateway_websockets.models.ApiGatewayAdditionalRoute(*args, **kwargs)[source]¶
Bases:
ModelStores the additional route keys
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- exception NotUpdated¶
Bases:
ObjectNotUpdated,DatabaseError
- api_gateway¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- api_gateway_id¶
- created_on¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- deployed¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=True, **kwargs)¶
- get_next_by_updated_on(*, field=<django.db.models.fields.DateTimeField: updated_on>, is_next=True, **kwargs)¶
- get_previous_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=False, **kwargs)¶
- get_previous_by_updated_on(*, field=<django.db.models.fields.DateTimeField: updated_on>, is_next=False, **kwargs)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- integration_url¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- route_key¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- save(*args, **kwargs)[source]¶
Save the record then deploy the new route if the parent has already been deployed
- updated_on¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class django_aws_api_gateway_websockets.models.ConnectionRateLimit(*args, **kwargs)[source]¶
Bases:
ModelTrack connection attempts for rate limiting
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- exception NotUpdated¶
Bases:
ObjectNotUpdated,DatabaseError
- attempt_time¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod check_rate_limit(ip_address, user=None, max_attempts=20, window_minutes=5)[source]¶
Check if IP or user has exceeded connection rate limit Returns: (is_allowed: bool, attempts_count: int)
- classmethod cleanup_old_records(days=7)[source]¶
Delete old rate limit records (call via cron/celery)
- get_next_by_attempt_time(*, field=<django.db.models.fields.DateTimeField: attempt_time>, is_next=True, **kwargs)¶
- get_previous_by_attempt_time(*, field=<django.db.models.fields.DateTimeField: attempt_time>, is_next=False, **kwargs)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- ip_address¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- classmethod record_attempt(ip_address, user=None, successful=False)[source]¶
Record a connection attempt
- successful¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- user¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- user_id¶
- class django_aws_api_gateway_websockets.models.WebSocketSession(id, connection_id, channel_name, user, connected, api_gateway, request_count, created_on, updated_on)[source]¶
Bases:
Model- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- exception NotUpdated¶
Bases:
ObjectNotUpdated,DatabaseError
- api_gateway¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- api_gateway_id¶
- channel_name¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- connected¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- connection_id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- created_on¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=True, **kwargs)¶
- get_next_by_updated_on(*, field=<django.db.models.fields.DateTimeField: updated_on>, is_next=True, **kwargs)¶
- get_previous_by_created_on(*, field=<django.db.models.fields.DateTimeField: created_on>, is_next=False, **kwargs)¶
- get_previous_by_updated_on(*, field=<django.db.models.fields.DateTimeField: updated_on>, is_next=False, **kwargs)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.ManagerFromWebSocketSessionQuerySet object>¶
- request_count¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- updated_on¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- user¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- user_id¶
- class django_aws_api_gateway_websockets.models.WebSocketSessionQuerySet(model=None, query=None, using=None, hints=None)[source]¶
Bases:
QuerySet
- class django_aws_api_gateway_websockets.models.WebSocketToken(*args, **kwargs)[source]¶
Bases:
ModelOne-time use tokens for establishing WebSocket connections (CSRF protection)
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- exception NotUpdated¶
Bases:
ObjectNotUpdated,DatabaseError
- classmethod check_rate_limit(user, max_tokens_per_minute=10)[source]¶
Check if user has exceeded token generation rate limit
- classmethod cleanup_expired(max_age_seconds=300)[source]¶
Delete expired/used tokens (call via cron/celery)
- created_at¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)¶
- get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- session_key¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- token¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- used¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- user¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- user_id¶
- django_aws_api_gateway_websockets.models.get_boto3_client(service: str = 'apigatewayv2', **kwargs)[source]¶
Returns the boto3 client to use.
When running within AWS, if you are using an IAM Role with the service, E.G. on an EC2 instance, you need to set AWS_REGION_NAME within settings.py
Otherwise you can either use a named profile using settings.AWS_IAM_PROFILE or you can set the credentials using both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
- Parameters:
service (str) – apigatewayv2 | apigatewaymanagementapi