درخواستهای نمونه در این صفحه نحوه مدیریت چاپگرها را با استفاده از API مدیریت چاپگر کروم نشان میدهد.
تمام درخواستهای نمونه از متغیرهای زیر استفاده میکنند:
-
TOKEN: توکن OAuth 2.0 برنامه شما. -
CUSTOMER_ID: شناسه مشتری منحصر به فرد حساب سازمانی، که با "C" شروع میشود. (مثال:C123abc4) همچنین میتوانیدmy_customerبرای مشخص کردن شناسه مشتری حساب خود وارد کنید.
فهرست مدلهای چاپگر
این نمونه لیستی از تمام مدلهای چاپگر پشتیبانیشده را درخواست میکند.
درخواست
curl -X GET \
--header "Authorization: Bearer TOKEN" \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers:listPrinterModels"
پاسخ
{
"printerModels": [
{
"manufacturer": "Anitech",
"displayName": "Anitech M24",
"makeAndModel": "anitech m24"
},
{
"manufacturer": "Apollo",
"displayName": "Apollo P-2100",
"makeAndModel": "apollo apollo 2100"
},
//...
{
"manufacturer": "Brother",
"displayName": "Brother DCP-7025",
"makeAndModel": "brother dcp-7025"
},
//...
],
"nextPageToken": "CGQQAQ=="
}
فهرست کردن یا جستجوی چاپگرها
این نمونه لیستی از تمام چاپگرهایی را درخواست میکند که در شناسه واحد سازمانی 04fatzly26exj7b قابل مشاهده هستند و شامل کلمه Lobby در نام نمایشی یا توضیحات چاپگر هستند. چاپگرهای اضافه شده در یک واحد سازمانی والد برای واحدهای سازمانی فرزند قابل مشاهده هستند، بنابراین پاسخ ممکن است شامل چاپگرهایی باشد که در واحد سازمانی 04fatzly26exj7b نیستند.
درخواست
curl -X GET \
--header "Authorization: Bearer TOKEN" \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers?orgUnitId=04fatzly26exj7b&filter=Lobby"
پاسخ
{
"printers": [
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs2zla0y7",
"id": "0gjdgxs2zla0y7",
"displayName": "Jupiter",
"description": "Guest printer in lobby Building C.",
"makeAndModel": "xerox able 1406",
"uri": "ipp://192.168.10.13",
"createTime": "2021-03-11T21:41:34.779587Z",
"orgUnitId": "04fatzly26exj7b"
},
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs1eqkb60",
"id": "0gjdgxs1eqkb60",
"displayName": "Mars",
"description": "Printer in Lobby Building A",
"uri": "ipp://192.168.10.11",
"createTime": "2021-03-11T22:02:06.048469Z",
"orgUnitId": "04fatzly4jbjho9",
"useDriverlessConfig": true
}
]
}
یک چاپگر خاص تهیه کنید
این نمونه جزئیات چاپگری با شناسه 0gjdgxs2zla0y7 را درخواست میکند.
درخواست
curl -X GET \
--header "Authorization: Bearer TOKEN" \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers/0gjdgxs2zla0y7"
پاسخ
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs2zla0y7",
"id": "0gjdgxs2zla0y7",
"displayName": "Jupiter",
"description": "Guest printer in lobby Building C.",
"makeAndModel": "xerox able 1406",
"uri": "ipp://192.168.10.13",
"createTime": "2021-03-11T21:41:34.779587Z",
"orgUnitId": "04fatzly26exj7b"
}
ایجاد یک چاپگر
این نمونه یک چاپگر جدید در واحد سازمانی با شناسه 04fatzly26exj7b اضافه میکند.
درخواست
curl -X POST \
-H "Content-Type: application/json" \
--header "Authorization: Bearer TOKEN" \
-d '{
"displayName": "Mercury",
"description": "Printer in the kitchen",
"makeAndModel": "xerox able 1406",
"uri": "ipp://192.168.10.14",
"orgUnitId": "04fatzly26exj7b"
}' \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers"
پاسخ
یک پاسخ موفقیتآمیز شامل شناسه چاپگر تازه ایجاد شده است:
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs0o422uq",
"id": "0gjdgxs0o422uq",
"displayName": "Mercury",
"description": "Printer in the kitchen",
"makeAndModel": "xerox able 1406",
"uri": "ipp://192.168.10.14",
"createTime": "2021-03-11T23:19:27.180846Z",
"orgUnitId": "04fatzly26exj7b"
}
بهروزرسانی یک چاپگر
این نمونه توضیحات شناسه چاپگر 0gjdgxs0o422uq را بهروزرسانی میکند.
درخواست
curl -X PATCH \
-H "Content-Type: application/json" \
--header "Authorization: Bearer TOKEN" \
-d '{
"description": "Printer in the office"
}' \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers/0gjdgxs0o422uq?updateMask=description"
پاسخ
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs0o422uq",
"id": "0gjdgxs0o422uq",
"displayName": "Mercury",
"description": "Printer in the office",
"makeAndModel": "xerox able 1406",
"uri": "ipp://192.168.10.14",
"createTime": "2021-03-11T23:19:27.180846Z",
"orgUnitId": "04fatzly26exj7b"
}
حذف یک چاپگر
این نمونه شناسه چاپگر 0gjdgxs0o422uq را حذف میکند.
درخواست
curl -X DELETE \
--header "Authorization: Bearer TOKEN" \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers/0gjdgxs0o422uq"
پاسخ
یک پاسخ موفق خالی است. {}
ایجاد چندین چاپگر در یک درخواست
این نمونه با استفاده از متد batchCreatePrinters ، چندین چاپگر را در یک درخواست واحد ایجاد میکند.
درخواست
curl -X POST \
-H "Content-Type: application/json" \
--header "Authorization: Bearer TOKEN" \
-d '{
"requests": [
{
"parent": "customers/CUSTOMER_ID",
"printer": {
"displayName": "Earth",
"description": "Color printer",
"useDriverlessConfig": true,
"uri": "ipp://192.168.10.15",
"orgUnitId": "04fatzly26exj7b"
}
},
{
"parent": "customers/CUSTOMER_ID",
"printer": {
"displayName": "Saturn",
"description": "Color printer",
"useDriverlessConfig": true,
"uri": "ipp://192.168.10.16",
"orgUnitId": "04fatzly26exj7b"
}
}
]
}' \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers:batchCreatePrinters"
پاسخ
{
"printers": [
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs0sbbh87",
"id": "0gjdgxs0sbbh87",
"displayName": "Saturn",
"description": "Color printer",
"uri": "ipp://192.168.10.16",
"createTime": "2021-03-12T01:10:32.957084Z",
"orgUnitId": "04fatzly26exj7b",
"useDriverlessConfig": true
},
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs2d6170e",
"id": "0gjdgxs2d6170e",
"displayName": "Earth",
"description": "Color printer",
"uri": "ipp://192.168.10.15",
"createTime": "2021-03-12T01:10:32.956735Z",
"orgUnitId": "04fatzly26exj7b",
"useDriverlessConfig": true
}
]
}
حذف چندین چاپگر در یک درخواست
این نمونه با استفاده از متد batchDeletePrinters چندین چاپگر را در یک درخواست واحد حذف میکند.
درخواست
curl -X POST \
-H "Content-Type: application/json" \
--header "Authorization: Bearer TOKEN" \
-d '{
"printerIds": ["0gjdgxs0sbbh87", "0gjdgxs2d6170e"]
}' \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers:batchDeletePrinters"
پاسخ
یک پاسخ موفقیتآمیز شامل شناسههای سرورهای چاپی است که حذف شدهاند:
{
"printerIds": [
"0gjdgxs2d6170e",
"0gjdgxs0sbbh87"
]
}