Skip to content

Commit

Permalink
Add max_message_size_in_kilobytes to azure_rm_servicebusqueue.py (#1092)
Browse files Browse the repository at this point in the history
* Add max_message_size_in_kilobytes to azure_rm_servicebustopic.py and azure_rm_servicebusqueue.py

* fix sanity fail

* Modify the document!

---------

Co-authored-by: xuzhang3 <[email protected]>
  • Loading branch information
Fred-sun and xuzhang3 authored Apr 6, 2023
1 parent c6021f9 commit d8f0593
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions plugins/modules/azure_rm_servicebusqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
- The maximum delivery count.
- A message is automatically deadlettered after this number of deliveries.
type: int
max_message_size_in_kb:
description:
- Maximum size (in KB) of the message payload that can be accepted by the queue.
- This property is only used in Premium today and default is 1024.
type: int
max_size_in_mb:
description:
- The maximum size of the queue in megabytes, which is the size of memory allocated for the queue.
Expand Down Expand Up @@ -178,6 +183,7 @@ def __init__(self):
forward_to=dict(type='str'),
lock_duration_in_seconds=dict(type='int'),
max_delivery_count=dict(type='int'),
max_message_size_in_kb=dict(type='int'),
max_size_in_mb=dict(type='int'),
requires_duplicate_detection=dict(type='bool'),
requires_session=dict(type='bool'),
Expand Down Expand Up @@ -206,6 +212,7 @@ def __init__(self):
self.requires_duplicate_detection = None
self.status = None
self.requires_session = None
self.max_message_size_in_kb = None

self.results = dict(
changed=False,
Expand Down Expand Up @@ -234,6 +241,7 @@ def exec_module(self, **kwargs):
forward_dead_lettered_messages_to=self.forward_dead_lettered_messages_to,
forward_to=self.forward_to,
max_delivery_count=self.max_delivery_count,
max_message_size_in_kilobytes=self.max_message_size_in_kb,
max_size_in_megabytes=self.max_size_in_mb,
requires_session=self.requires_session,
requires_duplicate_detection=self.requires_duplicate_detection
Expand Down Expand Up @@ -270,6 +278,7 @@ def exec_module(self, **kwargs):
return self.results

def create_or_update(self, param):

try:
client = self._get_client()
return client.create_or_update(self.resource_group, self.namespace, self.name, param)
Expand Down Expand Up @@ -317,6 +326,8 @@ def to_dict(self, instance):
result[attribute] = to_native(value)
elif attribute == 'max_size_in_megabytes':
result['max_size_in_mb'] = value
elif attribute == 'max_size_in_kilobytes':
result['max_size_in_kb'] = value
else:
result[attribute] = value
return result
Expand Down
10 changes: 10 additions & 0 deletions plugins/modules/azure_rm_servicebustopic.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
description:
- A value that indicates whether the topic is to be partitioned across multiple message brokers.
type: bool
max_message_size_in_kb:
description:
- Maximum size (in KB) of the message payload that can be accepted by the queue.
- This property is only used in Premium today and default is 1024.
type: int
max_size_in_mb:
description:
- The maximum size of the topic in megabytes, which is the size of memory allocated for the topic.
Expand Down Expand Up @@ -149,6 +154,7 @@ def __init__(self):
enable_express=dict(type='bool'),
enable_partitioning=dict(type='bool'),
max_size_in_mb=dict(type='int'),
max_message_size_in_kb=dict(type='int'),
name=dict(type='str', required=True),
namespace=dict(type='str'),
requires_duplicate_detection=dict(type='bool'),
Expand All @@ -172,6 +178,7 @@ def __init__(self):
self.requires_duplicate_detection = None
self.status = None
self.support_ordering = None
self.max_message_size_in_kb = None

self.results = dict(
changed=False,
Expand All @@ -196,6 +203,7 @@ def exec_module(self, **kwargs):
enable_express=self.enable_express,
enable_partitioning=self.enable_partitioning,
max_size_in_megabytes=self.max_size_in_mb,
max_message_size_in_kilobytes=self.max_message_size_in_kb,
support_ordering=self.support_ordering
)
if self.status:
Expand Down Expand Up @@ -277,6 +285,8 @@ def to_dict(self, instance):
result[attribute] = to_native(value)
elif attribute == 'max_size_in_megabytes':
result['max_size_in_mb'] = value
elif attribute == 'max_message_size_in_kilobyte':
result['max_message_size_in_kb'] = value
else:
result[attribute] = value
return result
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/targets/azure_rm_servicebus/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
azure_rm_servicebus:
name: "ns{{ rpfx }}"
resource_group: "{{ resource_group }}"
sku: premium
tags:
key1: value1
register: namespace
Expand All @@ -32,6 +33,8 @@
name: "queue{{ rpfx }}"
namespace: "ns{{ rpfx }}"
resource_group: "{{ resource_group }}"
max_message_size_in_kb: 2048
max_size_in_mb: 2048
register: queue

- assert:
Expand All @@ -45,6 +48,8 @@
resource_group: "{{ resource_group }}"
namespace: "ns{{ rpfx }}"
duplicate_detection_time_in_seconds: 600
max_message_size_in_kb: 2048
max_size_in_mb: 2048
check_mode: yes
register: output

Expand All @@ -58,6 +63,8 @@
resource_group: "{{ resource_group }}"
namespace: "ns{{ rpfx }}"
duplicate_detection_time_in_seconds: 600
max_message_size_in_kb: 2048
max_size_in_mb: 2048
register: output

- assert:
Expand All @@ -72,6 +79,8 @@
resource_group: "{{ resource_group }}"
namespace: "ns{{ rpfx }}"
duplicate_detection_time_in_seconds: 600
max_message_size_in_kb: 2048
max_size_in_mb: 2048
register: output

- assert:
Expand Down

0 comments on commit d8f0593

Please sign in to comment.