درخواستهای نمونه در این صفحه نحوه مدیریت سرورهای چاپ با API مدیریت چاپگر Chrome را نشان میدهند.
تمام درخواستهای نمونه از متغیرهای زیر استفاده میکنند:
-
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/printServers"
پاسخ
{
"printServers": [
{
"name": "customers/C0202nabg/chrome/printServers/0gjdgxs2zla0y7",
"id": "0gjdgxs2zla0y7",
"displayName": "Marketing Print Server",
"description": "Queue for corp marketing oversize jobs",
"uri": "ipp://192.168.10.13",
"createTime": "2021-03-11T21:41:34.779587Z",
"orgUnitId": "04fatzly26exj7b"
},
{
"name": "customers/C0202nabg/chrome/printServers/0gjdgxs1eqkb32",
"id": "0gjdgxs1eqkb32",
"displayName": "Production",
"description": "Production print server for user manuals",
"uri": "ipp://192.168.10.11",
"createTime": "2021-03-11T22:02:06.048469Z",
"orgUnitId": "04fatzly4jbjho9"
}
]
}
یک سرور چاپ خاص دریافت کنید
این نمونه جزئیات مربوط به یک سرور چاپ با شناسه 0gjdgxs2zla0y7 را درخواست میکند.
درخواست
curl -X GET \
--header "Authorization: Bearer TOKEN" \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printServers/0gjdgxs2zla0y7"
پاسخ
{
"name": "customers/C0234nab1/chrome/printServers/0gjdgxs2zla0y7",
"id": "0gjdgxs2zla0y7",
"displayName": "Marketing Print Server",
"description": "Queue for corp marketing oversize jobs",
"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": "hr-dept",
"description": "HR queue for sensitive documents",
"uri": "ipp://192.168.10.14",
"orgUnitId": "04fatzly26exj7b"
}' \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printServers"
پاسخ
یک پاسخ موفقیتآمیز شامل شناسه سرور چاپ تازه ایجاد شده است:
{
"name": "customers/C0234nab1/chrome/printServers/0gjdgxs0o422uq",
"id": "0gjdgxs0o422uq",
"displayName": "hr-dept",
"description": "HR queue for sensitive documents",
"uri": "ipp://192.168.10.14",
"orgUnitId": "04fatzly26exj7b",
"createTime": "2021-03-11T23:19:27.180846Z",
"orgUnitId": "04fatzly26exj7b"
}
بهروزرسانی سرور چاپ
این نمونه توضیحات مربوط به شناسه سرور چاپ 0gjdgxs0o422uq را بهروزرسانی میکند.
درخواست
curl -X PATCH \
-H "Content-Type: application/json" \
--header "Authorization: Bearer TOKEN" \
-d '{
"description": "General HR dept print server",
}' \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printServers/0gjdgxs0o422uq?updateMask=description"
پاسخ
{
"name": "customers/C0234nab1/chrome/printServers/0gjdgxs0o422uq",
"id": "0gjdgxs0o422uq",
"displayName": "hr-dept",
"description": "General HR dept print server",
"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/printServers/0gjdgxs0o422uq"
پاسخ
یک پاسخ موفق خالی است.
ایجاد چندین سرور چاپ با یک درخواست
این نمونه با استفاده از متد batchCreatePrintServers چندین سرور چاپ ایجاد میکند.
درخواست
curl -X POST \
-H "Content-Type: application/json" \
--header "Authorization: Bearer TOKEN" \
-d '{
"requests": [
{
"parent": "customers/CUSTOMER_ID",
"printServer": {
"displayName": "General print server",
"description": "Org-wide print queue",
"uri": "ipp://192.168.10.15",
"orgUnitId": "04fatzly26exj7b"
}
},
{
"parent": "customers/CUSTOMER_ID",
"printServer": {
"displayName": "Engineering print server",
"description": "Print server for Engineering use only",
"uri": "ipp://192.168.10.16",
"orgUnitId": "04fatzly26exj7b"
}
}
]
}' \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printServers:batchCreatePrintServers"
پاسخ
{
"printServers": [
{
"name": "customers/C0234nab1/chrome/printServers/0gjdgxs0sbbh87",
"id": "0gjdgxs0sbbh87",
"displayName": "General print server",
"description": "Org-wide print queue",
"uri": "ipp://192.168.10.15",
"createTime": "2021-03-12T01:10:32.957084Z",
"orgUnitId": "04fatzly26exj7b"
},
{
"name": "customers/C0234nab1/chrome/printServers/0gjdgxs2d6170e",
"id": "0gjdgxs2d6170e",
"displayName": "Engineering print server",
"description": "Print server for Engineering use only",
"uri": "ipp://192.168.10.16",
"createTime": "2021-03-12T01:10:32.956735Z",
"orgUnitId": "04fatzly26exj7b"
}
]
}
حذف چندین سرور چاپ در یک درخواست
این نمونه با استفاده از متد batchDeletePrintServers ، چندین سرور چاپ را در یک درخواست واحد حذف میکند.
درخواست
curl -X POST \
-H "Content-Type: application/json" \
--header "Authorization: Bearer TOKEN" \
-d '{
"printServerIds": ["0gjdgxs0sbbh87", "0gjdgxs2d6170e"]
}' \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printServers:batchDeletePrintServers"
پاسخ
یک پاسخ موفقیتآمیز شامل شناسههای سرورهای چاپی است که حذف شدهاند:
{
"printServerIds": [
"0gjdgxs2d6170e",
"0gjdgxs0sbbh87"
]
}