प्रिंटर बनाएं और प्रबंधित करें

इस पेज पर दिए गए सैंपल अनुरोधों में बताया गया है कि Chrome प्रिंटर मैनेजमेंट एपीआई की मदद से प्रिंटर कैसे मैनेज किए जाते हैं.

सैंपल के लिए किए गए सभी अनुरोधों में, इन वैरिएबल का इस्तेमाल किया जाता है:

  • $TOKEN: आपके ऐप्लिकेशन का OAuth 2.0 टोकन.
  • $CUSTOMER: एंटरप्राइज़ खाते का यूनीक ग्राहक आईडी, जिसे "C" से पहले जोड़ा जाता है. (उदाहरण: C123abc4) अपने खाते का ग्राहक आईडी दिखाने के लिए, आप my_customer भी डाल सकते हैं.

प्रिंटर के मॉडल की सूची बनाना

इस सैंपल के लिए, ऐसे सभी प्रिंटर मॉडल की सूची का अनुरोध किया जाता है जिनका इस्तेमाल किया जा सकता है.

अनुरोध

  curl -X GET \
  --header "Authorization: Bearer $TOKEN" \
  "https://admin.googleapis.com/admin/directory/v1/customers/$CUSTOMER/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 शब्द शामिल है.

अनुरोध

  curl -X GET  \
  --header "Authorization: Bearer $TOKEN" \
  "https://admin.googleapis.com/admin/directory/v1/customers/$CUSTOMER/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" // Note: This printer was created in the same OU that we are searching within.
    },
    {
      "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", // Note: This printer was added in parent OU, yet is visible from the OU we are searching within.
      "useDriverlessConfig": true
    }
  ]
}

कोई विशेष प्रिंटर खरीदें

यह सैंपल, 0gjdgxs2zla0y7 आईडी वाले प्रिंटर के लिए जानकारी का अनुरोध करता है.

अनुरोध

  curl -X GET  \
  --header "Authorization: Bearer $TOKEN" \
  "https://admin.googleapis.com/admin/directory/v1/customers/$CUSTOMER/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/chrome/printers"

जवाब

{
  "name": "customers/C0202nabg/chrome/printers/0gjdgxs0o422uq",
  "id": "0gjdgxs0o422uq", // Note: This is the ID of the newly created printer.
  "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/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/chrome/printers/0gjdgxs0o422uq"

जवाब

सही जवाब वाला फ़ील्ड खाली है. {}

एक अनुरोध में एक से ज़्यादा प्रिंटर बनाएं

यह सैंपल, batchCreatePrinters तरीके का इस्तेमाल करके, एक ही अनुरोध में कई प्रिंटर बनाता है.

अनुरोध

curl -X POST \
  -H "Content-Type: application/json" \
  --header "Authorization: Bearer $TOKEN" \
  -d '{
    "requests": [
      {
        "parent": "customers/$CUSTOMER",
        "printer": {
          "displayName": "Earth",
          "description": "Color printer",
          "useDriverlessConfig": true,
          "uri": "ipp://192.168.10.15",
          "orgUnitId": "04fatzly26exj7b"
        }
    },
    {
        "parent": "customers/$CUSTOMER",
        "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/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/chrome/printers:batchDeletePrinters"

जवाब

{
  "printerIds": [ // Successfully deleted printers.
    "0gjdgxs2d6170e",
    "0gjdgxs0sbbh87"
  ]
}