Skip to content

Commit baeaa0d

Browse files
authored
Add SNS operations (#8)
1 parent 2ab55db commit baeaa0d

File tree

10 files changed

+681
-51
lines changed

10 files changed

+681
-51
lines changed

localstack-sdk-python/localstack/sdk/aws/client.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
from localstack.clients import BaseClient
44
from localstack.sdk.api.aws_api import AwsApi
5-
from localstack.sdk.models import Message, SesSentEmail
5+
from localstack.sdk.models import (
6+
Message,
7+
SesSentEmail,
8+
SNSPlatformEndpointResponse,
9+
SNSSMSMessagesResponse,
10+
)
611

712

813
def _from_sqs_query_to_json(xml_dict: dict) -> list[Message]:
@@ -62,6 +67,50 @@ def get_ses_messages(
6267
def discard_ses_messages(self, id_filter: str | None = None) -> None:
6368
return self._client.discard_ses_messages(id=id_filter)
6469

70+
########
71+
# SNS
72+
########
73+
74+
def get_sns_sms_messages(
75+
self,
76+
phone_number: str | None = None,
77+
account_id: str = "000000000000",
78+
region: str = "us-east-1",
79+
) -> SNSSMSMessagesResponse:
80+
return self._client.get_sns_sms_messages(
81+
phone_number=phone_number, account_id=account_id, region=region
82+
)
83+
84+
def discard_sns_sms_messages(
85+
self,
86+
phone_number: str | None = None,
87+
account_id: str = "000000000000",
88+
region: str = "us-east-1",
89+
) -> None:
90+
return self._client.discard_sns_sms_messages(
91+
phone_number=phone_number, account_id=account_id, region=region
92+
)
93+
94+
def get_sns_endpoint_messages(
95+
self,
96+
endpoint_arn: str | None = None,
97+
account_id: str = "000000000000",
98+
region: str = "us-east-1",
99+
) -> SNSPlatformEndpointResponse:
100+
return self._client.get_sns_endpoint_messages(
101+
endpoint_arn=endpoint_arn, account_id=account_id, region=region
102+
)
103+
104+
def discard_sns_endpoint_messages(
105+
self,
106+
endpoint_arn: str | None = None,
107+
account_id: str = "000000000000",
108+
region: str = "us-east-1",
109+
) -> None:
110+
return self._client.discard_sns_endpoint_messages(
111+
endpoint_arn=endpoint_arn, account_id=account_id, region=region
112+
)
113+
65114

66115
def get_default(**args) -> AwsApi:
67116
"""Return a client with a default configuration"""

packages/localstack-sdk-generated/.openapi-generator/FILES

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ localstack/sdk/models/get_diagnostics200_response_version_localstack_version.py
3232
localstack/sdk/models/get_features_and_services200_response.py
3333
localstack/sdk/models/get_lambda_runtimes200_response.py
3434
localstack/sdk/models/get_ses_messages200_response.py
35-
localstack/sdk/models/get_sns_messages200_response.py
36-
localstack/sdk/models/get_sns_sms_messages200_response.py
3735
localstack/sdk/models/get_sns_subscription_token200_response.py
3836
localstack/sdk/models/init_scripts.py
3937
localstack/sdk/models/init_scripts_completed.py
@@ -60,7 +58,11 @@ localstack/sdk/models/ses_destination.py
6058
localstack/sdk/models/ses_sent_email.py
6159
localstack/sdk/models/ses_sent_email_body.py
6260
localstack/sdk/models/session_info.py
61+
localstack/sdk/models/sns_message.py
62+
localstack/sdk/models/sns_platform_endpoint_message.py
63+
localstack/sdk/models/sns_platform_endpoint_response.py
6364
localstack/sdk/models/sns_subscription_token_error.py
65+
localstack/sdk/models/snssms_messages_response.py
6466
localstack/sdk/models/state_result.py
6567
localstack/sdk/models/store_data200_response.py
6668
localstack/sdk/models/update_config_option200_response.py

packages/localstack-sdk-generated/localstack/sdk/api/aws_api.py

Lines changed: 38 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
from localstack.sdk.models.delete_ddb_expired_items200_response import DeleteDdbExpiredItems200Response
2626
from localstack.sdk.models.get_lambda_runtimes200_response import GetLambdaRuntimes200Response
2727
from localstack.sdk.models.get_ses_messages200_response import GetSesMessages200Response
28-
from localstack.sdk.models.get_sns_messages200_response import GetSnsMessages200Response
29-
from localstack.sdk.models.get_sns_sms_messages200_response import GetSnsSmsMessages200Response
3028
from localstack.sdk.models.get_sns_subscription_token200_response import GetSnsSubscriptionToken200Response
3129
from localstack.sdk.models.receive_message_result import ReceiveMessageResult
30+
from localstack.sdk.models.sns_platform_endpoint_response import SNSPlatformEndpointResponse
31+
from localstack.sdk.models.snssms_messages_response import SNSSMSMessagesResponse
3232

3333
from localstack.sdk.api_client import ApiClient, RequestSerialized
3434
from localstack.sdk.api_response import ApiResponse
@@ -4349,7 +4349,7 @@ def _discard_ses_messages_serialize(
43494349

43504350

43514351
@validate_call
4352-
def discard_sns_messages(
4352+
def discard_sns_endpoint_messages(
43534353
self,
43544354
account_id: Annotated[Optional[StrictStr], Field(description="`accountId` field of the resource")] = None,
43554355
region: Annotated[Optional[StrictStr], Field(description="`region` field of the resource")] = None,
@@ -4367,9 +4367,9 @@ def discard_sns_messages(
43674367
_headers: Optional[Dict[StrictStr, Any]] = None,
43684368
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
43694369
) -> None:
4370-
"""discard_sns_messages
4370+
"""discard_sns_endpoint_messages
43714371
4372-
Discard SNS platform endpoint messages
4372+
Discard the messages published to a platform endpoint via SNS
43734373
43744374
:param account_id: `accountId` field of the resource
43754375
:type account_id: str
@@ -4399,7 +4399,7 @@ def discard_sns_messages(
43994399
:return: Returns the result object.
44004400
""" # noqa: E501
44014401

4402-
_param = self._discard_sns_messages_serialize(
4402+
_param = self._discard_sns_endpoint_messages_serialize(
44034403
account_id=account_id,
44044404
region=region,
44054405
endpoint_arn=endpoint_arn,
@@ -4424,7 +4424,7 @@ def discard_sns_messages(
44244424

44254425

44264426
@validate_call
4427-
def discard_sns_messages_with_http_info(
4427+
def discard_sns_endpoint_messages_with_http_info(
44284428
self,
44294429
account_id: Annotated[Optional[StrictStr], Field(description="`accountId` field of the resource")] = None,
44304430
region: Annotated[Optional[StrictStr], Field(description="`region` field of the resource")] = None,
@@ -4442,9 +4442,9 @@ def discard_sns_messages_with_http_info(
44424442
_headers: Optional[Dict[StrictStr, Any]] = None,
44434443
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
44444444
) -> ApiResponse[None]:
4445-
"""discard_sns_messages
4445+
"""discard_sns_endpoint_messages
44464446
4447-
Discard SNS platform endpoint messages
4447+
Discard the messages published to a platform endpoint via SNS
44484448
44494449
:param account_id: `accountId` field of the resource
44504450
:type account_id: str
@@ -4474,7 +4474,7 @@ def discard_sns_messages_with_http_info(
44744474
:return: Returns the result object.
44754475
""" # noqa: E501
44764476

4477-
_param = self._discard_sns_messages_serialize(
4477+
_param = self._discard_sns_endpoint_messages_serialize(
44784478
account_id=account_id,
44794479
region=region,
44804480
endpoint_arn=endpoint_arn,
@@ -4499,7 +4499,7 @@ def discard_sns_messages_with_http_info(
44994499

45004500

45014501
@validate_call
4502-
def discard_sns_messages_without_preload_content(
4502+
def discard_sns_endpoint_messages_without_preload_content(
45034503
self,
45044504
account_id: Annotated[Optional[StrictStr], Field(description="`accountId` field of the resource")] = None,
45054505
region: Annotated[Optional[StrictStr], Field(description="`region` field of the resource")] = None,
@@ -4517,9 +4517,9 @@ def discard_sns_messages_without_preload_content(
45174517
_headers: Optional[Dict[StrictStr, Any]] = None,
45184518
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
45194519
) -> RESTResponseType:
4520-
"""discard_sns_messages
4520+
"""discard_sns_endpoint_messages
45214521
4522-
Discard SNS platform endpoint messages
4522+
Discard the messages published to a platform endpoint via SNS
45234523
45244524
:param account_id: `accountId` field of the resource
45254525
:type account_id: str
@@ -4549,7 +4549,7 @@ def discard_sns_messages_without_preload_content(
45494549
:return: Returns the result object.
45504550
""" # noqa: E501
45514551

4552-
_param = self._discard_sns_messages_serialize(
4552+
_param = self._discard_sns_endpoint_messages_serialize(
45534553
account_id=account_id,
45544554
region=region,
45554555
endpoint_arn=endpoint_arn,
@@ -4569,7 +4569,7 @@ def discard_sns_messages_without_preload_content(
45694569
return response_data.response
45704570

45714571

4572-
def _discard_sns_messages_serialize(
4572+
def _discard_sns_endpoint_messages_serialize(
45734573
self,
45744574
account_id,
45754575
region,
@@ -4902,13 +4902,6 @@ def _discard_sns_sms_messages_serialize(
49024902
# process the body parameter
49034903

49044904

4905-
# set the HTTP header `Accept`
4906-
if 'Accept' not in _header_params:
4907-
_header_params['Accept'] = self.api_client.select_header_accept(
4908-
[
4909-
'text/plain'
4910-
]
4911-
)
49124905

49134906

49144907
# authentication setting
@@ -5965,7 +5958,7 @@ def _get_ses_messages_serialize(
59655958

59665959

59675960
@validate_call
5968-
def get_sns_messages(
5961+
def get_sns_endpoint_messages(
59695962
self,
59705963
account_id: Annotated[Optional[StrictStr], Field(description="`accountId` field of the resource")] = None,
59715964
region: Annotated[Optional[StrictStr], Field(description="`region` field of the resource")] = None,
@@ -5982,10 +5975,10 @@ def get_sns_messages(
59825975
_content_type: Optional[StrictStr] = None,
59835976
_headers: Optional[Dict[StrictStr, Any]] = None,
59845977
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
5985-
) -> GetSnsMessages200Response:
5986-
"""get_sns_messages
5978+
) -> SNSPlatformEndpointResponse:
5979+
"""get_sns_endpoint_messages
59875980
5988-
Retrieve SNS platform endpoint messages
5981+
Retrieve the messages sent to a platform endpoint via SNS
59895982
59905983
:param account_id: `accountId` field of the resource
59915984
:type account_id: str
@@ -6015,7 +6008,7 @@ def get_sns_messages(
60156008
:return: Returns the result object.
60166009
""" # noqa: E501
60176010

6018-
_param = self._get_sns_messages_serialize(
6011+
_param = self._get_sns_endpoint_messages_serialize(
60196012
account_id=account_id,
60206013
region=region,
60216014
endpoint_arn=endpoint_arn,
@@ -6026,7 +6019,7 @@ def get_sns_messages(
60266019
)
60276020

60286021
_response_types_map: Dict[str, Optional[str]] = {
6029-
'200': "GetSnsMessages200Response",
6022+
'200': "SNSPlatformEndpointResponse",
60306023
}
60316024
response_data = self.api_client.call_api(
60326025
*_param,
@@ -6040,7 +6033,7 @@ def get_sns_messages(
60406033

60416034

60426035
@validate_call
6043-
def get_sns_messages_with_http_info(
6036+
def get_sns_endpoint_messages_with_http_info(
60446037
self,
60456038
account_id: Annotated[Optional[StrictStr], Field(description="`accountId` field of the resource")] = None,
60466039
region: Annotated[Optional[StrictStr], Field(description="`region` field of the resource")] = None,
@@ -6057,10 +6050,10 @@ def get_sns_messages_with_http_info(
60576050
_content_type: Optional[StrictStr] = None,
60586051
_headers: Optional[Dict[StrictStr, Any]] = None,
60596052
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
6060-
) -> ApiResponse[GetSnsMessages200Response]:
6061-
"""get_sns_messages
6053+
) -> ApiResponse[SNSPlatformEndpointResponse]:
6054+
"""get_sns_endpoint_messages
60626055
6063-
Retrieve SNS platform endpoint messages
6056+
Retrieve the messages sent to a platform endpoint via SNS
60646057
60656058
:param account_id: `accountId` field of the resource
60666059
:type account_id: str
@@ -6090,7 +6083,7 @@ def get_sns_messages_with_http_info(
60906083
:return: Returns the result object.
60916084
""" # noqa: E501
60926085

6093-
_param = self._get_sns_messages_serialize(
6086+
_param = self._get_sns_endpoint_messages_serialize(
60946087
account_id=account_id,
60956088
region=region,
60966089
endpoint_arn=endpoint_arn,
@@ -6101,7 +6094,7 @@ def get_sns_messages_with_http_info(
61016094
)
61026095

61036096
_response_types_map: Dict[str, Optional[str]] = {
6104-
'200': "GetSnsMessages200Response",
6097+
'200': "SNSPlatformEndpointResponse",
61056098
}
61066099
response_data = self.api_client.call_api(
61076100
*_param,
@@ -6115,7 +6108,7 @@ def get_sns_messages_with_http_info(
61156108

61166109

61176110
@validate_call
6118-
def get_sns_messages_without_preload_content(
6111+
def get_sns_endpoint_messages_without_preload_content(
61196112
self,
61206113
account_id: Annotated[Optional[StrictStr], Field(description="`accountId` field of the resource")] = None,
61216114
region: Annotated[Optional[StrictStr], Field(description="`region` field of the resource")] = None,
@@ -6133,9 +6126,9 @@ def get_sns_messages_without_preload_content(
61336126
_headers: Optional[Dict[StrictStr, Any]] = None,
61346127
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
61356128
) -> RESTResponseType:
6136-
"""get_sns_messages
6129+
"""get_sns_endpoint_messages
61376130
6138-
Retrieve SNS platform endpoint messages
6131+
Retrieve the messages sent to a platform endpoint via SNS
61396132
61406133
:param account_id: `accountId` field of the resource
61416134
:type account_id: str
@@ -6165,7 +6158,7 @@ def get_sns_messages_without_preload_content(
61656158
:return: Returns the result object.
61666159
""" # noqa: E501
61676160

6168-
_param = self._get_sns_messages_serialize(
6161+
_param = self._get_sns_endpoint_messages_serialize(
61696162
account_id=account_id,
61706163
region=region,
61716164
endpoint_arn=endpoint_arn,
@@ -6176,7 +6169,7 @@ def get_sns_messages_without_preload_content(
61766169
)
61776170

61786171
_response_types_map: Dict[str, Optional[str]] = {
6179-
'200': "GetSnsMessages200Response",
6172+
'200': "SNSPlatformEndpointResponse",
61806173
}
61816174
response_data = self.api_client.call_api(
61826175
*_param,
@@ -6185,7 +6178,7 @@ def get_sns_messages_without_preload_content(
61856178
return response_data.response
61866179

61876180

6188-
def _get_sns_messages_serialize(
6181+
def _get_sns_endpoint_messages_serialize(
61896182
self,
61906183
account_id,
61916184
region,
@@ -6278,7 +6271,7 @@ def get_sns_sms_messages(
62786271
_content_type: Optional[StrictStr] = None,
62796272
_headers: Optional[Dict[StrictStr, Any]] = None,
62806273
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
6281-
) -> GetSnsSmsMessages200Response:
6274+
) -> SNSSMSMessagesResponse:
62826275
"""get_sns_sms_messages
62836276
62846277
Retrieve SNS SMS messages
@@ -6322,7 +6315,7 @@ def get_sns_sms_messages(
63226315
)
63236316

63246317
_response_types_map: Dict[str, Optional[str]] = {
6325-
'200': "GetSnsSmsMessages200Response",
6318+
'200': "SNSSMSMessagesResponse",
63266319
}
63276320
response_data = self.api_client.call_api(
63286321
*_param,
@@ -6353,7 +6346,7 @@ def get_sns_sms_messages_with_http_info(
63536346
_content_type: Optional[StrictStr] = None,
63546347
_headers: Optional[Dict[StrictStr, Any]] = None,
63556348
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
6356-
) -> ApiResponse[GetSnsSmsMessages200Response]:
6349+
) -> ApiResponse[SNSSMSMessagesResponse]:
63576350
"""get_sns_sms_messages
63586351
63596352
Retrieve SNS SMS messages
@@ -6397,7 +6390,7 @@ def get_sns_sms_messages_with_http_info(
63976390
)
63986391

63996392
_response_types_map: Dict[str, Optional[str]] = {
6400-
'200': "GetSnsSmsMessages200Response",
6393+
'200': "SNSSMSMessagesResponse",
64016394
}
64026395
response_data = self.api_client.call_api(
64036396
*_param,
@@ -6472,7 +6465,7 @@ def get_sns_sms_messages_without_preload_content(
64726465
)
64736466

64746467
_response_types_map: Dict[str, Optional[str]] = {
6475-
'200': "GetSnsSmsMessages200Response",
6468+
'200': "SNSSMSMessagesResponse",
64766469
}
64776470
response_data = self.api_client.call_api(
64786471
*_param,

0 commit comments

Comments
 (0)