|
5 | 5 | from .address_helper import AddressHelper |
6 | 6 | from .common import CommonValues, QueueType |
7 | 7 | from .entities import ( |
| 8 | + ExchangeCustomSpecification, |
8 | 9 | ExchangeSpecification, |
9 | 10 | ExchangeToExchangeBindingSpecification, |
10 | 11 | ExchangeToQueueBindingSpecification, |
@@ -98,15 +99,21 @@ def _request( |
98 | 99 | return msg |
99 | 100 |
|
100 | 101 | def declare_exchange( |
101 | | - self, exchange_specification: ExchangeSpecification |
102 | | - ) -> ExchangeSpecification: |
| 102 | + self, |
| 103 | + exchange_specification: Union[ |
| 104 | + ExchangeSpecification, ExchangeCustomSpecification |
| 105 | + ], |
| 106 | + ) -> Union[ExchangeSpecification, ExchangeCustomSpecification]: |
103 | 107 | logger.debug("declare_exchange operation called") |
104 | | - body = {} |
| 108 | + body: dict[str, Any] = {} |
105 | 109 | body["auto_delete"] = exchange_specification.is_auto_delete |
106 | 110 | body["durable"] = exchange_specification.is_durable |
107 | | - body["type"] = exchange_specification.exchange_type.value # type: ignore |
| 111 | + if isinstance(exchange_specification, ExchangeSpecification): |
| 112 | + body["type"] = exchange_specification.exchange_type.value |
| 113 | + elif isinstance(exchange_specification, ExchangeCustomSpecification): |
| 114 | + body["type"] = exchange_specification.exchange_type |
108 | 115 | body["internal"] = exchange_specification.is_internal |
109 | | - body["arguments"] = exchange_specification.arguments # type: ignore |
| 116 | + body["arguments"] = exchange_specification.arguments |
110 | 117 |
|
111 | 118 | path = AddressHelper.exchange_address(exchange_specification.name) |
112 | 119 |
|
|
0 commit comments