cc-py-commons 0.5.31__tar.gz → 0.5.33__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/PKG-INFO +1 -1
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/config/env.py +2 -0
- cc_py_commons-0.5.33/cc_py_commons/sqs/booking_assistant_cancel_quote_notification.py +31 -0
- cc_py_commons-0.5.33/cc_py_commons/sqs/sqs_service.py +86 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons.egg-info/PKG-INFO +1 -1
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons.egg-info/SOURCES.txt +1 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/setup.py +1 -1
- cc_py_commons-0.5.31/cc_py_commons/sqs/sqs_service.py +0 -25
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/README.md +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/bids/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/bids/bid.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/bids/bid_history.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/bids/bid_history_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/bids/bid_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/carriers/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/carriers/account_carrier_map.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/carriers/account_carrier_map_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/carriers/carrier.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/carriers/carrier_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/carriers/contact.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/carriers/contact_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/config/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/config/c4_account_settings.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/config/mcleod_load_fields.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/config/pc_miler_config.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/db/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/db/connection.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/geolocate.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/lanes/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/lanes/carrier_lane.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/lanes/carrier_lane_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/lanes/lane.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/lanes/lane_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/equipment.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/equipment_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/equipment_types.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/freighthub_contact.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/freighthub_contact_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/load.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/load_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/load_status.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/location.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/location_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/map_load_response.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/quotes/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/quotes/quote.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/quotes/quote_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/quotes/quote_status.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/rfp/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/rfp/create_table.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/rfp/rfp_status.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/rfp/truck_lane_search_mapper.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/schemas/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/schemas/camel_case_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/analytics/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/analytics/analytics_event.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/accept_bid.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/cancel_bid.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/constants.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/counter_bid.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/decline_bid.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/get_bid_by_amazon_order_id.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/get_quote.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/get_quote_by_load_id.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/list_bids.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/list_quotes.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/update_bid.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/c4/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/c4/amazon_session_token.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/c4/constants.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/c4/get_account.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/c4/get_account_settings.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/c4/get_integration.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/c4/get_users_for_account.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/c4/refresh_amazon_token.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/carrier_hub/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/carrier_hub/get_carrier.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/carrier_hub/list_carriers.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/carrier_hub/list_contacts.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/carrier_hub/update_contact.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/freight_hub/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/freight_hub/post_freight_hub_load.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/create_account_folder.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/db/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/db/delete_table.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/get_client.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/get_green_screens_lane_price.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/get_import_stat.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/get_lane_price.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/list_clients.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/post_import_stat.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/update_import_stat.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/slack/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/slack/send_slack_message.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sns/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sns/book_load_notification.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sns/booking_agent/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sns/booking_agent/bid_counter_failure_notification.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sns/booking_agent/constants.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sns/booking_agent/send_sns_notification.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sns/booking_assistant_flow_notification.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sns/import_movements_notification.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sns/parsed_carrier_notification.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sns/sns_service.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sqs/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sqs/booking_assistant_flow_event.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/tests/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/tests/test_case_conversion.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/tests/test_lambda_utils.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/tests/test_map_transaction.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/tests/test_temperature_utils.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/transactions/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/transactions/equipment_clas_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/transactions/equipment_class.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/transactions/equipment_mapping.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/transactions/equipment_mapping_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/transactions/map_transaction.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/transactions/transaction.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/transactions/transaction_schema.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/__init__.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/bulk_lane_price_result_utils.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/case_conversion.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/datadog_logger.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/datetimes.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/dimension_utils.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/geocode_location.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/get_delivery_date.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/json_logger.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/lambda_utils.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/local_file.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/logger.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/logger_v2.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/pc_miler_utils.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/price_utils.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/redis.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/s3_file.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/temperature_utils.py +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons.egg-info/dependency_links.txt +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons.egg-info/requires.txt +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons.egg-info/top_level.txt +0 -0
- {cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/setup.cfg +0 -0
@@ -33,6 +33,8 @@ class Config(object):
|
|
33
33
|
BOOKING_ASSISTANT_SNS_TOPIC_ARN = 'arn:aws:sns:us-west-1:791608169866:booking-assistant-flow-test'
|
34
34
|
BOOKING_ASSISTANT_SNS_SUBJECT = 'booking-assistant-flow'
|
35
35
|
BOOKING_ASSISTANT_SNS_CLASS_NAME = 'com.cargochief.sdk.bookingagent.sns.BookingAssistantFlowNotification'
|
36
|
+
BOOKING_ASSISTANT_QUOTE_CANCEL_SUBJECT = 'quote-cancelled'
|
37
|
+
BOOKING_ASSISTANT_QUOTE_CANCEL_CLASS_NAME = 'com.cargochief.sdk.bookingagent.sns.QuoteCancelNotification'
|
36
38
|
IMPORT_MOVEMENTS_SNS_TOPIC_ARN = 'arn:aws:sns:us-west-1:791608169866:mcleod-import-movements-test'
|
37
39
|
IMPORT_MOVEMENTS_SNS_SUBJECT = 'import-movements'
|
38
40
|
IMPORT_MOVEMENTS_SNS_CLASS_NAME = 'com.cargochief.sdk.c4.sns.mcleod.ImportMovementsNotification'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import json
|
2
|
+
import traceback
|
3
|
+
|
4
|
+
from cc_py_commons.config.env import app_config
|
5
|
+
from cc_py_commons.sqs.sqs_service import SqsService
|
6
|
+
from cc_py_commons.utils.logger_v2 import logger
|
7
|
+
|
8
|
+
class BookingAssistantQuoteCancelNotification:
|
9
|
+
|
10
|
+
def send(self, load_id):
|
11
|
+
'''
|
12
|
+
Sends and event to the Booking Assistant Flow SQS queue specified in the config.
|
13
|
+
Returns the messageId of the enqueued message for later retrieval.
|
14
|
+
'''
|
15
|
+
event = {
|
16
|
+
'loadId': str(load_id),
|
17
|
+
'subject': app_config.BOOKING_ASSISTANT_QUOTE_CANCEL_SUBJECT,
|
18
|
+
'className': app_config.BOOKING_ASSISTANT_QUOTE_CANCEL_CLASS_NAME
|
19
|
+
}
|
20
|
+
logger.debug(f"sending event {event} to {app_config.BOOKING_ASSISTANT_FLOW_QUEUE}")
|
21
|
+
|
22
|
+
try:
|
23
|
+
sqs_service = SqsService()
|
24
|
+
return sqs_service.send(app_config.BOOKING_ASSISTANT_FLOW_QUEUE, json.dumps(event), app_config.BOOKING_ASSISTANT_DELAY_SECONDS)
|
25
|
+
except Exception as e:
|
26
|
+
logger.error(json.dumps({
|
27
|
+
'message': 'Failed to send class BookingAssistantQuoteCancelNotification',
|
28
|
+
'error': str(e),
|
29
|
+
'sta_cktrace': traceback.format_exc(),
|
30
|
+
'event': event
|
31
|
+
}))
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import json
|
2
|
+
from uuid import uuid4
|
3
|
+
import boto3
|
4
|
+
|
5
|
+
class SqsService:
|
6
|
+
def send(self, queue_url, message, delaySeconds=0, messageGroupId=None):
|
7
|
+
'''
|
8
|
+
Sends a message to the specified queue and returns the messageId.
|
9
|
+
The messageId can be used to lookup and delete the message in the queue.
|
10
|
+
'''
|
11
|
+
sqs = boto3.client('sqs')
|
12
|
+
if messageGroupId:
|
13
|
+
response = sqs.send_message(
|
14
|
+
QueueUrl=queue_url,
|
15
|
+
MessageBody=message,
|
16
|
+
DelaySeconds=delaySeconds,
|
17
|
+
MessageAttributes={},
|
18
|
+
MessageGroupId=messageGroupId
|
19
|
+
)
|
20
|
+
else:
|
21
|
+
response = sqs.send_message(
|
22
|
+
QueueUrl=queue_url,
|
23
|
+
MessageBody=message,
|
24
|
+
DelaySeconds=delaySeconds,
|
25
|
+
MessageAttributes={}
|
26
|
+
)
|
27
|
+
return response.get('MessageId')
|
28
|
+
|
29
|
+
def send_batches(queue_url, messages):
|
30
|
+
'''
|
31
|
+
Sends all messages to the specified queue in groups of 10 (the limit of send_batch)
|
32
|
+
The messageId can be used to lookup and delete the message in the queue.
|
33
|
+
Args:
|
34
|
+
queue_url (str): The URL of the Amazon SQS queue
|
35
|
+
messages (list): List of messages to be sent
|
36
|
+
|
37
|
+
Returns:
|
38
|
+
dict: Results containing 'successful' and 'failed' message lists
|
39
|
+
'''
|
40
|
+
results = {
|
41
|
+
'successful': [],
|
42
|
+
'failed': []
|
43
|
+
}
|
44
|
+
|
45
|
+
if not messages:
|
46
|
+
return results
|
47
|
+
|
48
|
+
sqs = boto3.client('sqs')
|
49
|
+
entries = [
|
50
|
+
{
|
51
|
+
# each message must have a unique id
|
52
|
+
'Id': str(uuid4()),
|
53
|
+
'MessageBody': json.dumps(message),
|
54
|
+
}
|
55
|
+
for message in messages
|
56
|
+
]
|
57
|
+
|
58
|
+
# SQS can only process 10 messages per batch
|
59
|
+
batch_size = 10
|
60
|
+
|
61
|
+
# Split messages into batches of 10
|
62
|
+
for i in range(0, len(entries), batch_size):
|
63
|
+
batch = entries[i:i + batch_size]
|
64
|
+
|
65
|
+
try:
|
66
|
+
response = sqs.send_message_batch(
|
67
|
+
QueueUrl=queue_url,
|
68
|
+
Entries=batch
|
69
|
+
)
|
70
|
+
|
71
|
+
# Track successful and failed messages
|
72
|
+
if 'Successful' in response:
|
73
|
+
results['successful'].extend(response['Successful'])
|
74
|
+
if 'Failed' in response:
|
75
|
+
results['failed'].extend(response['Failed'])
|
76
|
+
|
77
|
+
except Exception as e:
|
78
|
+
# Mark all messages in failed batch
|
79
|
+
failed_batch = [{
|
80
|
+
'Id': entry['Id'],
|
81
|
+
'Error': str(e),
|
82
|
+
'Message': entry['MessageBody']
|
83
|
+
} for entry in batch]
|
84
|
+
results['failed'].extend(failed_batch)
|
85
|
+
|
86
|
+
return results
|
@@ -107,6 +107,7 @@ cc_py_commons/sns/booking_agent/bid_counter_failure_notification.py
|
|
107
107
|
cc_py_commons/sns/booking_agent/constants.py
|
108
108
|
cc_py_commons/sns/booking_agent/send_sns_notification.py
|
109
109
|
cc_py_commons/sqs/__init__.py
|
110
|
+
cc_py_commons/sqs/booking_assistant_cancel_quote_notification.py
|
110
111
|
cc_py_commons/sqs/booking_assistant_flow_event.py
|
111
112
|
cc_py_commons/sqs/sqs_service.py
|
112
113
|
cc_py_commons/tests/__init__.py
|
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
|
3
3
|
setup(
|
4
4
|
name='cc_py_commons',
|
5
5
|
description='Common code for microservices',
|
6
|
-
version='0.5.
|
6
|
+
version='0.5.33',
|
7
7
|
url='https://github.com/Cargo-Chief/py-commons',
|
8
8
|
author='CargoChief',
|
9
9
|
author_email='engineering@cargochief.com',
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import boto3
|
2
|
-
|
3
|
-
class SqsService:
|
4
|
-
def send(self, queue_url, message, delaySeconds=0, messageGroupId=None):
|
5
|
-
'''
|
6
|
-
Sends a message to the specified queue and returns the messageId.
|
7
|
-
The messageId can be used to lookup and delete the message in the queue.
|
8
|
-
'''
|
9
|
-
sqs = boto3.client('sqs')
|
10
|
-
if messageGroupId:
|
11
|
-
response = sqs.send_message(
|
12
|
-
QueueUrl=queue_url,
|
13
|
-
MessageBody=message,
|
14
|
-
DelaySeconds=delaySeconds,
|
15
|
-
MessageAttributes={},
|
16
|
-
MessageGroupId=messageGroupId
|
17
|
-
)
|
18
|
-
else:
|
19
|
-
response = sqs.send_message(
|
20
|
-
QueueUrl=queue_url,
|
21
|
-
MessageBody=message,
|
22
|
-
DelaySeconds=delaySeconds,
|
23
|
-
MessageAttributes={}
|
24
|
-
)
|
25
|
-
return response.get('MessageId')
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/carriers/account_carrier_map_schema.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/loads/freighthub_contact_schema.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/analytics/analytics_event.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/__init__.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/accept_bid.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/cancel_bid.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/constants.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/counter_bid.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/decline_bid.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/get_quote.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/list_bids.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/list_quotes.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/booking_agent/update_bid.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/c4/amazon_session_token.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/c4/get_account_settings.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/c4/get_users_for_account.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/c4/refresh_amazon_token.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/carrier_hub/__init__.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/carrier_hub/get_carrier.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/carrier_hub/list_carriers.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/carrier_hub/list_contacts.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/carrier_hub/update_contact.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/freight_hub/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/db/delete_table.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/get_import_stat.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/get_lane_price.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/list_clients.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/post_import_stat.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/mercury/update_import_stat.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/services/slack/send_slack_message.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sns/import_movements_notification.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sns/parsed_carrier_notification.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/sqs/booking_assistant_flow_event.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/transactions/equipment_clas_schema.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/transactions/equipment_mapping.py
RENAMED
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/transactions/equipment_mapping_schema.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/transactions/transaction_schema.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.31 → cc_py_commons-0.5.33}/cc_py_commons/utils/bulk_lane_price_result_utils.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|