名前空間: microsoft.graph
重要
Microsoft Graph の /beta バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
ドライブ リソースのプロパティとリレーションシップを取得します。
ドライブは、OneDrive や SharePoint ドキュメント ライブラリなどのファイル システムの最上位のコンテナーです。
この API は、次の国内クラウド展開で使用できます。
| グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
| ✅ |
✅ |
✅ |
✅ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
| アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
| 委任 (職場または学校のアカウント) |
Files.Read |
Files.Read.All, Files.ReadWrite, Files.ReadWrite.All、Sites.Read.All、Sites.ReadWrite.All、User.Read |
| 委任 (個人用 Microsoft アカウント) |
Files.Read |
Files.Read.All, Files.ReadWrite, Files.ReadWrite.All |
| アプリケーション |
サポートされていません。 |
サポートされていません。 |
HTTP 要求
ユーザーの現在の OneDrive を取得する
サインインしているユーザーのドライブには (代理認証を使用している場合) me シングルトンからアクセスできます。
ユーザーが OneDrive のライセンスを持っているが OneDrive がまだ設定されていない場合、この要求は代理認証を使用するときに、ユーザーのドライブを自動的にプロビジョニングします。
GET /me/drive
ユーザーの OneDrive を取得する
ユーザーの OneDrive または OneDrive for Business にアクセスするには、User リソースについてのドライブ リレーションシップをアプリが要求する必要があります。
ユーザーが OneDrive のライセンスを持っているが OneDrive がまだ設定されていない場合、この要求は代理認証を使用するときに、ユーザーのドライブを自動的にプロビジョニングします。
GET /users/{idOrUserPrincipalName}/drive
パス パラメーター
| パラメーター名 |
値 |
説明 |
|
idOrUserPrincipalName |
string |
必須。 OneDrive を所有するユーザー オブジェクトの識別子。 |
グループに関連付けられたドキュメント ライブラリを取得する
グループの既定のドキュメント ライブラリにアクセスするには、そのグループについてのドライブ リレーションシップをアプリが要求する必要があります。
GET /groups/{groupId}/drive
パス パラメーター
| パラメーター名 |
値 |
説明 |
|
groupId |
string |
必須です。 ドキュメント ライブラリを所有するグループの識別子。 |
サイトのドキュメント ライブラリを取得する
サイトの既定のドキュメント ライブラリにアクセスするには、そのサイトについてのドライブ リレーションシップをアプリが要求する必要があります。
GET /sites/{siteId}/drive
パス パラメーター
| パラメーター名 |
値 |
説明 |
|
siteId |
string |
必須。 ドキュメント ライブラリを含むサイトの識別子。 |
ID によりドライブを取得する
ドライブの一意の識別子を持っている場合、最上位ドライブのコレクションから直接アクセスできます。
GET /drives/{driveId}
パス パラメーター
| パラメーター名 |
値 |
説明 |
|
driveId |
string |
必須。 要求されるドライブの識別子。 |
オプションのクエリ パラメーター
これらのメソッドは、応答を形成するための $select クエリ パラメーター をサポートします。
応答
各メソッドは、一致するドライブに応じた Drive リソースを応答本文で返します。
エラー応答コード
ドライブが存在せず、(代理認証を使用する場合に) 自動的にプロビジョニングできない場合は、 HTTP 404 応答が返されます。
例
例 1: ドライブを取得する
要求
次の例は要求を示しています。
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Drive.GetAsync();
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
drive, err := graphClient.Me().Drive().Get(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Drive result = graphClient.me().drive().get();
const options = {
authProvider,
};
const client = Client.init(options);
let drive = await client.api('/me/drive')
.version('beta')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->me()->drive()->get()->wait();
Import-Module Microsoft.Graph.Beta.Files
# A UPN can also be used as -UserId.
Get-MgBetaUserDefaultDrive -UserId $userId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.me.drive.get()
応答
次の例は応答を示しています。
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "b!t18F8ybsHUq1z3LTz8xvZqP8zaSWjkFNhsME-Fepo75dTf9vQKfeRblBZjoSQrd7",
"driveType": "business",
"owner": {
"user": {
"id": "efee1b77-fb3b-4f65-99d6-274c11914d12",
"displayName": "Ryan Gregg"
}
},
"quota": {
"deleted": 256938,
"remaining": 1099447353539,
"state": "normal",
"total": 1099511627776
}
}
例 2: ドライブとその設定を取得する
既定では、 settings プロパティは返されません。 次の例では、 $select を使用して、応答で明示的に要求します。
要求
次の例は要求を示しています。
GET /drives/b!t18F8ybsHUq1z3LTz8xvZqP8zaSWjkFNhsME-Fepo75dTf9vQKfeRblBZjoSQrd7?$select=id,settings
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Drives["{drive-id}"].GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Select = new string []{ "id","settings" };
});
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphdrives "github.com/microsoftgraph/msgraph-beta-sdk-go/drives"
//other-imports
)
requestParameters := &graphdrives.DriveItemRequestBuilderGetQueryParameters{
Select: [] string {"id","settings"},
}
configuration := &graphdrives.DriveItemRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
drives, err := graphClient.Drives().ByDriveId("drive-id").Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Drive result = graphClient.drives().byDriveId("{drive-id}").get(requestConfiguration -> {
requestConfiguration.queryParameters.select = new String []{"id", "settings"};
});
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Drives\Item\DriveItemRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new DriveItemRequestBuilderGetRequestConfiguration();
$queryParameters = DriveItemRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->select = ["id","settings"];
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->drives()->byDriveId('drive-id')->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Files
Get-MgBetaDrive -DriveId $driveId -Property "id,settings"
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.drives.item.drive_item_request_builder import DriveItemRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = DriveItemRequestBuilder.DriveItemRequestBuilderGetQueryParameters(
select = ["id","settings"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.drives.by_drive_id('drive-id').get(request_configuration = request_configuration)
応答
次の例は応答を示しています。
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "b!t18F8ybsHUq1z3LTz8xvZqP8zaSWjkFNhsME-Fepo75dTf9vQKfeRblBZjoSQrd7",
"settings": {
"itemDefaultSensitivityLabelId": "bf7ea563-b848-4ec8-9155-b2054564cfe4"
}
}