microsoftgraph / microsoftgraph/msgraph-sdk-python
skiptoken for large request responses
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 630
- フォーク
- 96
- 平均マージ
- 15時間 20分
- マージ済み PR(30日)
- 3
説明
I am looking to use the msgraph sdk for python. I want to get a list of devices in our tenant. We have thousands of devices. When using the msgraph.devices.get(), it will return 100 devices (the default limit for msgraph). Utilize the request_query=DevicesRequestBuilder.DevicesRequestBuilderGetQueryParameters(top=100,skip=100)
gives me this error msgraph.generated.models.o_data_errors.o_data_error.ODataError
After some digging in the Microsoft graph explorer for https://graph.microsoft.com/v1.0/devices?$top=100&$skip=100 gives this error
{
"error": {
"code": "Request_BadRequest",
"message": "'$skip' is not supported by the service.",
"innerError": {
"date": "2023-04-24T23:08:17",
"request-id": "e077ef6b-d848-4fba-8cce-257e7188a6ec",
"client-request-id": "4a9beda2-c3ee-0c9f-f012-5308f25f8954"
}
}
}
So, skip is not supported for devices. It is the same in the beta requests.
Since I am able to get the data_data_next_link from my initial devices.get() response, I tried
request_query=DevicesRequestBuilder.DevicesRequestBuilderGetQueryParameters(top=100,skiptoken='RNFw.....')
However, I get an error TypeError: __init__() got an unexpected keyword argument skiptoken
After digging through the code, I modified device_request_builder.py, changing the DevicesRequestBuilderGetQueryParameters(): adding
if original_name == "skiptoken":
return "%24skiptoken
......
skiptoken: Optional[str] = None
and class DevicesRequestBuilder(): modifying
self.url_template: str = "{+baseurl}/devices{?%24top,%24skip,%24search,%24filter,%24count,%24orderby,%24select,%24expand,%24skiptoken}
These make the skiptoken available and work with GetQueryParameters.
So basically modifying this module to work with the limitations of msgraph
Is there another way to accomplish paging with devices in this python module?
If not, I can try a pull request for this.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
device_request_builder.py と DevicesRequestBuilderGetQueryParameters クラスから始め、生成されたリクエストを devices response の data_data_next_link と比較します。リクエスト URL で skiptoken がどのように表現されているか、また既存の GetQueryParameters パスでそれをたどれるかを確認します。完了の条件は、デバイスのページングで、報告されているコンストラクターエラーなしに返された next link または skiptoken を使用できることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- api
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100