إنشاء الطابعات وإدارتها

توضّح طلبات العيّنات في هذه الصفحة كيفية إدارة الطابعات باستخدام Chrome Printer Management 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"
  ]
}