def get()

in ees_microsoft_teams/microsoft_teams_requests.py [0:0]


    def get(self, url, object_type):
        """Invokes a GET call to the Microsoft Graph API
        :param url: Request URL to call the Graph API
        :param object_type: The type of the object to get. The allowed values are teams, channels, channel_chat,
            channel_documents, user_chats, etc.
        Returns:
            Parsed object of the GET call
        """
        try:
            response = requests.get(url, headers={"Authorization": f"Bearer {self.access_token}"})
            status_code = response.status_code

            if status_code not in [200, 403, 404]:
                raise RequestException(
                    f"{response.reason}. Error while fetching {object_type} from Microsoft "
                    f"Teams, url: {url}"
                )

            if status_code == requests.codes.ok:
                return self.parse_response_object(response)

            elif status_code in range(400, 500):
                if status_code == 401:
                    self.regenerate_token(object_type=object_type)
                    raise UnauthorizedException
                elif status_code == 429:
                    retry_after_seconds = int(response.headers.get("Retry-After", 60))
                    time.sleep(retry_after_seconds)
                    raise TooManyRequestException(
                        message="Received TooManyRequestException while fetching the Teams"
                    )
                else:
                    return self.handle_4xx_errors(
                        response=response, object_type=object_type, request_url=url
                    )
        except RequestException as exception:
            raise exception