Source code for airflow.providers.microsoft.azure.sensors.msgraph
## Licensed to the Apache Software Foundation (ASF) under one# or more contributor license agreements. See the NOTICE file# distributed with this work for additional information# regarding copyright ownership. The ASF licenses this file# to you under the Apache License, Version 2.0 (the# "License"); you may not use this file except in compliance# with the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing,# software distributed under the License is distributed on an# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY# KIND, either express or implied. See the License for the# specific language governing permissions and limitations# under the License.from__future__importannotationsfromcollections.abcimportSequencefromtypingimportTYPE_CHECKING,Any,Callablefromairflow.exceptionsimportAirflowExceptionfromairflow.providers.common.compat.standard.triggersimportTimeDeltaTriggerfromairflow.providers.microsoft.azure.hooks.msgraphimportKiotaRequestAdapterHookfromairflow.providers.microsoft.azure.triggers.msgraphimportMSGraphTrigger,ResponseSerializerfromairflow.sensors.baseimportBaseSensorOperatorifTYPE_CHECKING:fromdatetimeimporttimedeltafromioimportBytesIOfromkiota_abstractions.request_informationimportQueryParamsfromkiota_http.httpx_request_adapterimportResponseTypefrommsgraph_coreimportAPIVersionfromairflow.utils.contextimportContext
[docs]classMSGraphSensor(BaseSensorOperator):""" A Microsoft Graph API sensor which allows you to poll an async REST call to the Microsoft Graph API. :param url: The url being executed on the Microsoft Graph API (templated). :param response_type: The expected return type of the response as a string. Possible value are: `bytes`, `str`, `int`, `float`, `bool` and `datetime` (default is None). :param method: The HTTP method being used to do the REST call (default is GET). :param conn_id: The HTTP Connection ID to run the operator against (templated). :param proxies: A dict defining the HTTP proxies to be used (default is None). :param api_version: The API version of the Microsoft Graph API to be used (default is v1). You can pass an enum named APIVersion which has 2 possible members v1 and beta, or you can pass a string as `v1.0` or `beta`. :param event_processor: Function which checks the response from MS Graph API (default is the `default_event_processor` method) and returns a boolean. When the result is True, the sensor will stop poking, otherwise it will continue until it's True or times out. :param result_processor: Function to further process the response from MS Graph API (default is lambda: context, response: response). When the response returned by the `KiotaRequestAdapterHook` are bytes, then those will be base64 encoded into a string. :param serializer: Class which handles response serialization (default is ResponseSerializer). Bytes will be base64 encoded into a string, so it can be stored as an XCom. """