partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
BaseHandler.close
Close down the handler connection. If the handler has already closed, this operation will do nothing. An optional exception can be passed in to indicate that the handler was shutdown due to error. It is recommended to open a handler within a context manager as opposed to calling the method directly. .. note:: This operation is not thread-safe. :param exception: An optional exception if the handler is closing due to an error. :type exception: Exception Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START open_close_sender_directly] :end-before: [END open_close_sender_directly] :language: python :dedent: 4 :caption: Explicitly open and close a Sender.
azure-servicebus/azure/servicebus/aio/async_base_handler.py
async def close(self, exception=None): """Close down the handler connection. If the handler has already closed, this operation will do nothing. An optional exception can be passed in to indicate that the handler was shutdown due to error. It is recommended to open a handler within a context manager as opposed to calling the method directly. .. note:: This operation is not thread-safe. :param exception: An optional exception if the handler is closing due to an error. :type exception: Exception Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START open_close_sender_directly] :end-before: [END open_close_sender_directly] :language: python :dedent: 4 :caption: Explicitly open and close a Sender. """ self.running = False if self.error: return if isinstance(exception, ServiceBusError): self.error = exception elif exception: self.error = ServiceBusError(str(exception)) else: self.error = ServiceBusError("This message handler is now closed.") await self._handler.close_async()
async def close(self, exception=None): """Close down the handler connection. If the handler has already closed, this operation will do nothing. An optional exception can be passed in to indicate that the handler was shutdown due to error. It is recommended to open a handler within a context manager as opposed to calling the method directly. .. note:: This operation is not thread-safe. :param exception: An optional exception if the handler is closing due to an error. :type exception: Exception Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START open_close_sender_directly] :end-before: [END open_close_sender_directly] :language: python :dedent: 4 :caption: Explicitly open and close a Sender. """ self.running = False if self.error: return if isinstance(exception, ServiceBusError): self.error = exception elif exception: self.error = ServiceBusError(str(exception)) else: self.error = ServiceBusError("This message handler is now closed.") await self._handler.close_async()
[ "Close", "down", "the", "handler", "connection", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/aio/async_base_handler.py#L171-L204
[ "async", "def", "close", "(", "self", ",", "exception", "=", "None", ")", ":", "self", ".", "running", "=", "False", "if", "self", ".", "error", ":", "return", "if", "isinstance", "(", "exception", ",", "ServiceBusError", ")", ":", "self", ".", "error", "=", "exception", "elif", "exception", ":", "self", ".", "error", "=", "ServiceBusError", "(", "str", "(", "exception", ")", ")", "else", ":", "self", ".", "error", "=", "ServiceBusError", "(", "\"This message handler is now closed.\"", ")", "await", "self", ".", "_handler", ".", "close_async", "(", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
Receiver.open
Open receiver connection and authenticate session. If the receiver is already open, this operation will do nothing. This method will be called automatically when one starts to iterate messages in the receiver, so there should be no need to call it directly. A receiver opened with this method must be explicitly closed. It is recommended to open a handler within a context manager as opposed to calling the method directly. .. note:: This operation is not thread-safe.
azure-servicebus/azure/servicebus/aio/async_receive_handler.py
async def open(self): """Open receiver connection and authenticate session. If the receiver is already open, this operation will do nothing. This method will be called automatically when one starts to iterate messages in the receiver, so there should be no need to call it directly. A receiver opened with this method must be explicitly closed. It is recommended to open a handler within a context manager as opposed to calling the method directly. .. note:: This operation is not thread-safe. """ if self.running: return self.running = True try: await self._handler.open_async(connection=self.connection) self.message_iter = self._handler.receive_messages_iter_async() while not await self._handler.auth_complete_async(): await asyncio.sleep(0.05) await self._build_receiver() while not await self._handler.client_ready_async(): await asyncio.sleep(0.05) except Exception as e: # pylint: disable=broad-except try: await self._handle_exception(e) except: self.running = False raise
async def open(self): """Open receiver connection and authenticate session. If the receiver is already open, this operation will do nothing. This method will be called automatically when one starts to iterate messages in the receiver, so there should be no need to call it directly. A receiver opened with this method must be explicitly closed. It is recommended to open a handler within a context manager as opposed to calling the method directly. .. note:: This operation is not thread-safe. """ if self.running: return self.running = True try: await self._handler.open_async(connection=self.connection) self.message_iter = self._handler.receive_messages_iter_async() while not await self._handler.auth_complete_async(): await asyncio.sleep(0.05) await self._build_receiver() while not await self._handler.client_ready_async(): await asyncio.sleep(0.05) except Exception as e: # pylint: disable=broad-except try: await self._handle_exception(e) except: self.running = False raise
[ "Open", "receiver", "connection", "and", "authenticate", "session", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/aio/async_receive_handler.py#L215-L244
[ "async", "def", "open", "(", "self", ")", ":", "if", "self", ".", "running", ":", "return", "self", ".", "running", "=", "True", "try", ":", "await", "self", ".", "_handler", ".", "open_async", "(", "connection", "=", "self", ".", "connection", ")", "self", ".", "message_iter", "=", "self", ".", "_handler", ".", "receive_messages_iter_async", "(", ")", "while", "not", "await", "self", ".", "_handler", ".", "auth_complete_async", "(", ")", ":", "await", "asyncio", ".", "sleep", "(", "0.05", ")", "await", "self", ".", "_build_receiver", "(", ")", "while", "not", "await", "self", ".", "_handler", ".", "client_ready_async", "(", ")", ":", "await", "asyncio", ".", "sleep", "(", "0.05", ")", "except", "Exception", "as", "e", ":", "# pylint: disable=broad-except", "try", ":", "await", "self", ".", "_handle_exception", "(", "e", ")", "except", ":", "self", ".", "running", "=", "False", "raise" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
Receiver.close
Close down the receiver connection. If the receiver has already closed, this operation will do nothing. An optional exception can be passed in to indicate that the handler was shutdown due to error. It is recommended to open a handler within a context manager as opposed to calling the method directly. The receiver will be implicitly closed on completion of the message iterator, however this method will need to be called explicitly if the message iterator is not run to completion. .. note:: This operation is not thread-safe. :param exception: An optional exception if the handler is closing due to an error. :type exception: Exception Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START open_close_receiver_directly] :end-before: [END open_close_receiver_directly] :language: python :dedent: 4 :caption: Iterate then explicitly close a Receiver.
azure-servicebus/azure/servicebus/aio/async_receive_handler.py
async def close(self, exception=None): """Close down the receiver connection. If the receiver has already closed, this operation will do nothing. An optional exception can be passed in to indicate that the handler was shutdown due to error. It is recommended to open a handler within a context manager as opposed to calling the method directly. The receiver will be implicitly closed on completion of the message iterator, however this method will need to be called explicitly if the message iterator is not run to completion. .. note:: This operation is not thread-safe. :param exception: An optional exception if the handler is closing due to an error. :type exception: Exception Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START open_close_receiver_directly] :end-before: [END open_close_receiver_directly] :language: python :dedent: 4 :caption: Iterate then explicitly close a Receiver. """ if not self.running: return self.running = False self.receiver_shutdown = True self._used.set() await super(Receiver, self).close(exception=exception)
async def close(self, exception=None): """Close down the receiver connection. If the receiver has already closed, this operation will do nothing. An optional exception can be passed in to indicate that the handler was shutdown due to error. It is recommended to open a handler within a context manager as opposed to calling the method directly. The receiver will be implicitly closed on completion of the message iterator, however this method will need to be called explicitly if the message iterator is not run to completion. .. note:: This operation is not thread-safe. :param exception: An optional exception if the handler is closing due to an error. :type exception: Exception Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START open_close_receiver_directly] :end-before: [END open_close_receiver_directly] :language: python :dedent: 4 :caption: Iterate then explicitly close a Receiver. """ if not self.running: return self.running = False self.receiver_shutdown = True self._used.set() await super(Receiver, self).close(exception=exception)
[ "Close", "down", "the", "receiver", "connection", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/aio/async_receive_handler.py#L246-L277
[ "async", "def", "close", "(", "self", ",", "exception", "=", "None", ")", ":", "if", "not", "self", ".", "running", ":", "return", "self", ".", "running", "=", "False", "self", ".", "receiver_shutdown", "=", "True", "self", ".", "_used", ".", "set", "(", ")", "await", "super", "(", "Receiver", ",", "self", ")", ".", "close", "(", "exception", "=", "exception", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
SessionReceiver.get_session_state
Get the session state. Returns None if no state has been set. :rtype: str Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START set_session_state] :end-before: [END set_session_state] :language: python :dedent: 4 :caption: Getting and setting the state of a session.
azure-servicebus/azure/servicebus/aio/async_receive_handler.py
async def get_session_state(self): """Get the session state. Returns None if no state has been set. :rtype: str Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START set_session_state] :end-before: [END set_session_state] :language: python :dedent: 4 :caption: Getting and setting the state of a session. """ await self._can_run() response = await self._mgmt_request_response( REQUEST_RESPONSE_GET_SESSION_STATE_OPERATION, {'session-id': self.session_id}, mgmt_handlers.default) session_state = response.get(b'session-state') if isinstance(session_state, six.binary_type): session_state = session_state.decode('UTF-8') return session_state
async def get_session_state(self): """Get the session state. Returns None if no state has been set. :rtype: str Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START set_session_state] :end-before: [END set_session_state] :language: python :dedent: 4 :caption: Getting and setting the state of a session. """ await self._can_run() response = await self._mgmt_request_response( REQUEST_RESPONSE_GET_SESSION_STATE_OPERATION, {'session-id': self.session_id}, mgmt_handlers.default) session_state = response.get(b'session-state') if isinstance(session_state, six.binary_type): session_state = session_state.decode('UTF-8') return session_state
[ "Get", "the", "session", "state", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/aio/async_receive_handler.py#L513-L537
[ "async", "def", "get_session_state", "(", "self", ")", ":", "await", "self", ".", "_can_run", "(", ")", "response", "=", "await", "self", ".", "_mgmt_request_response", "(", "REQUEST_RESPONSE_GET_SESSION_STATE_OPERATION", ",", "{", "'session-id'", ":", "self", ".", "session_id", "}", ",", "mgmt_handlers", ".", "default", ")", "session_state", "=", "response", ".", "get", "(", "b'session-state'", ")", "if", "isinstance", "(", "session_state", ",", "six", ".", "binary_type", ")", ":", "session_state", "=", "session_state", ".", "decode", "(", "'UTF-8'", ")", "return", "session_state" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
SessionReceiver.set_session_state
Set the session state. :param state: The state value. :type state: str or bytes or bytearray Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START set_session_state] :end-before: [END set_session_state] :language: python :dedent: 4 :caption: Getting and setting the state of a session.
azure-servicebus/azure/servicebus/aio/async_receive_handler.py
async def set_session_state(self, state): """Set the session state. :param state: The state value. :type state: str or bytes or bytearray Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START set_session_state] :end-before: [END set_session_state] :language: python :dedent: 4 :caption: Getting and setting the state of a session. """ await self._can_run() state = state.encode(self.encoding) if isinstance(state, six.text_type) else state return await self._mgmt_request_response( REQUEST_RESPONSE_SET_SESSION_STATE_OPERATION, {'session-id': self.session_id, 'session-state': bytearray(state)}, mgmt_handlers.default)
async def set_session_state(self, state): """Set the session state. :param state: The state value. :type state: str or bytes or bytearray Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START set_session_state] :end-before: [END set_session_state] :language: python :dedent: 4 :caption: Getting and setting the state of a session. """ await self._can_run() state = state.encode(self.encoding) if isinstance(state, six.text_type) else state return await self._mgmt_request_response( REQUEST_RESPONSE_SET_SESSION_STATE_OPERATION, {'session-id': self.session_id, 'session-state': bytearray(state)}, mgmt_handlers.default)
[ "Set", "the", "session", "state", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/aio/async_receive_handler.py#L539-L559
[ "async", "def", "set_session_state", "(", "self", ",", "state", ")", ":", "await", "self", ".", "_can_run", "(", ")", "state", "=", "state", ".", "encode", "(", "self", ".", "encoding", ")", "if", "isinstance", "(", "state", ",", "six", ".", "text_type", ")", "else", "state", "return", "await", "self", ".", "_mgmt_request_response", "(", "REQUEST_RESPONSE_SET_SESSION_STATE_OPERATION", ",", "{", "'session-id'", ":", "self", ".", "session_id", ",", "'session-state'", ":", "bytearray", "(", "state", ")", "}", ",", "mgmt_handlers", ".", "default", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
SessionReceiver.receive_deferred_messages
Receive messages that have previously been deferred. This operation can only receive deferred messages from the current session. When receiving deferred messages from a partitioned entity, all of the supplied sequence numbers must be messages from the same partition. :param sequence_numbers: A list of the sequence numbers of messages that have been deferred. :type sequence_numbers: list[int] :param mode: The receive mode, default value is PeekLock. :type mode: ~azure.servicebus.common.constants.ReceiveSettleMode :rtype: list[~azure.servicebus.aio.async_message.DeferredMessage] Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START receiver_defer_session_messages] :end-before: [END receiver_defer_session_messages] :language: python :dedent: 8 :caption: Defer messages, then retrieve them by sequence number.
azure-servicebus/azure/servicebus/aio/async_receive_handler.py
async def receive_deferred_messages(self, sequence_numbers, mode=ReceiveSettleMode.PeekLock): """Receive messages that have previously been deferred. This operation can only receive deferred messages from the current session. When receiving deferred messages from a partitioned entity, all of the supplied sequence numbers must be messages from the same partition. :param sequence_numbers: A list of the sequence numbers of messages that have been deferred. :type sequence_numbers: list[int] :param mode: The receive mode, default value is PeekLock. :type mode: ~azure.servicebus.common.constants.ReceiveSettleMode :rtype: list[~azure.servicebus.aio.async_message.DeferredMessage] Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START receiver_defer_session_messages] :end-before: [END receiver_defer_session_messages] :language: python :dedent: 8 :caption: Defer messages, then retrieve them by sequence number. """ if not sequence_numbers: raise ValueError("At least one sequence number must be specified.") await self._can_run() try: receive_mode = mode.value.value except AttributeError: receive_mode = int(mode) message = { 'sequence-numbers': types.AMQPArray([types.AMQPLong(s) for s in sequence_numbers]), 'receiver-settle-mode': types.AMQPuInt(receive_mode), 'session-id': self.session_id } handler = functools.partial(mgmt_handlers.deferred_message_op, mode=receive_mode, message_type=DeferredMessage) messages = await self._mgmt_request_response( REQUEST_RESPONSE_RECEIVE_BY_SEQUENCE_NUMBER, message, handler) for m in messages: m._receiver = self # pylint: disable=protected-access return messages
async def receive_deferred_messages(self, sequence_numbers, mode=ReceiveSettleMode.PeekLock): """Receive messages that have previously been deferred. This operation can only receive deferred messages from the current session. When receiving deferred messages from a partitioned entity, all of the supplied sequence numbers must be messages from the same partition. :param sequence_numbers: A list of the sequence numbers of messages that have been deferred. :type sequence_numbers: list[int] :param mode: The receive mode, default value is PeekLock. :type mode: ~azure.servicebus.common.constants.ReceiveSettleMode :rtype: list[~azure.servicebus.aio.async_message.DeferredMessage] Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START receiver_defer_session_messages] :end-before: [END receiver_defer_session_messages] :language: python :dedent: 8 :caption: Defer messages, then retrieve them by sequence number. """ if not sequence_numbers: raise ValueError("At least one sequence number must be specified.") await self._can_run() try: receive_mode = mode.value.value except AttributeError: receive_mode = int(mode) message = { 'sequence-numbers': types.AMQPArray([types.AMQPLong(s) for s in sequence_numbers]), 'receiver-settle-mode': types.AMQPuInt(receive_mode), 'session-id': self.session_id } handler = functools.partial(mgmt_handlers.deferred_message_op, mode=receive_mode, message_type=DeferredMessage) messages = await self._mgmt_request_response( REQUEST_RESPONSE_RECEIVE_BY_SEQUENCE_NUMBER, message, handler) for m in messages: m._receiver = self # pylint: disable=protected-access return messages
[ "Receive", "messages", "that", "have", "previously", "been", "deferred", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/aio/async_receive_handler.py#L625-L667
[ "async", "def", "receive_deferred_messages", "(", "self", ",", "sequence_numbers", ",", "mode", "=", "ReceiveSettleMode", ".", "PeekLock", ")", ":", "if", "not", "sequence_numbers", ":", "raise", "ValueError", "(", "\"At least one sequence number must be specified.\"", ")", "await", "self", ".", "_can_run", "(", ")", "try", ":", "receive_mode", "=", "mode", ".", "value", ".", "value", "except", "AttributeError", ":", "receive_mode", "=", "int", "(", "mode", ")", "message", "=", "{", "'sequence-numbers'", ":", "types", ".", "AMQPArray", "(", "[", "types", ".", "AMQPLong", "(", "s", ")", "for", "s", "in", "sequence_numbers", "]", ")", ",", "'receiver-settle-mode'", ":", "types", ".", "AMQPuInt", "(", "receive_mode", ")", ",", "'session-id'", ":", "self", ".", "session_id", "}", "handler", "=", "functools", ".", "partial", "(", "mgmt_handlers", ".", "deferred_message_op", ",", "mode", "=", "receive_mode", ",", "message_type", "=", "DeferredMessage", ")", "messages", "=", "await", "self", ".", "_mgmt_request_response", "(", "REQUEST_RESPONSE_RECEIVE_BY_SEQUENCE_NUMBER", ",", "message", ",", "handler", ")", "for", "m", "in", "messages", ":", "m", ".", "_receiver", "=", "self", "# pylint: disable=protected-access", "return", "messages" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ReservationOperations.merge
Merges two `Reservation`s. Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. :param reservation_order_id: Order Id of the reservation :type reservation_order_id: str :param sources: Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} :type sources: list[str] :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns list or ClientRawResponse<list> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[list[~azure.mgmt.reservations.models.ReservationResponse]] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[list[~azure.mgmt.reservations.models.ReservationResponse]]] :raises: :class:`ErrorException<azure.mgmt.reservations.models.ErrorException>`
azure-mgmt-reservations/azure/mgmt/reservations/operations/reservation_operations.py
def merge( self, reservation_order_id, sources=None, custom_headers=None, raw=False, polling=True, **operation_config): """Merges two `Reservation`s. Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. :param reservation_order_id: Order Id of the reservation :type reservation_order_id: str :param sources: Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} :type sources: list[str] :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns list or ClientRawResponse<list> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[list[~azure.mgmt.reservations.models.ReservationResponse]] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[list[~azure.mgmt.reservations.models.ReservationResponse]]] :raises: :class:`ErrorException<azure.mgmt.reservations.models.ErrorException>` """ raw_result = self._merge_initial( reservation_order_id=reservation_order_id, sources=sources, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('[ReservationResponse]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def merge( self, reservation_order_id, sources=None, custom_headers=None, raw=False, polling=True, **operation_config): """Merges two `Reservation`s. Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged must have same properties. :param reservation_order_id: Order Id of the reservation :type reservation_order_id: str :param sources: Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} :type sources: list[str] :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns list or ClientRawResponse<list> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[list[~azure.mgmt.reservations.models.ReservationResponse]] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[list[~azure.mgmt.reservations.models.ReservationResponse]]] :raises: :class:`ErrorException<azure.mgmt.reservations.models.ErrorException>` """ raw_result = self._merge_initial( reservation_order_id=reservation_order_id, sources=sources, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('[ReservationResponse]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Merges", "two", "Reservation", "s", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-reservations/azure/mgmt/reservations/operations/reservation_operations.py#L194-L243
[ "def", "merge", "(", "self", ",", "reservation_order_id", ",", "sources", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_merge_initial", "(", "reservation_order_id", "=", "reservation_order_id", ",", "sources", "=", "sources", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'[ReservationResponse]'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
HttpBearerChallenge._validate_challenge
Verifies that the challenge is a Bearer challenge and returns the key=value pairs.
azure-keyvault/azure/keyvault/http_bearer_challenge.py
def _validate_challenge(self, challenge): """ Verifies that the challenge is a Bearer challenge and returns the key=value pairs. """ bearer_string = 'Bearer ' if not challenge: raise ValueError('Challenge cannot be empty') challenge = challenge.strip() if not challenge.startswith(bearer_string): raise ValueError('Challenge is not Bearer') return challenge[len(bearer_string):]
def _validate_challenge(self, challenge): """ Verifies that the challenge is a Bearer challenge and returns the key=value pairs. """ bearer_string = 'Bearer ' if not challenge: raise ValueError('Challenge cannot be empty') challenge = challenge.strip() if not challenge.startswith(bearer_string): raise ValueError('Challenge is not Bearer') return challenge[len(bearer_string):]
[ "Verifies", "that", "the", "challenge", "is", "a", "Bearer", "challenge", "and", "returns", "the", "key", "=", "value", "pairs", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-keyvault/azure/keyvault/http_bearer_challenge.py#L73-L83
[ "def", "_validate_challenge", "(", "self", ",", "challenge", ")", ":", "bearer_string", "=", "'Bearer '", "if", "not", "challenge", ":", "raise", "ValueError", "(", "'Challenge cannot be empty'", ")", "challenge", "=", "challenge", ".", "strip", "(", ")", "if", "not", "challenge", ".", "startswith", "(", "bearer_string", ")", ":", "raise", "ValueError", "(", "'Challenge is not Bearer'", ")", "return", "challenge", "[", "len", "(", "bearer_string", ")", ":", "]" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
WorkspacesOperations.purge
Purges data in an Log Analytics workspace by a set of user-defined filters. :param resource_group_name: The name of the resource group to get. The name is case insensitive. :type resource_group_name: str :param workspace_name: Log Analytics workspace name :type workspace_name: str :param table: Table from which to purge data. :type table: str :param filters: The set of columns and filters (queries) to run over them to purge the resulting data. :type filters: list[~azure.mgmt.loganalytics.models.WorkspacePurgeBodyFilters] :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns object or ClientRawResponse<object> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[object] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[object]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/workspaces_operations.py
def purge( self, resource_group_name, workspace_name, table, filters, custom_headers=None, raw=False, polling=True, **operation_config): """Purges data in an Log Analytics workspace by a set of user-defined filters. :param resource_group_name: The name of the resource group to get. The name is case insensitive. :type resource_group_name: str :param workspace_name: Log Analytics workspace name :type workspace_name: str :param table: Table from which to purge data. :type table: str :param filters: The set of columns and filters (queries) to run over them to purge the resulting data. :type filters: list[~azure.mgmt.loganalytics.models.WorkspacePurgeBodyFilters] :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns object or ClientRawResponse<object> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[object] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[object]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._purge_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, table=table, filters=filters, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('object', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def purge( self, resource_group_name, workspace_name, table, filters, custom_headers=None, raw=False, polling=True, **operation_config): """Purges data in an Log Analytics workspace by a set of user-defined filters. :param resource_group_name: The name of the resource group to get. The name is case insensitive. :type resource_group_name: str :param workspace_name: Log Analytics workspace name :type workspace_name: str :param table: Table from which to purge data. :type table: str :param filters: The set of columns and filters (queries) to run over them to purge the resulting data. :type filters: list[~azure.mgmt.loganalytics.models.WorkspacePurgeBodyFilters] :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns object or ClientRawResponse<object> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[object] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[object]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._purge_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, table=table, filters=filters, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('object', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Purges", "data", "in", "an", "Log", "Analytics", "workspace", "by", "a", "set", "of", "user", "-", "defined", "filters", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/workspaces_operations.py#L396-L448
[ "def", "purge", "(", "self", ",", "resource_group_name", ",", "workspace_name", ",", "table", ",", "filters", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_purge_initial", "(", "resource_group_name", "=", "resource_group_name", ",", "workspace_name", "=", "workspace_name", ",", "table", "=", "table", ",", "filters", "=", "filters", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'object'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_error_handler
Handle connection and service errors. Called internally when an event has failed to send so we can parse the error to determine whether we should attempt to retry sending the event again. Returns the action to take according to error type. :param error: The error received in the send attempt. :type error: Exception :rtype: ~uamqp.errors.ErrorAction
azure-servicebus/azure/servicebus/common/errors.py
def _error_handler(error): """Handle connection and service errors. Called internally when an event has failed to send so we can parse the error to determine whether we should attempt to retry sending the event again. Returns the action to take according to error type. :param error: The error received in the send attempt. :type error: Exception :rtype: ~uamqp.errors.ErrorAction """ if error.condition == b'com.microsoft:server-busy': return errors.ErrorAction(retry=True, backoff=4) if error.condition == b'com.microsoft:timeout': return errors.ErrorAction(retry=True, backoff=2) if error.condition == b'com.microsoft:operation-cancelled': return errors.ErrorAction(retry=True) if error.condition == b"com.microsoft:container-close": return errors.ErrorAction(retry=True, backoff=4) if error.condition in _NO_RETRY_ERRORS: return errors.ErrorAction(retry=False) return errors.ErrorAction(retry=True)
def _error_handler(error): """Handle connection and service errors. Called internally when an event has failed to send so we can parse the error to determine whether we should attempt to retry sending the event again. Returns the action to take according to error type. :param error: The error received in the send attempt. :type error: Exception :rtype: ~uamqp.errors.ErrorAction """ if error.condition == b'com.microsoft:server-busy': return errors.ErrorAction(retry=True, backoff=4) if error.condition == b'com.microsoft:timeout': return errors.ErrorAction(retry=True, backoff=2) if error.condition == b'com.microsoft:operation-cancelled': return errors.ErrorAction(retry=True) if error.condition == b"com.microsoft:container-close": return errors.ErrorAction(retry=True, backoff=4) if error.condition in _NO_RETRY_ERRORS: return errors.ErrorAction(retry=False) return errors.ErrorAction(retry=True)
[ "Handle", "connection", "and", "service", "errors", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/errors.py#L38-L60
[ "def", "_error_handler", "(", "error", ")", ":", "if", "error", ".", "condition", "==", "b'com.microsoft:server-busy'", ":", "return", "errors", ".", "ErrorAction", "(", "retry", "=", "True", ",", "backoff", "=", "4", ")", "if", "error", ".", "condition", "==", "b'com.microsoft:timeout'", ":", "return", "errors", ".", "ErrorAction", "(", "retry", "=", "True", ",", "backoff", "=", "2", ")", "if", "error", ".", "condition", "==", "b'com.microsoft:operation-cancelled'", ":", "return", "errors", ".", "ErrorAction", "(", "retry", "=", "True", ")", "if", "error", ".", "condition", "==", "b\"com.microsoft:container-close\"", ":", "return", "errors", ".", "ErrorAction", "(", "retry", "=", "True", ",", "backoff", "=", "4", ")", "if", "error", ".", "condition", "in", "_NO_RETRY_ERRORS", ":", "return", "errors", ".", "ErrorAction", "(", "retry", "=", "False", ")", "return", "errors", ".", "ErrorAction", "(", "retry", "=", "True", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.with_filter
Returns a new service which will process requests with the specified filter. Filtering operations can include logging, automatic retrying, etc... The filter is a lambda which receives the HTTPRequest and another lambda. The filter can perform any pre-processing on the request, pass it off to the next lambda, and then perform any post-processing on the response.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def with_filter(self, filter_func): ''' Returns a new service which will process requests with the specified filter. Filtering operations can include logging, automatic retrying, etc... The filter is a lambda which receives the HTTPRequest and another lambda. The filter can perform any pre-processing on the request, pass it off to the next lambda, and then perform any post-processing on the response. ''' res = ServiceBusService( service_namespace=self.service_namespace, authentication=self.authentication) old_filter = self._filter def new_filter(request): return filter_func(request, old_filter) res._filter = new_filter # pylint: disable=protected-access return res
def with_filter(self, filter_func): ''' Returns a new service which will process requests with the specified filter. Filtering operations can include logging, automatic retrying, etc... The filter is a lambda which receives the HTTPRequest and another lambda. The filter can perform any pre-processing on the request, pass it off to the next lambda, and then perform any post-processing on the response. ''' res = ServiceBusService( service_namespace=self.service_namespace, authentication=self.authentication) old_filter = self._filter def new_filter(request): return filter_func(request, old_filter) res._filter = new_filter # pylint: disable=protected-access return res
[ "Returns", "a", "new", "service", "which", "will", "process", "requests", "with", "the", "specified", "filter", ".", "Filtering", "operations", "can", "include", "logging", "automatic", "retrying", "etc", "...", "The", "filter", "is", "a", "lambda", "which", "receives", "the", "HTTPRequest", "and", "another", "lambda", ".", "The", "filter", "can", "perform", "any", "pre", "-", "processing", "on", "the", "request", "pass", "it", "off", "to", "the", "next", "lambda", "and", "then", "perform", "any", "post", "-", "processing", "on", "the", "response", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L182-L201
[ "def", "with_filter", "(", "self", ",", "filter_func", ")", ":", "res", "=", "ServiceBusService", "(", "service_namespace", "=", "self", ".", "service_namespace", ",", "authentication", "=", "self", ".", "authentication", ")", "old_filter", "=", "self", ".", "_filter", "def", "new_filter", "(", "request", ")", ":", "return", "filter_func", "(", "request", ",", "old_filter", ")", "res", ".", "_filter", "=", "new_filter", "# pylint: disable=protected-access", "return", "res" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.create_queue
Creates a new queue. Once created, this queue's resource manifest is immutable. queue_name: Name of the queue to create. queue: Queue object to create. fail_on_exist: Specify whether to throw an exception when the queue exists.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def create_queue(self, queue_name, queue=None, fail_on_exist=False): ''' Creates a new queue. Once created, this queue's resource manifest is immutable. queue_name: Name of the queue to create. queue: Queue object to create. fail_on_exist: Specify whether to throw an exception when the queue exists. ''' _validate_not_none('queue_name', queue_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(queue_name) + '' request.body = _get_request_body(_convert_queue_to_xml(queue)) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) if not fail_on_exist: try: self._perform_request(request) return True except AzureHttpError as ex: _dont_fail_on_exist(ex) return False else: self._perform_request(request) return True
def create_queue(self, queue_name, queue=None, fail_on_exist=False): ''' Creates a new queue. Once created, this queue's resource manifest is immutable. queue_name: Name of the queue to create. queue: Queue object to create. fail_on_exist: Specify whether to throw an exception when the queue exists. ''' _validate_not_none('queue_name', queue_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(queue_name) + '' request.body = _get_request_body(_convert_queue_to_xml(queue)) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) if not fail_on_exist: try: self._perform_request(request) return True except AzureHttpError as ex: _dont_fail_on_exist(ex) return False else: self._perform_request(request) return True
[ "Creates", "a", "new", "queue", ".", "Once", "created", "this", "queue", "s", "resource", "manifest", "is", "immutable", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L226-L255
[ "def", "create_queue", "(", "self", ",", "queue_name", ",", "queue", "=", "None", ",", "fail_on_exist", "=", "False", ")", ":", "_validate_not_none", "(", "'queue_name'", ",", "queue_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'PUT'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "queue_name", ")", "+", "''", "request", ".", "body", "=", "_get_request_body", "(", "_convert_queue_to_xml", "(", "queue", ")", ")", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "if", "not", "fail_on_exist", ":", "try", ":", "self", ".", "_perform_request", "(", "request", ")", "return", "True", "except", "AzureHttpError", "as", "ex", ":", "_dont_fail_on_exist", "(", "ex", ")", "return", "False", "else", ":", "self", ".", "_perform_request", "(", "request", ")", "return", "True" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.delete_queue
Deletes an existing queue. This operation will also remove all associated state including messages in the queue. queue_name: Name of the queue to delete. fail_not_exist: Specify whether to throw an exception if the queue doesn't exist.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def delete_queue(self, queue_name, fail_not_exist=False): ''' Deletes an existing queue. This operation will also remove all associated state including messages in the queue. queue_name: Name of the queue to delete. fail_not_exist: Specify whether to throw an exception if the queue doesn't exist. ''' _validate_not_none('queue_name', queue_name) request = HTTPRequest() request.method = 'DELETE' request.host = self._get_host() request.path = '/' + _str(queue_name) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) if not fail_not_exist: try: self._perform_request(request) return True except AzureHttpError as ex: _dont_fail_not_exist(ex) return False else: self._perform_request(request) return True
def delete_queue(self, queue_name, fail_not_exist=False): ''' Deletes an existing queue. This operation will also remove all associated state including messages in the queue. queue_name: Name of the queue to delete. fail_not_exist: Specify whether to throw an exception if the queue doesn't exist. ''' _validate_not_none('queue_name', queue_name) request = HTTPRequest() request.method = 'DELETE' request.host = self._get_host() request.path = '/' + _str(queue_name) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) if not fail_not_exist: try: self._perform_request(request) return True except AzureHttpError as ex: _dont_fail_not_exist(ex) return False else: self._perform_request(request) return True
[ "Deletes", "an", "existing", "queue", ".", "This", "operation", "will", "also", "remove", "all", "associated", "state", "including", "messages", "in", "the", "queue", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L257-L283
[ "def", "delete_queue", "(", "self", ",", "queue_name", ",", "fail_not_exist", "=", "False", ")", ":", "_validate_not_none", "(", "'queue_name'", ",", "queue_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'DELETE'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "queue_name", ")", "+", "''", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "if", "not", "fail_not_exist", ":", "try", ":", "self", ".", "_perform_request", "(", "request", ")", "return", "True", "except", "AzureHttpError", "as", "ex", ":", "_dont_fail_not_exist", "(", "ex", ")", "return", "False", "else", ":", "self", ".", "_perform_request", "(", "request", ")", "return", "True" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.get_queue
Retrieves an existing queue. queue_name: Name of the queue.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def get_queue(self, queue_name): ''' Retrieves an existing queue. queue_name: Name of the queue. ''' _validate_not_none('queue_name', queue_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + _str(queue_name) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _convert_response_to_queue(response)
def get_queue(self, queue_name): ''' Retrieves an existing queue. queue_name: Name of the queue. ''' _validate_not_none('queue_name', queue_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + _str(queue_name) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _convert_response_to_queue(response)
[ "Retrieves", "an", "existing", "queue", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L285-L301
[ "def", "get_queue", "(", "self", ",", "queue_name", ")", ":", "_validate_not_none", "(", "'queue_name'", ",", "queue_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'GET'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "queue_name", ")", "+", "''", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "response", "=", "self", ".", "_perform_request", "(", "request", ")", "return", "_convert_response_to_queue", "(", "response", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.list_queues
Enumerates the queues in the service namespace.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def list_queues(self): ''' Enumerates the queues in the service namespace. ''' request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/$Resources/Queues' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _ETreeXmlToObject.convert_response_to_feeds( response, _convert_etree_element_to_queue)
def list_queues(self): ''' Enumerates the queues in the service namespace. ''' request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/$Resources/Queues' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _ETreeXmlToObject.convert_response_to_feeds( response, _convert_etree_element_to_queue)
[ "Enumerates", "the", "queues", "in", "the", "service", "namespace", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L303-L316
[ "def", "list_queues", "(", "self", ")", ":", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'GET'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/$Resources/Queues'", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "response", "=", "self", ".", "_perform_request", "(", "request", ")", "return", "_ETreeXmlToObject", ".", "convert_response_to_feeds", "(", "response", ",", "_convert_etree_element_to_queue", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.create_topic
Creates a new topic. Once created, this topic resource manifest is immutable. topic_name: Name of the topic to create. topic: Topic object to create. fail_on_exist: Specify whether to throw an exception when the topic exists.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def create_topic(self, topic_name, topic=None, fail_on_exist=False): ''' Creates a new topic. Once created, this topic resource manifest is immutable. topic_name: Name of the topic to create. topic: Topic object to create. fail_on_exist: Specify whether to throw an exception when the topic exists. ''' _validate_not_none('topic_name', topic_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(topic_name) + '' request.body = _get_request_body(_convert_topic_to_xml(topic)) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) if not fail_on_exist: try: self._perform_request(request) return True except AzureHttpError as ex: _dont_fail_on_exist(ex) return False else: self._perform_request(request) return True
def create_topic(self, topic_name, topic=None, fail_on_exist=False): ''' Creates a new topic. Once created, this topic resource manifest is immutable. topic_name: Name of the topic to create. topic: Topic object to create. fail_on_exist: Specify whether to throw an exception when the topic exists. ''' _validate_not_none('topic_name', topic_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(topic_name) + '' request.body = _get_request_body(_convert_topic_to_xml(topic)) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) if not fail_on_exist: try: self._perform_request(request) return True except AzureHttpError as ex: _dont_fail_on_exist(ex) return False else: self._perform_request(request) return True
[ "Creates", "a", "new", "topic", ".", "Once", "created", "this", "topic", "resource", "manifest", "is", "immutable", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L318-L347
[ "def", "create_topic", "(", "self", ",", "topic_name", ",", "topic", "=", "None", ",", "fail_on_exist", "=", "False", ")", ":", "_validate_not_none", "(", "'topic_name'", ",", "topic_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'PUT'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "topic_name", ")", "+", "''", "request", ".", "body", "=", "_get_request_body", "(", "_convert_topic_to_xml", "(", "topic", ")", ")", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "if", "not", "fail_on_exist", ":", "try", ":", "self", ".", "_perform_request", "(", "request", ")", "return", "True", "except", "AzureHttpError", "as", "ex", ":", "_dont_fail_on_exist", "(", "ex", ")", "return", "False", "else", ":", "self", ".", "_perform_request", "(", "request", ")", "return", "True" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.get_topic
Retrieves the description for the specified topic. topic_name: Name of the topic.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def get_topic(self, topic_name): ''' Retrieves the description for the specified topic. topic_name: Name of the topic. ''' _validate_not_none('topic_name', topic_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + _str(topic_name) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _convert_response_to_topic(response)
def get_topic(self, topic_name): ''' Retrieves the description for the specified topic. topic_name: Name of the topic. ''' _validate_not_none('topic_name', topic_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + _str(topic_name) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _convert_response_to_topic(response)
[ "Retrieves", "the", "description", "for", "the", "specified", "topic", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L377-L393
[ "def", "get_topic", "(", "self", ",", "topic_name", ")", ":", "_validate_not_none", "(", "'topic_name'", ",", "topic_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'GET'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "topic_name", ")", "+", "''", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "response", "=", "self", ".", "_perform_request", "(", "request", ")", "return", "_convert_response_to_topic", "(", "response", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.create_rule
Creates a new rule. Once created, this rule's resource manifest is immutable. topic_name: Name of the topic. subscription_name: Name of the subscription. rule_name: Name of the rule. fail_on_exist: Specify whether to throw an exception when the rule exists.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def create_rule(self, topic_name, subscription_name, rule_name, rule=None, fail_on_exist=False): ''' Creates a new rule. Once created, this rule's resource manifest is immutable. topic_name: Name of the topic. subscription_name: Name of the subscription. rule_name: Name of the rule. fail_on_exist: Specify whether to throw an exception when the rule exists. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) _validate_not_none('rule_name', rule_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(topic_name) + '/subscriptions/' + \ _str(subscription_name) + \ '/rules/' + _str(rule_name) + '' request.body = _get_request_body(_convert_rule_to_xml(rule)) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) if not fail_on_exist: try: self._perform_request(request) return True except AzureHttpError as ex: _dont_fail_on_exist(ex) return False else: self._perform_request(request) return True
def create_rule(self, topic_name, subscription_name, rule_name, rule=None, fail_on_exist=False): ''' Creates a new rule. Once created, this rule's resource manifest is immutable. topic_name: Name of the topic. subscription_name: Name of the subscription. rule_name: Name of the rule. fail_on_exist: Specify whether to throw an exception when the rule exists. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) _validate_not_none('rule_name', rule_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(topic_name) + '/subscriptions/' + \ _str(subscription_name) + \ '/rules/' + _str(rule_name) + '' request.body = _get_request_body(_convert_rule_to_xml(rule)) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) if not fail_on_exist: try: self._perform_request(request) return True except AzureHttpError as ex: _dont_fail_on_exist(ex) return False else: self._perform_request(request) return True
[ "Creates", "a", "new", "rule", ".", "Once", "created", "this", "rule", "s", "resource", "manifest", "is", "immutable", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L410-L446
[ "def", "create_rule", "(", "self", ",", "topic_name", ",", "subscription_name", ",", "rule_name", ",", "rule", "=", "None", ",", "fail_on_exist", "=", "False", ")", ":", "_validate_not_none", "(", "'topic_name'", ",", "topic_name", ")", "_validate_not_none", "(", "'subscription_name'", ",", "subscription_name", ")", "_validate_not_none", "(", "'rule_name'", ",", "rule_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'PUT'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "topic_name", ")", "+", "'/subscriptions/'", "+", "_str", "(", "subscription_name", ")", "+", "'/rules/'", "+", "_str", "(", "rule_name", ")", "+", "''", "request", ".", "body", "=", "_get_request_body", "(", "_convert_rule_to_xml", "(", "rule", ")", ")", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "if", "not", "fail_on_exist", ":", "try", ":", "self", ".", "_perform_request", "(", "request", ")", "return", "True", "except", "AzureHttpError", "as", "ex", ":", "_dont_fail_on_exist", "(", "ex", ")", "return", "False", "else", ":", "self", ".", "_perform_request", "(", "request", ")", "return", "True" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.get_rule
Retrieves the description for the specified rule. topic_name: Name of the topic. subscription_name: Name of the subscription. rule_name: Name of the rule.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def get_rule(self, topic_name, subscription_name, rule_name): ''' Retrieves the description for the specified rule. topic_name: Name of the topic. subscription_name: Name of the subscription. rule_name: Name of the rule. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) _validate_not_none('rule_name', rule_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + _str(topic_name) + '/subscriptions/' + \ _str(subscription_name) + \ '/rules/' + _str(rule_name) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _convert_response_to_rule(response)
def get_rule(self, topic_name, subscription_name, rule_name): ''' Retrieves the description for the specified rule. topic_name: Name of the topic. subscription_name: Name of the subscription. rule_name: Name of the rule. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) _validate_not_none('rule_name', rule_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + _str(topic_name) + '/subscriptions/' + \ _str(subscription_name) + \ '/rules/' + _str(rule_name) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _convert_response_to_rule(response)
[ "Retrieves", "the", "description", "for", "the", "specified", "rule", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L485-L509
[ "def", "get_rule", "(", "self", ",", "topic_name", ",", "subscription_name", ",", "rule_name", ")", ":", "_validate_not_none", "(", "'topic_name'", ",", "topic_name", ")", "_validate_not_none", "(", "'subscription_name'", ",", "subscription_name", ")", "_validate_not_none", "(", "'rule_name'", ",", "rule_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'GET'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "topic_name", ")", "+", "'/subscriptions/'", "+", "_str", "(", "subscription_name", ")", "+", "'/rules/'", "+", "_str", "(", "rule_name", ")", "+", "''", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "response", "=", "self", ".", "_perform_request", "(", "request", ")", "return", "_convert_response_to_rule", "(", "response", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.list_rules
Retrieves the rules that exist under the specified subscription. topic_name: Name of the topic. subscription_name: Name of the subscription.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def list_rules(self, topic_name, subscription_name): ''' Retrieves the rules that exist under the specified subscription. topic_name: Name of the topic. subscription_name: Name of the subscription. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + \ _str(topic_name) + '/subscriptions/' + \ _str(subscription_name) + '/rules/' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _ETreeXmlToObject.convert_response_to_feeds( response, _convert_etree_element_to_rule)
def list_rules(self, topic_name, subscription_name): ''' Retrieves the rules that exist under the specified subscription. topic_name: Name of the topic. subscription_name: Name of the subscription. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + \ _str(topic_name) + '/subscriptions/' + \ _str(subscription_name) + '/rules/' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _ETreeXmlToObject.convert_response_to_feeds( response, _convert_etree_element_to_rule)
[ "Retrieves", "the", "rules", "that", "exist", "under", "the", "specified", "subscription", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L511-L533
[ "def", "list_rules", "(", "self", ",", "topic_name", ",", "subscription_name", ")", ":", "_validate_not_none", "(", "'topic_name'", ",", "topic_name", ")", "_validate_not_none", "(", "'subscription_name'", ",", "subscription_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'GET'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "topic_name", ")", "+", "'/subscriptions/'", "+", "_str", "(", "subscription_name", ")", "+", "'/rules/'", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "response", "=", "self", ".", "_perform_request", "(", "request", ")", "return", "_ETreeXmlToObject", ".", "convert_response_to_feeds", "(", "response", ",", "_convert_etree_element_to_rule", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.create_subscription
Creates a new subscription. Once created, this subscription resource manifest is immutable. topic_name: Name of the topic. subscription_name: Name of the subscription. fail_on_exist: Specify whether throw exception when subscription exists.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def create_subscription(self, topic_name, subscription_name, subscription=None, fail_on_exist=False): ''' Creates a new subscription. Once created, this subscription resource manifest is immutable. topic_name: Name of the topic. subscription_name: Name of the subscription. fail_on_exist: Specify whether throw exception when subscription exists. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + \ _str(topic_name) + '/subscriptions/' + _str(subscription_name) + '' request.body = _get_request_body( _convert_subscription_to_xml(subscription)) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) if not fail_on_exist: try: self._perform_request(request) return True except AzureHttpError as ex: _dont_fail_on_exist(ex) return False else: self._perform_request(request) return True
def create_subscription(self, topic_name, subscription_name, subscription=None, fail_on_exist=False): ''' Creates a new subscription. Once created, this subscription resource manifest is immutable. topic_name: Name of the topic. subscription_name: Name of the subscription. fail_on_exist: Specify whether throw exception when subscription exists. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + \ _str(topic_name) + '/subscriptions/' + _str(subscription_name) + '' request.body = _get_request_body( _convert_subscription_to_xml(subscription)) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) if not fail_on_exist: try: self._perform_request(request) return True except AzureHttpError as ex: _dont_fail_on_exist(ex) return False else: self._perform_request(request) return True
[ "Creates", "a", "new", "subscription", ".", "Once", "created", "this", "subscription", "resource", "manifest", "is", "immutable", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L535-L568
[ "def", "create_subscription", "(", "self", ",", "topic_name", ",", "subscription_name", ",", "subscription", "=", "None", ",", "fail_on_exist", "=", "False", ")", ":", "_validate_not_none", "(", "'topic_name'", ",", "topic_name", ")", "_validate_not_none", "(", "'subscription_name'", ",", "subscription_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'PUT'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "topic_name", ")", "+", "'/subscriptions/'", "+", "_str", "(", "subscription_name", ")", "+", "''", "request", ".", "body", "=", "_get_request_body", "(", "_convert_subscription_to_xml", "(", "subscription", ")", ")", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "if", "not", "fail_on_exist", ":", "try", ":", "self", ".", "_perform_request", "(", "request", ")", "return", "True", "except", "AzureHttpError", "as", "ex", ":", "_dont_fail_on_exist", "(", "ex", ")", "return", "False", "else", ":", "self", ".", "_perform_request", "(", "request", ")", "return", "True" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.get_subscription
Gets an existing subscription. topic_name: Name of the topic. subscription_name: Name of the subscription.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def get_subscription(self, topic_name, subscription_name): ''' Gets an existing subscription. topic_name: Name of the topic. subscription_name: Name of the subscription. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + \ _str(topic_name) + '/subscriptions/' + _str(subscription_name) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _convert_response_to_subscription(response)
def get_subscription(self, topic_name, subscription_name): ''' Gets an existing subscription. topic_name: Name of the topic. subscription_name: Name of the subscription. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + \ _str(topic_name) + '/subscriptions/' + _str(subscription_name) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _convert_response_to_subscription(response)
[ "Gets", "an", "existing", "subscription", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L603-L623
[ "def", "get_subscription", "(", "self", ",", "topic_name", ",", "subscription_name", ")", ":", "_validate_not_none", "(", "'topic_name'", ",", "topic_name", ")", "_validate_not_none", "(", "'subscription_name'", ",", "subscription_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'GET'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "topic_name", ")", "+", "'/subscriptions/'", "+", "_str", "(", "subscription_name", ")", "+", "''", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "response", "=", "self", ".", "_perform_request", "(", "request", ")", "return", "_convert_response_to_subscription", "(", "response", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.list_subscriptions
Retrieves the subscriptions in the specified topic. topic_name: Name of the topic.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def list_subscriptions(self, topic_name): ''' Retrieves the subscriptions in the specified topic. topic_name: Name of the topic. ''' _validate_not_none('topic_name', topic_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + _str(topic_name) + '/subscriptions/' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _ETreeXmlToObject.convert_response_to_feeds( response, _convert_etree_element_to_subscription)
def list_subscriptions(self, topic_name): ''' Retrieves the subscriptions in the specified topic. topic_name: Name of the topic. ''' _validate_not_none('topic_name', topic_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + _str(topic_name) + '/subscriptions/' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _ETreeXmlToObject.convert_response_to_feeds( response, _convert_etree_element_to_subscription)
[ "Retrieves", "the", "subscriptions", "in", "the", "specified", "topic", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L625-L642
[ "def", "list_subscriptions", "(", "self", ",", "topic_name", ")", ":", "_validate_not_none", "(", "'topic_name'", ",", "topic_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'GET'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "topic_name", ")", "+", "'/subscriptions/'", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "response", "=", "self", ".", "_perform_request", "(", "request", ")", "return", "_ETreeXmlToObject", ".", "convert_response_to_feeds", "(", "response", ",", "_convert_etree_element_to_subscription", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.send_topic_message
Enqueues a message into the specified topic. The limit to the number of messages which may be present in the topic is governed by the message size in MaxTopicSizeInBytes. If this message causes the topic to exceed its quota, a quota exceeded error is returned and the message will be rejected. topic_name: Name of the topic. message: Message object containing message body and properties.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def send_topic_message(self, topic_name, message=None): ''' Enqueues a message into the specified topic. The limit to the number of messages which may be present in the topic is governed by the message size in MaxTopicSizeInBytes. If this message causes the topic to exceed its quota, a quota exceeded error is returned and the message will be rejected. topic_name: Name of the topic. message: Message object containing message body and properties. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('message', message) request = HTTPRequest() request.method = 'POST' request.host = self._get_host() request.path = '/' + _str(topic_name) + '/messages' request.headers = message.add_headers(request) request.body = _get_request_body(message.body) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) self._perform_request(request)
def send_topic_message(self, topic_name, message=None): ''' Enqueues a message into the specified topic. The limit to the number of messages which may be present in the topic is governed by the message size in MaxTopicSizeInBytes. If this message causes the topic to exceed its quota, a quota exceeded error is returned and the message will be rejected. topic_name: Name of the topic. message: Message object containing message body and properties. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('message', message) request = HTTPRequest() request.method = 'POST' request.host = self._get_host() request.path = '/' + _str(topic_name) + '/messages' request.headers = message.add_headers(request) request.body = _get_request_body(message.body) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) self._perform_request(request)
[ "Enqueues", "a", "message", "into", "the", "specified", "topic", ".", "The", "limit", "to", "the", "number", "of", "messages", "which", "may", "be", "present", "in", "the", "topic", "is", "governed", "by", "the", "message", "size", "in", "MaxTopicSizeInBytes", ".", "If", "this", "message", "causes", "the", "topic", "to", "exceed", "its", "quota", "a", "quota", "exceeded", "error", "is", "returned", "and", "the", "message", "will", "be", "rejected", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L644-L667
[ "def", "send_topic_message", "(", "self", ",", "topic_name", ",", "message", "=", "None", ")", ":", "_validate_not_none", "(", "'topic_name'", ",", "topic_name", ")", "_validate_not_none", "(", "'message'", ",", "message", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'POST'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "topic_name", ")", "+", "'/messages'", "request", ".", "headers", "=", "message", ".", "add_headers", "(", "request", ")", "request", ".", "body", "=", "_get_request_body", "(", "message", ".", "body", ")", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "self", ".", "_perform_request", "(", "request", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.peek_lock_subscription_message
This operation is used to atomically retrieve and lock a message for processing. The message is guaranteed not to be delivered to other receivers during the lock duration period specified in buffer description. Once the lock expires, the message will be available to other receivers (on the same subscription only) during the lock duration period specified in the topic description. Once the lock expires, the message will be available to other receivers. In order to complete processing of the message, the receiver should issue a delete command with the lock ID received from this operation. To abandon processing of the message and unlock it for other receivers, an Unlock Message command should be issued, or the lock duration period can expire. topic_name: Name of the topic. subscription_name: Name of the subscription. timeout: Optional. The timeout parameter is expressed in seconds.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def peek_lock_subscription_message(self, topic_name, subscription_name, timeout='60'): ''' This operation is used to atomically retrieve and lock a message for processing. The message is guaranteed not to be delivered to other receivers during the lock duration period specified in buffer description. Once the lock expires, the message will be available to other receivers (on the same subscription only) during the lock duration period specified in the topic description. Once the lock expires, the message will be available to other receivers. In order to complete processing of the message, the receiver should issue a delete command with the lock ID received from this operation. To abandon processing of the message and unlock it for other receivers, an Unlock Message command should be issued, or the lock duration period can expire. topic_name: Name of the topic. subscription_name: Name of the subscription. timeout: Optional. The timeout parameter is expressed in seconds. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) request = HTTPRequest() request.method = 'POST' request.host = self._get_host() request.path = '/' + \ _str(topic_name) + '/subscriptions/' + \ _str(subscription_name) + '/messages/head' request.query = [('timeout', _int_or_none(timeout))] request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _create_message(response, self)
def peek_lock_subscription_message(self, topic_name, subscription_name, timeout='60'): ''' This operation is used to atomically retrieve and lock a message for processing. The message is guaranteed not to be delivered to other receivers during the lock duration period specified in buffer description. Once the lock expires, the message will be available to other receivers (on the same subscription only) during the lock duration period specified in the topic description. Once the lock expires, the message will be available to other receivers. In order to complete processing of the message, the receiver should issue a delete command with the lock ID received from this operation. To abandon processing of the message and unlock it for other receivers, an Unlock Message command should be issued, or the lock duration period can expire. topic_name: Name of the topic. subscription_name: Name of the subscription. timeout: Optional. The timeout parameter is expressed in seconds. ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) request = HTTPRequest() request.method = 'POST' request.host = self._get_host() request.path = '/' + \ _str(topic_name) + '/subscriptions/' + \ _str(subscription_name) + '/messages/head' request.query = [('timeout', _int_or_none(timeout))] request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _create_message(response, self)
[ "This", "operation", "is", "used", "to", "atomically", "retrieve", "and", "lock", "a", "message", "for", "processing", ".", "The", "message", "is", "guaranteed", "not", "to", "be", "delivered", "to", "other", "receivers", "during", "the", "lock", "duration", "period", "specified", "in", "buffer", "description", ".", "Once", "the", "lock", "expires", "the", "message", "will", "be", "available", "to", "other", "receivers", "(", "on", "the", "same", "subscription", "only", ")", "during", "the", "lock", "duration", "period", "specified", "in", "the", "topic", "description", ".", "Once", "the", "lock", "expires", "the", "message", "will", "be", "available", "to", "other", "receivers", ".", "In", "order", "to", "complete", "processing", "of", "the", "message", "the", "receiver", "should", "issue", "a", "delete", "command", "with", "the", "lock", "ID", "received", "from", "this", "operation", ".", "To", "abandon", "processing", "of", "the", "message", "and", "unlock", "it", "for", "other", "receivers", "an", "Unlock", "Message", "command", "should", "be", "issued", "or", "the", "lock", "duration", "period", "can", "expire", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L694-L730
[ "def", "peek_lock_subscription_message", "(", "self", ",", "topic_name", ",", "subscription_name", ",", "timeout", "=", "'60'", ")", ":", "_validate_not_none", "(", "'topic_name'", ",", "topic_name", ")", "_validate_not_none", "(", "'subscription_name'", ",", "subscription_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'POST'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "topic_name", ")", "+", "'/subscriptions/'", "+", "_str", "(", "subscription_name", ")", "+", "'/messages/head'", "request", ".", "query", "=", "[", "(", "'timeout'", ",", "_int_or_none", "(", "timeout", ")", ")", "]", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "response", "=", "self", ".", "_perform_request", "(", "request", ")", "return", "_create_message", "(", "response", ",", "self", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.unlock_subscription_message
Unlock a message for processing by other receivers on a given subscription. This operation deletes the lock object, causing the message to be unlocked. A message must have first been locked by a receiver before this operation is called. topic_name: Name of the topic. subscription_name: Name of the subscription. sequence_number: The sequence number of the message to be unlocked as returned in BrokerProperties['SequenceNumber'] by the Peek Message operation. lock_token: The ID of the lock as returned by the Peek Message operation in BrokerProperties['LockToken']
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def unlock_subscription_message(self, topic_name, subscription_name, sequence_number, lock_token): ''' Unlock a message for processing by other receivers on a given subscription. This operation deletes the lock object, causing the message to be unlocked. A message must have first been locked by a receiver before this operation is called. topic_name: Name of the topic. subscription_name: Name of the subscription. sequence_number: The sequence number of the message to be unlocked as returned in BrokerProperties['SequenceNumber'] by the Peek Message operation. lock_token: The ID of the lock as returned by the Peek Message operation in BrokerProperties['LockToken'] ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) _validate_not_none('sequence_number', sequence_number) _validate_not_none('lock_token', lock_token) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(topic_name) + \ '/subscriptions/' + str(subscription_name) + \ '/messages/' + _str(sequence_number) + \ '/' + _str(lock_token) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) self._perform_request(request)
def unlock_subscription_message(self, topic_name, subscription_name, sequence_number, lock_token): ''' Unlock a message for processing by other receivers on a given subscription. This operation deletes the lock object, causing the message to be unlocked. A message must have first been locked by a receiver before this operation is called. topic_name: Name of the topic. subscription_name: Name of the subscription. sequence_number: The sequence number of the message to be unlocked as returned in BrokerProperties['SequenceNumber'] by the Peek Message operation. lock_token: The ID of the lock as returned by the Peek Message operation in BrokerProperties['LockToken'] ''' _validate_not_none('topic_name', topic_name) _validate_not_none('subscription_name', subscription_name) _validate_not_none('sequence_number', sequence_number) _validate_not_none('lock_token', lock_token) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(topic_name) + \ '/subscriptions/' + str(subscription_name) + \ '/messages/' + _str(sequence_number) + \ '/' + _str(lock_token) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) self._perform_request(request)
[ "Unlock", "a", "message", "for", "processing", "by", "other", "receivers", "on", "a", "given", "subscription", ".", "This", "operation", "deletes", "the", "lock", "object", "causing", "the", "message", "to", "be", "unlocked", ".", "A", "message", "must", "have", "first", "been", "locked", "by", "a", "receiver", "before", "this", "operation", "is", "called", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L732-L764
[ "def", "unlock_subscription_message", "(", "self", ",", "topic_name", ",", "subscription_name", ",", "sequence_number", ",", "lock_token", ")", ":", "_validate_not_none", "(", "'topic_name'", ",", "topic_name", ")", "_validate_not_none", "(", "'subscription_name'", ",", "subscription_name", ")", "_validate_not_none", "(", "'sequence_number'", ",", "sequence_number", ")", "_validate_not_none", "(", "'lock_token'", ",", "lock_token", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'PUT'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "topic_name", ")", "+", "'/subscriptions/'", "+", "str", "(", "subscription_name", ")", "+", "'/messages/'", "+", "_str", "(", "sequence_number", ")", "+", "'/'", "+", "_str", "(", "lock_token", ")", "+", "''", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "self", ".", "_perform_request", "(", "request", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.send_queue_message_batch
Sends a batch of messages into the specified queue. The limit to the number of messages which may be present in the topic is governed by the message size the MaxTopicSizeInMegaBytes. If this message will cause the queue to exceed its quota, a quota exceeded error is returned and the message will be rejected. queue_name: Name of the queue. messages: List of message objects containing message body and properties.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def send_queue_message_batch(self, queue_name, messages=None): ''' Sends a batch of messages into the specified queue. The limit to the number of messages which may be present in the topic is governed by the message size the MaxTopicSizeInMegaBytes. If this message will cause the queue to exceed its quota, a quota exceeded error is returned and the message will be rejected. queue_name: Name of the queue. messages: List of message objects containing message body and properties. ''' _validate_not_none('queue_name', queue_name) _validate_not_none('messages', messages) request = HTTPRequest() request.method = 'POST' request.host = self._get_host() request.path = '/' + _str(queue_name) + '/messages' request.headers.append(('Content-Type', 'application/vnd.microsoft.servicebus.json')) request.body = _get_request_body(json.dumps([m.as_batch_body() for m in messages])) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) self._perform_request(request)
def send_queue_message_batch(self, queue_name, messages=None): ''' Sends a batch of messages into the specified queue. The limit to the number of messages which may be present in the topic is governed by the message size the MaxTopicSizeInMegaBytes. If this message will cause the queue to exceed its quota, a quota exceeded error is returned and the message will be rejected. queue_name: Name of the queue. messages: List of message objects containing message body and properties. ''' _validate_not_none('queue_name', queue_name) _validate_not_none('messages', messages) request = HTTPRequest() request.method = 'POST' request.host = self._get_host() request.path = '/' + _str(queue_name) + '/messages' request.headers.append(('Content-Type', 'application/vnd.microsoft.servicebus.json')) request.body = _get_request_body(json.dumps([m.as_batch_body() for m in messages])) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) self._perform_request(request)
[ "Sends", "a", "batch", "of", "messages", "into", "the", "specified", "queue", ".", "The", "limit", "to", "the", "number", "of", "messages", "which", "may", "be", "present", "in", "the", "topic", "is", "governed", "by", "the", "message", "size", "the", "MaxTopicSizeInMegaBytes", ".", "If", "this", "message", "will", "cause", "the", "queue", "to", "exceed", "its", "quota", "a", "quota", "exceeded", "error", "is", "returned", "and", "the", "message", "will", "be", "rejected", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L888-L911
[ "def", "send_queue_message_batch", "(", "self", ",", "queue_name", ",", "messages", "=", "None", ")", ":", "_validate_not_none", "(", "'queue_name'", ",", "queue_name", ")", "_validate_not_none", "(", "'messages'", ",", "messages", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'POST'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "queue_name", ")", "+", "'/messages'", "request", ".", "headers", ".", "append", "(", "(", "'Content-Type'", ",", "'application/vnd.microsoft.servicebus.json'", ")", ")", "request", ".", "body", "=", "_get_request_body", "(", "json", ".", "dumps", "(", "[", "m", ".", "as_batch_body", "(", ")", "for", "m", "in", "messages", "]", ")", ")", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "self", ".", "_perform_request", "(", "request", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.peek_lock_queue_message
Automically retrieves and locks a message from a queue for processing. The message is guaranteed not to be delivered to other receivers (on the same subscription only) during the lock duration period specified in the queue description. Once the lock expires, the message will be available to other receivers. In order to complete processing of the message, the receiver should issue a delete command with the lock ID received from this operation. To abandon processing of the message and unlock it for other receivers, an Unlock Message command should be issued, or the lock duration period can expire. queue_name: Name of the queue. timeout: Optional. The timeout parameter is expressed in seconds.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def peek_lock_queue_message(self, queue_name, timeout='60'): ''' Automically retrieves and locks a message from a queue for processing. The message is guaranteed not to be delivered to other receivers (on the same subscription only) during the lock duration period specified in the queue description. Once the lock expires, the message will be available to other receivers. In order to complete processing of the message, the receiver should issue a delete command with the lock ID received from this operation. To abandon processing of the message and unlock it for other receivers, an Unlock Message command should be issued, or the lock duration period can expire. queue_name: Name of the queue. timeout: Optional. The timeout parameter is expressed in seconds. ''' _validate_not_none('queue_name', queue_name) request = HTTPRequest() request.method = 'POST' request.host = self._get_host() request.path = '/' + _str(queue_name) + '/messages/head' request.query = [('timeout', _int_or_none(timeout))] request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _create_message(response, self)
def peek_lock_queue_message(self, queue_name, timeout='60'): ''' Automically retrieves and locks a message from a queue for processing. The message is guaranteed not to be delivered to other receivers (on the same subscription only) during the lock duration period specified in the queue description. Once the lock expires, the message will be available to other receivers. In order to complete processing of the message, the receiver should issue a delete command with the lock ID received from this operation. To abandon processing of the message and unlock it for other receivers, an Unlock Message command should be issued, or the lock duration period can expire. queue_name: Name of the queue. timeout: Optional. The timeout parameter is expressed in seconds. ''' _validate_not_none('queue_name', queue_name) request = HTTPRequest() request.method = 'POST' request.host = self._get_host() request.path = '/' + _str(queue_name) + '/messages/head' request.query = [('timeout', _int_or_none(timeout))] request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _create_message(response, self)
[ "Automically", "retrieves", "and", "locks", "a", "message", "from", "a", "queue", "for", "processing", ".", "The", "message", "is", "guaranteed", "not", "to", "be", "delivered", "to", "other", "receivers", "(", "on", "the", "same", "subscription", "only", ")", "during", "the", "lock", "duration", "period", "specified", "in", "the", "queue", "description", ".", "Once", "the", "lock", "expires", "the", "message", "will", "be", "available", "to", "other", "receivers", ".", "In", "order", "to", "complete", "processing", "of", "the", "message", "the", "receiver", "should", "issue", "a", "delete", "command", "with", "the", "lock", "ID", "received", "from", "this", "operation", ".", "To", "abandon", "processing", "of", "the", "message", "and", "unlock", "it", "for", "other", "receivers", "an", "Unlock", "Message", "command", "should", "be", "issued", "or", "the", "lock", "duration", "period", "can", "expire", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L913-L940
[ "def", "peek_lock_queue_message", "(", "self", ",", "queue_name", ",", "timeout", "=", "'60'", ")", ":", "_validate_not_none", "(", "'queue_name'", ",", "queue_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'POST'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "queue_name", ")", "+", "'/messages/head'", "request", ".", "query", "=", "[", "(", "'timeout'", ",", "_int_or_none", "(", "timeout", ")", ")", "]", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "response", "=", "self", ".", "_perform_request", "(", "request", ")", "return", "_create_message", "(", "response", ",", "self", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.unlock_queue_message
Unlocks a message for processing by other receivers on a given queue. This operation deletes the lock object, causing the message to be unlocked. A message must have first been locked by a receiver before this operation is called. queue_name: Name of the queue. sequence_number: The sequence number of the message to be unlocked as returned in BrokerProperties['SequenceNumber'] by the Peek Message operation. lock_token: The ID of the lock as returned by the Peek Message operation in BrokerProperties['LockToken']
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def unlock_queue_message(self, queue_name, sequence_number, lock_token): ''' Unlocks a message for processing by other receivers on a given queue. This operation deletes the lock object, causing the message to be unlocked. A message must have first been locked by a receiver before this operation is called. queue_name: Name of the queue. sequence_number: The sequence number of the message to be unlocked as returned in BrokerProperties['SequenceNumber'] by the Peek Message operation. lock_token: The ID of the lock as returned by the Peek Message operation in BrokerProperties['LockToken'] ''' _validate_not_none('queue_name', queue_name) _validate_not_none('sequence_number', sequence_number) _validate_not_none('lock_token', lock_token) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(queue_name) + \ '/messages/' + _str(sequence_number) + \ '/' + _str(lock_token) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) self._perform_request(request)
def unlock_queue_message(self, queue_name, sequence_number, lock_token): ''' Unlocks a message for processing by other receivers on a given queue. This operation deletes the lock object, causing the message to be unlocked. A message must have first been locked by a receiver before this operation is called. queue_name: Name of the queue. sequence_number: The sequence number of the message to be unlocked as returned in BrokerProperties['SequenceNumber'] by the Peek Message operation. lock_token: The ID of the lock as returned by the Peek Message operation in BrokerProperties['LockToken'] ''' _validate_not_none('queue_name', queue_name) _validate_not_none('sequence_number', sequence_number) _validate_not_none('lock_token', lock_token) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(queue_name) + \ '/messages/' + _str(sequence_number) + \ '/' + _str(lock_token) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) self._perform_request(request)
[ "Unlocks", "a", "message", "for", "processing", "by", "other", "receivers", "on", "a", "given", "queue", ".", "This", "operation", "deletes", "the", "lock", "object", "causing", "the", "message", "to", "be", "unlocked", ".", "A", "message", "must", "have", "first", "been", "locked", "by", "a", "receiver", "before", "this", "operation", "is", "called", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L942-L969
[ "def", "unlock_queue_message", "(", "self", ",", "queue_name", ",", "sequence_number", ",", "lock_token", ")", ":", "_validate_not_none", "(", "'queue_name'", ",", "queue_name", ")", "_validate_not_none", "(", "'sequence_number'", ",", "sequence_number", ")", "_validate_not_none", "(", "'lock_token'", ",", "lock_token", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'PUT'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "queue_name", ")", "+", "'/messages/'", "+", "_str", "(", "sequence_number", ")", "+", "'/'", "+", "_str", "(", "lock_token", ")", "+", "''", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "self", ".", "_perform_request", "(", "request", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.receive_queue_message
Receive a message from a queue for processing. queue_name: Name of the queue. peek_lock: Optional. True to retrieve and lock the message. False to read and delete the message. Default is True (lock). timeout: Optional. The timeout parameter is expressed in seconds.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def receive_queue_message(self, queue_name, peek_lock=True, timeout=60): ''' Receive a message from a queue for processing. queue_name: Name of the queue. peek_lock: Optional. True to retrieve and lock the message. False to read and delete the message. Default is True (lock). timeout: Optional. The timeout parameter is expressed in seconds. ''' if peek_lock: return self.peek_lock_queue_message(queue_name, timeout) return self.read_delete_queue_message(queue_name, timeout)
def receive_queue_message(self, queue_name, peek_lock=True, timeout=60): ''' Receive a message from a queue for processing. queue_name: Name of the queue. peek_lock: Optional. True to retrieve and lock the message. False to read and delete the message. Default is True (lock). timeout: Optional. The timeout parameter is expressed in seconds. ''' if peek_lock: return self.peek_lock_queue_message(queue_name, timeout) return self.read_delete_queue_message(queue_name, timeout)
[ "Receive", "a", "message", "from", "a", "queue", "for", "processing", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L1052-L1066
[ "def", "receive_queue_message", "(", "self", ",", "queue_name", ",", "peek_lock", "=", "True", ",", "timeout", "=", "60", ")", ":", "if", "peek_lock", ":", "return", "self", ".", "peek_lock_queue_message", "(", "queue_name", ",", "timeout", ")", "return", "self", ".", "read_delete_queue_message", "(", "queue_name", ",", "timeout", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.receive_subscription_message
Receive a message from a subscription for processing. topic_name: Name of the topic. subscription_name: Name of the subscription. peek_lock: Optional. True to retrieve and lock the message. False to read and delete the message. Default is True (lock). timeout: Optional. The timeout parameter is expressed in seconds.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def receive_subscription_message(self, topic_name, subscription_name, peek_lock=True, timeout=60): ''' Receive a message from a subscription for processing. topic_name: Name of the topic. subscription_name: Name of the subscription. peek_lock: Optional. True to retrieve and lock the message. False to read and delete the message. Default is True (lock). timeout: Optional. The timeout parameter is expressed in seconds. ''' if peek_lock: return self.peek_lock_subscription_message(topic_name, subscription_name, timeout) return self.read_delete_subscription_message(topic_name, subscription_name, timeout)
def receive_subscription_message(self, topic_name, subscription_name, peek_lock=True, timeout=60): ''' Receive a message from a subscription for processing. topic_name: Name of the topic. subscription_name: Name of the subscription. peek_lock: Optional. True to retrieve and lock the message. False to read and delete the message. Default is True (lock). timeout: Optional. The timeout parameter is expressed in seconds. ''' if peek_lock: return self.peek_lock_subscription_message(topic_name, subscription_name, timeout) return self.read_delete_subscription_message(topic_name, subscription_name, timeout)
[ "Receive", "a", "message", "from", "a", "subscription", "for", "processing", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L1068-L1089
[ "def", "receive_subscription_message", "(", "self", ",", "topic_name", ",", "subscription_name", ",", "peek_lock", "=", "True", ",", "timeout", "=", "60", ")", ":", "if", "peek_lock", ":", "return", "self", ".", "peek_lock_subscription_message", "(", "topic_name", ",", "subscription_name", ",", "timeout", ")", "return", "self", ".", "read_delete_subscription_message", "(", "topic_name", ",", "subscription_name", ",", "timeout", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.create_event_hub
Creates a new Event Hub. hub_name: Name of event hub. hub: Optional. Event hub properties. Instance of EventHub class. hub.message_retention_in_days: Number of days to retain the events for this Event Hub. hub.status: Status of the Event Hub (enabled or disabled). hub.user_metadata: User metadata. hub.partition_count: Number of shards on the Event Hub. fail_on_exist: Specify whether to throw an exception when the event hub exists.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def create_event_hub(self, hub_name, hub=None, fail_on_exist=False): ''' Creates a new Event Hub. hub_name: Name of event hub. hub: Optional. Event hub properties. Instance of EventHub class. hub.message_retention_in_days: Number of days to retain the events for this Event Hub. hub.status: Status of the Event Hub (enabled or disabled). hub.user_metadata: User metadata. hub.partition_count: Number of shards on the Event Hub. fail_on_exist: Specify whether to throw an exception when the event hub exists. ''' _validate_not_none('hub_name', hub_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(hub_name) + '?api-version=2014-01' request.body = _get_request_body(_convert_event_hub_to_xml(hub)) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) if not fail_on_exist: try: self._perform_request(request) return True except AzureHttpError as ex: _dont_fail_on_exist(ex) return False else: self._perform_request(request) return True
def create_event_hub(self, hub_name, hub=None, fail_on_exist=False): ''' Creates a new Event Hub. hub_name: Name of event hub. hub: Optional. Event hub properties. Instance of EventHub class. hub.message_retention_in_days: Number of days to retain the events for this Event Hub. hub.status: Status of the Event Hub (enabled or disabled). hub.user_metadata: User metadata. hub.partition_count: Number of shards on the Event Hub. fail_on_exist: Specify whether to throw an exception when the event hub exists. ''' _validate_not_none('hub_name', hub_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(hub_name) + '?api-version=2014-01' request.body = _get_request_body(_convert_event_hub_to_xml(hub)) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) if not fail_on_exist: try: self._perform_request(request) return True except AzureHttpError as ex: _dont_fail_on_exist(ex) return False else: self._perform_request(request) return True
[ "Creates", "a", "new", "Event", "Hub", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L1091-L1127
[ "def", "create_event_hub", "(", "self", ",", "hub_name", ",", "hub", "=", "None", ",", "fail_on_exist", "=", "False", ")", ":", "_validate_not_none", "(", "'hub_name'", ",", "hub_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'PUT'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "hub_name", ")", "+", "'?api-version=2014-01'", "request", ".", "body", "=", "_get_request_body", "(", "_convert_event_hub_to_xml", "(", "hub", ")", ")", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "if", "not", "fail_on_exist", ":", "try", ":", "self", ".", "_perform_request", "(", "request", ")", "return", "True", "except", "AzureHttpError", "as", "ex", ":", "_dont_fail_on_exist", "(", "ex", ")", "return", "False", "else", ":", "self", ".", "_perform_request", "(", "request", ")", "return", "True" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.update_event_hub
Updates an Event Hub. hub_name: Name of event hub. hub: Optional. Event hub properties. Instance of EventHub class. hub.message_retention_in_days: Number of days to retain the events for this Event Hub.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def update_event_hub(self, hub_name, hub=None): ''' Updates an Event Hub. hub_name: Name of event hub. hub: Optional. Event hub properties. Instance of EventHub class. hub.message_retention_in_days: Number of days to retain the events for this Event Hub. ''' _validate_not_none('hub_name', hub_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(hub_name) + '?api-version=2014-01' request.body = _get_request_body(_convert_event_hub_to_xml(hub)) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers.append(('If-Match', '*')) request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _convert_response_to_event_hub(response)
def update_event_hub(self, hub_name, hub=None): ''' Updates an Event Hub. hub_name: Name of event hub. hub: Optional. Event hub properties. Instance of EventHub class. hub.message_retention_in_days: Number of days to retain the events for this Event Hub. ''' _validate_not_none('hub_name', hub_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = '/' + _str(hub_name) + '?api-version=2014-01' request.body = _get_request_body(_convert_event_hub_to_xml(hub)) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers.append(('If-Match', '*')) request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _convert_response_to_event_hub(response)
[ "Updates", "an", "Event", "Hub", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L1129-L1151
[ "def", "update_event_hub", "(", "self", ",", "hub_name", ",", "hub", "=", "None", ")", ":", "_validate_not_none", "(", "'hub_name'", ",", "hub_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'PUT'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "hub_name", ")", "+", "'?api-version=2014-01'", "request", ".", "body", "=", "_get_request_body", "(", "_convert_event_hub_to_xml", "(", "hub", ")", ")", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", ".", "append", "(", "(", "'If-Match'", ",", "'*'", ")", ")", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "response", "=", "self", ".", "_perform_request", "(", "request", ")", "return", "_convert_response_to_event_hub", "(", "response", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.get_event_hub
Retrieves an existing event hub. hub_name: Name of the event hub.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def get_event_hub(self, hub_name): ''' Retrieves an existing event hub. hub_name: Name of the event hub. ''' _validate_not_none('hub_name', hub_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + _str(hub_name) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _convert_response_to_event_hub(response)
def get_event_hub(self, hub_name): ''' Retrieves an existing event hub. hub_name: Name of the event hub. ''' _validate_not_none('hub_name', hub_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = '/' + _str(hub_name) + '' request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) response = self._perform_request(request) return _convert_response_to_event_hub(response)
[ "Retrieves", "an", "existing", "event", "hub", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L1181-L1197
[ "def", "get_event_hub", "(", "self", ",", "hub_name", ")", ":", "_validate_not_none", "(", "'hub_name'", ",", "hub_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'GET'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "request", ".", "path", "=", "'/'", "+", "_str", "(", "hub_name", ")", "+", "''", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "response", "=", "self", ".", "_perform_request", "(", "request", ")", "return", "_convert_response_to_event_hub", "(", "response", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService.send_event
Sends a new message event to an Event Hub.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def send_event(self, hub_name, message, device_id=None, broker_properties=None): ''' Sends a new message event to an Event Hub. ''' _validate_not_none('hub_name', hub_name) request = HTTPRequest() request.method = 'POST' request.host = self._get_host() if device_id: request.path = '/{0}/publishers/{1}/messages?api-version=2014-01'.format(hub_name, device_id) else: request.path = '/{0}/messages?api-version=2014-01'.format(hub_name) if broker_properties: request.headers.append( ('BrokerProperties', str(broker_properties))) request.body = _get_request_body(message) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) self._perform_request(request)
def send_event(self, hub_name, message, device_id=None, broker_properties=None): ''' Sends a new message event to an Event Hub. ''' _validate_not_none('hub_name', hub_name) request = HTTPRequest() request.method = 'POST' request.host = self._get_host() if device_id: request.path = '/{0}/publishers/{1}/messages?api-version=2014-01'.format(hub_name, device_id) else: request.path = '/{0}/messages?api-version=2014-01'.format(hub_name) if broker_properties: request.headers.append( ('BrokerProperties', str(broker_properties))) request.body = _get_request_body(message) request.path, request.query = self._httpclient._update_request_uri_query(request) # pylint: disable=protected-access request.headers = self._update_service_bus_header(request) self._perform_request(request)
[ "Sends", "a", "new", "message", "event", "to", "an", "Event", "Hub", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L1199-L1218
[ "def", "send_event", "(", "self", ",", "hub_name", ",", "message", ",", "device_id", "=", "None", ",", "broker_properties", "=", "None", ")", ":", "_validate_not_none", "(", "'hub_name'", ",", "hub_name", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'POST'", "request", ".", "host", "=", "self", ".", "_get_host", "(", ")", "if", "device_id", ":", "request", ".", "path", "=", "'/{0}/publishers/{1}/messages?api-version=2014-01'", ".", "format", "(", "hub_name", ",", "device_id", ")", "else", ":", "request", ".", "path", "=", "'/{0}/messages?api-version=2014-01'", ".", "format", "(", "hub_name", ")", "if", "broker_properties", ":", "request", ".", "headers", ".", "append", "(", "(", "'BrokerProperties'", ",", "str", "(", "broker_properties", ")", ")", ")", "request", ".", "body", "=", "_get_request_body", "(", "message", ")", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_httpclient", ".", "_update_request_uri_query", "(", "request", ")", "# pylint: disable=protected-access", "request", ".", "headers", "=", "self", ".", "_update_service_bus_header", "(", "request", ")", "self", ".", "_perform_request", "(", "request", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusService._update_service_bus_header
Add additional headers for Service Bus.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def _update_service_bus_header(self, request): ''' Add additional headers for Service Bus. ''' if request.method in ['PUT', 'POST', 'MERGE', 'DELETE']: request.headers.append(('Content-Length', str(len(request.body)))) # if it is not GET or HEAD request, must set content-type. if not request.method in ['GET', 'HEAD']: for name, _ in request.headers: if name.lower() == 'content-type': break else: request.headers.append( ('Content-Type', 'application/atom+xml;type=entry;charset=utf-8')) # Adds authorization header for authentication. self.authentication.sign_request(request, self._httpclient) return request.headers
def _update_service_bus_header(self, request): ''' Add additional headers for Service Bus. ''' if request.method in ['PUT', 'POST', 'MERGE', 'DELETE']: request.headers.append(('Content-Length', str(len(request.body)))) # if it is not GET or HEAD request, must set content-type. if not request.method in ['GET', 'HEAD']: for name, _ in request.headers: if name.lower() == 'content-type': break else: request.headers.append( ('Content-Type', 'application/atom+xml;type=entry;charset=utf-8')) # Adds authorization header for authentication. self.authentication.sign_request(request, self._httpclient) return request.headers
[ "Add", "additional", "headers", "for", "Service", "Bus", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L1231-L1250
[ "def", "_update_service_bus_header", "(", "self", ",", "request", ")", ":", "if", "request", ".", "method", "in", "[", "'PUT'", ",", "'POST'", ",", "'MERGE'", ",", "'DELETE'", "]", ":", "request", ".", "headers", ".", "append", "(", "(", "'Content-Length'", ",", "str", "(", "len", "(", "request", ".", "body", ")", ")", ")", ")", "# if it is not GET or HEAD request, must set content-type.", "if", "not", "request", ".", "method", "in", "[", "'GET'", ",", "'HEAD'", "]", ":", "for", "name", ",", "_", "in", "request", ".", "headers", ":", "if", "name", ".", "lower", "(", ")", "==", "'content-type'", ":", "break", "else", ":", "request", ".", "headers", ".", "append", "(", "(", "'Content-Type'", ",", "'application/atom+xml;type=entry;charset=utf-8'", ")", ")", "# Adds authorization header for authentication.", "self", ".", "authentication", ".", "sign_request", "(", "request", ",", "self", ".", "_httpclient", ")", "return", "request", ".", "headers" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusWrapTokenAuthentication._get_authorization
return the signed string with token.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def _get_authorization(self, request, httpclient): ''' return the signed string with token. ''' return 'WRAP access_token="' + \ self._get_token(request.host, request.path, httpclient) + '"'
def _get_authorization(self, request, httpclient): ''' return the signed string with token. ''' return 'WRAP access_token="' + \ self._get_token(request.host, request.path, httpclient) + '"'
[ "return", "the", "signed", "string", "with", "token", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L1267-L1270
[ "def", "_get_authorization", "(", "self", ",", "request", ",", "httpclient", ")", ":", "return", "'WRAP access_token=\"'", "+", "self", ".", "_get_token", "(", "request", ".", "host", ",", "request", ".", "path", ",", "httpclient", ")", "+", "'\"'" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusWrapTokenAuthentication._token_is_expired
Check if token expires or not.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def _token_is_expired(self, token): # pylint: disable=no-self-use ''' Check if token expires or not. ''' time_pos_begin = token.find('ExpiresOn=') + len('ExpiresOn=') time_pos_end = token.find('&', time_pos_begin) token_expire_time = int(token[time_pos_begin:time_pos_end]) time_now = time.mktime(time.localtime()) # Adding 30 seconds so the token wouldn't be expired when we send the # token to server. return (token_expire_time - time_now) < 30
def _token_is_expired(self, token): # pylint: disable=no-self-use ''' Check if token expires or not. ''' time_pos_begin = token.find('ExpiresOn=') + len('ExpiresOn=') time_pos_end = token.find('&', time_pos_begin) token_expire_time = int(token[time_pos_begin:time_pos_end]) time_now = time.mktime(time.localtime()) # Adding 30 seconds so the token wouldn't be expired when we send the # token to server. return (token_expire_time - time_now) < 30
[ "Check", "if", "token", "expires", "or", "not", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L1272-L1281
[ "def", "_token_is_expired", "(", "self", ",", "token", ")", ":", "# pylint: disable=no-self-use", "time_pos_begin", "=", "token", ".", "find", "(", "'ExpiresOn='", ")", "+", "len", "(", "'ExpiresOn='", ")", "time_pos_end", "=", "token", ".", "find", "(", "'&'", ",", "time_pos_begin", ")", "token_expire_time", "=", "int", "(", "token", "[", "time_pos_begin", ":", "time_pos_end", "]", ")", "time_now", "=", "time", ".", "mktime", "(", "time", ".", "localtime", "(", ")", ")", "# Adding 30 seconds so the token wouldn't be expired when we send the", "# token to server.", "return", "(", "token_expire_time", "-", "time_now", ")", "<", "30" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusWrapTokenAuthentication._get_token
Returns token for the request. host: the Service Bus service request. path: the Service Bus service request.
azure-servicebus/azure/servicebus/control_client/servicebusservice.py
def _get_token(self, host, path, httpclient): ''' Returns token for the request. host: the Service Bus service request. path: the Service Bus service request. ''' wrap_scope = 'http://' + host + path + self.issuer + self.account_key # Check whether has unexpired cache, return cached token if it is still # usable. if wrap_scope in _tokens: token = _tokens[wrap_scope] if not self._token_is_expired(token): return token # get token from accessconstrol server request = HTTPRequest() request.protocol_override = 'https' request.host = host.replace('.servicebus.', '-sb.accesscontrol.') request.method = 'POST' request.path = '/WRAPv0.9' request.body = ('wrap_name=' + url_quote(self.issuer) + '&wrap_password=' + url_quote(self.account_key) + '&wrap_scope=' + url_quote('http://' + host + path)).encode('utf-8') request.headers.append(('Content-Length', str(len(request.body)))) resp = httpclient.perform_request(request) token = resp.body.decode('utf-8-sig') token = url_unquote(token[token.find('=') + 1:token.rfind('&')]) _tokens[wrap_scope] = token return token
def _get_token(self, host, path, httpclient): ''' Returns token for the request. host: the Service Bus service request. path: the Service Bus service request. ''' wrap_scope = 'http://' + host + path + self.issuer + self.account_key # Check whether has unexpired cache, return cached token if it is still # usable. if wrap_scope in _tokens: token = _tokens[wrap_scope] if not self._token_is_expired(token): return token # get token from accessconstrol server request = HTTPRequest() request.protocol_override = 'https' request.host = host.replace('.servicebus.', '-sb.accesscontrol.') request.method = 'POST' request.path = '/WRAPv0.9' request.body = ('wrap_name=' + url_quote(self.issuer) + '&wrap_password=' + url_quote(self.account_key) + '&wrap_scope=' + url_quote('http://' + host + path)).encode('utf-8') request.headers.append(('Content-Length', str(len(request.body)))) resp = httpclient.perform_request(request) token = resp.body.decode('utf-8-sig') token = url_unquote(token[token.find('=') + 1:token.rfind('&')]) _tokens[wrap_scope] = token return token
[ "Returns", "token", "for", "the", "request", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L1283-L1318
[ "def", "_get_token", "(", "self", ",", "host", ",", "path", ",", "httpclient", ")", ":", "wrap_scope", "=", "'http://'", "+", "host", "+", "path", "+", "self", ".", "issuer", "+", "self", ".", "account_key", "# Check whether has unexpired cache, return cached token if it is still", "# usable.", "if", "wrap_scope", "in", "_tokens", ":", "token", "=", "_tokens", "[", "wrap_scope", "]", "if", "not", "self", ".", "_token_is_expired", "(", "token", ")", ":", "return", "token", "# get token from accessconstrol server", "request", "=", "HTTPRequest", "(", ")", "request", ".", "protocol_override", "=", "'https'", "request", ".", "host", "=", "host", ".", "replace", "(", "'.servicebus.'", ",", "'-sb.accesscontrol.'", ")", "request", ".", "method", "=", "'POST'", "request", ".", "path", "=", "'/WRAPv0.9'", "request", ".", "body", "=", "(", "'wrap_name='", "+", "url_quote", "(", "self", ".", "issuer", ")", "+", "'&wrap_password='", "+", "url_quote", "(", "self", ".", "account_key", ")", "+", "'&wrap_scope='", "+", "url_quote", "(", "'http://'", "+", "host", "+", "path", ")", ")", ".", "encode", "(", "'utf-8'", ")", "request", ".", "headers", ".", "append", "(", "(", "'Content-Length'", ",", "str", "(", "len", "(", "request", ".", "body", ")", ")", ")", ")", "resp", "=", "httpclient", ".", "perform_request", "(", "request", ")", "token", "=", "resp", ".", "body", ".", "decode", "(", "'utf-8-sig'", ")", "token", "=", "url_unquote", "(", "token", "[", "token", ".", "find", "(", "'='", ")", "+", "1", ":", "token", ".", "rfind", "(", "'&'", ")", "]", ")", "_tokens", "[", "wrap_scope", "]", "=", "token", "return", "token" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_HTTPClient._update_request_uri_query
pulls the query string out of the URI and moves it into the query portion of the request object. If there are already query parameters on the request the parameters in the URI will appear after the existing parameters
azure-servicemanagement-legacy/azure/servicemanagement/_http/httpclient.py
def _update_request_uri_query(self, request): '''pulls the query string out of the URI and moves it into the query portion of the request object. If there are already query parameters on the request the parameters in the URI will appear after the existing parameters''' if '?' in request.path: request.path, _, query_string = request.path.partition('?') if query_string: query_params = query_string.split('&') for query in query_params: if '=' in query: name, _, value = query.partition('=') request.query.append((name, value)) request.path = url_quote(request.path, '/()$=\',') # add encoded queries to request.path. if request.query: request.path += '?' for name, value in request.query: if value is not None: request.path += name + '=' + url_quote(value, '/()$=\',') + '&' request.path = request.path[:-1] return request.path, request.query
def _update_request_uri_query(self, request): '''pulls the query string out of the URI and moves it into the query portion of the request object. If there are already query parameters on the request the parameters in the URI will appear after the existing parameters''' if '?' in request.path: request.path, _, query_string = request.path.partition('?') if query_string: query_params = query_string.split('&') for query in query_params: if '=' in query: name, _, value = query.partition('=') request.query.append((name, value)) request.path = url_quote(request.path, '/()$=\',') # add encoded queries to request.path. if request.query: request.path += '?' for name, value in request.query: if value is not None: request.path += name + '=' + url_quote(value, '/()$=\',') + '&' request.path = request.path[:-1] return request.path, request.query
[ "pulls", "the", "query", "string", "out", "of", "the", "URI", "and", "moves", "it", "into", "the", "query", "portion", "of", "the", "request", "object", ".", "If", "there", "are", "already", "query", "parameters", "on", "the", "request", "the", "parameters", "in", "the", "URI", "will", "appear", "after", "the", "existing", "parameters" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/httpclient.py#L144-L169
[ "def", "_update_request_uri_query", "(", "self", ",", "request", ")", ":", "if", "'?'", "in", "request", ".", "path", ":", "request", ".", "path", ",", "_", ",", "query_string", "=", "request", ".", "path", ".", "partition", "(", "'?'", ")", "if", "query_string", ":", "query_params", "=", "query_string", ".", "split", "(", "'&'", ")", "for", "query", "in", "query_params", ":", "if", "'='", "in", "query", ":", "name", ",", "_", ",", "value", "=", "query", ".", "partition", "(", "'='", ")", "request", ".", "query", ".", "append", "(", "(", "name", ",", "value", ")", ")", "request", ".", "path", "=", "url_quote", "(", "request", ".", "path", ",", "'/()$=\\','", ")", "# add encoded queries to request.path.", "if", "request", ".", "query", ":", "request", ".", "path", "+=", "'?'", "for", "name", ",", "value", "in", "request", ".", "query", ":", "if", "value", "is", "not", "None", ":", "request", ".", "path", "+=", "name", "+", "'='", "+", "url_quote", "(", "value", ",", "'/()$=\\','", ")", "+", "'&'", "request", ".", "path", "=", "request", ".", "path", "[", ":", "-", "1", "]", "return", "request", ".", "path", ",", "request", ".", "query" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ManagedClustersOperations.reset_service_principal_profile
Reset Service Principal Profile of a managed cluster. Update the service principal Profile for a managed cluster. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param resource_name: The name of the managed cluster resource. :type resource_name: str :param client_id: The ID for the service principal. :type client_id: str :param secret: The secret password associated with the service principal in plain text. :type secret: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
azure-mgmt-containerservice/azure/mgmt/containerservice/v2018_08_01_preview/operations/managed_clusters_operations.py
def reset_service_principal_profile( self, resource_group_name, resource_name, client_id, secret=None, custom_headers=None, raw=False, polling=True, **operation_config): """Reset Service Principal Profile of a managed cluster. Update the service principal Profile for a managed cluster. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param resource_name: The name of the managed cluster resource. :type resource_name: str :param client_id: The ID for the service principal. :type client_id: str :param secret: The secret password associated with the service principal in plain text. :type secret: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._reset_service_principal_profile_initial( resource_group_name=resource_group_name, resource_name=resource_name, client_id=client_id, secret=secret, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def reset_service_principal_profile( self, resource_group_name, resource_name, client_id, secret=None, custom_headers=None, raw=False, polling=True, **operation_config): """Reset Service Principal Profile of a managed cluster. Update the service principal Profile for a managed cluster. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param resource_name: The name of the managed cluster resource. :type resource_name: str :param client_id: The ID for the service principal. :type client_id: str :param secret: The secret password associated with the service principal in plain text. :type secret: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._reset_service_principal_profile_initial( resource_group_name=resource_group_name, resource_name=resource_name, client_id=client_id, secret=secret, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Reset", "Service", "Principal", "Profile", "of", "a", "managed", "cluster", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-containerservice/azure/mgmt/containerservice/v2018_08_01_preview/operations/managed_clusters_operations.py#L850-L897
[ "def", "reset_service_principal_profile", "(", "self", ",", "resource_group_name", ",", "resource_name", ",", "client_id", ",", "secret", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_reset_service_principal_profile_initial", "(", "resource_group_name", "=", "resource_group_name", ",", "resource_name", "=", "resource_name", ",", "client_id", "=", "client_id", ",", "secret", "=", "secret", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "return", "client_raw_response", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
Message.delete
Deletes itself if find queue name or topic name and subscription name.
azure-servicebus/azure/servicebus/control_client/models.py
def delete(self): ''' Deletes itself if find queue name or topic name and subscription name. ''' if self._queue_name: self.service_bus_service.delete_queue_message( self._queue_name, self.broker_properties['SequenceNumber'], self.broker_properties['LockToken']) elif self._topic_name and self._subscription_name: self.service_bus_service.delete_subscription_message( self._topic_name, self._subscription_name, self.broker_properties['SequenceNumber'], self.broker_properties['LockToken']) else: raise AzureServiceBusPeekLockError(_ERROR_MESSAGE_NOT_PEEK_LOCKED_ON_DELETE)
def delete(self): ''' Deletes itself if find queue name or topic name and subscription name. ''' if self._queue_name: self.service_bus_service.delete_queue_message( self._queue_name, self.broker_properties['SequenceNumber'], self.broker_properties['LockToken']) elif self._topic_name and self._subscription_name: self.service_bus_service.delete_subscription_message( self._topic_name, self._subscription_name, self.broker_properties['SequenceNumber'], self.broker_properties['LockToken']) else: raise AzureServiceBusPeekLockError(_ERROR_MESSAGE_NOT_PEEK_LOCKED_ON_DELETE)
[ "Deletes", "itself", "if", "find", "queue", "name", "or", "topic", "name", "and", "subscription", "name", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/models.py#L185-L200
[ "def", "delete", "(", "self", ")", ":", "if", "self", ".", "_queue_name", ":", "self", ".", "service_bus_service", ".", "delete_queue_message", "(", "self", ".", "_queue_name", ",", "self", ".", "broker_properties", "[", "'SequenceNumber'", "]", ",", "self", ".", "broker_properties", "[", "'LockToken'", "]", ")", "elif", "self", ".", "_topic_name", "and", "self", ".", "_subscription_name", ":", "self", ".", "service_bus_service", ".", "delete_subscription_message", "(", "self", ".", "_topic_name", ",", "self", ".", "_subscription_name", ",", "self", ".", "broker_properties", "[", "'SequenceNumber'", "]", ",", "self", ".", "broker_properties", "[", "'LockToken'", "]", ")", "else", ":", "raise", "AzureServiceBusPeekLockError", "(", "_ERROR_MESSAGE_NOT_PEEK_LOCKED_ON_DELETE", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
Message.unlock
Unlocks itself if find queue name or topic name and subscription name.
azure-servicebus/azure/servicebus/control_client/models.py
def unlock(self): ''' Unlocks itself if find queue name or topic name and subscription name. ''' if self._queue_name: self.service_bus_service.unlock_queue_message( self._queue_name, self.broker_properties['SequenceNumber'], self.broker_properties['LockToken']) elif self._topic_name and self._subscription_name: self.service_bus_service.unlock_subscription_message( self._topic_name, self._subscription_name, self.broker_properties['SequenceNumber'], self.broker_properties['LockToken']) else: raise AzureServiceBusPeekLockError(_ERROR_MESSAGE_NOT_PEEK_LOCKED_ON_UNLOCK)
def unlock(self): ''' Unlocks itself if find queue name or topic name and subscription name. ''' if self._queue_name: self.service_bus_service.unlock_queue_message( self._queue_name, self.broker_properties['SequenceNumber'], self.broker_properties['LockToken']) elif self._topic_name and self._subscription_name: self.service_bus_service.unlock_subscription_message( self._topic_name, self._subscription_name, self.broker_properties['SequenceNumber'], self.broker_properties['LockToken']) else: raise AzureServiceBusPeekLockError(_ERROR_MESSAGE_NOT_PEEK_LOCKED_ON_UNLOCK)
[ "Unlocks", "itself", "if", "find", "queue", "name", "or", "topic", "name", "and", "subscription", "name", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/models.py#L202-L217
[ "def", "unlock", "(", "self", ")", ":", "if", "self", ".", "_queue_name", ":", "self", ".", "service_bus_service", ".", "unlock_queue_message", "(", "self", ".", "_queue_name", ",", "self", ".", "broker_properties", "[", "'SequenceNumber'", "]", ",", "self", ".", "broker_properties", "[", "'LockToken'", "]", ")", "elif", "self", ".", "_topic_name", "and", "self", ".", "_subscription_name", ":", "self", ".", "service_bus_service", ".", "unlock_subscription_message", "(", "self", ".", "_topic_name", ",", "self", ".", "_subscription_name", ",", "self", ".", "broker_properties", "[", "'SequenceNumber'", "]", ",", "self", ".", "broker_properties", "[", "'LockToken'", "]", ")", "else", ":", "raise", "AzureServiceBusPeekLockError", "(", "_ERROR_MESSAGE_NOT_PEEK_LOCKED_ON_UNLOCK", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
Message.renew_lock
Renew lock on itself if find queue name or topic name and subscription name.
azure-servicebus/azure/servicebus/control_client/models.py
def renew_lock(self): ''' Renew lock on itself if find queue name or topic name and subscription name. ''' if self._queue_name: self.service_bus_service.renew_lock_queue_message( self._queue_name, self.broker_properties['SequenceNumber'], self.broker_properties['LockToken']) elif self._topic_name and self._subscription_name: self.service_bus_service.renew_lock_subscription_message( self._topic_name, self._subscription_name, self.broker_properties['SequenceNumber'], self.broker_properties['LockToken']) else: raise AzureServiceBusPeekLockError(_ERROR_MESSAGE_NOT_PEEK_LOCKED_ON_RENEW_LOCK)
def renew_lock(self): ''' Renew lock on itself if find queue name or topic name and subscription name. ''' if self._queue_name: self.service_bus_service.renew_lock_queue_message( self._queue_name, self.broker_properties['SequenceNumber'], self.broker_properties['LockToken']) elif self._topic_name and self._subscription_name: self.service_bus_service.renew_lock_subscription_message( self._topic_name, self._subscription_name, self.broker_properties['SequenceNumber'], self.broker_properties['LockToken']) else: raise AzureServiceBusPeekLockError(_ERROR_MESSAGE_NOT_PEEK_LOCKED_ON_RENEW_LOCK)
[ "Renew", "lock", "on", "itself", "if", "find", "queue", "name", "or", "topic", "name", "and", "subscription", "name", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/models.py#L219-L234
[ "def", "renew_lock", "(", "self", ")", ":", "if", "self", ".", "_queue_name", ":", "self", ".", "service_bus_service", ".", "renew_lock_queue_message", "(", "self", ".", "_queue_name", ",", "self", ".", "broker_properties", "[", "'SequenceNumber'", "]", ",", "self", ".", "broker_properties", "[", "'LockToken'", "]", ")", "elif", "self", ".", "_topic_name", "and", "self", ".", "_subscription_name", ":", "self", ".", "service_bus_service", ".", "renew_lock_subscription_message", "(", "self", ".", "_topic_name", ",", "self", ".", "_subscription_name", ",", "self", ".", "broker_properties", "[", "'SequenceNumber'", "]", ",", "self", ".", "broker_properties", "[", "'LockToken'", "]", ")", "else", ":", "raise", "AzureServiceBusPeekLockError", "(", "_ERROR_MESSAGE_NOT_PEEK_LOCKED_ON_RENEW_LOCK", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
Message.add_headers
add addtional headers to request for message request.
azure-servicebus/azure/servicebus/control_client/models.py
def add_headers(self, request): ''' add addtional headers to request for message request.''' # Adds custom properties if self.custom_properties: for name, value in self.custom_properties.items(): request.headers.append((name, self._serialize_escaped_properties_value(value))) # Adds content-type request.headers.append(('Content-Type', self.type)) # Adds BrokerProperties if self.broker_properties: if hasattr(self.broker_properties, 'items'): broker_properties = {name: self._serialize_basic_properties_value(value) for name, value in self.broker_properties.items()} broker_properties = json.dumps(broker_properties) else: broker_properties = self.broker_properties request.headers.append( ('BrokerProperties', str(broker_properties))) return request.headers
def add_headers(self, request): ''' add addtional headers to request for message request.''' # Adds custom properties if self.custom_properties: for name, value in self.custom_properties.items(): request.headers.append((name, self._serialize_escaped_properties_value(value))) # Adds content-type request.headers.append(('Content-Type', self.type)) # Adds BrokerProperties if self.broker_properties: if hasattr(self.broker_properties, 'items'): broker_properties = {name: self._serialize_basic_properties_value(value) for name, value in self.broker_properties.items()} broker_properties = json.dumps(broker_properties) else: broker_properties = self.broker_properties request.headers.append( ('BrokerProperties', str(broker_properties))) return request.headers
[ "add", "addtional", "headers", "to", "request", "for", "message", "request", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/models.py#L256-L279
[ "def", "add_headers", "(", "self", ",", "request", ")", ":", "# Adds custom properties", "if", "self", ".", "custom_properties", ":", "for", "name", ",", "value", "in", "self", ".", "custom_properties", ".", "items", "(", ")", ":", "request", ".", "headers", ".", "append", "(", "(", "name", ",", "self", ".", "_serialize_escaped_properties_value", "(", "value", ")", ")", ")", "# Adds content-type", "request", ".", "headers", ".", "append", "(", "(", "'Content-Type'", ",", "self", ".", "type", ")", ")", "# Adds BrokerProperties", "if", "self", ".", "broker_properties", ":", "if", "hasattr", "(", "self", ".", "broker_properties", ",", "'items'", ")", ":", "broker_properties", "=", "{", "name", ":", "self", ".", "_serialize_basic_properties_value", "(", "value", ")", "for", "name", ",", "value", "in", "self", ".", "broker_properties", ".", "items", "(", ")", "}", "broker_properties", "=", "json", ".", "dumps", "(", "broker_properties", ")", "else", ":", "broker_properties", "=", "self", ".", "broker_properties", "request", ".", "headers", ".", "append", "(", "(", "'BrokerProperties'", ",", "str", "(", "broker_properties", ")", ")", ")", "return", "request", ".", "headers" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
Message.as_batch_body
return the current message as expected by batch body format
azure-servicebus/azure/servicebus/control_client/models.py
def as_batch_body(self): ''' return the current message as expected by batch body format''' if sys.version_info >= (3,) and isinstance(self.body, bytes): # It HAS to be string to be serialized in JSON body = self.body.decode('utf-8') else: # Python 2.7 people handle this themself body = self.body result = {'Body': body} # Adds custom properties if self.custom_properties: result['UserProperties'] = {name: self._serialize_basic_properties_value(value) for name, value in self.custom_properties.items()} # Adds BrokerProperties if self.broker_properties: result['BrokerProperties'] = {name: self._serialize_basic_properties_value(value) for name, value in self.broker_properties.items()} return result
def as_batch_body(self): ''' return the current message as expected by batch body format''' if sys.version_info >= (3,) and isinstance(self.body, bytes): # It HAS to be string to be serialized in JSON body = self.body.decode('utf-8') else: # Python 2.7 people handle this themself body = self.body result = {'Body': body} # Adds custom properties if self.custom_properties: result['UserProperties'] = {name: self._serialize_basic_properties_value(value) for name, value in self.custom_properties.items()} # Adds BrokerProperties if self.broker_properties: result['BrokerProperties'] = {name: self._serialize_basic_properties_value(value) for name, value in self.broker_properties.items()} return result
[ "return", "the", "current", "message", "as", "expected", "by", "batch", "body", "format" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/models.py#L281-L303
[ "def", "as_batch_body", "(", "self", ")", ":", "if", "sys", ".", "version_info", ">=", "(", "3", ",", ")", "and", "isinstance", "(", "self", ".", "body", ",", "bytes", ")", ":", "# It HAS to be string to be serialized in JSON", "body", "=", "self", ".", "body", ".", "decode", "(", "'utf-8'", ")", "else", ":", "# Python 2.7 people handle this themself", "body", "=", "self", ".", "body", "result", "=", "{", "'Body'", ":", "body", "}", "# Adds custom properties", "if", "self", ".", "custom_properties", ":", "result", "[", "'UserProperties'", "]", "=", "{", "name", ":", "self", ".", "_serialize_basic_properties_value", "(", "value", ")", "for", "name", ",", "value", "in", "self", ".", "custom_properties", ".", "items", "(", ")", "}", "# Adds BrokerProperties", "if", "self", ".", "broker_properties", ":", "result", "[", "'BrokerProperties'", "]", "=", "{", "name", ":", "self", ".", "_serialize_basic_properties_value", "(", "value", ")", "for", "name", ",", "value", "in", "self", ".", "broker_properties", ".", "items", "(", ")", "}", "return", "result" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceFabricClientAPIs.get_cluster_health
Gets the health of a Service Fabric cluster. Use EventsHealthStateFilter to filter the collection of health events reported on the cluster based on the health state. Similarly, use NodesHealthStateFilter and ApplicationsHealthStateFilter to filter the collection of nodes and applications returned based on their aggregated health state. :param nodes_health_state_filter: Allows filtering of the node health state objects returned in the result of cluster health query based on their health state. The possible values for this parameter include integer value of one of the following health states. Only nodes that match the filter are returned. All nodes are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values obtained using bitwise 'OR' operator. For example, if the provided value is 6 then health state of nodes with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type nodes_health_state_filter: int :param applications_health_state_filter: Allows filtering of the application health state objects returned in the result of cluster health query based on their health state. The possible values for this parameter include integer value obtained from members or bitwise operations on members of HealthStateFilter enumeration. Only applications that match the filter are returned. All applications are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values obtained using bitwise 'OR' operator. For example, if the provided value is 6 then health state of applications with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type applications_health_state_filter: int :param events_health_state_filter: Allows filtering the collection of HealthEvent objects returned based on health state. The possible values for this parameter include integer value of one of the following health states. Only events that match the filter are returned. All events are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values, obtained using the bitwise 'OR' operator. For example, If the provided value is 6 then all of the events with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type events_health_state_filter: int :param exclude_health_statistics: Indicates whether the health statistics should be returned as part of the query result. False by default. The statistics show the number of children entities in health state Ok, Warning, and Error. :type exclude_health_statistics: bool :param include_system_application_health_statistics: Indicates whether the health statistics should include the fabric:/System application health statistics. False by default. If IncludeSystemApplicationHealthStatistics is set to true, the health statistics include the entities that belong to the fabric:/System application. Otherwise, the query result includes health statistics only for user applications. The health statistics must be included in the query result for this parameter to be applied. :type include_system_application_health_statistics: bool :param timeout: The server timeout for performing the operation in seconds. This timeout specifies the time duration that the client is willing to wait for the requested operation to complete. The default value for this parameter is 60 seconds. :type timeout: long :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: ClusterHealth or ClientRawResponse if raw=true :rtype: ~azure.servicefabric.models.ClusterHealth or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>`
azure-servicefabric/azure/servicefabric/service_fabric_client_ap_is.py
def get_cluster_health( self, nodes_health_state_filter=0, applications_health_state_filter=0, events_health_state_filter=0, exclude_health_statistics=False, include_system_application_health_statistics=False, timeout=60, custom_headers=None, raw=False, **operation_config): """Gets the health of a Service Fabric cluster. Use EventsHealthStateFilter to filter the collection of health events reported on the cluster based on the health state. Similarly, use NodesHealthStateFilter and ApplicationsHealthStateFilter to filter the collection of nodes and applications returned based on their aggregated health state. :param nodes_health_state_filter: Allows filtering of the node health state objects returned in the result of cluster health query based on their health state. The possible values for this parameter include integer value of one of the following health states. Only nodes that match the filter are returned. All nodes are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values obtained using bitwise 'OR' operator. For example, if the provided value is 6 then health state of nodes with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type nodes_health_state_filter: int :param applications_health_state_filter: Allows filtering of the application health state objects returned in the result of cluster health query based on their health state. The possible values for this parameter include integer value obtained from members or bitwise operations on members of HealthStateFilter enumeration. Only applications that match the filter are returned. All applications are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values obtained using bitwise 'OR' operator. For example, if the provided value is 6 then health state of applications with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type applications_health_state_filter: int :param events_health_state_filter: Allows filtering the collection of HealthEvent objects returned based on health state. The possible values for this parameter include integer value of one of the following health states. Only events that match the filter are returned. All events are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values, obtained using the bitwise 'OR' operator. For example, If the provided value is 6 then all of the events with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type events_health_state_filter: int :param exclude_health_statistics: Indicates whether the health statistics should be returned as part of the query result. False by default. The statistics show the number of children entities in health state Ok, Warning, and Error. :type exclude_health_statistics: bool :param include_system_application_health_statistics: Indicates whether the health statistics should include the fabric:/System application health statistics. False by default. If IncludeSystemApplicationHealthStatistics is set to true, the health statistics include the entities that belong to the fabric:/System application. Otherwise, the query result includes health statistics only for user applications. The health statistics must be included in the query result for this parameter to be applied. :type include_system_application_health_statistics: bool :param timeout: The server timeout for performing the operation in seconds. This timeout specifies the time duration that the client is willing to wait for the requested operation to complete. The default value for this parameter is 60 seconds. :type timeout: long :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: ClusterHealth or ClientRawResponse if raw=true :rtype: ~azure.servicefabric.models.ClusterHealth or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>` """ api_version = "6.0" # Construct URL url = self.get_cluster_health.metadata['url'] # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if nodes_health_state_filter is not None: query_parameters['NodesHealthStateFilter'] = self._serialize.query("nodes_health_state_filter", nodes_health_state_filter, 'int') if applications_health_state_filter is not None: query_parameters['ApplicationsHealthStateFilter'] = self._serialize.query("applications_health_state_filter", applications_health_state_filter, 'int') if events_health_state_filter is not None: query_parameters['EventsHealthStateFilter'] = self._serialize.query("events_health_state_filter", events_health_state_filter, 'int') if exclude_health_statistics is not None: query_parameters['ExcludeHealthStatistics'] = self._serialize.query("exclude_health_statistics", exclude_health_statistics, 'bool') if include_system_application_health_statistics is not None: query_parameters['IncludeSystemApplicationHealthStatistics'] = self._serialize.query("include_system_application_health_statistics", include_system_application_health_statistics, 'bool') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'long', maximum=4294967295, minimum=1) # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.FabricErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ClusterHealth', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def get_cluster_health( self, nodes_health_state_filter=0, applications_health_state_filter=0, events_health_state_filter=0, exclude_health_statistics=False, include_system_application_health_statistics=False, timeout=60, custom_headers=None, raw=False, **operation_config): """Gets the health of a Service Fabric cluster. Use EventsHealthStateFilter to filter the collection of health events reported on the cluster based on the health state. Similarly, use NodesHealthStateFilter and ApplicationsHealthStateFilter to filter the collection of nodes and applications returned based on their aggregated health state. :param nodes_health_state_filter: Allows filtering of the node health state objects returned in the result of cluster health query based on their health state. The possible values for this parameter include integer value of one of the following health states. Only nodes that match the filter are returned. All nodes are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values obtained using bitwise 'OR' operator. For example, if the provided value is 6 then health state of nodes with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type nodes_health_state_filter: int :param applications_health_state_filter: Allows filtering of the application health state objects returned in the result of cluster health query based on their health state. The possible values for this parameter include integer value obtained from members or bitwise operations on members of HealthStateFilter enumeration. Only applications that match the filter are returned. All applications are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values obtained using bitwise 'OR' operator. For example, if the provided value is 6 then health state of applications with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type applications_health_state_filter: int :param events_health_state_filter: Allows filtering the collection of HealthEvent objects returned based on health state. The possible values for this parameter include integer value of one of the following health states. Only events that match the filter are returned. All events are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values, obtained using the bitwise 'OR' operator. For example, If the provided value is 6 then all of the events with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type events_health_state_filter: int :param exclude_health_statistics: Indicates whether the health statistics should be returned as part of the query result. False by default. The statistics show the number of children entities in health state Ok, Warning, and Error. :type exclude_health_statistics: bool :param include_system_application_health_statistics: Indicates whether the health statistics should include the fabric:/System application health statistics. False by default. If IncludeSystemApplicationHealthStatistics is set to true, the health statistics include the entities that belong to the fabric:/System application. Otherwise, the query result includes health statistics only for user applications. The health statistics must be included in the query result for this parameter to be applied. :type include_system_application_health_statistics: bool :param timeout: The server timeout for performing the operation in seconds. This timeout specifies the time duration that the client is willing to wait for the requested operation to complete. The default value for this parameter is 60 seconds. :type timeout: long :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: ClusterHealth or ClientRawResponse if raw=true :rtype: ~azure.servicefabric.models.ClusterHealth or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>` """ api_version = "6.0" # Construct URL url = self.get_cluster_health.metadata['url'] # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if nodes_health_state_filter is not None: query_parameters['NodesHealthStateFilter'] = self._serialize.query("nodes_health_state_filter", nodes_health_state_filter, 'int') if applications_health_state_filter is not None: query_parameters['ApplicationsHealthStateFilter'] = self._serialize.query("applications_health_state_filter", applications_health_state_filter, 'int') if events_health_state_filter is not None: query_parameters['EventsHealthStateFilter'] = self._serialize.query("events_health_state_filter", events_health_state_filter, 'int') if exclude_health_statistics is not None: query_parameters['ExcludeHealthStatistics'] = self._serialize.query("exclude_health_statistics", exclude_health_statistics, 'bool') if include_system_application_health_statistics is not None: query_parameters['IncludeSystemApplicationHealthStatistics'] = self._serialize.query("include_system_application_health_statistics", include_system_application_health_statistics, 'bool') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'long', maximum=4294967295, minimum=1) # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.FabricErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ClusterHealth', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Gets", "the", "health", "of", "a", "Service", "Fabric", "cluster", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicefabric/azure/servicefabric/service_fabric_client_ap_is.py#L184-L346
[ "def", "get_cluster_health", "(", "self", ",", "nodes_health_state_filter", "=", "0", ",", "applications_health_state_filter", "=", "0", ",", "events_health_state_filter", "=", "0", ",", "exclude_health_statistics", "=", "False", ",", "include_system_application_health_statistics", "=", "False", ",", "timeout", "=", "60", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "api_version", "=", "\"6.0\"", "# Construct URL", "url", "=", "self", ".", "get_cluster_health", ".", "metadata", "[", "'url'", "]", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"api_version\"", ",", "api_version", ",", "'str'", ")", "if", "nodes_health_state_filter", "is", "not", "None", ":", "query_parameters", "[", "'NodesHealthStateFilter'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"nodes_health_state_filter\"", ",", "nodes_health_state_filter", ",", "'int'", ")", "if", "applications_health_state_filter", "is", "not", "None", ":", "query_parameters", "[", "'ApplicationsHealthStateFilter'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"applications_health_state_filter\"", ",", "applications_health_state_filter", ",", "'int'", ")", "if", "events_health_state_filter", "is", "not", "None", ":", "query_parameters", "[", "'EventsHealthStateFilter'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"events_health_state_filter\"", ",", "events_health_state_filter", ",", "'int'", ")", "if", "exclude_health_statistics", "is", "not", "None", ":", "query_parameters", "[", "'ExcludeHealthStatistics'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"exclude_health_statistics\"", ",", "exclude_health_statistics", ",", "'bool'", ")", "if", "include_system_application_health_statistics", "is", "not", "None", ":", "query_parameters", "[", "'IncludeSystemApplicationHealthStatistics'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"include_system_application_health_statistics\"", ",", "include_system_application_health_statistics", ",", "'bool'", ")", "if", "timeout", "is", "not", "None", ":", "query_parameters", "[", "'timeout'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"timeout\"", ",", "timeout", ",", "'long'", ",", "maximum", "=", "4294967295", ",", "minimum", "=", "1", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "get", "(", "url", ",", "query_parameters", ",", "header_parameters", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "FabricErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'ClusterHealth'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceFabricClientAPIs.get_cluster_health_using_policy
Gets the health of a Service Fabric cluster using the specified policy. Use EventsHealthStateFilter to filter the collection of health events reported on the cluster based on the health state. Similarly, use NodesHealthStateFilter and ApplicationsHealthStateFilter to filter the collection of nodes and applications returned based on their aggregated health state. Use ClusterHealthPolicies to override the health policies used to evaluate the health. :param nodes_health_state_filter: Allows filtering of the node health state objects returned in the result of cluster health query based on their health state. The possible values for this parameter include integer value of one of the following health states. Only nodes that match the filter are returned. All nodes are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values obtained using bitwise 'OR' operator. For example, if the provided value is 6 then health state of nodes with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type nodes_health_state_filter: int :param applications_health_state_filter: Allows filtering of the application health state objects returned in the result of cluster health query based on their health state. The possible values for this parameter include integer value obtained from members or bitwise operations on members of HealthStateFilter enumeration. Only applications that match the filter are returned. All applications are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values obtained using bitwise 'OR' operator. For example, if the provided value is 6 then health state of applications with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type applications_health_state_filter: int :param events_health_state_filter: Allows filtering the collection of HealthEvent objects returned based on health state. The possible values for this parameter include integer value of one of the following health states. Only events that match the filter are returned. All events are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values, obtained using the bitwise 'OR' operator. For example, If the provided value is 6 then all of the events with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type events_health_state_filter: int :param exclude_health_statistics: Indicates whether the health statistics should be returned as part of the query result. False by default. The statistics show the number of children entities in health state Ok, Warning, and Error. :type exclude_health_statistics: bool :param include_system_application_health_statistics: Indicates whether the health statistics should include the fabric:/System application health statistics. False by default. If IncludeSystemApplicationHealthStatistics is set to true, the health statistics include the entities that belong to the fabric:/System application. Otherwise, the query result includes health statistics only for user applications. The health statistics must be included in the query result for this parameter to be applied. :type include_system_application_health_statistics: bool :param timeout: The server timeout for performing the operation in seconds. This timeout specifies the time duration that the client is willing to wait for the requested operation to complete. The default value for this parameter is 60 seconds. :type timeout: long :param application_health_policy_map: Defines a map that contains specific application health policies for different applications. Each entry specifies as key the application name and as value an ApplicationHealthPolicy used to evaluate the application health. If an application is not specified in the map, the application health evaluation uses the ApplicationHealthPolicy found in its application manifest or the default application health policy (if no health policy is defined in the manifest). The map is empty by default. :type application_health_policy_map: list[~azure.servicefabric.models.ApplicationHealthPolicyMapItem] :param cluster_health_policy: Defines a health policy used to evaluate the health of the cluster or of a cluster node. :type cluster_health_policy: ~azure.servicefabric.models.ClusterHealthPolicy :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: ClusterHealth or ClientRawResponse if raw=true :rtype: ~azure.servicefabric.models.ClusterHealth or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>`
azure-servicefabric/azure/servicefabric/service_fabric_client_ap_is.py
def get_cluster_health_using_policy( self, nodes_health_state_filter=0, applications_health_state_filter=0, events_health_state_filter=0, exclude_health_statistics=False, include_system_application_health_statistics=False, timeout=60, application_health_policy_map=None, cluster_health_policy=None, custom_headers=None, raw=False, **operation_config): """Gets the health of a Service Fabric cluster using the specified policy. Use EventsHealthStateFilter to filter the collection of health events reported on the cluster based on the health state. Similarly, use NodesHealthStateFilter and ApplicationsHealthStateFilter to filter the collection of nodes and applications returned based on their aggregated health state. Use ClusterHealthPolicies to override the health policies used to evaluate the health. :param nodes_health_state_filter: Allows filtering of the node health state objects returned in the result of cluster health query based on their health state. The possible values for this parameter include integer value of one of the following health states. Only nodes that match the filter are returned. All nodes are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values obtained using bitwise 'OR' operator. For example, if the provided value is 6 then health state of nodes with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type nodes_health_state_filter: int :param applications_health_state_filter: Allows filtering of the application health state objects returned in the result of cluster health query based on their health state. The possible values for this parameter include integer value obtained from members or bitwise operations on members of HealthStateFilter enumeration. Only applications that match the filter are returned. All applications are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values obtained using bitwise 'OR' operator. For example, if the provided value is 6 then health state of applications with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type applications_health_state_filter: int :param events_health_state_filter: Allows filtering the collection of HealthEvent objects returned based on health state. The possible values for this parameter include integer value of one of the following health states. Only events that match the filter are returned. All events are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values, obtained using the bitwise 'OR' operator. For example, If the provided value is 6 then all of the events with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type events_health_state_filter: int :param exclude_health_statistics: Indicates whether the health statistics should be returned as part of the query result. False by default. The statistics show the number of children entities in health state Ok, Warning, and Error. :type exclude_health_statistics: bool :param include_system_application_health_statistics: Indicates whether the health statistics should include the fabric:/System application health statistics. False by default. If IncludeSystemApplicationHealthStatistics is set to true, the health statistics include the entities that belong to the fabric:/System application. Otherwise, the query result includes health statistics only for user applications. The health statistics must be included in the query result for this parameter to be applied. :type include_system_application_health_statistics: bool :param timeout: The server timeout for performing the operation in seconds. This timeout specifies the time duration that the client is willing to wait for the requested operation to complete. The default value for this parameter is 60 seconds. :type timeout: long :param application_health_policy_map: Defines a map that contains specific application health policies for different applications. Each entry specifies as key the application name and as value an ApplicationHealthPolicy used to evaluate the application health. If an application is not specified in the map, the application health evaluation uses the ApplicationHealthPolicy found in its application manifest or the default application health policy (if no health policy is defined in the manifest). The map is empty by default. :type application_health_policy_map: list[~azure.servicefabric.models.ApplicationHealthPolicyMapItem] :param cluster_health_policy: Defines a health policy used to evaluate the health of the cluster or of a cluster node. :type cluster_health_policy: ~azure.servicefabric.models.ClusterHealthPolicy :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: ClusterHealth or ClientRawResponse if raw=true :rtype: ~azure.servicefabric.models.ClusterHealth or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>` """ cluster_health_policies = None if application_health_policy_map is not None or cluster_health_policy is not None: cluster_health_policies = models.ClusterHealthPolicies(application_health_policy_map=application_health_policy_map, cluster_health_policy=cluster_health_policy) api_version = "6.0" # Construct URL url = self.get_cluster_health_using_policy.metadata['url'] # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if nodes_health_state_filter is not None: query_parameters['NodesHealthStateFilter'] = self._serialize.query("nodes_health_state_filter", nodes_health_state_filter, 'int') if applications_health_state_filter is not None: query_parameters['ApplicationsHealthStateFilter'] = self._serialize.query("applications_health_state_filter", applications_health_state_filter, 'int') if events_health_state_filter is not None: query_parameters['EventsHealthStateFilter'] = self._serialize.query("events_health_state_filter", events_health_state_filter, 'int') if exclude_health_statistics is not None: query_parameters['ExcludeHealthStatistics'] = self._serialize.query("exclude_health_statistics", exclude_health_statistics, 'bool') if include_system_application_health_statistics is not None: query_parameters['IncludeSystemApplicationHealthStatistics'] = self._serialize.query("include_system_application_health_statistics", include_system_application_health_statistics, 'bool') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'long', maximum=4294967295, minimum=1) # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if cluster_health_policies is not None: body_content = self._serialize.body(cluster_health_policies, 'ClusterHealthPolicies') else: body_content = None # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.FabricErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ClusterHealth', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def get_cluster_health_using_policy( self, nodes_health_state_filter=0, applications_health_state_filter=0, events_health_state_filter=0, exclude_health_statistics=False, include_system_application_health_statistics=False, timeout=60, application_health_policy_map=None, cluster_health_policy=None, custom_headers=None, raw=False, **operation_config): """Gets the health of a Service Fabric cluster using the specified policy. Use EventsHealthStateFilter to filter the collection of health events reported on the cluster based on the health state. Similarly, use NodesHealthStateFilter and ApplicationsHealthStateFilter to filter the collection of nodes and applications returned based on their aggregated health state. Use ClusterHealthPolicies to override the health policies used to evaluate the health. :param nodes_health_state_filter: Allows filtering of the node health state objects returned in the result of cluster health query based on their health state. The possible values for this parameter include integer value of one of the following health states. Only nodes that match the filter are returned. All nodes are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values obtained using bitwise 'OR' operator. For example, if the provided value is 6 then health state of nodes with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type nodes_health_state_filter: int :param applications_health_state_filter: Allows filtering of the application health state objects returned in the result of cluster health query based on their health state. The possible values for this parameter include integer value obtained from members or bitwise operations on members of HealthStateFilter enumeration. Only applications that match the filter are returned. All applications are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values obtained using bitwise 'OR' operator. For example, if the provided value is 6 then health state of applications with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type applications_health_state_filter: int :param events_health_state_filter: Allows filtering the collection of HealthEvent objects returned based on health state. The possible values for this parameter include integer value of one of the following health states. Only events that match the filter are returned. All events are used to evaluate the aggregated health state. If not specified, all entries are returned. The state values are flag-based enumeration, so the value could be a combination of these values, obtained using the bitwise 'OR' operator. For example, If the provided value is 6 then all of the events with HealthState value of OK (2) and Warning (4) are returned. - Default - Default value. Matches any HealthState. The value is zero. - None - Filter that doesn't match any HealthState value. Used in order to return no results on a given collection of states. The value is 1. - Ok - Filter that matches input with HealthState value Ok. The value is 2. - Warning - Filter that matches input with HealthState value Warning. The value is 4. - Error - Filter that matches input with HealthState value Error. The value is 8. - All - Filter that matches input with any HealthState value. The value is 65535. :type events_health_state_filter: int :param exclude_health_statistics: Indicates whether the health statistics should be returned as part of the query result. False by default. The statistics show the number of children entities in health state Ok, Warning, and Error. :type exclude_health_statistics: bool :param include_system_application_health_statistics: Indicates whether the health statistics should include the fabric:/System application health statistics. False by default. If IncludeSystemApplicationHealthStatistics is set to true, the health statistics include the entities that belong to the fabric:/System application. Otherwise, the query result includes health statistics only for user applications. The health statistics must be included in the query result for this parameter to be applied. :type include_system_application_health_statistics: bool :param timeout: The server timeout for performing the operation in seconds. This timeout specifies the time duration that the client is willing to wait for the requested operation to complete. The default value for this parameter is 60 seconds. :type timeout: long :param application_health_policy_map: Defines a map that contains specific application health policies for different applications. Each entry specifies as key the application name and as value an ApplicationHealthPolicy used to evaluate the application health. If an application is not specified in the map, the application health evaluation uses the ApplicationHealthPolicy found in its application manifest or the default application health policy (if no health policy is defined in the manifest). The map is empty by default. :type application_health_policy_map: list[~azure.servicefabric.models.ApplicationHealthPolicyMapItem] :param cluster_health_policy: Defines a health policy used to evaluate the health of the cluster or of a cluster node. :type cluster_health_policy: ~azure.servicefabric.models.ClusterHealthPolicy :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: ClusterHealth or ClientRawResponse if raw=true :rtype: ~azure.servicefabric.models.ClusterHealth or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>` """ cluster_health_policies = None if application_health_policy_map is not None or cluster_health_policy is not None: cluster_health_policies = models.ClusterHealthPolicies(application_health_policy_map=application_health_policy_map, cluster_health_policy=cluster_health_policy) api_version = "6.0" # Construct URL url = self.get_cluster_health_using_policy.metadata['url'] # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if nodes_health_state_filter is not None: query_parameters['NodesHealthStateFilter'] = self._serialize.query("nodes_health_state_filter", nodes_health_state_filter, 'int') if applications_health_state_filter is not None: query_parameters['ApplicationsHealthStateFilter'] = self._serialize.query("applications_health_state_filter", applications_health_state_filter, 'int') if events_health_state_filter is not None: query_parameters['EventsHealthStateFilter'] = self._serialize.query("events_health_state_filter", events_health_state_filter, 'int') if exclude_health_statistics is not None: query_parameters['ExcludeHealthStatistics'] = self._serialize.query("exclude_health_statistics", exclude_health_statistics, 'bool') if include_system_application_health_statistics is not None: query_parameters['IncludeSystemApplicationHealthStatistics'] = self._serialize.query("include_system_application_health_statistics", include_system_application_health_statistics, 'bool') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'long', maximum=4294967295, minimum=1) # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if cluster_health_policies is not None: body_content = self._serialize.body(cluster_health_policies, 'ClusterHealthPolicies') else: body_content = None # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.FabricErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ClusterHealth', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Gets", "the", "health", "of", "a", "Service", "Fabric", "cluster", "using", "the", "specified", "policy", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicefabric/azure/servicefabric/service_fabric_client_ap_is.py#L349-L539
[ "def", "get_cluster_health_using_policy", "(", "self", ",", "nodes_health_state_filter", "=", "0", ",", "applications_health_state_filter", "=", "0", ",", "events_health_state_filter", "=", "0", ",", "exclude_health_statistics", "=", "False", ",", "include_system_application_health_statistics", "=", "False", ",", "timeout", "=", "60", ",", "application_health_policy_map", "=", "None", ",", "cluster_health_policy", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "cluster_health_policies", "=", "None", "if", "application_health_policy_map", "is", "not", "None", "or", "cluster_health_policy", "is", "not", "None", ":", "cluster_health_policies", "=", "models", ".", "ClusterHealthPolicies", "(", "application_health_policy_map", "=", "application_health_policy_map", ",", "cluster_health_policy", "=", "cluster_health_policy", ")", "api_version", "=", "\"6.0\"", "# Construct URL", "url", "=", "self", ".", "get_cluster_health_using_policy", ".", "metadata", "[", "'url'", "]", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"api_version\"", ",", "api_version", ",", "'str'", ")", "if", "nodes_health_state_filter", "is", "not", "None", ":", "query_parameters", "[", "'NodesHealthStateFilter'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"nodes_health_state_filter\"", ",", "nodes_health_state_filter", ",", "'int'", ")", "if", "applications_health_state_filter", "is", "not", "None", ":", "query_parameters", "[", "'ApplicationsHealthStateFilter'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"applications_health_state_filter\"", ",", "applications_health_state_filter", ",", "'int'", ")", "if", "events_health_state_filter", "is", "not", "None", ":", "query_parameters", "[", "'EventsHealthStateFilter'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"events_health_state_filter\"", ",", "events_health_state_filter", ",", "'int'", ")", "if", "exclude_health_statistics", "is", "not", "None", ":", "query_parameters", "[", "'ExcludeHealthStatistics'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"exclude_health_statistics\"", ",", "exclude_health_statistics", ",", "'bool'", ")", "if", "include_system_application_health_statistics", "is", "not", "None", ":", "query_parameters", "[", "'IncludeSystemApplicationHealthStatistics'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"include_system_application_health_statistics\"", ",", "include_system_application_health_statistics", ",", "'bool'", ")", "if", "timeout", "is", "not", "None", ":", "query_parameters", "[", "'timeout'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"timeout\"", ",", "timeout", ",", "'long'", ",", "maximum", "=", "4294967295", ",", "minimum", "=", "1", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct body", "if", "cluster_health_policies", "is", "not", "None", ":", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "cluster_health_policies", ",", "'ClusterHealthPolicies'", ")", "else", ":", "body_content", "=", "None", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ",", "header_parameters", ",", "body_content", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "FabricErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'ClusterHealth'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceFabricClientAPIs.unprovision_application_type
Removes or unregisters a Service Fabric application type from the cluster. This operation can only be performed if all application instances of the application type have been deleted. Once the application type is unregistered, no new application instances can be created for this particular application type. :param application_type_name: The name of the application type. :type application_type_name: str :param application_type_version: The version of the application type as defined in the application manifest. :type application_type_version: str :param timeout: The server timeout for performing the operation in seconds. This timeout specifies the time duration that the client is willing to wait for the requested operation to complete. The default value for this parameter is 60 seconds. :type timeout: long :param async_parameter: The flag indicating whether or not unprovision should occur asynchronously. When set to true, the unprovision operation returns when the request is accepted by the system, and the unprovision operation continues without any timeout limit. The default value is false. However, we recommend setting it to true for large application packages that were provisioned. :type async_parameter: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>`
azure-servicefabric/azure/servicefabric/service_fabric_client_ap_is.py
def unprovision_application_type( self, application_type_name, application_type_version, timeout=60, async_parameter=None, custom_headers=None, raw=False, **operation_config): """Removes or unregisters a Service Fabric application type from the cluster. This operation can only be performed if all application instances of the application type have been deleted. Once the application type is unregistered, no new application instances can be created for this particular application type. :param application_type_name: The name of the application type. :type application_type_name: str :param application_type_version: The version of the application type as defined in the application manifest. :type application_type_version: str :param timeout: The server timeout for performing the operation in seconds. This timeout specifies the time duration that the client is willing to wait for the requested operation to complete. The default value for this parameter is 60 seconds. :type timeout: long :param async_parameter: The flag indicating whether or not unprovision should occur asynchronously. When set to true, the unprovision operation returns when the request is accepted by the system, and the unprovision operation continues without any timeout limit. The default value is false. However, we recommend setting it to true for large application packages that were provisioned. :type async_parameter: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>` """ unprovision_application_type_description_info = models.UnprovisionApplicationTypeDescriptionInfo(application_type_version=application_type_version, async_property=async_parameter) api_version = "6.0" # Construct URL url = self.unprovision_application_type.metadata['url'] path_format_arguments = { 'applicationTypeName': self._serialize.url("application_type_name", application_type_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'long', maximum=4294967295, minimum=1) # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(unprovision_application_type_description_info, 'UnprovisionApplicationTypeDescriptionInfo') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200, 202]: raise models.FabricErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
def unprovision_application_type( self, application_type_name, application_type_version, timeout=60, async_parameter=None, custom_headers=None, raw=False, **operation_config): """Removes or unregisters a Service Fabric application type from the cluster. This operation can only be performed if all application instances of the application type have been deleted. Once the application type is unregistered, no new application instances can be created for this particular application type. :param application_type_name: The name of the application type. :type application_type_name: str :param application_type_version: The version of the application type as defined in the application manifest. :type application_type_version: str :param timeout: The server timeout for performing the operation in seconds. This timeout specifies the time duration that the client is willing to wait for the requested operation to complete. The default value for this parameter is 60 seconds. :type timeout: long :param async_parameter: The flag indicating whether or not unprovision should occur asynchronously. When set to true, the unprovision operation returns when the request is accepted by the system, and the unprovision operation continues without any timeout limit. The default value is false. However, we recommend setting it to true for large application packages that were provisioned. :type async_parameter: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>` """ unprovision_application_type_description_info = models.UnprovisionApplicationTypeDescriptionInfo(application_type_version=application_type_version, async_property=async_parameter) api_version = "6.0" # Construct URL url = self.unprovision_application_type.metadata['url'] path_format_arguments = { 'applicationTypeName': self._serialize.url("application_type_name", application_type_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'long', maximum=4294967295, minimum=1) # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(unprovision_application_type_description_info, 'UnprovisionApplicationTypeDescriptionInfo') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200, 202]: raise models.FabricErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
[ "Removes", "or", "unregisters", "a", "Service", "Fabric", "application", "type", "from", "the", "cluster", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicefabric/azure/servicefabric/service_fabric_client_ap_is.py#L2842-L2914
[ "def", "unprovision_application_type", "(", "self", ",", "application_type_name", ",", "application_type_version", ",", "timeout", "=", "60", ",", "async_parameter", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "unprovision_application_type_description_info", "=", "models", ".", "UnprovisionApplicationTypeDescriptionInfo", "(", "application_type_version", "=", "application_type_version", ",", "async_property", "=", "async_parameter", ")", "api_version", "=", "\"6.0\"", "# Construct URL", "url", "=", "self", ".", "unprovision_application_type", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'applicationTypeName'", ":", "self", ".", "_serialize", ".", "url", "(", "\"application_type_name\"", ",", "application_type_name", ",", "'str'", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"api_version\"", ",", "api_version", ",", "'str'", ")", "if", "timeout", "is", "not", "None", ":", "query_parameters", "[", "'timeout'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"timeout\"", ",", "timeout", ",", "'long'", ",", "maximum", "=", "4294967295", ",", "minimum", "=", "1", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "unprovision_application_type_description_info", ",", "'UnprovisionApplicationTypeDescriptionInfo'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ",", "header_parameters", ",", "body_content", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", ",", "202", "]", ":", "raise", "models", ".", "FabricErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "return", "client_raw_response" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceFabricClientAPIs.get_repair_task_list
Gets a list of repair tasks matching the given filters. This API supports the Service Fabric platform; it is not meant to be used directly from your code. :param task_id_filter: The repair task ID prefix to be matched. :type task_id_filter: str :param state_filter: A bitwise-OR of the following values, specifying which task states should be included in the result list. - 1 - Created - 2 - Claimed - 4 - Preparing - 8 - Approved - 16 - Executing - 32 - Restoring - 64 - Completed :type state_filter: int :param executor_filter: The name of the repair executor whose claimed tasks should be included in the list. :type executor_filter: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: list or ClientRawResponse if raw=true :rtype: list[~azure.servicefabric.models.RepairTask] or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>`
azure-servicefabric/azure/servicefabric/service_fabric_client_ap_is.py
def get_repair_task_list( self, task_id_filter=None, state_filter=None, executor_filter=None, custom_headers=None, raw=False, **operation_config): """Gets a list of repair tasks matching the given filters. This API supports the Service Fabric platform; it is not meant to be used directly from your code. :param task_id_filter: The repair task ID prefix to be matched. :type task_id_filter: str :param state_filter: A bitwise-OR of the following values, specifying which task states should be included in the result list. - 1 - Created - 2 - Claimed - 4 - Preparing - 8 - Approved - 16 - Executing - 32 - Restoring - 64 - Completed :type state_filter: int :param executor_filter: The name of the repair executor whose claimed tasks should be included in the list. :type executor_filter: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: list or ClientRawResponse if raw=true :rtype: list[~azure.servicefabric.models.RepairTask] or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>` """ api_version = "6.0" # Construct URL url = self.get_repair_task_list.metadata['url'] # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if task_id_filter is not None: query_parameters['TaskIdFilter'] = self._serialize.query("task_id_filter", task_id_filter, 'str') if state_filter is not None: query_parameters['StateFilter'] = self._serialize.query("state_filter", state_filter, 'int') if executor_filter is not None: query_parameters['ExecutorFilter'] = self._serialize.query("executor_filter", executor_filter, 'str') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.FabricErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[RepairTask]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def get_repair_task_list( self, task_id_filter=None, state_filter=None, executor_filter=None, custom_headers=None, raw=False, **operation_config): """Gets a list of repair tasks matching the given filters. This API supports the Service Fabric platform; it is not meant to be used directly from your code. :param task_id_filter: The repair task ID prefix to be matched. :type task_id_filter: str :param state_filter: A bitwise-OR of the following values, specifying which task states should be included in the result list. - 1 - Created - 2 - Claimed - 4 - Preparing - 8 - Approved - 16 - Executing - 32 - Restoring - 64 - Completed :type state_filter: int :param executor_filter: The name of the repair executor whose claimed tasks should be included in the list. :type executor_filter: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: list or ClientRawResponse if raw=true :rtype: list[~azure.servicefabric.models.RepairTask] or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>` """ api_version = "6.0" # Construct URL url = self.get_repair_task_list.metadata['url'] # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if task_id_filter is not None: query_parameters['TaskIdFilter'] = self._serialize.query("task_id_filter", task_id_filter, 'str') if state_filter is not None: query_parameters['StateFilter'] = self._serialize.query("state_filter", state_filter, 'int') if executor_filter is not None: query_parameters['ExecutorFilter'] = self._serialize.query("executor_filter", executor_filter, 'str') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.FabricErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[RepairTask]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Gets", "a", "list", "of", "repair", "tasks", "matching", "the", "given", "filters", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicefabric/azure/servicefabric/service_fabric_client_ap_is.py#L7441-L7511
[ "def", "get_repair_task_list", "(", "self", ",", "task_id_filter", "=", "None", ",", "state_filter", "=", "None", ",", "executor_filter", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "api_version", "=", "\"6.0\"", "# Construct URL", "url", "=", "self", ".", "get_repair_task_list", ".", "metadata", "[", "'url'", "]", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"api_version\"", ",", "api_version", ",", "'str'", ")", "if", "task_id_filter", "is", "not", "None", ":", "query_parameters", "[", "'TaskIdFilter'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"task_id_filter\"", ",", "task_id_filter", ",", "'str'", ")", "if", "state_filter", "is", "not", "None", ":", "query_parameters", "[", "'StateFilter'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"state_filter\"", ",", "state_filter", ",", "'int'", ")", "if", "executor_filter", "is", "not", "None", ":", "query_parameters", "[", "'ExecutorFilter'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"executor_filter\"", ",", "executor_filter", ",", "'str'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "get", "(", "url", ",", "query_parameters", ",", "header_parameters", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "FabricErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'[RepairTask]'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceFabricClientAPIs.submit_property_batch
Submits a property batch. Submits a batch of property operations. Either all or none of the operations will be committed. :param name_id: The Service Fabric name, without the 'fabric:' URI scheme. :type name_id: str :param timeout: The server timeout for performing the operation in seconds. This timeout specifies the time duration that the client is willing to wait for the requested operation to complete. The default value for this parameter is 60 seconds. :type timeout: long :param operations: A list of the property batch operations to be executed. :type operations: list[~azure.servicefabric.models.PropertyBatchOperation] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: PropertyBatchInfo or ClientRawResponse if raw=true :rtype: ~azure.servicefabric.models.PropertyBatchInfo or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>`
azure-servicefabric/azure/servicefabric/service_fabric_client_ap_is.py
def submit_property_batch( self, name_id, timeout=60, operations=None, custom_headers=None, raw=False, **operation_config): """Submits a property batch. Submits a batch of property operations. Either all or none of the operations will be committed. :param name_id: The Service Fabric name, without the 'fabric:' URI scheme. :type name_id: str :param timeout: The server timeout for performing the operation in seconds. This timeout specifies the time duration that the client is willing to wait for the requested operation to complete. The default value for this parameter is 60 seconds. :type timeout: long :param operations: A list of the property batch operations to be executed. :type operations: list[~azure.servicefabric.models.PropertyBatchOperation] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: PropertyBatchInfo or ClientRawResponse if raw=true :rtype: ~azure.servicefabric.models.PropertyBatchInfo or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>` """ property_batch_description_list = models.PropertyBatchDescriptionList(operations=operations) api_version = "6.0" # Construct URL url = self.submit_property_batch.metadata['url'] path_format_arguments = { 'nameId': self._serialize.url("name_id", name_id, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'long', maximum=4294967295, minimum=1) # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(property_batch_description_list, 'PropertyBatchDescriptionList') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200, 409]: raise models.FabricErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SuccessfulPropertyBatchInfo', response) if response.status_code == 409: deserialized = self._deserialize('FailedPropertyBatchInfo', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def submit_property_batch( self, name_id, timeout=60, operations=None, custom_headers=None, raw=False, **operation_config): """Submits a property batch. Submits a batch of property operations. Either all or none of the operations will be committed. :param name_id: The Service Fabric name, without the 'fabric:' URI scheme. :type name_id: str :param timeout: The server timeout for performing the operation in seconds. This timeout specifies the time duration that the client is willing to wait for the requested operation to complete. The default value for this parameter is 60 seconds. :type timeout: long :param operations: A list of the property batch operations to be executed. :type operations: list[~azure.servicefabric.models.PropertyBatchOperation] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: PropertyBatchInfo or ClientRawResponse if raw=true :rtype: ~azure.servicefabric.models.PropertyBatchInfo or ~msrest.pipeline.ClientRawResponse :raises: :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>` """ property_batch_description_list = models.PropertyBatchDescriptionList(operations=operations) api_version = "6.0" # Construct URL url = self.submit_property_batch.metadata['url'] path_format_arguments = { 'nameId': self._serialize.url("name_id", name_id, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'long', maximum=4294967295, minimum=1) # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(property_batch_description_list, 'PropertyBatchDescriptionList') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200, 409]: raise models.FabricErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SuccessfulPropertyBatchInfo', response) if response.status_code == 409: deserialized = self._deserialize('FailedPropertyBatchInfo', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Submits", "a", "property", "batch", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicefabric/azure/servicefabric/service_fabric_client_ap_is.py#L14626-L14701
[ "def", "submit_property_batch", "(", "self", ",", "name_id", ",", "timeout", "=", "60", ",", "operations", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "property_batch_description_list", "=", "models", ".", "PropertyBatchDescriptionList", "(", "operations", "=", "operations", ")", "api_version", "=", "\"6.0\"", "# Construct URL", "url", "=", "self", ".", "submit_property_batch", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'nameId'", ":", "self", ".", "_serialize", ".", "url", "(", "\"name_id\"", ",", "name_id", ",", "'str'", ",", "skip_quote", "=", "True", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"api_version\"", ",", "api_version", ",", "'str'", ")", "if", "timeout", "is", "not", "None", ":", "query_parameters", "[", "'timeout'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"timeout\"", ",", "timeout", ",", "'long'", ",", "maximum", "=", "4294967295", ",", "minimum", "=", "1", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "property_batch_description_list", ",", "'PropertyBatchDescriptionList'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ",", "header_parameters", ",", "body_content", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", ",", "409", "]", ":", "raise", "models", ".", "FabricErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'SuccessfulPropertyBatchInfo'", ",", "response", ")", "if", "response", ".", "status_code", "==", "409", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'FailedPropertyBatchInfo'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
FeatureClient.models
Module depends on the API version: * 2015-12-01: :mod:`v2015_12_01.models<azure.mgmt.resource.features.v2015_12_01.models>`
azure-mgmt-resource/azure/mgmt/resource/features/feature_client.py
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2015-12-01: :mod:`v2015_12_01.models<azure.mgmt.resource.features.v2015_12_01.models>` """ if api_version == '2015-12-01': from .v2015_12_01 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2015-12-01: :mod:`v2015_12_01.models<azure.mgmt.resource.features.v2015_12_01.models>` """ if api_version == '2015-12-01': from .v2015_12_01 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
[ "Module", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-resource/azure/mgmt/resource/features/feature_client.py#L101-L109
[ "def", "models", "(", "cls", ",", "api_version", "=", "DEFAULT_API_VERSION", ")", ":", "if", "api_version", "==", "'2015-12-01'", ":", "from", ".", "v2015_12_01", "import", "models", "return", "models", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
FeatureClient.features
Instance depends on the API version: * 2015-12-01: :class:`FeaturesOperations<azure.mgmt.resource.features.v2015_12_01.operations.FeaturesOperations>`
azure-mgmt-resource/azure/mgmt/resource/features/feature_client.py
def features(self): """Instance depends on the API version: * 2015-12-01: :class:`FeaturesOperations<azure.mgmt.resource.features.v2015_12_01.operations.FeaturesOperations>` """ api_version = self._get_api_version('features') if api_version == '2015-12-01': from .v2015_12_01.operations import FeaturesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def features(self): """Instance depends on the API version: * 2015-12-01: :class:`FeaturesOperations<azure.mgmt.resource.features.v2015_12_01.operations.FeaturesOperations>` """ api_version = self._get_api_version('features') if api_version == '2015-12-01': from .v2015_12_01.operations import FeaturesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-resource/azure/mgmt/resource/features/feature_client.py#L112-L122
[ "def", "features", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'features'", ")", "if", "api_version", "==", "'2015-12-01'", ":", "from", ".", "v2015_12_01", ".", "operations", "import", "FeaturesOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_general_error_handler
Simple error handler for azure.
azure-servicemanagement-legacy/azure/servicemanagement/_common_error.py
def _general_error_handler(http_error): ''' Simple error handler for azure.''' message = str(http_error) if http_error.respbody is not None: message += '\n' + http_error.respbody.decode('utf-8-sig') raise AzureHttpError(message, http_error.status)
def _general_error_handler(http_error): ''' Simple error handler for azure.''' message = str(http_error) if http_error.respbody is not None: message += '\n' + http_error.respbody.decode('utf-8-sig') raise AzureHttpError(message, http_error.status)
[ "Simple", "error", "handler", "for", "azure", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_common_error.py#L29-L34
[ "def", "_general_error_handler", "(", "http_error", ")", ":", "message", "=", "str", "(", "http_error", ")", "if", "http_error", ".", "respbody", "is", "not", "None", ":", "message", "+=", "'\\n'", "+", "http_error", ".", "respbody", ".", "decode", "(", "'utf-8-sig'", ")", "raise", "AzureHttpError", "(", "message", ",", "http_error", ".", "status", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
WebAppsOperations.start_web_site_network_trace_operation
Start capturing network packets for the site. Start capturing network packets for the site. :param resource_group_name: Name of the resource group to which the resource belongs. :type resource_group_name: str :param name: The name of the web app. :type name: str :param duration_in_seconds: The duration to keep capturing in seconds. :type duration_in_seconds: int :param max_frame_length: The maximum frame length in bytes (Optional). :type max_frame_length: int :param sas_url: The Blob URL to store capture file. :type sas_url: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns list or ClientRawResponse<list> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[list[~azure.mgmt.web.models.NetworkTrace]] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[list[~azure.mgmt.web.models.NetworkTrace]]] :raises: :class:`DefaultErrorResponseException<azure.mgmt.web.models.DefaultErrorResponseException>`
azure-mgmt-web/azure/mgmt/web/operations/web_apps_operations.py
def start_web_site_network_trace_operation( self, resource_group_name, name, duration_in_seconds=None, max_frame_length=None, sas_url=None, custom_headers=None, raw=False, polling=True, **operation_config): """Start capturing network packets for the site. Start capturing network packets for the site. :param resource_group_name: Name of the resource group to which the resource belongs. :type resource_group_name: str :param name: The name of the web app. :type name: str :param duration_in_seconds: The duration to keep capturing in seconds. :type duration_in_seconds: int :param max_frame_length: The maximum frame length in bytes (Optional). :type max_frame_length: int :param sas_url: The Blob URL to store capture file. :type sas_url: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns list or ClientRawResponse<list> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[list[~azure.mgmt.web.models.NetworkTrace]] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[list[~azure.mgmt.web.models.NetworkTrace]]] :raises: :class:`DefaultErrorResponseException<azure.mgmt.web.models.DefaultErrorResponseException>` """ raw_result = self._start_web_site_network_trace_operation_initial( resource_group_name=resource_group_name, name=name, duration_in_seconds=duration_in_seconds, max_frame_length=max_frame_length, sas_url=sas_url, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('[NetworkTrace]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def start_web_site_network_trace_operation( self, resource_group_name, name, duration_in_seconds=None, max_frame_length=None, sas_url=None, custom_headers=None, raw=False, polling=True, **operation_config): """Start capturing network packets for the site. Start capturing network packets for the site. :param resource_group_name: Name of the resource group to which the resource belongs. :type resource_group_name: str :param name: The name of the web app. :type name: str :param duration_in_seconds: The duration to keep capturing in seconds. :type duration_in_seconds: int :param max_frame_length: The maximum frame length in bytes (Optional). :type max_frame_length: int :param sas_url: The Blob URL to store capture file. :type sas_url: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns list or ClientRawResponse<list> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[list[~azure.mgmt.web.models.NetworkTrace]] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[list[~azure.mgmt.web.models.NetworkTrace]]] :raises: :class:`DefaultErrorResponseException<azure.mgmt.web.models.DefaultErrorResponseException>` """ raw_result = self._start_web_site_network_trace_operation_initial( resource_group_name=resource_group_name, name=name, duration_in_seconds=duration_in_seconds, max_frame_length=max_frame_length, sas_url=sas_url, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('[NetworkTrace]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Start", "capturing", "network", "packets", "for", "the", "site", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-web/azure/mgmt/web/operations/web_apps_operations.py#L7932-L7989
[ "def", "start_web_site_network_trace_operation", "(", "self", ",", "resource_group_name", ",", "name", ",", "duration_in_seconds", "=", "None", ",", "max_frame_length", "=", "None", ",", "sas_url", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_start_web_site_network_trace_operation_initial", "(", "resource_group_name", "=", "resource_group_name", ",", "name", "=", "name", ",", "duration_in_seconds", "=", "duration_in_seconds", ",", "max_frame_length", "=", "max_frame_length", ",", "sas_url", "=", "sas_url", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'[NetworkTrace]'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
WebAppsOperations.list_slot_differences_slot
Get the difference in configuration settings between two web app slots. Get the difference in configuration settings between two web app slots. :param resource_group_name: Name of the resource group to which the resource belongs. :type resource_group_name: str :param name: Name of the app. :type name: str :param slot: Name of the source slot. If a slot is not specified, the production slot is used as the source slot. :type slot: str :param target_slot: Destination deployment slot during swap operation. :type target_slot: str :param preserve_vnet: <code>true</code> to preserve Virtual Network to the slot during swap; otherwise, <code>false</code>. :type preserve_vnet: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of SlotDifference :rtype: ~azure.mgmt.web.models.SlotDifferencePaged[~azure.mgmt.web.models.SlotDifference] :raises: :class:`DefaultErrorResponseException<azure.mgmt.web.models.DefaultErrorResponseException>`
azure-mgmt-web/azure/mgmt/web/operations/web_apps_operations.py
def list_slot_differences_slot( self, resource_group_name, name, slot, target_slot, preserve_vnet, custom_headers=None, raw=False, **operation_config): """Get the difference in configuration settings between two web app slots. Get the difference in configuration settings between two web app slots. :param resource_group_name: Name of the resource group to which the resource belongs. :type resource_group_name: str :param name: Name of the app. :type name: str :param slot: Name of the source slot. If a slot is not specified, the production slot is used as the source slot. :type slot: str :param target_slot: Destination deployment slot during swap operation. :type target_slot: str :param preserve_vnet: <code>true</code> to preserve Virtual Network to the slot during swap; otherwise, <code>false</code>. :type preserve_vnet: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of SlotDifference :rtype: ~azure.mgmt.web.models.SlotDifferencePaged[~azure.mgmt.web.models.SlotDifference] :raises: :class:`DefaultErrorResponseException<azure.mgmt.web.models.DefaultErrorResponseException>` """ slot_swap_entity = models.CsmSlotEntity(target_slot=target_slot, preserve_vnet=preserve_vnet) def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.list_slot_differences_slot.metadata['url'] path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'), 'name': self._serialize.url("name", name, 'str'), 'slot': self._serialize.url("slot", slot, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(slot_swap_entity, 'CsmSlotEntity') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.DefaultErrorResponseException(self._deserialize, response) return response # Deserialize response deserialized = models.SlotDifferencePaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.SlotDifferencePaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
def list_slot_differences_slot( self, resource_group_name, name, slot, target_slot, preserve_vnet, custom_headers=None, raw=False, **operation_config): """Get the difference in configuration settings between two web app slots. Get the difference in configuration settings between two web app slots. :param resource_group_name: Name of the resource group to which the resource belongs. :type resource_group_name: str :param name: Name of the app. :type name: str :param slot: Name of the source slot. If a slot is not specified, the production slot is used as the source slot. :type slot: str :param target_slot: Destination deployment slot during swap operation. :type target_slot: str :param preserve_vnet: <code>true</code> to preserve Virtual Network to the slot during swap; otherwise, <code>false</code>. :type preserve_vnet: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of SlotDifference :rtype: ~azure.mgmt.web.models.SlotDifferencePaged[~azure.mgmt.web.models.SlotDifference] :raises: :class:`DefaultErrorResponseException<azure.mgmt.web.models.DefaultErrorResponseException>` """ slot_swap_entity = models.CsmSlotEntity(target_slot=target_slot, preserve_vnet=preserve_vnet) def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.list_slot_differences_slot.metadata['url'] path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'), 'name': self._serialize.url("name", name, 'str'), 'slot': self._serialize.url("slot", slot, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(slot_swap_entity, 'CsmSlotEntity') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.DefaultErrorResponseException(self._deserialize, response) return response # Deserialize response deserialized = models.SlotDifferencePaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.SlotDifferencePaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
[ "Get", "the", "difference", "in", "configuration", "settings", "between", "two", "web", "app", "slots", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-web/azure/mgmt/web/operations/web_apps_operations.py#L21249-L21333
[ "def", "list_slot_differences_slot", "(", "self", ",", "resource_group_name", ",", "name", ",", "slot", ",", "target_slot", ",", "preserve_vnet", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "slot_swap_entity", "=", "models", ".", "CsmSlotEntity", "(", "target_slot", "=", "target_slot", ",", "preserve_vnet", "=", "preserve_vnet", ")", "def", "internal_paging", "(", "next_link", "=", "None", ",", "raw", "=", "False", ")", ":", "if", "not", "next_link", ":", "# Construct URL", "url", "=", "self", ".", "list_slot_differences_slot", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'resourceGroupName'", ":", "self", ".", "_serialize", ".", "url", "(", "\"resource_group_name\"", ",", "resource_group_name", ",", "'str'", ",", "max_length", "=", "90", ",", "min_length", "=", "1", ",", "pattern", "=", "r'^[-\\w\\._\\(\\)]+[^\\.]$'", ")", ",", "'name'", ":", "self", ".", "_serialize", ".", "url", "(", "\"name\"", ",", "name", ",", "'str'", ")", ",", "'slot'", ":", "self", ".", "_serialize", ".", "url", "(", "\"slot\"", ",", "slot", ",", "'str'", ")", ",", "'subscriptionId'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.subscription_id\"", ",", "self", ".", "config", ".", "subscription_id", ",", "'str'", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"self.api_version\"", ",", "self", ".", "api_version", ",", "'str'", ")", "else", ":", "url", "=", "next_link", "query_parameters", "=", "{", "}", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "self", ".", "config", ".", "generate_client_request_id", ":", "header_parameters", "[", "'x-ms-client-request-id'", "]", "=", "str", "(", "uuid", ".", "uuid1", "(", ")", ")", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "if", "self", ".", "config", ".", "accept_language", "is", "not", "None", ":", "header_parameters", "[", "'accept-language'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"self.config.accept_language\"", ",", "self", ".", "config", ".", "accept_language", ",", "'str'", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "slot_swap_entity", ",", "'CsmSlotEntity'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ",", "header_parameters", ",", "body_content", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "DefaultErrorResponseException", "(", "self", ".", "_deserialize", ",", "response", ")", "return", "response", "# Deserialize response", "deserialized", "=", "models", ".", "SlotDifferencePaged", "(", "internal_paging", ",", "self", ".", "_deserialize", ".", "dependencies", ")", "if", "raw", ":", "header_dict", "=", "{", "}", "client_raw_response", "=", "models", ".", "SlotDifferencePaged", "(", "internal_paging", ",", "self", ".", "_deserialize", ".", "dependencies", ",", "header_dict", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
WebAppsOperations.swap_slot_slot
Swaps two deployment slots of an app. Swaps two deployment slots of an app. :param resource_group_name: Name of the resource group to which the resource belongs. :type resource_group_name: str :param name: Name of the app. :type name: str :param slot: Name of the source slot. If a slot is not specified, the production slot is used as the source slot. :type slot: str :param target_slot: Destination deployment slot during swap operation. :type target_slot: str :param preserve_vnet: <code>true</code> to preserve Virtual Network to the slot during swap; otherwise, <code>false</code>. :type preserve_vnet: bool :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
azure-mgmt-web/azure/mgmt/web/operations/web_apps_operations.py
def swap_slot_slot( self, resource_group_name, name, slot, target_slot, preserve_vnet, custom_headers=None, raw=False, polling=True, **operation_config): """Swaps two deployment slots of an app. Swaps two deployment slots of an app. :param resource_group_name: Name of the resource group to which the resource belongs. :type resource_group_name: str :param name: Name of the app. :type name: str :param slot: Name of the source slot. If a slot is not specified, the production slot is used as the source slot. :type slot: str :param target_slot: Destination deployment slot during swap operation. :type target_slot: str :param preserve_vnet: <code>true</code> to preserve Virtual Network to the slot during swap; otherwise, <code>false</code>. :type preserve_vnet: bool :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._swap_slot_slot_initial( resource_group_name=resource_group_name, name=name, slot=slot, target_slot=target_slot, preserve_vnet=preserve_vnet, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def swap_slot_slot( self, resource_group_name, name, slot, target_slot, preserve_vnet, custom_headers=None, raw=False, polling=True, **operation_config): """Swaps two deployment slots of an app. Swaps two deployment slots of an app. :param resource_group_name: Name of the resource group to which the resource belongs. :type resource_group_name: str :param name: Name of the app. :type name: str :param slot: Name of the source slot. If a slot is not specified, the production slot is used as the source slot. :type slot: str :param target_slot: Destination deployment slot during swap operation. :type target_slot: str :param preserve_vnet: <code>true</code> to preserve Virtual Network to the slot during swap; otherwise, <code>false</code>. :type preserve_vnet: bool :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._swap_slot_slot_initial( resource_group_name=resource_group_name, name=name, slot=slot, target_slot=target_slot, preserve_vnet=preserve_vnet, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Swaps", "two", "deployment", "slots", "of", "an", "app", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-web/azure/mgmt/web/operations/web_apps_operations.py#L21381-L21433
[ "def", "swap_slot_slot", "(", "self", ",", "resource_group_name", ",", "name", ",", "slot", ",", "target_slot", ",", "preserve_vnet", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_swap_slot_slot_initial", "(", "resource_group_name", "=", "resource_group_name", ",", "name", "=", "name", ",", "slot", "=", "slot", ",", "target_slot", "=", "target_slot", ",", "preserve_vnet", "=", "preserve_vnet", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "return", "client_raw_response", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
EventsOperations.get_by_type
Execute OData query. Executes an OData query for events. :param app_id: ID of the application. This is Application ID from the API Access settings blade in the Azure portal. :type app_id: str :param event_type: The type of events to query; either a standard event type (`traces`, `customEvents`, `pageViews`, `requests`, `dependencies`, `exceptions`, `availabilityResults`) or `$all` to query across all event types. Possible values include: '$all', 'traces', 'customEvents', 'pageViews', 'browserTimings', 'requests', 'dependencies', 'exceptions', 'availabilityResults', 'performanceCounters', 'customMetrics' :type event_type: str or ~azure.applicationinsights.models.EventType :param timespan: Optional. The timespan over which to retrieve events. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the Odata expression. :type timespan: str :param filter: An expression used to filter the returned events :type filter: str :param search: A free-text search expression to match for whether a particular event should be returned :type search: str :param orderby: A comma-separated list of properties with \\"asc\\" (the default) or \\"desc\\" to control the order of returned events :type orderby: str :param select: Limits the properties to just those requested on each returned event :type select: str :param skip: The number of items to skip over before returning events :type skip: int :param top: The number of events to return :type top: int :param format: Format for the returned events :type format: str :param count: Request a count of matching items included with the returned events :type count: bool :param apply: An expression used for aggregation over returned events :type apply: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: EventsResults or ClientRawResponse if raw=true :rtype: ~azure.applicationinsights.models.EventsResults or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.applicationinsights.models.ErrorResponseException>`
azure-applicationinsights/azure/applicationinsights/operations/events_operations.py
def get_by_type( self, app_id, event_type, timespan=None, filter=None, search=None, orderby=None, select=None, skip=None, top=None, format=None, count=None, apply=None, custom_headers=None, raw=False, **operation_config): """Execute OData query. Executes an OData query for events. :param app_id: ID of the application. This is Application ID from the API Access settings blade in the Azure portal. :type app_id: str :param event_type: The type of events to query; either a standard event type (`traces`, `customEvents`, `pageViews`, `requests`, `dependencies`, `exceptions`, `availabilityResults`) or `$all` to query across all event types. Possible values include: '$all', 'traces', 'customEvents', 'pageViews', 'browserTimings', 'requests', 'dependencies', 'exceptions', 'availabilityResults', 'performanceCounters', 'customMetrics' :type event_type: str or ~azure.applicationinsights.models.EventType :param timespan: Optional. The timespan over which to retrieve events. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the Odata expression. :type timespan: str :param filter: An expression used to filter the returned events :type filter: str :param search: A free-text search expression to match for whether a particular event should be returned :type search: str :param orderby: A comma-separated list of properties with \\"asc\\" (the default) or \\"desc\\" to control the order of returned events :type orderby: str :param select: Limits the properties to just those requested on each returned event :type select: str :param skip: The number of items to skip over before returning events :type skip: int :param top: The number of events to return :type top: int :param format: Format for the returned events :type format: str :param count: Request a count of matching items included with the returned events :type count: bool :param apply: An expression used for aggregation over returned events :type apply: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: EventsResults or ClientRawResponse if raw=true :rtype: ~azure.applicationinsights.models.EventsResults or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.applicationinsights.models.ErrorResponseException>` """ # Construct URL url = self.get_by_type.metadata['url'] path_format_arguments = { 'appId': self._serialize.url("app_id", app_id, 'str'), 'eventType': self._serialize.url("event_type", event_type, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if timespan is not None: query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if search is not None: query_parameters['$search'] = self._serialize.query("search", search, 'str') if orderby is not None: query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, 'str') if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int') if format is not None: query_parameters['$format'] = self._serialize.query("format", format, 'str') if count is not None: query_parameters['$count'] = self._serialize.query("count", count, 'bool') if apply is not None: query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('EventsResults', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def get_by_type( self, app_id, event_type, timespan=None, filter=None, search=None, orderby=None, select=None, skip=None, top=None, format=None, count=None, apply=None, custom_headers=None, raw=False, **operation_config): """Execute OData query. Executes an OData query for events. :param app_id: ID of the application. This is Application ID from the API Access settings blade in the Azure portal. :type app_id: str :param event_type: The type of events to query; either a standard event type (`traces`, `customEvents`, `pageViews`, `requests`, `dependencies`, `exceptions`, `availabilityResults`) or `$all` to query across all event types. Possible values include: '$all', 'traces', 'customEvents', 'pageViews', 'browserTimings', 'requests', 'dependencies', 'exceptions', 'availabilityResults', 'performanceCounters', 'customMetrics' :type event_type: str or ~azure.applicationinsights.models.EventType :param timespan: Optional. The timespan over which to retrieve events. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the Odata expression. :type timespan: str :param filter: An expression used to filter the returned events :type filter: str :param search: A free-text search expression to match for whether a particular event should be returned :type search: str :param orderby: A comma-separated list of properties with \\"asc\\" (the default) or \\"desc\\" to control the order of returned events :type orderby: str :param select: Limits the properties to just those requested on each returned event :type select: str :param skip: The number of items to skip over before returning events :type skip: int :param top: The number of events to return :type top: int :param format: Format for the returned events :type format: str :param count: Request a count of matching items included with the returned events :type count: bool :param apply: An expression used for aggregation over returned events :type apply: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: EventsResults or ClientRawResponse if raw=true :rtype: ~azure.applicationinsights.models.EventsResults or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.applicationinsights.models.ErrorResponseException>` """ # Construct URL url = self.get_by_type.metadata['url'] path_format_arguments = { 'appId': self._serialize.url("app_id", app_id, 'str'), 'eventType': self._serialize.url("event_type", event_type, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if timespan is not None: query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if search is not None: query_parameters['$search'] = self._serialize.query("search", search, 'str') if orderby is not None: query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, 'str') if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int') if format is not None: query_parameters['$format'] = self._serialize.query("format", format, 'str') if count is not None: query_parameters['$count'] = self._serialize.query("count", count, 'bool') if apply is not None: query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('EventsResults', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Execute", "OData", "query", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-applicationinsights/azure/applicationinsights/operations/events_operations.py#L36-L143
[ "def", "get_by_type", "(", "self", ",", "app_id", ",", "event_type", ",", "timespan", "=", "None", ",", "filter", "=", "None", ",", "search", "=", "None", ",", "orderby", "=", "None", ",", "select", "=", "None", ",", "skip", "=", "None", ",", "top", "=", "None", ",", "format", "=", "None", ",", "count", "=", "None", ",", "apply", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "# Construct URL", "url", "=", "self", ".", "get_by_type", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'appId'", ":", "self", ".", "_serialize", ".", "url", "(", "\"app_id\"", ",", "app_id", ",", "'str'", ")", ",", "'eventType'", ":", "self", ".", "_serialize", ".", "url", "(", "\"event_type\"", ",", "event_type", ",", "'str'", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "if", "timespan", "is", "not", "None", ":", "query_parameters", "[", "'timespan'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"timespan\"", ",", "timespan", ",", "'str'", ")", "if", "filter", "is", "not", "None", ":", "query_parameters", "[", "'$filter'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"filter\"", ",", "filter", ",", "'str'", ")", "if", "search", "is", "not", "None", ":", "query_parameters", "[", "'$search'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"search\"", ",", "search", ",", "'str'", ")", "if", "orderby", "is", "not", "None", ":", "query_parameters", "[", "'$orderby'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"orderby\"", ",", "orderby", ",", "'str'", ")", "if", "select", "is", "not", "None", ":", "query_parameters", "[", "'$select'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"select\"", ",", "select", ",", "'str'", ")", "if", "skip", "is", "not", "None", ":", "query_parameters", "[", "'$skip'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"skip\"", ",", "skip", ",", "'int'", ")", "if", "top", "is", "not", "None", ":", "query_parameters", "[", "'$top'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"top\"", ",", "top", ",", "'int'", ")", "if", "format", "is", "not", "None", ":", "query_parameters", "[", "'$format'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"format\"", ",", "format", ",", "'str'", ")", "if", "count", "is", "not", "None", ":", "query_parameters", "[", "'$count'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"count\"", ",", "count", ",", "'bool'", ")", "if", "apply", "is", "not", "None", ":", "query_parameters", "[", "'$apply'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"apply\"", ",", "apply", ",", "'str'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "get", "(", "url", ",", "query_parameters", ",", "header_parameters", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "ErrorResponseException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'EventsResults'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
LargeFaceListOperations.add_face_from_stream
Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. :param large_face_list_id: Id referencing a particular large face list. :type large_face_list_id: str :param image: An image stream. :type image: Generator :param user_data: User-specified data about the face for any purpose. The maximum length is 1KB. :type user_data: str :param target_face: A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. :type target_face: list[int] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param callback: When specified, will be called with each chunk of data that is streamed. The callback should take two arguments, the bytes of the current chunk of data and the response object. If the data is uploading, response will be None. :type callback: Callable[Bytes, response=None] :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: PersistedFace or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.vision.face.models.PersistedFace or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>`
azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_face_list_operations.py
def add_face_from_stream( self, large_face_list_id, image, user_data=None, target_face=None, custom_headers=None, raw=False, callback=None, **operation_config): """Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. :param large_face_list_id: Id referencing a particular large face list. :type large_face_list_id: str :param image: An image stream. :type image: Generator :param user_data: User-specified data about the face for any purpose. The maximum length is 1KB. :type user_data: str :param target_face: A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. :type target_face: list[int] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param callback: When specified, will be called with each chunk of data that is streamed. The callback should take two arguments, the bytes of the current chunk of data and the response object. If the data is uploading, response will be None. :type callback: Callable[Bytes, response=None] :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: PersistedFace or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.vision.face.models.PersistedFace or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>` """ # Construct URL url = self.add_face_from_stream.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if user_data is not None: query_parameters['userData'] = self._serialize.query("user_data", user_data, 'str', max_length=1024) if target_face is not None: query_parameters['targetFace'] = self._serialize.query("target_face", target_face, '[int]', div=',') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._client.stream_upload(image, callback) # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('PersistedFace', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def add_face_from_stream( self, large_face_list_id, image, user_data=None, target_face=None, custom_headers=None, raw=False, callback=None, **operation_config): """Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. :param large_face_list_id: Id referencing a particular large face list. :type large_face_list_id: str :param image: An image stream. :type image: Generator :param user_data: User-specified data about the face for any purpose. The maximum length is 1KB. :type user_data: str :param target_face: A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. :type target_face: list[int] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param callback: When specified, will be called with each chunk of data that is streamed. The callback should take two arguments, the bytes of the current chunk of data and the response object. If the data is uploading, response will be None. :type callback: Callable[Bytes, response=None] :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: PersistedFace or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.vision.face.models.PersistedFace or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>` """ # Construct URL url = self.add_face_from_stream.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if user_data is not None: query_parameters['userData'] = self._serialize.query("user_data", user_data, 'str', max_length=1024) if target_face is not None: query_parameters['targetFace'] = self._serialize.query("target_face", target_face, '[int]', div=',') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._client.stream_upload(image, callback) # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('PersistedFace', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Add", "a", "face", "to", "a", "large", "face", "list", ".", "The", "input", "face", "is", "specified", "as", "an", "image", "with", "a", "targetFace", "rectangle", ".", "It", "returns", "a", "persistedFaceId", "representing", "the", "added", "face", "and", "persistedFaceId", "will", "not", "expire", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_face_list_operations.py#L778-L855
[ "def", "add_face_from_stream", "(", "self", ",", "large_face_list_id", ",", "image", ",", "user_data", "=", "None", ",", "target_face", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "callback", "=", "None", ",", "*", "*", "operation_config", ")", ":", "# Construct URL", "url", "=", "self", ".", "add_face_from_stream", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'Endpoint'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.endpoint\"", ",", "self", ".", "config", ".", "endpoint", ",", "'str'", ",", "skip_quote", "=", "True", ")", ",", "'largeFaceListId'", ":", "self", ".", "_serialize", ".", "url", "(", "\"large_face_list_id\"", ",", "large_face_list_id", ",", "'str'", ",", "max_length", "=", "64", ",", "pattern", "=", "r'^[a-z0-9-_]+$'", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "if", "user_data", "is", "not", "None", ":", "query_parameters", "[", "'userData'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"user_data\"", ",", "user_data", ",", "'str'", ",", "max_length", "=", "1024", ")", "if", "target_face", "is", "not", "None", ":", "query_parameters", "[", "'targetFace'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"target_face\"", ",", "target_face", ",", "'[int]'", ",", "div", "=", "','", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/octet-stream'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct body", "body_content", "=", "self", ".", "_client", ".", "stream_upload", "(", "image", ",", "callback", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ",", "header_parameters", ",", "body_content", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "APIErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'PersistedFace'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
KeyVaultAuthBase._handle_redirect
Reset auth_attempted on redirects.
azure-keyvault/azure/keyvault/key_vault_authentication.py
def _handle_redirect(self, r, **kwargs): """Reset auth_attempted on redirects.""" if r.is_redirect: self._thread_local.auth_attempted = False
def _handle_redirect(self, r, **kwargs): """Reset auth_attempted on redirects.""" if r.is_redirect: self._thread_local.auth_attempted = False
[ "Reset", "auth_attempted", "on", "redirects", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-keyvault/azure/keyvault/key_vault_authentication.py#L93-L96
[ "def", "_handle_redirect", "(", "self", ",", "r", ",", "*", "*", "kwargs", ")", ":", "if", "r", ".", "is_redirect", ":", "self", ".", "_thread_local", ".", "auth_attempted", "=", "False" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
KeyVaultAuthBase._handle_401
Takes the response authenticates and resends if neccissary :return: The final response to the authenticated request :rtype: requests.Response
azure-keyvault/azure/keyvault/key_vault_authentication.py
def _handle_401(self, response, **kwargs): """ Takes the response authenticates and resends if neccissary :return: The final response to the authenticated request :rtype: requests.Response """ # If response is not 401 do not auth and return response if not response.status_code == 401: self._thread_local.auth_attempted = False return response # If we've already attempted to auth for this request once, do not auth and return response if self._thread_local.auth_attempted: self._thread_local.auth_attempted = False return response auth_header = response.headers.get('www-authenticate', '') # Otherwise authenticate and retry the request self._thread_local.auth_attempted = True # parse the challenge challenge = HttpChallenge(response.request.url, auth_header, response.headers) # bearer and PoP are the only authentication schemes supported at this time # if the response auth header is not a bearer challenge or pop challange do not auth and return response if not (challenge.is_bearer_challenge() or challenge.is_pop_challenge()): self._thread_local.auth_attempted = False return response # add the challenge to the cache ChallengeCache.set_challenge_for_url(response.request.url, challenge) # Consume content and release the original connection # to allow our new request to reuse the same one. response.content response.close() # copy the request to resend prep = response.request.copy() if self._thread_local.orig_body is not None: # replace the body with the saved body prep.prepare_body(data=self._thread_local.orig_body, files=None) extract_cookies_to_jar(prep._cookies, response.request, response.raw) prep.prepare_cookies(prep._cookies) security = self._get_message_security(prep, challenge) # auth and protect the prepped request message security.protect_request(prep) # resend the request with proper authentication and message protection _response = response.connection.send(prep, **kwargs) _response.history.append(response) _response.request = prep # unprotected the response security.unprotect_response(_response) return _response
def _handle_401(self, response, **kwargs): """ Takes the response authenticates and resends if neccissary :return: The final response to the authenticated request :rtype: requests.Response """ # If response is not 401 do not auth and return response if not response.status_code == 401: self._thread_local.auth_attempted = False return response # If we've already attempted to auth for this request once, do not auth and return response if self._thread_local.auth_attempted: self._thread_local.auth_attempted = False return response auth_header = response.headers.get('www-authenticate', '') # Otherwise authenticate and retry the request self._thread_local.auth_attempted = True # parse the challenge challenge = HttpChallenge(response.request.url, auth_header, response.headers) # bearer and PoP are the only authentication schemes supported at this time # if the response auth header is not a bearer challenge or pop challange do not auth and return response if not (challenge.is_bearer_challenge() or challenge.is_pop_challenge()): self._thread_local.auth_attempted = False return response # add the challenge to the cache ChallengeCache.set_challenge_for_url(response.request.url, challenge) # Consume content and release the original connection # to allow our new request to reuse the same one. response.content response.close() # copy the request to resend prep = response.request.copy() if self._thread_local.orig_body is not None: # replace the body with the saved body prep.prepare_body(data=self._thread_local.orig_body, files=None) extract_cookies_to_jar(prep._cookies, response.request, response.raw) prep.prepare_cookies(prep._cookies) security = self._get_message_security(prep, challenge) # auth and protect the prepped request message security.protect_request(prep) # resend the request with proper authentication and message protection _response = response.connection.send(prep, **kwargs) _response.history.append(response) _response.request = prep # unprotected the response security.unprotect_response(_response) return _response
[ "Takes", "the", "response", "authenticates", "and", "resends", "if", "neccissary", ":", "return", ":", "The", "final", "response", "to", "the", "authenticated", "request", ":", "rtype", ":", "requests", ".", "Response" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-keyvault/azure/keyvault/key_vault_authentication.py#L98-L159
[ "def", "_handle_401", "(", "self", ",", "response", ",", "*", "*", "kwargs", ")", ":", "# If response is not 401 do not auth and return response", "if", "not", "response", ".", "status_code", "==", "401", ":", "self", ".", "_thread_local", ".", "auth_attempted", "=", "False", "return", "response", "# If we've already attempted to auth for this request once, do not auth and return response", "if", "self", ".", "_thread_local", ".", "auth_attempted", ":", "self", ".", "_thread_local", ".", "auth_attempted", "=", "False", "return", "response", "auth_header", "=", "response", ".", "headers", ".", "get", "(", "'www-authenticate'", ",", "''", ")", "# Otherwise authenticate and retry the request", "self", ".", "_thread_local", ".", "auth_attempted", "=", "True", "# parse the challenge", "challenge", "=", "HttpChallenge", "(", "response", ".", "request", ".", "url", ",", "auth_header", ",", "response", ".", "headers", ")", "# bearer and PoP are the only authentication schemes supported at this time", "# if the response auth header is not a bearer challenge or pop challange do not auth and return response", "if", "not", "(", "challenge", ".", "is_bearer_challenge", "(", ")", "or", "challenge", ".", "is_pop_challenge", "(", ")", ")", ":", "self", ".", "_thread_local", ".", "auth_attempted", "=", "False", "return", "response", "# add the challenge to the cache", "ChallengeCache", ".", "set_challenge_for_url", "(", "response", ".", "request", ".", "url", ",", "challenge", ")", "# Consume content and release the original connection", "# to allow our new request to reuse the same one.", "response", ".", "content", "response", ".", "close", "(", ")", "# copy the request to resend", "prep", "=", "response", ".", "request", ".", "copy", "(", ")", "if", "self", ".", "_thread_local", ".", "orig_body", "is", "not", "None", ":", "# replace the body with the saved body", "prep", ".", "prepare_body", "(", "data", "=", "self", ".", "_thread_local", ".", "orig_body", ",", "files", "=", "None", ")", "extract_cookies_to_jar", "(", "prep", ".", "_cookies", ",", "response", ".", "request", ",", "response", ".", "raw", ")", "prep", ".", "prepare_cookies", "(", "prep", ".", "_cookies", ")", "security", "=", "self", ".", "_get_message_security", "(", "prep", ",", "challenge", ")", "# auth and protect the prepped request message", "security", ".", "protect_request", "(", "prep", ")", "# resend the request with proper authentication and message protection", "_response", "=", "response", ".", "connection", ".", "send", "(", "prep", ",", "*", "*", "kwargs", ")", "_response", ".", "history", ".", "append", "(", "response", ")", "_response", ".", "request", "=", "prep", "# unprotected the response", "security", ".", "unprotect_response", "(", "_response", ")", "return", "_response" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
MigrationConfigsOperations.create_and_start_migration
Creates Migration configuration and starts migration of entities from Standard to Premium namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name :type namespace_name: str :param target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration :type target_namespace: str :param post_migration_name: Name to access Standard Namespace after migration :type post_migration_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns MigrationConfigProperties or ClientRawResponse<MigrationConfigProperties> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.servicebus.models.MigrationConfigProperties] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.servicebus.models.MigrationConfigProperties]] :raises: :class:`ErrorResponseException<azure.mgmt.servicebus.models.ErrorResponseException>`
azure-mgmt-servicebus/azure/mgmt/servicebus/operations/migration_configs_operations.py
def create_and_start_migration( self, resource_group_name, namespace_name, target_namespace, post_migration_name, custom_headers=None, raw=False, polling=True, **operation_config): """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name :type namespace_name: str :param target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration :type target_namespace: str :param post_migration_name: Name to access Standard Namespace after migration :type post_migration_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns MigrationConfigProperties or ClientRawResponse<MigrationConfigProperties> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.servicebus.models.MigrationConfigProperties] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.servicebus.models.MigrationConfigProperties]] :raises: :class:`ErrorResponseException<azure.mgmt.servicebus.models.ErrorResponseException>` """ raw_result = self._create_and_start_migration_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, target_namespace=target_namespace, post_migration_name=post_migration_name, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('MigrationConfigProperties', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def create_and_start_migration( self, resource_group_name, namespace_name, target_namespace, post_migration_name, custom_headers=None, raw=False, polling=True, **operation_config): """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name :type namespace_name: str :param target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration :type target_namespace: str :param post_migration_name: Name to access Standard Namespace after migration :type post_migration_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns MigrationConfigProperties or ClientRawResponse<MigrationConfigProperties> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.servicebus.models.MigrationConfigProperties] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.servicebus.models.MigrationConfigProperties]] :raises: :class:`ErrorResponseException<azure.mgmt.servicebus.models.ErrorResponseException>` """ raw_result = self._create_and_start_migration_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, target_namespace=target_namespace, post_migration_name=post_migration_name, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('MigrationConfigProperties', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Creates", "Migration", "configuration", "and", "starts", "migration", "of", "entities", "from", "Standard", "to", "Premium", "namespace", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-servicebus/azure/mgmt/servicebus/operations/migration_configs_operations.py#L164-L220
[ "def", "create_and_start_migration", "(", "self", ",", "resource_group_name", ",", "namespace_name", ",", "target_namespace", ",", "post_migration_name", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_create_and_start_migration_initial", "(", "resource_group_name", "=", "resource_group_name", ",", "namespace_name", "=", "namespace_name", ",", "target_namespace", "=", "target_namespace", ",", "post_migration_name", "=", "post_migration_name", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'MigrationConfigProperties'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
EventGridClient.publish_events
Publishes a batch of events to an Azure Event Grid topic. :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net :type topic_hostname: str :param events: An array of events to be published to Event Grid. :type events: list[~azure.eventgrid.models.EventGridEvent] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
azure-eventgrid/azure/eventgrid/event_grid_client.py
def publish_events( self, topic_hostname, events, custom_headers=None, raw=False, **operation_config): """Publishes a batch of events to an Azure Event Grid topic. :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net :type topic_hostname: str :param events: An array of events to be published to Event Grid. :type events: list[~azure.eventgrid.models.EventGridEvent] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.publish_events.metadata['url'] path_format_arguments = { 'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(events, '[EventGridEvent]') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
def publish_events( self, topic_hostname, events, custom_headers=None, raw=False, **operation_config): """Publishes a batch of events to an Azure Event Grid topic. :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net :type topic_hostname: str :param events: An array of events to be published to Event Grid. :type events: list[~azure.eventgrid.models.EventGridEvent] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.publish_events.metadata['url'] path_format_arguments = { 'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(events, '[EventGridEvent]') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
[ "Publishes", "a", "batch", "of", "events", "to", "an", "Azure", "Event", "Grid", "topic", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-eventgrid/azure/eventgrid/event_grid_client.py#L67-L116
[ "def", "publish_events", "(", "self", ",", "topic_hostname", ",", "events", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "# Construct URL", "url", "=", "self", ".", "publish_events", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'topicHostname'", ":", "self", ".", "_serialize", ".", "url", "(", "\"topic_hostname\"", ",", "topic_hostname", ",", "'str'", ",", "skip_quote", "=", "True", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"self.api_version\"", ",", "self", ".", "api_version", ",", "'str'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "events", ",", "'[EventGridEvent]'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "header_parameters", ",", "body_content", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "HttpOperationError", "(", "self", ".", "_deserialize", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "return", "client_raw_response" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ResourcesOperations.move_resources
Moves resources from one resource group to another resource group. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. . :param source_resource_group_name: The name of the resource group containing the resources to move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/resources_operations.py
def move_resources( self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): """Moves resources from one resource group to another resource group. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. . :param source_resource_group_name: The name of the resource group containing the resources to move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def move_resources( self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): """Moves resources from one resource group to another resource group. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. . :param source_resource_group_name: The name of the resource group containing the resources to move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Moves", "resources", "from", "one", "resource", "group", "to", "another", "resource", "group", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/resources_operations.py#L185-L233
[ "def", "move_resources", "(", "self", ",", "source_resource_group_name", ",", "resources", "=", "None", ",", "target_resource_group", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_move_resources_initial", "(", "source_resource_group_name", "=", "source_resource_group_name", ",", "resources", "=", "resources", ",", "target_resource_group", "=", "target_resource_group", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "return", "client_raw_response", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ContainerServiceClient.models
Module depends on the API version: * 2017-07-01: :mod:`v2017_07_01.models<azure.mgmt.containerservice.v2017_07_01.models>` * 2018-03-31: :mod:`v2018_03_31.models<azure.mgmt.containerservice.v2018_03_31.models>` * 2018-08-01-preview: :mod:`v2018_08_01_preview.models<azure.mgmt.containerservice.v2018_08_01_preview.models>` * 2018-09-30-preview: :mod:`v2018_09_30_preview.models<azure.mgmt.containerservice.v2018_09_30_preview.models>` * 2019-02-01: :mod:`v2019_02_01.models<azure.mgmt.containerservice.v2019_02_01.models>`
azure-mgmt-containerservice/azure/mgmt/containerservice/container_service_client.py
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2017-07-01: :mod:`v2017_07_01.models<azure.mgmt.containerservice.v2017_07_01.models>` * 2018-03-31: :mod:`v2018_03_31.models<azure.mgmt.containerservice.v2018_03_31.models>` * 2018-08-01-preview: :mod:`v2018_08_01_preview.models<azure.mgmt.containerservice.v2018_08_01_preview.models>` * 2018-09-30-preview: :mod:`v2018_09_30_preview.models<azure.mgmt.containerservice.v2018_09_30_preview.models>` * 2019-02-01: :mod:`v2019_02_01.models<azure.mgmt.containerservice.v2019_02_01.models>` """ if api_version == '2017-07-01': from .v2017_07_01 import models return models elif api_version == '2018-03-31': from .v2018_03_31 import models return models elif api_version == '2018-08-01-preview': from .v2018_08_01_preview import models return models elif api_version == '2018-09-30-preview': from .v2018_09_30_preview import models return models elif api_version == '2019-02-01': from .v2019_02_01 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2017-07-01: :mod:`v2017_07_01.models<azure.mgmt.containerservice.v2017_07_01.models>` * 2018-03-31: :mod:`v2018_03_31.models<azure.mgmt.containerservice.v2018_03_31.models>` * 2018-08-01-preview: :mod:`v2018_08_01_preview.models<azure.mgmt.containerservice.v2018_08_01_preview.models>` * 2018-09-30-preview: :mod:`v2018_09_30_preview.models<azure.mgmt.containerservice.v2018_09_30_preview.models>` * 2019-02-01: :mod:`v2019_02_01.models<azure.mgmt.containerservice.v2019_02_01.models>` """ if api_version == '2017-07-01': from .v2017_07_01 import models return models elif api_version == '2018-03-31': from .v2018_03_31 import models return models elif api_version == '2018-08-01-preview': from .v2018_08_01_preview import models return models elif api_version == '2018-09-30-preview': from .v2018_09_30_preview import models return models elif api_version == '2019-02-01': from .v2019_02_01 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
[ "Module", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-containerservice/azure/mgmt/containerservice/container_service_client.py#L102-L126
[ "def", "models", "(", "cls", ",", "api_version", "=", "DEFAULT_API_VERSION", ")", ":", "if", "api_version", "==", "'2017-07-01'", ":", "from", ".", "v2017_07_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-03-31'", ":", "from", ".", "v2018_03_31", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-08-01-preview'", ":", "from", ".", "v2018_08_01_preview", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-09-30-preview'", ":", "from", ".", "v2018_09_30_preview", "import", "models", "return", "models", "elif", "api_version", "==", "'2019-02-01'", ":", "from", ".", "v2019_02_01", "import", "models", "return", "models", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ContainerServiceClient.agent_pools
Instance depends on the API version: * 2019-02-01: :class:`AgentPoolsOperations<azure.mgmt.containerservice.v2019_02_01.operations.AgentPoolsOperations>`
azure-mgmt-containerservice/azure/mgmt/containerservice/container_service_client.py
def agent_pools(self): """Instance depends on the API version: * 2019-02-01: :class:`AgentPoolsOperations<azure.mgmt.containerservice.v2019_02_01.operations.AgentPoolsOperations>` """ api_version = self._get_api_version('agent_pools') if api_version == '2019-02-01': from .v2019_02_01.operations import AgentPoolsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def agent_pools(self): """Instance depends on the API version: * 2019-02-01: :class:`AgentPoolsOperations<azure.mgmt.containerservice.v2019_02_01.operations.AgentPoolsOperations>` """ api_version = self._get_api_version('agent_pools') if api_version == '2019-02-01': from .v2019_02_01.operations import AgentPoolsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-containerservice/azure/mgmt/containerservice/container_service_client.py#L129-L139
[ "def", "agent_pools", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'agent_pools'", ")", "if", "api_version", "==", "'2019-02-01'", ":", "from", ".", "v2019_02_01", ".", "operations", "import", "AgentPoolsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ContainerServiceClient.container_services
Instance depends on the API version: * 2017-07-01: :class:`ContainerServicesOperations<azure.mgmt.containerservice.v2017_07_01.operations.ContainerServicesOperations>`
azure-mgmt-containerservice/azure/mgmt/containerservice/container_service_client.py
def container_services(self): """Instance depends on the API version: * 2017-07-01: :class:`ContainerServicesOperations<azure.mgmt.containerservice.v2017_07_01.operations.ContainerServicesOperations>` """ api_version = self._get_api_version('container_services') if api_version == '2017-07-01': from .v2017_07_01.operations import ContainerServicesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def container_services(self): """Instance depends on the API version: * 2017-07-01: :class:`ContainerServicesOperations<azure.mgmt.containerservice.v2017_07_01.operations.ContainerServicesOperations>` """ api_version = self._get_api_version('container_services') if api_version == '2017-07-01': from .v2017_07_01.operations import ContainerServicesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-containerservice/azure/mgmt/containerservice/container_service_client.py#L142-L152
[ "def", "container_services", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'container_services'", ")", "if", "api_version", "==", "'2017-07-01'", ":", "from", ".", "v2017_07_01", ".", "operations", "import", "ContainerServicesOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ContainerServiceClient.open_shift_managed_clusters
Instance depends on the API version: * 2018-09-30-preview: :class:`OpenShiftManagedClustersOperations<azure.mgmt.containerservice.v2018_09_30_preview.operations.OpenShiftManagedClustersOperations>`
azure-mgmt-containerservice/azure/mgmt/containerservice/container_service_client.py
def open_shift_managed_clusters(self): """Instance depends on the API version: * 2018-09-30-preview: :class:`OpenShiftManagedClustersOperations<azure.mgmt.containerservice.v2018_09_30_preview.operations.OpenShiftManagedClustersOperations>` """ api_version = self._get_api_version('open_shift_managed_clusters') if api_version == '2018-09-30-preview': from .v2018_09_30_preview.operations import OpenShiftManagedClustersOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def open_shift_managed_clusters(self): """Instance depends on the API version: * 2018-09-30-preview: :class:`OpenShiftManagedClustersOperations<azure.mgmt.containerservice.v2018_09_30_preview.operations.OpenShiftManagedClustersOperations>` """ api_version = self._get_api_version('open_shift_managed_clusters') if api_version == '2018-09-30-preview': from .v2018_09_30_preview.operations import OpenShiftManagedClustersOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-containerservice/azure/mgmt/containerservice/container_service_client.py#L174-L184
[ "def", "open_shift_managed_clusters", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'open_shift_managed_clusters'", ")", "if", "api_version", "==", "'2018-09-30-preview'", ":", "from", ".", "v2018_09_30_preview", ".", "operations", "import", "OpenShiftManagedClustersOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ContainerServiceClient.operations
Instance depends on the API version: * 2018-03-31: :class:`Operations<azure.mgmt.containerservice.v2018_03_31.operations.Operations>` * 2018-08-01-preview: :class:`Operations<azure.mgmt.containerservice.v2018_08_01_preview.operations.Operations>` * 2019-02-01: :class:`Operations<azure.mgmt.containerservice.v2019_02_01.operations.Operations>`
azure-mgmt-containerservice/azure/mgmt/containerservice/container_service_client.py
def operations(self): """Instance depends on the API version: * 2018-03-31: :class:`Operations<azure.mgmt.containerservice.v2018_03_31.operations.Operations>` * 2018-08-01-preview: :class:`Operations<azure.mgmt.containerservice.v2018_08_01_preview.operations.Operations>` * 2019-02-01: :class:`Operations<azure.mgmt.containerservice.v2019_02_01.operations.Operations>` """ api_version = self._get_api_version('operations') if api_version == '2018-03-31': from .v2018_03_31.operations import Operations as OperationClass elif api_version == '2018-08-01-preview': from .v2018_08_01_preview.operations import Operations as OperationClass elif api_version == '2019-02-01': from .v2019_02_01.operations import Operations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def operations(self): """Instance depends on the API version: * 2018-03-31: :class:`Operations<azure.mgmt.containerservice.v2018_03_31.operations.Operations>` * 2018-08-01-preview: :class:`Operations<azure.mgmt.containerservice.v2018_08_01_preview.operations.Operations>` * 2019-02-01: :class:`Operations<azure.mgmt.containerservice.v2019_02_01.operations.Operations>` """ api_version = self._get_api_version('operations') if api_version == '2018-03-31': from .v2018_03_31.operations import Operations as OperationClass elif api_version == '2018-08-01-preview': from .v2018_08_01_preview.operations import Operations as OperationClass elif api_version == '2019-02-01': from .v2019_02_01.operations import Operations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-containerservice/azure/mgmt/containerservice/container_service_client.py#L187-L203
[ "def", "operations", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'operations'", ")", "if", "api_version", "==", "'2018-03-31'", ":", "from", ".", "v2018_03_31", ".", "operations", "import", "Operations", "as", "OperationClass", "elif", "api_version", "==", "'2018-08-01-preview'", ":", "from", ".", "v2018_08_01_preview", ".", "operations", "import", "Operations", "as", "OperationClass", "elif", "api_version", "==", "'2019-02-01'", ":", "from", ".", "v2019_02_01", ".", "operations", "import", "Operations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
DefaultProfile.use
Define a new default profile.
azure-common/azure/profiles/__init__.py
def use(self, profile): """Define a new default profile.""" if not isinstance(profile, (KnownProfiles, ProfileDefinition)): raise ValueError("Can only set as default a ProfileDefinition or a KnownProfiles") type(self).profile = profile
def use(self, profile): """Define a new default profile.""" if not isinstance(profile, (KnownProfiles, ProfileDefinition)): raise ValueError("Can only set as default a ProfileDefinition or a KnownProfiles") type(self).profile = profile
[ "Define", "a", "new", "default", "profile", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-common/azure/profiles/__init__.py#L47-L51
[ "def", "use", "(", "self", ",", "profile", ")", ":", "if", "not", "isinstance", "(", "profile", ",", "(", "KnownProfiles", ",", "ProfileDefinition", ")", ")", ":", "raise", "ValueError", "(", "\"Can only set as default a ProfileDefinition or a KnownProfiles\"", ")", "type", "(", "self", ")", ".", "profile", "=", "profile" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
PolicyTrackedResourcesOperations.list_query_results_for_management_group
Queries policy tracked resources under the management group. :param management_group_name: Management group name. :type management_group_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of PolicyTrackedResource :rtype: ~azure.mgmt.policyinsights.models.PolicyTrackedResourcePaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] :raises: :class:`QueryFailureException<azure.mgmt.policyinsights.models.QueryFailureException>`
azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_tracked_resources_operations.py
def list_query_results_for_management_group( self, management_group_name, query_options=None, custom_headers=None, raw=False, **operation_config): """Queries policy tracked resources under the management group. :param management_group_name: Management group name. :type management_group_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of PolicyTrackedResource :rtype: ~azure.mgmt.policyinsights.models.PolicyTrackedResourcePaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] :raises: :class:`QueryFailureException<azure.mgmt.policyinsights.models.QueryFailureException>` """ top = None if query_options is not None: top = query_options.top filter = None if query_options is not None: filter = query_options.filter def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.list_query_results_for_management_group.metadata['url'] path_format_arguments = { 'managementGroupsNamespace': self._serialize.url("self.management_groups_namespace", self.management_groups_namespace, 'str'), 'managementGroupName': self._serialize.url("management_group_name", management_group_name, 'str'), 'policyTrackedResourcesResource': self._serialize.url("self.policy_tracked_resources_resource", self.policy_tracked_resources_resource, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.QueryFailureException(self._deserialize, response) return response # Deserialize response deserialized = models.PolicyTrackedResourcePaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.PolicyTrackedResourcePaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
def list_query_results_for_management_group( self, management_group_name, query_options=None, custom_headers=None, raw=False, **operation_config): """Queries policy tracked resources under the management group. :param management_group_name: Management group name. :type management_group_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of PolicyTrackedResource :rtype: ~azure.mgmt.policyinsights.models.PolicyTrackedResourcePaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] :raises: :class:`QueryFailureException<azure.mgmt.policyinsights.models.QueryFailureException>` """ top = None if query_options is not None: top = query_options.top filter = None if query_options is not None: filter = query_options.filter def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.list_query_results_for_management_group.metadata['url'] path_format_arguments = { 'managementGroupsNamespace': self._serialize.url("self.management_groups_namespace", self.management_groups_namespace, 'str'), 'managementGroupName': self._serialize.url("management_group_name", management_group_name, 'str'), 'policyTrackedResourcesResource': self._serialize.url("self.policy_tracked_resources_resource", self.policy_tracked_resources_resource, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.QueryFailureException(self._deserialize, response) return response # Deserialize response deserialized = models.PolicyTrackedResourcePaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.PolicyTrackedResourcePaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
[ "Queries", "policy", "tracked", "resources", "under", "the", "management", "group", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_tracked_resources_operations.py#L43-L120
[ "def", "list_query_results_for_management_group", "(", "self", ",", "management_group_name", ",", "query_options", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "top", "=", "None", "if", "query_options", "is", "not", "None", ":", "top", "=", "query_options", ".", "top", "filter", "=", "None", "if", "query_options", "is", "not", "None", ":", "filter", "=", "query_options", ".", "filter", "def", "internal_paging", "(", "next_link", "=", "None", ",", "raw", "=", "False", ")", ":", "if", "not", "next_link", ":", "# Construct URL", "url", "=", "self", ".", "list_query_results_for_management_group", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'managementGroupsNamespace'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.management_groups_namespace\"", ",", "self", ".", "management_groups_namespace", ",", "'str'", ")", ",", "'managementGroupName'", ":", "self", ".", "_serialize", ".", "url", "(", "\"management_group_name\"", ",", "management_group_name", ",", "'str'", ")", ",", "'policyTrackedResourcesResource'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.policy_tracked_resources_resource\"", ",", "self", ".", "policy_tracked_resources_resource", ",", "'str'", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"self.api_version\"", ",", "self", ".", "api_version", ",", "'str'", ")", "if", "top", "is", "not", "None", ":", "query_parameters", "[", "'$top'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"top\"", ",", "top", ",", "'int'", ",", "minimum", "=", "0", ")", "if", "filter", "is", "not", "None", ":", "query_parameters", "[", "'$filter'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"filter\"", ",", "filter", ",", "'str'", ")", "else", ":", "url", "=", "next_link", "query_parameters", "=", "{", "}", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "if", "self", ".", "config", ".", "generate_client_request_id", ":", "header_parameters", "[", "'x-ms-client-request-id'", "]", "=", "str", "(", "uuid", ".", "uuid1", "(", ")", ")", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "if", "self", ".", "config", ".", "accept_language", "is", "not", "None", ":", "header_parameters", "[", "'accept-language'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"self.config.accept_language\"", ",", "self", ".", "config", ".", "accept_language", ",", "'str'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ",", "header_parameters", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "QueryFailureException", "(", "self", ".", "_deserialize", ",", "response", ")", "return", "response", "# Deserialize response", "deserialized", "=", "models", ".", "PolicyTrackedResourcePaged", "(", "internal_paging", ",", "self", ".", "_deserialize", ".", "dependencies", ")", "if", "raw", ":", "header_dict", "=", "{", "}", "client_raw_response", "=", "models", ".", "PolicyTrackedResourcePaged", "(", "internal_paging", ",", "self", ".", "_deserialize", ".", "dependencies", ",", "header_dict", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
Sender.send
Send a message and blocks until acknowledgement is received or the operation fails. :param message: The message to be sent. :type message: ~azure.servicebus.common.message.Message :raises: ~azure.servicebus.common.errors.MessageSendFailed if the message fails to send. Example: .. literalinclude:: ../examples/test_examples.py :start-after: [START send_message] :end-before: [END send_message] :language: python :dedent: 4 :caption: Send a message and block
azure-servicebus/azure/servicebus/send_handler.py
def send(self, message): """Send a message and blocks until acknowledgement is received or the operation fails. :param message: The message to be sent. :type message: ~azure.servicebus.common.message.Message :raises: ~azure.servicebus.common.errors.MessageSendFailed if the message fails to send. Example: .. literalinclude:: ../examples/test_examples.py :start-after: [START send_message] :end-before: [END send_message] :language: python :dedent: 4 :caption: Send a message and block """ if not isinstance(message, Message): raise TypeError("Value of message must be of type 'Message'.") if not self.running: self.open() if self.session_id and not message.properties.group_id: message.properties.group_id = self.session_id try: self._handler.send_message(message.message) except Exception as e: raise MessageSendFailed(e)
def send(self, message): """Send a message and blocks until acknowledgement is received or the operation fails. :param message: The message to be sent. :type message: ~azure.servicebus.common.message.Message :raises: ~azure.servicebus.common.errors.MessageSendFailed if the message fails to send. Example: .. literalinclude:: ../examples/test_examples.py :start-after: [START send_message] :end-before: [END send_message] :language: python :dedent: 4 :caption: Send a message and block """ if not isinstance(message, Message): raise TypeError("Value of message must be of type 'Message'.") if not self.running: self.open() if self.session_id and not message.properties.group_id: message.properties.group_id = self.session_id try: self._handler.send_message(message.message) except Exception as e: raise MessageSendFailed(e)
[ "Send", "a", "message", "and", "blocks", "until", "acknowledgement", "is", "received", "or", "the", "operation", "fails", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/send_handler.py#L82-L107
[ "def", "send", "(", "self", ",", "message", ")", ":", "if", "not", "isinstance", "(", "message", ",", "Message", ")", ":", "raise", "TypeError", "(", "\"Value of message must be of type 'Message'.\"", ")", "if", "not", "self", ".", "running", ":", "self", ".", "open", "(", ")", "if", "self", ".", "session_id", "and", "not", "message", ".", "properties", ".", "group_id", ":", "message", ".", "properties", ".", "group_id", "=", "self", ".", "session_id", "try", ":", "self", ".", "_handler", ".", "send_message", "(", "message", ".", "message", ")", "except", "Exception", "as", "e", ":", "raise", "MessageSendFailed", "(", "e", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
SessionSender.queue_message
Queue a message to be sent later. This operation should be followed up with send_pending_messages. If neither the Sender nor the message has a session ID, a `ValueError` will be raised. :param message: The message to be sent. :type message: ~azure.servicebus.Message Example: .. literalinclude:: ../examples/test_examples.py :start-after: [START queue_and_send_session_messages] :end-before: [END queue_and_send_session_messages] :language: python :dedent: 4 :caption: Put the message to be sent later in the queue
azure-servicebus/azure/servicebus/send_handler.py
def queue_message(self, message): """Queue a message to be sent later. This operation should be followed up with send_pending_messages. If neither the Sender nor the message has a session ID, a `ValueError` will be raised. :param message: The message to be sent. :type message: ~azure.servicebus.Message Example: .. literalinclude:: ../examples/test_examples.py :start-after: [START queue_and_send_session_messages] :end-before: [END queue_and_send_session_messages] :language: python :dedent: 4 :caption: Put the message to be sent later in the queue """ if not self.session_id and not message.properties.group_id: raise ValueError("Message must have Session ID.") super(SessionSender, self).queue_message(message)
def queue_message(self, message): """Queue a message to be sent later. This operation should be followed up with send_pending_messages. If neither the Sender nor the message has a session ID, a `ValueError` will be raised. :param message: The message to be sent. :type message: ~azure.servicebus.Message Example: .. literalinclude:: ../examples/test_examples.py :start-after: [START queue_and_send_session_messages] :end-before: [END queue_and_send_session_messages] :language: python :dedent: 4 :caption: Put the message to be sent later in the queue """ if not self.session_id and not message.properties.group_id: raise ValueError("Message must have Session ID.") super(SessionSender, self).queue_message(message)
[ "Queue", "a", "message", "to", "be", "sent", "later", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/send_handler.py#L269-L289
[ "def", "queue_message", "(", "self", ",", "message", ")", ":", "if", "not", "self", ".", "session_id", "and", "not", "message", ".", "properties", ".", "group_id", ":", "raise", "ValueError", "(", "\"Message must have Session ID.\"", ")", "super", "(", "SessionSender", ",", "self", ")", ".", "queue_message", "(", "message", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
SessionSender.schedule
Send one or more messages to be enqueued at a specific time. Returns a list of the sequence numbers of the enqueued messages. :param schedule_time: The date and time to enqueue the messages. :type schedule_time: ~datetime.datetime :param messages: The messages to schedule. :type messages: ~azure.servicebus.common.message.Message :rtype: list[int] Example: .. literalinclude:: ../examples/test_examples.py :start-after: [START scheduling_messages] :end-before: [END scheduling_messages] :language: python :dedent: 4 :caption: Schedule a message to be sent in future
azure-servicebus/azure/servicebus/send_handler.py
def schedule(self, schedule_time, *messages): """Send one or more messages to be enqueued at a specific time. Returns a list of the sequence numbers of the enqueued messages. :param schedule_time: The date and time to enqueue the messages. :type schedule_time: ~datetime.datetime :param messages: The messages to schedule. :type messages: ~azure.servicebus.common.message.Message :rtype: list[int] Example: .. literalinclude:: ../examples/test_examples.py :start-after: [START scheduling_messages] :end-before: [END scheduling_messages] :language: python :dedent: 4 :caption: Schedule a message to be sent in future """ for message in messages: if not self.session_id and not message.properties.group_id: raise ValueError("Message must have Session ID.") return super(SessionSender, self).schedule(schedule_time, *messages)
def schedule(self, schedule_time, *messages): """Send one or more messages to be enqueued at a specific time. Returns a list of the sequence numbers of the enqueued messages. :param schedule_time: The date and time to enqueue the messages. :type schedule_time: ~datetime.datetime :param messages: The messages to schedule. :type messages: ~azure.servicebus.common.message.Message :rtype: list[int] Example: .. literalinclude:: ../examples/test_examples.py :start-after: [START scheduling_messages] :end-before: [END scheduling_messages] :language: python :dedent: 4 :caption: Schedule a message to be sent in future """ for message in messages: if not self.session_id and not message.properties.group_id: raise ValueError("Message must have Session ID.") return super(SessionSender, self).schedule(schedule_time, *messages)
[ "Send", "one", "or", "more", "messages", "to", "be", "enqueued", "at", "a", "specific", "time", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/send_handler.py#L291-L314
[ "def", "schedule", "(", "self", ",", "schedule_time", ",", "*", "messages", ")", ":", "for", "message", "in", "messages", ":", "if", "not", "self", ".", "session_id", "and", "not", "message", ".", "properties", ".", "group_id", ":", "raise", "ValueError", "(", "\"Message must have Session ID.\"", ")", "return", "super", "(", "SessionSender", ",", "self", ")", ".", "schedule", "(", "schedule_time", ",", "*", "messages", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusMixin.create_queue
Create a queue entity. :param queue_name: The name of the new queue. :type queue_name: str :param lock_duration: The lock durection in seconds for each message in the queue. :type lock_duration: int :param max_size_in_megabytes: The max size to allow the queue to grow to. :type max_size_in_megabytes: int :param requires_duplicate_detection: Whether the queue will require every message with a specified time frame to have a unique ID. Non-unique messages will be discarded. Default value is False. :type requires_duplicate_detection: bool :param requires_session: Whether the queue will be sessionful, and therefore require all message to have a Session ID and be received by a sessionful receiver. Default value is False. :type requires_session: bool :param default_message_time_to_live: The length of time a message will remain in the queue before it is either discarded or moved to the dead letter queue. :type default_message_time_to_live: ~datetime.timedelta :param dead_lettering_on_message_expiration: Whether to move expired messages to the dead letter queue. Default value is False. :type dead_lettering_on_message_expiration: bool :param duplicate_detection_history_time_window: The period within which all incoming messages must have a unique message ID. :type duplicate_detection_history_time_window: ~datetime.timedelta :param max_delivery_count: The maximum number of times a message will attempt to be delivered before it is moved to the dead letter queue. :type max_delivery_count: int :param enable_batched_operations: :type: enable_batched_operations: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found. :raises: ~azure.common.AzureConflictHttpError if a queue of the same name already exists.
azure-servicebus/azure/servicebus/common/mixins.py
def create_queue( self, queue_name, lock_duration=30, max_size_in_megabytes=None, requires_duplicate_detection=False, requires_session=False, default_message_time_to_live=None, dead_lettering_on_message_expiration=False, duplicate_detection_history_time_window=None, max_delivery_count=None, enable_batched_operations=None): """Create a queue entity. :param queue_name: The name of the new queue. :type queue_name: str :param lock_duration: The lock durection in seconds for each message in the queue. :type lock_duration: int :param max_size_in_megabytes: The max size to allow the queue to grow to. :type max_size_in_megabytes: int :param requires_duplicate_detection: Whether the queue will require every message with a specified time frame to have a unique ID. Non-unique messages will be discarded. Default value is False. :type requires_duplicate_detection: bool :param requires_session: Whether the queue will be sessionful, and therefore require all message to have a Session ID and be received by a sessionful receiver. Default value is False. :type requires_session: bool :param default_message_time_to_live: The length of time a message will remain in the queue before it is either discarded or moved to the dead letter queue. :type default_message_time_to_live: ~datetime.timedelta :param dead_lettering_on_message_expiration: Whether to move expired messages to the dead letter queue. Default value is False. :type dead_lettering_on_message_expiration: bool :param duplicate_detection_history_time_window: The period within which all incoming messages must have a unique message ID. :type duplicate_detection_history_time_window: ~datetime.timedelta :param max_delivery_count: The maximum number of times a message will attempt to be delivered before it is moved to the dead letter queue. :type max_delivery_count: int :param enable_batched_operations: :type: enable_batched_operations: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found. :raises: ~azure.common.AzureConflictHttpError if a queue of the same name already exists. """ queue_properties = Queue( lock_duration="PT{}S".format(int(lock_duration)), max_size_in_megabytes=max_size_in_megabytes, requires_duplicate_detection=requires_duplicate_detection, requires_session=requires_session, default_message_time_to_live=default_message_time_to_live, dead_lettering_on_message_expiration=dead_lettering_on_message_expiration, duplicate_detection_history_time_window=duplicate_detection_history_time_window, max_delivery_count=max_delivery_count, enable_batched_operations=enable_batched_operations) try: return self.mgmt_client.create_queue(queue_name, queue=queue_properties, fail_on_exist=True) except requests.exceptions.ConnectionError as e: raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e)
def create_queue( self, queue_name, lock_duration=30, max_size_in_megabytes=None, requires_duplicate_detection=False, requires_session=False, default_message_time_to_live=None, dead_lettering_on_message_expiration=False, duplicate_detection_history_time_window=None, max_delivery_count=None, enable_batched_operations=None): """Create a queue entity. :param queue_name: The name of the new queue. :type queue_name: str :param lock_duration: The lock durection in seconds for each message in the queue. :type lock_duration: int :param max_size_in_megabytes: The max size to allow the queue to grow to. :type max_size_in_megabytes: int :param requires_duplicate_detection: Whether the queue will require every message with a specified time frame to have a unique ID. Non-unique messages will be discarded. Default value is False. :type requires_duplicate_detection: bool :param requires_session: Whether the queue will be sessionful, and therefore require all message to have a Session ID and be received by a sessionful receiver. Default value is False. :type requires_session: bool :param default_message_time_to_live: The length of time a message will remain in the queue before it is either discarded or moved to the dead letter queue. :type default_message_time_to_live: ~datetime.timedelta :param dead_lettering_on_message_expiration: Whether to move expired messages to the dead letter queue. Default value is False. :type dead_lettering_on_message_expiration: bool :param duplicate_detection_history_time_window: The period within which all incoming messages must have a unique message ID. :type duplicate_detection_history_time_window: ~datetime.timedelta :param max_delivery_count: The maximum number of times a message will attempt to be delivered before it is moved to the dead letter queue. :type max_delivery_count: int :param enable_batched_operations: :type: enable_batched_operations: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found. :raises: ~azure.common.AzureConflictHttpError if a queue of the same name already exists. """ queue_properties = Queue( lock_duration="PT{}S".format(int(lock_duration)), max_size_in_megabytes=max_size_in_megabytes, requires_duplicate_detection=requires_duplicate_detection, requires_session=requires_session, default_message_time_to_live=default_message_time_to_live, dead_lettering_on_message_expiration=dead_lettering_on_message_expiration, duplicate_detection_history_time_window=duplicate_detection_history_time_window, max_delivery_count=max_delivery_count, enable_batched_operations=enable_batched_operations) try: return self.mgmt_client.create_queue(queue_name, queue=queue_properties, fail_on_exist=True) except requests.exceptions.ConnectionError as e: raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e)
[ "Create", "a", "queue", "entity", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/mixins.py#L39-L94
[ "def", "create_queue", "(", "self", ",", "queue_name", ",", "lock_duration", "=", "30", ",", "max_size_in_megabytes", "=", "None", ",", "requires_duplicate_detection", "=", "False", ",", "requires_session", "=", "False", ",", "default_message_time_to_live", "=", "None", ",", "dead_lettering_on_message_expiration", "=", "False", ",", "duplicate_detection_history_time_window", "=", "None", ",", "max_delivery_count", "=", "None", ",", "enable_batched_operations", "=", "None", ")", ":", "queue_properties", "=", "Queue", "(", "lock_duration", "=", "\"PT{}S\"", ".", "format", "(", "int", "(", "lock_duration", ")", ")", ",", "max_size_in_megabytes", "=", "max_size_in_megabytes", ",", "requires_duplicate_detection", "=", "requires_duplicate_detection", ",", "requires_session", "=", "requires_session", ",", "default_message_time_to_live", "=", "default_message_time_to_live", ",", "dead_lettering_on_message_expiration", "=", "dead_lettering_on_message_expiration", ",", "duplicate_detection_history_time_window", "=", "duplicate_detection_history_time_window", ",", "max_delivery_count", "=", "max_delivery_count", ",", "enable_batched_operations", "=", "enable_batched_operations", ")", "try", ":", "return", "self", ".", "mgmt_client", ".", "create_queue", "(", "queue_name", ",", "queue", "=", "queue_properties", ",", "fail_on_exist", "=", "True", ")", "except", "requests", ".", "exceptions", ".", "ConnectionError", "as", "e", ":", "raise", "ServiceBusConnectionError", "(", "\"Namespace: {} not found\"", ".", "format", "(", "self", ".", "service_namespace", ")", ",", "e", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusMixin.delete_queue
Delete a queue entity. :param queue_name: The name of the queue to delete. :type queue_name: str :param fail_not_exist: Whether to raise an exception if the named queue is not found. If set to True, a ServiceBusResourceNotFound will be raised. Default value is False. :type fail_not_exist: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namesapce is not found. :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the queue is not found and `fail_not_exist` is set to True.
azure-servicebus/azure/servicebus/common/mixins.py
def delete_queue(self, queue_name, fail_not_exist=False): """Delete a queue entity. :param queue_name: The name of the queue to delete. :type queue_name: str :param fail_not_exist: Whether to raise an exception if the named queue is not found. If set to True, a ServiceBusResourceNotFound will be raised. Default value is False. :type fail_not_exist: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namesapce is not found. :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the queue is not found and `fail_not_exist` is set to True. """ try: return self.mgmt_client.delete_queue(queue_name, fail_not_exist=fail_not_exist) except requests.exceptions.ConnectionError as e: raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e) except azure.common.AzureMissingResourceHttpError as e: raise ServiceBusResourceNotFound("Specificed queue '{}' does not exist.".format(queue_name), e)
def delete_queue(self, queue_name, fail_not_exist=False): """Delete a queue entity. :param queue_name: The name of the queue to delete. :type queue_name: str :param fail_not_exist: Whether to raise an exception if the named queue is not found. If set to True, a ServiceBusResourceNotFound will be raised. Default value is False. :type fail_not_exist: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namesapce is not found. :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the queue is not found and `fail_not_exist` is set to True. """ try: return self.mgmt_client.delete_queue(queue_name, fail_not_exist=fail_not_exist) except requests.exceptions.ConnectionError as e: raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e) except azure.common.AzureMissingResourceHttpError as e: raise ServiceBusResourceNotFound("Specificed queue '{}' does not exist.".format(queue_name), e)
[ "Delete", "a", "queue", "entity", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/mixins.py#L96-L114
[ "def", "delete_queue", "(", "self", ",", "queue_name", ",", "fail_not_exist", "=", "False", ")", ":", "try", ":", "return", "self", ".", "mgmt_client", ".", "delete_queue", "(", "queue_name", ",", "fail_not_exist", "=", "fail_not_exist", ")", "except", "requests", ".", "exceptions", ".", "ConnectionError", "as", "e", ":", "raise", "ServiceBusConnectionError", "(", "\"Namespace: {} not found\"", ".", "format", "(", "self", ".", "service_namespace", ")", ",", "e", ")", "except", "azure", ".", "common", ".", "AzureMissingResourceHttpError", "as", "e", ":", "raise", "ServiceBusResourceNotFound", "(", "\"Specificed queue '{}' does not exist.\"", ".", "format", "(", "queue_name", ")", ",", "e", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusMixin.create_topic
Create a topic entity. :param topic_name: The name of the new topic. :type topic_name: str :param max_size_in_megabytes: The max size to allow the topic to grow to. :type max_size_in_megabytes: int :param requires_duplicate_detection: Whether the topic will require every message with a specified time frame to have a unique ID. Non-unique messages will be discarded. Default value is False. :type requires_duplicate_detection: bool :param default_message_time_to_live: The length of time a message will remain in the topic before it is either discarded or moved to the dead letter queue. :type default_message_time_to_live: ~datetime.timedelta :param duplicate_detection_history_time_window: The period within which all incoming messages must have a unique message ID. :type duplicate_detection_history_time_window: ~datetime.timedelta :param enable_batched_operations: :type: enable_batched_operations: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found. :raises: ~azure.common.AzureConflictHttpError if a topic of the same name already exists.
azure-servicebus/azure/servicebus/common/mixins.py
def create_topic( self, topic_name, default_message_time_to_live=None, max_size_in_megabytes=None, requires_duplicate_detection=None, duplicate_detection_history_time_window=None, enable_batched_operations=None): """Create a topic entity. :param topic_name: The name of the new topic. :type topic_name: str :param max_size_in_megabytes: The max size to allow the topic to grow to. :type max_size_in_megabytes: int :param requires_duplicate_detection: Whether the topic will require every message with a specified time frame to have a unique ID. Non-unique messages will be discarded. Default value is False. :type requires_duplicate_detection: bool :param default_message_time_to_live: The length of time a message will remain in the topic before it is either discarded or moved to the dead letter queue. :type default_message_time_to_live: ~datetime.timedelta :param duplicate_detection_history_time_window: The period within which all incoming messages must have a unique message ID. :type duplicate_detection_history_time_window: ~datetime.timedelta :param enable_batched_operations: :type: enable_batched_operations: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found. :raises: ~azure.common.AzureConflictHttpError if a topic of the same name already exists. """ topic_properties = Topic( max_size_in_megabytes=max_size_in_megabytes, requires_duplicate_detection=requires_duplicate_detection, default_message_time_to_live=default_message_time_to_live, duplicate_detection_history_time_window=duplicate_detection_history_time_window, enable_batched_operations=enable_batched_operations) try: return self.mgmt_client.create_topic(topic_name, topic=topic_properties, fail_on_exist=True) except requests.exceptions.ConnectionError as e: raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e)
def create_topic( self, topic_name, default_message_time_to_live=None, max_size_in_megabytes=None, requires_duplicate_detection=None, duplicate_detection_history_time_window=None, enable_batched_operations=None): """Create a topic entity. :param topic_name: The name of the new topic. :type topic_name: str :param max_size_in_megabytes: The max size to allow the topic to grow to. :type max_size_in_megabytes: int :param requires_duplicate_detection: Whether the topic will require every message with a specified time frame to have a unique ID. Non-unique messages will be discarded. Default value is False. :type requires_duplicate_detection: bool :param default_message_time_to_live: The length of time a message will remain in the topic before it is either discarded or moved to the dead letter queue. :type default_message_time_to_live: ~datetime.timedelta :param duplicate_detection_history_time_window: The period within which all incoming messages must have a unique message ID. :type duplicate_detection_history_time_window: ~datetime.timedelta :param enable_batched_operations: :type: enable_batched_operations: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found. :raises: ~azure.common.AzureConflictHttpError if a topic of the same name already exists. """ topic_properties = Topic( max_size_in_megabytes=max_size_in_megabytes, requires_duplicate_detection=requires_duplicate_detection, default_message_time_to_live=default_message_time_to_live, duplicate_detection_history_time_window=duplicate_detection_history_time_window, enable_batched_operations=enable_batched_operations) try: return self.mgmt_client.create_topic(topic_name, topic=topic_properties, fail_on_exist=True) except requests.exceptions.ConnectionError as e: raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e)
[ "Create", "a", "topic", "entity", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/mixins.py#L116-L152
[ "def", "create_topic", "(", "self", ",", "topic_name", ",", "default_message_time_to_live", "=", "None", ",", "max_size_in_megabytes", "=", "None", ",", "requires_duplicate_detection", "=", "None", ",", "duplicate_detection_history_time_window", "=", "None", ",", "enable_batched_operations", "=", "None", ")", ":", "topic_properties", "=", "Topic", "(", "max_size_in_megabytes", "=", "max_size_in_megabytes", ",", "requires_duplicate_detection", "=", "requires_duplicate_detection", ",", "default_message_time_to_live", "=", "default_message_time_to_live", ",", "duplicate_detection_history_time_window", "=", "duplicate_detection_history_time_window", ",", "enable_batched_operations", "=", "enable_batched_operations", ")", "try", ":", "return", "self", ".", "mgmt_client", ".", "create_topic", "(", "topic_name", ",", "topic", "=", "topic_properties", ",", "fail_on_exist", "=", "True", ")", "except", "requests", ".", "exceptions", ".", "ConnectionError", "as", "e", ":", "raise", "ServiceBusConnectionError", "(", "\"Namespace: {} not found\"", ".", "format", "(", "self", ".", "service_namespace", ")", ",", "e", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusMixin.delete_topic
Delete a topic entity. :param topic_name: The name of the topic to delete. :type topic_name: str :param fail_not_exist: Whether to raise an exception if the named topic is not found. If set to True, a ServiceBusResourceNotFound will be raised. Default value is False. :type fail_not_exist: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namesapce is not found. :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the topic is not found and `fail_not_exist` is set to True.
azure-servicebus/azure/servicebus/common/mixins.py
def delete_topic(self, topic_name, fail_not_exist=False): """Delete a topic entity. :param topic_name: The name of the topic to delete. :type topic_name: str :param fail_not_exist: Whether to raise an exception if the named topic is not found. If set to True, a ServiceBusResourceNotFound will be raised. Default value is False. :type fail_not_exist: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namesapce is not found. :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the topic is not found and `fail_not_exist` is set to True. """ try: return self.mgmt_client.delete_topic(topic_name, fail_not_exist=fail_not_exist) except requests.exceptions.ConnectionError as e: raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e) except azure.common.AzureMissingResourceHttpError as e: raise ServiceBusResourceNotFound("Specificed queue does not exist.", e)
def delete_topic(self, topic_name, fail_not_exist=False): """Delete a topic entity. :param topic_name: The name of the topic to delete. :type topic_name: str :param fail_not_exist: Whether to raise an exception if the named topic is not found. If set to True, a ServiceBusResourceNotFound will be raised. Default value is False. :type fail_not_exist: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namesapce is not found. :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the topic is not found and `fail_not_exist` is set to True. """ try: return self.mgmt_client.delete_topic(topic_name, fail_not_exist=fail_not_exist) except requests.exceptions.ConnectionError as e: raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e) except azure.common.AzureMissingResourceHttpError as e: raise ServiceBusResourceNotFound("Specificed queue does not exist.", e)
[ "Delete", "a", "topic", "entity", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/mixins.py#L154-L172
[ "def", "delete_topic", "(", "self", ",", "topic_name", ",", "fail_not_exist", "=", "False", ")", ":", "try", ":", "return", "self", ".", "mgmt_client", ".", "delete_topic", "(", "topic_name", ",", "fail_not_exist", "=", "fail_not_exist", ")", "except", "requests", ".", "exceptions", ".", "ConnectionError", "as", "e", ":", "raise", "ServiceBusConnectionError", "(", "\"Namespace: {} not found\"", ".", "format", "(", "self", ".", "service_namespace", ")", ",", "e", ")", "except", "azure", ".", "common", ".", "AzureMissingResourceHttpError", "as", "e", ":", "raise", "ServiceBusResourceNotFound", "(", "\"Specificed queue does not exist.\"", ",", "e", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ServiceBusMixin.create_subscription
Create a subscription entity. :param topic_name: The name of the topic under which to create the subscription. :param subscription_name: The name of the new subscription. :type subscription_name: str :param lock_duration: The lock durection in seconds for each message in the subscription. :type lock_duration: int :param requires_session: Whether the subscription will be sessionful, and therefore require all message to have a Session ID and be received by a sessionful receiver. Default value is False. :type requires_session: bool :param default_message_time_to_live: The length of time a message will remain in the subscription before it is either discarded or moved to the dead letter queue. :type default_message_time_to_live: ~datetime.timedelta :param dead_lettering_on_message_expiration: Whether to move expired messages to the dead letter queue. Default value is False. :type dead_lettering_on_message_expiration: bool :param dead_lettering_on_filter_evaluation_exceptions: Whether to move messages that error on filtering into the dead letter queue. Default is False, and the messages will be discarded. :type dead_lettering_on_filter_evaluation_exceptions: bool :param max_delivery_count: The maximum number of times a message will attempt to be delivered before it is moved to the dead letter queue. :type max_delivery_count: int :param enable_batched_operations: :type: enable_batched_operations: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found. :raises: ~azure.common.AzureConflictHttpError if a queue of the same name already exists.
azure-servicebus/azure/servicebus/common/mixins.py
def create_subscription( self, topic_name, subscription_name, lock_duration=30, requires_session=None, default_message_time_to_live=None, dead_lettering_on_message_expiration=None, dead_lettering_on_filter_evaluation_exceptions=None, enable_batched_operations=None, max_delivery_count=None): """Create a subscription entity. :param topic_name: The name of the topic under which to create the subscription. :param subscription_name: The name of the new subscription. :type subscription_name: str :param lock_duration: The lock durection in seconds for each message in the subscription. :type lock_duration: int :param requires_session: Whether the subscription will be sessionful, and therefore require all message to have a Session ID and be received by a sessionful receiver. Default value is False. :type requires_session: bool :param default_message_time_to_live: The length of time a message will remain in the subscription before it is either discarded or moved to the dead letter queue. :type default_message_time_to_live: ~datetime.timedelta :param dead_lettering_on_message_expiration: Whether to move expired messages to the dead letter queue. Default value is False. :type dead_lettering_on_message_expiration: bool :param dead_lettering_on_filter_evaluation_exceptions: Whether to move messages that error on filtering into the dead letter queue. Default is False, and the messages will be discarded. :type dead_lettering_on_filter_evaluation_exceptions: bool :param max_delivery_count: The maximum number of times a message will attempt to be delivered before it is moved to the dead letter queue. :type max_delivery_count: int :param enable_batched_operations: :type: enable_batched_operations: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found. :raises: ~azure.common.AzureConflictHttpError if a queue of the same name already exists. """ sub_properties = Subscription( lock_duration="PT{}S".format(int(lock_duration)), requires_session=requires_session, default_message_time_to_live=default_message_time_to_live, dead_lettering_on_message_expiration=dead_lettering_on_message_expiration, dead_lettering_on_filter_evaluation_exceptions=dead_lettering_on_filter_evaluation_exceptions, max_delivery_count=max_delivery_count, enable_batched_operations=enable_batched_operations) try: return self.mgmt_client.create_subscription( topic_name, subscription_name, subscription=sub_properties, fail_on_exist=True) except requests.exceptions.ConnectionError as e: raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e)
def create_subscription( self, topic_name, subscription_name, lock_duration=30, requires_session=None, default_message_time_to_live=None, dead_lettering_on_message_expiration=None, dead_lettering_on_filter_evaluation_exceptions=None, enable_batched_operations=None, max_delivery_count=None): """Create a subscription entity. :param topic_name: The name of the topic under which to create the subscription. :param subscription_name: The name of the new subscription. :type subscription_name: str :param lock_duration: The lock durection in seconds for each message in the subscription. :type lock_duration: int :param requires_session: Whether the subscription will be sessionful, and therefore require all message to have a Session ID and be received by a sessionful receiver. Default value is False. :type requires_session: bool :param default_message_time_to_live: The length of time a message will remain in the subscription before it is either discarded or moved to the dead letter queue. :type default_message_time_to_live: ~datetime.timedelta :param dead_lettering_on_message_expiration: Whether to move expired messages to the dead letter queue. Default value is False. :type dead_lettering_on_message_expiration: bool :param dead_lettering_on_filter_evaluation_exceptions: Whether to move messages that error on filtering into the dead letter queue. Default is False, and the messages will be discarded. :type dead_lettering_on_filter_evaluation_exceptions: bool :param max_delivery_count: The maximum number of times a message will attempt to be delivered before it is moved to the dead letter queue. :type max_delivery_count: int :param enable_batched_operations: :type: enable_batched_operations: bool :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found. :raises: ~azure.common.AzureConflictHttpError if a queue of the same name already exists. """ sub_properties = Subscription( lock_duration="PT{}S".format(int(lock_duration)), requires_session=requires_session, default_message_time_to_live=default_message_time_to_live, dead_lettering_on_message_expiration=dead_lettering_on_message_expiration, dead_lettering_on_filter_evaluation_exceptions=dead_lettering_on_filter_evaluation_exceptions, max_delivery_count=max_delivery_count, enable_batched_operations=enable_batched_operations) try: return self.mgmt_client.create_subscription( topic_name, subscription_name, subscription=sub_properties, fail_on_exist=True) except requests.exceptions.ConnectionError as e: raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e)
[ "Create", "a", "subscription", "entity", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/mixins.py#L174-L222
[ "def", "create_subscription", "(", "self", ",", "topic_name", ",", "subscription_name", ",", "lock_duration", "=", "30", ",", "requires_session", "=", "None", ",", "default_message_time_to_live", "=", "None", ",", "dead_lettering_on_message_expiration", "=", "None", ",", "dead_lettering_on_filter_evaluation_exceptions", "=", "None", ",", "enable_batched_operations", "=", "None", ",", "max_delivery_count", "=", "None", ")", ":", "sub_properties", "=", "Subscription", "(", "lock_duration", "=", "\"PT{}S\"", ".", "format", "(", "int", "(", "lock_duration", ")", ")", ",", "requires_session", "=", "requires_session", ",", "default_message_time_to_live", "=", "default_message_time_to_live", ",", "dead_lettering_on_message_expiration", "=", "dead_lettering_on_message_expiration", ",", "dead_lettering_on_filter_evaluation_exceptions", "=", "dead_lettering_on_filter_evaluation_exceptions", ",", "max_delivery_count", "=", "max_delivery_count", ",", "enable_batched_operations", "=", "enable_batched_operations", ")", "try", ":", "return", "self", ".", "mgmt_client", ".", "create_subscription", "(", "topic_name", ",", "subscription_name", ",", "subscription", "=", "sub_properties", ",", "fail_on_exist", "=", "True", ")", "except", "requests", ".", "exceptions", ".", "ConnectionError", "as", "e", ":", "raise", "ServiceBusConnectionError", "(", "\"Namespace: {} not found\"", ".", "format", "(", "self", ".", "service_namespace", ")", ",", "e", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
BaseClient.from_connection_string
Create a Client from a Service Bus connection string. :param conn_str: The connection string. :type conn_str: str :param name: The name of the entity, if the 'EntityName' property is not included in the connection string.
azure-servicebus/azure/servicebus/common/mixins.py
def from_connection_string(cls, conn_str, name=None, **kwargs): """Create a Client from a Service Bus connection string. :param conn_str: The connection string. :type conn_str: str :param name: The name of the entity, if the 'EntityName' property is not included in the connection string. """ address, policy, key, entity = parse_conn_str(conn_str) entity = name or entity address = build_uri(address, entity) name = address.split('/')[-1] return cls(address, name, shared_access_key_name=policy, shared_access_key_value=key, **kwargs)
def from_connection_string(cls, conn_str, name=None, **kwargs): """Create a Client from a Service Bus connection string. :param conn_str: The connection string. :type conn_str: str :param name: The name of the entity, if the 'EntityName' property is not included in the connection string. """ address, policy, key, entity = parse_conn_str(conn_str) entity = name or entity address = build_uri(address, entity) name = address.split('/')[-1] return cls(address, name, shared_access_key_name=policy, shared_access_key_value=key, **kwargs)
[ "Create", "a", "Client", "from", "a", "Service", "Bus", "connection", "string", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/mixins.py#L307-L319
[ "def", "from_connection_string", "(", "cls", ",", "conn_str", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "address", ",", "policy", ",", "key", ",", "entity", "=", "parse_conn_str", "(", "conn_str", ")", "entity", "=", "name", "or", "entity", "address", "=", "build_uri", "(", "address", ",", "entity", ")", "name", "=", "address", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "return", "cls", "(", "address", ",", "name", ",", "shared_access_key_name", "=", "policy", ",", "shared_access_key_value", "=", "key", ",", "*", "*", "kwargs", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
BaseClient.get_properties
Perform an operation to update the properties of the entity. :returns: The properties of the entity as a dictionary. :rtype: dict[str, Any] :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the entity does not exist. :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the endpoint cannot be reached. :raises: ~azure.common.AzureHTTPError if the credentials are invalid.
azure-servicebus/azure/servicebus/common/mixins.py
def get_properties(self): """Perform an operation to update the properties of the entity. :returns: The properties of the entity as a dictionary. :rtype: dict[str, Any] :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the entity does not exist. :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the endpoint cannot be reached. :raises: ~azure.common.AzureHTTPError if the credentials are invalid. """ try: self.entity = self._get_entity() self.properties = dict(self.entity) if hasattr(self.entity, 'requires_session'): self.requires_session = self.entity.requires_session return self.properties except AzureServiceBusResourceNotFound: raise ServiceBusResourceNotFound("Specificed queue does not exist.") except azure.common.AzureHttpError: self.entity = None self.properties = {} self.requires_session = False except requests.exceptions.ConnectionError as e: raise ServiceBusConnectionError("Namespace not found", e)
def get_properties(self): """Perform an operation to update the properties of the entity. :returns: The properties of the entity as a dictionary. :rtype: dict[str, Any] :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the entity does not exist. :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the endpoint cannot be reached. :raises: ~azure.common.AzureHTTPError if the credentials are invalid. """ try: self.entity = self._get_entity() self.properties = dict(self.entity) if hasattr(self.entity, 'requires_session'): self.requires_session = self.entity.requires_session return self.properties except AzureServiceBusResourceNotFound: raise ServiceBusResourceNotFound("Specificed queue does not exist.") except azure.common.AzureHttpError: self.entity = None self.properties = {} self.requires_session = False except requests.exceptions.ConnectionError as e: raise ServiceBusConnectionError("Namespace not found", e)
[ "Perform", "an", "operation", "to", "update", "the", "properties", "of", "the", "entity", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/mixins.py#L324-L346
[ "def", "get_properties", "(", "self", ")", ":", "try", ":", "self", ".", "entity", "=", "self", ".", "_get_entity", "(", ")", "self", ".", "properties", "=", "dict", "(", "self", ".", "entity", ")", "if", "hasattr", "(", "self", ".", "entity", ",", "'requires_session'", ")", ":", "self", ".", "requires_session", "=", "self", ".", "entity", ".", "requires_session", "return", "self", ".", "properties", "except", "AzureServiceBusResourceNotFound", ":", "raise", "ServiceBusResourceNotFound", "(", "\"Specificed queue does not exist.\"", ")", "except", "azure", ".", "common", ".", "AzureHttpError", ":", "self", ".", "entity", "=", "None", "self", ".", "properties", "=", "{", "}", "self", ".", "requires_session", "=", "False", "except", "requests", ".", "exceptions", ".", "ConnectionError", "as", "e", ":", "raise", "ServiceBusConnectionError", "(", "\"Namespace not found\"", ",", "e", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
SessionMixin.expired
Whether the receivers lock on a particular session has expired. :rtype: bool
azure-servicebus/azure/servicebus/common/mixins.py
def expired(self): """Whether the receivers lock on a particular session has expired. :rtype: bool """ if self.locked_until and self.locked_until <= datetime.datetime.now(): return True return False
def expired(self): """Whether the receivers lock on a particular session has expired. :rtype: bool """ if self.locked_until and self.locked_until <= datetime.datetime.now(): return True return False
[ "Whether", "the", "receivers", "lock", "on", "a", "particular", "session", "has", "expired", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/mixins.py#L368-L375
[ "def", "expired", "(", "self", ")", ":", "if", "self", ".", "locked_until", "and", "self", ".", "locked_until", "<=", "datetime", ".", "datetime", ".", "now", "(", ")", ":", "return", "True", "return", "False" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
SenderMixin.queue_message
Queue a message to be sent later. This operation should be followed up with send_pending_messages. :param message: The message to be sent. :type message: ~azure.servicebus.common.message.Message Example: .. literalinclude:: ../examples/test_examples.py :start-after: [START queue_and_send_messages] :end-before: [END queue_and_send_messages] :language: python :dedent: 4 :caption: Send the queued messages :name: sender_queue
azure-servicebus/azure/servicebus/common/mixins.py
def queue_message(self, message): """Queue a message to be sent later. This operation should be followed up with send_pending_messages. :param message: The message to be sent. :type message: ~azure.servicebus.common.message.Message Example: .. literalinclude:: ../examples/test_examples.py :start-after: [START queue_and_send_messages] :end-before: [END queue_and_send_messages] :language: python :dedent: 4 :caption: Send the queued messages :name: sender_queue """ if not self.running: self.open() if self.session_id and not message.properties.group_id: message.properties.group_id = self.session_id self._handler.queue_message(message.message)
def queue_message(self, message): """Queue a message to be sent later. This operation should be followed up with send_pending_messages. :param message: The message to be sent. :type message: ~azure.servicebus.common.message.Message Example: .. literalinclude:: ../examples/test_examples.py :start-after: [START queue_and_send_messages] :end-before: [END queue_and_send_messages] :language: python :dedent: 4 :caption: Send the queued messages :name: sender_queue """ if not self.running: self.open() if self.session_id and not message.properties.group_id: message.properties.group_id = self.session_id self._handler.queue_message(message.message)
[ "Queue", "a", "message", "to", "be", "sent", "later", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/mixins.py#L398-L420
[ "def", "queue_message", "(", "self", ",", "message", ")", ":", "if", "not", "self", ".", "running", ":", "self", ".", "open", "(", ")", "if", "self", ".", "session_id", "and", "not", "message", ".", "properties", ".", "group_id", ":", "message", ".", "properties", ".", "group_id", "=", "self", ".", "session_id", "self", ".", "_handler", ".", "queue_message", "(", "message", ".", "message", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
AutoLockRenew.register
Register a renewable entity for automatic lock renewal. :param renewable: A locked entity that needs to be renewed. :type renewable: ~azure.servicebus.common.message.Message or ~azure.servicebus.receive_handler.SessionReceiver :param timeout: A time in seconds that the lock should be maintained for. Default value is 300 (5 minutes). :type timeout: int
azure-servicebus/azure/servicebus/common/utils.py
def register(self, renewable, timeout=300): """Register a renewable entity for automatic lock renewal. :param renewable: A locked entity that needs to be renewed. :type renewable: ~azure.servicebus.common.message.Message or ~azure.servicebus.receive_handler.SessionReceiver :param timeout: A time in seconds that the lock should be maintained for. Default value is 300 (5 minutes). :type timeout: int """ starttime = renewable_start_time(renewable) self.executor.submit(self._auto_lock_renew, renewable, starttime, timeout)
def register(self, renewable, timeout=300): """Register a renewable entity for automatic lock renewal. :param renewable: A locked entity that needs to be renewed. :type renewable: ~azure.servicebus.common.message.Message or ~azure.servicebus.receive_handler.SessionReceiver :param timeout: A time in seconds that the lock should be maintained for. Default value is 300 (5 minutes). :type timeout: int """ starttime = renewable_start_time(renewable) self.executor.submit(self._auto_lock_renew, renewable, starttime, timeout)
[ "Register", "a", "renewable", "entity", "for", "automatic", "lock", "renewal", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/utils.py#L154-L165
[ "def", "register", "(", "self", ",", "renewable", ",", "timeout", "=", "300", ")", ":", "starttime", "=", "renewable_start_time", "(", "renewable", ")", "self", ".", "executor", ".", "submit", "(", "self", ".", "_auto_lock_renew", ",", "renewable", ",", "starttime", ",", "timeout", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
SessionOperations.create
Creates a session for a node. :param resource_group_name: The resource group name uniquely identifies the resource group within the user subscriptionId. :type resource_group_name: str :param node_name: The node name (256 characters maximum). :type node_name: str :param session: The sessionId from the user. :type session: str :param user_name: Encrypted User name to be used to connect to node. :type user_name: str :param password: Encrypted Password associated with user name. :type password: str :param retention_period: Session retention period. Possible values include: 'Session', 'Persistent' :type retention_period: str or ~azure.mgmt.servermanager.models.RetentionPeriod :param credential_data_format: Credential data format. Possible values include: 'RsaEncrypted' :type credential_data_format: str or ~azure.mgmt.servermanager.models.CredentialDataFormat :param encryption_certificate_thumbprint: Encryption certificate thumbprint. :type encryption_certificate_thumbprint: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns SessionResource or ClientRawResponse<SessionResource> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.servermanager.models.SessionResource] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.servermanager.models.SessionResource]] :raises: :class:`ErrorException<azure.mgmt.servermanager.models.ErrorException>`
azure-mgmt-servermanager/azure/mgmt/servermanager/operations/session_operations.py
def create( self, resource_group_name, node_name, session, user_name=None, password=None, retention_period=None, credential_data_format=None, encryption_certificate_thumbprint=None, custom_headers=None, raw=False, polling=True, **operation_config): """Creates a session for a node. :param resource_group_name: The resource group name uniquely identifies the resource group within the user subscriptionId. :type resource_group_name: str :param node_name: The node name (256 characters maximum). :type node_name: str :param session: The sessionId from the user. :type session: str :param user_name: Encrypted User name to be used to connect to node. :type user_name: str :param password: Encrypted Password associated with user name. :type password: str :param retention_period: Session retention period. Possible values include: 'Session', 'Persistent' :type retention_period: str or ~azure.mgmt.servermanager.models.RetentionPeriod :param credential_data_format: Credential data format. Possible values include: 'RsaEncrypted' :type credential_data_format: str or ~azure.mgmt.servermanager.models.CredentialDataFormat :param encryption_certificate_thumbprint: Encryption certificate thumbprint. :type encryption_certificate_thumbprint: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns SessionResource or ClientRawResponse<SessionResource> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.servermanager.models.SessionResource] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.servermanager.models.SessionResource]] :raises: :class:`ErrorException<azure.mgmt.servermanager.models.ErrorException>` """ raw_result = self._create_initial( resource_group_name=resource_group_name, node_name=node_name, session=session, user_name=user_name, password=password, retention_period=retention_period, credential_data_format=credential_data_format, encryption_certificate_thumbprint=encryption_certificate_thumbprint, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('SessionResource', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def create( self, resource_group_name, node_name, session, user_name=None, password=None, retention_period=None, credential_data_format=None, encryption_certificate_thumbprint=None, custom_headers=None, raw=False, polling=True, **operation_config): """Creates a session for a node. :param resource_group_name: The resource group name uniquely identifies the resource group within the user subscriptionId. :type resource_group_name: str :param node_name: The node name (256 characters maximum). :type node_name: str :param session: The sessionId from the user. :type session: str :param user_name: Encrypted User name to be used to connect to node. :type user_name: str :param password: Encrypted Password associated with user name. :type password: str :param retention_period: Session retention period. Possible values include: 'Session', 'Persistent' :type retention_period: str or ~azure.mgmt.servermanager.models.RetentionPeriod :param credential_data_format: Credential data format. Possible values include: 'RsaEncrypted' :type credential_data_format: str or ~azure.mgmt.servermanager.models.CredentialDataFormat :param encryption_certificate_thumbprint: Encryption certificate thumbprint. :type encryption_certificate_thumbprint: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns SessionResource or ClientRawResponse<SessionResource> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.servermanager.models.SessionResource] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.servermanager.models.SessionResource]] :raises: :class:`ErrorException<azure.mgmt.servermanager.models.ErrorException>` """ raw_result = self._create_initial( resource_group_name=resource_group_name, node_name=node_name, session=session, user_name=user_name, password=password, retention_period=retention_period, credential_data_format=credential_data_format, encryption_certificate_thumbprint=encryption_certificate_thumbprint, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('SessionResource', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Creates", "a", "session", "for", "a", "node", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-servermanager/azure/mgmt/servermanager/operations/session_operations.py#L94-L163
[ "def", "create", "(", "self", ",", "resource_group_name", ",", "node_name", ",", "session", ",", "user_name", "=", "None", ",", "password", "=", "None", ",", "retention_period", "=", "None", ",", "credential_data_format", "=", "None", ",", "encryption_certificate_thumbprint", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_create_initial", "(", "resource_group_name", "=", "resource_group_name", ",", "node_name", "=", "node_name", ",", "session", "=", "session", ",", "user_name", "=", "user_name", ",", "password", "=", "password", ",", "retention_period", "=", "retention_period", ",", "credential_data_format", "=", "credential_data_format", ",", "encryption_certificate_thumbprint", "=", "encryption_certificate_thumbprint", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'SessionResource'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
SubscriptionFactoryOperations.create_subscription
Creates an Azure subscription. :param billing_account_name: The name of the commerce root billing account. :type billing_account_name: str :param invoice_section_name: The name of the invoice section. :type invoice_section_name: str :param body: The subscription creation parameters. :type body: ~azure.mgmt.subscription.models.SubscriptionCreationParameters :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns SubscriptionCreationResult or ClientRawResponse<SubscriptionCreationResult> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.subscription.models.SubscriptionCreationResult] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.subscription.models.SubscriptionCreationResult]] :raises: :class:`ErrorResponseException<azure.mgmt.subscription.models.ErrorResponseException>`
azure-mgmt-subscription/azure/mgmt/subscription/operations/subscription_factory_operations.py
def create_subscription( self, billing_account_name, invoice_section_name, body, custom_headers=None, raw=False, polling=True, **operation_config): """Creates an Azure subscription. :param billing_account_name: The name of the commerce root billing account. :type billing_account_name: str :param invoice_section_name: The name of the invoice section. :type invoice_section_name: str :param body: The subscription creation parameters. :type body: ~azure.mgmt.subscription.models.SubscriptionCreationParameters :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns SubscriptionCreationResult or ClientRawResponse<SubscriptionCreationResult> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.subscription.models.SubscriptionCreationResult] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.subscription.models.SubscriptionCreationResult]] :raises: :class:`ErrorResponseException<azure.mgmt.subscription.models.ErrorResponseException>` """ raw_result = self._create_subscription_initial( billing_account_name=billing_account_name, invoice_section_name=invoice_section_name, body=body, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): header_dict = { 'Location': 'str', 'Retry-After': 'int', } deserialized = self._deserialize('SubscriptionCreationResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) client_raw_response.add_headers(header_dict) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def create_subscription( self, billing_account_name, invoice_section_name, body, custom_headers=None, raw=False, polling=True, **operation_config): """Creates an Azure subscription. :param billing_account_name: The name of the commerce root billing account. :type billing_account_name: str :param invoice_section_name: The name of the invoice section. :type invoice_section_name: str :param body: The subscription creation parameters. :type body: ~azure.mgmt.subscription.models.SubscriptionCreationParameters :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns SubscriptionCreationResult or ClientRawResponse<SubscriptionCreationResult> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.subscription.models.SubscriptionCreationResult] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.subscription.models.SubscriptionCreationResult]] :raises: :class:`ErrorResponseException<azure.mgmt.subscription.models.ErrorResponseException>` """ raw_result = self._create_subscription_initial( billing_account_name=billing_account_name, invoice_section_name=invoice_section_name, body=body, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): header_dict = { 'Location': 'str', 'Retry-After': 'int', } deserialized = self._deserialize('SubscriptionCreationResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) client_raw_response.add_headers(header_dict) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Creates", "an", "Azure", "subscription", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-subscription/azure/mgmt/subscription/operations/subscription_factory_operations.py#L94-L150
[ "def", "create_subscription", "(", "self", ",", "billing_account_name", ",", "invoice_section_name", ",", "body", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_create_subscription_initial", "(", "billing_account_name", "=", "billing_account_name", ",", "invoice_section_name", "=", "invoice_section_name", ",", "body", "=", "body", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "header_dict", "=", "{", "'Location'", ":", "'str'", ",", "'Retry-After'", ":", "'int'", ",", "}", "deserialized", "=", "self", ".", "_deserialize", "(", "'SubscriptionCreationResult'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "client_raw_response", ".", "add_headers", "(", "header_dict", ")", "return", "client_raw_response", "return", "deserialized", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
PyPIClient.get_relevant_versions
Return a tuple: (latest release, latest stable) If there are different, it means the latest is not a stable
azure-sdk-tools/packaging_tools/pypi.py
def get_relevant_versions(self, package_name: str): """Return a tuple: (latest release, latest stable) If there are different, it means the latest is not a stable """ versions = self.get_ordered_versions(package_name) pre_releases = [version for version in versions if not version.is_prerelease] return ( versions[-1], pre_releases[-1] )
def get_relevant_versions(self, package_name: str): """Return a tuple: (latest release, latest stable) If there are different, it means the latest is not a stable """ versions = self.get_ordered_versions(package_name) pre_releases = [version for version in versions if not version.is_prerelease] return ( versions[-1], pre_releases[-1] )
[ "Return", "a", "tuple", ":", "(", "latest", "release", "latest", "stable", ")", "If", "there", "are", "different", "it", "means", "the", "latest", "is", "not", "a", "stable" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-sdk-tools/packaging_tools/pypi.py#L49-L58
[ "def", "get_relevant_versions", "(", "self", ",", "package_name", ":", "str", ")", ":", "versions", "=", "self", ".", "get_ordered_versions", "(", "package_name", ")", "pre_releases", "=", "[", "version", "for", "version", "in", "versions", "if", "not", "version", ".", "is_prerelease", "]", "return", "(", "versions", "[", "-", "1", "]", ",", "pre_releases", "[", "-", "1", "]", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
LogAnalyticsOperations.export_request_rate_by_interval
Export logs that show Api requests made by this subscription in the given time window to show throttling activities. :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. :type parameters: ~azure.mgmt.compute.v2018_04_01.models.RequestRateByIntervalInput :param location: The location upon which virtual-machine-sizes is queried. :type location: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns LogAnalyticsOperationResult or ClientRawResponse<LogAnalyticsOperationResult> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.compute.v2018_04_01.models.LogAnalyticsOperationResult] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.compute.v2018_04_01.models.LogAnalyticsOperationResult]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/log_analytics_operations.py
def export_request_rate_by_interval( self, parameters, location, custom_headers=None, raw=False, polling=True, **operation_config): """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. :type parameters: ~azure.mgmt.compute.v2018_04_01.models.RequestRateByIntervalInput :param location: The location upon which virtual-machine-sizes is queried. :type location: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns LogAnalyticsOperationResult or ClientRawResponse<LogAnalyticsOperationResult> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.compute.v2018_04_01.models.LogAnalyticsOperationResult] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.compute.v2018_04_01.models.LogAnalyticsOperationResult]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._export_request_rate_by_interval_initial( parameters=parameters, location=location, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('LogAnalyticsOperationResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def export_request_rate_by_interval( self, parameters, location, custom_headers=None, raw=False, polling=True, **operation_config): """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. :type parameters: ~azure.mgmt.compute.v2018_04_01.models.RequestRateByIntervalInput :param location: The location upon which virtual-machine-sizes is queried. :type location: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns LogAnalyticsOperationResult or ClientRawResponse<LogAnalyticsOperationResult> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.compute.v2018_04_01.models.LogAnalyticsOperationResult] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.compute.v2018_04_01.models.LogAnalyticsOperationResult]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._export_request_rate_by_interval_initial( parameters=parameters, location=location, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('LogAnalyticsOperationResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Export", "logs", "that", "show", "Api", "requests", "made", "by", "this", "subscription", "in", "the", "given", "time", "window", "to", "show", "throttling", "activities", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/log_analytics_operations.py#L91-L140
[ "def", "export_request_rate_by_interval", "(", "self", ",", "parameters", ",", "location", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_export_request_rate_by_interval_initial", "(", "parameters", "=", "parameters", ",", "location", "=", "location", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'LogAnalyticsOperationResult'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "lro_options", "=", "{", "'final-state-via'", ":", "'azure-async-operation'", "}", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_handle_output
Scan output for exceptions If there is an output from an add task collection call add it to the results. :param results_queue: Queue containing results of attempted add_collection's :type results_queue: collections.deque :return: list of TaskAddResults :rtype: list[~TaskAddResult]
azure-batch/azure/batch/custom/patch.py
def _handle_output(results_queue): """Scan output for exceptions If there is an output from an add task collection call add it to the results. :param results_queue: Queue containing results of attempted add_collection's :type results_queue: collections.deque :return: list of TaskAddResults :rtype: list[~TaskAddResult] """ results = [] while results_queue: queue_item = results_queue.pop() results.append(queue_item) return results
def _handle_output(results_queue): """Scan output for exceptions If there is an output from an add task collection call add it to the results. :param results_queue: Queue containing results of attempted add_collection's :type results_queue: collections.deque :return: list of TaskAddResults :rtype: list[~TaskAddResult] """ results = [] while results_queue: queue_item = results_queue.pop() results.append(queue_item) return results
[ "Scan", "output", "for", "exceptions" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-batch/azure/batch/custom/patch.py#L172-L186
[ "def", "_handle_output", "(", "results_queue", ")", ":", "results", "=", "[", "]", "while", "results_queue", ":", "queue_item", "=", "results_queue", ".", "pop", "(", ")", "results", ".", "append", "(", "queue_item", ")", "return", "results" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_TaskWorkflowManager._bulk_add_tasks
Adds a chunk of tasks to the job Retry chunk if body exceeds the maximum request size and retry tasks if failed due to server errors. :param results_queue: Queue to place the return value of the request :type results_queue: collections.deque :param chunk_tasks_to_add: Chunk of at most 100 tasks with retry details :type chunk_tasks_to_add: list[~TrackedCloudTask]
azure-batch/azure/batch/custom/patch.py
def _bulk_add_tasks(self, results_queue, chunk_tasks_to_add): """Adds a chunk of tasks to the job Retry chunk if body exceeds the maximum request size and retry tasks if failed due to server errors. :param results_queue: Queue to place the return value of the request :type results_queue: collections.deque :param chunk_tasks_to_add: Chunk of at most 100 tasks with retry details :type chunk_tasks_to_add: list[~TrackedCloudTask] """ try: add_collection_response = self._original_add_collection( self._client, self._job_id, chunk_tasks_to_add, self._task_add_collection_options, self._custom_headers, self._raw) except BatchErrorException as e: # In case of a chunk exceeding the MaxMessageSize split chunk in half # and resubmit smaller chunk requests # TODO: Replace string with constant variable once available in SDK if e.error.code == "RequestBodyTooLarge": # pylint: disable=no-member # In this case the task is misbehaved and will not be able to be added due to: # 1) The task exceeding the max message size # 2) A single cell of the task exceeds the per-cell limit, or # 3) Sum of all cells exceeds max row limit if len(chunk_tasks_to_add) == 1: failed_task = chunk_tasks_to_add.pop() self.errors.appendleft(e) _LOGGER.error("Failed to add task with ID %s due to the body" " exceeding the maximum request size", failed_task.id) else: # Assumption: Tasks are relatively close in size therefore if one batch exceeds size limit # we should decrease the initial task collection size to avoid repeating the error # Midpoint is lower bounded by 1 due to above base case midpoint = int(len(chunk_tasks_to_add) / 2) # Restrict one thread at a time to do this compare and set, # therefore forcing max_tasks_per_request to be strictly decreasing with self._max_tasks_lock: if midpoint < self._max_tasks_per_request: self._max_tasks_per_request = midpoint _LOGGER.info("Amount of tasks per request reduced from %s to %s due to the" " request body being too large", str(self._max_tasks_per_request), str(midpoint)) # Not the most efficient solution for all cases, but the goal of this is to handle this # exception and have it work in all cases where tasks are well behaved # Behavior retries as a smaller chunk and # appends extra tasks to queue to be picked up by another thread . self.tasks_to_add.extendleft(chunk_tasks_to_add[midpoint:]) self._bulk_add_tasks(results_queue, chunk_tasks_to_add[:midpoint]) # Retry server side errors elif 500 <= e.response.status_code <= 599: self.tasks_to_add.extendleft(chunk_tasks_to_add) else: # Re-add to pending queue as unknown status / don't have result self.tasks_to_add.extendleft(chunk_tasks_to_add) # Unknown State - don't know if tasks failed to add or were successful self.errors.appendleft(e) except Exception as e: # pylint: disable=broad-except # Re-add to pending queue as unknown status / don't have result self.tasks_to_add.extendleft(chunk_tasks_to_add) # Unknown State - don't know if tasks failed to add or were successful self.errors.appendleft(e) else: try: add_collection_response = add_collection_response.output except AttributeError: pass for task_result in add_collection_response.value: # pylint: disable=no-member if task_result.status == TaskAddStatus.server_error: # Server error will be retried with self._pending_queue_lock: for task in chunk_tasks_to_add: if task.id == task_result.task_id: self.tasks_to_add.appendleft(task) elif (task_result.status == TaskAddStatus.client_error and not task_result.error.code == "TaskExists"): # Client error will be recorded unless Task already exists self.failure_tasks.appendleft(task_result) else: results_queue.appendleft(task_result)
def _bulk_add_tasks(self, results_queue, chunk_tasks_to_add): """Adds a chunk of tasks to the job Retry chunk if body exceeds the maximum request size and retry tasks if failed due to server errors. :param results_queue: Queue to place the return value of the request :type results_queue: collections.deque :param chunk_tasks_to_add: Chunk of at most 100 tasks with retry details :type chunk_tasks_to_add: list[~TrackedCloudTask] """ try: add_collection_response = self._original_add_collection( self._client, self._job_id, chunk_tasks_to_add, self._task_add_collection_options, self._custom_headers, self._raw) except BatchErrorException as e: # In case of a chunk exceeding the MaxMessageSize split chunk in half # and resubmit smaller chunk requests # TODO: Replace string with constant variable once available in SDK if e.error.code == "RequestBodyTooLarge": # pylint: disable=no-member # In this case the task is misbehaved and will not be able to be added due to: # 1) The task exceeding the max message size # 2) A single cell of the task exceeds the per-cell limit, or # 3) Sum of all cells exceeds max row limit if len(chunk_tasks_to_add) == 1: failed_task = chunk_tasks_to_add.pop() self.errors.appendleft(e) _LOGGER.error("Failed to add task with ID %s due to the body" " exceeding the maximum request size", failed_task.id) else: # Assumption: Tasks are relatively close in size therefore if one batch exceeds size limit # we should decrease the initial task collection size to avoid repeating the error # Midpoint is lower bounded by 1 due to above base case midpoint = int(len(chunk_tasks_to_add) / 2) # Restrict one thread at a time to do this compare and set, # therefore forcing max_tasks_per_request to be strictly decreasing with self._max_tasks_lock: if midpoint < self._max_tasks_per_request: self._max_tasks_per_request = midpoint _LOGGER.info("Amount of tasks per request reduced from %s to %s due to the" " request body being too large", str(self._max_tasks_per_request), str(midpoint)) # Not the most efficient solution for all cases, but the goal of this is to handle this # exception and have it work in all cases where tasks are well behaved # Behavior retries as a smaller chunk and # appends extra tasks to queue to be picked up by another thread . self.tasks_to_add.extendleft(chunk_tasks_to_add[midpoint:]) self._bulk_add_tasks(results_queue, chunk_tasks_to_add[:midpoint]) # Retry server side errors elif 500 <= e.response.status_code <= 599: self.tasks_to_add.extendleft(chunk_tasks_to_add) else: # Re-add to pending queue as unknown status / don't have result self.tasks_to_add.extendleft(chunk_tasks_to_add) # Unknown State - don't know if tasks failed to add or were successful self.errors.appendleft(e) except Exception as e: # pylint: disable=broad-except # Re-add to pending queue as unknown status / don't have result self.tasks_to_add.extendleft(chunk_tasks_to_add) # Unknown State - don't know if tasks failed to add or were successful self.errors.appendleft(e) else: try: add_collection_response = add_collection_response.output except AttributeError: pass for task_result in add_collection_response.value: # pylint: disable=no-member if task_result.status == TaskAddStatus.server_error: # Server error will be retried with self._pending_queue_lock: for task in chunk_tasks_to_add: if task.id == task_result.task_id: self.tasks_to_add.appendleft(task) elif (task_result.status == TaskAddStatus.client_error and not task_result.error.code == "TaskExists"): # Client error will be recorded unless Task already exists self.failure_tasks.appendleft(task_result) else: results_queue.appendleft(task_result)
[ "Adds", "a", "chunk", "of", "tasks", "to", "the", "job" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-batch/azure/batch/custom/patch.py#L66-L151
[ "def", "_bulk_add_tasks", "(", "self", ",", "results_queue", ",", "chunk_tasks_to_add", ")", ":", "try", ":", "add_collection_response", "=", "self", ".", "_original_add_collection", "(", "self", ".", "_client", ",", "self", ".", "_job_id", ",", "chunk_tasks_to_add", ",", "self", ".", "_task_add_collection_options", ",", "self", ".", "_custom_headers", ",", "self", ".", "_raw", ")", "except", "BatchErrorException", "as", "e", ":", "# In case of a chunk exceeding the MaxMessageSize split chunk in half", "# and resubmit smaller chunk requests", "# TODO: Replace string with constant variable once available in SDK", "if", "e", ".", "error", ".", "code", "==", "\"RequestBodyTooLarge\"", ":", "# pylint: disable=no-member", "# In this case the task is misbehaved and will not be able to be added due to:", "# 1) The task exceeding the max message size", "# 2) A single cell of the task exceeds the per-cell limit, or", "# 3) Sum of all cells exceeds max row limit", "if", "len", "(", "chunk_tasks_to_add", ")", "==", "1", ":", "failed_task", "=", "chunk_tasks_to_add", ".", "pop", "(", ")", "self", ".", "errors", ".", "appendleft", "(", "e", ")", "_LOGGER", ".", "error", "(", "\"Failed to add task with ID %s due to the body\"", "\" exceeding the maximum request size\"", ",", "failed_task", ".", "id", ")", "else", ":", "# Assumption: Tasks are relatively close in size therefore if one batch exceeds size limit", "# we should decrease the initial task collection size to avoid repeating the error", "# Midpoint is lower bounded by 1 due to above base case", "midpoint", "=", "int", "(", "len", "(", "chunk_tasks_to_add", ")", "/", "2", ")", "# Restrict one thread at a time to do this compare and set,", "# therefore forcing max_tasks_per_request to be strictly decreasing", "with", "self", ".", "_max_tasks_lock", ":", "if", "midpoint", "<", "self", ".", "_max_tasks_per_request", ":", "self", ".", "_max_tasks_per_request", "=", "midpoint", "_LOGGER", ".", "info", "(", "\"Amount of tasks per request reduced from %s to %s due to the\"", "\" request body being too large\"", ",", "str", "(", "self", ".", "_max_tasks_per_request", ")", ",", "str", "(", "midpoint", ")", ")", "# Not the most efficient solution for all cases, but the goal of this is to handle this", "# exception and have it work in all cases where tasks are well behaved", "# Behavior retries as a smaller chunk and", "# appends extra tasks to queue to be picked up by another thread .", "self", ".", "tasks_to_add", ".", "extendleft", "(", "chunk_tasks_to_add", "[", "midpoint", ":", "]", ")", "self", ".", "_bulk_add_tasks", "(", "results_queue", ",", "chunk_tasks_to_add", "[", ":", "midpoint", "]", ")", "# Retry server side errors", "elif", "500", "<=", "e", ".", "response", ".", "status_code", "<=", "599", ":", "self", ".", "tasks_to_add", ".", "extendleft", "(", "chunk_tasks_to_add", ")", "else", ":", "# Re-add to pending queue as unknown status / don't have result", "self", ".", "tasks_to_add", ".", "extendleft", "(", "chunk_tasks_to_add", ")", "# Unknown State - don't know if tasks failed to add or were successful", "self", ".", "errors", ".", "appendleft", "(", "e", ")", "except", "Exception", "as", "e", ":", "# pylint: disable=broad-except", "# Re-add to pending queue as unknown status / don't have result", "self", ".", "tasks_to_add", ".", "extendleft", "(", "chunk_tasks_to_add", ")", "# Unknown State - don't know if tasks failed to add or were successful", "self", ".", "errors", ".", "appendleft", "(", "e", ")", "else", ":", "try", ":", "add_collection_response", "=", "add_collection_response", ".", "output", "except", "AttributeError", ":", "pass", "for", "task_result", "in", "add_collection_response", ".", "value", ":", "# pylint: disable=no-member", "if", "task_result", ".", "status", "==", "TaskAddStatus", ".", "server_error", ":", "# Server error will be retried", "with", "self", ".", "_pending_queue_lock", ":", "for", "task", "in", "chunk_tasks_to_add", ":", "if", "task", ".", "id", "==", "task_result", ".", "task_id", ":", "self", ".", "tasks_to_add", ".", "appendleft", "(", "task", ")", "elif", "(", "task_result", ".", "status", "==", "TaskAddStatus", ".", "client_error", "and", "not", "task_result", ".", "error", ".", "code", "==", "\"TaskExists\"", ")", ":", "# Client error will be recorded unless Task already exists", "self", ".", "failure_tasks", ".", "appendleft", "(", "task_result", ")", "else", ":", "results_queue", ".", "appendleft", "(", "task_result", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_TaskWorkflowManager.task_collection_thread_handler
Main method for worker to run Pops a chunk of tasks off the collection of pending tasks to be added and submits them to be added. :param collections.deque results_queue: Queue for worker to output results to
azure-batch/azure/batch/custom/patch.py
def task_collection_thread_handler(self, results_queue): """Main method for worker to run Pops a chunk of tasks off the collection of pending tasks to be added and submits them to be added. :param collections.deque results_queue: Queue for worker to output results to """ # Add tasks until either we run out or we run into an unexpected error while self.tasks_to_add and not self.errors: max_tasks = self._max_tasks_per_request # local copy chunk_tasks_to_add = [] with self._pending_queue_lock: while len(chunk_tasks_to_add) < max_tasks and self.tasks_to_add: chunk_tasks_to_add.append(self.tasks_to_add.pop()) if chunk_tasks_to_add: self._bulk_add_tasks(results_queue, chunk_tasks_to_add)
def task_collection_thread_handler(self, results_queue): """Main method for worker to run Pops a chunk of tasks off the collection of pending tasks to be added and submits them to be added. :param collections.deque results_queue: Queue for worker to output results to """ # Add tasks until either we run out or we run into an unexpected error while self.tasks_to_add and not self.errors: max_tasks = self._max_tasks_per_request # local copy chunk_tasks_to_add = [] with self._pending_queue_lock: while len(chunk_tasks_to_add) < max_tasks and self.tasks_to_add: chunk_tasks_to_add.append(self.tasks_to_add.pop()) if chunk_tasks_to_add: self._bulk_add_tasks(results_queue, chunk_tasks_to_add)
[ "Main", "method", "for", "worker", "to", "run" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-batch/azure/batch/custom/patch.py#L153-L169
[ "def", "task_collection_thread_handler", "(", "self", ",", "results_queue", ")", ":", "# Add tasks until either we run out or we run into an unexpected error", "while", "self", ".", "tasks_to_add", "and", "not", "self", ".", "errors", ":", "max_tasks", "=", "self", ".", "_max_tasks_per_request", "# local copy", "chunk_tasks_to_add", "=", "[", "]", "with", "self", ".", "_pending_queue_lock", ":", "while", "len", "(", "chunk_tasks_to_add", ")", "<", "max_tasks", "and", "self", ".", "tasks_to_add", ":", "chunk_tasks_to_add", ".", "append", "(", "self", ".", "tasks_to_add", ".", "pop", "(", ")", ")", "if", "chunk_tasks_to_add", ":", "self", ".", "_bulk_add_tasks", "(", "results_queue", ",", "chunk_tasks_to_add", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
build_config
Will build the actual config for Jinja2, based on SDK config.
azure-sdk-tools/packaging_tools/__init__.py
def build_config(config : Dict[str, Any]) -> Dict[str, str]: """Will build the actual config for Jinja2, based on SDK config. """ result = config.copy() # Manage the classifier stable/beta is_stable = result.pop("is_stable", False) if is_stable: result["classifier"] = "Development Status :: 5 - Production/Stable" else: result["classifier"] = "Development Status :: 4 - Beta" # Manage the nspkg package_name = result["package_name"] result["package_nspkg"] = result.pop( "package_nspkg", package_name[:package_name.rindex('-')]+"-nspkg" ) # ARM? result['is_arm'] = result.pop("is_arm", True) # Do I need msrestazure for this package? result['need_msrestazure'] = result.pop("need_msrestazure", True) # Pre-compute some Jinja variable that are complicated to do inside the templates package_parts = result["package_nspkg"][:-len('-nspkg')].split('-') result['nspkg_names'] = [ ".".join(package_parts[:i+1]) for i in range(len(package_parts)) ] result['init_names'] = [ "/".join(package_parts[:i+1])+"/__init__.py" for i in range(len(package_parts)) ] # Return result return result
def build_config(config : Dict[str, Any]) -> Dict[str, str]: """Will build the actual config for Jinja2, based on SDK config. """ result = config.copy() # Manage the classifier stable/beta is_stable = result.pop("is_stable", False) if is_stable: result["classifier"] = "Development Status :: 5 - Production/Stable" else: result["classifier"] = "Development Status :: 4 - Beta" # Manage the nspkg package_name = result["package_name"] result["package_nspkg"] = result.pop( "package_nspkg", package_name[:package_name.rindex('-')]+"-nspkg" ) # ARM? result['is_arm'] = result.pop("is_arm", True) # Do I need msrestazure for this package? result['need_msrestazure'] = result.pop("need_msrestazure", True) # Pre-compute some Jinja variable that are complicated to do inside the templates package_parts = result["package_nspkg"][:-len('-nspkg')].split('-') result['nspkg_names'] = [ ".".join(package_parts[:i+1]) for i in range(len(package_parts)) ] result['init_names'] = [ "/".join(package_parts[:i+1])+"/__init__.py" for i in range(len(package_parts)) ] # Return result return result
[ "Will", "build", "the", "actual", "config", "for", "Jinja2", "based", "on", "SDK", "config", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-sdk-tools/packaging_tools/__init__.py#L15-L49
[ "def", "build_config", "(", "config", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "result", "=", "config", ".", "copy", "(", ")", "# Manage the classifier stable/beta", "is_stable", "=", "result", ".", "pop", "(", "\"is_stable\"", ",", "False", ")", "if", "is_stable", ":", "result", "[", "\"classifier\"", "]", "=", "\"Development Status :: 5 - Production/Stable\"", "else", ":", "result", "[", "\"classifier\"", "]", "=", "\"Development Status :: 4 - Beta\"", "# Manage the nspkg", "package_name", "=", "result", "[", "\"package_name\"", "]", "result", "[", "\"package_nspkg\"", "]", "=", "result", ".", "pop", "(", "\"package_nspkg\"", ",", "package_name", "[", ":", "package_name", ".", "rindex", "(", "'-'", ")", "]", "+", "\"-nspkg\"", ")", "# ARM?", "result", "[", "'is_arm'", "]", "=", "result", ".", "pop", "(", "\"is_arm\"", ",", "True", ")", "# Do I need msrestazure for this package?", "result", "[", "'need_msrestazure'", "]", "=", "result", ".", "pop", "(", "\"need_msrestazure\"", ",", "True", ")", "# Pre-compute some Jinja variable that are complicated to do inside the templates", "package_parts", "=", "result", "[", "\"package_nspkg\"", "]", "[", ":", "-", "len", "(", "'-nspkg'", ")", "]", ".", "split", "(", "'-'", ")", "result", "[", "'nspkg_names'", "]", "=", "[", "\".\"", ".", "join", "(", "package_parts", "[", ":", "i", "+", "1", "]", ")", "for", "i", "in", "range", "(", "len", "(", "package_parts", ")", ")", "]", "result", "[", "'init_names'", "]", "=", "[", "\"/\"", ".", "join", "(", "package_parts", "[", ":", "i", "+", "1", "]", ")", "+", "\"/__init__.py\"", "for", "i", "in", "range", "(", "len", "(", "package_parts", ")", ")", "]", "# Return result", "return", "result" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ManagementLinkClient.models
Module depends on the API version: * 2016-09-01: :mod:`v2016_09_01.models<azure.mgmt.resource.links.v2016_09_01.models>`
azure-mgmt-resource/azure/mgmt/resource/links/management_link_client.py
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2016-09-01: :mod:`v2016_09_01.models<azure.mgmt.resource.links.v2016_09_01.models>` """ if api_version == '2016-09-01': from .v2016_09_01 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2016-09-01: :mod:`v2016_09_01.models<azure.mgmt.resource.links.v2016_09_01.models>` """ if api_version == '2016-09-01': from .v2016_09_01 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
[ "Module", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-resource/azure/mgmt/resource/links/management_link_client.py#L96-L104
[ "def", "models", "(", "cls", ",", "api_version", "=", "DEFAULT_API_VERSION", ")", ":", "if", "api_version", "==", "'2016-09-01'", ":", "from", ".", "v2016_09_01", "import", "models", "return", "models", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
GlobalUsersOperations.reset_password
Resets the user password on an environment This operation can take a while to complete. :param user_name: The name of the user. :type user_name: str :param reset_password_payload: Represents the payload for resetting passwords. :type reset_password_payload: ~azure.mgmt.labservices.models.ResetPasswordPayload :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
azure-mgmt-labservices/azure/mgmt/labservices/operations/global_users_operations.py
def reset_password( self, user_name, reset_password_payload, custom_headers=None, raw=False, polling=True, **operation_config): """Resets the user password on an environment This operation can take a while to complete. :param user_name: The name of the user. :type user_name: str :param reset_password_payload: Represents the payload for resetting passwords. :type reset_password_payload: ~azure.mgmt.labservices.models.ResetPasswordPayload :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._reset_password_initial( user_name=user_name, reset_password_payload=reset_password_payload, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def reset_password( self, user_name, reset_password_payload, custom_headers=None, raw=False, polling=True, **operation_config): """Resets the user password on an environment This operation can take a while to complete. :param user_name: The name of the user. :type user_name: str :param reset_password_payload: Represents the payload for resetting passwords. :type reset_password_payload: ~azure.mgmt.labservices.models.ResetPasswordPayload :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._reset_password_initial( user_name=user_name, reset_password_payload=reset_password_payload, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Resets", "the", "user", "password", "on", "an", "environment", "This", "operation", "can", "take", "a", "while", "to", "complete", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-labservices/azure/mgmt/labservices/operations/global_users_operations.py#L533-L574
[ "def", "reset_password", "(", "self", ",", "user_name", ",", "reset_password_payload", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_reset_password_initial", "(", "user_name", "=", "user_name", ",", "reset_password_payload", "=", "reset_password_payload", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "return", "client_raw_response", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
GlobalUsersOperations.start_environment
Starts an environment by starting all resources inside the environment. This operation can take a while to complete. :param user_name: The name of the user. :type user_name: str :param environment_id: The resourceId of the environment :type environment_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
azure-mgmt-labservices/azure/mgmt/labservices/operations/global_users_operations.py
def start_environment( self, user_name, environment_id, custom_headers=None, raw=False, polling=True, **operation_config): """Starts an environment by starting all resources inside the environment. This operation can take a while to complete. :param user_name: The name of the user. :type user_name: str :param environment_id: The resourceId of the environment :type environment_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._start_environment_initial( user_name=user_name, environment_id=environment_id, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def start_environment( self, user_name, environment_id, custom_headers=None, raw=False, polling=True, **operation_config): """Starts an environment by starting all resources inside the environment. This operation can take a while to complete. :param user_name: The name of the user. :type user_name: str :param environment_id: The resourceId of the environment :type environment_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._start_environment_initial( user_name=user_name, environment_id=environment_id, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Starts", "an", "environment", "by", "starting", "all", "resources", "inside", "the", "environment", ".", "This", "operation", "can", "take", "a", "while", "to", "complete", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-labservices/azure/mgmt/labservices/operations/global_users_operations.py#L619-L658
[ "def", "start_environment", "(", "self", ",", "user_name", ",", "environment_id", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_start_environment_initial", "(", "user_name", "=", "user_name", ",", "environment_id", "=", "environment_id", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "return", "client_raw_response", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ContainerRegistryManagementClient.models
Module depends on the API version: * 2017-03-01: :mod:`v2017_03_01.models<azure.mgmt.containerregistry.v2017_03_01.models>` * 2017-10-01: :mod:`v2017_10_01.models<azure.mgmt.containerregistry.v2017_10_01.models>` * 2018-02-01-preview: :mod:`v2018_02_01_preview.models<azure.mgmt.containerregistry.v2018_02_01_preview.models>` * 2018-09-01: :mod:`v2018_09_01.models<azure.mgmt.containerregistry.v2018_09_01.models>`
azure-mgmt-containerregistry/azure/mgmt/containerregistry/container_registry_management_client.py
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2017-03-01: :mod:`v2017_03_01.models<azure.mgmt.containerregistry.v2017_03_01.models>` * 2017-10-01: :mod:`v2017_10_01.models<azure.mgmt.containerregistry.v2017_10_01.models>` * 2018-02-01-preview: :mod:`v2018_02_01_preview.models<azure.mgmt.containerregistry.v2018_02_01_preview.models>` * 2018-09-01: :mod:`v2018_09_01.models<azure.mgmt.containerregistry.v2018_09_01.models>` """ if api_version == '2017-03-01': from .v2017_03_01 import models return models elif api_version == '2017-10-01': from .v2017_10_01 import models return models elif api_version == '2018-02-01-preview': from .v2018_02_01_preview import models return models elif api_version == '2018-09-01': from .v2018_09_01 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2017-03-01: :mod:`v2017_03_01.models<azure.mgmt.containerregistry.v2017_03_01.models>` * 2017-10-01: :mod:`v2017_10_01.models<azure.mgmt.containerregistry.v2017_10_01.models>` * 2018-02-01-preview: :mod:`v2018_02_01_preview.models<azure.mgmt.containerregistry.v2018_02_01_preview.models>` * 2018-09-01: :mod:`v2018_09_01.models<azure.mgmt.containerregistry.v2018_09_01.models>` """ if api_version == '2017-03-01': from .v2017_03_01 import models return models elif api_version == '2017-10-01': from .v2017_10_01 import models return models elif api_version == '2018-02-01-preview': from .v2018_02_01_preview import models return models elif api_version == '2018-09-01': from .v2018_09_01 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
[ "Module", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-containerregistry/azure/mgmt/containerregistry/container_registry_management_client.py#L95-L115
[ "def", "models", "(", "cls", ",", "api_version", "=", "DEFAULT_API_VERSION", ")", ":", "if", "api_version", "==", "'2017-03-01'", ":", "from", ".", "v2017_03_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2017-10-01'", ":", "from", ".", "v2017_10_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-02-01-preview'", ":", "from", ".", "v2018_02_01_preview", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-09-01'", ":", "from", ".", "v2018_09_01", "import", "models", "return", "models", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ContainerRegistryManagementClient.build_steps
Instance depends on the API version: * 2018-02-01-preview: :class:`BuildStepsOperations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.BuildStepsOperations>`
azure-mgmt-containerregistry/azure/mgmt/containerregistry/container_registry_management_client.py
def build_steps(self): """Instance depends on the API version: * 2018-02-01-preview: :class:`BuildStepsOperations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.BuildStepsOperations>` """ api_version = self._get_api_version('build_steps') if api_version == '2018-02-01-preview': from .v2018_02_01_preview.operations import BuildStepsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def build_steps(self): """Instance depends on the API version: * 2018-02-01-preview: :class:`BuildStepsOperations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.BuildStepsOperations>` """ api_version = self._get_api_version('build_steps') if api_version == '2018-02-01-preview': from .v2018_02_01_preview.operations import BuildStepsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-containerregistry/azure/mgmt/containerregistry/container_registry_management_client.py#L118-L128
[ "def", "build_steps", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'build_steps'", ")", "if", "api_version", "==", "'2018-02-01-preview'", ":", "from", ".", "v2018_02_01_preview", ".", "operations", "import", "BuildStepsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ContainerRegistryManagementClient.build_tasks
Instance depends on the API version: * 2018-02-01-preview: :class:`BuildTasksOperations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.BuildTasksOperations>`
azure-mgmt-containerregistry/azure/mgmt/containerregistry/container_registry_management_client.py
def build_tasks(self): """Instance depends on the API version: * 2018-02-01-preview: :class:`BuildTasksOperations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.BuildTasksOperations>` """ api_version = self._get_api_version('build_tasks') if api_version == '2018-02-01-preview': from .v2018_02_01_preview.operations import BuildTasksOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def build_tasks(self): """Instance depends on the API version: * 2018-02-01-preview: :class:`BuildTasksOperations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.BuildTasksOperations>` """ api_version = self._get_api_version('build_tasks') if api_version == '2018-02-01-preview': from .v2018_02_01_preview.operations import BuildTasksOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-containerregistry/azure/mgmt/containerregistry/container_registry_management_client.py#L131-L141
[ "def", "build_tasks", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'build_tasks'", ")", "if", "api_version", "==", "'2018-02-01-preview'", ":", "from", ".", "v2018_02_01_preview", ".", "operations", "import", "BuildTasksOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ContainerRegistryManagementClient.builds
Instance depends on the API version: * 2018-02-01-preview: :class:`BuildsOperations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.BuildsOperations>`
azure-mgmt-containerregistry/azure/mgmt/containerregistry/container_registry_management_client.py
def builds(self): """Instance depends on the API version: * 2018-02-01-preview: :class:`BuildsOperations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.BuildsOperations>` """ api_version = self._get_api_version('builds') if api_version == '2018-02-01-preview': from .v2018_02_01_preview.operations import BuildsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def builds(self): """Instance depends on the API version: * 2018-02-01-preview: :class:`BuildsOperations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.BuildsOperations>` """ api_version = self._get_api_version('builds') if api_version == '2018-02-01-preview': from .v2018_02_01_preview.operations import BuildsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-containerregistry/azure/mgmt/containerregistry/container_registry_management_client.py#L144-L154
[ "def", "builds", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'builds'", ")", "if", "api_version", "==", "'2018-02-01-preview'", ":", "from", ".", "v2018_02_01_preview", ".", "operations", "import", "BuildsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ContainerRegistryManagementClient.operations
Instance depends on the API version: * 2017-03-01: :class:`Operations<azure.mgmt.containerregistry.v2017_03_01.operations.Operations>` * 2017-10-01: :class:`Operations<azure.mgmt.containerregistry.v2017_10_01.operations.Operations>` * 2018-02-01-preview: :class:`Operations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.Operations>` * 2018-09-01: :class:`Operations<azure.mgmt.containerregistry.v2018_09_01.operations.Operations>`
azure-mgmt-containerregistry/azure/mgmt/containerregistry/container_registry_management_client.py
def operations(self): """Instance depends on the API version: * 2017-03-01: :class:`Operations<azure.mgmt.containerregistry.v2017_03_01.operations.Operations>` * 2017-10-01: :class:`Operations<azure.mgmt.containerregistry.v2017_10_01.operations.Operations>` * 2018-02-01-preview: :class:`Operations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.Operations>` * 2018-09-01: :class:`Operations<azure.mgmt.containerregistry.v2018_09_01.operations.Operations>` """ api_version = self._get_api_version('operations') if api_version == '2017-03-01': from .v2017_03_01.operations import Operations as OperationClass elif api_version == '2017-10-01': from .v2017_10_01.operations import Operations as OperationClass elif api_version == '2018-02-01-preview': from .v2018_02_01_preview.operations import Operations as OperationClass elif api_version == '2018-09-01': from .v2018_09_01.operations import Operations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def operations(self): """Instance depends on the API version: * 2017-03-01: :class:`Operations<azure.mgmt.containerregistry.v2017_03_01.operations.Operations>` * 2017-10-01: :class:`Operations<azure.mgmt.containerregistry.v2017_10_01.operations.Operations>` * 2018-02-01-preview: :class:`Operations<azure.mgmt.containerregistry.v2018_02_01_preview.operations.Operations>` * 2018-09-01: :class:`Operations<azure.mgmt.containerregistry.v2018_09_01.operations.Operations>` """ api_version = self._get_api_version('operations') if api_version == '2017-03-01': from .v2017_03_01.operations import Operations as OperationClass elif api_version == '2017-10-01': from .v2017_10_01.operations import Operations as OperationClass elif api_version == '2018-02-01-preview': from .v2018_02_01_preview.operations import Operations as OperationClass elif api_version == '2018-09-01': from .v2018_09_01.operations import Operations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-containerregistry/azure/mgmt/containerregistry/container_registry_management_client.py#L157-L176
[ "def", "operations", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'operations'", ")", "if", "api_version", "==", "'2017-03-01'", ":", "from", ".", "v2017_03_01", ".", "operations", "import", "Operations", "as", "OperationClass", "elif", "api_version", "==", "'2017-10-01'", ":", "from", ".", "v2017_10_01", ".", "operations", "import", "Operations", "as", "OperationClass", "elif", "api_version", "==", "'2018-02-01-preview'", ":", "from", ".", "v2018_02_01_preview", ".", "operations", "import", "Operations", "as", "OperationClass", "elif", "api_version", "==", "'2018-09-01'", ":", "from", ".", "v2018_09_01", ".", "operations", "import", "Operations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667