名前空間: microsoft.graph
重要
Microsoft Graph の /beta バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
プリンター共有のプロパティを更新します。 このメソッドは、 プリンターの交換に使用できます。
たとえば、物理プリンター デバイスが切断された場合、管理者は新しい プリンター デバイスを登録し、この プリンターを 更新できますShare ユーザーが何も操作しなくても、新しいプリンターをポイントするように共有します。
この API は、次の国内クラウド展開で使用できます。
| グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
| ✅ |
✅ |
✅ |
❌ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
| アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
| 委任 (職場または学校のアカウント) |
PrinterShare.ReadWrite.All |
注意事項なし。 |
| 委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
| アプリケーション |
サポートされていません。 |
サポートされていません。 |
HTTP 要求
PATCH /print/shares/{id}
| 名前 |
説明 |
| Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
| Content-type |
application/json. 必須です。 |
要求本文
要求本文で、更新する関連 する printerShare フィールドの値を指定します。 要求本文に含まれていない既存のプロパティは、以前の値を維持するか、他のプロパティ値の変更に基づいて再計算されます。 最適なパフォーマンスを得るために、変更されていない既存の値を含めないでください。
次の表に、更新できるプロパティの一覧を示します。
| プロパティ |
型 |
説明 |
| プリンター |
microsoft.graph.printer |
このプリンター共有が関連しているプリンター。 次の例に示すように、 printer@odata.bind 構文を使用して、このプリンター共有が関連付けられているプリンターを更新します。 |
| displayName |
文字列 |
印刷クライアントが表示するプリンター共有の名前。 |
| allowAllUsers |
ブール値 |
true場合、すべてのユーザーとグループにこのプリンター共有へのアクセス権が付与されます。 このプロパティは、 allowedUsers ナビゲーション プロパティと allowedGroups ナビゲーション プロパティによって定義された許可リストよりも優先されます。 |
注:
プリンター プロパティが更新された場合、同じ要求で他のプロパティを更新することはできません。
応答
成功した場合、このメソッドは 200 OK 応答コードと、応答本文で更新された printerShare オブジェクトを返します。
例
要求
次の例は要求を示しています。
PATCH https://graph.microsoft.com/beta/print/shares/{id}
Content-type: application/json
{
"displayName": "ShareName",
"allowAllUsers": true,
"printer@odata.bind": "https://graph.microsoft.com/beta/print/printers/{id}"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new PrinterShare
{
DisplayName = "ShareName",
AllowAllUsers = true,
AdditionalData = new Dictionary<string, object>
{
{
"printer@odata.bind" , "https://graph.microsoft.com/beta/print/printers/{id}"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Print.Shares["{printerShare-id}"].PatchAsync(requestBody);
// 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"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewPrinterShare()
displayName := "ShareName"
requestBody.SetDisplayName(&displayName)
allowAllUsers := true
requestBody.SetAllowAllUsers(&allowAllUsers)
additionalData := map[string]interface{}{
"printer@odata.bind" : "https://graph.microsoft.com/beta/print/printers/{id}",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
shares, err := graphClient.Print().Shares().ByPrinterShareId("printerShare-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
PrinterShare printerShare = new PrinterShare();
printerShare.setDisplayName("ShareName");
printerShare.setAllowAllUsers(true);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("printer@odata.bind", "https://graph.microsoft.com/beta/print/printers/{id}");
printerShare.setAdditionalData(additionalData);
PrinterShare result = graphClient.print().shares().byPrinterShareId("{printerShare-id}").patch(printerShare);
const options = {
authProvider,
};
const client = Client.init(options);
const printerShare = {
displayName: 'ShareName',
allowAllUsers: true,
'printer@odata.bind': 'https://graph.microsoft.com/beta/print/printers/{id}'
};
await client.api('/print/shares/{id}')
.version('beta')
.update(printerShare);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\PrinterShare;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new PrinterShare();
$requestBody->setDisplayName('ShareName');
$requestBody->setAllowAllUsers(true);
$additionalData = [
'printer@odata.bind' => 'https://graph.microsoft.com/beta/print/printers/{id}',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->escapedPrint()->shares()->byPrinterShareId('printerShare-id')->patch($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Devices.CloudPrint
$params = @{
displayName = "ShareName"
allowAllUsers = $true
"printer@odata.bind" = "https://graph.microsoft.com/beta/print/printers/{id}"
}
Update-MgBetaPrintShare -PrinterShareId $printerShareId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.printer_share import PrinterShare
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = PrinterShare(
display_name = "ShareName",
allow_all_users = True,
additional_data = {
"printer@odata_bind" : "https://graph.microsoft.com/beta/print/printers/{id}",
}
)
result = await graph_client.print.shares.by_printer_share_id('printerShare-id').patch(request_body)
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#print/shares/$entity",
"id": "d837c17b-3296-4384-a053-828d56e10f50",
"displayName": "ShareName",
"createdDateTime": "2020-02-04T00:00:00.0000000Z",
"isAcceptingJobs": true,
"allowAllUsers": true,
"status": {
"state": "stopped",
"details": ["disconnected"],
"description": ""
}
}